From 9d605e2f6fbdd5f4680d81982b0f86b9391b6143 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 10 Dec 2024 10:15:41 +0800 Subject: [PATCH 01/93] https://gitee.com/ark_standalone_build/test262_sendable to https://gitee.com/ark_compiler_sendable/test262_sendable change Signed-off-by: zhuzhihui7 --- LICENSE | 2 +- README.en.md | 14 + README.md | 14 + harness/assert.js | 130 + harness/assertRelativeDateMs.js | 37 + harness/async-gc.js | 69 + harness/asyncHelpers.js | 123 + harness/atomicsHelper.js | 336 +++ harness/byteConversionValues.js | 458 +++ harness/compareArray.js | 62 + harness/compareIterator.js | 47 + harness/dateConstants.js | 41 + harness/decimalToHexString.js | 38 + harness/deepEqual.js | 339 +++ harness/detachArrayBuffer.js | 28 + harness/doneprintHandle.js | 34 + harness/features.yml | 6 + harness/fnGlobalObject.js | 24 + harness/hidden-constructors.js | 29 + harness/isConstructor.js | 34 + harness/nans.js | 34 + harness/nativeFunctionMatcher.js | 232 ++ harness/promiseHelper.js | 87 + harness/propertyHelper.js | 266 ++ harness/proxyTrapsHelper.js | 43 + harness/regExpUtils.js | 123 + harness/sta.js | 39 + harness/tcoHelper.js | 26 + harness/temporalHelpers.js | 2086 ++++++++++++++ harness/testAtomics.js | 135 + harness/testBigIntTypedArray.js | 52 + harness/testIntl.js | 2510 +++++++++++++++++ harness/testTypedArray.js | 134 + harness/timer.js | 42 + harness/typeCoercion.js | 463 +++ harness/wellKnownIntrinsicObjects.js | 302 ++ package.json | 31 + test/sendable/builtins/ASON/15.12-0-1.js | 27 + test/sendable/builtins/ASON/15.12-0-2.js | 28 + test/sendable/builtins/ASON/15.12-0-3.js | 28 + test/sendable/builtins/ASON/15.12-0-4.js | 34 + .../builtins/ASON/Symbol.toStringTag.js | 33 + .../builtins/ASON/parse/15.12.1.1-0-1.js | 23 + .../builtins/ASON/parse/15.12.1.1-0-2.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-3.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-4.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-5.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-6.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-8.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-9.js | 25 + .../builtins/ASON/parse/15.12.1.1-g1-1.js | 25 + .../builtins/ASON/parse/15.12.1.1-g1-2.js | 25 + .../builtins/ASON/parse/15.12.1.1-g1-3.js | 25 + .../builtins/ASON/parse/15.12.1.1-g1-4.js | 25 + .../builtins/ASON/parse/15.12.1.1-g2-1.js | 21 + .../builtins/ASON/parse/15.12.1.1-g2-2.js | 23 + .../builtins/ASON/parse/15.12.1.1-g2-3.js | 23 + .../builtins/ASON/parse/15.12.1.1-g2-4.js | 23 + .../builtins/ASON/parse/15.12.1.1-g2-5.js | 23 + .../builtins/ASON/parse/15.12.1.1-g4-1.js | 25 + .../builtins/ASON/parse/15.12.1.1-g4-2.js | 25 + .../builtins/ASON/parse/15.12.1.1-g4-3.js | 25 + .../builtins/ASON/parse/15.12.1.1-g4-4.js | 25 + .../builtins/ASON/parse/15.12.1.1-g5-1.js | 23 + .../builtins/ASON/parse/15.12.1.1-g5-2.js | 25 + .../builtins/ASON/parse/15.12.1.1-g5-3.js | 25 + .../builtins/ASON/parse/15.12.1.1-g6-1.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-2.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-3.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-4.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-5.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-6.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-7.js | 23 + .../builtins/ASON/parse/15.12.2-2-1.js | 61 + .../builtins/ASON/parse/15.12.2-2-10.js | 61 + .../builtins/ASON/parse/15.12.2-2-2.js | 61 + .../builtins/ASON/parse/15.12.2-2-3.js | 61 + .../builtins/ASON/parse/15.12.2-2-4.js | 61 + .../builtins/ASON/parse/15.12.2-2-5.js | 61 + .../builtins/ASON/parse/15.12.2-2-6.js | 61 + .../builtins/ASON/parse/15.12.2-2-7.js | 61 + .../builtins/ASON/parse/15.12.2-2-8.js | 61 + .../builtins/ASON/parse/15.12.2-2-9.js | 61 + .../builtins/ASON/parse/S15.12.2_A1.js | 30 + .../builtins/ASON/parse/invalid-whitespace.js | 86 + .../stringify/value-bigint-cross-realm.js | 31 + .../ASON/stringify/value-bigint-order.js | 54 + .../ASON/stringify/value-bigint-replacer.js | 36 + .../builtins/ASON/stringify/value-bigint.js | 24 + .../stringify/value-string-escape-unicode.js | 48 + test262/data/package.json | 31 + 91 files changed, 10314 insertions(+), 1 deletion(-) create mode 100644 harness/assert.js create mode 100644 harness/assertRelativeDateMs.js create mode 100644 harness/async-gc.js create mode 100644 harness/asyncHelpers.js create mode 100644 harness/atomicsHelper.js create mode 100644 harness/byteConversionValues.js create mode 100644 harness/compareArray.js create mode 100644 harness/compareIterator.js create mode 100644 harness/dateConstants.js create mode 100644 harness/decimalToHexString.js create mode 100644 harness/deepEqual.js create mode 100644 harness/detachArrayBuffer.js create mode 100644 harness/doneprintHandle.js create mode 100644 harness/features.yml create mode 100644 harness/fnGlobalObject.js create mode 100644 harness/hidden-constructors.js create mode 100644 harness/isConstructor.js create mode 100644 harness/nans.js create mode 100644 harness/nativeFunctionMatcher.js create mode 100644 harness/promiseHelper.js create mode 100644 harness/propertyHelper.js create mode 100644 harness/proxyTrapsHelper.js create mode 100644 harness/regExpUtils.js create mode 100644 harness/sta.js create mode 100644 harness/tcoHelper.js create mode 100644 harness/temporalHelpers.js create mode 100644 harness/testAtomics.js create mode 100644 harness/testBigIntTypedArray.js create mode 100644 harness/testIntl.js create mode 100644 harness/testTypedArray.js create mode 100644 harness/timer.js create mode 100644 harness/typeCoercion.js create mode 100644 harness/wellKnownIntrinsicObjects.js create mode 100644 package.json create mode 100644 test/sendable/builtins/ASON/15.12-0-1.js create mode 100644 test/sendable/builtins/ASON/15.12-0-2.js create mode 100644 test/sendable/builtins/ASON/15.12-0-3.js create mode 100644 test/sendable/builtins/ASON/15.12-0-4.js create mode 100644 test/sendable/builtins/ASON/Symbol.toStringTag.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-5.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-6.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-8.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-9.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g1-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g1-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g1-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g1-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-5.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g4-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g4-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g4-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g4-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g5-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g5-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g5-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-5.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-6.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-7.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-10.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-5.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-6.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-7.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-8.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-9.js create mode 100644 test/sendable/builtins/ASON/parse/S15.12.2_A1.js create mode 100644 test/sendable/builtins/ASON/parse/invalid-whitespace.js create mode 100644 test/sendable/builtins/ASON/stringify/value-bigint-cross-realm.js create mode 100644 test/sendable/builtins/ASON/stringify/value-bigint-order.js create mode 100644 test/sendable/builtins/ASON/stringify/value-bigint-replacer.js create mode 100644 test/sendable/builtins/ASON/stringify/value-bigint.js create mode 100644 test/sendable/builtins/ASON/stringify/value-string-escape-unicode.js create mode 100644 test262/data/package.json diff --git a/LICENSE b/LICENSE index 29f81d812f3..c9db8b287c9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ Apache License - Version 2.0, January 2004 + Version 2.0, January 2024 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION diff --git a/README.en.md b/README.en.md index 37e4cb93c14..e4013df8392 100644 --- a/README.en.md +++ b/README.en.md @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ # test262_sendable #### Description diff --git a/README.md b/README.md index 3462fb7652b..8bd8055c06f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ # test262_sendable #### 介绍 diff --git a/harness/assert.js b/harness/assert.js new file mode 100644 index 00000000000..c3373464f08 --- /dev/null +++ b/harness/assert.js @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of assertion functions used throughout test262 +defines: [assert] +---*/ + + +function assert(mustBeTrue, message) { + if (mustBeTrue === true) { + return; + } + + if (message === undefined) { + message = 'Expected true but got ' + assert._toString(mustBeTrue); + } + throw new Test262Error(message); +} + +assert._isSameValue = function (a, b) { + if (a === b) { + // Handle +/-0 vs. -/+0 + return a !== 0 || 1 / a === 1 / b; + } + + // Handle NaN vs. NaN + return a !== a && b !== b; +}; + +assert.sameValue = function (actual, expected, message) { + try { + if (assert._isSameValue(actual, expected)) { + return; + } + } catch (error) { + throw new Test262Error(message + ' (_isSameValue operation threw) ' + error); + return; + } + + if (message === undefined) { + message = ''; + } else { + message += ' '; + } + + message += 'Expected SameValue(«' + assert._toString(actual) + '», «' + assert._toString(expected) + '») to be true'; + + throw new Test262Error(message); +}; + +assert.notSameValue = function (actual, unexpected, message) { + if (!assert._isSameValue(actual, unexpected)) { + return; + } + + if (message === undefined) { + message = ''; + } else { + message += ' '; + } + + message += 'Expected SameValue(«' + assert._toString(actual) + '», «' + assert._toString(unexpected) + '») to be false'; + + throw new Test262Error(message); +}; + +assert.throws = function (expectedErrorConstructor, func, message) { + var expectedName, actualName; + if (typeof func !== "function") { + throw new Test262Error('assert.throws requires two arguments: the error constructor ' + + 'and a function to run'); + return; + } + if (message === undefined) { + message = ''; + } else { + message += ' '; + } + + try { + func(); + } catch (thrown) { + if (typeof thrown !== 'object' || thrown === null) { + message += 'Thrown value was not an object!'; + throw new Test262Error(message); + } else if (thrown.constructor !== expectedErrorConstructor) { + expectedName = expectedErrorConstructor.name; + actualName = thrown.constructor.name; + if (expectedName === actualName) { + message += 'Expected a ' + expectedName + ' but got a different error constructor with the same name'; + } else { + message += 'Expected a ' + expectedName + ' but got a ' + actualName; + } + throw new Test262Error(message); + } + return; + } + + message += 'Expected a ' + expectedErrorConstructor.name + ' to be thrown but no exception was thrown at all'; + throw new Test262Error(message); +}; + +assert._toString = function (value) { + try { + if (value === 0 && 1 / value === -Infinity) { + return '-0'; + } + + return String(value); + } catch (err) { + if (err.name === 'TypeError') { + return Object.prototype.toString.call(value); + } + + throw err; + } +}; diff --git a/harness/assertRelativeDateMs.js b/harness/assertRelativeDateMs.js new file mode 100644 index 00000000000..eda726eb9fa --- /dev/null +++ b/harness/assertRelativeDateMs.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Verify that the given date object's Number representation describes the + correct number of milliseconds since the Unix epoch relative to the local + time zone (as interpreted at the specified date). +defines: [assertRelativeDateMs] +---*/ + +/** + * @param {Date} date + * @param {Number} expectedMs + */ +function assertRelativeDateMs(date, expectedMs) { + var actualMs = date.valueOf(); + var localOffset = date.getTimezoneOffset() * 60000; + + if (actualMs - localOffset !== expectedMs) { + throw new Test262Error( + 'Expected ' + date + ' to be ' + expectedMs + + ' milliseconds from the Unix epoch' + ); + } +} diff --git a/harness/async-gc.js b/harness/async-gc.js new file mode 100644 index 00000000000..87a4a3e73fd --- /dev/null +++ b/harness/async-gc.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Collection of functions used to capture references cleanup from garbage collectors +features: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry, Symbol, async-functions] +flags: [non-deterministic] +defines: [asyncGC, asyncGCDeref, resolveAsyncGC] +---*/ + +function asyncGC(...targets) { + var finalizationRegistry = new FinalizationRegistry(() => {}); + var length = targets.length; + + for (let target of targets) { + finalizationRegistry.register(target, 'target'); + target = null; + } + + targets = null; + + return Promise.resolve('tick').then(() => asyncGCDeref()).then(() => { + var names = []; + + // consume iterator to capture names + finalizationRegistry.cleanupSome(name => { names.push(name); }); + + if (!names || names.length != length) { + throw asyncGC.notCollected; + } + }); +} + +asyncGC.notCollected = Symbol('Object was not collected'); + +async function asyncGCDeref() { + var trigger; + + // TODO: Remove this when $262.clearKeptObject becomes documented and required + if ($262.clearKeptObjects) { + trigger = $262.clearKeptObjects(); + } + + await $262.gc(); + + return Promise.resolve(trigger); +} + +function resolveAsyncGC(err) { + if (err === asyncGC.notCollected) { + // Do not fail as GC can't provide necessary resources. + $DONE(); + return; + } + + $DONE(err); +} diff --git a/harness/asyncHelpers.js b/harness/asyncHelpers.js new file mode 100644 index 00000000000..9f48fa5a508 --- /dev/null +++ b/harness/asyncHelpers.js @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + A collection of assertion and wrapper functions for testing asynchronous built-ins. +defines: [asyncTest] +---*/ + +function asyncTest(testFunc) { + if (!Object.hasOwn(globalThis, "$DONE")) { + throw new Test262Error("asyncTest called without async flag"); + } + if (typeof testFunc !== "function") { + $DONE(new Test262Error("asyncTest called with non-function argument")); + return; + } + try { + testFunc().then( + function () { + $DONE(); + }, + function (error) { + $DONE(error); + } + ); + } catch (syncError) { + $DONE(syncError); + } +} + +assert.throwsAsync = async function (expectedErrorConstructor, func, message) { + var innerThenable; + if (message === undefined) { + message = ""; + } else { + message += " "; + } + if (typeof func === "function") { + try { + innerThenable = func(); + if ( + innerThenable === null || + typeof innerThenable !== "object" || + typeof innerThenable.then !== "function" + ) { + message += + "Expected to obtain an inner promise that would reject with a" + + expectedErrorConstructor.name + + " but result was not a thenable"; + throw new Test262Error(message); + } + } catch (thrown) { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but an exception was thrown synchronously while obtaining the inner promise"; + throw new Test262Error(message); + } + } else { + message += + "assert.throwsAsync called with an argument that is not a function"; + throw new Test262Error(message); + } + + try { + return innerThenable.then( + function () { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but no exception was thrown at all"; + throw new Test262Error(message); + }, + function (thrown) { + var expectedName, actualName; + if (typeof thrown !== "object" || thrown === null) { + message += "Thrown value was not an object!"; + throw new Test262Error(message); + } else if (thrown.constructor !== expectedErrorConstructor) { + expectedName = expectedErrorConstructor.name; + actualName = thrown.constructor.name; + if (expectedName === actualName) { + message += + "Expected a " + + expectedName + + " but got a different error constructor with the same name"; + } else { + message += + "Expected a " + expectedName + " but got a " + actualName; + } + throw new Test262Error(message); + } + } + ); + } catch (thrown) { + if (typeof thrown !== "object" || thrown === null) { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but innerThenable synchronously threw a value that was not an object "; + } else { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but a " + + thrown.constructor.name + + " was thrown synchronously"; + } + throw new Test262Error(message); + } +}; diff --git a/harness/atomicsHelper.js b/harness/atomicsHelper.js new file mode 100644 index 00000000000..761fee87c87 --- /dev/null +++ b/harness/atomicsHelper.js @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Collection of functions used to interact with Atomics.* operations across agent boundaries. +defines: + - $262.agent.getReportAsync + - $262.agent.getReport + - $262.agent.safeBroadcastAsync + - $262.agent.safeBroadcast + - $262.agent.setTimeout + - $262.agent.tryYield + - $262.agent.trySleep +---*/ + +/** + * @return {String} A report sent from an agent. + */ +{ + // This is only necessary because the original + // $262.agent.getReport API was insufficient. + // + // All runtimes currently have their own + // $262.agent.getReport which is wrong, so we + // will pave over it with a corrected version. + // + // Binding $262.agent is necessary to prevent + // breaking SpiderMonkey's $262.agent.getReport + let getReport = $262.agent.getReport.bind($262.agent); + + $262.agent.getReport = function() { + var r; + while ((r = getReport()) == null) { + $262.agent.sleep(1); + } + return r; + }; + + if (this.setTimeout === undefined) { + (function(that) { + that.setTimeout = function(callback, delay) { + let p = Promise.resolve(); + let start = Date.now(); + let end = start + delay; + function check() { + if ((end - Date.now()) > 0) { + p.then(check); + } + else { + callback(); + } + } + p.then(check); + } + })(this); + } + + $262.agent.setTimeout = setTimeout; + + $262.agent.getReportAsync = function() { + return new Promise(function(resolve) { + (function loop() { + let result = getReport(); + if (!result) { + setTimeout(loop, 1000); + } else { + resolve(result); + } + })(); + }); + }; +} + +/** + * + * Share a given Int32Array or BigInt64Array to all running agents. Ensure that the + * provided TypedArray is a "shared typed array". + * + * NOTE: Migrating all tests to this API is necessary to prevent tests from hanging + * indefinitely when a SAB is sent to a worker but the code in the worker attempts to + * create a non-sharable TypedArray (something that is not Int32Array or BigInt64Array). + * When that scenario occurs, an exception is thrown and the agent worker can no + * longer communicate with any other threads that control the SAB. If the main + * thread happens to be spinning in the $262.agent.waitUntil() while loop, it will never + * meet its termination condition and the test will hang indefinitely. + * + * Because we've defined $262.agent.broadcast(SAB) in + * https://github.com/tc39/test262/blob/HEAD/INTERPRETING.md, there are host implementations + * that assume compatibility, which must be maintained. + * + * + * $262.agent.safeBroadcast(TA) should not be included in + * https://github.com/tc39/test262/blob/HEAD/INTERPRETING.md + * + * + * @param {(Int32Array|BigInt64Array)} typedArray An Int32Array or BigInt64Array with a SharedArrayBuffer + */ +$262.agent.safeBroadcast = function(typedArray) { + let Constructor = Object.getPrototypeOf(typedArray).constructor; + let temp = new Constructor( + new SharedArrayBuffer(Constructor.BYTES_PER_ELEMENT) + ); + try { + // This will never actually wait, but that's fine because we only + // want to ensure that this typedArray CAN be waited on and is shareable. + Atomics.wait(temp, 0, Constructor === Int32Array ? 1 : BigInt(1)); + } catch (error) { + throw new Test262Error(`${Constructor.name} cannot be used as a shared typed array. (${error})`); + } + + $262.agent.broadcast(typedArray.buffer); +}; + +$262.agent.safeBroadcastAsync = async function(ta, index, expected) { + await $262.agent.broadcast(ta.buffer); + await $262.agent.waitUntil(ta, index, expected); + await $262.agent.tryYield(); + return await Atomics.load(ta, index); +}; + + +/** + * With a given Int32Array or BigInt64Array, wait until the expected number of agents have + * reported themselves by calling: + * + * Atomics.add(typedArray, index, 1); + * + * @param {(Int32Array|BigInt64Array)} typedArray An Int32Array or BigInt64Array with a SharedArrayBuffer + * @param {number} index The index of which all agents will report. + * @param {number} expected The number of agents that are expected to report as active. + */ +$262.agent.waitUntil = function(typedArray, index, expected) { + + var agents = 0; + while ((agents = Atomics.load(typedArray, index)) !== expected) { + /* nothing */ + } + assert.sameValue(agents, expected, "Reporting number of 'agents' equals the value of 'expected'"); +}; + +/** + * Timeout values used throughout the Atomics tests. All timeouts are specified in milliseconds. + * + * @property {number} yield Used for `$262.agent.tryYield`. Must not be used in other functions. + * @property {number} small Used when agents will always timeout and `Atomics.wake` is not part + * of the test semantics. Must be larger than `$262.agent.timeouts.yield`. + * @property {number} long Used when some agents may timeout and `Atomics.wake` is called on some + * agents. The agents are required to wait and this needs to be observable + * by the main thread. + * @property {number} huge Used when `Atomics.wake` is called on all waiting agents. The waiting + * must not timeout. The agents are required to wait and this needs to be + * observable by the main thread. All waiting agents must be woken by the + * main thread. + * + * Usage for `$262.agent.timeouts.small`: + * const WAIT_INDEX = 0; + * const RUNNING = 1; + * const TIMEOUT = $262.agent.timeouts.small; + * const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)); + * + * $262.agent.start(` + * $262.agent.receiveBroadcast(function(sab) { + * const i32a = new Int32Array(sab); + * Atomics.add(i32a, ${RUNNING}, 1); + * + * $262.agent.report(Atomics.wait(i32a, ${WAIT_INDEX}, 0, ${TIMEOUT})); + * + * $262.agent.leaving(); + * }); + * `); + * $262.agent.safeBroadcast(i32a.buffer); + * + * // Wait until the agent was started and then try to yield control to increase + * // the likelihood the agent has called `Atomics.wait` and is now waiting. + * $262.agent.waitUntil(i32a, RUNNING, 1); + * $262.agent.tryYield(); + * + * // The agent is expected to time out. + * assert.sameValue($262.agent.getReport(), "timed-out"); + * + * + * Usage for `$262.agent.timeouts.long`: + * const WAIT_INDEX = 0; + * const RUNNING = 1; + * const NUMAGENT = 2; + * const TIMEOUT = $262.agent.timeouts.long; + * const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)); + * + * for (let i = 0; i < NUMAGENT; i++) { + * $262.agent.start(` + * $262.agent.receiveBroadcast(function(sab) { + * const i32a = new Int32Array(sab); + * Atomics.add(i32a, ${RUNNING}, 1); + * + * $262.agent.report(Atomics.wait(i32a, ${WAIT_INDEX}, 0, ${TIMEOUT})); + * + * $262.agent.leaving(); + * }); + * `); + * } + * $262.agent.safeBroadcast(i32a.buffer); + * + * // Wait until the agents were started and then try to yield control to increase + * // the likelihood the agents have called `Atomics.wait` and are now waiting. + * $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); + * $262.agent.tryYield(); + * + * // Wake exactly one agent. + * assert.sameValue(Atomics.wake(i32a, WAIT_INDEX, 1), 1); + * + * // When it doesn't matter how many agents were woken at once, a while loop + * // can be used to make the test more resilient against intermittent failures + * // in case even though `tryYield` was called, the agents haven't started to + * // wait. + * // + * // // Repeat until exactly one agent was woken. + * // var woken = 0; + * // while ((woken = Atomics.wake(i32a, WAIT_INDEX, 1)) !== 0) ; + * // assert.sameValue(woken, 1); + * + * // One agent was woken and the other one timed out. + * const reports = [$262.agent.getReport(), $262.agent.getReport()]; + * assert(reports.includes("ok")); + * assert(reports.includes("timed-out")); + * + * + * Usage for `$262.agent.timeouts.huge`: + * const WAIT_INDEX = 0; + * const RUNNING = 1; + * const NUMAGENT = 2; + * const TIMEOUT = $262.agent.timeouts.huge; + * const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)); + * + * for (let i = 0; i < NUMAGENT; i++) { + * $262.agent.start(` + * $262.agent.receiveBroadcast(function(sab) { + * const i32a = new Int32Array(sab); + * Atomics.add(i32a, ${RUNNING}, 1); + * + * $262.agent.report(Atomics.wait(i32a, ${WAIT_INDEX}, 0, ${TIMEOUT})); + * + * $262.agent.leaving(); + * }); + * `); + * } + * $262.agent.safeBroadcast(i32a.buffer); + * + * // Wait until the agents were started and then try to yield control to increase + * // the likelihood the agents have called `Atomics.wait` and are now waiting. + * $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); + * $262.agent.tryYield(); + * + * // Wake all agents. + * assert.sameValue(Atomics.wake(i32a, WAIT_INDEX), NUMAGENT); + * + * // When it doesn't matter how many agents were woken at once, a while loop + * // can be used to make the test more resilient against intermittent failures + * // in case even though `tryYield` was called, the agents haven't started to + * // wait. + * // + * // // Repeat until all agents were woken. + * // for (var wokenCount = 0; wokenCount < NUMAGENT; ) { + * // var woken = 0; + * // while ((woken = Atomics.wake(i32a, WAIT_INDEX)) !== 0) ; + * // // Maybe perform an action on the woken agents here. + * // wokenCount += woken; + * // } + * + * // All agents were woken and none timeout. + * for (var i = 0; i < NUMAGENT; i++) { + * assert($262.agent.getReport(), "ok"); + * } + */ +$262.agent.timeouts = { + yield: 100, + small: 200, + long: 1000, + huge: 10000, +}; + +/** + * Try to yield control to the agent threads. + * + * Usage: + * const VALUE = 0; + * const RUNNING = 1; + * const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)); + * + * $262.agent.start(` + * $262.agent.receiveBroadcast(function(sab) { + * const i32a = new Int32Array(sab); + * Atomics.add(i32a, ${RUNNING}, 1); + * + * Atomics.store(i32a, ${VALUE}, 1); + * + * $262.agent.leaving(); + * }); + * `); + * $262.agent.safeBroadcast(i32a.buffer); + * + * // Wait until agent was started and then try to yield control. + * $262.agent.waitUntil(i32a, RUNNING, 1); + * $262.agent.tryYield(); + * + * // Note: This result is not guaranteed, but should hold in practice most of the time. + * assert.sameValue(Atomics.load(i32a, VALUE), 1); + * + * The default implementation simply waits for `$262.agent.timeouts.yield` milliseconds. + */ +$262.agent.tryYield = function() { + $262.agent.sleep($262.agent.timeouts.yield); +}; + +/** + * Try to sleep the current agent for the given amount of milliseconds. It is acceptable, + * but not encouraged, to ignore this sleep request and directly continue execution. + * + * The default implementation calls `$262.agent.sleep(ms)`. + * + * @param {number} ms Time to sleep in milliseconds. + */ +$262.agent.trySleep = function(ms) { + $262.agent.sleep(ms); +}; diff --git a/harness/byteConversionValues.js b/harness/byteConversionValues.js new file mode 100644 index 00000000000..e84d7c1e9d7 --- /dev/null +++ b/harness/byteConversionValues.js @@ -0,0 +1,458 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Provide a list for original and expected values for different byte + conversions. + This helper is mostly used on tests for TypedArray and DataView, and each + array from the expected values must match the original values array on every + index containing its original value. +defines: [byteConversionValues] +---*/ +var byteConversionValues = { + values: [ + 127, // 2 ** 7 - 1 + 128, // 2 ** 7 + 32767, // 2 ** 15 - 1 + 32768, // 2 ** 15 + 2147483647, // 2 ** 31 - 1 + 2147483648, // 2 ** 31 + 255, // 2 ** 8 - 1 + 256, // 2 ** 8 + 65535, // 2 ** 16 - 1 + 65536, // 2 ** 16 + 4294967295, // 2 ** 32 - 1 + 4294967296, // 2 ** 32 + 9007199254740991, // 2 ** 53 - 1 + 9007199254740992, // 2 ** 53 + 1.1, + 0.1, + 0.5, + 0.50000001, + 0.6, + 0.7, + undefined, + -1, + -0, + -0.1, + -1.1, + NaN, + -127, // - ( 2 ** 7 - 1 ) + -128, // - ( 2 ** 7 ) + -32767, // - ( 2 ** 15 - 1 ) + -32768, // - ( 2 ** 15 ) + -2147483647, // - ( 2 ** 31 - 1 ) + -2147483648, // - ( 2 ** 31 ) + -255, // - ( 2 ** 8 - 1 ) + -256, // - ( 2 ** 8 ) + -65535, // - ( 2 ** 16 - 1 ) + -65536, // - ( 2 ** 16 ) + -4294967295, // - ( 2 ** 32 - 1 ) + -4294967296, // - ( 2 ** 32 ) + Infinity, + -Infinity, + 0 + ], + + expected: { + Int8: [ + 127, // 127 + -128, // 128 + -1, // 32767 + 0, // 32768 + -1, // 2147483647 + 0, // 2147483648 + -1, // 255 + 0, // 256 + -1, // 65535 + 0, // 65536 + -1, // 4294967295 + 0, // 4294967296 + -1, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + -1, // -1 + 0, // -0 + 0, // -0.1 + -1, // -1.1 + 0, // NaN + -127, // -127 + -128, // -128 + 1, // -32767 + 0, // -32768 + 1, // -2147483647 + 0, // -2147483648 + 1, // -255 + 0, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Uint8: [ + 127, // 127 + 128, // 128 + 255, // 32767 + 0, // 32768 + 255, // 2147483647 + 0, // 2147483648 + 255, // 255 + 0, // 256 + 255, // 65535 + 0, // 65536 + 255, // 4294967295 + 0, // 4294967296 + 255, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + 255, // -1 + 0, // -0 + 0, // -0.1 + 255, // -1.1 + 0, // NaN + 129, // -127 + 128, // -128 + 1, // -32767 + 0, // -32768 + 1, // -2147483647 + 0, // -2147483648 + 1, // -255 + 0, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Uint8Clamped: [ + 127, // 127 + 128, // 128 + 255, // 32767 + 255, // 32768 + 255, // 2147483647 + 255, // 2147483648 + 255, // 255 + 255, // 256 + 255, // 65535 + 255, // 65536 + 255, // 4294967295 + 255, // 4294967296 + 255, // 9007199254740991 + 255, // 9007199254740992 + 1, // 1.1, + 0, // 0.1 + 0, // 0.5 + 1, // 0.50000001, + 1, // 0.6 + 1, // 0.7 + 0, // undefined + 0, // -1 + 0, // -0 + 0, // -0.1 + 0, // -1.1 + 0, // NaN + 0, // -127 + 0, // -128 + 0, // -32767 + 0, // -32768 + 0, // -2147483647 + 0, // -2147483648 + 0, // -255 + 0, // -256 + 0, // -65535 + 0, // -65536 + 0, // -4294967295 + 0, // -4294967296 + 255, // Infinity + 0, // -Infinity + 0 + ], + Int16: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + -32768, // 32768 + -1, // 2147483647 + 0, // 2147483648 + 255, // 255 + 256, // 256 + -1, // 65535 + 0, // 65536 + -1, // 4294967295 + 0, // 4294967296 + -1, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + -1, // -1 + 0, // -0 + 0, // -0.1 + -1, // -1.1 + 0, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + 1, // -2147483647 + 0, // -2147483648 + -255, // -255 + -256, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Uint16: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 65535, // 2147483647 + 0, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 0, // 65536 + 65535, // 4294967295 + 0, // 4294967296 + 65535, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + 65535, // -1 + 0, // -0 + 0, // -0.1 + 65535, // -1.1 + 0, // NaN + 65409, // -127 + 65408, // -128 + 32769, // -32767 + 32768, // -32768 + 1, // -2147483647 + 0, // -2147483648 + 65281, // -255 + 65280, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Int32: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483647, // 2147483647 + -2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + -1, // 4294967295 + 0, // 4294967296 + -1, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + -1, // -1 + 0, // -0 + 0, // -0.1 + -1, // -1.1 + 0, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483647, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Uint32: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483647, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967295, // 4294967295 + 0, // 4294967296 + 4294967295, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + 4294967295, // -1 + 0, // -0 + 0, // -0.1 + 4294967295, // -1.1 + 0, // NaN + 4294967169, // -127 + 4294967168, // -128 + 4294934529, // -32767 + 4294934528, // -32768 + 2147483649, // -2147483647 + 2147483648, // -2147483648 + 4294967041, // -255 + 4294967040, // -256 + 4294901761, // -65535 + 4294901760, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Float32: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483648, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967296, // 4294967295 + 4294967296, // 4294967296 + 9007199254740992, // 9007199254740991 + 9007199254740992, // 9007199254740992 + 1.100000023841858, // 1.1 + 0.10000000149011612, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.6000000238418579, // 0.6 + 0.699999988079071, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.10000000149011612, // -0.1 + -1.100000023841858, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483648, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + -4294967296, // -4294967295 + -4294967296, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0 + ], + Float64: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483647, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967295, // 4294967295 + 4294967296, // 4294967296 + 9007199254740991, // 9007199254740991 + 9007199254740992, // 9007199254740992 + 1.1, // 1.1 + 0.1, // 0.1 + 0.5, // 0.5 + 0.50000001, // 0.50000001, + 0.6, // 0.6 + 0.7, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.1, // -0.1 + -1.1, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483647, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + -4294967295, // -4294967295 + -4294967296, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0 + ] + } +}; diff --git a/harness/compareArray.js b/harness/compareArray.js new file mode 100644 index 00000000000..2783698457e --- /dev/null +++ b/harness/compareArray.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Compare the contents of two arrays +defines: [compareArray] +---*/ + +function compareArray(a, b) { + if (b.length !== a.length) { + return false; + } + + for (var i = 0; i < a.length; i++) { + if (!compareArray.isSameValue(b[i], a[i])) { + return false; + } + } + return true; +} + +compareArray.isSameValue = function(a, b) { + if (a === 0 && b === 0) return 1 / a === 1 / b; + if (a !== a && b !== b) return true; + + return a === b; +}; + +compareArray.format = function(arrayLike) { + return `[${[].map.call(arrayLike, String).join(', ')}]`; +}; + +assert.compareArray = function(actual, expected, message) { + message = message === undefined ? '' : message; + + if (typeof message === 'symbol') { + message = message.toString(); + } + + assert(actual != null, `First argument shouldn't be nullish. ${message}`); + assert(expected != null, `Second argument shouldn't be nullish. ${message}`); + var format = compareArray.format; + var result = compareArray(actual, expected); + + // The following prevents actual and expected from being iterated and evaluated + // more than once unless absolutely necessary. + if (!result) { + assert(false, `Expected ${format(actual)} and ${format(expected)} to have the same contents. ${message}`); + } +}; diff --git a/harness/compareIterator.js b/harness/compareIterator.js new file mode 100644 index 00000000000..d4e3b9a53aa --- /dev/null +++ b/harness/compareIterator.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Compare the values of an iterator with an array of expected values +defines: [assert.compareIterator] +---*/ + +// Example: +// +// function* numbers() { +// yield 1; +// yield 2; +// yield 3; +// } +// +// assert.compareIterator(numbers(), [ +// v => assert.sameValue(v, 1), +// v => assert.sameValue(v, 2), +// v => assert.sameValue(v, 3), +// ]); +// +assert.compareIterator = function(iter, validators, message) { + message = message || ''; + + var i, result; + for (i = 0; i < validators.length; i++) { + result = iter.next(); + assert(!result.done, 'Expected ' + i + ' values(s). Instead iterator only produced ' + (i - 1) + ' value(s). ' + message); + validators[i](result.value); + } + + result = iter.next(); + assert(result.done, 'Expected only ' + i + ' values(s). Instead iterator produced more. ' + message); + assert.sameValue(result.value, undefined, 'Expected value of `undefined` when iterator completes. ' + message); +} diff --git a/harness/dateConstants.js b/harness/dateConstants.js new file mode 100644 index 00000000000..2eed15ca63a --- /dev/null +++ b/harness/dateConstants.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of date-centric values +defines: + - date_1899_end + - date_1900_start + - date_1969_end + - date_1970_start + - date_1999_end + - date_2000_start + - date_2099_end + - date_2100_start + - start_of_time + - end_of_time +---*/ + +var date_1899_end = -2208988800001; +var date_1900_start = -2208988800000; +var date_1969_end = -1; +var date_1970_start = 0; +var date_1999_end = 946684799999; +var date_2000_start = 946684800000; +var date_2099_end = 4102444799999; +var date_2100_start = 4102444800000; + +var start_of_time = -8.64e15; +var end_of_time = 8.64e15; diff --git a/harness/decimalToHexString.js b/harness/decimalToHexString.js new file mode 100644 index 00000000000..9840ee589cd --- /dev/null +++ b/harness/decimalToHexString.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +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]; +} diff --git a/harness/deepEqual.js b/harness/deepEqual.js new file mode 100644 index 00000000000..a2ceeb3d9cc --- /dev/null +++ b/harness/deepEqual.js @@ -0,0 +1,339 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Compare two values structurally +defines: [assert.deepEqual] +---*/ + +assert.deepEqual = function(actual, expected, message) { + var format = assert.deepEqual.format; + assert( + assert.deepEqual._compare(actual, expected), + `Expected ${format(actual)} to be structurally equal to ${format(expected)}. ${(message || '')}` + ); +}; + +assert.deepEqual.format = function(value, seen) { + switch (typeof value) { + case 'string': + return typeof JSON !== "undefined" ? JSON.stringify(value) : `"${value}"`; + case 'number': + case 'boolean': + case 'symbol': + case 'bigint': + return value.toString(); + case 'undefined': + return 'undefined'; + case 'function': + return `[Function${value.name ? `: ${value.name}` : ''}]`; + case 'object': + if (value === null) return 'null'; + if (value instanceof Date) return `Date "${value.toISOString()}"`; + if (value instanceof RegExp) return value.toString(); + if (!seen) { + seen = { + counter: 0, + map: new Map() + }; + } + + let usage = seen.map.get(value); + if (usage) { + usage.used = true; + return `[Ref: #${usage.id}]`; + } + + usage = { id: ++seen.counter, used: false }; + seen.map.set(value, usage); + + if (typeof Set !== "undefined" && value instanceof Set) { + return `Set {${Array.from(value).map(value => assert.deepEqual.format(value, seen)).join(', ')}}${usage.used ? ` as #${usage.id}` : ''}`; + } + if (typeof Map !== "undefined" && value instanceof Map) { + return `Map {${Array.from(value).map(pair => `${assert.deepEqual.format(pair[0], seen)} => ${assert.deepEqual.format(pair[1], seen)}}`).join(', ')}}${usage.used ? ` as #${usage.id}` : ''}`; + } + if (Array.isArray ? Array.isArray(value) : value instanceof Array) { + return `[${value.map(value => assert.deepEqual.format(value, seen)).join(', ')}]${usage.used ? ` as #${usage.id}` : ''}`; + } + let tag = Symbol.toStringTag in value ? value[Symbol.toStringTag] : 'Object'; + if (tag === 'Object' && Object.getPrototypeOf(value) === null) { + tag = '[Object: null prototype]'; + } + return `${tag ? `${tag} ` : ''}{ ${Object.keys(value).map(key => `${key.toString()}: ${assert.deepEqual.format(value[key], seen)}`).join(', ')} }${usage.used ? ` as #${usage.id}` : ''}`; + default: + return typeof value; + } +}; + +assert.deepEqual._compare = (function () { + var EQUAL = 1; + var NOT_EQUAL = -1; + var UNKNOWN = 0; + + function deepEqual(a, b) { + return compareEquality(a, b) === EQUAL; + } + + function compareEquality(a, b, cache) { + return compareIf(a, b, isOptional, compareOptionality) + || compareIf(a, b, isPrimitiveEquatable, comparePrimitiveEquality) + || compareIf(a, b, isObjectEquatable, compareObjectEquality, cache) + || NOT_EQUAL; + } + + function compareIf(a, b, test, compare, cache) { + return !test(a) + ? !test(b) ? UNKNOWN : NOT_EQUAL + : !test(b) ? NOT_EQUAL : cacheComparison(a, b, compare, cache); + } + + function tryCompareStrictEquality(a, b) { + return a === b ? EQUAL : UNKNOWN; + } + + function tryCompareTypeOfEquality(a, b) { + return typeof a !== typeof b ? NOT_EQUAL : UNKNOWN; + } + + function tryCompareToStringTagEquality(a, b) { + var aTag = Symbol.toStringTag in a ? a[Symbol.toStringTag] : undefined; + var bTag = Symbol.toStringTag in b ? b[Symbol.toStringTag] : undefined; + return aTag !== bTag ? NOT_EQUAL : UNKNOWN; + } + + function isOptional(value) { + return value === undefined + || value === null; + } + + function compareOptionality(a, b) { + return tryCompareStrictEquality(a, b) + || NOT_EQUAL; + } + + function isPrimitiveEquatable(value) { + switch (typeof value) { + case 'string': + case 'number': + case 'bigint': + case 'boolean': + case 'symbol': + return true; + default: + return isBoxed(value); + } + } + + function comparePrimitiveEquality(a, b) { + if (isBoxed(a)) a = a.valueOf(); + if (isBoxed(b)) b = b.valueOf(); + return tryCompareStrictEquality(a, b) + || tryCompareTypeOfEquality(a, b) + || compareIf(a, b, isNaNEquatable, compareNaNEquality) + || NOT_EQUAL; + } + + function isNaNEquatable(value) { + return typeof value === 'number'; + } + + function compareNaNEquality(a, b) { + return isNaN(a) && isNaN(b) ? EQUAL : NOT_EQUAL; + } + + function isObjectEquatable(value) { + return typeof value === 'object'; + } + + function compareObjectEquality(a, b, cache) { + if (!cache) cache = new Map(); + return getCache(cache, a, b) + || setCache(cache, a, b, EQUAL) // consider equal for now + || cacheComparison(a, b, tryCompareStrictEquality, cache) + || cacheComparison(a, b, tryCompareToStringTagEquality, cache) + || compareIf(a, b, isValueOfEquatable, compareValueOfEquality) + || compareIf(a, b, isToStringEquatable, compareToStringEquality) + || compareIf(a, b, isArrayLikeEquatable, compareArrayLikeEquality, cache) + || compareIf(a, b, isStructurallyEquatable, compareStructuralEquality, cache) + || compareIf(a, b, isIterableEquatable, compareIterableEquality, cache) + || cacheComparison(a, b, fail, cache); + } + + function isBoxed(value) { + return value instanceof String + || value instanceof Number + || value instanceof Boolean + || typeof Symbol === 'function' && value instanceof Symbol + || typeof BigInt === 'function' && value instanceof BigInt; + } + + function isValueOfEquatable(value) { + return value instanceof Date; + } + + function compareValueOfEquality(a, b) { + return compareIf(a.valueOf(), b.valueOf(), isPrimitiveEquatable, comparePrimitiveEquality) + || NOT_EQUAL; + } + + function isToStringEquatable(value) { + return value instanceof RegExp; + } + + function compareToStringEquality(a, b) { + return compareIf(a.toString(), b.toString(), isPrimitiveEquatable, comparePrimitiveEquality) + || NOT_EQUAL; + } + + function isArrayLikeEquatable(value) { + return (Array.isArray ? Array.isArray(value) : value instanceof Array) + || (typeof Uint8Array === 'function' && value instanceof Uint8Array) + || (typeof Uint8ClampedArray === 'function' && value instanceof Uint8ClampedArray) + || (typeof Uint16Array === 'function' && value instanceof Uint16Array) + || (typeof Uint32Array === 'function' && value instanceof Uint32Array) + || (typeof Int8Array === 'function' && value instanceof Int8Array) + || (typeof Int16Array === 'function' && value instanceof Int16Array) + || (typeof Int32Array === 'function' && value instanceof Int32Array) + || (typeof Float32Array === 'function' && value instanceof Float32Array) + || (typeof Float64Array === 'function' && value instanceof Float64Array) + || (typeof BigUint64Array === 'function' && value instanceof BigUint64Array) + || (typeof BigInt64Array === 'function' && value instanceof BigInt64Array); + } + + function compareArrayLikeEquality(a, b, cache) { + if (a.length !== b.length) return NOT_EQUAL; + for (var i = 0; i < a.length; i++) { + if (compareEquality(a[i], b[i], cache) === NOT_EQUAL) { + return NOT_EQUAL; + } + } + return EQUAL; + } + + function isStructurallyEquatable(value) { + return !(typeof Promise === 'function' && value instanceof Promise // only comparable by reference + || typeof WeakMap === 'function' && value instanceof WeakMap // only comparable by reference + || typeof WeakSet === 'function' && value instanceof WeakSet // only comparable by reference + || typeof Map === 'function' && value instanceof Map // comparable via @@iterator + || typeof Set === 'function' && value instanceof Set); // comparable via @@iterator + } + + function compareStructuralEquality(a, b, cache) { + var aKeys = []; + for (var key in a) aKeys.push(key); + + var bKeys = []; + for (var key in b) bKeys.push(key); + + if (aKeys.length !== bKeys.length) { + return NOT_EQUAL; + } + + aKeys.sort(); + bKeys.sort(); + + for (var i = 0; i < aKeys.length; i++) { + var aKey = aKeys[i]; + var bKey = bKeys[i]; + if (compareEquality(aKey, bKey, cache) === NOT_EQUAL) { + return NOT_EQUAL; + } + if (compareEquality(a[aKey], b[bKey], cache) === NOT_EQUAL) { + return NOT_EQUAL; + } + } + + return compareIf(a, b, isIterableEquatable, compareIterableEquality, cache) + || EQUAL; + } + + function isIterableEquatable(value) { + return typeof Symbol === 'function' + && typeof value[Symbol.iterator] === 'function'; + } + + function compareIteratorEquality(a, b, cache) { + if (typeof Map === 'function' && a instanceof Map && b instanceof Map || + typeof Set === 'function' && a instanceof Set && b instanceof Set) { + if (a.size !== b.size) return NOT_EQUAL; // exit early if we detect a difference in size + } + + var ar, br; + while (true) { + ar = a.next(); + br = b.next(); + if (ar.done) { + if (br.done) return EQUAL; + if (b.return) b.return(); + return NOT_EQUAL; + } + if (br.done) { + if (a.return) a.return(); + return NOT_EQUAL; + } + if (compareEquality(ar.value, br.value, cache) === NOT_EQUAL) { + if (a.return) a.return(); + if (b.return) b.return(); + return NOT_EQUAL; + } + } + } + + function compareIterableEquality(a, b, cache) { + return compareIteratorEquality(a[Symbol.iterator](), b[Symbol.iterator](), cache); + } + + function cacheComparison(a, b, compare, cache) { + var result = compare(a, b, cache); + if (cache && (result === EQUAL || result === NOT_EQUAL)) { + setCache(cache, a, b, /** @type {EQUAL | NOT_EQUAL} */(result)); + } + return result; + } + + function fail() { + return NOT_EQUAL; + } + + function setCache(cache, left, right, result) { + var otherCache; + + otherCache = cache.get(left); + if (!otherCache) cache.set(left, otherCache = new Map()); + otherCache.set(right, result); + + otherCache = cache.get(right); + if (!otherCache) cache.set(right, otherCache = new Map()); + otherCache.set(left, result); + } + + function getCache(cache, left, right) { + var otherCache; + var result; + + otherCache = cache.get(left); + result = otherCache && otherCache.get(right); + if (result) return result; + + otherCache = cache.get(right); + result = otherCache && otherCache.get(left); + if (result) return result; + + return UNKNOWN; + } + + return deepEqual; +})(); diff --git a/harness/detachArrayBuffer.js b/harness/detachArrayBuffer.js new file mode 100644 index 00000000000..e69c0cbc2cd --- /dev/null +++ b/harness/detachArrayBuffer.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + A function used in the process of asserting correctness of TypedArray objects. + + $262.detachArrayBuffer is defined by a host. +defines: [$DETACHBUFFER] +---*/ + +function $DETACHBUFFER(buffer) { + if (!$262 || typeof $262.detachArrayBuffer !== "function") { + throw new Test262Error("No method available to detach an ArrayBuffer"); + } + $262.detachArrayBuffer(buffer); +} diff --git a/harness/doneprintHandle.js b/harness/doneprintHandle.js new file mode 100644 index 00000000000..8c8f589868d --- /dev/null +++ b/harness/doneprintHandle.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | +defines: [$DONE] +---*/ + +function __consolePrintHandle__(msg) { + print(msg); +} + +function $DONE(error) { + if (error) { + if(typeof error === 'object' && error !== null && 'name' in error) { + __consolePrintHandle__('Test262:AsyncTestFailure:' + error.name + ': ' + error.message); + } else { + __consolePrintHandle__('Test262:AsyncTestFailure:Test262Error: ' + String(error)); + } + } else { + __consolePrintHandle__('Test262:AsyncTestComplete'); + } +} diff --git a/harness/features.yml b/harness/features.yml new file mode 100644 index 00000000000..333af083bed --- /dev/null +++ b/harness/features.yml @@ -0,0 +1,6 @@ +atomicsHelper: [Atomics] +typeCoercion.js: [Symbol.toPrimitive, BigInt] +testAtomics.js: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, Symbol, TypedArray] +testBigIntTypedArray.js: [BigInt, TypedArray] +testTypedArray.js: [TypedArray] +isConstructor.js: [Reflect.construct] diff --git a/harness/fnGlobalObject.js b/harness/fnGlobalObject.js new file mode 100644 index 00000000000..370e40c3356 --- /dev/null +++ b/harness/fnGlobalObject.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Produce a reliable global object +defines: [fnGlobalObject] +---*/ + +var __globalObject = Function("return this;")(); +function fnGlobalObject() { + return __globalObject; +} diff --git a/harness/hidden-constructors.js b/harness/hidden-constructors.js new file mode 100644 index 00000000000..7ea8430fe48 --- /dev/null +++ b/harness/hidden-constructors.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: | + Provides uniform access to built-in constructors that are not exposed to the global object. +defines: + - AsyncArrowFunction + - AsyncFunction + - AsyncGeneratorFunction + - GeneratorFunction +---*/ + +var AsyncArrowFunction = Object.getPrototypeOf(async () => {}).constructor; +var AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; +var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; diff --git a/harness/isConstructor.js b/harness/isConstructor.js new file mode 100644 index 00000000000..9fad1048809 --- /dev/null +++ b/harness/isConstructor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +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/harness/nans.js b/harness/nans.js new file mode 100644 index 00000000000..39f2c57c22e --- /dev/null +++ b/harness/nans.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + A collection of NaN values produced from expressions that have been observed + to create distinct bit representations on various platforms. These provide a + weak basis for assertions regarding the consistent canonicalization of NaN + values in Array buffers. +defines: [NaNs] +---*/ + +var NaNs = [ + NaN, + Number.NaN, + NaN * 0, + 0/0, + Infinity/Infinity, + -(0/0), + Math.pow(-1, 0.5), + -Math.pow(-1, 0.5), + Number("Not-a-Number"), +]; diff --git a/harness/nativeFunctionMatcher.js b/harness/nativeFunctionMatcher.js new file mode 100644 index 00000000000..c913005ce30 --- /dev/null +++ b/harness/nativeFunctionMatcher.js @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Assert _NativeFunction_ Syntax +info: | + NativeFunction : + function _NativeFunctionAccessor_ opt _IdentifierName_ opt ( _FormalParameters_ ) { [ native code ] } + NativeFunctionAccessor : + get + set +defines: + - assertToStringOrNativeFunction + - assertNativeFunction + - validateNativeFunctionSource +---*/ + +const validateNativeFunctionSource = function(source) { + // These regexes should be kept up to date with Unicode using `regexpu-core`. + // `/\p{ID_Start}/u` + const UnicodeIDStart = /(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/; + // `/\p{ID_Continue}/u` + const UnicodeIDContinue = /(?:[0-9A-Z_a-z\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u08D3-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1ABF\u1AC0\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA827\uA82C\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD27\uDD30-\uDD39\uDE80-\uDEA9\uDEAB\uDEAC\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF50\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD47\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCE9\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0\uDFF1]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDEC0-\uDEF9]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A]|\uDB40[\uDD00-\uDDEF])/; + // `/\p{Space_Separator}/u` + const UnicodeSpaceSeparator = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/; + + const isNewline = (c) => /[\u000A\u000D\u2028\u2029]/u.test(c); + const isWhitespace = (c) => /[\u0009\u000B\u000C\u0020\u00A0\uFEFF]/u.test(c) || UnicodeSpaceSeparator.test(c); + + let pos = 0; + + const eatWhitespace = () => { + while (pos < source.length) { + const c = source[pos]; + if (isWhitespace(c) || isNewline(c)) { + pos += 1; + continue; + } + + if (c === '/') { + if (source[pos + 1] === '/') { + while (pos < source.length) { + if (isNewline(source[pos])) { + break; + } + pos += 1; + } + continue; + } + if (source[pos + 1] === '*') { + const end = source.indexOf('*/', pos); + if (end === -1) { + throw new SyntaxError(); + } + pos = end + '*/'.length; + continue; + } + } + + break; + } + }; + + const getIdentifier = () => { + eatWhitespace(); + + const start = pos; + let end = pos; + switch (source[end]) { + case '_': + case '$': + end += 1; + break; + default: + if (UnicodeIDStart.test(source[end])) { + end += 1; + break; + } + return null; + } + while (end < source.length) { + const c = source[end]; + switch (c) { + case '_': + case '$': + end += 1; + break; + default: + if (UnicodeIDContinue.test(c)) { + end += 1; + break; + } + return source.slice(start, end); + } + } + return source.slice(start, end); + }; + + const test = (s) => { + eatWhitespace(); + + if (/\w/.test(s)) { + return getIdentifier() === s; + } + return source.slice(pos, pos + s.length) === s; + }; + + const eat = (s) => { + if (test(s)) { + pos += s.length; + return true; + } + return false; + }; + + const eatIdentifier = () => { + const n = getIdentifier(); + if (n !== null) { + pos += n.length; + return true; + } + return false; + }; + + const expect = (s) => { + if (!eat(s)) { + throw new SyntaxError(); + } + }; + + const eatString = () => { + if (source[pos] === '\'' || source[pos] === '"') { + const match = source[pos]; + pos += 1; + while (pos < source.length) { + if (source[pos] === match && source[pos - 1] !== '\\') { + return; + } + if (isNewline(source[pos])) { + throw new SyntaxError(); + } + pos += 1; + } + throw new SyntaxError(); + } + }; + + // "Stumble" through source text until matching character is found. + // Assumes ECMAScript syntax keeps `[]` and `()` balanced. + const stumbleUntil = (c) => { + const match = { + ']': '[', + ')': '(', + }[c]; + let nesting = 1; + while (pos < source.length) { + eatWhitespace(); + eatString(); // Strings may contain unbalanced characters. + if (source[pos] === match) { + nesting += 1; + } else if (source[pos] === c) { + nesting -= 1; + } + pos += 1; + if (nesting === 0) { + return; + } + } + throw new SyntaxError(); + }; + + // function + expect('function'); + + // NativeFunctionAccessor + eat('get') || eat('set'); + + // PropertyName + if (!eatIdentifier() && eat('[')) { + stumbleUntil(']'); + } + + // ( FormalParameters ) + expect('('); + stumbleUntil(')'); + + // { + expect('{'); + + // [native code] + expect('['); + expect('native'); + expect('code'); + expect(']'); + + // } + expect('}'); + + eatWhitespace(); + if (pos !== source.length) { + throw new SyntaxError(); + } +}; + +const assertToStringOrNativeFunction = function(fn, expected) { + const actual = "" + fn; + try { + assert.sameValue(actual, expected); + } catch (unused) { + assertNativeFunction(fn, expected); + } +}; + +const assertNativeFunction = function(fn, special) { + const actual = "" + fn; + try { + validateNativeFunctionSource(actual); + } catch (unused) { + throw new Test262Error('Conforms to NativeFunction Syntax: ' + JSON.stringify(actual) + (special ? ' (' + special + ')' : '')); + } +}; diff --git a/harness/promiseHelper.js b/harness/promiseHelper.js new file mode 100644 index 00000000000..9750544489e --- /dev/null +++ b/harness/promiseHelper.js @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Check that an array contains a numeric sequence starting at 1 + and incrementing by 1 for each entry in the array. Used by + Promise tests to assert the order of execution in deep Promise + resolution pipelines. +defines: [checkSequence, checkSettledPromises] +---*/ + +function checkSequence(arr, message) { + arr.forEach(function(e, i) { + if (e !== (i+1)) { + throw new Test262Error((message ? message : "Steps in unexpected sequence:") + + " '" + arr.join(',') + "'"); + } + }); + + return true; +} + +function checkSettledPromises(settleds, expected, message) { + const prefix = message ? `${message}: ` : ''; + + assert.sameValue(Array.isArray(settleds), true, `${prefix}Settled values is an array`); + + assert.sameValue( + settleds.length, + expected.length, + `${prefix}The settled values has a different length than expected` + ); + + settleds.forEach((settled, i) => { + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'status'), + true, + `${prefix}The settled value has a property status` + ); + + assert.sameValue(settled.status, expected[i].status, `${prefix}status for item ${i}`); + + if (settled.status === 'fulfilled') { + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'value'), + true, + `${prefix}The fulfilled promise has a property named value` + ); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'reason'), + false, + `${prefix}The fulfilled promise has no property named reason` + ); + + assert.sameValue(settled.value, expected[i].value, `${prefix}value for item ${i}`); + } else { + assert.sameValue(settled.status, 'rejected', `${prefix}Valid statuses are only fulfilled or rejected`); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'value'), + false, + `${prefix}The fulfilled promise has no property named value` + ); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'reason'), + true, + `${prefix}The fulfilled promise has a property named reason` + ); + + assert.sameValue(settled.reason, expected[i].reason, `${prefix}Reason value for item ${i}`); + } + }); +} diff --git a/harness/propertyHelper.js b/harness/propertyHelper.js new file mode 100644 index 00000000000..6b38bb72e0b --- /dev/null +++ b/harness/propertyHelper.js @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to safely verify the correctness of + property descriptors. +defines: + - verifyProperty + - verifyEqualTo # deprecated + - verifyWritable # deprecated + - verifyNotWritable # deprecated + - verifyEnumerable # deprecated + - verifyNotEnumerable # deprecated + - verifyConfigurable # deprecated + - verifyNotConfigurable # deprecated +---*/ + +// @ts-check + +/** + * @param {object} obj + * @param {string|symbol} name + * @param {PropertyDescriptor|undefined} desc + * @param {object} [options] + * @param {boolean} [options.restore] + */ +function verifyProperty(obj, name, desc, options) { + assert( + arguments.length > 2, + 'verifyProperty should receive at least 3 arguments: obj, name, and descriptor' + ); + + var originalDesc = Object.getOwnPropertyDescriptor(obj, name); + var nameStr = String(name); + + // Allows checking for undefined descriptor if it's explicitly given. + if (desc === undefined) { + assert.sameValue( + originalDesc, + undefined, + "obj['" + nameStr + "'] descriptor should be undefined" + ); + + // desc and originalDesc are both undefined, problem solved; + return true; + } + + assert( + Object.prototype.hasOwnProperty.call(obj, name), + "obj should have an own property " + nameStr + ); + + assert.notSameValue( + desc, + null, + "The desc argument should be an object or undefined, null" + ); + + assert.sameValue( + typeof desc, + "object", + "The desc argument should be an object or undefined, " + String(desc) + ); + + var failures = []; + + if (Object.prototype.hasOwnProperty.call(desc, 'value')) { + if (!isSameValue(desc.value, originalDesc.value)) { + failures.push("descriptor value should be " + desc.value); + } + } + + if (Object.prototype.hasOwnProperty.call(desc, 'enumerable')) { + if (desc.enumerable !== originalDesc.enumerable || + desc.enumerable !== isEnumerable(obj, name)) { + failures.push('descriptor should ' + (desc.enumerable ? '' : 'not ') + 'be enumerable'); + } + } + + if (Object.prototype.hasOwnProperty.call(desc, 'writable')) { + if (desc.writable !== originalDesc.writable || + desc.writable !== isWritable(obj, name)) { + failures.push('descriptor should ' + (desc.writable ? '' : 'not ') + 'be writable'); + } + } + + if (Object.prototype.hasOwnProperty.call(desc, 'configurable')) { + if (desc.configurable !== originalDesc.configurable || + desc.configurable !== isConfigurable(obj, name)) { + failures.push('descriptor should ' + (desc.configurable ? '' : 'not ') + 'be configurable'); + } + } + + assert(!failures.length, failures.join('; ')); + + if (options && options.restore) { + Object.defineProperty(obj, name, originalDesc); + } + + return true; +} + +function isConfigurable(obj, name) { + var hasOwnProperty = Object.prototype.hasOwnProperty; + try { + delete obj[name]; + } catch (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + } + return !hasOwnProperty.call(obj, name); +} + +function isEnumerable(obj, name) { + var stringCheck = false; + + if (typeof name === "string") { + for (var x in obj) { + if (x === name) { + stringCheck = true; + break; + } + } + } else { + // skip it if name is not string, works for Symbol names. + stringCheck = true; + } + + return stringCheck && + Object.prototype.hasOwnProperty.call(obj, name) && + Object.prototype.propertyIsEnumerable.call(obj, name); +} + +function isSameValue(a, b) { + if (a === 0 && b === 0) return 1 / a === 1 / b; + if (a !== a && b !== b) return true; + + return a === b; +} + +var __isArray = Array.isArray; +function isWritable(obj, name, verifyProp, value) { + var unlikelyValue = __isArray(obj) && name === "length" ? + Math.pow(2, 32) - 1 : + "unlikelyValue"; + var newValue = value || unlikelyValue; + var hadValue = Object.prototype.hasOwnProperty.call(obj, name); + var oldValue = obj[name]; + var writeSucceeded; + + try { + obj[name] = newValue; + } catch (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + } + + writeSucceeded = isSameValue(obj[verifyProp || name], newValue); + + // Revert the change only if it was successful (in other cases, reverting + // is unnecessary and may trigger exceptions for certain property + // configurations) + if (writeSucceeded) { + if (hadValue) { + obj[name] = oldValue; + } else { + delete obj[name]; + } + } + + return writeSucceeded; +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyEqualTo(obj, name, value) { + if (!isSameValue(obj[name], value)) { + throw new Test262Error("Expected obj[" + String(name) + "] to equal " + value + + ", actually " + obj[name]); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyWritable(obj, name, verifyProp, value) { + if (!verifyProp) { + assert(Object.getOwnPropertyDescriptor(obj, name).writable, + "Expected obj[" + String(name) + "] to have writable:true."); + } + if (!isWritable(obj, name, verifyProp, value)) { + throw new Test262Error("Expected obj[" + String(name) + "] to be writable, but was not."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyNotWritable(obj, name, verifyProp, value) { + if (!verifyProp) { + assert(!Object.getOwnPropertyDescriptor(obj, name).writable, + "Expected obj[" + String(name) + "] to have writable:false."); + } + if (isWritable(obj, name, verifyProp)) { + throw new Test262Error("Expected obj[" + String(name) + "] NOT to be writable, but was."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyEnumerable(obj, name) { + assert(Object.getOwnPropertyDescriptor(obj, name).enumerable, + "Expected obj[" + String(name) + "] to have enumerable:true."); + if (!isEnumerable(obj, name)) { + throw new Test262Error("Expected obj[" + String(name) + "] to be enumerable, but was not."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyNotEnumerable(obj, name) { + assert(!Object.getOwnPropertyDescriptor(obj, name).enumerable, + "Expected obj[" + String(name) + "] to have enumerable:false."); + if (isEnumerable(obj, name)) { + throw new Test262Error("Expected obj[" + String(name) + "] NOT to be enumerable, but was."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyConfigurable(obj, name) { + assert(Object.getOwnPropertyDescriptor(obj, name).configurable, + "Expected obj[" + String(name) + "] to have configurable:true."); + if (!isConfigurable(obj, name)) { + throw new Test262Error("Expected obj[" + String(name) + "] to be configurable, but was not."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyNotConfigurable(obj, name) { + assert(!Object.getOwnPropertyDescriptor(obj, name).configurable, + "Expected obj[" + String(name) + "] to have configurable:false."); + if (isConfigurable(obj, name)) { + throw new Test262Error("Expected obj[" + String(name) + "] NOT to be configurable, but was."); + } +} diff --git a/harness/proxyTrapsHelper.js b/harness/proxyTrapsHelper.js new file mode 100644 index 00000000000..17daab5abc1 --- /dev/null +++ b/harness/proxyTrapsHelper.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Used to assert the correctness of object behavior in the presence + and context of Proxy objects. +defines: [allowProxyTraps] +---*/ + +function allowProxyTraps(overrides) { + function throwTest262Error(msg) { + return function () { throw new Test262Error(msg); }; + } + if (!overrides) { overrides = {}; } + return { + getPrototypeOf: overrides.getPrototypeOf || throwTest262Error('[[GetPrototypeOf]] trap called'), + setPrototypeOf: overrides.setPrototypeOf || throwTest262Error('[[SetPrototypeOf]] trap called'), + isExtensible: overrides.isExtensible || throwTest262Error('[[IsExtensible]] trap called'), + preventExtensions: overrides.preventExtensions || throwTest262Error('[[PreventExtensions]] trap called'), + getOwnPropertyDescriptor: overrides.getOwnPropertyDescriptor || throwTest262Error('[[GetOwnProperty]] trap called'), + has: overrides.has || throwTest262Error('[[HasProperty]] trap called'), + get: overrides.get || throwTest262Error('[[Get]] trap called'), + set: overrides.set || throwTest262Error('[[Set]] trap called'), + deleteProperty: overrides.deleteProperty || throwTest262Error('[[Delete]] trap called'), + defineProperty: overrides.defineProperty || throwTest262Error('[[DefineOwnProperty]] trap called'), + enumerate: throwTest262Error('[[Enumerate]] trap called: this trap has been removed'), + ownKeys: overrides.ownKeys || throwTest262Error('[[OwnPropertyKeys]] trap called'), + apply: overrides.apply || throwTest262Error('[[Call]] trap called'), + construct: overrides.construct || throwTest262Error('[[Construct]] trap called') + }; +} diff --git a/harness/regExpUtils.js b/harness/regExpUtils.js new file mode 100644 index 00000000000..4be437e20a7 --- /dev/null +++ b/harness/regExpUtils.js @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to assert the correctness of RegExp objects. +defines: [buildString, testPropertyEscapes, testPropertyOfStrings, testExtendedCharacterClass, matchValidator] +---*/ + +function buildString(args) { + // Use member expressions rather than destructuring `args` for improved + // compatibility with engines that only implement assignment patterns + // partially or not at all. + const loneCodePoints = args.loneCodePoints; + const ranges = args.ranges; + const CHUNK_SIZE = 10000; + let result = Reflect.apply(String.fromCodePoint, null, loneCodePoints); + for (let i = 0; i < ranges.length; i++) { + const range = ranges[i]; + const start = range[0]; + const end = range[1]; + const codePoints = []; + for (let length = 0, codePoint = start; codePoint <= end; codePoint++) { + codePoints[length++] = codePoint; + if (length === CHUNK_SIZE) { + result += Reflect.apply(String.fromCodePoint, null, codePoints); + codePoints.length = length = 0; + } + } + result += Reflect.apply(String.fromCodePoint, null, codePoints); + } + return result; +} + +function printCodePoint(codePoint) { + const hex = codePoint + .toString(16) + .toUpperCase() + .padStart(6, "0"); + return `U+${hex}`; +} + +function printStringCodePoints(string) { + const buf = []; + for (const symbol of string) { + const formatted = printCodePoint(symbol.codePointAt(0)); + buf.push(formatted); + } + return buf.join(' '); +} + +function testPropertyEscapes(regExp, string, expression) { + if (!regExp.test(string)) { + for (const symbol of string) { + const formatted = printCodePoint(symbol.codePointAt(0)); + assert( + regExp.test(symbol), + `\`${ expression }\` should match ${ formatted } (\`${ symbol }\`)` + ); + } + } +} + +function testPropertyOfStrings(args) { + // Use member expressions rather than destructuring `args` for improved + // compatibility with engines that only implement assignment patterns + // partially or not at all. + const regExp = args.regExp; + const expression = args.expression; + const matchStrings = args.matchStrings; + const nonMatchStrings = args.nonMatchStrings; + const allStrings = matchStrings.join(''); + if (!regExp.test(allStrings)) { + for (const string of matchStrings) { + assert( + regExp.test(string), + `\`${ expression }\` should match ${ string } (${ printStringCodePoints(string) })` + ); + } + } + + const allNonMatchStrings = nonMatchStrings.join(''); + if (regExp.test(allNonMatchStrings)) { + for (const string of nonMatchStrings) { + assert( + !regExp.test(string), + `\`${ expression }\` should not match ${ string } (${ printStringCodePoints(string) })` + ); + } + } +} + +// The exact same logic can be used to test extended character classes +// as enabled through the RegExp `v` flag. This is useful to test not +// just standalone properties of strings, but also string literals, and +// set operations. +const testExtendedCharacterClass = testPropertyOfStrings; + +// Returns a function that validates a RegExp match result. +// +// Example: +// +// var validate = matchValidator(['b'], 1, 'abc'); +// validate(/b/.exec('abc')); +// +function matchValidator(expectedEntries, expectedIndex, expectedInput) { + return function(match) { + assert.compareArray(match, expectedEntries, 'Match entries'); + assert.sameValue(match.index, expectedIndex, 'Match index'); + assert.sameValue(match.input, expectedInput, 'Match input'); + } +} diff --git a/harness/sta.js b/harness/sta.js new file mode 100644 index 00000000000..5634cb9b003 --- /dev/null +++ b/harness/sta.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Provides both: + + - An error class to avoid false positives when testing for thrown exceptions + - A function to explicitly throw an exception using the Test262Error class +defines: [Test262Error, $DONOTEVALUATE] +---*/ + + +function Test262Error(message) { + this.message = message || ""; +} + +Test262Error.prototype.toString = function () { + return "Test262Error: " + this.message; +}; + +Test262Error.thrower = function (message) { + throw new Test262Error(message); +}; + +function $DONOTEVALUATE() { + throw "Test262: This statement should not be evaluated."; +} diff --git a/harness/tcoHelper.js b/harness/tcoHelper.js new file mode 100644 index 00000000000..fafbed857f4 --- /dev/null +++ b/harness/tcoHelper.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + This defines the number of consecutive recursive function calls that must be + made in order to prove that stack frames are properly destroyed according to + ES2015 tail call optimization semantics. +defines: [$MAX_ITERATIONS] +---*/ + + + + +var $MAX_ITERATIONS = 100000; diff --git a/harness/temporalHelpers.js b/harness/temporalHelpers.js new file mode 100644 index 00000000000..c8aee0516f4 --- /dev/null +++ b/harness/temporalHelpers.js @@ -0,0 +1,2086 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + This defines helper objects and functions for testing Temporal. +defines: [TemporalHelpers] +features: [Symbol.species, Symbol.iterator, Temporal] +---*/ + +const ASCII_IDENTIFIER = /^[$_a-zA-Z][$_a-zA-Z0-9]*$/u; + +function formatPropertyName(propertyKey, objectName = "") { + switch (typeof propertyKey) { + case "symbol": + if (Symbol.keyFor(propertyKey) !== undefined) { + return `${objectName}[Symbol.for('${Symbol.keyFor(propertyKey)}')]`; + } else if (propertyKey.description.startsWith('Symbol.')) { + return `${objectName}[${propertyKey.description}]`; + } else { + return `${objectName}[Symbol('${propertyKey.description}')]` + } + case "string": + if (propertyKey !== String(Number(propertyKey))) { + if (ASCII_IDENTIFIER.test(propertyKey)) { + return objectName ? `${objectName}.${propertyKey}` : propertyKey; + } + return `${objectName}['${propertyKey.replace(/'/g, "\\'")}']` + } + // fall through + default: + // integer or string integer-index + return `${objectName}[${propertyKey}]`; + } +} + +const SKIP_SYMBOL = Symbol("Skip"); + +var TemporalHelpers = { + /* + * assertDuration(duration, years, ..., nanoseconds[, description]): + * + * Shorthand for asserting that each field of a Temporal.Duration is equal to + * an expected value. + */ + assertDuration(duration, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, description = "") { + assert(duration instanceof Temporal.Duration, `${description} instanceof`); + assert.sameValue(duration.years, years, `${description} years result`); + assert.sameValue(duration.months, months, `${description} months result`); + assert.sameValue(duration.weeks, weeks, `${description} weeks result`); + assert.sameValue(duration.days, days, `${description} days result`); + assert.sameValue(duration.hours, hours, `${description} hours result`); + assert.sameValue(duration.minutes, minutes, `${description} minutes result`); + assert.sameValue(duration.seconds, seconds, `${description} seconds result`); + assert.sameValue(duration.milliseconds, milliseconds, `${description} milliseconds result`); + assert.sameValue(duration.microseconds, microseconds, `${description} microseconds result`); + assert.sameValue(duration.nanoseconds, nanoseconds, `${description} nanoseconds result`); + }, + + /* + * assertDurationsEqual(actual, expected[, description]): + * + * Shorthand for asserting that each field of a Temporal.Duration is equal to + * the corresponding field in another Temporal.Duration. + */ + assertDurationsEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.Duration, `${description} expected value should be a Temporal.Duration`); + TemporalHelpers.assertDuration(actual, expected.years, expected.months, expected.weeks, expected.days, expected.hours, expected.minutes, expected.seconds, expected.milliseconds, expected.microseconds, expected.nanoseconds, description); + }, + + /* + * assertInstantsEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.Instants are of the correct type + * and equal according to their equals() methods. + */ + assertInstantsEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.Instant, `${description} expected value should be a Temporal.Instant`); + assert(actual instanceof Temporal.Instant, `${description} instanceof`); + assert(actual.equals(expected), `${description} equals method`); + }, + + /* + * assertPlainDate(date, year, ..., nanosecond[, description[, era, eraYear]]): + * + * Shorthand for asserting that each field of a Temporal.PlainDate is equal to + * an expected value. (Except the `calendar` property, since callers may want + * to assert either object equality with an object they put in there, or the + * value of date.calendarId.) + */ + assertPlainDate(date, year, month, monthCode, day, description = "", era = undefined, eraYear = undefined) { + assert(date instanceof Temporal.PlainDate, `${description} instanceof`); + assert.sameValue(date.era, era, `${description} era result`); + assert.sameValue(date.eraYear, eraYear, `${description} eraYear result`); + assert.sameValue(date.year, year, `${description} year result`); + assert.sameValue(date.month, month, `${description} month result`); + assert.sameValue(date.monthCode, monthCode, `${description} monthCode result`); + assert.sameValue(date.day, day, `${description} day result`); + }, + + /* + * assertPlainDateTime(datetime, year, ..., nanosecond[, description[, era, eraYear]]): + * + * Shorthand for asserting that each field of a Temporal.PlainDateTime is + * equal to an expected value. (Except the `calendar` property, since callers + * may want to assert either object equality with an object they put in there, + * or the value of datetime.calendarId.) + */ + assertPlainDateTime(datetime, year, month, monthCode, day, hour, minute, second, millisecond, microsecond, nanosecond, description = "", era = undefined, eraYear = undefined) { + assert(datetime instanceof Temporal.PlainDateTime, `${description} instanceof`); + assert.sameValue(datetime.era, era, `${description} era result`); + assert.sameValue(datetime.eraYear, eraYear, `${description} eraYear result`); + assert.sameValue(datetime.year, year, `${description} year result`); + assert.sameValue(datetime.month, month, `${description} month result`); + assert.sameValue(datetime.monthCode, monthCode, `${description} monthCode result`); + assert.sameValue(datetime.day, day, `${description} day result`); + assert.sameValue(datetime.hour, hour, `${description} hour result`); + assert.sameValue(datetime.minute, minute, `${description} minute result`); + assert.sameValue(datetime.second, second, `${description} second result`); + assert.sameValue(datetime.millisecond, millisecond, `${description} millisecond result`); + assert.sameValue(datetime.microsecond, microsecond, `${description} microsecond result`); + assert.sameValue(datetime.nanosecond, nanosecond, `${description} nanosecond result`); + }, + + /* + * assertPlainDateTimesEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.PlainDateTimes are of the correct + * type, equal according to their equals() methods, and additionally that + * their calendar internal slots are the same value. + */ + assertPlainDateTimesEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.PlainDateTime, `${description} expected value should be a Temporal.PlainDateTime`); + assert(actual instanceof Temporal.PlainDateTime, `${description} instanceof`); + assert(actual.equals(expected), `${description} equals method`); + assert.sameValue( + actual.getISOFields().calendar, + expected.getISOFields().calendar, + `${description} calendar same value` + ); + }, + + /* + * assertPlainMonthDay(monthDay, monthCode, day[, description [, referenceISOYear]]): + * + * Shorthand for asserting that each field of a Temporal.PlainMonthDay is + * equal to an expected value. (Except the `calendar` property, since callers + * may want to assert either object equality with an object they put in there, + * or the value of monthDay.calendarId().) + */ + assertPlainMonthDay(monthDay, monthCode, day, description = "", referenceISOYear = 1972) { + assert(monthDay instanceof Temporal.PlainMonthDay, `${description} instanceof`); + assert.sameValue(monthDay.monthCode, monthCode, `${description} monthCode result`); + assert.sameValue(monthDay.day, day, `${description} day result`); + assert.sameValue(monthDay.getISOFields().isoYear, referenceISOYear, `${description} referenceISOYear result`); + }, + + /* + * assertPlainTime(time, hour, ..., nanosecond[, description]): + * + * Shorthand for asserting that each field of a Temporal.PlainTime is equal to + * an expected value. + */ + assertPlainTime(time, hour, minute, second, millisecond, microsecond, nanosecond, description = "") { + assert(time instanceof Temporal.PlainTime, `${description} instanceof`); + assert.sameValue(time.hour, hour, `${description} hour result`); + assert.sameValue(time.minute, minute, `${description} minute result`); + assert.sameValue(time.second, second, `${description} second result`); + assert.sameValue(time.millisecond, millisecond, `${description} millisecond result`); + assert.sameValue(time.microsecond, microsecond, `${description} microsecond result`); + assert.sameValue(time.nanosecond, nanosecond, `${description} nanosecond result`); + }, + + /* + * assertPlainTimesEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.PlainTimes are of the correct + * type and equal according to their equals() methods. + */ + assertPlainTimesEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.PlainTime, `${description} expected value should be a Temporal.PlainTime`); + assert(actual instanceof Temporal.PlainTime, `${description} instanceof`); + assert(actual.equals(expected), `${description} equals method`); + }, + + /* + * assertPlainYearMonth(yearMonth, year, month, monthCode[, description[, era, eraYear, referenceISODay]]): + * + * Shorthand for asserting that each field of a Temporal.PlainYearMonth is + * equal to an expected value. (Except the `calendar` property, since callers + * may want to assert either object equality with an object they put in there, + * or the value of yearMonth.calendarId.) + */ + assertPlainYearMonth(yearMonth, year, month, monthCode, description = "", era = undefined, eraYear = undefined, referenceISODay = 1) { + assert(yearMonth instanceof Temporal.PlainYearMonth, `${description} instanceof`); + assert.sameValue(yearMonth.era, era, `${description} era result`); + assert.sameValue(yearMonth.eraYear, eraYear, `${description} eraYear result`); + assert.sameValue(yearMonth.year, year, `${description} year result`); + assert.sameValue(yearMonth.month, month, `${description} month result`); + assert.sameValue(yearMonth.monthCode, monthCode, `${description} monthCode result`); + assert.sameValue(yearMonth.getISOFields().isoDay, referenceISODay, `${description} referenceISODay result`); + }, + + /* + * assertZonedDateTimesEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.ZonedDateTimes are of the correct + * type, equal according to their equals() methods, and additionally that + * their time zones and calendar internal slots are the same value. + */ + assertZonedDateTimesEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.ZonedDateTime, `${description} expected value should be a Temporal.ZonedDateTime`); + assert(actual instanceof Temporal.ZonedDateTime, `${description} instanceof`); + assert(actual.equals(expected), `${description} equals method`); + assert.sameValue(actual.timeZone, expected.timeZone, `${description} time zone same value`); + assert.sameValue( + actual.getISOFields().calendar, + expected.getISOFields().calendar, + `${description} calendar same value` + ); + }, + + /* + * assertUnreachable(description): + * + * Helper for asserting that code is not executed. This is useful for + * assertions that methods of user calendars and time zones are not called. + */ + assertUnreachable(description) { + let message = "This code should not be executed"; + if (description) { + message = `${message}: ${description}`; + } + throw new Test262Error(message); + }, + + /* + * checkCalendarDateUntilLargestUnitSingular(func, expectedLargestUnitCalls): + * + * When an options object with a largestUnit property is synthesized inside + * Temporal and passed to user code such as calendar.dateUntil(), the value of + * the largestUnit property should be in the singular form, even if the input + * was given in the plural form. + * (This doesn't apply when the options object is passed through verbatim.) + * + * func(calendar, largestUnit, index) is the operation under test. It's called + * with an instance of a calendar that keeps track of which largestUnit is + * passed to dateUntil(), each key of expectedLargestUnitCalls in turn, and + * the key's numerical index in case the function needs to generate test data + * based on the index. At the end, the actual values passed to dateUntil() are + * compared with the array values of expectedLargestUnitCalls. + */ + checkCalendarDateUntilLargestUnitSingular(func, expectedLargestUnitCalls) { + const actual = []; + + class DateUntilOptionsCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateUntil(earlier, later, options) { + actual.push(options.largestUnit); + return super.dateUntil(earlier, later, options); + } + + toString() { + return "date-until-options"; + } + } + + const calendar = new DateUntilOptionsCalendar(); + Object.entries(expectedLargestUnitCalls).forEach(([largestUnit, expected], index) => { + func(calendar, largestUnit, index); + assert.compareArray(actual, expected, `largestUnit passed to calendar.dateUntil() for largestUnit ${largestUnit}`); + actual.splice(0); // empty it for the next check + }); + }, + + /* + * checkPlainDateTimeConversionFastPath(func): + * + * ToTemporalDate and ToTemporalTime should both, if given a + * Temporal.PlainDateTime instance, convert to the desired type by reading the + * PlainDateTime's internal slots, rather than calling any getters. + * + * func(datetime, calendar) is the actual operation to test, that must + * internally call the abstract operation ToTemporalDate or ToTemporalTime. + * It is passed a Temporal.PlainDateTime instance, as well as the instance's + * calendar object (so that it doesn't have to call the calendar getter itself + * if it wants to make any assertions about the calendar.) + */ + checkPlainDateTimeConversionFastPath(func, message = "checkPlainDateTimeConversionFastPath") { + const actual = []; + const expected = []; + + const calendar = new Temporal.Calendar("iso8601"); + const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); + const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.PlainDateTime.prototype); + ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond"].forEach((property) => { + Object.defineProperty(datetime, property, { + get() { + actual.push(`get ${formatPropertyName(property)}`); + const value = prototypeDescrs[property].get.call(this); + return { + toString() { + actual.push(`toString ${formatPropertyName(property)}`); + return value.toString(); + }, + valueOf() { + actual.push(`valueOf ${formatPropertyName(property)}`); + return value; + }, + }; + }, + }); + }); + Object.defineProperty(datetime, "calendar", { + get() { + actual.push("get calendar"); + return calendar; + }, + }); + + func(datetime, calendar); + assert.compareArray(actual, expected, `${message}: property getters not called`); + }, + + /* + * Check that an options bag that accepts units written in the singular form, + * also accepts the same units written in the plural form. + * func(unit) should call the method with the appropriate options bag + * containing unit as a value. This will be called twice for each element of + * validSingularUnits, once with singular and once with plural, and the + * results of each pair should be the same (whether a Temporal object or a + * primitive value.) + */ + checkPluralUnitsAccepted(func, validSingularUnits) { + const plurals = { + year: 'years', + month: 'months', + week: 'weeks', + day: 'days', + hour: 'hours', + minute: 'minutes', + second: 'seconds', + millisecond: 'milliseconds', + microsecond: 'microseconds', + nanosecond: 'nanoseconds', + }; + + validSingularUnits.forEach((unit) => { + const singularValue = func(unit); + const pluralValue = func(plurals[unit]); + const desc = `Plural ${plurals[unit]} produces the same result as singular ${unit}`; + if (singularValue instanceof Temporal.Duration) { + TemporalHelpers.assertDurationsEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.Instant) { + TemporalHelpers.assertInstantsEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.PlainDateTime) { + TemporalHelpers.assertPlainDateTimesEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.PlainTime) { + TemporalHelpers.assertPlainTimesEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.ZonedDateTime) { + TemporalHelpers.assertZonedDateTimesEqual(pluralValue, singularValue, desc); + } else { + assert.sameValue(pluralValue, singularValue); + } + }); + }, + + /* + * checkRoundingIncrementOptionWrongType(checkFunc, assertTrueResultFunc, assertObjectResultFunc): + * + * Checks the type handling of the roundingIncrement option. + * checkFunc(roundingIncrement) is a function which takes the value of + * roundingIncrement to test, and calls the method under test with it, + * returning the result. assertTrueResultFunc(result, description) should + * assert that result is the expected result with roundingIncrement: true, and + * assertObjectResultFunc(result, description) should assert that result is + * the expected result with roundingIncrement being an object with a valueOf() + * method. + */ + checkRoundingIncrementOptionWrongType(checkFunc, assertTrueResultFunc, assertObjectResultFunc) { + // null converts to 0, which is out of range + assert.throws(RangeError, () => checkFunc(null), "null"); + // Booleans convert to either 0 or 1, and 1 is allowed + const trueResult = checkFunc(true); + assertTrueResultFunc(trueResult, "true"); + assert.throws(RangeError, () => checkFunc(false), "false"); + // Symbols and BigInts cannot convert to numbers + assert.throws(TypeError, () => checkFunc(Symbol()), "symbol"); + assert.throws(TypeError, () => checkFunc(2n), "bigint"); + + // Objects prefer their valueOf() methods when converting to a number + assert.throws(RangeError, () => checkFunc({}), "plain object"); + + const expected = [ + "get roundingIncrement.valueOf", + "call roundingIncrement.valueOf", + ]; + const actual = []; + const observer = TemporalHelpers.toPrimitiveObserver(actual, 2, "roundingIncrement"); + const objectResult = checkFunc(observer); + assertObjectResultFunc(objectResult, "object with valueOf"); + assert.compareArray(actual, expected, "order of operations"); + }, + + /* + * checkStringOptionWrongType(propertyName, value, checkFunc, assertFunc): + * + * Checks the type handling of a string option, of which there are several in + * Temporal. + * propertyName is the name of the option, and value is the value that + * assertFunc should expect it to have. + * checkFunc(value) is a function which takes the value of the option to test, + * and calls the method under test with it, returning the result. + * assertFunc(result, description) should assert that result is the expected + * result with the option value being an object with a toString() method + * which returns the given value. + */ + checkStringOptionWrongType(propertyName, value, checkFunc, assertFunc) { + // null converts to the string "null", which is an invalid string value + assert.throws(RangeError, () => checkFunc(null), "null"); + // Booleans convert to the strings "true" or "false", which are invalid + assert.throws(RangeError, () => checkFunc(true), "true"); + assert.throws(RangeError, () => checkFunc(false), "false"); + // Symbols cannot convert to strings + assert.throws(TypeError, () => checkFunc(Symbol()), "symbol"); + // Numbers convert to strings which are invalid + assert.throws(RangeError, () => checkFunc(2), "number"); + // BigInts convert to strings which are invalid + assert.throws(RangeError, () => checkFunc(2n), "bigint"); + + // Objects prefer their toString() methods when converting to a string + assert.throws(RangeError, () => checkFunc({}), "plain object"); + + const expected = [ + `get ${propertyName}.toString`, + `call ${propertyName}.toString`, + ]; + const actual = []; + const observer = TemporalHelpers.toPrimitiveObserver(actual, value, propertyName); + const result = checkFunc(observer); + assertFunc(result, "object with toString"); + assert.compareArray(actual, expected, "order of operations"); + }, + + /* + * checkSubclassingIgnored(construct, constructArgs, method, methodArgs, + * resultAssertions): + * + * Methods of Temporal classes that return a new instance of the same class, + * must not take the constructor of a subclass into account, nor the @@species + * property. This helper runs tests to ensure this. + * + * construct(...constructArgs) must yield a valid instance of the Temporal + * class. instance[method](...methodArgs) is the method call under test, which + * must also yield a valid instance of the same Temporal class, not a + * subclass. See below for the individual tests that this runs. + * resultAssertions() is a function that performs additional assertions on the + * instance returned by the method under test. + */ + checkSubclassingIgnored(...args) { + this.checkSubclassConstructorNotObject(...args); + this.checkSubclassConstructorUndefined(...args); + this.checkSubclassConstructorThrows(...args); + this.checkSubclassConstructorNotCalled(...args); + this.checkSubclassSpeciesInvalidResult(...args); + this.checkSubclassSpeciesNotAConstructor(...args); + this.checkSubclassSpeciesNull(...args); + this.checkSubclassSpeciesUndefined(...args); + this.checkSubclassSpeciesThrows(...args); + }, + + /* + * Checks that replacing the 'constructor' property of the instance with + * various primitive values does not affect the returned new instance. + */ + checkSubclassConstructorNotObject(construct, constructArgs, method, methodArgs, resultAssertions) { + function check(value, description) { + const instance = new construct(...constructArgs); + instance.constructor = value; + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype, description); + resultAssertions(result); + } + + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "Symbol"); + check(7, "number"); + check(7n, "bigint"); + }, + + /* + * Checks that replacing the 'constructor' property of the subclass with + * undefined does not affect the returned new instance. + */ + checkSubclassConstructorUndefined(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + MySubclass.prototype.constructor = undefined; + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Checks that making the 'constructor' property of the instance throw when + * called does not affect the returned new instance. + */ + checkSubclassConstructorThrows(construct, constructArgs, method, methodArgs, resultAssertions) { + function CustomError() {} + const instance = new construct(...constructArgs); + Object.defineProperty(instance, "constructor", { + get() { + throw new CustomError(); + } + }); + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Checks that when subclassing, the subclass constructor is not called by + * the method under test. + */ + checkSubclassConstructorNotCalled(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that the constructor's @@species property is ignored when it's a + * constructor that returns a non-object value. + */ + checkSubclassSpeciesInvalidResult(construct, constructArgs, method, methodArgs, resultAssertions) { + function check(value, description) { + const instance = new construct(...constructArgs); + instance.constructor = { + [Symbol.species]: function() { + return value; + }, + }; + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype, description); + resultAssertions(result); + } + + check(undefined, "undefined"); + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "Symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "plain object"); + }, + + /* + * Check that the constructor's @@species property is ignored when it's not a + * constructor. + */ + checkSubclassSpeciesNotAConstructor(construct, constructArgs, method, methodArgs, resultAssertions) { + function check(value, description) { + const instance = new construct(...constructArgs); + instance.constructor = { + [Symbol.species]: value, + }; + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype, description); + resultAssertions(result); + } + + check(true, "true"); + check("test", "string"); + check(Symbol(), "Symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "plain object"); + }, + + /* + * Check that the constructor's @@species property is ignored when it's null. + */ + checkSubclassSpeciesNull(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + MySubclass.prototype.constructor = { + [Symbol.species]: null, + }; + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that the constructor's @@species property is ignored when it's + * undefined. + */ + checkSubclassSpeciesUndefined(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + MySubclass.prototype.constructor = { + [Symbol.species]: undefined, + }; + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that the constructor's @@species property is ignored when it throws, + * i.e. it is not called at all. + */ + checkSubclassSpeciesThrows(construct, constructArgs, method, methodArgs, resultAssertions) { + function CustomError() {} + + const instance = new construct(...constructArgs); + instance.constructor = { + get [Symbol.species]() { + throw new CustomError(); + }, + }; + + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + }, + + /* + * checkSubclassingIgnoredStatic(construct, method, methodArgs, resultAssertions): + * + * Static methods of Temporal classes that return a new instance of the class, + * must not use the this-value as a constructor. This helper runs tests to + * ensure this. + * + * construct[method](...methodArgs) is the static method call under test, and + * must yield a valid instance of the Temporal class, not a subclass. See + * below for the individual tests that this runs. + * resultAssertions() is a function that performs additional assertions on the + * instance returned by the method under test. + */ + checkSubclassingIgnoredStatic(...args) { + this.checkStaticInvalidReceiver(...args); + this.checkStaticReceiverNotCalled(...args); + this.checkThisValueNotCalled(...args); + }, + + /* + * Check that calling the static method with a receiver that's not callable, + * still calls the intrinsic constructor. + */ + checkStaticInvalidReceiver(construct, method, methodArgs, resultAssertions) { + function check(value, description) { + const result = construct[method].apply(value, methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + } + + check(undefined, "undefined"); + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "Non-callable object"); + }, + + /* + * Check that calling the static method with a receiver that returns a value + * that's not callable, still calls the intrinsic constructor. + */ + checkStaticReceiverNotCalled(construct, method, methodArgs, resultAssertions) { + function check(value, description) { + const receiver = function () { + return value; + }; + const result = construct[method].apply(receiver, methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + } + + check(undefined, "undefined"); + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "Non-callable object"); + }, + + /* + * Check that the receiver isn't called. + */ + checkThisValueNotCalled(construct, method, methodArgs, resultAssertions) { + let called = false; + + class MySubclass extends construct { + constructor(...args) { + called = true; + super(...args); + } + } + + const result = MySubclass[method](...methodArgs); + assert.sameValue(called, false); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that any iterable returned from a custom time zone's + * getPossibleInstantsFor() method is exhausted. + * The custom time zone object is passed in to func(). + * expected is an array of strings representing the expected calls to the + * getPossibleInstantsFor() method. The PlainDateTimes that it is called with, + * are compared (using their toString() results) with the array. + */ + checkTimeZonePossibleInstantsIterable(func, expected) { + // A custom time zone that returns an iterable instead of an array from its + // getPossibleInstantsFor() method, and for testing purposes skips + // 00:00-01:00 UTC on January 1, 2030, and repeats 00:00-01:00 UTC+1 on + // January 3, 2030. Otherwise identical to the UTC time zone. + class TimeZonePossibleInstantsIterable extends Temporal.TimeZone { + constructor() { + super("UTC"); + this.getPossibleInstantsForCallCount = 0; + this.getPossibleInstantsForCalledWith = []; + this.getPossibleInstantsForReturns = []; + this.iteratorExhausted = []; + } + + toString() { + return "Custom/Iterable"; + } + + getOffsetNanosecondsFor(instant) { + if (Temporal.Instant.compare(instant, "2030-01-01T00:00Z") >= 0 && + Temporal.Instant.compare(instant, "2030-01-03T01:00Z") < 0) { + return 3600_000_000_000; + } else { + return 0; + } + } + + getPossibleInstantsFor(dateTime) { + this.getPossibleInstantsForCallCount++; + this.getPossibleInstantsForCalledWith.push(dateTime); + + // Fake DST transition + let retval = super.getPossibleInstantsFor(dateTime); + if (dateTime.toPlainDate().equals("2030-01-01") && dateTime.hour === 0) { + retval = []; + } else if (dateTime.toPlainDate().equals("2030-01-03") && dateTime.hour === 0) { + retval.push(retval[0].subtract({ hours: 1 })); + } else if (dateTime.year === 2030 && dateTime.month === 1 && dateTime.day >= 1 && dateTime.day <= 2) { + retval[0] = retval[0].subtract({ hours: 1 }); + } + + this.getPossibleInstantsForReturns.push(retval); + this.iteratorExhausted.push(false); + return { + callIndex: this.getPossibleInstantsForCallCount - 1, + timeZone: this, + *[Symbol.iterator]() { + yield* this.timeZone.getPossibleInstantsForReturns[this.callIndex]; + this.timeZone.iteratorExhausted[this.callIndex] = true; + }, + }; + } + } + + const timeZone = new TimeZonePossibleInstantsIterable(); + func(timeZone); + + assert.sameValue(timeZone.getPossibleInstantsForCallCount, expected.length, "getPossibleInstantsFor() method called correct number of times"); + + for (let index = 0; index < expected.length; index++) { + assert.sameValue(timeZone.getPossibleInstantsForCalledWith[index].toString(), expected[index], "getPossibleInstantsFor() called with expected PlainDateTime"); + assert(timeZone.iteratorExhausted[index], "iterated through the whole iterable"); + } + }, + + /* + * Check that any calendar-carrying Temporal object has its [[Calendar]] + * internal slot read by ToTemporalCalendar, and does not fetch the calendar + * by calling getters. + * The custom calendar object is passed in to func() so that it can do its + * own additional assertions involving the calendar if necessary. (Sometimes + * there is nothing to assert as the calendar isn't stored anywhere that can + * be asserted about.) + */ + checkToTemporalCalendarFastPath(func) { + class CalendarFastPathCheck extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateFromFields(...args) { + return super.dateFromFields(...args).withCalendar(this); + } + + monthDayFromFields(...args) { + const { isoYear, isoMonth, isoDay } = super.monthDayFromFields(...args).getISOFields(); + return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); + } + + yearMonthFromFields(...args) { + const { isoYear, isoMonth, isoDay } = super.yearMonthFromFields(...args).getISOFields(); + return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); + } + + toString() { + return "fast-path-check"; + } + } + const calendar = new CalendarFastPathCheck(); + + const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar); + const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); + const plainMonthDay = new Temporal.PlainMonthDay(5, 2, calendar); + const plainYearMonth = new Temporal.PlainYearMonth(2000, 5, calendar); + const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); + + [plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((temporalObject) => { + const actual = []; + const expected = []; + + Object.defineProperty(temporalObject, "calendar", { + get() { + actual.push("get calendar"); + return calendar; + }, + }); + + func(temporalObject, calendar); + assert.compareArray(actual, expected, "calendar getter not called"); + }); + }, + + checkToTemporalInstantFastPath(func) { + const actual = []; + const expected = []; + + const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); + Object.defineProperty(datetime, 'toString', { + get() { + actual.push("get toString"); + return function (options) { + actual.push("call toString"); + return Temporal.ZonedDateTime.prototype.toString.call(this, options); + }; + }, + }); + + func(datetime); + assert.compareArray(actual, expected, "toString not called"); + }, + + checkToTemporalPlainDateTimeFastPath(func) { + const actual = []; + const expected = []; + + const calendar = new Temporal.Calendar("iso8601"); + const date = new Temporal.PlainDate(2000, 5, 2, calendar); + const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.PlainDate.prototype); + ["year", "month", "monthCode", "day"].forEach((property) => { + Object.defineProperty(date, property, { + get() { + actual.push(`get ${formatPropertyName(property)}`); + const value = prototypeDescrs[property].get.call(this); + return TemporalHelpers.toPrimitiveObserver(actual, value, property); + }, + }); + }); + ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"].forEach((property) => { + Object.defineProperty(date, property, { + get() { + actual.push(`get ${formatPropertyName(property)}`); + return undefined; + }, + }); + }); + Object.defineProperty(date, "calendar", { + get() { + actual.push("get calendar"); + return calendar; + }, + }); + + func(date, calendar); + assert.compareArray(actual, expected, "property getters not called"); + }, + + /* + * A custom calendar used in prototype pollution checks. Verifies that the + * fromFields methods are always called with a null-prototype fields object. + */ + calendarCheckFieldsPrototypePollution() { + class CalendarCheckFieldsPrototypePollution extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateFromFieldsCallCount = 0; + this.yearMonthFromFieldsCallCount = 0; + this.monthDayFromFieldsCallCount = 0; + } + + // toString must remain "iso8601", so that some methods don't throw due to + // incompatible calendars + + dateFromFields(fields, options = {}) { + this.dateFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "dateFromFields should be called with null-prototype fields object"); + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options = {}) { + this.yearMonthFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "yearMonthFromFields should be called with null-prototype fields object"); + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options = {}) { + this.monthDayFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "monthDayFromFields should be called with null-prototype fields object"); + return super.monthDayFromFields(fields, options); + } + } + + return new CalendarCheckFieldsPrototypePollution(); + }, + + /* + * A custom calendar used in prototype pollution checks. Verifies that the + * mergeFields() method is always called with null-prototype fields objects. + */ + calendarCheckMergeFieldsPrototypePollution() { + class CalendarCheckMergeFieldsPrototypePollution extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.mergeFieldsCallCount = 0; + } + + toString() { + return "merge-fields-null-proto"; + } + + mergeFields(fields, additionalFields) { + this.mergeFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "mergeFields should be called with null-prototype fields object (first argument)"); + assert.sameValue(Object.getPrototypeOf(additionalFields), null, "mergeFields should be called with null-prototype fields object (second argument)"); + return super.mergeFields(fields, additionalFields); + } + } + + return new CalendarCheckMergeFieldsPrototypePollution(); + }, + + /* + * A custom calendar used in prototype pollution checks. Verifies that methods + * are always called with a null-prototype options object. + */ + calendarCheckOptionsPrototypePollution() { + class CalendarCheckOptionsPrototypePollution extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.yearMonthFromFieldsCallCount = 0; + this.dateUntilCallCount = 0; + } + + toString() { + return "options-null-proto"; + } + + yearMonthFromFields(fields, options) { + this.yearMonthFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(options), null, "yearMonthFromFields should be called with null-prototype options"); + return super.yearMonthFromFields(fields, options); + } + + dateUntil(one, two, options) { + this.dateUntilCallCount++; + assert.sameValue(Object.getPrototypeOf(options), null, "dateUntil should be called with null-prototype options"); + return super.dateUntil(one, two, options); + } + } + + return new CalendarCheckOptionsPrototypePollution(); + }, + + /* + * A custom calendar that asserts its dateAdd() method is called with the + * options parameter having the value undefined. + */ + calendarDateAddUndefinedOptions() { + class CalendarDateAddUndefinedOptions extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateAddCallCount = 0; + } + + toString() { + return "dateadd-undef-options"; + } + + dateAdd(date, duration, options) { + this.dateAddCallCount++; + assert.sameValue(options, undefined, "dateAdd shouldn't be called with options"); + return super.dateAdd(date, duration, options); + } + } + return new CalendarDateAddUndefinedOptions(); + }, + + /* + * A custom calendar that asserts its dateAdd() method is called with a + * PlainDate instance. Optionally, it also asserts that the PlainDate instance + * is the specific object `this.specificPlainDate`, if it is set by the + * calling code. + */ + calendarDateAddPlainDateInstance() { + class CalendarDateAddPlainDateInstance extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateAddCallCount = 0; + this.specificPlainDate = undefined; + } + + toString() { + return "dateadd-plain-date-instance"; + } + + dateFromFields(...args) { + return super.dateFromFields(...args).withCalendar(this); + } + + dateAdd(date, duration, options) { + this.dateAddCallCount++; + assert(date instanceof Temporal.PlainDate, "dateAdd() should be called with a PlainDate instance"); + if (this.dateAddCallCount === 1 && this.specificPlainDate) { + assert.sameValue(date, this.specificPlainDate, `dateAdd() should be called first with the specific PlainDate instance ${this.specificPlainDate}`); + } + return super.dateAdd(date, duration, options).withCalendar(this); + } + } + return new CalendarDateAddPlainDateInstance(); + }, + + /* + * A custom calendar that returns @returnValue from its dateUntil() method, + * recording the call in @calls. + */ + calendarDateUntilObservable(calls, returnValue) { + class CalendarDateUntilObservable extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateUntil() { + calls.push("call dateUntil"); + return returnValue; + } + } + + return new CalendarDateUntilObservable(); + }, + + /* + * A custom calendar that returns an iterable instead of an array from its + * fields() method, otherwise identical to the ISO calendar. + */ + calendarFieldsIterable() { + class CalendarFieldsIterable extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.fieldsCallCount = 0; + this.fieldsCalledWith = []; + this.iteratorExhausted = []; + } + + toString() { + return "fields-iterable"; + } + + fields(fieldNames) { + this.fieldsCallCount++; + this.fieldsCalledWith.push(fieldNames.slice()); + this.iteratorExhausted.push(false); + return { + callIndex: this.fieldsCallCount - 1, + calendar: this, + *[Symbol.iterator]() { + yield* this.calendar.fieldsCalledWith[this.callIndex]; + this.calendar.iteratorExhausted[this.callIndex] = true; + }, + }; + } + } + return new CalendarFieldsIterable(); + }, + + /* + * A custom calendar that asserts its ...FromFields() methods are called with + * the options parameter having the value undefined. + */ + calendarFromFieldsUndefinedOptions() { + class CalendarFromFieldsUndefinedOptions extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateFromFieldsCallCount = 0; + this.monthDayFromFieldsCallCount = 0; + this.yearMonthFromFieldsCallCount = 0; + } + + toString() { + return "from-fields-undef-options"; + } + + dateFromFields(fields, options) { + this.dateFromFieldsCallCount++; + assert.sameValue(options, undefined, "dateFromFields shouldn't be called with options"); + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options) { + this.yearMonthFromFieldsCallCount++; + assert.sameValue(options, undefined, "yearMonthFromFields shouldn't be called with options"); + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options) { + this.monthDayFromFieldsCallCount++; + assert.sameValue(options, undefined, "monthDayFromFields shouldn't be called with options"); + return super.monthDayFromFields(fields, options); + } + } + return new CalendarFromFieldsUndefinedOptions(); + }, + + /* + * A custom calendar that modifies the fields object passed in to + * dateFromFields, sabotaging its time properties. + */ + calendarMakeInfinityTime() { + class CalendarMakeInfinityTime extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateFromFields(fields, options) { + const retval = super.dateFromFields(fields, options); + fields.hour = Infinity; + fields.minute = Infinity; + fields.second = Infinity; + fields.millisecond = Infinity; + fields.microsecond = Infinity; + fields.nanosecond = Infinity; + return retval; + } + } + return new CalendarMakeInfinityTime(); + }, + + /* + * A custom calendar that defines getters on the fields object passed into + * dateFromFields that throw, sabotaging its time properties. + */ + calendarMakeInvalidGettersTime() { + class CalendarMakeInvalidGettersTime extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateFromFields(fields, options) { + const retval = super.dateFromFields(fields, options); + const throwingDescriptor = { + get() { + throw new Test262Error("reading a sabotaged time field"); + }, + }; + Object.defineProperties(fields, { + hour: throwingDescriptor, + minute: throwingDescriptor, + second: throwingDescriptor, + millisecond: throwingDescriptor, + microsecond: throwingDescriptor, + nanosecond: throwingDescriptor, + }); + return retval; + } + } + return new CalendarMakeInvalidGettersTime(); + }, + + /* + * A custom calendar whose mergeFields() method returns a proxy object with + * all of its Get and HasProperty operations observable, as well as adding a + * "shouldNotBeCopied": true property. + */ + calendarMergeFieldsGetters() { + class CalendarMergeFieldsGetters extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.mergeFieldsReturnOperations = []; + } + + toString() { + return "merge-fields-getters"; + } + + dateFromFields(fields, options) { + assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options) { + assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options) { + assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); + return super.monthDayFromFields(fields, options); + } + + mergeFields(fields, additionalFields) { + const retval = super.mergeFields(fields, additionalFields); + retval._calendar = this; + retval.shouldNotBeCopied = true; + return new Proxy(retval, { + get(target, key) { + target._calendar.mergeFieldsReturnOperations.push(`get ${key}`); + const result = target[key]; + if (result === undefined) { + return undefined; + } + return TemporalHelpers.toPrimitiveObserver(target._calendar.mergeFieldsReturnOperations, result, key); + }, + has(target, key) { + target._calendar.mergeFieldsReturnOperations.push(`has ${key}`); + return key in target; + }, + }); + } + } + return new CalendarMergeFieldsGetters(); + }, + + /* + * A custom calendar whose mergeFields() method returns a primitive value, + * given by @primitive, and which records the number of calls made to its + * dateFromFields(), yearMonthFromFields(), and monthDayFromFields() methods. + */ + calendarMergeFieldsReturnsPrimitive(primitive) { + class CalendarMergeFieldsPrimitive extends Temporal.Calendar { + constructor(mergeFieldsReturnValue) { + super("iso8601"); + this._mergeFieldsReturnValue = mergeFieldsReturnValue; + this.dateFromFieldsCallCount = 0; + this.monthDayFromFieldsCallCount = 0; + this.yearMonthFromFieldsCallCount = 0; + } + + toString() { + return "merge-fields-primitive"; + } + + dateFromFields(fields, options) { + this.dateFromFieldsCallCount++; + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options) { + this.yearMonthFromFieldsCallCount++; + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options) { + this.monthDayFromFieldsCallCount++; + return super.monthDayFromFields(fields, options); + } + + mergeFields() { + return this._mergeFieldsReturnValue; + } + } + return new CalendarMergeFieldsPrimitive(primitive); + }, + + /* + * crossDateLineTimeZone(): + * + * This returns an instance of a custom time zone class that implements one + * single transition where the time zone moves from one side of the + * International Date Line to the other, for the purpose of testing time zone + * calculations without depending on system time zone data. + * + * The transition occurs at epoch second 1325239200 and goes from offset + * -10:00 to +14:00. In other words, the time zone skips the whole calendar + * day of 2011-12-30. This is the same as the real-life transition in the + * Pacific/Apia time zone. + */ + crossDateLineTimeZone() { + const { compare } = Temporal.PlainDateTime; + const skippedDay = new Temporal.PlainDate(2011, 12, 30); + const transitionEpoch = 1325239200_000_000_000n; + const beforeOffset = new Temporal.TimeZone("-10:00"); + const afterOffset = new Temporal.TimeZone("+14:00"); + + class CrossDateLineTimeZone extends Temporal.TimeZone { + constructor() { + super("+14:00"); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < transitionEpoch) { + return beforeOffset.getOffsetNanosecondsFor(instant); + } + return afterOffset.getOffsetNanosecondsFor(instant); + } + + getPossibleInstantsFor(datetime) { + const comparison = Temporal.PlainDate.compare(datetime.toPlainDate(), skippedDay); + if (comparison === 0) { + return []; + } + if (comparison < 0) { + return [beforeOffset.getInstantFor(datetime)]; + } + return [afterOffset.getInstantFor(datetime)]; + } + + getPreviousTransition(instant) { + if (instant.epochNanoseconds > transitionEpoch) return new Temporal.Instant(transitionEpoch); + return null; + } + + getNextTransition(instant) { + if (instant.epochNanoseconds < transitionEpoch) return new Temporal.Instant(transitionEpoch); + return null; + } + + toString() { + return "Custom/Date_Line"; + } + } + return new CrossDateLineTimeZone(); + }, + + /* + * observeProperty(calls, object, propertyName, value): + * + * Defines an own property @object.@propertyName with value @value, that + * will log any calls to its accessors to the array @calls. + */ + observeProperty(calls, object, propertyName, value, objectName = "") { + Object.defineProperty(object, propertyName, { + get() { + calls.push(`get ${formatPropertyName(propertyName, objectName)}`); + return value; + }, + set(v) { + calls.push(`set ${formatPropertyName(propertyName, objectName)}`); + } + }); + }, + + /* + * observeMethod(calls, object, propertyName, value): + * + * Defines an own property @object.@propertyName with value @value, that + * will log any calls of @value to the array @calls. + */ + observeMethod(calls, object, propertyName, objectName = "") { + const method = object[propertyName]; + object[propertyName] = function () { + calls.push(`call ${formatPropertyName(propertyName, objectName)}`); + return method.apply(object, arguments); + }; + }, + + /* + * Used for substituteMethod to indicate default behavior instead of a + * substituted value + */ + SUBSTITUTE_SKIP: SKIP_SYMBOL, + + /* + * substituteMethod(object, propertyName, values): + * + * Defines an own property @object.@propertyName that will, for each + * subsequent call to the method previously defined as + * @object.@propertyName: + * - Call the method, if no more values remain + * - Call the method, if the value in @values for the corresponding call + * is SUBSTITUTE_SKIP + * - Otherwise, return the corresponding value in @value + */ + substituteMethod(object, propertyName, values) { + let calls = 0; + const method = object[propertyName]; + object[propertyName] = function () { + if (calls >= values.length) { + return method.apply(object, arguments); + } else if (values[calls] === SKIP_SYMBOL) { + calls++; + return method.apply(object, arguments); + } else { + return values[calls++]; + } + }; + }, + + /* + * calendarObserver: + * A custom calendar that behaves exactly like the ISO 8601 calendar but + * tracks calls to any of its methods, and Get/Has operations on its + * properties, by appending messages to an array. This is for the purpose of + * testing order of operations that are observable from user code. + * objectName is used in the log. + */ + calendarObserver(calls, objectName, methodOverrides = {}) { + function removeExtraHasPropertyChecks(objectName, calls) { + // Inserting the tracking calendar into the return values of methods + // that we chain up into the ISO calendar for, causes extra HasProperty + // checks, which we observe. This removes them so that we don't leak + // implementation details of the helper into the test code. + assert.sameValue(calls.pop(), `has ${objectName}.yearOfWeek`); + assert.sameValue(calls.pop(), `has ${objectName}.yearMonthFromFields`); + assert.sameValue(calls.pop(), `has ${objectName}.year`); + assert.sameValue(calls.pop(), `has ${objectName}.weekOfYear`); + assert.sameValue(calls.pop(), `has ${objectName}.monthsInYear`); + assert.sameValue(calls.pop(), `has ${objectName}.monthDayFromFields`); + assert.sameValue(calls.pop(), `has ${objectName}.monthCode`); + assert.sameValue(calls.pop(), `has ${objectName}.month`); + assert.sameValue(calls.pop(), `has ${objectName}.mergeFields`); + assert.sameValue(calls.pop(), `has ${objectName}.inLeapYear`); + assert.sameValue(calls.pop(), `has ${objectName}.id`); + assert.sameValue(calls.pop(), `has ${objectName}.fields`); + assert.sameValue(calls.pop(), `has ${objectName}.daysInYear`); + assert.sameValue(calls.pop(), `has ${objectName}.daysInWeek`); + assert.sameValue(calls.pop(), `has ${objectName}.daysInMonth`); + assert.sameValue(calls.pop(), `has ${objectName}.dayOfYear`); + assert.sameValue(calls.pop(), `has ${objectName}.dayOfWeek`); + assert.sameValue(calls.pop(), `has ${objectName}.day`); + assert.sameValue(calls.pop(), `has ${objectName}.dateUntil`); + assert.sameValue(calls.pop(), `has ${objectName}.dateFromFields`); + assert.sameValue(calls.pop(), `has ${objectName}.dateAdd`); + } + + const iso8601 = new Temporal.Calendar("iso8601"); + const trackingMethods = { + dateFromFields(...args) { + calls.push(`call ${objectName}.dateFromFields`); + if ('dateFromFields' in methodOverrides) { + const value = methodOverrides.dateFromFields; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.dateFromFields(...args); + // Replace the calendar in the result with the call-tracking calendar + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + yearMonthFromFields(...args) { + calls.push(`call ${objectName}.yearMonthFromFields`); + if ('yearMonthFromFields' in methodOverrides) { + const value = methodOverrides.yearMonthFromFields; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.yearMonthFromFields(...args); + // Replace the calendar in the result with the call-tracking calendar + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + monthDayFromFields(...args) { + calls.push(`call ${objectName}.monthDayFromFields`); + if ('monthDayFromFields' in methodOverrides) { + const value = methodOverrides.monthDayFromFields; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.monthDayFromFields(...args); + // Replace the calendar in the result with the call-tracking calendar + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + dateAdd(...args) { + calls.push(`call ${objectName}.dateAdd`); + if ('dateAdd' in methodOverrides) { + const value = methodOverrides.dateAdd; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.dateAdd(...args); + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + id: "iso8601", + }; + // Automatically generate the other methods that don't need any custom code + [ + "dateUntil", + "day", + "dayOfWeek", + "dayOfYear", + "daysInMonth", + "daysInWeek", + "daysInYear", + "era", + "eraYear", + "fields", + "inLeapYear", + "mergeFields", + "month", + "monthCode", + "monthsInYear", + "toString", + "weekOfYear", + "year", + "yearOfWeek", + ].forEach((methodName) => { + trackingMethods[methodName] = function (...args) { + calls.push(`call ${formatPropertyName(methodName, objectName)}`); + if (methodName in methodOverrides) { + const value = methodOverrides[methodName]; + return typeof value === "function" ? value(...args) : value; + } + return iso8601[methodName](...args); + }; + }); + return new Proxy(trackingMethods, { + get(target, key, receiver) { + const result = Reflect.get(target, key, receiver); + calls.push(`get ${formatPropertyName(key, objectName)}`); + return result; + }, + has(target, key) { + calls.push(`has ${formatPropertyName(key, objectName)}`); + return Reflect.has(target, key); + }, + }); + }, + + /* + * A custom calendar that does not allow any of its methods to be called, for + * the purpose of asserting that a particular operation does not call into + * user code. + */ + calendarThrowEverything() { + class CalendarThrowEverything extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + toString() { + TemporalHelpers.assertUnreachable("toString should not be called"); + } + dateFromFields() { + TemporalHelpers.assertUnreachable("dateFromFields should not be called"); + } + yearMonthFromFields() { + TemporalHelpers.assertUnreachable("yearMonthFromFields should not be called"); + } + monthDayFromFields() { + TemporalHelpers.assertUnreachable("monthDayFromFields should not be called"); + } + dateAdd() { + TemporalHelpers.assertUnreachable("dateAdd should not be called"); + } + dateUntil() { + TemporalHelpers.assertUnreachable("dateUntil should not be called"); + } + era() { + TemporalHelpers.assertUnreachable("era should not be called"); + } + eraYear() { + TemporalHelpers.assertUnreachable("eraYear should not be called"); + } + year() { + TemporalHelpers.assertUnreachable("year should not be called"); + } + month() { + TemporalHelpers.assertUnreachable("month should not be called"); + } + monthCode() { + TemporalHelpers.assertUnreachable("monthCode should not be called"); + } + day() { + TemporalHelpers.assertUnreachable("day should not be called"); + } + fields() { + TemporalHelpers.assertUnreachable("fields should not be called"); + } + mergeFields() { + TemporalHelpers.assertUnreachable("mergeFields should not be called"); + } + } + + return new CalendarThrowEverything(); + }, + + /* + * oneShiftTimeZone(shiftInstant, shiftNanoseconds): + * + * In the case of a spring-forward time zone offset transition (skipped time), + * and disambiguation === 'earlier', BuiltinTimeZoneGetInstantFor subtracts a + * negative number of nanoseconds from a PlainDateTime, which should balance + * with the microseconds field. + * + * This returns an instance of a custom time zone class which skips a length + * of time equal to shiftNanoseconds (a number), at the Temporal.Instant + * shiftInstant. Before shiftInstant, it's identical to UTC, and after + * shiftInstant it's a constant-offset time zone. + * + * It provides a getPossibleInstantsForCalledWith member which is an array + * with the result of calling toString() on any PlainDateTimes passed to + * getPossibleInstantsFor(). + */ + oneShiftTimeZone(shiftInstant, shiftNanoseconds) { + class OneShiftTimeZone extends Temporal.TimeZone { + constructor(shiftInstant, shiftNanoseconds) { + super("+00:00"); + this._shiftInstant = shiftInstant; + this._epoch1 = shiftInstant.epochNanoseconds; + this._epoch2 = this._epoch1 + BigInt(shiftNanoseconds); + this._shiftNanoseconds = shiftNanoseconds; + this._shift = new Temporal.Duration(0, 0, 0, 0, 0, 0, 0, 0, 0, this._shiftNanoseconds); + this.getPossibleInstantsForCalledWith = []; + } + + _isBeforeShift(instant) { + return instant.epochNanoseconds < this._epoch1; + } + + getOffsetNanosecondsFor(instant) { + return this._isBeforeShift(instant) ? 0 : this._shiftNanoseconds; + } + + getPossibleInstantsFor(plainDateTime) { + this.getPossibleInstantsForCalledWith.push(plainDateTime.toString()); + const [instant] = super.getPossibleInstantsFor(plainDateTime); + if (this._shiftNanoseconds > 0) { + if (this._isBeforeShift(instant)) return [instant]; + if (instant.epochNanoseconds < this._epoch2) return []; + return [instant.subtract(this._shift)]; + } + if (instant.epochNanoseconds < this._epoch2) return [instant]; + const shifted = instant.subtract(this._shift); + if (this._isBeforeShift(instant)) return [instant, shifted]; + return [shifted]; + } + + getNextTransition(instant) { + return this._isBeforeShift(instant) ? this._shiftInstant : null; + } + + getPreviousTransition(instant) { + return this._isBeforeShift(instant) ? null : this._shiftInstant; + } + + toString() { + return "Custom/One_Shift"; + } + } + return new OneShiftTimeZone(shiftInstant, shiftNanoseconds); + }, + + /* + * propertyBagObserver(): + * Returns an object that behaves like the given propertyBag but tracks Get + * and Has operations on any of its properties, by appending messages to an + * array. If the value of a property in propertyBag is a primitive, the value + * of the returned object's property will additionally be a + * TemporalHelpers.toPrimitiveObserver that will track calls to its toString + * and valueOf methods in the same array. This is for the purpose of testing + * order of operations that are observable from user code. objectName is used + * in the log. + */ + propertyBagObserver(calls, propertyBag, objectName) { + return new Proxy(propertyBag, { + ownKeys(target) { + calls.push(`ownKeys ${objectName}`); + return Reflect.ownKeys(target); + }, + getOwnPropertyDescriptor(target, key) { + calls.push(`getOwnPropertyDescriptor ${formatPropertyName(key, objectName)}`); + return Reflect.getOwnPropertyDescriptor(target, key); + }, + get(target, key, receiver) { + calls.push(`get ${formatPropertyName(key, objectName)}`); + const result = Reflect.get(target, key, receiver); + if (result === undefined) { + return undefined; + } + if ((result !== null && typeof result === "object") || typeof result === "function") { + return result; + } + return TemporalHelpers.toPrimitiveObserver(calls, result, `${formatPropertyName(key, objectName)}`); + }, + has(target, key) { + calls.push(`has ${formatPropertyName(key, objectName)}`); + return Reflect.has(target, key); + }, + }); + }, + + /* + * specificOffsetTimeZone(): + * + * This returns an instance of a custom time zone class, which returns a + * specific custom value from its getOffsetNanosecondsFrom() method. This is + * for the purpose of testing the validation of what this method returns. + * + * It also returns an empty array from getPossibleInstantsFor(), so as to + * trigger calls to getOffsetNanosecondsFor() when used from the + * BuiltinTimeZoneGetInstantFor operation. + */ + specificOffsetTimeZone(offsetValue) { + class SpecificOffsetTimeZone extends Temporal.TimeZone { + constructor(offsetValue) { + super("UTC"); + this._offsetValue = offsetValue; + } + + getOffsetNanosecondsFor() { + return this._offsetValue; + } + + getPossibleInstantsFor() { + return []; + } + } + return new SpecificOffsetTimeZone(offsetValue); + }, + + /* + * springForwardFallBackTimeZone(): + * + * This returns an instance of a custom time zone class that implements one + * single spring-forward/fall-back transition, for the purpose of testing the + * disambiguation option, without depending on system time zone data. + * + * The spring-forward occurs at epoch second 954669600 (2000-04-02T02:00 + * local) and goes from offset -08:00 to -07:00. + * + * The fall-back occurs at epoch second 972810000 (2000-10-29T02:00 local) and + * goes from offset -07:00 to -08:00. + */ + springForwardFallBackTimeZone() { + const { compare } = Temporal.PlainDateTime; + const springForwardLocal = new Temporal.PlainDateTime(2000, 4, 2, 2); + const springForwardEpoch = 954669600_000_000_000n; + const fallBackLocal = new Temporal.PlainDateTime(2000, 10, 29, 1); + const fallBackEpoch = 972810000_000_000_000n; + const winterOffset = new Temporal.TimeZone('-08:00'); + const summerOffset = new Temporal.TimeZone('-07:00'); + + class SpringForwardFallBackTimeZone extends Temporal.TimeZone { + constructor() { + super("-08:00"); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < springForwardEpoch || + instant.epochNanoseconds >= fallBackEpoch) { + return winterOffset.getOffsetNanosecondsFor(instant); + } + return summerOffset.getOffsetNanosecondsFor(instant); + } + + getPossibleInstantsFor(datetime) { + if (compare(datetime, springForwardLocal) >= 0 && compare(datetime, springForwardLocal.add({ hours: 1 })) < 0) { + return []; + } + if (compare(datetime, fallBackLocal) >= 0 && compare(datetime, fallBackLocal.add({ hours: 1 })) < 0) { + return [summerOffset.getInstantFor(datetime), winterOffset.getInstantFor(datetime)]; + } + if (compare(datetime, springForwardLocal) < 0 || compare(datetime, fallBackLocal) >= 0) { + return [winterOffset.getInstantFor(datetime)]; + } + return [summerOffset.getInstantFor(datetime)]; + } + + getPreviousTransition(instant) { + if (instant.epochNanoseconds > fallBackEpoch) return new Temporal.Instant(fallBackEpoch); + if (instant.epochNanoseconds > springForwardEpoch) return new Temporal.Instant(springForwardEpoch); + return null; + } + + getNextTransition(instant) { + if (instant.epochNanoseconds < springForwardEpoch) return new Temporal.Instant(springForwardEpoch); + if (instant.epochNanoseconds < fallBackEpoch) return new Temporal.Instant(fallBackEpoch); + return null; + } + + get id() { + return "Custom/Spring_Fall"; + } + + toString() { + return "Custom/Spring_Fall"; + } + } + return new SpringForwardFallBackTimeZone(); + }, + + /* + * timeZoneObserver: + * A custom calendar that behaves exactly like the UTC time zone but tracks + * calls to any of its methods, and Get/Has operations on its properties, by + * appending messages to an array. This is for the purpose of testing order of + * operations that are observable from user code. objectName is used in the + * log. methodOverrides is an optional object containing properties with the + * same name as Temporal.TimeZone methods. If the property value is a function + * it will be called with the proper arguments instead of the UTC method. + * Otherwise, the property value will be returned directly. + */ + timeZoneObserver(calls, objectName, methodOverrides = {}) { + const utc = new Temporal.TimeZone("UTC"); + const trackingMethods = { + id: "UTC", + }; + // Automatically generate the methods + ["getOffsetNanosecondsFor", "getPossibleInstantsFor", "toString"].forEach((methodName) => { + trackingMethods[methodName] = function (...args) { + calls.push(`call ${formatPropertyName(methodName, objectName)}`); + if (methodName in methodOverrides) { + const value = methodOverrides[methodName]; + return typeof value === "function" ? value(...args) : value; + } + return utc[methodName](...args); + }; + }); + return new Proxy(trackingMethods, { + get(target, key, receiver) { + const result = Reflect.get(target, key, receiver); + calls.push(`get ${formatPropertyName(key, objectName)}`); + return result; + }, + has(target, key) { + calls.push(`has ${formatPropertyName(key, objectName)}`); + return Reflect.has(target, key); + }, + }); + }, + + /* + * Returns an object that will append logs of any Gets or Calls of its valueOf + * or toString properties to the array calls. Both valueOf and toString will + * return the actual primitiveValue. propertyName is used in the log. + */ + toPrimitiveObserver(calls, primitiveValue, propertyName) { + return { + get valueOf() { + calls.push(`get ${propertyName}.valueOf`); + return function () { + calls.push(`call ${propertyName}.valueOf`); + return primitiveValue; + }; + }, + get toString() { + calls.push(`get ${propertyName}.toString`); + return function () { + calls.push(`call ${propertyName}.toString`); + if (primitiveValue === undefined) return undefined; + return primitiveValue.toString(); + }; + }, + }; + }, + + /* + * An object containing further methods that return arrays of ISO strings, for + * testing parsers. + */ + ISO: { + /* + * PlainMonthDay strings that are not valid. + */ + plainMonthDayStringsInvalid() { + return [ + "11-18junk", + ]; + }, + + /* + * PlainMonthDay strings that are valid and that should produce October 1st. + */ + plainMonthDayStringsValid() { + return [ + "10-01", + "1001", + "1965-10-01", + "1976-10-01T152330.1+00:00", + "19761001T15:23:30.1+00:00", + "1976-10-01T15:23:30.1+0000", + "1976-10-01T152330.1+0000", + "19761001T15:23:30.1+0000", + "19761001T152330.1+00:00", + "19761001T152330.1+0000", + "+001976-10-01T152330.1+00:00", + "+0019761001T15:23:30.1+00:00", + "+001976-10-01T15:23:30.1+0000", + "+001976-10-01T152330.1+0000", + "+0019761001T15:23:30.1+0000", + "+0019761001T152330.1+00:00", + "+0019761001T152330.1+0000", + "1976-10-01T15:23:00", + "1976-10-01T15:23", + "1976-10-01T15", + "1976-10-01", + "--10-01", + "--1001", + ]; + }, + + /* + * PlainTime strings that may be mistaken for PlainMonthDay or + * PlainYearMonth strings, and so require a time designator. + */ + plainTimeStringsAmbiguous() { + const ambiguousStrings = [ + "2021-12", // ambiguity between YYYY-MM and HHMM-UU + "2021-12[-12:00]", // ditto, TZ does not disambiguate + "1214", // ambiguity between MMDD and HHMM + "0229", // ditto, including MMDD that doesn't occur every year + "1130", // ditto, including DD that doesn't occur in every month + "12-14", // ambiguity between MM-DD and HH-UU + "12-14[-14:00]", // ditto, TZ does not disambiguate + "202112", // ambiguity between YYYYMM and HHMMSS + "202112[UTC]", // ditto, TZ does not disambiguate + ]; + // Adding a calendar annotation to one of these strings must not cause + // disambiguation in favour of time. + const stringsWithCalendar = ambiguousStrings.map((s) => s + '[u-ca=iso8601]'); + return ambiguousStrings.concat(stringsWithCalendar); + }, + + /* + * PlainTime strings that are of similar form to PlainMonthDay and + * PlainYearMonth strings, but are not ambiguous due to components that + * aren't valid as months or days. + */ + plainTimeStringsUnambiguous() { + return [ + "2021-13", // 13 is not a month + "202113", // ditto + "2021-13[-13:00]", // ditto + "202113[-13:00]", // ditto + "0000-00", // 0 is not a month + "000000", // ditto + "0000-00[UTC]", // ditto + "000000[UTC]", // ditto + "1314", // 13 is not a month + "13-14", // ditto + "1232", // 32 is not a day + "0230", // 30 is not a day in February + "0631", // 31 is not a day in June + "0000", // 0 is neither a month nor a day + "00-00", // ditto + ]; + }, + + /* + * PlainYearMonth-like strings that are not valid. + */ + plainYearMonthStringsInvalid() { + return [ + "2020-13", + ]; + }, + + /* + * PlainYearMonth-like strings that are valid and should produce November + * 1976 in the ISO 8601 calendar. + */ + plainYearMonthStringsValid() { + return [ + "1976-11", + "1976-11-10", + "1976-11-01T09:00:00+00:00", + "1976-11-01T00:00:00+05:00", + "197611", + "+00197611", + "1976-11-18T15:23:30.1\u221202:00", + "1976-11-18T152330.1+00:00", + "19761118T15:23:30.1+00:00", + "1976-11-18T15:23:30.1+0000", + "1976-11-18T152330.1+0000", + "19761118T15:23:30.1+0000", + "19761118T152330.1+00:00", + "19761118T152330.1+0000", + "+001976-11-18T152330.1+00:00", + "+0019761118T15:23:30.1+00:00", + "+001976-11-18T15:23:30.1+0000", + "+001976-11-18T152330.1+0000", + "+0019761118T15:23:30.1+0000", + "+0019761118T152330.1+00:00", + "+0019761118T152330.1+0000", + "1976-11-18T15:23", + "1976-11-18T15", + "1976-11-18", + ]; + }, + + /* + * PlainYearMonth-like strings that are valid and should produce November of + * the ISO year -9999. + */ + plainYearMonthStringsValidNegativeYear() { + return [ + "\u2212009999-11", + ]; + }, + } +}; diff --git a/harness/testAtomics.js b/harness/testAtomics.js new file mode 100644 index 00000000000..8dd9ff365fa --- /dev/null +++ b/harness/testAtomics.js @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to assert the correctness of SharedArrayBuffer objects. +defines: + - testWithAtomicsOutOfBoundsIndices + - testWithAtomicsInBoundsIndices + - testWithAtomicsNonViewValues +---*/ + + +/** + * Calls the provided function for a each bad index that should throw a + * RangeError when passed to an Atomics method on a SAB-backed view where + * index 125 is out of range. + * + * @param f - the function to call for each bad index. + */ +function testWithAtomicsOutOfBoundsIndices(f) { + var bad_indices = [ + function(view) { return -1; }, + function(view) { return view.length; }, + function(view) { return view.length * 2; }, + function(view) { return Number.POSITIVE_INFINITY; }, + function(view) { return Number.NEGATIVE_INFINITY; }, + function(view) { return { valueOf: function() { return 125; } }; }, + function(view) { return { toString: function() { return '125'; }, valueOf: false }; }, // non-callable valueOf triggers invocation of toString + ]; + + for (var i = 0; i < bad_indices.length; ++i) { + var IdxGen = bad_indices[i]; + try { + f(IdxGen); + } catch (e) { + e.message += ' (Testing with index gen ' + IdxGen + '.)'; + throw e; + } + } +} + +/** + * Calls the provided function for each good index that should not throw when + * passed to an Atomics method on a SAB-backed view. + * + * The view must have length greater than zero. + * + * @param f - the function to call for each good index. + */ +function testWithAtomicsInBoundsIndices(f) { + // Most of these are eventually coerced to +0 by ToIndex. + var good_indices = [ + function(view) { return 0/-1; }, + function(view) { return '-0'; }, + function(view) { return undefined; }, + function(view) { return NaN; }, + function(view) { return 0.5; }, + function(view) { return '0.5'; }, + function(view) { return -0.9; }, + function(view) { return { password: 'qumquat' }; }, + function(view) { return view.length - 1; }, + function(view) { return { valueOf: function() { return 0; } }; }, + function(view) { return { toString: function() { return '0'; }, valueOf: false }; }, // non-callable valueOf triggers invocation of toString + ]; + + for (var i = 0; i < good_indices.length; ++i) { + var IdxGen = good_indices[i]; + try { + f(IdxGen); + } catch (e) { + e.message += ' (Testing with index gen ' + IdxGen + '.)'; + throw e; + } + } +} + +/** + * Calls the provided function for each value that should throw a TypeError + * when passed to an Atomics method as a view. + * + * @param f - the function to call for each non-view value. + */ + +function testWithAtomicsNonViewValues(f) { + var values = [ + null, + undefined, + true, + false, + new Boolean(true), + 10, + 3.14, + new Number(4), + 'Hi there', + new Date, + /a*utomaton/g, + { password: 'qumquat' }, + new DataView(new ArrayBuffer(10)), + new ArrayBuffer(128), + new SharedArrayBuffer(128), + new Error('Ouch'), + [1,1,2,3,5,8], + function(x) { return -x; }, + Symbol('halleluja'), + // TODO: Proxy? + Object, + Int32Array, + Date, + Math, + Atomics + ]; + + for (var i = 0; i < values.length; ++i) { + var nonView = values[i]; + try { + f(nonView); + } catch (e) { + e.message += ' (Testing with non-view value ' + nonView + '.)'; + throw e; + } + } +} + diff --git a/harness/testBigIntTypedArray.js b/harness/testBigIntTypedArray.js new file mode 100644 index 00000000000..4956aaa7e35 --- /dev/null +++ b/harness/testBigIntTypedArray.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to assert the correctness of BigInt TypedArray objects. +defines: + - TypedArray + - testWithBigIntTypedArrayConstructors +---*/ + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithBigIntTypedArrayConstructors(f, selected) { + /** + * Array containing every BigInt typed array constructor. + */ + var constructors = selected || [ + BigInt64Array, + BigUint64Array + ]; + + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} diff --git a/harness/testIntl.js b/harness/testIntl.js new file mode 100644 index 00000000000..94efe546c30 --- /dev/null +++ b/harness/testIntl.js @@ -0,0 +1,2510 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + This file contains shared functions for the tests in the conformance test + suite for the ECMAScript Internationalization API. +author: Norbert Lindenberg +defines: + - testWithIntlConstructors + - taintDataProperty + - taintMethod + - taintProperties + - taintArray + - getLocaleSupportInfo + - getInvalidLanguageTags + - isCanonicalizedStructurallyValidLanguageTag + - getInvalidLocaleArguments + - testOption + - testForUnwantedRegExpChanges + - allCalendars + - allCollations + - allNumberingSystems + - isValidNumberingSystem + - numberingSystemDigits + - allSimpleSanctionedUnits + - testNumberFormat + - getDateTimeComponents + - getDateTimeComponentValues + - isCanonicalizedStructurallyValidTimeZoneName +---*/ +/** + */ + + +/** + * @description Calls the provided function for every service constructor in + * the Intl object. + * @param {Function} f the function to call for each service constructor in + * the Intl object. + * @param {Function} Constructor the constructor object to test with. + */ +function testWithIntlConstructors(f) { + var constructors = ["Collator", "NumberFormat", "DateTimeFormat"]; + + // Optionally supported Intl constructors. + // NB: Intl.Locale isn't an Intl service constructor! + // Intl.DisplayNames cannot be called without type in options. + ["PluralRules", "RelativeTimeFormat", "ListFormat"].forEach(function(constructor) { + if (typeof Intl[constructor] === "function") { + constructors[constructors.length] = constructor; + } + }); + + constructors.forEach(function (constructor) { + var Constructor = Intl[constructor]; + try { + f(Constructor); + } catch (e) { + e.message += " (Testing with " + constructor + ".)"; + throw e; + } + }); +} + + +/** + * Taints a named data property of the given object by installing + * a setter that throws an exception. + * @param {object} obj the object whose data property to taint + * @param {string} property the property to taint + */ +function taintDataProperty(obj, property) { + Object.defineProperty(obj, property, { + set: function(value) { + throw new Test262Error("Client code can adversely affect behavior: setter for " + property + "."); + }, + enumerable: false, + configurable: true + }); +} + + +/** + * Taints a named method of the given object by replacing it with a function + * that throws an exception. + * @param {object} obj the object whose method to taint + * @param {string} property the name of the method to taint + */ +function taintMethod(obj, property) { + Object.defineProperty(obj, property, { + value: function() { + throw new Test262Error("Client code can adversely affect behavior: method " + property + "."); + }, + writable: true, + enumerable: false, + configurable: true + }); +} + + +/** + * Taints the given properties (and similarly named properties) by installing + * setters on Object.prototype that throw exceptions. + * @param {Array} properties an array of property names to taint + */ +function taintProperties(properties) { + properties.forEach(function (property) { + var adaptedProperties = [property, "__" + property, "_" + property, property + "_", property + "__"]; + adaptedProperties.forEach(function (property) { + taintDataProperty(Object.prototype, property); + }); + }); +} + + +/** + * Taints the Array object by creating a setter for the property "0" and + * replacing some key methods with functions that throw exceptions. + */ +function taintArray() { + taintDataProperty(Array.prototype, "0"); + taintMethod(Array.prototype, "indexOf"); + taintMethod(Array.prototype, "join"); + taintMethod(Array.prototype, "push"); + taintMethod(Array.prototype, "slice"); + taintMethod(Array.prototype, "sort"); +} + + +/** + * Gets locale support info for the given constructor object, which must be one + * of Intl constructors. + * @param {object} Constructor the constructor for which to get locale support info + * @param {object} options the options while calling the constructor + * @return {object} locale support info with the following properties: + * supported: array of fully supported language tags + * byFallback: array of language tags that are supported through fallbacks + * unsupported: array of unsupported language tags + */ +function getLocaleSupportInfo(Constructor, options) { + var languages = ["zh", "es", "en", "hi", "ur", "ar", "ja", "pa"]; + var scripts = ["Latn", "Hans", "Deva", "Arab", "Jpan", "Hant", "Guru"]; + var countries = ["CN", "IN", "US", "PK", "JP", "TW", "HK", "SG", "419"]; + + var allTags = []; + var i, j, k; + var language, script, country; + for (i = 0; i < languages.length; i++) { + language = languages[i]; + allTags.push(language); + for (j = 0; j < scripts.length; j++) { + script = scripts[j]; + allTags.push(language + "-" + script); + for (k = 0; k < countries.length; k++) { + country = countries[k]; + allTags.push(language + "-" + script + "-" + country); + } + } + for (k = 0; k < countries.length; k++) { + country = countries[k]; + allTags.push(language + "-" + country); + } + } + + var supported = []; + var byFallback = []; + var unsupported = []; + for (i = 0; i < allTags.length; i++) { + var request = allTags[i]; + var result = new Constructor([request], options).resolvedOptions().locale; + if (request === result) { + supported.push(request); + } else if (request.indexOf(result) === 0) { + byFallback.push(request); + } else { + unsupported.push(request); + } + } + + return { + supported: supported, + byFallback: byFallback, + unsupported: unsupported + }; +} + + +/** + * Returns an array of strings for which IsStructurallyValidLanguageTag() returns false + */ +function getInvalidLanguageTags() { + var invalidLanguageTags = [ + "", // empty tag + "i", // singleton alone + "x", // private use without subtag + "u", // extension singleton in first place + "419", // region code in first place + "u-nu-latn-cu-bob", // extension sequence without language + "hans-cmn-cn", // "hans" could theoretically be a 4-letter language code, + // but those can't be followed by extlang codes. + "cmn-hans-cn-u-u", // duplicate singleton + "cmn-hans-cn-t-u-ca-u", // duplicate singleton + "de-gregory-gregory", // duplicate variant + "*", // language range + "de-*", // language range + "中文", // non-ASCII letters + "en-ß", // non-ASCII letters + "ıd", // non-ASCII letters + "es-Latn-latn", // two scripts + "pl-PL-pl", // two regions + "u-ca-gregory", // extension in first place + "de-1996-1996", // duplicate numeric variant + "pt-u-ca-gregory-u-nu-latn", // duplicate singleton subtag + + // Invalid tags starting with: https://github.com/tc39/ecma402/pull/289 + "no-nyn", // regular grandfathered in BCP47, but invalid in UTS35 + "i-klingon", // irregular grandfathered in BCP47, but invalid in UTS35 + "zh-hak-CN", // language with extlang in BCP47, but invalid in UTS35 + "sgn-ils", // language with extlang in BCP47, but invalid in UTS35 + "x-foo", // privateuse-only in BCP47, but invalid in UTS35 + "x-en-US-12345", // more privateuse-only variants. + "x-12345-12345-en-US", + "x-en-US-12345-12345", + "x-en-u-foo", + "x-en-u-foo-u-bar", + "x-u-foo", + + // underscores in different parts of the language tag + "de_DE", + "DE_de", + "cmn_Hans", + "cmn-hans_cn", + "es_419", + "es-419-u-nu-latn-cu_bob", + "i_klingon", + "cmn-hans-cn-t-ca-u-ca-x_t-u", + "enochian_enochian", + "de-gregory_u-ca-gregory", + + "en\u0000", // null-terminator sequence + " en", // leading whitespace + "en ", // trailing whitespace + "it-IT-Latn", // country before script tag + "de-u", // incomplete Unicode extension sequences + "de-u-", + "de-u-ca-", + "de-u-ca-gregory-", + "si-x", // incomplete private-use tags + "x-", + "x-y-", + ]; + + // make sure the data above is correct + for (var i = 0; i < invalidLanguageTags.length; ++i) { + var invalidTag = invalidLanguageTags[i]; + assert( + !isCanonicalizedStructurallyValidLanguageTag(invalidTag), + "Test data \"" + invalidTag + "\" is a canonicalized and structurally valid language tag." + ); + } + + return invalidLanguageTags; +} + + +/** + * @description Tests whether locale is a String value representing a + * structurally valid and canonicalized BCP 47 language tag, as defined in + * sections 6.2.2 and 6.2.3 of the ECMAScript Internationalization API + * Specification. + * @param {String} locale the string to be tested. + * @result {Boolean} whether the test succeeded. + */ +function isCanonicalizedStructurallyValidLanguageTag(locale) { + + /** + * Regular expression defining Unicode BCP 47 Locale Identifiers. + * + * Spec: https://unicode.org/reports/tr35/#Unicode_locale_identifier + */ + var alpha = "[a-z]", + digit = "[0-9]", + alphanum = "[a-z0-9]", + variant = "(" + alphanum + "{5,8}|(?:" + digit + alphanum + "{3}))", + region = "(" + alpha + "{2}|" + digit + "{3})", + script = "(" + alpha + "{4})", + language = "(" + alpha + "{2,3}|" + alpha + "{5,8})", + privateuse = "(x(-[a-z0-9]{1,8})+)", + singleton = "(" + digit + "|[a-wy-z])", + attribute= "(" + alphanum + "{3,8})", + keyword = "(" + alphanum + alpha + "(-" + alphanum + "{3,8})*)", + unicode_locale_extensions = "(u((-" + keyword + ")+|((-" + attribute + ")+(-" + keyword + ")*)))", + tlang = "(" + language + "(-" + script + ")?(-" + region + ")?(-" + variant + ")*)", + tfield = "(" + alpha + digit + "(-" + alphanum + "{3,8})+)", + transformed_extensions = "(t((-" + tlang + "(-" + tfield + ")*)|(-" + tfield + ")+))", + other_singleton = "(" + digit + "|[a-sv-wy-z])", + other_extensions = "(" + other_singleton + "(-" + alphanum + "{2,8})+)", + extension = "(" + unicode_locale_extensions + "|" + transformed_extensions + "|" + other_extensions + ")", + locale_id = language + "(-" + script + ")?(-" + region + ")?(-" + variant + ")*(-" + extension + ")*(-" + privateuse + ")?", + languageTag = "^(" + locale_id + ")$", + languageTagRE = new RegExp(languageTag, "i"); + + var duplicateSingleton = "-" + singleton + "-(.*-)?\\1(?!" + alphanum + ")", + duplicateSingletonRE = new RegExp(duplicateSingleton, "i"), + duplicateVariant = "(" + alphanum + "{2,8}-)+" + variant + "-(" + alphanum + "{2,8}-)*\\2(?!" + alphanum + ")", + duplicateVariantRE = new RegExp(duplicateVariant, "i"); + + var transformKeyRE = new RegExp("^" + alpha + digit + "$", "i"); + + /** + * Verifies that the given string is a well-formed Unicode BCP 47 Locale Identifier + * with no duplicate variant or singleton subtags. + * + * Spec: ECMAScript Internationalization API Specification, draft, 6.2.2. + */ + function isStructurallyValidLanguageTag(locale) { + if (!languageTagRE.test(locale)) { + return false; + } + locale = locale.split(/-x-/)[0]; + return !duplicateSingletonRE.test(locale) && !duplicateVariantRE.test(locale); + } + + + /** + * Mappings from complete tags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __tagMappings = { + // property names must be in lower case; values in canonical form + + "art-lojban": "jbo", + "cel-gaulish": "xtg", + "zh-guoyu": "zh", + "zh-hakka": "hak", + "zh-xiang": "hsn", + }; + + + /** + * Mappings from language subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __languageMappings = { + // property names and values must be in canonical case + + "aam": "aas", + "aar": "aa", + "abk": "ab", + "adp": "dz", + "afr": "af", + "aju": "jrb", + "aka": "ak", + "alb": "sq", + "als": "sq", + "amh": "am", + "ara": "ar", + "arb": "ar", + "arg": "an", + "arm": "hy", + "asd": "snz", + "asm": "as", + "aue": "ktz", + "ava": "av", + "ave": "ae", + "aym": "ay", + "ayr": "ay", + "ayx": "nun", + "aze": "az", + "azj": "az", + "bak": "ba", + "bam": "bm", + "baq": "eu", + "bcc": "bal", + "bcl": "bik", + "bel": "be", + "ben": "bn", + "bgm": "bcg", + "bh": "bho", + "bih": "bho", + "bis": "bi", + "bjd": "drl", + "bod": "bo", + "bos": "bs", + "bre": "br", + "bul": "bg", + "bur": "my", + "bxk": "luy", + "bxr": "bua", + "cat": "ca", + "ccq": "rki", + "ces": "cs", + "cha": "ch", + "che": "ce", + "chi": "zh", + "chu": "cu", + "chv": "cv", + "cjr": "mom", + "cka": "cmr", + "cld": "syr", + "cmk": "xch", + "cmn": "zh", + "cor": "kw", + "cos": "co", + "coy": "pij", + "cqu": "quh", + "cre": "cr", + "cwd": "cr", + "cym": "cy", + "cze": "cs", + "dan": "da", + "deu": "de", + "dgo": "doi", + "dhd": "mwr", + "dik": "din", + "diq": "zza", + "dit": "dif", + "div": "dv", + "drh": "mn", + "dut": "nl", + "dzo": "dz", + "ekk": "et", + "ell": "el", + "emk": "man", + "eng": "en", + "epo": "eo", + "esk": "ik", + "est": "et", + "eus": "eu", + "ewe": "ee", + "fao": "fo", + "fas": "fa", + "fat": "ak", + "fij": "fj", + "fin": "fi", + "fra": "fr", + "fre": "fr", + "fry": "fy", + "fuc": "ff", + "ful": "ff", + "gav": "dev", + "gaz": "om", + "gbo": "grb", + "geo": "ka", + "ger": "de", + "gfx": "vaj", + "ggn": "gvr", + "gla": "gd", + "gle": "ga", + "glg": "gl", + "glv": "gv", + "gno": "gon", + "gre": "el", + "grn": "gn", + "gti": "nyc", + "gug": "gn", + "guj": "gu", + "guv": "duz", + "gya": "gba", + "hat": "ht", + "hau": "ha", + "hdn": "hai", + "hea": "hmn", + "heb": "he", + "her": "hz", + "him": "srx", + "hin": "hi", + "hmo": "ho", + "hrr": "jal", + "hrv": "hr", + "hun": "hu", + "hye": "hy", + "ibi": "opa", + "ibo": "ig", + "ice": "is", + "ido": "io", + "iii": "ii", + "ike": "iu", + "iku": "iu", + "ile": "ie", + "ilw": "gal", + "in": "id", + "ina": "ia", + "ind": "id", + "ipk": "ik", + "isl": "is", + "ita": "it", + "iw": "he", + "jav": "jv", + "jeg": "oyb", + "ji": "yi", + "jpn": "ja", + "jw": "jv", + "kal": "kl", + "kan": "kn", + "kas": "ks", + "kat": "ka", + "kau": "kr", + "kaz": "kk", + "kgc": "tdf", + "kgh": "kml", + "khk": "mn", + "khm": "km", + "kik": "ki", + "kin": "rw", + "kir": "ky", + "kmr": "ku", + "knc": "kr", + "kng": "kg", + "knn": "kok", + "koj": "kwv", + "kom": "kv", + "kon": "kg", + "kor": "ko", + "kpv": "kv", + "krm": "bmf", + "ktr": "dtp", + "kua": "kj", + "kur": "ku", + "kvs": "gdj", + "kwq": "yam", + "kxe": "tvd", + "kzj": "dtp", + "kzt": "dtp", + "lao": "lo", + "lat": "la", + "lav": "lv", + "lbk": "bnc", + "lii": "raq", + "lim": "li", + "lin": "ln", + "lit": "lt", + "llo": "ngt", + "lmm": "rmx", + "ltz": "lb", + "lub": "lu", + "lug": "lg", + "lvs": "lv", + "mac": "mk", + "mah": "mh", + "mal": "ml", + "mao": "mi", + "mar": "mr", + "may": "ms", + "meg": "cir", + "mhr": "chm", + "mkd": "mk", + "mlg": "mg", + "mlt": "mt", + "mnk": "man", + "mo": "ro", + "mol": "ro", + "mon": "mn", + "mri": "mi", + "msa": "ms", + "mst": "mry", + "mup": "raj", + "mwj": "vaj", + "mya": "my", + "myd": "aog", + "myt": "mry", + "nad": "xny", + "nau": "na", + "nav": "nv", + "nbl": "nr", + "ncp": "kdz", + "nde": "nd", + "ndo": "ng", + "nep": "ne", + "nld": "nl", + "nno": "nn", + "nns": "nbr", + "nnx": "ngv", + "no": "nb", + "nob": "nb", + "nor": "nb", + "npi": "ne", + "nts": "pij", + "nya": "ny", + "oci": "oc", + "ojg": "oj", + "oji": "oj", + "ori": "or", + "orm": "om", + "ory": "or", + "oss": "os", + "oun": "vaj", + "pan": "pa", + "pbu": "ps", + "pcr": "adx", + "per": "fa", + "pes": "fa", + "pli": "pi", + "plt": "mg", + "pmc": "huw", + "pmu": "phr", + "pnb": "lah", + "pol": "pl", + "por": "pt", + "ppa": "bfy", + "ppr": "lcq", + "pry": "prt", + "pus": "ps", + "puz": "pub", + "que": "qu", + "quz": "qu", + "rmy": "rom", + "roh": "rm", + "ron": "ro", + "rum": "ro", + "run": "rn", + "rus": "ru", + "sag": "sg", + "san": "sa", + "sca": "hle", + "scc": "sr", + "scr": "hr", + "sin": "si", + "skk": "oyb", + "slk": "sk", + "slo": "sk", + "slv": "sl", + "sme": "se", + "smo": "sm", + "sna": "sn", + "snd": "sd", + "som": "so", + "sot": "st", + "spa": "es", + "spy": "kln", + "sqi": "sq", + "src": "sc", + "srd": "sc", + "srp": "sr", + "ssw": "ss", + "sun": "su", + "swa": "sw", + "swe": "sv", + "swh": "sw", + "tah": "ty", + "tam": "ta", + "tat": "tt", + "tdu": "dtp", + "tel": "te", + "tgk": "tg", + "tgl": "fil", + "tha": "th", + "thc": "tpo", + "thx": "oyb", + "tib": "bo", + "tie": "ras", + "tir": "ti", + "tkk": "twm", + "tl": "fil", + "tlw": "weo", + "tmp": "tyj", + "tne": "kak", + "ton": "to", + "tsf": "taj", + "tsn": "tn", + "tso": "ts", + "ttq": "tmh", + "tuk": "tk", + "tur": "tr", + "tw": "ak", + "twi": "ak", + "uig": "ug", + "ukr": "uk", + "umu": "del", + "uok": "ema", + "urd": "ur", + "uzb": "uz", + "uzn": "uz", + "ven": "ve", + "vie": "vi", + "vol": "vo", + "wel": "cy", + "wln": "wa", + "wol": "wo", + "xba": "cax", + "xho": "xh", + "xia": "acn", + "xkh": "waw", + "xpe": "kpe", + "xsj": "suj", + "xsl": "den", + "ybd": "rki", + "ydd": "yi", + "yid": "yi", + "yma": "lrr", + "ymt": "mtm", + "yor": "yo", + "yos": "zom", + "yuu": "yug", + "zai": "zap", + "zha": "za", + "zho": "zh", + "zsm": "ms", + "zul": "zu", + "zyb": "za", + }; + + + /** + * Mappings from region subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __regionMappings = { + // property names and values must be in canonical case + + "004": "AF", + "008": "AL", + "010": "AQ", + "012": "DZ", + "016": "AS", + "020": "AD", + "024": "AO", + "028": "AG", + "031": "AZ", + "032": "AR", + "036": "AU", + "040": "AT", + "044": "BS", + "048": "BH", + "050": "BD", + "051": "AM", + "052": "BB", + "056": "BE", + "060": "BM", + "062": "034", + "064": "BT", + "068": "BO", + "070": "BA", + "072": "BW", + "074": "BV", + "076": "BR", + "084": "BZ", + "086": "IO", + "090": "SB", + "092": "VG", + "096": "BN", + "100": "BG", + "104": "MM", + "108": "BI", + "112": "BY", + "116": "KH", + "120": "CM", + "124": "CA", + "132": "CV", + "136": "KY", + "140": "CF", + "144": "LK", + "148": "TD", + "152": "CL", + "156": "CN", + "158": "TW", + "162": "CX", + "166": "CC", + "170": "CO", + "174": "KM", + "175": "YT", + "178": "CG", + "180": "CD", + "184": "CK", + "188": "CR", + "191": "HR", + "192": "CU", + "196": "CY", + "203": "CZ", + "204": "BJ", + "208": "DK", + "212": "DM", + "214": "DO", + "218": "EC", + "222": "SV", + "226": "GQ", + "230": "ET", + "231": "ET", + "232": "ER", + "233": "EE", + "234": "FO", + "238": "FK", + "239": "GS", + "242": "FJ", + "246": "FI", + "248": "AX", + "249": "FR", + "250": "FR", + "254": "GF", + "258": "PF", + "260": "TF", + "262": "DJ", + "266": "GA", + "268": "GE", + "270": "GM", + "275": "PS", + "276": "DE", + "278": "DE", + "280": "DE", + "288": "GH", + "292": "GI", + "296": "KI", + "300": "GR", + "304": "GL", + "308": "GD", + "312": "GP", + "316": "GU", + "320": "GT", + "324": "GN", + "328": "GY", + "332": "HT", + "334": "HM", + "336": "VA", + "340": "HN", + "344": "HK", + "348": "HU", + "352": "IS", + "356": "IN", + "360": "ID", + "364": "IR", + "368": "IQ", + "372": "IE", + "376": "IL", + "380": "IT", + "384": "CI", + "388": "JM", + "392": "JP", + "398": "KZ", + "400": "JO", + "404": "KE", + "408": "KP", + "410": "KR", + "414": "KW", + "417": "KG", + "418": "LA", + "422": "LB", + "426": "LS", + "428": "LV", + "430": "LR", + "434": "LY", + "438": "LI", + "440": "LT", + "442": "LU", + "446": "MO", + "450": "MG", + "454": "MW", + "458": "MY", + "462": "MV", + "466": "ML", + "470": "MT", + "474": "MQ", + "478": "MR", + "480": "MU", + "484": "MX", + "492": "MC", + "496": "MN", + "498": "MD", + "499": "ME", + "500": "MS", + "504": "MA", + "508": "MZ", + "512": "OM", + "516": "NA", + "520": "NR", + "524": "NP", + "528": "NL", + "531": "CW", + "533": "AW", + "534": "SX", + "535": "BQ", + "540": "NC", + "548": "VU", + "554": "NZ", + "558": "NI", + "562": "NE", + "566": "NG", + "570": "NU", + "574": "NF", + "578": "NO", + "580": "MP", + "581": "UM", + "583": "FM", + "584": "MH", + "585": "PW", + "586": "PK", + "591": "PA", + "598": "PG", + "600": "PY", + "604": "PE", + "608": "PH", + "612": "PN", + "616": "PL", + "620": "PT", + "624": "GW", + "626": "TL", + "630": "PR", + "634": "QA", + "638": "RE", + "642": "RO", + "643": "RU", + "646": "RW", + "652": "BL", + "654": "SH", + "659": "KN", + "660": "AI", + "662": "LC", + "663": "MF", + "666": "PM", + "670": "VC", + "674": "SM", + "678": "ST", + "682": "SA", + "686": "SN", + "688": "RS", + "690": "SC", + "694": "SL", + "702": "SG", + "703": "SK", + "704": "VN", + "705": "SI", + "706": "SO", + "710": "ZA", + "716": "ZW", + "720": "YE", + "724": "ES", + "728": "SS", + "729": "SD", + "732": "EH", + "736": "SD", + "740": "SR", + "744": "SJ", + "748": "SZ", + "752": "SE", + "756": "CH", + "760": "SY", + "762": "TJ", + "764": "TH", + "768": "TG", + "772": "TK", + "776": "TO", + "780": "TT", + "784": "AE", + "788": "TN", + "792": "TR", + "795": "TM", + "796": "TC", + "798": "TV", + "800": "UG", + "804": "UA", + "807": "MK", + "818": "EG", + "826": "GB", + "830": "JE", + "831": "GG", + "832": "JE", + "833": "IM", + "834": "TZ", + "840": "US", + "850": "VI", + "854": "BF", + "858": "UY", + "860": "UZ", + "862": "VE", + "876": "WF", + "882": "WS", + "886": "YE", + "887": "YE", + "891": "RS", + "894": "ZM", + "958": "AA", + "959": "QM", + "960": "QN", + "962": "QP", + "963": "QQ", + "964": "QR", + "965": "QS", + "966": "QT", + "967": "EU", + "968": "QV", + "969": "QW", + "970": "QX", + "971": "QY", + "972": "QZ", + "973": "XA", + "974": "XB", + "975": "XC", + "976": "XD", + "977": "XE", + "978": "XF", + "979": "XG", + "980": "XH", + "981": "XI", + "982": "XJ", + "983": "XK", + "984": "XL", + "985": "XM", + "986": "XN", + "987": "XO", + "988": "XP", + "989": "XQ", + "990": "XR", + "991": "XS", + "992": "XT", + "993": "XU", + "994": "XV", + "995": "XW", + "996": "XX", + "997": "XY", + "998": "XZ", + "999": "ZZ", + "BU": "MM", + "CS": "RS", + "CT": "KI", + "DD": "DE", + "DY": "BJ", + "FQ": "AQ", + "FX": "FR", + "HV": "BF", + "JT": "UM", + "MI": "UM", + "NH": "VU", + "NQ": "AQ", + "PU": "UM", + "PZ": "PA", + "QU": "EU", + "RH": "ZW", + "TP": "TL", + "UK": "GB", + "VD": "VN", + "WK": "UM", + "YD": "YE", + "YU": "RS", + "ZR": "CD", + }; + + + /** + * Complex mappings from language subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __complexLanguageMappings = { + // property names and values must be in canonical case + + "cnr": {language: "sr", region: "ME"}, + "drw": {language: "fa", region: "AF"}, + "hbs": {language: "sr", script: "Latn"}, + "prs": {language: "fa", region: "AF"}, + "sh": {language: "sr", script: "Latn"}, + "swc": {language: "sw", region: "CD"}, + "tnf": {language: "fa", region: "AF"}, + }; + + + /** + * Complex mappings from region subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __complexRegionMappings = { + // property names and values must be in canonical case + + "172": { + default: "RU", + "ab": "GE", + "az": "AZ", + "be": "BY", + "crh": "UA", + "gag": "MD", + "got": "UA", + "hy": "AM", + "ji": "UA", + "ka": "GE", + "kaa": "UZ", + "kk": "KZ", + "ku-Yezi": "GE", + "ky": "KG", + "os": "GE", + "rue": "UA", + "sog": "UZ", + "tg": "TJ", + "tk": "TM", + "tkr": "AZ", + "tly": "AZ", + "ttt": "AZ", + "ug-Cyrl": "KZ", + "uk": "UA", + "und-Armn": "AM", + "und-Chrs": "UZ", + "und-Geor": "GE", + "und-Goth": "UA", + "und-Sogd": "UZ", + "und-Sogo": "UZ", + "und-Yezi": "GE", + "uz": "UZ", + "xco": "UZ", + "xmf": "GE", + }, + "200": { + default: "CZ", + "sk": "SK", + }, + "530": { + default: "CW", + "vic": "SX", + }, + "532": { + default: "CW", + "vic": "SX", + }, + "536": { + default: "SA", + "akk": "IQ", + "ckb": "IQ", + "ku-Arab": "IQ", + "mis": "IQ", + "syr": "IQ", + "und-Hatr": "IQ", + "und-Syrc": "IQ", + "und-Xsux": "IQ", + }, + "582": { + default: "FM", + "mh": "MH", + "pau": "PW", + }, + "810": { + default: "RU", + "ab": "GE", + "az": "AZ", + "be": "BY", + "crh": "UA", + "et": "EE", + "gag": "MD", + "got": "UA", + "hy": "AM", + "ji": "UA", + "ka": "GE", + "kaa": "UZ", + "kk": "KZ", + "ku-Yezi": "GE", + "ky": "KG", + "lt": "LT", + "ltg": "LV", + "lv": "LV", + "os": "GE", + "rue": "UA", + "sgs": "LT", + "sog": "UZ", + "tg": "TJ", + "tk": "TM", + "tkr": "AZ", + "tly": "AZ", + "ttt": "AZ", + "ug-Cyrl": "KZ", + "uk": "UA", + "und-Armn": "AM", + "und-Chrs": "UZ", + "und-Geor": "GE", + "und-Goth": "UA", + "und-Sogd": "UZ", + "und-Sogo": "UZ", + "und-Yezi": "GE", + "uz": "UZ", + "vro": "EE", + "xco": "UZ", + "xmf": "GE", + }, + "890": { + default: "RS", + "bs": "BA", + "hr": "HR", + "mk": "MK", + "sl": "SI", + }, + "AN": { + default: "CW", + "vic": "SX", + }, + "NT": { + default: "SA", + "akk": "IQ", + "ckb": "IQ", + "ku-Arab": "IQ", + "mis": "IQ", + "syr": "IQ", + "und-Hatr": "IQ", + "und-Syrc": "IQ", + "und-Xsux": "IQ", + }, + "PC": { + default: "FM", + "mh": "MH", + "pau": "PW", + }, + "SU": { + default: "RU", + "ab": "GE", + "az": "AZ", + "be": "BY", + "crh": "UA", + "et": "EE", + "gag": "MD", + "got": "UA", + "hy": "AM", + "ji": "UA", + "ka": "GE", + "kaa": "UZ", + "kk": "KZ", + "ku-Yezi": "GE", + "ky": "KG", + "lt": "LT", + "ltg": "LV", + "lv": "LV", + "os": "GE", + "rue": "UA", + "sgs": "LT", + "sog": "UZ", + "tg": "TJ", + "tk": "TM", + "tkr": "AZ", + "tly": "AZ", + "ttt": "AZ", + "ug-Cyrl": "KZ", + "uk": "UA", + "und-Armn": "AM", + "und-Chrs": "UZ", + "und-Geor": "GE", + "und-Goth": "UA", + "und-Sogd": "UZ", + "und-Sogo": "UZ", + "und-Yezi": "GE", + "uz": "UZ", + "vro": "EE", + "xco": "UZ", + "xmf": "GE", + }, + }; + + + /** + * Mappings from variant subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __variantMappings = { + // property names and values must be in canonical case + + "aaland": {type: "region", replacement: "AX"}, + "arevela": {type: "language", replacement: "hy"}, + "arevmda": {type: "language", replacement: "hyw"}, + "heploc": {type: "variant", replacement: "alalc97"}, + "polytoni": {type: "variant", replacement: "polyton"}, + }; + + + /** + * Mappings from Unicode extension subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __unicodeMappings = { + // property names and values must be in canonical case + + "ca": { + "ethiopic-amete-alem": "ethioaa", + "islamicc": "islamic-civil", + }, + "kb": { + "yes": "true", + }, + "kc": { + "yes": "true", + }, + "kh": { + "yes": "true", + }, + "kk": { + "yes": "true", + }, + "kn": { + "yes": "true", + }, + "ks": { + "primary": "level1", + "tertiary": "level3", + }, + "ms": { + "imperial": "uksystem", + }, + "rg": { + "cn11": "cnbj", + "cn12": "cntj", + "cn13": "cnhe", + "cn14": "cnsx", + "cn15": "cnmn", + "cn21": "cnln", + "cn22": "cnjl", + "cn23": "cnhl", + "cn31": "cnsh", + "cn32": "cnjs", + "cn33": "cnzj", + "cn34": "cnah", + "cn35": "cnfj", + "cn36": "cnjx", + "cn37": "cnsd", + "cn41": "cnha", + "cn42": "cnhb", + "cn43": "cnhn", + "cn44": "cngd", + "cn45": "cngx", + "cn46": "cnhi", + "cn50": "cncq", + "cn51": "cnsc", + "cn52": "cngz", + "cn53": "cnyn", + "cn54": "cnxz", + "cn61": "cnsn", + "cn62": "cngs", + "cn63": "cnqh", + "cn64": "cnnx", + "cn65": "cnxj", + "cz10a": "cz110", + "cz10b": "cz111", + "cz10c": "cz112", + "cz10d": "cz113", + "cz10e": "cz114", + "cz10f": "cz115", + "cz611": "cz663", + "cz612": "cz632", + "cz613": "cz633", + "cz614": "cz634", + "cz615": "cz635", + "cz621": "cz641", + "cz622": "cz642", + "cz623": "cz643", + "cz624": "cz644", + "cz626": "cz646", + "cz627": "cz647", + "czjc": "cz31", + "czjm": "cz64", + "czka": "cz41", + "czkr": "cz52", + "czli": "cz51", + "czmo": "cz80", + "czol": "cz71", + "czpa": "cz53", + "czpl": "cz32", + "czpr": "cz10", + "czst": "cz20", + "czus": "cz42", + "czvy": "cz63", + "czzl": "cz72", + "fra": "frges", + "frb": "frnaq", + "frc": "frara", + "frd": "frbfc", + "fre": "frbre", + "frf": "frcvl", + "frg": "frges", + "frh": "frcor", + "fri": "frbfc", + "frj": "fridf", + "frk": "frocc", + "frl": "frnaq", + "frm": "frges", + "frn": "frocc", + "fro": "frhdf", + "frp": "frnor", + "frq": "frnor", + "frr": "frpdl", + "frs": "frhdf", + "frt": "frnaq", + "fru": "frpac", + "frv": "frara", + "laxn": "laxs", + "lud": "lucl", + "lug": "luec", + "lul": "luca", + "mrnkc": "mr13", + "no23": "no50", + "nzn": "nzauk", + "nzs": "nzcan", + "omba": "ombj", + "omsh": "omsj", + "plds": "pl02", + "plkp": "pl04", + "pllb": "pl08", + "plld": "pl10", + "pllu": "pl06", + "plma": "pl12", + "plmz": "pl14", + "plop": "pl16", + "plpd": "pl20", + "plpk": "pl18", + "plpm": "pl22", + "plsk": "pl26", + "plsl": "pl24", + "plwn": "pl28", + "plwp": "pl30", + "plzp": "pl32", + "tteto": "tttob", + "ttrcm": "ttmrc", + "ttwto": "tttob", + "twkhq": "twkhh", + "twtnq": "twtnn", + "twtpq": "twnwt", + "twtxq": "twtxg", + }, + "sd": { + "cn11": "cnbj", + "cn12": "cntj", + "cn13": "cnhe", + "cn14": "cnsx", + "cn15": "cnmn", + "cn21": "cnln", + "cn22": "cnjl", + "cn23": "cnhl", + "cn31": "cnsh", + "cn32": "cnjs", + "cn33": "cnzj", + "cn34": "cnah", + "cn35": "cnfj", + "cn36": "cnjx", + "cn37": "cnsd", + "cn41": "cnha", + "cn42": "cnhb", + "cn43": "cnhn", + "cn44": "cngd", + "cn45": "cngx", + "cn46": "cnhi", + "cn50": "cncq", + "cn51": "cnsc", + "cn52": "cngz", + "cn53": "cnyn", + "cn54": "cnxz", + "cn61": "cnsn", + "cn62": "cngs", + "cn63": "cnqh", + "cn64": "cnnx", + "cn65": "cnxj", + "cz10a": "cz110", + "cz10b": "cz111", + "cz10c": "cz112", + "cz10d": "cz113", + "cz10e": "cz114", + "cz10f": "cz115", + "cz611": "cz663", + "cz612": "cz632", + "cz613": "cz633", + "cz614": "cz634", + "cz615": "cz635", + "cz621": "cz641", + "cz622": "cz642", + "cz623": "cz643", + "cz624": "cz644", + "cz626": "cz646", + "cz627": "cz647", + "czjc": "cz31", + "czjm": "cz64", + "czka": "cz41", + "czkr": "cz52", + "czli": "cz51", + "czmo": "cz80", + "czol": "cz71", + "czpa": "cz53", + "czpl": "cz32", + "czpr": "cz10", + "czst": "cz20", + "czus": "cz42", + "czvy": "cz63", + "czzl": "cz72", + "fra": "frges", + "frb": "frnaq", + "frc": "frara", + "frd": "frbfc", + "fre": "frbre", + "frf": "frcvl", + "frg": "frges", + "frh": "frcor", + "fri": "frbfc", + "frj": "fridf", + "frk": "frocc", + "frl": "frnaq", + "frm": "frges", + "frn": "frocc", + "fro": "frhdf", + "frp": "frnor", + "frq": "frnor", + "frr": "frpdl", + "frs": "frhdf", + "frt": "frnaq", + "fru": "frpac", + "frv": "frara", + "laxn": "laxs", + "lud": "lucl", + "lug": "luec", + "lul": "luca", + "mrnkc": "mr13", + "no23": "no50", + "nzn": "nzauk", + "nzs": "nzcan", + "omba": "ombj", + "omsh": "omsj", + "plds": "pl02", + "plkp": "pl04", + "pllb": "pl08", + "plld": "pl10", + "pllu": "pl06", + "plma": "pl12", + "plmz": "pl14", + "plop": "pl16", + "plpd": "pl20", + "plpk": "pl18", + "plpm": "pl22", + "plsk": "pl26", + "plsl": "pl24", + "plwn": "pl28", + "plwp": "pl30", + "plzp": "pl32", + "tteto": "tttob", + "ttrcm": "ttmrc", + "ttwto": "tttob", + "twkhq": "twkhh", + "twtnq": "twtnn", + "twtpq": "twnwt", + "twtxq": "twtxg", + }, + "tz": { + "aqams": "nzakl", + "cnckg": "cnsha", + "cnhrb": "cnsha", + "cnkhg": "cnurc", + "cuba": "cuhav", + "egypt": "egcai", + "eire": "iedub", + "est": "utcw05", + "gmt0": "gmt", + "hongkong": "hkhkg", + "hst": "utcw10", + "iceland": "isrey", + "iran": "irthr", + "israel": "jeruslm", + "jamaica": "jmkin", + "japan": "jptyo", + "libya": "lytip", + "mst": "utcw07", + "navajo": "usden", + "poland": "plwaw", + "portugal": "ptlis", + "prc": "cnsha", + "roc": "twtpe", + "rok": "krsel", + "turkey": "trist", + "uct": "utc", + "usnavajo": "usden", + "zulu": "utc", + }, + }; + + + /** + * Mappings from Unicode extension subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __transformMappings = { + // property names and values must be in canonical case + + "d0": { + "name": "charname", + }, + "m0": { + "names": "prprname", + }, + }; + + /** + * Canonicalizes the given well-formed BCP 47 language tag, including regularized case of subtags. + * + * Spec: ECMAScript Internationalization API Specification, draft, 6.2.3. + * Spec: RFC 5646, section 4.5. + */ + function canonicalizeLanguageTag(locale) { + + // start with lower case for easier processing, and because most subtags will need to be lower case anyway + locale = locale.toLowerCase(); + + // handle mappings for complete tags + if (__tagMappings.hasOwnProperty(locale)) { + return __tagMappings[locale]; + } + + var subtags = locale.split("-"); + var i = 0; + + // handle standard part: all subtags before first variant or singleton subtag + var language; + var script; + var region; + while (i < subtags.length) { + var subtag = subtags[i]; + if (i === 0) { + language = subtag; + } else if (subtag.length === 2 || subtag.length === 3) { + region = subtag.toUpperCase(); + } else if (subtag.length === 4 && !("0" <= subtag[0] && subtag[0] <= "9")) { + script = subtag[0].toUpperCase() + subtag.substring(1).toLowerCase(); + } else { + break; + } + i++; + } + + if (__languageMappings.hasOwnProperty(language)) { + language = __languageMappings[language]; + } else if (__complexLanguageMappings.hasOwnProperty(language)) { + var mapping = __complexLanguageMappings[language]; + + language = mapping.language; + if (script === undefined && mapping.hasOwnProperty("script")) { + script = mapping.script; + } + if (region === undefined && mapping.hasOwnProperty("region")) { + region = mapping.region; + } + } + + if (region !== undefined) { + if (__regionMappings.hasOwnProperty(region)) { + region = __regionMappings[region]; + } else if (__complexRegionMappings.hasOwnProperty(region)) { + var mapping = __complexRegionMappings[region]; + + var mappingKey = language; + if (script !== undefined) { + mappingKey += "-" + script; + } + + if (mapping.hasOwnProperty(mappingKey)) { + region = mapping[mappingKey]; + } else { + region = mapping.default; + } + } + } + + // handle variants + var variants = []; + while (i < subtags.length && subtags[i].length > 1) { + var variant = subtags[i]; + + if (__variantMappings.hasOwnProperty(variant)) { + var mapping = __variantMappings[variant]; + switch (mapping.type) { + case "language": + language = mapping.replacement; + break; + + case "region": + region = mapping.replacement; + break; + + case "variant": + variants.push(mapping.replacement); + break; + + default: + throw new Error("illegal variant mapping type"); + } + } else { + variants.push(variant); + } + + i += 1; + } + variants.sort(); + + // handle extensions + var extensions = []; + while (i < subtags.length && subtags[i] !== "x") { + var extensionStart = i; + i++; + while (i < subtags.length && subtags[i].length > 1) { + i++; + } + + var extension; + var extensionKey = subtags[extensionStart]; + if (extensionKey === "u") { + var j = extensionStart + 1; + + // skip over leading attributes + while (j < i && subtags[j].length > 2) { + j++; + } + + extension = subtags.slice(extensionStart, j).join("-"); + + while (j < i) { + var keyStart = j; + j++; + + while (j < i && subtags[j].length > 2) { + j++; + } + + var key = subtags[keyStart]; + var value = subtags.slice(keyStart + 1, j).join("-"); + + if (__unicodeMappings.hasOwnProperty(key)) { + var mapping = __unicodeMappings[key]; + if (mapping.hasOwnProperty(value)) { + value = mapping[value]; + } + } + + extension += "-" + key; + if (value !== "" && value !== "true") { + extension += "-" + value; + } + } + } else if (extensionKey === "t") { + var j = extensionStart + 1; + + while (j < i && !transformKeyRE.test(subtags[j])) { + j++; + } + + extension = "t"; + + var transformLanguage = subtags.slice(extensionStart + 1, j).join("-"); + if (transformLanguage !== "") { + extension += "-" + canonicalizeLanguageTag(transformLanguage).toLowerCase(); + } + + while (j < i) { + var keyStart = j; + j++; + + while (j < i && subtags[j].length > 2) { + j++; + } + + var key = subtags[keyStart]; + var value = subtags.slice(keyStart + 1, j).join("-"); + + if (__transformMappings.hasOwnProperty(key)) { + var mapping = __transformMappings[key]; + if (mapping.hasOwnProperty(value)) { + value = mapping[value]; + } + } + + extension += "-" + key + "-" + value; + } + } else { + extension = subtags.slice(extensionStart, i).join("-"); + } + + extensions.push(extension); + } + extensions.sort(); + + // handle private use + var privateUse; + if (i < subtags.length) { + privateUse = subtags.slice(i).join("-"); + } + + // put everything back together + var canonical = language; + if (script !== undefined) { + canonical += "-" + script; + } + if (region !== undefined) { + canonical += "-" + region; + } + if (variants.length > 0) { + canonical += "-" + variants.join("-"); + } + if (extensions.length > 0) { + canonical += "-" + extensions.join("-"); + } + if (privateUse !== undefined) { + if (canonical.length > 0) { + canonical += "-" + privateUse; + } else { + canonical = privateUse; + } + } + + return canonical; + } + + return typeof locale === "string" && isStructurallyValidLanguageTag(locale) && + canonicalizeLanguageTag(locale) === locale; +} + + +/** + * Returns an array of error cases handled by CanonicalizeLocaleList(). + */ +function getInvalidLocaleArguments() { + function CustomError() {} + + var topLevelErrors = [ + // fails ToObject + [null, TypeError], + + // fails Get + [{ get length() { throw new CustomError(); } }, CustomError], + + // fail ToLength + [{ length: Symbol.toPrimitive }, TypeError], + [{ length: { get [Symbol.toPrimitive]() { throw new CustomError(); } } }, CustomError], + [{ length: { [Symbol.toPrimitive]() { throw new CustomError(); } } }, CustomError], + [{ length: { get valueOf() { throw new CustomError(); } } }, CustomError], + [{ length: { valueOf() { throw new CustomError(); } } }, CustomError], + [{ length: { get toString() { throw new CustomError(); } } }, CustomError], + [{ length: { toString() { throw new CustomError(); } } }, CustomError], + + // fail type check + [[undefined], TypeError], + [[null], TypeError], + [[true], TypeError], + [[Symbol.toPrimitive], TypeError], + [[1], TypeError], + [[0.1], TypeError], + [[NaN], TypeError], + ]; + + var invalidLanguageTags = [ + "", // empty tag + "i", // singleton alone + "x", // private use without subtag + "u", // extension singleton in first place + "419", // region code in first place + "u-nu-latn-cu-bob", // extension sequence without language + "hans-cmn-cn", // "hans" could theoretically be a 4-letter language code, + // but those can't be followed by extlang codes. + "abcdefghi", // overlong language + "cmn-hans-cn-u-u", // duplicate singleton + "cmn-hans-cn-t-u-ca-u", // duplicate singleton + "de-gregory-gregory", // duplicate variant + "*", // language range + "de-*", // language range + "中文", // non-ASCII letters + "en-ß", // non-ASCII letters + "ıd" // non-ASCII letters + ]; + + return topLevelErrors.concat( + invalidLanguageTags.map(tag => [tag, RangeError]), + invalidLanguageTags.map(tag => [[tag], RangeError]), + invalidLanguageTags.map(tag => [["en", tag], RangeError]), + ) +} + +/** + * Tests whether the named options property is correctly handled by the given constructor. + * @param {object} Constructor the constructor to test. + * @param {string} property the name of the options property to test. + * @param {string} type the type that values of the property are expected to have + * @param {Array} [values] an array of allowed values for the property. Not needed for boolean. + * @param {any} fallback the fallback value that the property assumes if not provided. + * @param {object} testOptions additional options: + * @param {boolean} isOptional whether support for this property is optional for implementations. + * @param {boolean} noReturn whether the resulting value of the property is not returned. + * @param {boolean} isILD whether the resulting value of the property is implementation and locale dependent. + * @param {object} extra additional option to pass along, properties are value -> {option: value}. + */ +function testOption(Constructor, property, type, values, fallback, testOptions) { + var isOptional = testOptions !== undefined && testOptions.isOptional === true; + var noReturn = testOptions !== undefined && testOptions.noReturn === true; + var isILD = testOptions !== undefined && testOptions.isILD === true; + + function addExtraOptions(options, value, testOptions) { + if (testOptions !== undefined && testOptions.extra !== undefined) { + var extra; + if (value !== undefined && testOptions.extra[value] !== undefined) { + extra = testOptions.extra[value]; + } else if (testOptions.extra.any !== undefined) { + extra = testOptions.extra.any; + } + if (extra !== undefined) { + Object.getOwnPropertyNames(extra).forEach(function (prop) { + options[prop] = extra[prop]; + }); + } + } + } + + var testValues, options, obj, expected, actual, error; + + // test that the specified values are accepted. Also add values that convert to specified values. + if (type === "boolean") { + if (values === undefined) { + values = [true, false]; + } + testValues = values.slice(0); + testValues.push(888); + testValues.push(0); + } else if (type === "string") { + testValues = values.slice(0); + testValues.push({toString: function () { return values[0]; }}); + } + testValues.forEach(function (value) { + options = {}; + options[property] = value; + addExtraOptions(options, value, testOptions); + obj = new Constructor(undefined, options); + if (noReturn) { + if (obj.resolvedOptions().hasOwnProperty(property)) { + throw new Test262Error("Option property " + property + " is returned, but shouldn't be."); + } + } else { + actual = obj.resolvedOptions()[property]; + if (isILD) { + if (actual !== undefined && values.indexOf(actual) === -1) { + throw new Test262Error("Invalid value " + actual + " returned for property " + property + "."); + } + } else { + if (type === "boolean") { + expected = Boolean(value); + } else if (type === "string") { + expected = String(value); + } + if (actual !== expected && !(isOptional && actual === undefined)) { + throw new Test262Error("Option value " + value + " for property " + property + + " was not accepted; got " + actual + " instead."); + } + } + } + }); + + // test that invalid values are rejected + if (type === "string") { + var invalidValues = ["invalidValue", -1, null]; + // assume that we won't have values in caseless scripts + if (values[0].toUpperCase() !== values[0]) { + invalidValues.push(values[0].toUpperCase()); + } else { + invalidValues.push(values[0].toLowerCase()); + } + invalidValues.forEach(function (value) { + options = {}; + options[property] = value; + addExtraOptions(options, value, testOptions); + error = undefined; + try { + obj = new Constructor(undefined, options); + } catch (e) { + error = e; + } + if (error === undefined) { + throw new Test262Error("Invalid option value " + value + " for property " + property + " was not rejected."); + } else if (error.name !== "RangeError") { + throw new Test262Error("Invalid option value " + value + " for property " + property + " was rejected with wrong error " + error.name + "."); + } + }); + } + + // test that fallback value or another valid value is used if no options value is provided + if (!noReturn) { + options = {}; + addExtraOptions(options, undefined, testOptions); + obj = new Constructor(undefined, options); + actual = obj.resolvedOptions()[property]; + if (!(isOptional && actual === undefined)) { + if (fallback !== undefined) { + if (actual !== fallback) { + throw new Test262Error("Option fallback value " + fallback + " for property " + property + + " was not used; got " + actual + " instead."); + } + } else { + if (values.indexOf(actual) === -1 && !(isILD && actual === undefined)) { + throw new Test262Error("Invalid value " + actual + " returned for property " + property + "."); + } + } + } + } +} + + +/** + * Properties of the RegExp constructor that may be affected by use of regular + * expressions, and the default values of these properties. Properties are from + * https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Deprecated_and_obsolete_features#RegExp_Properties + */ +var regExpProperties = ["$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$_", "$*", "$&", "$+", "$`", "$'", + "input", "lastMatch", "lastParen", "leftContext", "rightContext" +]; + +var regExpPropertiesDefaultValues = (function () { + var values = Object.create(null); + (/(?:)/).test(""); + regExpProperties.forEach(function (property) { + values[property] = RegExp[property]; + }); + return values; +}()); + + +/** + * Tests that executing the provided function (which may use regular expressions + * in its implementation) does not create or modify unwanted properties on the + * RegExp constructor. + */ +function testForUnwantedRegExpChanges(testFunc) { + (/(?:)/).test(""); + testFunc(); + regExpProperties.forEach(function (property) { + if (RegExp[property] !== regExpPropertiesDefaultValues[property]) { + throw new Test262Error("RegExp has unexpected property " + property + " with value " + + RegExp[property] + "."); + } + }); +} + + +/** + * Returns an array of all known calendars. + */ +function allCalendars() { + // source: CLDR file common/bcp47/number.xml; version CLDR 39. + // https://github.com/unicode-org/cldr/blob/master/common/bcp47/calendar.xml + return [ + "buddhist", + "chinese", + "coptic", + "dangi", + "ethioaa", + "ethiopic", + "gregory", + "hebrew", + "indian", + "islamic", + "islamic-umalqura", + "islamic-tbla", + "islamic-civil", + "islamic-rgsa", + "iso8601", + "japanese", + "persian", + "roc", + ]; +} + + +/** + * Returns an array of all known collations. + */ +function allCollations() { + // source: CLDR file common/bcp47/collation.xml; version CLDR 39. + // https://github.com/unicode-org/cldr/blob/master/common/bcp47/collation.xml + return [ + "big5han", + "compat", + "dict", + "direct", + "ducet", + "emoji", + "eor", + "gb2312", + "phonebk", + "phonetic", + "pinyin", + "reformed", + "search", + "searchjl", + "standard", + "stroke", + "trad", + "unihan", + "zhuyin", + ]; +} + + +/** + * Returns an array of all known numbering systems. + */ +function allNumberingSystems() { + // source: CLDR file common/bcp47/number.xml; version CLDR 40 & new in Unicode 14.0 + // https://github.com/unicode-org/cldr/blob/master/common/bcp47/number.xml + return [ + "adlm", + "ahom", + "arab", + "arabext", + "armn", + "armnlow", + "bali", + "beng", + "bhks", + "brah", + "cakm", + "cham", + "cyrl", + "deva", + "diak", + "ethi", + "finance", + "fullwide", + "geor", + "gong", + "gonm", + "grek", + "greklow", + "gujr", + "guru", + "hanidays", + "hanidec", + "hans", + "hansfin", + "hant", + "hantfin", + "hebr", + "hmng", + "hmnp", + "java", + "jpan", + "jpanfin", + "jpanyear", + "kali", + "khmr", + "knda", + "lana", + "lanatham", + "laoo", + "latn", + "lepc", + "limb", + "mathbold", + "mathdbl", + "mathmono", + "mathsanb", + "mathsans", + "mlym", + "modi", + "mong", + "mroo", + "mtei", + "mymr", + "mymrshan", + "mymrtlng", + "native", + "newa", + "nkoo", + "olck", + "orya", + "osma", + "rohg", + "roman", + "romanlow", + "saur", + "shrd", + "sind", + "sinh", + "sora", + "sund", + "takr", + "talu", + "taml", + "tamldec", + "tnsa", + "telu", + "thai", + "tirh", + "tibt", + "traditio", + "vaii", + "wara", + "wcho", + ]; +} + + +/** + * Tests whether name is a valid BCP 47 numbering system name + * and not excluded from use in the ECMAScript Internationalization API. + * @param {string} name the name to be tested. + * @return {boolean} whether name is a valid BCP 47 numbering system name and + * allowed for use in the ECMAScript Internationalization API. + */ + +function isValidNumberingSystem(name) { + + var numberingSystems = allNumberingSystems(); + + var excluded = [ + "finance", + "native", + "traditio" + ]; + + + return numberingSystems.indexOf(name) !== -1 && excluded.indexOf(name) === -1; +} + + +/** + * Provides the digits of numbering systems with simple digit mappings, + * as specified in 11.3.2. + */ + +var numberingSystemDigits = { + adlm: "𞥐𞥑𞥒𞥓𞥔𞥕𞥖𞥗𞥘𞥙", + ahom: "𑜰𑜱𑜲𑜳𑜴𑜵𑜶𑜷𑜸𑜹", + arab: "٠١٢٣٤٥٦٧٨٩", + arabext: "۰۱۲۳۴۵۶۷۸۹", + bali: "\u1B50\u1B51\u1B52\u1B53\u1B54\u1B55\u1B56\u1B57\u1B58\u1B59", + beng: "০১২৩৪৫৬৭৮৯", + bhks: "𑱐𑱑𑱒𑱓𑱔𑱕𑱖𑱗𑱘𑱙", + brah: "𑁦𑁧𑁨𑁩𑁪𑁫𑁬𑁭𑁮𑁯", + cakm: "𑄶𑄷𑄸𑄹𑄺𑄻𑄼𑄽𑄾𑄿", + cham: "꩐꩑꩒꩓꩔꩕꩖꩗꩘꩙", + deva: "०१२३४५६७८९", + diak: "𑥐𑥑𑥒𑥓𑥔𑥕𑥖𑥗𑥘𑥙", + fullwide: "0123456789", + gong: "𑶠𑶡𑶢𑶣𑶤𑶥𑶦𑶧𑶨𑶩", + gonm: "𑵐𑵑𑵒𑵓𑵔𑵕𑵖𑵗𑵘𑵙", + gujr: "૦૧૨૩૪૫૬૭૮૯", + guru: "੦੧੨੩੪੫੬੭੮੯", + hanidec: "〇一二三四五六七八九", + hmng: "𖭐𖭑𖭒𖭓𖭔𖭕𖭖𖭗𖭘𖭙", + hmnp: "𞅀𞅁𞅂𞅃𞅄𞅅𞅆𞅇𞅈𞅉", + java: "꧐꧑꧒꧓꧔꧕꧖꧗꧘꧙", + kali: "꤀꤁꤂꤃꤄꤅꤆꤇꤈꤉", + khmr: "០១២៣៤៥៦៧៨៩", + knda: "೦೧೨೩೪೫೬೭೮೯", + lana: "᪀᪁᪂᪃᪄᪅᪆᪇᪈᪉", + lanatham: "᪐᪑᪒᪓᪔᪕᪖᪗᪘᪙", + laoo: "໐໑໒໓໔໕໖໗໘໙", + latn: "0123456789", + lepc: "᱀᱁᱂᱃᱄᱅᱆᱇᱈᱉", + limb: "\u1946\u1947\u1948\u1949\u194A\u194B\u194C\u194D\u194E\u194F", + mathbold: "𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗", + mathdbl: "𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡", + mathmono: "𝟶𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿", + mathsanb: "𝟬𝟭𝟮𝟯𝟰𝟱𝟲𝟳𝟴𝟵", + mathsans: "𝟢𝟣𝟤𝟥𝟦𝟧𝟨𝟩𝟪𝟫", + mlym: "൦൧൨൩൪൫൬൭൮൯", + modi: "𑙐𑙑𑙒𑙓𑙔𑙕𑙖𑙗𑙘𑙙", + mong: "᠐᠑᠒᠓᠔᠕᠖᠗᠘᠙", + mroo: "𖩠𖩡𖩢𖩣𖩤𖩥𖩦𖩧𖩨𖩩", + mtei: "꯰꯱꯲꯳꯴꯵꯶꯷꯸꯹", + mymr: "၀၁၂၃၄၅၆၇၈၉", + mymrshan: "႐႑႒႓႔႕႖႗႘႙", + mymrtlng: "꧰꧱꧲꧳꧴꧵꧶꧷꧸꧹", + newa: "𑑐𑑑𑑒𑑓𑑔𑑕𑑖𑑗𑑘𑑙", + nkoo: "߀߁߂߃߄߅߆߇߈߉", + olck: "᱐᱑᱒᱓᱔᱕᱖᱗᱘᱙", + orya: "୦୧୨୩୪୫୬୭୮୯", + osma: "𐒠𐒡𐒢𐒣𐒤𐒥𐒦𐒧𐒨𐒩", + rohg: "𐴰𐴱𐴲𐴳𐴴𐴵𐴶𐴷𐴸𐴹", + saur: "꣐꣑꣒꣓꣔꣕꣖꣗꣘꣙", + segment: "🯰🯱🯲🯳🯴🯵🯶🯷🯸🯹", + shrd: "𑇐𑇑𑇒𑇓𑇔𑇕𑇖𑇗𑇘𑇙", + sind: "𑋰𑋱𑋲𑋳𑋴𑋵𑋶𑋷𑋸𑋹", + sinh: "෦෧෨෩෪෫෬෭෮෯", + sora: "𑃰𑃱𑃲𑃳𑃴𑃵𑃶𑃷𑃸𑃹", + sund: "᮰᮱᮲᮳᮴᮵᮶᮷᮸᮹", + takr: "𑛀𑛁𑛂𑛃𑛄𑛅𑛆𑛇𑛈𑛉", + talu: "᧐᧑᧒᧓᧔᧕᧖᧗᧘᧙", + tamldec: "௦௧௨௩௪௫௬௭௮௯", + tnsa: "\u{16AC0}\u{16AC1}\u{16AC2}\u{16AC3}\u{16AC4}\u{16AC5}\u{16AC6}\u{16AC7}\u{16AC8}\u{16AC9}", + telu: "౦౧౨౩౪౫౬౭౮౯", + thai: "๐๑๒๓๔๕๖๗๘๙", + tibt: "༠༡༢༣༤༥༦༧༨༩", + tirh: "𑓐𑓑𑓒𑓓𑓔𑓕𑓖𑓗𑓘𑓙", + vaii: "꘠꘡꘢꘣꘤꘥꘦꘧꘨꘩", + wara: "𑣠𑣡𑣢𑣣𑣤𑣥𑣦𑣧𑣨𑣩", + wcho: "𞋰𞋱𞋲𞋳𞋴𞋵𞋶𞋷𞋸𞋹", +}; + + +/** + * Returns an array of all simple, sanctioned unit identifiers. + */ +function allSimpleSanctionedUnits() { + // https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers + return [ + "acre", + "bit", + "byte", + "celsius", + "centimeter", + "day", + "degree", + "fahrenheit", + "fluid-ounce", + "foot", + "gallon", + "gigabit", + "gigabyte", + "gram", + "hectare", + "hour", + "inch", + "kilobit", + "kilobyte", + "kilogram", + "kilometer", + "liter", + "megabit", + "megabyte", + "meter", + "microsecond", + "mile", + "mile-scandinavian", + "milliliter", + "millimeter", + "millisecond", + "minute", + "month", + "nanosecond", + "ounce", + "percent", + "petabyte", + "pound", + "second", + "stone", + "terabit", + "terabyte", + "week", + "yard", + "year", + ]; +} + + +/** + * Tests that number formatting is handled correctly. The function checks that the + * digit sequences in formatted output are as specified, converted to the + * selected numbering system, and embedded in consistent localized patterns. + * @param {Array} locales the locales to be tested. + * @param {Array} numberingSystems the numbering systems to be tested. + * @param {Object} options the options to pass to Intl.NumberFormat. Options + * must include {useGrouping: false}, and must cause 1.1 to be formatted + * pre- and post-decimal digits. + * @param {Object} testData maps input data (in ES5 9.3.1 format) to expected output strings + * in unlocalized format with Western digits. + */ + +function testNumberFormat(locales, numberingSystems, options, testData) { + locales.forEach(function (locale) { + numberingSystems.forEach(function (numbering) { + var digits = numberingSystemDigits[numbering]; + var format = new Intl.NumberFormat([locale + "-u-nu-" + numbering], options); + + function getPatternParts(positive) { + var n = positive ? 1.1 : -1.1; + var formatted = format.format(n); + var oneoneRE = "([^" + digits + "]*)[" + digits + "]+([^" + digits + "]+)[" + digits + "]+([^" + digits + "]*)"; + var match = formatted.match(new RegExp(oneoneRE)); + if (match === null) { + throw new Test262Error("Unexpected formatted " + n + " for " + + format.resolvedOptions().locale + " and options " + + JSON.stringify(options) + ": " + formatted); + } + return match; + } + + function toNumbering(raw) { + return raw.replace(/[0-9]/g, function (digit) { + return digits[digit.charCodeAt(0) - "0".charCodeAt(0)]; + }); + } + + function buildExpected(raw, patternParts) { + var period = raw.indexOf("."); + if (period === -1) { + return patternParts[1] + toNumbering(raw) + patternParts[3]; + } else { + return patternParts[1] + + toNumbering(raw.substring(0, period)) + + patternParts[2] + + toNumbering(raw.substring(period + 1)) + + patternParts[3]; + } + } + + if (format.resolvedOptions().numberingSystem === numbering) { + // figure out prefixes, infixes, suffixes for positive and negative values + var posPatternParts = getPatternParts(true); + var negPatternParts = getPatternParts(false); + + Object.getOwnPropertyNames(testData).forEach(function (input) { + var rawExpected = testData[input]; + var patternParts; + if (rawExpected[0] === "-") { + patternParts = negPatternParts; + rawExpected = rawExpected.substring(1); + } else { + patternParts = posPatternParts; + } + var expected = buildExpected(rawExpected, patternParts); + var actual = format.format(input); + if (actual !== expected) { + throw new Test262Error("Formatted value for " + input + ", " + + format.resolvedOptions().locale + " and options " + + JSON.stringify(options) + " is " + actual + "; expected " + expected + "."); + } + }); + } + }); + }); +} + + +/** + * Return the components of date-time formats. + * @return {Array} an array with all date-time components. + */ + +function getDateTimeComponents() { + return ["weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName"]; +} + + +/** + * Return the valid values for the given date-time component, as specified + * by the table in section 12.1.1. + * @param {string} component a date-time component. + * @return {Array} an array with the valid values for the component. + */ + +function getDateTimeComponentValues(component) { + + var components = { + weekday: ["narrow", "short", "long"], + era: ["narrow", "short", "long"], + year: ["2-digit", "numeric"], + month: ["2-digit", "numeric", "narrow", "short", "long"], + day: ["2-digit", "numeric"], + hour: ["2-digit", "numeric"], + minute: ["2-digit", "numeric"], + second: ["2-digit", "numeric"], + timeZoneName: ["short", "long"] + }; + + var result = components[component]; + if (result === undefined) { + throw new Test262Error("Internal error: No values defined for date-time component " + component + "."); + } + return result; +} + + +/** + * @description Tests whether timeZone is a String value representing a + * structurally valid and canonicalized time zone name, as defined in + * sections 6.4.1 and 6.4.2 of the ECMAScript Internationalization API + * Specification. + * @param {String} timeZone the string to be tested. + * @result {Boolean} whether the test succeeded. + */ + +function isCanonicalizedStructurallyValidTimeZoneName(timeZone) { + /** + * Regular expression defining IANA Time Zone names. + * + * Spec: IANA Time Zone Database, Theory file + */ + var fileNameComponent = "(?:[A-Za-z_]|\\.(?!\\.?(?:/|$)))[A-Za-z.\\-_]{0,13}"; + var fileName = fileNameComponent + "(?:/" + fileNameComponent + ")*"; + var etcName = "(?:Etc/)?GMT[+-]\\d{1,2}"; + var systemVName = "SystemV/[A-Z]{3}\\d{1,2}(?:[A-Z]{3})?"; + var legacyName = etcName + "|" + systemVName + "|CST6CDT|EST5EDT|MST7MDT|PST8PDT|NZ"; + var zoneNamePattern = new RegExp("^(?:" + fileName + "|" + legacyName + ")$"); + + if (typeof timeZone !== "string") { + return false; + } + // 6.4.2 CanonicalizeTimeZoneName (timeZone), step 3 + if (timeZone === "UTC") { + return true; + } + // 6.4.2 CanonicalizeTimeZoneName (timeZone), step 3 + if (timeZone === "Etc/UTC" || timeZone === "Etc/GMT") { + return false; + } + return zoneNamePattern.test(timeZone); +} diff --git a/harness/testTypedArray.js b/harness/testTypedArray.js new file mode 100644 index 00000000000..0cc50c9fd50 --- /dev/null +++ b/harness/testTypedArray.js @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - typedArrayConstructors + - floatArrayConstructors + - intArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +/** + * Array containing every typed array constructor. + */ +var typedArrayConstructors = [ + Float64Array, + Float32Array, + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + Uint8ClampedArray +]; + +var floatArrayConstructors = typedArrayConstructors.slice(0, 2); +var intArrayConstructors = typedArrayConstructors.slice(2, 7); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Float64Array, + Float32Array, + Uint8ClampedArray + ]); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} diff --git a/harness/timer.js b/harness/timer.js new file mode 100644 index 00000000000..d55f47d4f73 --- /dev/null +++ b/harness/timer.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Used in website/scripts/sth.js +defines: [setTimeout] +---*/ +//setTimeout is not available, hence this script was loaded +if (Promise === undefined && this.setTimeout === undefined) { + if(/\$DONE()/.test(code)) + throw new Test262Error("Async test capability is not supported in your test environment"); +} + +if (Promise !== undefined && this.setTimeout === undefined) { + (function(that) { + that.setTimeout = function(callback, delay) { + var p = Promise.resolve(); + var start = Date.now(); + var end = start + delay; + function check(){ + var timeLeft = end - Date.now(); + if(timeLeft > 0) + p.then(check); + else + callback(); + } + p.then(check); + } + })(this); +} diff --git a/harness/typeCoercion.js b/harness/typeCoercion.js new file mode 100644 index 00000000000..72f79205a01 --- /dev/null +++ b/harness/typeCoercion.js @@ -0,0 +1,463 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Functions to help generate test cases for testing type coercion abstract + operations like ToNumber. +defines: + - testCoercibleToIndexZero + - testCoercibleToIndexOne + - testCoercibleToIndexFromIndex + - testCoercibleToIntegerZero + - testCoercibleToIntegerOne + - testCoercibleToNumberZero + - testCoercibleToNumberNan + - testCoercibleToNumberOne + - testCoercibleToIntegerFromInteger + - testPrimitiveWrappers + - testCoercibleToPrimitiveWithMethod + - testNotCoercibleToIndex + - testNotCoercibleToInteger + - testNotCoercibleToNumber + - testNotCoercibleToPrimitive + - testCoercibleToString + - testNotCoercibleToString + - testCoercibleToBooleanTrue + - testCoercibleToBooleanFalse + - testCoercibleToBigIntZero + - testCoercibleToBigIntOne + - testCoercibleToBigIntFromBigInt + - testNotCoercibleToBigInt +---*/ + +function testCoercibleToIndexZero(test) { + testCoercibleToIntegerZero(test); +} + +function testCoercibleToIndexOne(test) { + testCoercibleToIntegerOne(test); +} + +function testCoercibleToIndexFromIndex(nominalIndex, test) { + assert(Number.isInteger(nominalIndex)); + assert(0 <= nominalIndex && nominalIndex <= 2**53 - 1); + testCoercibleToIntegerFromInteger(nominalIndex, test); +} + +function testCoercibleToIntegerZero(test) { + testCoercibleToNumberZero(test); + + testCoercibleToIntegerFromInteger(0, test); + + // NaN -> +0 + testCoercibleToNumberNan(test); + + // When toString() returns a string that parses to NaN: + test({}); + test([]); +} + +function testCoercibleToIntegerOne(test) { + testCoercibleToNumberOne(test); + + testCoercibleToIntegerFromInteger(1, test); + + // When toString() returns "1" + test([1]); + test(["1"]); +} + +function testCoercibleToNumberZero(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testPrimitiveValue(null); + testPrimitiveValue(false); + testPrimitiveValue(0); + testPrimitiveValue("0"); +} + +function testCoercibleToNumberNan(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testPrimitiveValue(undefined); + testPrimitiveValue(NaN); + testPrimitiveValue(""); + testPrimitiveValue("foo"); + testPrimitiveValue("true"); +} + +function testCoercibleToNumberOne(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testPrimitiveValue(true); + testPrimitiveValue(1); + testPrimitiveValue("1"); +} + +function testCoercibleToIntegerFromInteger(nominalInteger, test) { + assert(Number.isInteger(nominalInteger)); + + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + + // Non-primitive values that coerce to the nominal integer: + // toString() returns a string that parsers to a primitive value. + test([value]); + } + + function testPrimitiveNumber(number) { + testPrimitiveValue(number); + // ToNumber: String -> Number + testPrimitiveValue(number.toString()); + } + + testPrimitiveNumber(nominalInteger); + + // ToInteger: floor(abs(number)) + if (nominalInteger >= 0) { + testPrimitiveNumber(nominalInteger + 0.9); + } + if (nominalInteger <= 0) { + testPrimitiveNumber(nominalInteger - 0.9); + } +} + +function testPrimitiveWrappers(primitiveValue, hint, test) { + if (primitiveValue != null) { + // null and undefined result in {} rather than a proper wrapper, + // so skip this case for those values. + test(Object(primitiveValue)); + } + + testCoercibleToPrimitiveWithMethod(hint, function() { + return primitiveValue; + }, test); +} + +function testCoercibleToPrimitiveWithMethod(hint, method, test) { + var methodNames; + if (hint === "number") { + methodNames = ["valueOf", "toString"]; + } else if (hint === "string") { + methodNames = ["toString", "valueOf"]; + } else { + throw new Test262Error(); + } + // precedence order + test({ + [Symbol.toPrimitive]: method, + [methodNames[0]]: function() { throw new Test262Error(); }, + [methodNames[1]]: function() { throw new Test262Error(); }, + }); + test({ + [methodNames[0]]: method, + [methodNames[1]]: function() { throw new Test262Error(); }, + }); + if (hint === "number") { + // The default valueOf returns an object, which is unsuitable. + // The default toString returns a String, which is suitable. + // Therefore this test only works for valueOf falling back to toString. + test({ + // this is toString: + [methodNames[1]]: method, + }); + } + + // GetMethod: if func is undefined or null, return undefined. + test({ + [Symbol.toPrimitive]: undefined, + [methodNames[0]]: method, + [methodNames[1]]: method, + }); + test({ + [Symbol.toPrimitive]: null, + [methodNames[0]]: method, + [methodNames[1]]: method, + }); + + // if methodNames[0] is not callable, fallback to methodNames[1] + test({ + [methodNames[0]]: null, + [methodNames[1]]: method, + }); + test({ + [methodNames[0]]: 1, + [methodNames[1]]: method, + }); + test({ + [methodNames[0]]: {}, + [methodNames[1]]: method, + }); + + // if methodNames[0] returns an object, fallback to methodNames[1] + test({ + [methodNames[0]]: function() { return {}; }, + [methodNames[1]]: method, + }); + test({ + [methodNames[0]]: function() { return Object(1); }, + [methodNames[1]]: method, + }); +} + +function testNotCoercibleToIndex(test) { + function testPrimitiveValue(value) { + test(RangeError, value); + // ToPrimitive + testPrimitiveWrappers(value, "number", function(value) { + test(RangeError, value); + }); + } + + // Let integerIndex be ? ToInteger(value). + testNotCoercibleToInteger(test); + + // If integerIndex < 0, throw a RangeError exception. + testPrimitiveValue(-1); + testPrimitiveValue(-2.5); + testPrimitiveValue("-2.5"); + testPrimitiveValue(-Infinity); + + // Let index be ! ToLength(integerIndex). + // If SameValueZero(integerIndex, index) is false, throw a RangeError exception. + testPrimitiveValue(2 ** 53); + testPrimitiveValue(Infinity); +} + +function testNotCoercibleToInteger(test) { + // ToInteger only throws from ToNumber. + testNotCoercibleToNumber(test); +} + +function testNotCoercibleToNumber(test) { + function testPrimitiveValue(value) { + test(TypeError, value); + // ToPrimitive + testPrimitiveWrappers(value, "number", function(value) { + test(TypeError, value); + }); + } + + // ToNumber: Symbol -> TypeError + testPrimitiveValue(Symbol("1")); + + if (typeof BigInt !== "undefined") { + // ToNumber: BigInt -> TypeError + testPrimitiveValue(BigInt(0)); + } + + // ToPrimitive + testNotCoercibleToPrimitive("number", test); +} + +function testNotCoercibleToPrimitive(hint, test) { + function MyError() {} + + // ToPrimitive: input[@@toPrimitive] is not callable (and non-null) + test(TypeError, {[Symbol.toPrimitive]: 1}); + test(TypeError, {[Symbol.toPrimitive]: {}}); + + // ToPrimitive: input[@@toPrimitive] returns object + test(TypeError, {[Symbol.toPrimitive]: function() { return Object(1); }}); + test(TypeError, {[Symbol.toPrimitive]: function() { return {}; }}); + + // ToPrimitive: input[@@toPrimitive] throws + test(MyError, {[Symbol.toPrimitive]: function() { throw new MyError(); }}); + + // OrdinaryToPrimitive: method throws + testCoercibleToPrimitiveWithMethod(hint, function() { + throw new MyError(); + }, function(value) { + test(MyError, value); + }); + + // OrdinaryToPrimitive: both methods are unsuitable + function testUnsuitableMethod(method) { + test(TypeError, {valueOf:method, toString:method}); + } + // not callable: + testUnsuitableMethod(null); + testUnsuitableMethod(1); + testUnsuitableMethod({}); + // returns object: + testUnsuitableMethod(function() { return Object(1); }); + testUnsuitableMethod(function() { return {}; }); +} + +function testCoercibleToString(test) { + function testPrimitiveValue(value, expectedString) { + test(value, expectedString); + // ToPrimitive + testPrimitiveWrappers(value, "string", function(value) { + test(value, expectedString); + }); + } + + testPrimitiveValue(undefined, "undefined"); + testPrimitiveValue(null, "null"); + testPrimitiveValue(true, "true"); + testPrimitiveValue(false, "false"); + testPrimitiveValue(0, "0"); + testPrimitiveValue(-0, "0"); + testPrimitiveValue(Infinity, "Infinity"); + testPrimitiveValue(-Infinity, "-Infinity"); + testPrimitiveValue(123.456, "123.456"); + testPrimitiveValue(-123.456, "-123.456"); + testPrimitiveValue("", ""); + testPrimitiveValue("foo", "foo"); + + if (typeof BigInt !== "undefined") { + // BigInt -> TypeError + testPrimitiveValue(BigInt(0), "0"); + } + + // toString of a few objects + test([], ""); + test(["foo", "bar"], "foo,bar"); + test({}, "[object Object]"); +} + +function testNotCoercibleToString(test) { + function testPrimitiveValue(value) { + test(TypeError, value); + // ToPrimitive + testPrimitiveWrappers(value, "string", function(value) { + test(TypeError, value); + }); + } + + // Symbol -> TypeError + testPrimitiveValue(Symbol("1")); + + // ToPrimitive + testNotCoercibleToPrimitive("string", test); +} + +function testCoercibleToBooleanTrue(test) { + test(true); + test(1); + test("string"); + test(Symbol("1")); + test({}); +} + +function testCoercibleToBooleanFalse(test) { + test(undefined); + test(null); + test(false); + test(0); + test(-0); + test(NaN); + test(""); +} + +function testCoercibleToBigIntZero(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testCoercibleToBigIntFromBigInt(BigInt(0), test); + testPrimitiveValue(-BigInt(0)); + testPrimitiveValue("-0"); + testPrimitiveValue(false); + testPrimitiveValue(""); + testPrimitiveValue(" "); + + // toString() returns "" + test([]); + + // toString() returns "0" + test([0]); +} + +function testCoercibleToBigIntOne(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testCoercibleToBigIntFromBigInt(BigInt(1), test); + testPrimitiveValue(true); + + // toString() returns "1" + test([1]); +} + +function testCoercibleToBigIntFromBigInt(nominalBigInt, test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testPrimitiveValue(nominalBigInt); + testPrimitiveValue(nominalBigInt.toString()); + testPrimitiveValue("0b" + nominalBigInt.toString(2)); + testPrimitiveValue("0o" + nominalBigInt.toString(8)); + testPrimitiveValue("0x" + nominalBigInt.toString(16)); + testPrimitiveValue(" " + nominalBigInt.toString() + " "); + + // toString() returns the decimal string representation + test([nominalBigInt]); + test([nominalBigInt.toString()]); +} + +function testNotCoercibleToBigInt(test) { + function testPrimitiveValue(error, value) { + test(error, value); + // ToPrimitive + testPrimitiveWrappers(value, "number", function(value) { + test(error, value); + }); + } + + // Undefined, Null, Number, Symbol -> TypeError + testPrimitiveValue(TypeError, undefined); + testPrimitiveValue(TypeError, null); + testPrimitiveValue(TypeError, 0); + testPrimitiveValue(TypeError, NaN); + testPrimitiveValue(TypeError, Infinity); + testPrimitiveValue(TypeError, Symbol("1")); + + // when a String parses to NaN -> SyntaxError + function testStringValue(string) { + testPrimitiveValue(SyntaxError, string); + testPrimitiveValue(SyntaxError, " " + string); + testPrimitiveValue(SyntaxError, string + " "); + testPrimitiveValue(SyntaxError, " " + string + " "); + } + testStringValue("a"); + testStringValue("0b2"); + testStringValue("0o8"); + testStringValue("0xg"); + testStringValue("1n"); +} diff --git a/harness/wellKnownIntrinsicObjects.js b/harness/wellKnownIntrinsicObjects.js new file mode 100644 index 00000000000..3d0b57dc8bd --- /dev/null +++ b/harness/wellKnownIntrinsicObjects.js @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + An Array of all representable Well-Known Intrinsic Objects +defines: [WellKnownIntrinsicObjects] +---*/ + +const WellKnownIntrinsicObjects = [ + { + name: '%AggregateError%', + source: 'AggregateError', + }, + { + name: '%Array%', + source: 'Array', + }, + { + name: '%ArrayBuffer%', + source: 'ArrayBuffer', + }, + { + name: '%ArrayIteratorPrototype%', + source: 'Object.getPrototypeOf([][Symbol.iterator]())', + }, + { + name: '%AsyncFromSyncIteratorPrototype%', + source: 'undefined', + }, + { + name: '%AsyncFunction%', + source: '(async function() {}).constructor', + }, + { + name: '%AsyncGeneratorFunction%', + source: 'Object.getPrototypeOf(async function * () {})', + }, + { + name: '%AsyncIteratorPrototype%', + source: '((async function * () {})())[Symbol.asyncIterator]()', + }, + { + name: '%Atomics%', + source: 'Atomics', + }, + { + name: '%BigInt%', + source: 'BigInt', + }, + { + name: '%BigInt64Array%', + source: 'BigInt64Array', + }, + { + name: '%BigUint64Array%', + source: 'BigUint64Array', + }, + { + name: '%Boolean%', + source: 'Boolean', + }, + { + name: '%DataView%', + source: 'DataView', + }, + { + name: '%Date%', + source: 'Date', + }, + { + name: '%decodeURI%', + source: 'decodeURI', + }, + { + name: '%decodeURIComponent%', + source: 'decodeURIComponent', + }, + { + name: '%encodeURI%', + source: 'encodeURI', + }, + { + name: '%encodeURIComponent%', + source: 'encodeURIComponent', + }, + { + name: '%Error%', + source: 'Error', + }, + { + name: '%eval%', + source: 'eval', + }, + { + name: '%EvalError%', + source: 'EvalError', + }, + { + name: '%FinalizationRegistry%', + source: 'FinalizationRegistry', + }, + { + name: '%Float32Array%', + source: 'Float32Array', + }, + { + name: '%Float64Array%', + source: 'Float64Array', + }, + { + name: '%ForInIteratorPrototype%', + source: '', + }, + { + name: '%Function%', + source: 'Function', + }, + { + name: '%GeneratorFunction%', + source: 'Object.getPrototypeOf(function * () {})', + }, + { + name: '%Int8Array%', + source: 'Int8Array', + }, + { + name: '%Int16Array%', + source: 'Int16Array', + }, + { + name: '%Int32Array%', + source: 'Int32Array', + }, + { + name: '%isFinite%', + source: 'isFinite', + }, + { + name: '%isNaN%', + source: 'isNaN', + }, + { + name: '%IteratorPrototype%', + source: 'Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))', + }, + { + name: '%JSON%', + source: 'JSON', + }, + { + name: '%Map%', + source: 'Map', + }, + { + name: '%MapIteratorPrototype%', + source: 'Object.getPrototypeOf(new Map()[Symbol.iterator]())', + }, + { + name: '%Math%', + source: 'Math', + }, + { + name: '%Number%', + source: 'Number', + }, + { + name: '%Object%', + source: 'Object', + }, + { + name: '%parseFloat%', + source: 'parseFloat', + }, + { + name: '%parseInt%', + source: 'parseInt', + }, + { + name: '%Promise%', + source: 'Promise', + }, + { + name: '%Proxy%', + source: 'Proxy', + }, + { + name: '%RangeError%', + source: 'RangeError', + }, + { + name: '%ReferenceError%', + source: 'ReferenceError', + }, + { + name: '%Reflect%', + source: 'Reflect', + }, + { + name: '%RegExp%', + source: 'RegExp', + }, + { + name: '%RegExpStringIteratorPrototype%', + source: 'RegExp.prototype[Symbol.matchAll]("")', + }, + { + name: '%Set%', + source: 'Set', + }, + { + name: '%SetIteratorPrototype%', + source: 'Object.getPrototypeOf(new Set()[Symbol.iterator]())', + }, + { + name: '%SharedArrayBuffer%', + source: 'SharedArrayBuffer', + }, + { + name: '%String%', + source: 'String', + }, + { + name: '%StringIteratorPrototype%', + source: 'Object.getPrototypeOf(new String()[Symbol.iterator]())', + }, + { + name: '%Symbol%', + source: 'Symbol', + }, + { + name: '%SyntaxError%', + source: 'SyntaxError', + }, + { + name: '%ThrowTypeError%', + source: '(function() { "use strict"; return Object.getOwnPropertyDescriptor(arguments, "callee").get })()', + }, + { + name: '%TypedArray%', + source: 'Object.getPrototypeOf(Uint8Array)', + }, + { + name: '%TypeError%', + source: 'TypeError', + }, + { + name: '%Uint8Array%', + source: 'Uint8Array', + }, + { + name: '%Uint8ClampedArray%', + source: 'Uint8ClampedArray', + }, + { + name: '%Uint16Array%', + source: 'Uint16Array', + }, + { + name: '%Uint32Array%', + source: 'Uint32Array', + }, + { + name: '%URIError%', + source: 'URIError', + }, + { + name: '%WeakMap%', + source: 'WeakMap', + }, + { + name: '%WeakRef%', + source: 'WeakRef', + }, + { + name: '%WeakSet%', + source: 'WeakSet', + }, +]; + +WellKnownIntrinsicObjects.forEach((wkio) => { + var actual; + + try { + actual = new Function("return " + wkio.source)(); + } catch (exception) { + // Nothing to do here. + } + + wkio.value = actual; +}); diff --git a/package.json b/package.json new file mode 100644 index 00000000000..faa769dd7c7 --- /dev/null +++ b/package.json @@ -0,0 +1,31 @@ +{ + "name": "test262", + "version": "5.0.0", + "description": "Test262 tests conformance to the continually maintained draft future ECMAScript standard found at http://tc39.github.io/ecma262/ , together with any Stage 3 or later TC39 proposals.", + "repository": { + "type": "git", + "url": "git+https://github.com/tc39/test262.git" + }, + "license": "BSD", + "bugs": { + "url": "https://github.com/tc39/test262/issues" + }, + "private": true, + "homepage": "https://github.com/tc39/test262#readme", + "devDependencies": { + "esvu": "^1.2.11", + "test262-harness": "^8.0.0" + }, + "scripts": { + "ci": "./tools/scripts/ci_test.sh", + "test": "test262-harness", + "diff": "git diff --diff-filter ACMR --name-only main.. -- test/ && git ls-files --exclude-standard --others -- test/", + "test:diff": "npm run test:diff:v8 && npm run test:diff:spidermonkey && npm run test:diff:chakra && npm run test:diff:javascriptcore", + "test:diff:v8": "test262-harness -t 8 --hostType=d8 --hostPath=v8 $(npm run --silent diff)", + "test:diff:spidermonkey": "test262-harness -t 8 --hostType=jsshell --hostPath=spidermonkey $(npm run --silent diff)", + "test:diff:chakra": "test262-harness -t 8 --hostType=ch --hostPath=chakra $(npm run --silent diff)", + "test:diff:javascriptcore": "test262-harness -t 8 --hostType=jsc --hostPath=javascriptcore $(npm run --silent diff)", + "test:diff:xs": "test262-harness -t 8 --hostType=xs --hostPath=xs $(npm run --silent diff)" + } +} + diff --git a/test/sendable/builtins/ASON/15.12-0-1.js b/test/sendable/builtins/ASON/15.12-0-1.js new file mode 100644 index 00000000000..5a18e8cc541 --- /dev/null +++ b/test/sendable/builtins/ASON/15.12-0-1.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: | + This test should be run without any built-ins being added/augmented. + The name JSON must be bound to an object. + 4.2 calls out JSON as one of the built-in objects. +es5id: 15.12-0-1 +description: JSON must be a built-in object +---*/ + +var o = JSON; + +assert.sameValue(typeof(o), "object", 'typeof(o)'); diff --git a/test/sendable/builtins/ASON/15.12-0-2.js b/test/sendable/builtins/ASON/15.12-0-2.js new file mode 100644 index 00000000000..be97a00743e --- /dev/null +++ b/test/sendable/builtins/ASON/15.12-0-2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: | + This test should be run without any built-ins being added/augmented. + The name JSON must be bound to an object, and must not support [[Construct]]. + step 4 in 11.2.2 should throw a TypeError exception. +es5id: 15.12-0-2 +description: JSON must not support the [[Construct]] method +---*/ + +var o = JSON; +assert.throws(TypeError, function() { + var j = new JSON(); +}); diff --git a/test/sendable/builtins/ASON/15.12-0-3.js b/test/sendable/builtins/ASON/15.12-0-3.js new file mode 100644 index 00000000000..2de9aba9f99 --- /dev/null +++ b/test/sendable/builtins/ASON/15.12-0-3.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: | + This test should be run without any built-ins being added/augmented. + The name JSON must be bound to an object, and must not support [[Call]]. + step 5 in 11.2.3 should throw a TypeError exception. +es5id: 15.12-0-3 +description: JSON must not support the [[Call]] method +---*/ + +var o = JSON; +assert.throws(TypeError, function() { + var j = JSON(); +}); diff --git a/test/sendable/builtins/ASON/15.12-0-4.js b/test/sendable/builtins/ASON/15.12-0-4.js new file mode 100644 index 00000000000..88211d9d301 --- /dev/null +++ b/test/sendable/builtins/ASON/15.12-0-4.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: | + This test should be run without any built-ins being added/augmented. + The last paragraph in section 15 says "every other property described + in this section has the attribute {... [[Enumerable]] : false ...} + unless otherwise specified. This default applies to the properties on + JSON, and we should not be able to enumerate them. +es5id: 15.12-0-4 +description: JSON object's properties must be non enumerable +---*/ + +var o = JSON; +var i = 0; +for (var p in o) { + i++; +} + + +assert.sameValue(i, 0, 'i'); diff --git a/test/sendable/builtins/ASON/Symbol.toStringTag.js b/test/sendable/builtins/ASON/Symbol.toStringTag.js new file mode 100644 index 00000000000..1f521b04297 --- /dev/null +++ b/test/sendable/builtins/ASON/Symbol.toStringTag.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +es6id: 24.3.3 +description: > + `Symbol.toStringTag` property descriptor +info: | + The initial value of the @@toStringTag property is the String value + "JSON". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.toStringTag] +---*/ + +assert.sameValue(JSON[Symbol.toStringTag], 'JSON'); + +verifyNotEnumerable(JSON, Symbol.toStringTag); +verifyNotWritable(JSON, Symbol.toStringTag); +verifyConfigurable(JSON, Symbol.toStringTag); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-1.js new file mode 100644 index 00000000000..50dea92ecd0 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-1 +description: The JSON lexical grammar treats whitespace as a token seperator +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12\t\r\n 34'); // should produce a syntax error as whitespace results in two tokens +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-2.js new file mode 100644 index 00000000000..17d77b48a5b --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-2 +description: > + is not valid JSON whitespace as specified by the production + JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u000b1234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-3.js new file mode 100644 index 00000000000..4f64dc20b48 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-3 +description: > + is not valid JSON whitespace as specified by the production + JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u000c1234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-4.js new file mode 100644 index 00000000000..b0a57d78ff0 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-4.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-4 +description: > + is not valid JSON whitespace as specified by the production + JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u00a01234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-5.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-5.js new file mode 100644 index 00000000000..201a22e7703 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-5.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-5 +description: > + is not valid JSON whitespace as specified by the + production JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u200b1234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-6.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-6.js new file mode 100644 index 00000000000..b5a2e2a7b2f --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-6.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-6 +description: > + is not valid JSON whitespace as specified by the production + JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\ufeff1234'); // should produce a syntax error a +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-8.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-8.js new file mode 100644 index 00000000000..c37e2e39a35 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-8.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-8 +description: > + U+2028 and U+2029 are not valid JSON whitespace as specified by + the production JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u2028\u20291234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-9.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-9.js new file mode 100644 index 00000000000..6efca79868c --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-9.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-9 +description: Whitespace characters can appear before/after any JSONtoken +---*/ + +JSON.parseSendable('\t\r \n{\t\r \n' + + '"property"\t\r \n:\t\r \n{\t\r \n}\t\r \n,\t\r \n' + + '"prop2"\t\r \n:\t\r \n' + + '[\t\r \ntrue\t\r \n,\t\r \nnull\t\r \n,123.456\t\r \n]' + + '\t\r \n}\t\r \n'); // should JOSN parse without error diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g1-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-1.js new file mode 100644 index 00000000000..5ffb43c42ba --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g1-1 +description: The JSON lexical grammar treats as a whitespace character +---*/ + +assert.sameValue(JSON.parseSendable('\t1234'), 1234, ' should be ignored'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12\t34'); +}, ' should produce a syntax error as whitespace results in two tokens'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g1-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-2.js new file mode 100644 index 00000000000..616ce7a920d --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g1-2 +description: The JSON lexical grammar treats as a whitespace character +---*/ + +assert.sameValue(JSON.parseSendable('\r1234'), 1234, ' should be ignored'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12\r34'); +}, ' should produce a syntax error as whitespace results in two tokens'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g1-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-3.js new file mode 100644 index 00000000000..10e3d2e6651 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g1-3 +description: The JSON lexical grammar treats as a whitespace character +---*/ + +assert.sameValue(JSON.parseSendable('\n1234'), 1234, ' should be ignored'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12\n34'); +}, ' should produce a syntax error as whitespace results in two tokens'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g1-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-4.js new file mode 100644 index 00000000000..7036a2c6976 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-4.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g1-4 +description: The JSON lexical grammar treats as a whitespace character +---*/ + +assert.sameValue(JSON.parseSendable(' 1234'), 1234, ' should be ignored'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12 34'); +}, ' should produce a syntax error as whitespace results in two tokens'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-1.js new file mode 100644 index 00000000000..0b267f2b768 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-1.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-1 +description: JSONStrings can be written using double quotes +---*/ + +assert.sameValue(JSON.parseSendable('"abc"'), "abc", 'JSON.parseSendable(\'"abc"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-2.js new file mode 100644 index 00000000000..2e668977bc5 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-2.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-2 +description: A JSONString may not be delimited by single quotes +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable("'abc'"); +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-3.js new file mode 100644 index 00000000000..e669dcd42a7 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-3 +description: A JSONString may not be delimited by Uncode escaped quotes +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable("\\u0022abc\\u0022"); +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-4.js new file mode 100644 index 00000000000..70b5fb22e09 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-4.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-4 +description: A JSONString must both begin and end with double quotes +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"ab'+"c'"); +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-5.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-5.js new file mode 100644 index 00000000000..25e2ad16bd6 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-5.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-5 +description: > + A JSONStrings can contain no JSONStringCharacters (Empty + JSONStrings) +---*/ + +assert.sameValue(JSON.parseSendable('""'), "", 'JSON.parseSendable(\'""\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g4-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-1.js new file mode 100644 index 00000000000..90922377afb --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g4-1 +description: > + The JSON lexical grammar does not allow a JSONStringCharacter to + be any of the Unicode characters U+0000 thru U+0007 +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007"'); // invalid string characters should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g4-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-2.js new file mode 100644 index 00000000000..3d78b1713bd --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g4-2 +description: > + The JSON lexical grammar does not allow a JSONStringCharacter to + be any of the Unicode characters U+0008 thru U+000F +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\u0008\u0009\u000a\u000b\u000c\u000d\u000e\u000f"'); // invalid string characters should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g4-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-3.js new file mode 100644 index 00000000000..70666e48bbe --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g4-3 +description: > + The JSON lexical grammar does not allow a JSONStringCharacter to + be any of the Unicode characters U+0010 thru U+0017 +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017"'); // invalid string characters should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g4-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-4.js new file mode 100644 index 00000000000..15f0fa148ec --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-4.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g4-4 +description: > + The JSON lexical grammar does not allow a JSONStringCharacter to + be any of the Unicode characters U+0018 thru U+001F +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f"'); // invalid string characters should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g5-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-1.js new file mode 100644 index 00000000000..7c8956efc0f --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g5-1 +description: > + The JSON lexical grammar allows Unicode escape sequences in a + JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\u0058"'), 'X', 'JSON.parseSendable(\'"\\u0058"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g5-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-2.js new file mode 100644 index 00000000000..b0f26a5e5da --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g5-2 +description: > + A JSONStringCharacter UnicodeEscape may not have fewer than 4 hex + characters +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\\u005"') +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g5-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-3.js new file mode 100644 index 00000000000..39902df1e08 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g5-3 +description: > + A JSONStringCharacter UnicodeEscape may not include any non=hex + characters +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\\u0X50"') +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-1.js new file mode 100644 index 00000000000..f6c13053628 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-1 +description: > + The JSON lexical grammer allows '/' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\/"'), '/', 'JSON.parseSendable(\'"\\/"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-2.js new file mode 100644 index 00000000000..999f68dec57 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-2.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-2 +description: > + The JSON lexical grammer allows '' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\\\"'), '\\', 'JSON.parseSendable(\'"\\\\"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-3.js new file mode 100644 index 00000000000..1121b8279d1 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-3 +description: > + The JSON lexical grammer allows 'b' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\b"'), '\b', 'JSON.parseSendable(\'"\\b"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-4.js new file mode 100644 index 00000000000..ac68e632327 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-4.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-4 +description: > + The JSON lexical grammer allows 'f' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\f"'), '\f', 'JSON.parseSendable(\'"\\f"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-5.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-5.js new file mode 100644 index 00000000000..12ae29aa064 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-5.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-5 +description: > + The JSON lexical grammer allows 'n' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\n"'), '\n', 'JSON.parseSendable(\'"\\n"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-6.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-6.js new file mode 100644 index 00000000000..d2af48c9027 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-6.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-6 +description: > + The JSON lexical grammer allows 'r' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\r"'), '\r', 'JSON.parseSendable(\'"\\r"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-7.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-7.js new file mode 100644 index 00000000000..2694840cdd4 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-7.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-7 +description: > + The JSON lexical grammer allows 't' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\t"'), '\t', 'JSON.parseSendable(\'"\\t"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-1.js b/test/sendable/builtins/ASON/parse/15.12.2-2-1.js new file mode 100644 index 00000000000..f930df426b4 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-1.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-1 +description: > + JSON.parse - parsing an object where property name is a null + character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ ' + nullChars[index] + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-10.js b/test/sendable/builtins/ASON/parse/15.12.2-2-10.js new file mode 100644 index 00000000000..9d6fb44ae11 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-10.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-10 +description: > + JSON.parse - parsing an object where property value middles with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + "Jo" + nullChars[index] + "hn" + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-2.js b/test/sendable/builtins/ASON/parse/15.12.2-2-2.js new file mode 100644 index 00000000000..c186f556dc7 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-2.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-2 +description: > + JSON.parse - parsing an object where property name starts with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ ' + nullChars[index] + "name" + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-3.js b/test/sendable/builtins/ASON/parse/15.12.2-2-3.js new file mode 100644 index 00000000000..5378050c58d --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-3.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-3 +description: > + JSON.parse - parsing an object where property name ends with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{' + "name" + nullChars[index] + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-4.js b/test/sendable/builtins/ASON/parse/15.12.2-2-4.js new file mode 100644 index 00000000000..b382455ca13 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-4.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-4 +description: > + JSON.parse - parsing an object where property name starts and ends + with a null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{' + nullChars[index] + "name" + nullChars[index] + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-5.js b/test/sendable/builtins/ASON/parse/15.12.2-2-5.js new file mode 100644 index 00000000000..4364a4757f1 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-5.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-5 +description: > + JSON.parse - parsing an object where property name middles with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ ' + "na" + nullChars[index] + "me" + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-6.js b/test/sendable/builtins/ASON/parse/15.12.2-2-6.js new file mode 100644 index 00000000000..8cf76e5d294 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-6.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-6 +description: > + JSON.parse - parsing an object where property value is a null + character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + nullChars[index] + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-7.js b/test/sendable/builtins/ASON/parse/15.12.2-2-7.js new file mode 100644 index 00000000000..70c8283e19b --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-7.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-7 +description: > + JSON.parse - parsing an object where property value starts with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + nullChars[index] + "John" + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-8.js b/test/sendable/builtins/ASON/parse/15.12.2-2-8.js new file mode 100644 index 00000000000..c3abc56c3d4 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-8.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-8 +description: > + JSON.parse - parsing an object where property value ends with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + "John" + nullChars[index] + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-9.js b/test/sendable/builtins/ASON/parse/15.12.2-2-9.js new file mode 100644 index 00000000000..7a4e6633618 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-9.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-9 +description: > + JSON.parse - parsing an object where property value starts and + ends with a null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + nullChars[index] + "John" + nullChars[index] + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/S15.12.2_A1.js b/test/sendable/builtins/ASON/parse/S15.12.2_A1.js new file mode 100644 index 00000000000..c3ea45ad889 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/S15.12.2_A1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: JSON.parse must create a property with the given property name +es5id: 15.12.2_A1 +description: Tests that JSON.parse treats "__proto__" as a regular property name +---*/ + +var x = JSON.parseSendable('{"__proto__":[]}'); + +assert.sameValue( + Object.getPrototypeOf(x), + Object.prototype, + 'Object.getPrototypeOf("JSON.parseSendable(\'{"__proto__":[]}\')") returns Object.prototype' +); + +assert(Array.isArray(x.__proto__), 'Array.isArray(x.__proto__) must return true'); diff --git a/test/sendable/builtins/ASON/parse/invalid-whitespace.js b/test/sendable/builtins/ASON/parse/invalid-whitespace.js new file mode 100644 index 00000000000..b65c52f5d03 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/invalid-whitespace.js @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-json.parse +es5id: 15.12.1.1-0-7 +description: > + other category z spaces are not valid JSON whitespace as specified + by the production JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u16801'); +}, '\\u1680'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u180e1'); +}, '\\u180e'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20001'); +}, '\\u2000'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20011'); +}, '\\u2001'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20021'); +}, '\\u2002'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20031'); +}, '\\u2003'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20041'); +}, '\\u2004'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20051'); +}, '\\u2005'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20061'); +}, '\\u2006'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20071'); +}, '\\u2007'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20081'); +}, '\\u2008'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20091'); +}, '\\u2009'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u200a1'); +}, '\\u200a'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u202f1'); +}, '\\u202f'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u205f1'); +}, '\\u205f'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u30001'); +}, '\\u3000'); diff --git a/test/sendable/builtins/ASON/stringify/value-bigint-cross-realm.js b/test/sendable/builtins/ASON/stringify/value-bigint-cross-realm.js new file mode 100644 index 00000000000..123d728f29d --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-bigint-cross-realm.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-serializejsonproperty +description: JSON.stringify called with a BigInt object from another realm +features: [BigInt, cross-realm] +---*/ + +var other = $262.createRealm().global; +var wrapped = other.Object(other.BigInt(100)); + +assert.throws(TypeError, () => JSON.stringify(wrapped), + "cross-realm BigInt object without toJSON method"); + +other.BigInt.prototype.toJSON = function () { return this.toString(); }; + +assert.sameValue(JSON.stringify(wrapped), "\"100\"", + "cross-realm BigInt object with toJSON method"); diff --git a/test/sendable/builtins/ASON/stringify/value-bigint-order.js b/test/sendable/builtins/ASON/stringify/value-bigint-order.js new file mode 100644 index 00000000000..253986e5069 --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-bigint-order.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: BigInt stringify order of steps +esid: sec-serializejsonproperty +info: | + Runtime Semantics: SerializeJSONProperty ( key, holder ) + + 2. If Type(value) is Object or BigInt, then + a. Let toJSON be ? GetGetV(value, "toJSON"). + b. If IsCallable(toJSON) is true, then + i. Set value to ? Call(toJSON, value, « key »). + 3. If ReplacerFunction is not undefined, then + a. Set value to ? Call(ReplacerFunction, holder, « key, value »). + 4. If Type(value) is Object, then + [...] + d. Else if value has a [[BigIntData]] internal slot, then + i. Set value to value.[[BigIntData]]. + [...] + 10. If Type(value) is BigInt, throw a TypeError exception +features: [BigInt, arrow-function] +---*/ + +let step; + +function replacer(x, k, v) +{ + assert.sameValue(step++, 1); + assert.sameValue(v, 1n); + return x; +} + +BigInt.prototype.toJSON = function () { assert.sameValue(step++, 0); return 1n; }; + +step = 0; +assert.throws(TypeError, () => JSON.stringify(0n, (k, v) => replacer(2n, k, v))); +assert.sameValue(step, 2); + +step = 0; +assert.throws(TypeError, () => JSON.stringify(0n, (k, v) => replacer(Object(2n), k, v))); +assert.sameValue(step, 2); diff --git a/test/sendable/builtins/ASON/stringify/value-bigint-replacer.js b/test/sendable/builtins/ASON/stringify/value-bigint-replacer.js new file mode 100644 index 00000000000..3213f22f8e9 --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-bigint-replacer.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: JSON serialization of BigInt values with replacer +esid: sec-serializejsonproperty +info: | + Runtime Semantics: SerializeJSONProperty ( key, holder ) + + 3. If ReplacerFunction is not undefined, then + a. Set value to ? Call(ReplacerFunction, holder, « key, value »). +features: [BigInt] +---*/ + +function replacer(k, v) +{ + if (typeof v === "bigint") + return "bigint"; + else + return v; +} + +assert.sameValue(JSON.stringify(0n, replacer), '"bigint"'); +assert.sameValue(JSON.stringify({x: 0n}, replacer), '{"x":"bigint"}'); diff --git a/test/sendable/builtins/ASON/stringify/value-bigint.js b/test/sendable/builtins/ASON/stringify/value-bigint.js new file mode 100644 index 00000000000..1170ebe057b --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-bigint.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: JSON serialization of BigInt values +esid: pending +features: [BigInt] +---*/ + +assert.throws(TypeError, () => JSON.stringify(0n)); +assert.throws(TypeError, () => JSON.stringify(Object(0n))); +assert.throws(TypeError, () => JSON.stringify({x: 0n})); diff --git a/test/sendable/builtins/ASON/stringify/value-string-escape-unicode.js b/test/sendable/builtins/ASON/stringify/value-string-escape-unicode.js new file mode 100644 index 00000000000..67d77a18d46 --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-string-escape-unicode.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-quotejsonstring +description: > + JSON.stringify strings containing surrogate code units +features: [well-formed-json-stringify] +---*/ + +assert.sameValue(JSON.stringify("\uD834"), '"\\ud834"', + 'JSON.stringify("\\uD834")'); +assert.sameValue(JSON.stringify("\uDF06"), '"\\udf06"', + 'JSON.stringify("\\uDF06")'); + +assert.sameValue(JSON.stringify("\uD834\uDF06"), '"𝌆"', + 'JSON.stringify("\\uD834\\uDF06")'); +assert.sameValue(JSON.stringify("\uD834\uD834\uDF06\uD834"), '"\\ud834𝌆\\ud834"', + 'JSON.stringify("\\uD834\\uD834\\uDF06\\uD834")'); +assert.sameValue(JSON.stringify("\uD834\uD834\uDF06\uDF06"), '"\\ud834𝌆\\udf06"', + 'JSON.stringify("\\uD834\\uD834\\uDF06\\uDF06")'); +assert.sameValue(JSON.stringify("\uDF06\uD834\uDF06\uD834"), '"\\udf06𝌆\\ud834"', + 'JSON.stringify("\\uDF06\\uD834\\uDF06\\uD834")'); +assert.sameValue(JSON.stringify("\uDF06\uD834\uDF06\uDF06"), '"\\udf06𝌆\\udf06"', + 'JSON.stringify("\\uDF06\\uD834\\uDF06\\uDF06")'); + +assert.sameValue(JSON.stringify("\uDF06\uD834"), '"\\udf06\\ud834"', + 'JSON.stringify("\\uDF06\\uD834")'); +assert.sameValue(JSON.stringify("\uD834\uDF06\uD834\uD834"), '"𝌆\\ud834\\ud834"', + 'JSON.stringify("\\uD834\\uDF06\\uD834\\uD834")'); +assert.sameValue(JSON.stringify("\uD834\uDF06\uD834\uDF06"), '"𝌆𝌆"', + 'JSON.stringify("\\uD834\\uDF06\\uD834\\uDF06")'); +assert.sameValue(JSON.stringify("\uDF06\uDF06\uD834\uD834"), '"\\udf06\\udf06\\ud834\\ud834"', + 'JSON.stringify("\\uDF06\\uDF06\\uD834\\uD834")'); +assert.sameValue(JSON.stringify("\uDF06\uDF06\uD834\uDF06"), '"\\udf06\\udf06𝌆"', + 'JSON.stringify("\\uDF06\\uDF06\\uD834\\uDF06")'); diff --git a/test262/data/package.json b/test262/data/package.json new file mode 100644 index 00000000000..faa769dd7c7 --- /dev/null +++ b/test262/data/package.json @@ -0,0 +1,31 @@ +{ + "name": "test262", + "version": "5.0.0", + "description": "Test262 tests conformance to the continually maintained draft future ECMAScript standard found at http://tc39.github.io/ecma262/ , together with any Stage 3 or later TC39 proposals.", + "repository": { + "type": "git", + "url": "git+https://github.com/tc39/test262.git" + }, + "license": "BSD", + "bugs": { + "url": "https://github.com/tc39/test262/issues" + }, + "private": true, + "homepage": "https://github.com/tc39/test262#readme", + "devDependencies": { + "esvu": "^1.2.11", + "test262-harness": "^8.0.0" + }, + "scripts": { + "ci": "./tools/scripts/ci_test.sh", + "test": "test262-harness", + "diff": "git diff --diff-filter ACMR --name-only main.. -- test/ && git ls-files --exclude-standard --others -- test/", + "test:diff": "npm run test:diff:v8 && npm run test:diff:spidermonkey && npm run test:diff:chakra && npm run test:diff:javascriptcore", + "test:diff:v8": "test262-harness -t 8 --hostType=d8 --hostPath=v8 $(npm run --silent diff)", + "test:diff:spidermonkey": "test262-harness -t 8 --hostType=jsshell --hostPath=spidermonkey $(npm run --silent diff)", + "test:diff:chakra": "test262-harness -t 8 --hostType=ch --hostPath=chakra $(npm run --silent diff)", + "test:diff:javascriptcore": "test262-harness -t 8 --hostType=jsc --hostPath=javascriptcore $(npm run --silent diff)", + "test:diff:xs": "test262-harness -t 8 --hostType=xs --hostPath=xs $(npm run --silent diff)" + } +} + -- Gitee From e1d200d945a762280292423441949eb17f0fdcd7 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 10 Dec 2024 10:15:41 +0800 Subject: [PATCH 02/93] https://gitee.com/ark_standalone_build/test262_sendable to https://gitee.com/ark_compiler_sendable/test262_sendable change add new case Signed-off-by: zhuzhihui7 --- LICENSE | 2 +- README.en.md | 14 + README.md | 14 + harness/assert.js | 130 + harness/assertRelativeDateMs.js | 37 + harness/async-gc.js | 69 + harness/asyncHelpers.js | 123 + harness/atomicsHelper.js | 336 +++ harness/byteConversionValues.js | 458 +++ harness/compareArray.js | 62 + harness/compareIterator.js | 47 + harness/dateConstants.js | 41 + harness/decimalToHexString.js | 38 + harness/deepEqual.js | 339 +++ harness/detachArrayBuffer.js | 28 + harness/doneprintHandle.js | 34 + harness/features.yml | 6 + harness/fnGlobalObject.js | 24 + harness/hidden-constructors.js | 29 + harness/isConstructor.js | 34 + harness/nans.js | 34 + harness/nativeFunctionMatcher.js | 232 ++ harness/promiseHelper.js | 87 + harness/propertyHelper.js | 266 ++ harness/proxyTrapsHelper.js | 43 + harness/regExpUtils.js | 123 + harness/sta.js | 39 + harness/tcoHelper.js | 26 + harness/temporalHelpers.js | 2086 ++++++++++++++ harness/testAtomics.js | 135 + harness/testBigIntTypedArray.js | 52 + harness/testIntl.js | 2510 +++++++++++++++++ harness/testTypedArray.js | 134 + harness/timer.js | 42 + harness/typeCoercion.js | 463 +++ harness/wellKnownIntrinsicObjects.js | 302 ++ package.json | 31 + test/sendable/builtins/ASON/15.12-0-1.js | 27 + test/sendable/builtins/ASON/15.12-0-2.js | 28 + test/sendable/builtins/ASON/15.12-0-3.js | 28 + test/sendable/builtins/ASON/15.12-0-4.js | 34 + .../builtins/ASON/Symbol.toStringTag.js | 33 + .../builtins/ASON/parse/15.12.1.1-0-1.js | 23 + .../builtins/ASON/parse/15.12.1.1-0-2.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-3.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-4.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-5.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-6.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-8.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-9.js | 25 + .../builtins/ASON/parse/15.12.1.1-g1-1.js | 25 + .../builtins/ASON/parse/15.12.1.1-g1-2.js | 25 + .../builtins/ASON/parse/15.12.1.1-g1-3.js | 25 + .../builtins/ASON/parse/15.12.1.1-g1-4.js | 25 + .../builtins/ASON/parse/15.12.1.1-g2-1.js | 21 + .../builtins/ASON/parse/15.12.1.1-g2-2.js | 23 + .../builtins/ASON/parse/15.12.1.1-g2-3.js | 23 + .../builtins/ASON/parse/15.12.1.1-g2-4.js | 23 + .../builtins/ASON/parse/15.12.1.1-g2-5.js | 23 + .../builtins/ASON/parse/15.12.1.1-g4-1.js | 25 + .../builtins/ASON/parse/15.12.1.1-g4-2.js | 25 + .../builtins/ASON/parse/15.12.1.1-g4-3.js | 25 + .../builtins/ASON/parse/15.12.1.1-g4-4.js | 25 + .../builtins/ASON/parse/15.12.1.1-g5-1.js | 23 + .../builtins/ASON/parse/15.12.1.1-g5-2.js | 25 + .../builtins/ASON/parse/15.12.1.1-g5-3.js | 25 + .../builtins/ASON/parse/15.12.1.1-g6-1.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-2.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-3.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-4.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-5.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-6.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-7.js | 23 + .../builtins/ASON/parse/15.12.2-2-1.js | 61 + .../builtins/ASON/parse/15.12.2-2-10.js | 61 + .../builtins/ASON/parse/15.12.2-2-2.js | 61 + .../builtins/ASON/parse/15.12.2-2-3.js | 61 + .../builtins/ASON/parse/15.12.2-2-4.js | 61 + .../builtins/ASON/parse/15.12.2-2-5.js | 61 + .../builtins/ASON/parse/15.12.2-2-6.js | 61 + .../builtins/ASON/parse/15.12.2-2-7.js | 61 + .../builtins/ASON/parse/15.12.2-2-8.js | 61 + .../builtins/ASON/parse/15.12.2-2-9.js | 61 + .../builtins/ASON/parse/S15.12.2_A1.js | 30 + .../builtins/ASON/parse/invalid-whitespace.js | 86 + .../stringify/value-bigint-cross-realm.js | 31 + .../ASON/stringify/value-bigint-order.js | 54 + .../ASON/stringify/value-bigint-replacer.js | 36 + .../builtins/ASON/stringify/value-bigint.js | 24 + .../stringify/value-string-escape-unicode.js | 48 + .../builtins/Array/from/from-array.js | 35 + test262/data/package.json | 31 + 92 files changed, 10349 insertions(+), 1 deletion(-) create mode 100644 harness/assert.js create mode 100644 harness/assertRelativeDateMs.js create mode 100644 harness/async-gc.js create mode 100644 harness/asyncHelpers.js create mode 100644 harness/atomicsHelper.js create mode 100644 harness/byteConversionValues.js create mode 100644 harness/compareArray.js create mode 100644 harness/compareIterator.js create mode 100644 harness/dateConstants.js create mode 100644 harness/decimalToHexString.js create mode 100644 harness/deepEqual.js create mode 100644 harness/detachArrayBuffer.js create mode 100644 harness/doneprintHandle.js create mode 100644 harness/features.yml create mode 100644 harness/fnGlobalObject.js create mode 100644 harness/hidden-constructors.js create mode 100644 harness/isConstructor.js create mode 100644 harness/nans.js create mode 100644 harness/nativeFunctionMatcher.js create mode 100644 harness/promiseHelper.js create mode 100644 harness/propertyHelper.js create mode 100644 harness/proxyTrapsHelper.js create mode 100644 harness/regExpUtils.js create mode 100644 harness/sta.js create mode 100644 harness/tcoHelper.js create mode 100644 harness/temporalHelpers.js create mode 100644 harness/testAtomics.js create mode 100644 harness/testBigIntTypedArray.js create mode 100644 harness/testIntl.js create mode 100644 harness/testTypedArray.js create mode 100644 harness/timer.js create mode 100644 harness/typeCoercion.js create mode 100644 harness/wellKnownIntrinsicObjects.js create mode 100644 package.json create mode 100644 test/sendable/builtins/ASON/15.12-0-1.js create mode 100644 test/sendable/builtins/ASON/15.12-0-2.js create mode 100644 test/sendable/builtins/ASON/15.12-0-3.js create mode 100644 test/sendable/builtins/ASON/15.12-0-4.js create mode 100644 test/sendable/builtins/ASON/Symbol.toStringTag.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-5.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-6.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-8.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-9.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g1-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g1-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g1-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g1-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-5.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g4-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g4-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g4-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g4-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g5-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g5-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g5-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-5.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-6.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-7.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-10.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-5.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-6.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-7.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-8.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-9.js create mode 100644 test/sendable/builtins/ASON/parse/S15.12.2_A1.js create mode 100644 test/sendable/builtins/ASON/parse/invalid-whitespace.js create mode 100644 test/sendable/builtins/ASON/stringify/value-bigint-cross-realm.js create mode 100644 test/sendable/builtins/ASON/stringify/value-bigint-order.js create mode 100644 test/sendable/builtins/ASON/stringify/value-bigint-replacer.js create mode 100644 test/sendable/builtins/ASON/stringify/value-bigint.js create mode 100644 test/sendable/builtins/ASON/stringify/value-string-escape-unicode.js create mode 100644 test/sendable/builtins/Array/from/from-array.js create mode 100644 test262/data/package.json diff --git a/LICENSE b/LICENSE index 29f81d812f3..c9db8b287c9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ Apache License - Version 2.0, January 2004 + Version 2.0, January 2024 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION diff --git a/README.en.md b/README.en.md index 37e4cb93c14..e4013df8392 100644 --- a/README.en.md +++ b/README.en.md @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ # test262_sendable #### Description diff --git a/README.md b/README.md index 3462fb7652b..8bd8055c06f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ # test262_sendable #### 介绍 diff --git a/harness/assert.js b/harness/assert.js new file mode 100644 index 00000000000..c3373464f08 --- /dev/null +++ b/harness/assert.js @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of assertion functions used throughout test262 +defines: [assert] +---*/ + + +function assert(mustBeTrue, message) { + if (mustBeTrue === true) { + return; + } + + if (message === undefined) { + message = 'Expected true but got ' + assert._toString(mustBeTrue); + } + throw new Test262Error(message); +} + +assert._isSameValue = function (a, b) { + if (a === b) { + // Handle +/-0 vs. -/+0 + return a !== 0 || 1 / a === 1 / b; + } + + // Handle NaN vs. NaN + return a !== a && b !== b; +}; + +assert.sameValue = function (actual, expected, message) { + try { + if (assert._isSameValue(actual, expected)) { + return; + } + } catch (error) { + throw new Test262Error(message + ' (_isSameValue operation threw) ' + error); + return; + } + + if (message === undefined) { + message = ''; + } else { + message += ' '; + } + + message += 'Expected SameValue(«' + assert._toString(actual) + '», «' + assert._toString(expected) + '») to be true'; + + throw new Test262Error(message); +}; + +assert.notSameValue = function (actual, unexpected, message) { + if (!assert._isSameValue(actual, unexpected)) { + return; + } + + if (message === undefined) { + message = ''; + } else { + message += ' '; + } + + message += 'Expected SameValue(«' + assert._toString(actual) + '», «' + assert._toString(unexpected) + '») to be false'; + + throw new Test262Error(message); +}; + +assert.throws = function (expectedErrorConstructor, func, message) { + var expectedName, actualName; + if (typeof func !== "function") { + throw new Test262Error('assert.throws requires two arguments: the error constructor ' + + 'and a function to run'); + return; + } + if (message === undefined) { + message = ''; + } else { + message += ' '; + } + + try { + func(); + } catch (thrown) { + if (typeof thrown !== 'object' || thrown === null) { + message += 'Thrown value was not an object!'; + throw new Test262Error(message); + } else if (thrown.constructor !== expectedErrorConstructor) { + expectedName = expectedErrorConstructor.name; + actualName = thrown.constructor.name; + if (expectedName === actualName) { + message += 'Expected a ' + expectedName + ' but got a different error constructor with the same name'; + } else { + message += 'Expected a ' + expectedName + ' but got a ' + actualName; + } + throw new Test262Error(message); + } + return; + } + + message += 'Expected a ' + expectedErrorConstructor.name + ' to be thrown but no exception was thrown at all'; + throw new Test262Error(message); +}; + +assert._toString = function (value) { + try { + if (value === 0 && 1 / value === -Infinity) { + return '-0'; + } + + return String(value); + } catch (err) { + if (err.name === 'TypeError') { + return Object.prototype.toString.call(value); + } + + throw err; + } +}; diff --git a/harness/assertRelativeDateMs.js b/harness/assertRelativeDateMs.js new file mode 100644 index 00000000000..eda726eb9fa --- /dev/null +++ b/harness/assertRelativeDateMs.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Verify that the given date object's Number representation describes the + correct number of milliseconds since the Unix epoch relative to the local + time zone (as interpreted at the specified date). +defines: [assertRelativeDateMs] +---*/ + +/** + * @param {Date} date + * @param {Number} expectedMs + */ +function assertRelativeDateMs(date, expectedMs) { + var actualMs = date.valueOf(); + var localOffset = date.getTimezoneOffset() * 60000; + + if (actualMs - localOffset !== expectedMs) { + throw new Test262Error( + 'Expected ' + date + ' to be ' + expectedMs + + ' milliseconds from the Unix epoch' + ); + } +} diff --git a/harness/async-gc.js b/harness/async-gc.js new file mode 100644 index 00000000000..87a4a3e73fd --- /dev/null +++ b/harness/async-gc.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Collection of functions used to capture references cleanup from garbage collectors +features: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry, Symbol, async-functions] +flags: [non-deterministic] +defines: [asyncGC, asyncGCDeref, resolveAsyncGC] +---*/ + +function asyncGC(...targets) { + var finalizationRegistry = new FinalizationRegistry(() => {}); + var length = targets.length; + + for (let target of targets) { + finalizationRegistry.register(target, 'target'); + target = null; + } + + targets = null; + + return Promise.resolve('tick').then(() => asyncGCDeref()).then(() => { + var names = []; + + // consume iterator to capture names + finalizationRegistry.cleanupSome(name => { names.push(name); }); + + if (!names || names.length != length) { + throw asyncGC.notCollected; + } + }); +} + +asyncGC.notCollected = Symbol('Object was not collected'); + +async function asyncGCDeref() { + var trigger; + + // TODO: Remove this when $262.clearKeptObject becomes documented and required + if ($262.clearKeptObjects) { + trigger = $262.clearKeptObjects(); + } + + await $262.gc(); + + return Promise.resolve(trigger); +} + +function resolveAsyncGC(err) { + if (err === asyncGC.notCollected) { + // Do not fail as GC can't provide necessary resources. + $DONE(); + return; + } + + $DONE(err); +} diff --git a/harness/asyncHelpers.js b/harness/asyncHelpers.js new file mode 100644 index 00000000000..9f48fa5a508 --- /dev/null +++ b/harness/asyncHelpers.js @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + A collection of assertion and wrapper functions for testing asynchronous built-ins. +defines: [asyncTest] +---*/ + +function asyncTest(testFunc) { + if (!Object.hasOwn(globalThis, "$DONE")) { + throw new Test262Error("asyncTest called without async flag"); + } + if (typeof testFunc !== "function") { + $DONE(new Test262Error("asyncTest called with non-function argument")); + return; + } + try { + testFunc().then( + function () { + $DONE(); + }, + function (error) { + $DONE(error); + } + ); + } catch (syncError) { + $DONE(syncError); + } +} + +assert.throwsAsync = async function (expectedErrorConstructor, func, message) { + var innerThenable; + if (message === undefined) { + message = ""; + } else { + message += " "; + } + if (typeof func === "function") { + try { + innerThenable = func(); + if ( + innerThenable === null || + typeof innerThenable !== "object" || + typeof innerThenable.then !== "function" + ) { + message += + "Expected to obtain an inner promise that would reject with a" + + expectedErrorConstructor.name + + " but result was not a thenable"; + throw new Test262Error(message); + } + } catch (thrown) { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but an exception was thrown synchronously while obtaining the inner promise"; + throw new Test262Error(message); + } + } else { + message += + "assert.throwsAsync called with an argument that is not a function"; + throw new Test262Error(message); + } + + try { + return innerThenable.then( + function () { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but no exception was thrown at all"; + throw new Test262Error(message); + }, + function (thrown) { + var expectedName, actualName; + if (typeof thrown !== "object" || thrown === null) { + message += "Thrown value was not an object!"; + throw new Test262Error(message); + } else if (thrown.constructor !== expectedErrorConstructor) { + expectedName = expectedErrorConstructor.name; + actualName = thrown.constructor.name; + if (expectedName === actualName) { + message += + "Expected a " + + expectedName + + " but got a different error constructor with the same name"; + } else { + message += + "Expected a " + expectedName + " but got a " + actualName; + } + throw new Test262Error(message); + } + } + ); + } catch (thrown) { + if (typeof thrown !== "object" || thrown === null) { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but innerThenable synchronously threw a value that was not an object "; + } else { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but a " + + thrown.constructor.name + + " was thrown synchronously"; + } + throw new Test262Error(message); + } +}; diff --git a/harness/atomicsHelper.js b/harness/atomicsHelper.js new file mode 100644 index 00000000000..761fee87c87 --- /dev/null +++ b/harness/atomicsHelper.js @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Collection of functions used to interact with Atomics.* operations across agent boundaries. +defines: + - $262.agent.getReportAsync + - $262.agent.getReport + - $262.agent.safeBroadcastAsync + - $262.agent.safeBroadcast + - $262.agent.setTimeout + - $262.agent.tryYield + - $262.agent.trySleep +---*/ + +/** + * @return {String} A report sent from an agent. + */ +{ + // This is only necessary because the original + // $262.agent.getReport API was insufficient. + // + // All runtimes currently have their own + // $262.agent.getReport which is wrong, so we + // will pave over it with a corrected version. + // + // Binding $262.agent is necessary to prevent + // breaking SpiderMonkey's $262.agent.getReport + let getReport = $262.agent.getReport.bind($262.agent); + + $262.agent.getReport = function() { + var r; + while ((r = getReport()) == null) { + $262.agent.sleep(1); + } + return r; + }; + + if (this.setTimeout === undefined) { + (function(that) { + that.setTimeout = function(callback, delay) { + let p = Promise.resolve(); + let start = Date.now(); + let end = start + delay; + function check() { + if ((end - Date.now()) > 0) { + p.then(check); + } + else { + callback(); + } + } + p.then(check); + } + })(this); + } + + $262.agent.setTimeout = setTimeout; + + $262.agent.getReportAsync = function() { + return new Promise(function(resolve) { + (function loop() { + let result = getReport(); + if (!result) { + setTimeout(loop, 1000); + } else { + resolve(result); + } + })(); + }); + }; +} + +/** + * + * Share a given Int32Array or BigInt64Array to all running agents. Ensure that the + * provided TypedArray is a "shared typed array". + * + * NOTE: Migrating all tests to this API is necessary to prevent tests from hanging + * indefinitely when a SAB is sent to a worker but the code in the worker attempts to + * create a non-sharable TypedArray (something that is not Int32Array or BigInt64Array). + * When that scenario occurs, an exception is thrown and the agent worker can no + * longer communicate with any other threads that control the SAB. If the main + * thread happens to be spinning in the $262.agent.waitUntil() while loop, it will never + * meet its termination condition and the test will hang indefinitely. + * + * Because we've defined $262.agent.broadcast(SAB) in + * https://github.com/tc39/test262/blob/HEAD/INTERPRETING.md, there are host implementations + * that assume compatibility, which must be maintained. + * + * + * $262.agent.safeBroadcast(TA) should not be included in + * https://github.com/tc39/test262/blob/HEAD/INTERPRETING.md + * + * + * @param {(Int32Array|BigInt64Array)} typedArray An Int32Array or BigInt64Array with a SharedArrayBuffer + */ +$262.agent.safeBroadcast = function(typedArray) { + let Constructor = Object.getPrototypeOf(typedArray).constructor; + let temp = new Constructor( + new SharedArrayBuffer(Constructor.BYTES_PER_ELEMENT) + ); + try { + // This will never actually wait, but that's fine because we only + // want to ensure that this typedArray CAN be waited on and is shareable. + Atomics.wait(temp, 0, Constructor === Int32Array ? 1 : BigInt(1)); + } catch (error) { + throw new Test262Error(`${Constructor.name} cannot be used as a shared typed array. (${error})`); + } + + $262.agent.broadcast(typedArray.buffer); +}; + +$262.agent.safeBroadcastAsync = async function(ta, index, expected) { + await $262.agent.broadcast(ta.buffer); + await $262.agent.waitUntil(ta, index, expected); + await $262.agent.tryYield(); + return await Atomics.load(ta, index); +}; + + +/** + * With a given Int32Array or BigInt64Array, wait until the expected number of agents have + * reported themselves by calling: + * + * Atomics.add(typedArray, index, 1); + * + * @param {(Int32Array|BigInt64Array)} typedArray An Int32Array or BigInt64Array with a SharedArrayBuffer + * @param {number} index The index of which all agents will report. + * @param {number} expected The number of agents that are expected to report as active. + */ +$262.agent.waitUntil = function(typedArray, index, expected) { + + var agents = 0; + while ((agents = Atomics.load(typedArray, index)) !== expected) { + /* nothing */ + } + assert.sameValue(agents, expected, "Reporting number of 'agents' equals the value of 'expected'"); +}; + +/** + * Timeout values used throughout the Atomics tests. All timeouts are specified in milliseconds. + * + * @property {number} yield Used for `$262.agent.tryYield`. Must not be used in other functions. + * @property {number} small Used when agents will always timeout and `Atomics.wake` is not part + * of the test semantics. Must be larger than `$262.agent.timeouts.yield`. + * @property {number} long Used when some agents may timeout and `Atomics.wake` is called on some + * agents. The agents are required to wait and this needs to be observable + * by the main thread. + * @property {number} huge Used when `Atomics.wake` is called on all waiting agents. The waiting + * must not timeout. The agents are required to wait and this needs to be + * observable by the main thread. All waiting agents must be woken by the + * main thread. + * + * Usage for `$262.agent.timeouts.small`: + * const WAIT_INDEX = 0; + * const RUNNING = 1; + * const TIMEOUT = $262.agent.timeouts.small; + * const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)); + * + * $262.agent.start(` + * $262.agent.receiveBroadcast(function(sab) { + * const i32a = new Int32Array(sab); + * Atomics.add(i32a, ${RUNNING}, 1); + * + * $262.agent.report(Atomics.wait(i32a, ${WAIT_INDEX}, 0, ${TIMEOUT})); + * + * $262.agent.leaving(); + * }); + * `); + * $262.agent.safeBroadcast(i32a.buffer); + * + * // Wait until the agent was started and then try to yield control to increase + * // the likelihood the agent has called `Atomics.wait` and is now waiting. + * $262.agent.waitUntil(i32a, RUNNING, 1); + * $262.agent.tryYield(); + * + * // The agent is expected to time out. + * assert.sameValue($262.agent.getReport(), "timed-out"); + * + * + * Usage for `$262.agent.timeouts.long`: + * const WAIT_INDEX = 0; + * const RUNNING = 1; + * const NUMAGENT = 2; + * const TIMEOUT = $262.agent.timeouts.long; + * const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)); + * + * for (let i = 0; i < NUMAGENT; i++) { + * $262.agent.start(` + * $262.agent.receiveBroadcast(function(sab) { + * const i32a = new Int32Array(sab); + * Atomics.add(i32a, ${RUNNING}, 1); + * + * $262.agent.report(Atomics.wait(i32a, ${WAIT_INDEX}, 0, ${TIMEOUT})); + * + * $262.agent.leaving(); + * }); + * `); + * } + * $262.agent.safeBroadcast(i32a.buffer); + * + * // Wait until the agents were started and then try to yield control to increase + * // the likelihood the agents have called `Atomics.wait` and are now waiting. + * $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); + * $262.agent.tryYield(); + * + * // Wake exactly one agent. + * assert.sameValue(Atomics.wake(i32a, WAIT_INDEX, 1), 1); + * + * // When it doesn't matter how many agents were woken at once, a while loop + * // can be used to make the test more resilient against intermittent failures + * // in case even though `tryYield` was called, the agents haven't started to + * // wait. + * // + * // // Repeat until exactly one agent was woken. + * // var woken = 0; + * // while ((woken = Atomics.wake(i32a, WAIT_INDEX, 1)) !== 0) ; + * // assert.sameValue(woken, 1); + * + * // One agent was woken and the other one timed out. + * const reports = [$262.agent.getReport(), $262.agent.getReport()]; + * assert(reports.includes("ok")); + * assert(reports.includes("timed-out")); + * + * + * Usage for `$262.agent.timeouts.huge`: + * const WAIT_INDEX = 0; + * const RUNNING = 1; + * const NUMAGENT = 2; + * const TIMEOUT = $262.agent.timeouts.huge; + * const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)); + * + * for (let i = 0; i < NUMAGENT; i++) { + * $262.agent.start(` + * $262.agent.receiveBroadcast(function(sab) { + * const i32a = new Int32Array(sab); + * Atomics.add(i32a, ${RUNNING}, 1); + * + * $262.agent.report(Atomics.wait(i32a, ${WAIT_INDEX}, 0, ${TIMEOUT})); + * + * $262.agent.leaving(); + * }); + * `); + * } + * $262.agent.safeBroadcast(i32a.buffer); + * + * // Wait until the agents were started and then try to yield control to increase + * // the likelihood the agents have called `Atomics.wait` and are now waiting. + * $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); + * $262.agent.tryYield(); + * + * // Wake all agents. + * assert.sameValue(Atomics.wake(i32a, WAIT_INDEX), NUMAGENT); + * + * // When it doesn't matter how many agents were woken at once, a while loop + * // can be used to make the test more resilient against intermittent failures + * // in case even though `tryYield` was called, the agents haven't started to + * // wait. + * // + * // // Repeat until all agents were woken. + * // for (var wokenCount = 0; wokenCount < NUMAGENT; ) { + * // var woken = 0; + * // while ((woken = Atomics.wake(i32a, WAIT_INDEX)) !== 0) ; + * // // Maybe perform an action on the woken agents here. + * // wokenCount += woken; + * // } + * + * // All agents were woken and none timeout. + * for (var i = 0; i < NUMAGENT; i++) { + * assert($262.agent.getReport(), "ok"); + * } + */ +$262.agent.timeouts = { + yield: 100, + small: 200, + long: 1000, + huge: 10000, +}; + +/** + * Try to yield control to the agent threads. + * + * Usage: + * const VALUE = 0; + * const RUNNING = 1; + * const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)); + * + * $262.agent.start(` + * $262.agent.receiveBroadcast(function(sab) { + * const i32a = new Int32Array(sab); + * Atomics.add(i32a, ${RUNNING}, 1); + * + * Atomics.store(i32a, ${VALUE}, 1); + * + * $262.agent.leaving(); + * }); + * `); + * $262.agent.safeBroadcast(i32a.buffer); + * + * // Wait until agent was started and then try to yield control. + * $262.agent.waitUntil(i32a, RUNNING, 1); + * $262.agent.tryYield(); + * + * // Note: This result is not guaranteed, but should hold in practice most of the time. + * assert.sameValue(Atomics.load(i32a, VALUE), 1); + * + * The default implementation simply waits for `$262.agent.timeouts.yield` milliseconds. + */ +$262.agent.tryYield = function() { + $262.agent.sleep($262.agent.timeouts.yield); +}; + +/** + * Try to sleep the current agent for the given amount of milliseconds. It is acceptable, + * but not encouraged, to ignore this sleep request and directly continue execution. + * + * The default implementation calls `$262.agent.sleep(ms)`. + * + * @param {number} ms Time to sleep in milliseconds. + */ +$262.agent.trySleep = function(ms) { + $262.agent.sleep(ms); +}; diff --git a/harness/byteConversionValues.js b/harness/byteConversionValues.js new file mode 100644 index 00000000000..e84d7c1e9d7 --- /dev/null +++ b/harness/byteConversionValues.js @@ -0,0 +1,458 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Provide a list for original and expected values for different byte + conversions. + This helper is mostly used on tests for TypedArray and DataView, and each + array from the expected values must match the original values array on every + index containing its original value. +defines: [byteConversionValues] +---*/ +var byteConversionValues = { + values: [ + 127, // 2 ** 7 - 1 + 128, // 2 ** 7 + 32767, // 2 ** 15 - 1 + 32768, // 2 ** 15 + 2147483647, // 2 ** 31 - 1 + 2147483648, // 2 ** 31 + 255, // 2 ** 8 - 1 + 256, // 2 ** 8 + 65535, // 2 ** 16 - 1 + 65536, // 2 ** 16 + 4294967295, // 2 ** 32 - 1 + 4294967296, // 2 ** 32 + 9007199254740991, // 2 ** 53 - 1 + 9007199254740992, // 2 ** 53 + 1.1, + 0.1, + 0.5, + 0.50000001, + 0.6, + 0.7, + undefined, + -1, + -0, + -0.1, + -1.1, + NaN, + -127, // - ( 2 ** 7 - 1 ) + -128, // - ( 2 ** 7 ) + -32767, // - ( 2 ** 15 - 1 ) + -32768, // - ( 2 ** 15 ) + -2147483647, // - ( 2 ** 31 - 1 ) + -2147483648, // - ( 2 ** 31 ) + -255, // - ( 2 ** 8 - 1 ) + -256, // - ( 2 ** 8 ) + -65535, // - ( 2 ** 16 - 1 ) + -65536, // - ( 2 ** 16 ) + -4294967295, // - ( 2 ** 32 - 1 ) + -4294967296, // - ( 2 ** 32 ) + Infinity, + -Infinity, + 0 + ], + + expected: { + Int8: [ + 127, // 127 + -128, // 128 + -1, // 32767 + 0, // 32768 + -1, // 2147483647 + 0, // 2147483648 + -1, // 255 + 0, // 256 + -1, // 65535 + 0, // 65536 + -1, // 4294967295 + 0, // 4294967296 + -1, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + -1, // -1 + 0, // -0 + 0, // -0.1 + -1, // -1.1 + 0, // NaN + -127, // -127 + -128, // -128 + 1, // -32767 + 0, // -32768 + 1, // -2147483647 + 0, // -2147483648 + 1, // -255 + 0, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Uint8: [ + 127, // 127 + 128, // 128 + 255, // 32767 + 0, // 32768 + 255, // 2147483647 + 0, // 2147483648 + 255, // 255 + 0, // 256 + 255, // 65535 + 0, // 65536 + 255, // 4294967295 + 0, // 4294967296 + 255, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + 255, // -1 + 0, // -0 + 0, // -0.1 + 255, // -1.1 + 0, // NaN + 129, // -127 + 128, // -128 + 1, // -32767 + 0, // -32768 + 1, // -2147483647 + 0, // -2147483648 + 1, // -255 + 0, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Uint8Clamped: [ + 127, // 127 + 128, // 128 + 255, // 32767 + 255, // 32768 + 255, // 2147483647 + 255, // 2147483648 + 255, // 255 + 255, // 256 + 255, // 65535 + 255, // 65536 + 255, // 4294967295 + 255, // 4294967296 + 255, // 9007199254740991 + 255, // 9007199254740992 + 1, // 1.1, + 0, // 0.1 + 0, // 0.5 + 1, // 0.50000001, + 1, // 0.6 + 1, // 0.7 + 0, // undefined + 0, // -1 + 0, // -0 + 0, // -0.1 + 0, // -1.1 + 0, // NaN + 0, // -127 + 0, // -128 + 0, // -32767 + 0, // -32768 + 0, // -2147483647 + 0, // -2147483648 + 0, // -255 + 0, // -256 + 0, // -65535 + 0, // -65536 + 0, // -4294967295 + 0, // -4294967296 + 255, // Infinity + 0, // -Infinity + 0 + ], + Int16: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + -32768, // 32768 + -1, // 2147483647 + 0, // 2147483648 + 255, // 255 + 256, // 256 + -1, // 65535 + 0, // 65536 + -1, // 4294967295 + 0, // 4294967296 + -1, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + -1, // -1 + 0, // -0 + 0, // -0.1 + -1, // -1.1 + 0, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + 1, // -2147483647 + 0, // -2147483648 + -255, // -255 + -256, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Uint16: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 65535, // 2147483647 + 0, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 0, // 65536 + 65535, // 4294967295 + 0, // 4294967296 + 65535, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + 65535, // -1 + 0, // -0 + 0, // -0.1 + 65535, // -1.1 + 0, // NaN + 65409, // -127 + 65408, // -128 + 32769, // -32767 + 32768, // -32768 + 1, // -2147483647 + 0, // -2147483648 + 65281, // -255 + 65280, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Int32: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483647, // 2147483647 + -2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + -1, // 4294967295 + 0, // 4294967296 + -1, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + -1, // -1 + 0, // -0 + 0, // -0.1 + -1, // -1.1 + 0, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483647, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Uint32: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483647, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967295, // 4294967295 + 0, // 4294967296 + 4294967295, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + 4294967295, // -1 + 0, // -0 + 0, // -0.1 + 4294967295, // -1.1 + 0, // NaN + 4294967169, // -127 + 4294967168, // -128 + 4294934529, // -32767 + 4294934528, // -32768 + 2147483649, // -2147483647 + 2147483648, // -2147483648 + 4294967041, // -255 + 4294967040, // -256 + 4294901761, // -65535 + 4294901760, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Float32: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483648, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967296, // 4294967295 + 4294967296, // 4294967296 + 9007199254740992, // 9007199254740991 + 9007199254740992, // 9007199254740992 + 1.100000023841858, // 1.1 + 0.10000000149011612, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.6000000238418579, // 0.6 + 0.699999988079071, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.10000000149011612, // -0.1 + -1.100000023841858, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483648, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + -4294967296, // -4294967295 + -4294967296, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0 + ], + Float64: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483647, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967295, // 4294967295 + 4294967296, // 4294967296 + 9007199254740991, // 9007199254740991 + 9007199254740992, // 9007199254740992 + 1.1, // 1.1 + 0.1, // 0.1 + 0.5, // 0.5 + 0.50000001, // 0.50000001, + 0.6, // 0.6 + 0.7, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.1, // -0.1 + -1.1, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483647, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + -4294967295, // -4294967295 + -4294967296, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0 + ] + } +}; diff --git a/harness/compareArray.js b/harness/compareArray.js new file mode 100644 index 00000000000..2783698457e --- /dev/null +++ b/harness/compareArray.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Compare the contents of two arrays +defines: [compareArray] +---*/ + +function compareArray(a, b) { + if (b.length !== a.length) { + return false; + } + + for (var i = 0; i < a.length; i++) { + if (!compareArray.isSameValue(b[i], a[i])) { + return false; + } + } + return true; +} + +compareArray.isSameValue = function(a, b) { + if (a === 0 && b === 0) return 1 / a === 1 / b; + if (a !== a && b !== b) return true; + + return a === b; +}; + +compareArray.format = function(arrayLike) { + return `[${[].map.call(arrayLike, String).join(', ')}]`; +}; + +assert.compareArray = function(actual, expected, message) { + message = message === undefined ? '' : message; + + if (typeof message === 'symbol') { + message = message.toString(); + } + + assert(actual != null, `First argument shouldn't be nullish. ${message}`); + assert(expected != null, `Second argument shouldn't be nullish. ${message}`); + var format = compareArray.format; + var result = compareArray(actual, expected); + + // The following prevents actual and expected from being iterated and evaluated + // more than once unless absolutely necessary. + if (!result) { + assert(false, `Expected ${format(actual)} and ${format(expected)} to have the same contents. ${message}`); + } +}; diff --git a/harness/compareIterator.js b/harness/compareIterator.js new file mode 100644 index 00000000000..d4e3b9a53aa --- /dev/null +++ b/harness/compareIterator.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Compare the values of an iterator with an array of expected values +defines: [assert.compareIterator] +---*/ + +// Example: +// +// function* numbers() { +// yield 1; +// yield 2; +// yield 3; +// } +// +// assert.compareIterator(numbers(), [ +// v => assert.sameValue(v, 1), +// v => assert.sameValue(v, 2), +// v => assert.sameValue(v, 3), +// ]); +// +assert.compareIterator = function(iter, validators, message) { + message = message || ''; + + var i, result; + for (i = 0; i < validators.length; i++) { + result = iter.next(); + assert(!result.done, 'Expected ' + i + ' values(s). Instead iterator only produced ' + (i - 1) + ' value(s). ' + message); + validators[i](result.value); + } + + result = iter.next(); + assert(result.done, 'Expected only ' + i + ' values(s). Instead iterator produced more. ' + message); + assert.sameValue(result.value, undefined, 'Expected value of `undefined` when iterator completes. ' + message); +} diff --git a/harness/dateConstants.js b/harness/dateConstants.js new file mode 100644 index 00000000000..2eed15ca63a --- /dev/null +++ b/harness/dateConstants.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of date-centric values +defines: + - date_1899_end + - date_1900_start + - date_1969_end + - date_1970_start + - date_1999_end + - date_2000_start + - date_2099_end + - date_2100_start + - start_of_time + - end_of_time +---*/ + +var date_1899_end = -2208988800001; +var date_1900_start = -2208988800000; +var date_1969_end = -1; +var date_1970_start = 0; +var date_1999_end = 946684799999; +var date_2000_start = 946684800000; +var date_2099_end = 4102444799999; +var date_2100_start = 4102444800000; + +var start_of_time = -8.64e15; +var end_of_time = 8.64e15; diff --git a/harness/decimalToHexString.js b/harness/decimalToHexString.js new file mode 100644 index 00000000000..9840ee589cd --- /dev/null +++ b/harness/decimalToHexString.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +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]; +} diff --git a/harness/deepEqual.js b/harness/deepEqual.js new file mode 100644 index 00000000000..a2ceeb3d9cc --- /dev/null +++ b/harness/deepEqual.js @@ -0,0 +1,339 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Compare two values structurally +defines: [assert.deepEqual] +---*/ + +assert.deepEqual = function(actual, expected, message) { + var format = assert.deepEqual.format; + assert( + assert.deepEqual._compare(actual, expected), + `Expected ${format(actual)} to be structurally equal to ${format(expected)}. ${(message || '')}` + ); +}; + +assert.deepEqual.format = function(value, seen) { + switch (typeof value) { + case 'string': + return typeof JSON !== "undefined" ? JSON.stringify(value) : `"${value}"`; + case 'number': + case 'boolean': + case 'symbol': + case 'bigint': + return value.toString(); + case 'undefined': + return 'undefined'; + case 'function': + return `[Function${value.name ? `: ${value.name}` : ''}]`; + case 'object': + if (value === null) return 'null'; + if (value instanceof Date) return `Date "${value.toISOString()}"`; + if (value instanceof RegExp) return value.toString(); + if (!seen) { + seen = { + counter: 0, + map: new Map() + }; + } + + let usage = seen.map.get(value); + if (usage) { + usage.used = true; + return `[Ref: #${usage.id}]`; + } + + usage = { id: ++seen.counter, used: false }; + seen.map.set(value, usage); + + if (typeof Set !== "undefined" && value instanceof Set) { + return `Set {${Array.from(value).map(value => assert.deepEqual.format(value, seen)).join(', ')}}${usage.used ? ` as #${usage.id}` : ''}`; + } + if (typeof Map !== "undefined" && value instanceof Map) { + return `Map {${Array.from(value).map(pair => `${assert.deepEqual.format(pair[0], seen)} => ${assert.deepEqual.format(pair[1], seen)}}`).join(', ')}}${usage.used ? ` as #${usage.id}` : ''}`; + } + if (Array.isArray ? Array.isArray(value) : value instanceof Array) { + return `[${value.map(value => assert.deepEqual.format(value, seen)).join(', ')}]${usage.used ? ` as #${usage.id}` : ''}`; + } + let tag = Symbol.toStringTag in value ? value[Symbol.toStringTag] : 'Object'; + if (tag === 'Object' && Object.getPrototypeOf(value) === null) { + tag = '[Object: null prototype]'; + } + return `${tag ? `${tag} ` : ''}{ ${Object.keys(value).map(key => `${key.toString()}: ${assert.deepEqual.format(value[key], seen)}`).join(', ')} }${usage.used ? ` as #${usage.id}` : ''}`; + default: + return typeof value; + } +}; + +assert.deepEqual._compare = (function () { + var EQUAL = 1; + var NOT_EQUAL = -1; + var UNKNOWN = 0; + + function deepEqual(a, b) { + return compareEquality(a, b) === EQUAL; + } + + function compareEquality(a, b, cache) { + return compareIf(a, b, isOptional, compareOptionality) + || compareIf(a, b, isPrimitiveEquatable, comparePrimitiveEquality) + || compareIf(a, b, isObjectEquatable, compareObjectEquality, cache) + || NOT_EQUAL; + } + + function compareIf(a, b, test, compare, cache) { + return !test(a) + ? !test(b) ? UNKNOWN : NOT_EQUAL + : !test(b) ? NOT_EQUAL : cacheComparison(a, b, compare, cache); + } + + function tryCompareStrictEquality(a, b) { + return a === b ? EQUAL : UNKNOWN; + } + + function tryCompareTypeOfEquality(a, b) { + return typeof a !== typeof b ? NOT_EQUAL : UNKNOWN; + } + + function tryCompareToStringTagEquality(a, b) { + var aTag = Symbol.toStringTag in a ? a[Symbol.toStringTag] : undefined; + var bTag = Symbol.toStringTag in b ? b[Symbol.toStringTag] : undefined; + return aTag !== bTag ? NOT_EQUAL : UNKNOWN; + } + + function isOptional(value) { + return value === undefined + || value === null; + } + + function compareOptionality(a, b) { + return tryCompareStrictEquality(a, b) + || NOT_EQUAL; + } + + function isPrimitiveEquatable(value) { + switch (typeof value) { + case 'string': + case 'number': + case 'bigint': + case 'boolean': + case 'symbol': + return true; + default: + return isBoxed(value); + } + } + + function comparePrimitiveEquality(a, b) { + if (isBoxed(a)) a = a.valueOf(); + if (isBoxed(b)) b = b.valueOf(); + return tryCompareStrictEquality(a, b) + || tryCompareTypeOfEquality(a, b) + || compareIf(a, b, isNaNEquatable, compareNaNEquality) + || NOT_EQUAL; + } + + function isNaNEquatable(value) { + return typeof value === 'number'; + } + + function compareNaNEquality(a, b) { + return isNaN(a) && isNaN(b) ? EQUAL : NOT_EQUAL; + } + + function isObjectEquatable(value) { + return typeof value === 'object'; + } + + function compareObjectEquality(a, b, cache) { + if (!cache) cache = new Map(); + return getCache(cache, a, b) + || setCache(cache, a, b, EQUAL) // consider equal for now + || cacheComparison(a, b, tryCompareStrictEquality, cache) + || cacheComparison(a, b, tryCompareToStringTagEquality, cache) + || compareIf(a, b, isValueOfEquatable, compareValueOfEquality) + || compareIf(a, b, isToStringEquatable, compareToStringEquality) + || compareIf(a, b, isArrayLikeEquatable, compareArrayLikeEquality, cache) + || compareIf(a, b, isStructurallyEquatable, compareStructuralEquality, cache) + || compareIf(a, b, isIterableEquatable, compareIterableEquality, cache) + || cacheComparison(a, b, fail, cache); + } + + function isBoxed(value) { + return value instanceof String + || value instanceof Number + || value instanceof Boolean + || typeof Symbol === 'function' && value instanceof Symbol + || typeof BigInt === 'function' && value instanceof BigInt; + } + + function isValueOfEquatable(value) { + return value instanceof Date; + } + + function compareValueOfEquality(a, b) { + return compareIf(a.valueOf(), b.valueOf(), isPrimitiveEquatable, comparePrimitiveEquality) + || NOT_EQUAL; + } + + function isToStringEquatable(value) { + return value instanceof RegExp; + } + + function compareToStringEquality(a, b) { + return compareIf(a.toString(), b.toString(), isPrimitiveEquatable, comparePrimitiveEquality) + || NOT_EQUAL; + } + + function isArrayLikeEquatable(value) { + return (Array.isArray ? Array.isArray(value) : value instanceof Array) + || (typeof Uint8Array === 'function' && value instanceof Uint8Array) + || (typeof Uint8ClampedArray === 'function' && value instanceof Uint8ClampedArray) + || (typeof Uint16Array === 'function' && value instanceof Uint16Array) + || (typeof Uint32Array === 'function' && value instanceof Uint32Array) + || (typeof Int8Array === 'function' && value instanceof Int8Array) + || (typeof Int16Array === 'function' && value instanceof Int16Array) + || (typeof Int32Array === 'function' && value instanceof Int32Array) + || (typeof Float32Array === 'function' && value instanceof Float32Array) + || (typeof Float64Array === 'function' && value instanceof Float64Array) + || (typeof BigUint64Array === 'function' && value instanceof BigUint64Array) + || (typeof BigInt64Array === 'function' && value instanceof BigInt64Array); + } + + function compareArrayLikeEquality(a, b, cache) { + if (a.length !== b.length) return NOT_EQUAL; + for (var i = 0; i < a.length; i++) { + if (compareEquality(a[i], b[i], cache) === NOT_EQUAL) { + return NOT_EQUAL; + } + } + return EQUAL; + } + + function isStructurallyEquatable(value) { + return !(typeof Promise === 'function' && value instanceof Promise // only comparable by reference + || typeof WeakMap === 'function' && value instanceof WeakMap // only comparable by reference + || typeof WeakSet === 'function' && value instanceof WeakSet // only comparable by reference + || typeof Map === 'function' && value instanceof Map // comparable via @@iterator + || typeof Set === 'function' && value instanceof Set); // comparable via @@iterator + } + + function compareStructuralEquality(a, b, cache) { + var aKeys = []; + for (var key in a) aKeys.push(key); + + var bKeys = []; + for (var key in b) bKeys.push(key); + + if (aKeys.length !== bKeys.length) { + return NOT_EQUAL; + } + + aKeys.sort(); + bKeys.sort(); + + for (var i = 0; i < aKeys.length; i++) { + var aKey = aKeys[i]; + var bKey = bKeys[i]; + if (compareEquality(aKey, bKey, cache) === NOT_EQUAL) { + return NOT_EQUAL; + } + if (compareEquality(a[aKey], b[bKey], cache) === NOT_EQUAL) { + return NOT_EQUAL; + } + } + + return compareIf(a, b, isIterableEquatable, compareIterableEquality, cache) + || EQUAL; + } + + function isIterableEquatable(value) { + return typeof Symbol === 'function' + && typeof value[Symbol.iterator] === 'function'; + } + + function compareIteratorEquality(a, b, cache) { + if (typeof Map === 'function' && a instanceof Map && b instanceof Map || + typeof Set === 'function' && a instanceof Set && b instanceof Set) { + if (a.size !== b.size) return NOT_EQUAL; // exit early if we detect a difference in size + } + + var ar, br; + while (true) { + ar = a.next(); + br = b.next(); + if (ar.done) { + if (br.done) return EQUAL; + if (b.return) b.return(); + return NOT_EQUAL; + } + if (br.done) { + if (a.return) a.return(); + return NOT_EQUAL; + } + if (compareEquality(ar.value, br.value, cache) === NOT_EQUAL) { + if (a.return) a.return(); + if (b.return) b.return(); + return NOT_EQUAL; + } + } + } + + function compareIterableEquality(a, b, cache) { + return compareIteratorEquality(a[Symbol.iterator](), b[Symbol.iterator](), cache); + } + + function cacheComparison(a, b, compare, cache) { + var result = compare(a, b, cache); + if (cache && (result === EQUAL || result === NOT_EQUAL)) { + setCache(cache, a, b, /** @type {EQUAL | NOT_EQUAL} */(result)); + } + return result; + } + + function fail() { + return NOT_EQUAL; + } + + function setCache(cache, left, right, result) { + var otherCache; + + otherCache = cache.get(left); + if (!otherCache) cache.set(left, otherCache = new Map()); + otherCache.set(right, result); + + otherCache = cache.get(right); + if (!otherCache) cache.set(right, otherCache = new Map()); + otherCache.set(left, result); + } + + function getCache(cache, left, right) { + var otherCache; + var result; + + otherCache = cache.get(left); + result = otherCache && otherCache.get(right); + if (result) return result; + + otherCache = cache.get(right); + result = otherCache && otherCache.get(left); + if (result) return result; + + return UNKNOWN; + } + + return deepEqual; +})(); diff --git a/harness/detachArrayBuffer.js b/harness/detachArrayBuffer.js new file mode 100644 index 00000000000..e69c0cbc2cd --- /dev/null +++ b/harness/detachArrayBuffer.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + A function used in the process of asserting correctness of TypedArray objects. + + $262.detachArrayBuffer is defined by a host. +defines: [$DETACHBUFFER] +---*/ + +function $DETACHBUFFER(buffer) { + if (!$262 || typeof $262.detachArrayBuffer !== "function") { + throw new Test262Error("No method available to detach an ArrayBuffer"); + } + $262.detachArrayBuffer(buffer); +} diff --git a/harness/doneprintHandle.js b/harness/doneprintHandle.js new file mode 100644 index 00000000000..8c8f589868d --- /dev/null +++ b/harness/doneprintHandle.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | +defines: [$DONE] +---*/ + +function __consolePrintHandle__(msg) { + print(msg); +} + +function $DONE(error) { + if (error) { + if(typeof error === 'object' && error !== null && 'name' in error) { + __consolePrintHandle__('Test262:AsyncTestFailure:' + error.name + ': ' + error.message); + } else { + __consolePrintHandle__('Test262:AsyncTestFailure:Test262Error: ' + String(error)); + } + } else { + __consolePrintHandle__('Test262:AsyncTestComplete'); + } +} diff --git a/harness/features.yml b/harness/features.yml new file mode 100644 index 00000000000..333af083bed --- /dev/null +++ b/harness/features.yml @@ -0,0 +1,6 @@ +atomicsHelper: [Atomics] +typeCoercion.js: [Symbol.toPrimitive, BigInt] +testAtomics.js: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, Symbol, TypedArray] +testBigIntTypedArray.js: [BigInt, TypedArray] +testTypedArray.js: [TypedArray] +isConstructor.js: [Reflect.construct] diff --git a/harness/fnGlobalObject.js b/harness/fnGlobalObject.js new file mode 100644 index 00000000000..370e40c3356 --- /dev/null +++ b/harness/fnGlobalObject.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Produce a reliable global object +defines: [fnGlobalObject] +---*/ + +var __globalObject = Function("return this;")(); +function fnGlobalObject() { + return __globalObject; +} diff --git a/harness/hidden-constructors.js b/harness/hidden-constructors.js new file mode 100644 index 00000000000..7ea8430fe48 --- /dev/null +++ b/harness/hidden-constructors.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: | + Provides uniform access to built-in constructors that are not exposed to the global object. +defines: + - AsyncArrowFunction + - AsyncFunction + - AsyncGeneratorFunction + - GeneratorFunction +---*/ + +var AsyncArrowFunction = Object.getPrototypeOf(async () => {}).constructor; +var AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; +var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; diff --git a/harness/isConstructor.js b/harness/isConstructor.js new file mode 100644 index 00000000000..9fad1048809 --- /dev/null +++ b/harness/isConstructor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +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/harness/nans.js b/harness/nans.js new file mode 100644 index 00000000000..39f2c57c22e --- /dev/null +++ b/harness/nans.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + A collection of NaN values produced from expressions that have been observed + to create distinct bit representations on various platforms. These provide a + weak basis for assertions regarding the consistent canonicalization of NaN + values in Array buffers. +defines: [NaNs] +---*/ + +var NaNs = [ + NaN, + Number.NaN, + NaN * 0, + 0/0, + Infinity/Infinity, + -(0/0), + Math.pow(-1, 0.5), + -Math.pow(-1, 0.5), + Number("Not-a-Number"), +]; diff --git a/harness/nativeFunctionMatcher.js b/harness/nativeFunctionMatcher.js new file mode 100644 index 00000000000..c913005ce30 --- /dev/null +++ b/harness/nativeFunctionMatcher.js @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Assert _NativeFunction_ Syntax +info: | + NativeFunction : + function _NativeFunctionAccessor_ opt _IdentifierName_ opt ( _FormalParameters_ ) { [ native code ] } + NativeFunctionAccessor : + get + set +defines: + - assertToStringOrNativeFunction + - assertNativeFunction + - validateNativeFunctionSource +---*/ + +const validateNativeFunctionSource = function(source) { + // These regexes should be kept up to date with Unicode using `regexpu-core`. + // `/\p{ID_Start}/u` + const UnicodeIDStart = /(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/; + // `/\p{ID_Continue}/u` + const UnicodeIDContinue = /(?:[0-9A-Z_a-z\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u08D3-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1ABF\u1AC0\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA827\uA82C\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD27\uDD30-\uDD39\uDE80-\uDEA9\uDEAB\uDEAC\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF50\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD47\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCE9\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0\uDFF1]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDEC0-\uDEF9]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A]|\uDB40[\uDD00-\uDDEF])/; + // `/\p{Space_Separator}/u` + const UnicodeSpaceSeparator = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/; + + const isNewline = (c) => /[\u000A\u000D\u2028\u2029]/u.test(c); + const isWhitespace = (c) => /[\u0009\u000B\u000C\u0020\u00A0\uFEFF]/u.test(c) || UnicodeSpaceSeparator.test(c); + + let pos = 0; + + const eatWhitespace = () => { + while (pos < source.length) { + const c = source[pos]; + if (isWhitespace(c) || isNewline(c)) { + pos += 1; + continue; + } + + if (c === '/') { + if (source[pos + 1] === '/') { + while (pos < source.length) { + if (isNewline(source[pos])) { + break; + } + pos += 1; + } + continue; + } + if (source[pos + 1] === '*') { + const end = source.indexOf('*/', pos); + if (end === -1) { + throw new SyntaxError(); + } + pos = end + '*/'.length; + continue; + } + } + + break; + } + }; + + const getIdentifier = () => { + eatWhitespace(); + + const start = pos; + let end = pos; + switch (source[end]) { + case '_': + case '$': + end += 1; + break; + default: + if (UnicodeIDStart.test(source[end])) { + end += 1; + break; + } + return null; + } + while (end < source.length) { + const c = source[end]; + switch (c) { + case '_': + case '$': + end += 1; + break; + default: + if (UnicodeIDContinue.test(c)) { + end += 1; + break; + } + return source.slice(start, end); + } + } + return source.slice(start, end); + }; + + const test = (s) => { + eatWhitespace(); + + if (/\w/.test(s)) { + return getIdentifier() === s; + } + return source.slice(pos, pos + s.length) === s; + }; + + const eat = (s) => { + if (test(s)) { + pos += s.length; + return true; + } + return false; + }; + + const eatIdentifier = () => { + const n = getIdentifier(); + if (n !== null) { + pos += n.length; + return true; + } + return false; + }; + + const expect = (s) => { + if (!eat(s)) { + throw new SyntaxError(); + } + }; + + const eatString = () => { + if (source[pos] === '\'' || source[pos] === '"') { + const match = source[pos]; + pos += 1; + while (pos < source.length) { + if (source[pos] === match && source[pos - 1] !== '\\') { + return; + } + if (isNewline(source[pos])) { + throw new SyntaxError(); + } + pos += 1; + } + throw new SyntaxError(); + } + }; + + // "Stumble" through source text until matching character is found. + // Assumes ECMAScript syntax keeps `[]` and `()` balanced. + const stumbleUntil = (c) => { + const match = { + ']': '[', + ')': '(', + }[c]; + let nesting = 1; + while (pos < source.length) { + eatWhitespace(); + eatString(); // Strings may contain unbalanced characters. + if (source[pos] === match) { + nesting += 1; + } else if (source[pos] === c) { + nesting -= 1; + } + pos += 1; + if (nesting === 0) { + return; + } + } + throw new SyntaxError(); + }; + + // function + expect('function'); + + // NativeFunctionAccessor + eat('get') || eat('set'); + + // PropertyName + if (!eatIdentifier() && eat('[')) { + stumbleUntil(']'); + } + + // ( FormalParameters ) + expect('('); + stumbleUntil(')'); + + // { + expect('{'); + + // [native code] + expect('['); + expect('native'); + expect('code'); + expect(']'); + + // } + expect('}'); + + eatWhitespace(); + if (pos !== source.length) { + throw new SyntaxError(); + } +}; + +const assertToStringOrNativeFunction = function(fn, expected) { + const actual = "" + fn; + try { + assert.sameValue(actual, expected); + } catch (unused) { + assertNativeFunction(fn, expected); + } +}; + +const assertNativeFunction = function(fn, special) { + const actual = "" + fn; + try { + validateNativeFunctionSource(actual); + } catch (unused) { + throw new Test262Error('Conforms to NativeFunction Syntax: ' + JSON.stringify(actual) + (special ? ' (' + special + ')' : '')); + } +}; diff --git a/harness/promiseHelper.js b/harness/promiseHelper.js new file mode 100644 index 00000000000..9750544489e --- /dev/null +++ b/harness/promiseHelper.js @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Check that an array contains a numeric sequence starting at 1 + and incrementing by 1 for each entry in the array. Used by + Promise tests to assert the order of execution in deep Promise + resolution pipelines. +defines: [checkSequence, checkSettledPromises] +---*/ + +function checkSequence(arr, message) { + arr.forEach(function(e, i) { + if (e !== (i+1)) { + throw new Test262Error((message ? message : "Steps in unexpected sequence:") + + " '" + arr.join(',') + "'"); + } + }); + + return true; +} + +function checkSettledPromises(settleds, expected, message) { + const prefix = message ? `${message}: ` : ''; + + assert.sameValue(Array.isArray(settleds), true, `${prefix}Settled values is an array`); + + assert.sameValue( + settleds.length, + expected.length, + `${prefix}The settled values has a different length than expected` + ); + + settleds.forEach((settled, i) => { + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'status'), + true, + `${prefix}The settled value has a property status` + ); + + assert.sameValue(settled.status, expected[i].status, `${prefix}status for item ${i}`); + + if (settled.status === 'fulfilled') { + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'value'), + true, + `${prefix}The fulfilled promise has a property named value` + ); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'reason'), + false, + `${prefix}The fulfilled promise has no property named reason` + ); + + assert.sameValue(settled.value, expected[i].value, `${prefix}value for item ${i}`); + } else { + assert.sameValue(settled.status, 'rejected', `${prefix}Valid statuses are only fulfilled or rejected`); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'value'), + false, + `${prefix}The fulfilled promise has no property named value` + ); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'reason'), + true, + `${prefix}The fulfilled promise has a property named reason` + ); + + assert.sameValue(settled.reason, expected[i].reason, `${prefix}Reason value for item ${i}`); + } + }); +} diff --git a/harness/propertyHelper.js b/harness/propertyHelper.js new file mode 100644 index 00000000000..6b38bb72e0b --- /dev/null +++ b/harness/propertyHelper.js @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to safely verify the correctness of + property descriptors. +defines: + - verifyProperty + - verifyEqualTo # deprecated + - verifyWritable # deprecated + - verifyNotWritable # deprecated + - verifyEnumerable # deprecated + - verifyNotEnumerable # deprecated + - verifyConfigurable # deprecated + - verifyNotConfigurable # deprecated +---*/ + +// @ts-check + +/** + * @param {object} obj + * @param {string|symbol} name + * @param {PropertyDescriptor|undefined} desc + * @param {object} [options] + * @param {boolean} [options.restore] + */ +function verifyProperty(obj, name, desc, options) { + assert( + arguments.length > 2, + 'verifyProperty should receive at least 3 arguments: obj, name, and descriptor' + ); + + var originalDesc = Object.getOwnPropertyDescriptor(obj, name); + var nameStr = String(name); + + // Allows checking for undefined descriptor if it's explicitly given. + if (desc === undefined) { + assert.sameValue( + originalDesc, + undefined, + "obj['" + nameStr + "'] descriptor should be undefined" + ); + + // desc and originalDesc are both undefined, problem solved; + return true; + } + + assert( + Object.prototype.hasOwnProperty.call(obj, name), + "obj should have an own property " + nameStr + ); + + assert.notSameValue( + desc, + null, + "The desc argument should be an object or undefined, null" + ); + + assert.sameValue( + typeof desc, + "object", + "The desc argument should be an object or undefined, " + String(desc) + ); + + var failures = []; + + if (Object.prototype.hasOwnProperty.call(desc, 'value')) { + if (!isSameValue(desc.value, originalDesc.value)) { + failures.push("descriptor value should be " + desc.value); + } + } + + if (Object.prototype.hasOwnProperty.call(desc, 'enumerable')) { + if (desc.enumerable !== originalDesc.enumerable || + desc.enumerable !== isEnumerable(obj, name)) { + failures.push('descriptor should ' + (desc.enumerable ? '' : 'not ') + 'be enumerable'); + } + } + + if (Object.prototype.hasOwnProperty.call(desc, 'writable')) { + if (desc.writable !== originalDesc.writable || + desc.writable !== isWritable(obj, name)) { + failures.push('descriptor should ' + (desc.writable ? '' : 'not ') + 'be writable'); + } + } + + if (Object.prototype.hasOwnProperty.call(desc, 'configurable')) { + if (desc.configurable !== originalDesc.configurable || + desc.configurable !== isConfigurable(obj, name)) { + failures.push('descriptor should ' + (desc.configurable ? '' : 'not ') + 'be configurable'); + } + } + + assert(!failures.length, failures.join('; ')); + + if (options && options.restore) { + Object.defineProperty(obj, name, originalDesc); + } + + return true; +} + +function isConfigurable(obj, name) { + var hasOwnProperty = Object.prototype.hasOwnProperty; + try { + delete obj[name]; + } catch (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + } + return !hasOwnProperty.call(obj, name); +} + +function isEnumerable(obj, name) { + var stringCheck = false; + + if (typeof name === "string") { + for (var x in obj) { + if (x === name) { + stringCheck = true; + break; + } + } + } else { + // skip it if name is not string, works for Symbol names. + stringCheck = true; + } + + return stringCheck && + Object.prototype.hasOwnProperty.call(obj, name) && + Object.prototype.propertyIsEnumerable.call(obj, name); +} + +function isSameValue(a, b) { + if (a === 0 && b === 0) return 1 / a === 1 / b; + if (a !== a && b !== b) return true; + + return a === b; +} + +var __isArray = Array.isArray; +function isWritable(obj, name, verifyProp, value) { + var unlikelyValue = __isArray(obj) && name === "length" ? + Math.pow(2, 32) - 1 : + "unlikelyValue"; + var newValue = value || unlikelyValue; + var hadValue = Object.prototype.hasOwnProperty.call(obj, name); + var oldValue = obj[name]; + var writeSucceeded; + + try { + obj[name] = newValue; + } catch (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + } + + writeSucceeded = isSameValue(obj[verifyProp || name], newValue); + + // Revert the change only if it was successful (in other cases, reverting + // is unnecessary and may trigger exceptions for certain property + // configurations) + if (writeSucceeded) { + if (hadValue) { + obj[name] = oldValue; + } else { + delete obj[name]; + } + } + + return writeSucceeded; +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyEqualTo(obj, name, value) { + if (!isSameValue(obj[name], value)) { + throw new Test262Error("Expected obj[" + String(name) + "] to equal " + value + + ", actually " + obj[name]); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyWritable(obj, name, verifyProp, value) { + if (!verifyProp) { + assert(Object.getOwnPropertyDescriptor(obj, name).writable, + "Expected obj[" + String(name) + "] to have writable:true."); + } + if (!isWritable(obj, name, verifyProp, value)) { + throw new Test262Error("Expected obj[" + String(name) + "] to be writable, but was not."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyNotWritable(obj, name, verifyProp, value) { + if (!verifyProp) { + assert(!Object.getOwnPropertyDescriptor(obj, name).writable, + "Expected obj[" + String(name) + "] to have writable:false."); + } + if (isWritable(obj, name, verifyProp)) { + throw new Test262Error("Expected obj[" + String(name) + "] NOT to be writable, but was."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyEnumerable(obj, name) { + assert(Object.getOwnPropertyDescriptor(obj, name).enumerable, + "Expected obj[" + String(name) + "] to have enumerable:true."); + if (!isEnumerable(obj, name)) { + throw new Test262Error("Expected obj[" + String(name) + "] to be enumerable, but was not."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyNotEnumerable(obj, name) { + assert(!Object.getOwnPropertyDescriptor(obj, name).enumerable, + "Expected obj[" + String(name) + "] to have enumerable:false."); + if (isEnumerable(obj, name)) { + throw new Test262Error("Expected obj[" + String(name) + "] NOT to be enumerable, but was."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyConfigurable(obj, name) { + assert(Object.getOwnPropertyDescriptor(obj, name).configurable, + "Expected obj[" + String(name) + "] to have configurable:true."); + if (!isConfigurable(obj, name)) { + throw new Test262Error("Expected obj[" + String(name) + "] to be configurable, but was not."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyNotConfigurable(obj, name) { + assert(!Object.getOwnPropertyDescriptor(obj, name).configurable, + "Expected obj[" + String(name) + "] to have configurable:false."); + if (isConfigurable(obj, name)) { + throw new Test262Error("Expected obj[" + String(name) + "] NOT to be configurable, but was."); + } +} diff --git a/harness/proxyTrapsHelper.js b/harness/proxyTrapsHelper.js new file mode 100644 index 00000000000..17daab5abc1 --- /dev/null +++ b/harness/proxyTrapsHelper.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Used to assert the correctness of object behavior in the presence + and context of Proxy objects. +defines: [allowProxyTraps] +---*/ + +function allowProxyTraps(overrides) { + function throwTest262Error(msg) { + return function () { throw new Test262Error(msg); }; + } + if (!overrides) { overrides = {}; } + return { + getPrototypeOf: overrides.getPrototypeOf || throwTest262Error('[[GetPrototypeOf]] trap called'), + setPrototypeOf: overrides.setPrototypeOf || throwTest262Error('[[SetPrototypeOf]] trap called'), + isExtensible: overrides.isExtensible || throwTest262Error('[[IsExtensible]] trap called'), + preventExtensions: overrides.preventExtensions || throwTest262Error('[[PreventExtensions]] trap called'), + getOwnPropertyDescriptor: overrides.getOwnPropertyDescriptor || throwTest262Error('[[GetOwnProperty]] trap called'), + has: overrides.has || throwTest262Error('[[HasProperty]] trap called'), + get: overrides.get || throwTest262Error('[[Get]] trap called'), + set: overrides.set || throwTest262Error('[[Set]] trap called'), + deleteProperty: overrides.deleteProperty || throwTest262Error('[[Delete]] trap called'), + defineProperty: overrides.defineProperty || throwTest262Error('[[DefineOwnProperty]] trap called'), + enumerate: throwTest262Error('[[Enumerate]] trap called: this trap has been removed'), + ownKeys: overrides.ownKeys || throwTest262Error('[[OwnPropertyKeys]] trap called'), + apply: overrides.apply || throwTest262Error('[[Call]] trap called'), + construct: overrides.construct || throwTest262Error('[[Construct]] trap called') + }; +} diff --git a/harness/regExpUtils.js b/harness/regExpUtils.js new file mode 100644 index 00000000000..4be437e20a7 --- /dev/null +++ b/harness/regExpUtils.js @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to assert the correctness of RegExp objects. +defines: [buildString, testPropertyEscapes, testPropertyOfStrings, testExtendedCharacterClass, matchValidator] +---*/ + +function buildString(args) { + // Use member expressions rather than destructuring `args` for improved + // compatibility with engines that only implement assignment patterns + // partially or not at all. + const loneCodePoints = args.loneCodePoints; + const ranges = args.ranges; + const CHUNK_SIZE = 10000; + let result = Reflect.apply(String.fromCodePoint, null, loneCodePoints); + for (let i = 0; i < ranges.length; i++) { + const range = ranges[i]; + const start = range[0]; + const end = range[1]; + const codePoints = []; + for (let length = 0, codePoint = start; codePoint <= end; codePoint++) { + codePoints[length++] = codePoint; + if (length === CHUNK_SIZE) { + result += Reflect.apply(String.fromCodePoint, null, codePoints); + codePoints.length = length = 0; + } + } + result += Reflect.apply(String.fromCodePoint, null, codePoints); + } + return result; +} + +function printCodePoint(codePoint) { + const hex = codePoint + .toString(16) + .toUpperCase() + .padStart(6, "0"); + return `U+${hex}`; +} + +function printStringCodePoints(string) { + const buf = []; + for (const symbol of string) { + const formatted = printCodePoint(symbol.codePointAt(0)); + buf.push(formatted); + } + return buf.join(' '); +} + +function testPropertyEscapes(regExp, string, expression) { + if (!regExp.test(string)) { + for (const symbol of string) { + const formatted = printCodePoint(symbol.codePointAt(0)); + assert( + regExp.test(symbol), + `\`${ expression }\` should match ${ formatted } (\`${ symbol }\`)` + ); + } + } +} + +function testPropertyOfStrings(args) { + // Use member expressions rather than destructuring `args` for improved + // compatibility with engines that only implement assignment patterns + // partially or not at all. + const regExp = args.regExp; + const expression = args.expression; + const matchStrings = args.matchStrings; + const nonMatchStrings = args.nonMatchStrings; + const allStrings = matchStrings.join(''); + if (!regExp.test(allStrings)) { + for (const string of matchStrings) { + assert( + regExp.test(string), + `\`${ expression }\` should match ${ string } (${ printStringCodePoints(string) })` + ); + } + } + + const allNonMatchStrings = nonMatchStrings.join(''); + if (regExp.test(allNonMatchStrings)) { + for (const string of nonMatchStrings) { + assert( + !regExp.test(string), + `\`${ expression }\` should not match ${ string } (${ printStringCodePoints(string) })` + ); + } + } +} + +// The exact same logic can be used to test extended character classes +// as enabled through the RegExp `v` flag. This is useful to test not +// just standalone properties of strings, but also string literals, and +// set operations. +const testExtendedCharacterClass = testPropertyOfStrings; + +// Returns a function that validates a RegExp match result. +// +// Example: +// +// var validate = matchValidator(['b'], 1, 'abc'); +// validate(/b/.exec('abc')); +// +function matchValidator(expectedEntries, expectedIndex, expectedInput) { + return function(match) { + assert.compareArray(match, expectedEntries, 'Match entries'); + assert.sameValue(match.index, expectedIndex, 'Match index'); + assert.sameValue(match.input, expectedInput, 'Match input'); + } +} diff --git a/harness/sta.js b/harness/sta.js new file mode 100644 index 00000000000..5634cb9b003 --- /dev/null +++ b/harness/sta.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Provides both: + + - An error class to avoid false positives when testing for thrown exceptions + - A function to explicitly throw an exception using the Test262Error class +defines: [Test262Error, $DONOTEVALUATE] +---*/ + + +function Test262Error(message) { + this.message = message || ""; +} + +Test262Error.prototype.toString = function () { + return "Test262Error: " + this.message; +}; + +Test262Error.thrower = function (message) { + throw new Test262Error(message); +}; + +function $DONOTEVALUATE() { + throw "Test262: This statement should not be evaluated."; +} diff --git a/harness/tcoHelper.js b/harness/tcoHelper.js new file mode 100644 index 00000000000..fafbed857f4 --- /dev/null +++ b/harness/tcoHelper.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + This defines the number of consecutive recursive function calls that must be + made in order to prove that stack frames are properly destroyed according to + ES2015 tail call optimization semantics. +defines: [$MAX_ITERATIONS] +---*/ + + + + +var $MAX_ITERATIONS = 100000; diff --git a/harness/temporalHelpers.js b/harness/temporalHelpers.js new file mode 100644 index 00000000000..c8aee0516f4 --- /dev/null +++ b/harness/temporalHelpers.js @@ -0,0 +1,2086 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + This defines helper objects and functions for testing Temporal. +defines: [TemporalHelpers] +features: [Symbol.species, Symbol.iterator, Temporal] +---*/ + +const ASCII_IDENTIFIER = /^[$_a-zA-Z][$_a-zA-Z0-9]*$/u; + +function formatPropertyName(propertyKey, objectName = "") { + switch (typeof propertyKey) { + case "symbol": + if (Symbol.keyFor(propertyKey) !== undefined) { + return `${objectName}[Symbol.for('${Symbol.keyFor(propertyKey)}')]`; + } else if (propertyKey.description.startsWith('Symbol.')) { + return `${objectName}[${propertyKey.description}]`; + } else { + return `${objectName}[Symbol('${propertyKey.description}')]` + } + case "string": + if (propertyKey !== String(Number(propertyKey))) { + if (ASCII_IDENTIFIER.test(propertyKey)) { + return objectName ? `${objectName}.${propertyKey}` : propertyKey; + } + return `${objectName}['${propertyKey.replace(/'/g, "\\'")}']` + } + // fall through + default: + // integer or string integer-index + return `${objectName}[${propertyKey}]`; + } +} + +const SKIP_SYMBOL = Symbol("Skip"); + +var TemporalHelpers = { + /* + * assertDuration(duration, years, ..., nanoseconds[, description]): + * + * Shorthand for asserting that each field of a Temporal.Duration is equal to + * an expected value. + */ + assertDuration(duration, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, description = "") { + assert(duration instanceof Temporal.Duration, `${description} instanceof`); + assert.sameValue(duration.years, years, `${description} years result`); + assert.sameValue(duration.months, months, `${description} months result`); + assert.sameValue(duration.weeks, weeks, `${description} weeks result`); + assert.sameValue(duration.days, days, `${description} days result`); + assert.sameValue(duration.hours, hours, `${description} hours result`); + assert.sameValue(duration.minutes, minutes, `${description} minutes result`); + assert.sameValue(duration.seconds, seconds, `${description} seconds result`); + assert.sameValue(duration.milliseconds, milliseconds, `${description} milliseconds result`); + assert.sameValue(duration.microseconds, microseconds, `${description} microseconds result`); + assert.sameValue(duration.nanoseconds, nanoseconds, `${description} nanoseconds result`); + }, + + /* + * assertDurationsEqual(actual, expected[, description]): + * + * Shorthand for asserting that each field of a Temporal.Duration is equal to + * the corresponding field in another Temporal.Duration. + */ + assertDurationsEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.Duration, `${description} expected value should be a Temporal.Duration`); + TemporalHelpers.assertDuration(actual, expected.years, expected.months, expected.weeks, expected.days, expected.hours, expected.minutes, expected.seconds, expected.milliseconds, expected.microseconds, expected.nanoseconds, description); + }, + + /* + * assertInstantsEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.Instants are of the correct type + * and equal according to their equals() methods. + */ + assertInstantsEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.Instant, `${description} expected value should be a Temporal.Instant`); + assert(actual instanceof Temporal.Instant, `${description} instanceof`); + assert(actual.equals(expected), `${description} equals method`); + }, + + /* + * assertPlainDate(date, year, ..., nanosecond[, description[, era, eraYear]]): + * + * Shorthand for asserting that each field of a Temporal.PlainDate is equal to + * an expected value. (Except the `calendar` property, since callers may want + * to assert either object equality with an object they put in there, or the + * value of date.calendarId.) + */ + assertPlainDate(date, year, month, monthCode, day, description = "", era = undefined, eraYear = undefined) { + assert(date instanceof Temporal.PlainDate, `${description} instanceof`); + assert.sameValue(date.era, era, `${description} era result`); + assert.sameValue(date.eraYear, eraYear, `${description} eraYear result`); + assert.sameValue(date.year, year, `${description} year result`); + assert.sameValue(date.month, month, `${description} month result`); + assert.sameValue(date.monthCode, monthCode, `${description} monthCode result`); + assert.sameValue(date.day, day, `${description} day result`); + }, + + /* + * assertPlainDateTime(datetime, year, ..., nanosecond[, description[, era, eraYear]]): + * + * Shorthand for asserting that each field of a Temporal.PlainDateTime is + * equal to an expected value. (Except the `calendar` property, since callers + * may want to assert either object equality with an object they put in there, + * or the value of datetime.calendarId.) + */ + assertPlainDateTime(datetime, year, month, monthCode, day, hour, minute, second, millisecond, microsecond, nanosecond, description = "", era = undefined, eraYear = undefined) { + assert(datetime instanceof Temporal.PlainDateTime, `${description} instanceof`); + assert.sameValue(datetime.era, era, `${description} era result`); + assert.sameValue(datetime.eraYear, eraYear, `${description} eraYear result`); + assert.sameValue(datetime.year, year, `${description} year result`); + assert.sameValue(datetime.month, month, `${description} month result`); + assert.sameValue(datetime.monthCode, monthCode, `${description} monthCode result`); + assert.sameValue(datetime.day, day, `${description} day result`); + assert.sameValue(datetime.hour, hour, `${description} hour result`); + assert.sameValue(datetime.minute, minute, `${description} minute result`); + assert.sameValue(datetime.second, second, `${description} second result`); + assert.sameValue(datetime.millisecond, millisecond, `${description} millisecond result`); + assert.sameValue(datetime.microsecond, microsecond, `${description} microsecond result`); + assert.sameValue(datetime.nanosecond, nanosecond, `${description} nanosecond result`); + }, + + /* + * assertPlainDateTimesEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.PlainDateTimes are of the correct + * type, equal according to their equals() methods, and additionally that + * their calendar internal slots are the same value. + */ + assertPlainDateTimesEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.PlainDateTime, `${description} expected value should be a Temporal.PlainDateTime`); + assert(actual instanceof Temporal.PlainDateTime, `${description} instanceof`); + assert(actual.equals(expected), `${description} equals method`); + assert.sameValue( + actual.getISOFields().calendar, + expected.getISOFields().calendar, + `${description} calendar same value` + ); + }, + + /* + * assertPlainMonthDay(monthDay, monthCode, day[, description [, referenceISOYear]]): + * + * Shorthand for asserting that each field of a Temporal.PlainMonthDay is + * equal to an expected value. (Except the `calendar` property, since callers + * may want to assert either object equality with an object they put in there, + * or the value of monthDay.calendarId().) + */ + assertPlainMonthDay(monthDay, monthCode, day, description = "", referenceISOYear = 1972) { + assert(monthDay instanceof Temporal.PlainMonthDay, `${description} instanceof`); + assert.sameValue(monthDay.monthCode, monthCode, `${description} monthCode result`); + assert.sameValue(monthDay.day, day, `${description} day result`); + assert.sameValue(monthDay.getISOFields().isoYear, referenceISOYear, `${description} referenceISOYear result`); + }, + + /* + * assertPlainTime(time, hour, ..., nanosecond[, description]): + * + * Shorthand for asserting that each field of a Temporal.PlainTime is equal to + * an expected value. + */ + assertPlainTime(time, hour, minute, second, millisecond, microsecond, nanosecond, description = "") { + assert(time instanceof Temporal.PlainTime, `${description} instanceof`); + assert.sameValue(time.hour, hour, `${description} hour result`); + assert.sameValue(time.minute, minute, `${description} minute result`); + assert.sameValue(time.second, second, `${description} second result`); + assert.sameValue(time.millisecond, millisecond, `${description} millisecond result`); + assert.sameValue(time.microsecond, microsecond, `${description} microsecond result`); + assert.sameValue(time.nanosecond, nanosecond, `${description} nanosecond result`); + }, + + /* + * assertPlainTimesEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.PlainTimes are of the correct + * type and equal according to their equals() methods. + */ + assertPlainTimesEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.PlainTime, `${description} expected value should be a Temporal.PlainTime`); + assert(actual instanceof Temporal.PlainTime, `${description} instanceof`); + assert(actual.equals(expected), `${description} equals method`); + }, + + /* + * assertPlainYearMonth(yearMonth, year, month, monthCode[, description[, era, eraYear, referenceISODay]]): + * + * Shorthand for asserting that each field of a Temporal.PlainYearMonth is + * equal to an expected value. (Except the `calendar` property, since callers + * may want to assert either object equality with an object they put in there, + * or the value of yearMonth.calendarId.) + */ + assertPlainYearMonth(yearMonth, year, month, monthCode, description = "", era = undefined, eraYear = undefined, referenceISODay = 1) { + assert(yearMonth instanceof Temporal.PlainYearMonth, `${description} instanceof`); + assert.sameValue(yearMonth.era, era, `${description} era result`); + assert.sameValue(yearMonth.eraYear, eraYear, `${description} eraYear result`); + assert.sameValue(yearMonth.year, year, `${description} year result`); + assert.sameValue(yearMonth.month, month, `${description} month result`); + assert.sameValue(yearMonth.monthCode, monthCode, `${description} monthCode result`); + assert.sameValue(yearMonth.getISOFields().isoDay, referenceISODay, `${description} referenceISODay result`); + }, + + /* + * assertZonedDateTimesEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.ZonedDateTimes are of the correct + * type, equal according to their equals() methods, and additionally that + * their time zones and calendar internal slots are the same value. + */ + assertZonedDateTimesEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.ZonedDateTime, `${description} expected value should be a Temporal.ZonedDateTime`); + assert(actual instanceof Temporal.ZonedDateTime, `${description} instanceof`); + assert(actual.equals(expected), `${description} equals method`); + assert.sameValue(actual.timeZone, expected.timeZone, `${description} time zone same value`); + assert.sameValue( + actual.getISOFields().calendar, + expected.getISOFields().calendar, + `${description} calendar same value` + ); + }, + + /* + * assertUnreachable(description): + * + * Helper for asserting that code is not executed. This is useful for + * assertions that methods of user calendars and time zones are not called. + */ + assertUnreachable(description) { + let message = "This code should not be executed"; + if (description) { + message = `${message}: ${description}`; + } + throw new Test262Error(message); + }, + + /* + * checkCalendarDateUntilLargestUnitSingular(func, expectedLargestUnitCalls): + * + * When an options object with a largestUnit property is synthesized inside + * Temporal and passed to user code such as calendar.dateUntil(), the value of + * the largestUnit property should be in the singular form, even if the input + * was given in the plural form. + * (This doesn't apply when the options object is passed through verbatim.) + * + * func(calendar, largestUnit, index) is the operation under test. It's called + * with an instance of a calendar that keeps track of which largestUnit is + * passed to dateUntil(), each key of expectedLargestUnitCalls in turn, and + * the key's numerical index in case the function needs to generate test data + * based on the index. At the end, the actual values passed to dateUntil() are + * compared with the array values of expectedLargestUnitCalls. + */ + checkCalendarDateUntilLargestUnitSingular(func, expectedLargestUnitCalls) { + const actual = []; + + class DateUntilOptionsCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateUntil(earlier, later, options) { + actual.push(options.largestUnit); + return super.dateUntil(earlier, later, options); + } + + toString() { + return "date-until-options"; + } + } + + const calendar = new DateUntilOptionsCalendar(); + Object.entries(expectedLargestUnitCalls).forEach(([largestUnit, expected], index) => { + func(calendar, largestUnit, index); + assert.compareArray(actual, expected, `largestUnit passed to calendar.dateUntil() for largestUnit ${largestUnit}`); + actual.splice(0); // empty it for the next check + }); + }, + + /* + * checkPlainDateTimeConversionFastPath(func): + * + * ToTemporalDate and ToTemporalTime should both, if given a + * Temporal.PlainDateTime instance, convert to the desired type by reading the + * PlainDateTime's internal slots, rather than calling any getters. + * + * func(datetime, calendar) is the actual operation to test, that must + * internally call the abstract operation ToTemporalDate or ToTemporalTime. + * It is passed a Temporal.PlainDateTime instance, as well as the instance's + * calendar object (so that it doesn't have to call the calendar getter itself + * if it wants to make any assertions about the calendar.) + */ + checkPlainDateTimeConversionFastPath(func, message = "checkPlainDateTimeConversionFastPath") { + const actual = []; + const expected = []; + + const calendar = new Temporal.Calendar("iso8601"); + const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); + const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.PlainDateTime.prototype); + ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond"].forEach((property) => { + Object.defineProperty(datetime, property, { + get() { + actual.push(`get ${formatPropertyName(property)}`); + const value = prototypeDescrs[property].get.call(this); + return { + toString() { + actual.push(`toString ${formatPropertyName(property)}`); + return value.toString(); + }, + valueOf() { + actual.push(`valueOf ${formatPropertyName(property)}`); + return value; + }, + }; + }, + }); + }); + Object.defineProperty(datetime, "calendar", { + get() { + actual.push("get calendar"); + return calendar; + }, + }); + + func(datetime, calendar); + assert.compareArray(actual, expected, `${message}: property getters not called`); + }, + + /* + * Check that an options bag that accepts units written in the singular form, + * also accepts the same units written in the plural form. + * func(unit) should call the method with the appropriate options bag + * containing unit as a value. This will be called twice for each element of + * validSingularUnits, once with singular and once with plural, and the + * results of each pair should be the same (whether a Temporal object or a + * primitive value.) + */ + checkPluralUnitsAccepted(func, validSingularUnits) { + const plurals = { + year: 'years', + month: 'months', + week: 'weeks', + day: 'days', + hour: 'hours', + minute: 'minutes', + second: 'seconds', + millisecond: 'milliseconds', + microsecond: 'microseconds', + nanosecond: 'nanoseconds', + }; + + validSingularUnits.forEach((unit) => { + const singularValue = func(unit); + const pluralValue = func(plurals[unit]); + const desc = `Plural ${plurals[unit]} produces the same result as singular ${unit}`; + if (singularValue instanceof Temporal.Duration) { + TemporalHelpers.assertDurationsEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.Instant) { + TemporalHelpers.assertInstantsEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.PlainDateTime) { + TemporalHelpers.assertPlainDateTimesEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.PlainTime) { + TemporalHelpers.assertPlainTimesEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.ZonedDateTime) { + TemporalHelpers.assertZonedDateTimesEqual(pluralValue, singularValue, desc); + } else { + assert.sameValue(pluralValue, singularValue); + } + }); + }, + + /* + * checkRoundingIncrementOptionWrongType(checkFunc, assertTrueResultFunc, assertObjectResultFunc): + * + * Checks the type handling of the roundingIncrement option. + * checkFunc(roundingIncrement) is a function which takes the value of + * roundingIncrement to test, and calls the method under test with it, + * returning the result. assertTrueResultFunc(result, description) should + * assert that result is the expected result with roundingIncrement: true, and + * assertObjectResultFunc(result, description) should assert that result is + * the expected result with roundingIncrement being an object with a valueOf() + * method. + */ + checkRoundingIncrementOptionWrongType(checkFunc, assertTrueResultFunc, assertObjectResultFunc) { + // null converts to 0, which is out of range + assert.throws(RangeError, () => checkFunc(null), "null"); + // Booleans convert to either 0 or 1, and 1 is allowed + const trueResult = checkFunc(true); + assertTrueResultFunc(trueResult, "true"); + assert.throws(RangeError, () => checkFunc(false), "false"); + // Symbols and BigInts cannot convert to numbers + assert.throws(TypeError, () => checkFunc(Symbol()), "symbol"); + assert.throws(TypeError, () => checkFunc(2n), "bigint"); + + // Objects prefer their valueOf() methods when converting to a number + assert.throws(RangeError, () => checkFunc({}), "plain object"); + + const expected = [ + "get roundingIncrement.valueOf", + "call roundingIncrement.valueOf", + ]; + const actual = []; + const observer = TemporalHelpers.toPrimitiveObserver(actual, 2, "roundingIncrement"); + const objectResult = checkFunc(observer); + assertObjectResultFunc(objectResult, "object with valueOf"); + assert.compareArray(actual, expected, "order of operations"); + }, + + /* + * checkStringOptionWrongType(propertyName, value, checkFunc, assertFunc): + * + * Checks the type handling of a string option, of which there are several in + * Temporal. + * propertyName is the name of the option, and value is the value that + * assertFunc should expect it to have. + * checkFunc(value) is a function which takes the value of the option to test, + * and calls the method under test with it, returning the result. + * assertFunc(result, description) should assert that result is the expected + * result with the option value being an object with a toString() method + * which returns the given value. + */ + checkStringOptionWrongType(propertyName, value, checkFunc, assertFunc) { + // null converts to the string "null", which is an invalid string value + assert.throws(RangeError, () => checkFunc(null), "null"); + // Booleans convert to the strings "true" or "false", which are invalid + assert.throws(RangeError, () => checkFunc(true), "true"); + assert.throws(RangeError, () => checkFunc(false), "false"); + // Symbols cannot convert to strings + assert.throws(TypeError, () => checkFunc(Symbol()), "symbol"); + // Numbers convert to strings which are invalid + assert.throws(RangeError, () => checkFunc(2), "number"); + // BigInts convert to strings which are invalid + assert.throws(RangeError, () => checkFunc(2n), "bigint"); + + // Objects prefer their toString() methods when converting to a string + assert.throws(RangeError, () => checkFunc({}), "plain object"); + + const expected = [ + `get ${propertyName}.toString`, + `call ${propertyName}.toString`, + ]; + const actual = []; + const observer = TemporalHelpers.toPrimitiveObserver(actual, value, propertyName); + const result = checkFunc(observer); + assertFunc(result, "object with toString"); + assert.compareArray(actual, expected, "order of operations"); + }, + + /* + * checkSubclassingIgnored(construct, constructArgs, method, methodArgs, + * resultAssertions): + * + * Methods of Temporal classes that return a new instance of the same class, + * must not take the constructor of a subclass into account, nor the @@species + * property. This helper runs tests to ensure this. + * + * construct(...constructArgs) must yield a valid instance of the Temporal + * class. instance[method](...methodArgs) is the method call under test, which + * must also yield a valid instance of the same Temporal class, not a + * subclass. See below for the individual tests that this runs. + * resultAssertions() is a function that performs additional assertions on the + * instance returned by the method under test. + */ + checkSubclassingIgnored(...args) { + this.checkSubclassConstructorNotObject(...args); + this.checkSubclassConstructorUndefined(...args); + this.checkSubclassConstructorThrows(...args); + this.checkSubclassConstructorNotCalled(...args); + this.checkSubclassSpeciesInvalidResult(...args); + this.checkSubclassSpeciesNotAConstructor(...args); + this.checkSubclassSpeciesNull(...args); + this.checkSubclassSpeciesUndefined(...args); + this.checkSubclassSpeciesThrows(...args); + }, + + /* + * Checks that replacing the 'constructor' property of the instance with + * various primitive values does not affect the returned new instance. + */ + checkSubclassConstructorNotObject(construct, constructArgs, method, methodArgs, resultAssertions) { + function check(value, description) { + const instance = new construct(...constructArgs); + instance.constructor = value; + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype, description); + resultAssertions(result); + } + + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "Symbol"); + check(7, "number"); + check(7n, "bigint"); + }, + + /* + * Checks that replacing the 'constructor' property of the subclass with + * undefined does not affect the returned new instance. + */ + checkSubclassConstructorUndefined(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + MySubclass.prototype.constructor = undefined; + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Checks that making the 'constructor' property of the instance throw when + * called does not affect the returned new instance. + */ + checkSubclassConstructorThrows(construct, constructArgs, method, methodArgs, resultAssertions) { + function CustomError() {} + const instance = new construct(...constructArgs); + Object.defineProperty(instance, "constructor", { + get() { + throw new CustomError(); + } + }); + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Checks that when subclassing, the subclass constructor is not called by + * the method under test. + */ + checkSubclassConstructorNotCalled(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that the constructor's @@species property is ignored when it's a + * constructor that returns a non-object value. + */ + checkSubclassSpeciesInvalidResult(construct, constructArgs, method, methodArgs, resultAssertions) { + function check(value, description) { + const instance = new construct(...constructArgs); + instance.constructor = { + [Symbol.species]: function() { + return value; + }, + }; + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype, description); + resultAssertions(result); + } + + check(undefined, "undefined"); + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "Symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "plain object"); + }, + + /* + * Check that the constructor's @@species property is ignored when it's not a + * constructor. + */ + checkSubclassSpeciesNotAConstructor(construct, constructArgs, method, methodArgs, resultAssertions) { + function check(value, description) { + const instance = new construct(...constructArgs); + instance.constructor = { + [Symbol.species]: value, + }; + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype, description); + resultAssertions(result); + } + + check(true, "true"); + check("test", "string"); + check(Symbol(), "Symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "plain object"); + }, + + /* + * Check that the constructor's @@species property is ignored when it's null. + */ + checkSubclassSpeciesNull(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + MySubclass.prototype.constructor = { + [Symbol.species]: null, + }; + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that the constructor's @@species property is ignored when it's + * undefined. + */ + checkSubclassSpeciesUndefined(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + MySubclass.prototype.constructor = { + [Symbol.species]: undefined, + }; + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that the constructor's @@species property is ignored when it throws, + * i.e. it is not called at all. + */ + checkSubclassSpeciesThrows(construct, constructArgs, method, methodArgs, resultAssertions) { + function CustomError() {} + + const instance = new construct(...constructArgs); + instance.constructor = { + get [Symbol.species]() { + throw new CustomError(); + }, + }; + + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + }, + + /* + * checkSubclassingIgnoredStatic(construct, method, methodArgs, resultAssertions): + * + * Static methods of Temporal classes that return a new instance of the class, + * must not use the this-value as a constructor. This helper runs tests to + * ensure this. + * + * construct[method](...methodArgs) is the static method call under test, and + * must yield a valid instance of the Temporal class, not a subclass. See + * below for the individual tests that this runs. + * resultAssertions() is a function that performs additional assertions on the + * instance returned by the method under test. + */ + checkSubclassingIgnoredStatic(...args) { + this.checkStaticInvalidReceiver(...args); + this.checkStaticReceiverNotCalled(...args); + this.checkThisValueNotCalled(...args); + }, + + /* + * Check that calling the static method with a receiver that's not callable, + * still calls the intrinsic constructor. + */ + checkStaticInvalidReceiver(construct, method, methodArgs, resultAssertions) { + function check(value, description) { + const result = construct[method].apply(value, methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + } + + check(undefined, "undefined"); + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "Non-callable object"); + }, + + /* + * Check that calling the static method with a receiver that returns a value + * that's not callable, still calls the intrinsic constructor. + */ + checkStaticReceiverNotCalled(construct, method, methodArgs, resultAssertions) { + function check(value, description) { + const receiver = function () { + return value; + }; + const result = construct[method].apply(receiver, methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + } + + check(undefined, "undefined"); + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "Non-callable object"); + }, + + /* + * Check that the receiver isn't called. + */ + checkThisValueNotCalled(construct, method, methodArgs, resultAssertions) { + let called = false; + + class MySubclass extends construct { + constructor(...args) { + called = true; + super(...args); + } + } + + const result = MySubclass[method](...methodArgs); + assert.sameValue(called, false); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that any iterable returned from a custom time zone's + * getPossibleInstantsFor() method is exhausted. + * The custom time zone object is passed in to func(). + * expected is an array of strings representing the expected calls to the + * getPossibleInstantsFor() method. The PlainDateTimes that it is called with, + * are compared (using their toString() results) with the array. + */ + checkTimeZonePossibleInstantsIterable(func, expected) { + // A custom time zone that returns an iterable instead of an array from its + // getPossibleInstantsFor() method, and for testing purposes skips + // 00:00-01:00 UTC on January 1, 2030, and repeats 00:00-01:00 UTC+1 on + // January 3, 2030. Otherwise identical to the UTC time zone. + class TimeZonePossibleInstantsIterable extends Temporal.TimeZone { + constructor() { + super("UTC"); + this.getPossibleInstantsForCallCount = 0; + this.getPossibleInstantsForCalledWith = []; + this.getPossibleInstantsForReturns = []; + this.iteratorExhausted = []; + } + + toString() { + return "Custom/Iterable"; + } + + getOffsetNanosecondsFor(instant) { + if (Temporal.Instant.compare(instant, "2030-01-01T00:00Z") >= 0 && + Temporal.Instant.compare(instant, "2030-01-03T01:00Z") < 0) { + return 3600_000_000_000; + } else { + return 0; + } + } + + getPossibleInstantsFor(dateTime) { + this.getPossibleInstantsForCallCount++; + this.getPossibleInstantsForCalledWith.push(dateTime); + + // Fake DST transition + let retval = super.getPossibleInstantsFor(dateTime); + if (dateTime.toPlainDate().equals("2030-01-01") && dateTime.hour === 0) { + retval = []; + } else if (dateTime.toPlainDate().equals("2030-01-03") && dateTime.hour === 0) { + retval.push(retval[0].subtract({ hours: 1 })); + } else if (dateTime.year === 2030 && dateTime.month === 1 && dateTime.day >= 1 && dateTime.day <= 2) { + retval[0] = retval[0].subtract({ hours: 1 }); + } + + this.getPossibleInstantsForReturns.push(retval); + this.iteratorExhausted.push(false); + return { + callIndex: this.getPossibleInstantsForCallCount - 1, + timeZone: this, + *[Symbol.iterator]() { + yield* this.timeZone.getPossibleInstantsForReturns[this.callIndex]; + this.timeZone.iteratorExhausted[this.callIndex] = true; + }, + }; + } + } + + const timeZone = new TimeZonePossibleInstantsIterable(); + func(timeZone); + + assert.sameValue(timeZone.getPossibleInstantsForCallCount, expected.length, "getPossibleInstantsFor() method called correct number of times"); + + for (let index = 0; index < expected.length; index++) { + assert.sameValue(timeZone.getPossibleInstantsForCalledWith[index].toString(), expected[index], "getPossibleInstantsFor() called with expected PlainDateTime"); + assert(timeZone.iteratorExhausted[index], "iterated through the whole iterable"); + } + }, + + /* + * Check that any calendar-carrying Temporal object has its [[Calendar]] + * internal slot read by ToTemporalCalendar, and does not fetch the calendar + * by calling getters. + * The custom calendar object is passed in to func() so that it can do its + * own additional assertions involving the calendar if necessary. (Sometimes + * there is nothing to assert as the calendar isn't stored anywhere that can + * be asserted about.) + */ + checkToTemporalCalendarFastPath(func) { + class CalendarFastPathCheck extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateFromFields(...args) { + return super.dateFromFields(...args).withCalendar(this); + } + + monthDayFromFields(...args) { + const { isoYear, isoMonth, isoDay } = super.monthDayFromFields(...args).getISOFields(); + return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); + } + + yearMonthFromFields(...args) { + const { isoYear, isoMonth, isoDay } = super.yearMonthFromFields(...args).getISOFields(); + return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); + } + + toString() { + return "fast-path-check"; + } + } + const calendar = new CalendarFastPathCheck(); + + const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar); + const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); + const plainMonthDay = new Temporal.PlainMonthDay(5, 2, calendar); + const plainYearMonth = new Temporal.PlainYearMonth(2000, 5, calendar); + const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); + + [plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((temporalObject) => { + const actual = []; + const expected = []; + + Object.defineProperty(temporalObject, "calendar", { + get() { + actual.push("get calendar"); + return calendar; + }, + }); + + func(temporalObject, calendar); + assert.compareArray(actual, expected, "calendar getter not called"); + }); + }, + + checkToTemporalInstantFastPath(func) { + const actual = []; + const expected = []; + + const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); + Object.defineProperty(datetime, 'toString', { + get() { + actual.push("get toString"); + return function (options) { + actual.push("call toString"); + return Temporal.ZonedDateTime.prototype.toString.call(this, options); + }; + }, + }); + + func(datetime); + assert.compareArray(actual, expected, "toString not called"); + }, + + checkToTemporalPlainDateTimeFastPath(func) { + const actual = []; + const expected = []; + + const calendar = new Temporal.Calendar("iso8601"); + const date = new Temporal.PlainDate(2000, 5, 2, calendar); + const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.PlainDate.prototype); + ["year", "month", "monthCode", "day"].forEach((property) => { + Object.defineProperty(date, property, { + get() { + actual.push(`get ${formatPropertyName(property)}`); + const value = prototypeDescrs[property].get.call(this); + return TemporalHelpers.toPrimitiveObserver(actual, value, property); + }, + }); + }); + ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"].forEach((property) => { + Object.defineProperty(date, property, { + get() { + actual.push(`get ${formatPropertyName(property)}`); + return undefined; + }, + }); + }); + Object.defineProperty(date, "calendar", { + get() { + actual.push("get calendar"); + return calendar; + }, + }); + + func(date, calendar); + assert.compareArray(actual, expected, "property getters not called"); + }, + + /* + * A custom calendar used in prototype pollution checks. Verifies that the + * fromFields methods are always called with a null-prototype fields object. + */ + calendarCheckFieldsPrototypePollution() { + class CalendarCheckFieldsPrototypePollution extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateFromFieldsCallCount = 0; + this.yearMonthFromFieldsCallCount = 0; + this.monthDayFromFieldsCallCount = 0; + } + + // toString must remain "iso8601", so that some methods don't throw due to + // incompatible calendars + + dateFromFields(fields, options = {}) { + this.dateFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "dateFromFields should be called with null-prototype fields object"); + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options = {}) { + this.yearMonthFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "yearMonthFromFields should be called with null-prototype fields object"); + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options = {}) { + this.monthDayFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "monthDayFromFields should be called with null-prototype fields object"); + return super.monthDayFromFields(fields, options); + } + } + + return new CalendarCheckFieldsPrototypePollution(); + }, + + /* + * A custom calendar used in prototype pollution checks. Verifies that the + * mergeFields() method is always called with null-prototype fields objects. + */ + calendarCheckMergeFieldsPrototypePollution() { + class CalendarCheckMergeFieldsPrototypePollution extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.mergeFieldsCallCount = 0; + } + + toString() { + return "merge-fields-null-proto"; + } + + mergeFields(fields, additionalFields) { + this.mergeFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "mergeFields should be called with null-prototype fields object (first argument)"); + assert.sameValue(Object.getPrototypeOf(additionalFields), null, "mergeFields should be called with null-prototype fields object (second argument)"); + return super.mergeFields(fields, additionalFields); + } + } + + return new CalendarCheckMergeFieldsPrototypePollution(); + }, + + /* + * A custom calendar used in prototype pollution checks. Verifies that methods + * are always called with a null-prototype options object. + */ + calendarCheckOptionsPrototypePollution() { + class CalendarCheckOptionsPrototypePollution extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.yearMonthFromFieldsCallCount = 0; + this.dateUntilCallCount = 0; + } + + toString() { + return "options-null-proto"; + } + + yearMonthFromFields(fields, options) { + this.yearMonthFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(options), null, "yearMonthFromFields should be called with null-prototype options"); + return super.yearMonthFromFields(fields, options); + } + + dateUntil(one, two, options) { + this.dateUntilCallCount++; + assert.sameValue(Object.getPrototypeOf(options), null, "dateUntil should be called with null-prototype options"); + return super.dateUntil(one, two, options); + } + } + + return new CalendarCheckOptionsPrototypePollution(); + }, + + /* + * A custom calendar that asserts its dateAdd() method is called with the + * options parameter having the value undefined. + */ + calendarDateAddUndefinedOptions() { + class CalendarDateAddUndefinedOptions extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateAddCallCount = 0; + } + + toString() { + return "dateadd-undef-options"; + } + + dateAdd(date, duration, options) { + this.dateAddCallCount++; + assert.sameValue(options, undefined, "dateAdd shouldn't be called with options"); + return super.dateAdd(date, duration, options); + } + } + return new CalendarDateAddUndefinedOptions(); + }, + + /* + * A custom calendar that asserts its dateAdd() method is called with a + * PlainDate instance. Optionally, it also asserts that the PlainDate instance + * is the specific object `this.specificPlainDate`, if it is set by the + * calling code. + */ + calendarDateAddPlainDateInstance() { + class CalendarDateAddPlainDateInstance extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateAddCallCount = 0; + this.specificPlainDate = undefined; + } + + toString() { + return "dateadd-plain-date-instance"; + } + + dateFromFields(...args) { + return super.dateFromFields(...args).withCalendar(this); + } + + dateAdd(date, duration, options) { + this.dateAddCallCount++; + assert(date instanceof Temporal.PlainDate, "dateAdd() should be called with a PlainDate instance"); + if (this.dateAddCallCount === 1 && this.specificPlainDate) { + assert.sameValue(date, this.specificPlainDate, `dateAdd() should be called first with the specific PlainDate instance ${this.specificPlainDate}`); + } + return super.dateAdd(date, duration, options).withCalendar(this); + } + } + return new CalendarDateAddPlainDateInstance(); + }, + + /* + * A custom calendar that returns @returnValue from its dateUntil() method, + * recording the call in @calls. + */ + calendarDateUntilObservable(calls, returnValue) { + class CalendarDateUntilObservable extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateUntil() { + calls.push("call dateUntil"); + return returnValue; + } + } + + return new CalendarDateUntilObservable(); + }, + + /* + * A custom calendar that returns an iterable instead of an array from its + * fields() method, otherwise identical to the ISO calendar. + */ + calendarFieldsIterable() { + class CalendarFieldsIterable extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.fieldsCallCount = 0; + this.fieldsCalledWith = []; + this.iteratorExhausted = []; + } + + toString() { + return "fields-iterable"; + } + + fields(fieldNames) { + this.fieldsCallCount++; + this.fieldsCalledWith.push(fieldNames.slice()); + this.iteratorExhausted.push(false); + return { + callIndex: this.fieldsCallCount - 1, + calendar: this, + *[Symbol.iterator]() { + yield* this.calendar.fieldsCalledWith[this.callIndex]; + this.calendar.iteratorExhausted[this.callIndex] = true; + }, + }; + } + } + return new CalendarFieldsIterable(); + }, + + /* + * A custom calendar that asserts its ...FromFields() methods are called with + * the options parameter having the value undefined. + */ + calendarFromFieldsUndefinedOptions() { + class CalendarFromFieldsUndefinedOptions extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateFromFieldsCallCount = 0; + this.monthDayFromFieldsCallCount = 0; + this.yearMonthFromFieldsCallCount = 0; + } + + toString() { + return "from-fields-undef-options"; + } + + dateFromFields(fields, options) { + this.dateFromFieldsCallCount++; + assert.sameValue(options, undefined, "dateFromFields shouldn't be called with options"); + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options) { + this.yearMonthFromFieldsCallCount++; + assert.sameValue(options, undefined, "yearMonthFromFields shouldn't be called with options"); + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options) { + this.monthDayFromFieldsCallCount++; + assert.sameValue(options, undefined, "monthDayFromFields shouldn't be called with options"); + return super.monthDayFromFields(fields, options); + } + } + return new CalendarFromFieldsUndefinedOptions(); + }, + + /* + * A custom calendar that modifies the fields object passed in to + * dateFromFields, sabotaging its time properties. + */ + calendarMakeInfinityTime() { + class CalendarMakeInfinityTime extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateFromFields(fields, options) { + const retval = super.dateFromFields(fields, options); + fields.hour = Infinity; + fields.minute = Infinity; + fields.second = Infinity; + fields.millisecond = Infinity; + fields.microsecond = Infinity; + fields.nanosecond = Infinity; + return retval; + } + } + return new CalendarMakeInfinityTime(); + }, + + /* + * A custom calendar that defines getters on the fields object passed into + * dateFromFields that throw, sabotaging its time properties. + */ + calendarMakeInvalidGettersTime() { + class CalendarMakeInvalidGettersTime extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateFromFields(fields, options) { + const retval = super.dateFromFields(fields, options); + const throwingDescriptor = { + get() { + throw new Test262Error("reading a sabotaged time field"); + }, + }; + Object.defineProperties(fields, { + hour: throwingDescriptor, + minute: throwingDescriptor, + second: throwingDescriptor, + millisecond: throwingDescriptor, + microsecond: throwingDescriptor, + nanosecond: throwingDescriptor, + }); + return retval; + } + } + return new CalendarMakeInvalidGettersTime(); + }, + + /* + * A custom calendar whose mergeFields() method returns a proxy object with + * all of its Get and HasProperty operations observable, as well as adding a + * "shouldNotBeCopied": true property. + */ + calendarMergeFieldsGetters() { + class CalendarMergeFieldsGetters extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.mergeFieldsReturnOperations = []; + } + + toString() { + return "merge-fields-getters"; + } + + dateFromFields(fields, options) { + assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options) { + assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options) { + assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); + return super.monthDayFromFields(fields, options); + } + + mergeFields(fields, additionalFields) { + const retval = super.mergeFields(fields, additionalFields); + retval._calendar = this; + retval.shouldNotBeCopied = true; + return new Proxy(retval, { + get(target, key) { + target._calendar.mergeFieldsReturnOperations.push(`get ${key}`); + const result = target[key]; + if (result === undefined) { + return undefined; + } + return TemporalHelpers.toPrimitiveObserver(target._calendar.mergeFieldsReturnOperations, result, key); + }, + has(target, key) { + target._calendar.mergeFieldsReturnOperations.push(`has ${key}`); + return key in target; + }, + }); + } + } + return new CalendarMergeFieldsGetters(); + }, + + /* + * A custom calendar whose mergeFields() method returns a primitive value, + * given by @primitive, and which records the number of calls made to its + * dateFromFields(), yearMonthFromFields(), and monthDayFromFields() methods. + */ + calendarMergeFieldsReturnsPrimitive(primitive) { + class CalendarMergeFieldsPrimitive extends Temporal.Calendar { + constructor(mergeFieldsReturnValue) { + super("iso8601"); + this._mergeFieldsReturnValue = mergeFieldsReturnValue; + this.dateFromFieldsCallCount = 0; + this.monthDayFromFieldsCallCount = 0; + this.yearMonthFromFieldsCallCount = 0; + } + + toString() { + return "merge-fields-primitive"; + } + + dateFromFields(fields, options) { + this.dateFromFieldsCallCount++; + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options) { + this.yearMonthFromFieldsCallCount++; + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options) { + this.monthDayFromFieldsCallCount++; + return super.monthDayFromFields(fields, options); + } + + mergeFields() { + return this._mergeFieldsReturnValue; + } + } + return new CalendarMergeFieldsPrimitive(primitive); + }, + + /* + * crossDateLineTimeZone(): + * + * This returns an instance of a custom time zone class that implements one + * single transition where the time zone moves from one side of the + * International Date Line to the other, for the purpose of testing time zone + * calculations without depending on system time zone data. + * + * The transition occurs at epoch second 1325239200 and goes from offset + * -10:00 to +14:00. In other words, the time zone skips the whole calendar + * day of 2011-12-30. This is the same as the real-life transition in the + * Pacific/Apia time zone. + */ + crossDateLineTimeZone() { + const { compare } = Temporal.PlainDateTime; + const skippedDay = new Temporal.PlainDate(2011, 12, 30); + const transitionEpoch = 1325239200_000_000_000n; + const beforeOffset = new Temporal.TimeZone("-10:00"); + const afterOffset = new Temporal.TimeZone("+14:00"); + + class CrossDateLineTimeZone extends Temporal.TimeZone { + constructor() { + super("+14:00"); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < transitionEpoch) { + return beforeOffset.getOffsetNanosecondsFor(instant); + } + return afterOffset.getOffsetNanosecondsFor(instant); + } + + getPossibleInstantsFor(datetime) { + const comparison = Temporal.PlainDate.compare(datetime.toPlainDate(), skippedDay); + if (comparison === 0) { + return []; + } + if (comparison < 0) { + return [beforeOffset.getInstantFor(datetime)]; + } + return [afterOffset.getInstantFor(datetime)]; + } + + getPreviousTransition(instant) { + if (instant.epochNanoseconds > transitionEpoch) return new Temporal.Instant(transitionEpoch); + return null; + } + + getNextTransition(instant) { + if (instant.epochNanoseconds < transitionEpoch) return new Temporal.Instant(transitionEpoch); + return null; + } + + toString() { + return "Custom/Date_Line"; + } + } + return new CrossDateLineTimeZone(); + }, + + /* + * observeProperty(calls, object, propertyName, value): + * + * Defines an own property @object.@propertyName with value @value, that + * will log any calls to its accessors to the array @calls. + */ + observeProperty(calls, object, propertyName, value, objectName = "") { + Object.defineProperty(object, propertyName, { + get() { + calls.push(`get ${formatPropertyName(propertyName, objectName)}`); + return value; + }, + set(v) { + calls.push(`set ${formatPropertyName(propertyName, objectName)}`); + } + }); + }, + + /* + * observeMethod(calls, object, propertyName, value): + * + * Defines an own property @object.@propertyName with value @value, that + * will log any calls of @value to the array @calls. + */ + observeMethod(calls, object, propertyName, objectName = "") { + const method = object[propertyName]; + object[propertyName] = function () { + calls.push(`call ${formatPropertyName(propertyName, objectName)}`); + return method.apply(object, arguments); + }; + }, + + /* + * Used for substituteMethod to indicate default behavior instead of a + * substituted value + */ + SUBSTITUTE_SKIP: SKIP_SYMBOL, + + /* + * substituteMethod(object, propertyName, values): + * + * Defines an own property @object.@propertyName that will, for each + * subsequent call to the method previously defined as + * @object.@propertyName: + * - Call the method, if no more values remain + * - Call the method, if the value in @values for the corresponding call + * is SUBSTITUTE_SKIP + * - Otherwise, return the corresponding value in @value + */ + substituteMethod(object, propertyName, values) { + let calls = 0; + const method = object[propertyName]; + object[propertyName] = function () { + if (calls >= values.length) { + return method.apply(object, arguments); + } else if (values[calls] === SKIP_SYMBOL) { + calls++; + return method.apply(object, arguments); + } else { + return values[calls++]; + } + }; + }, + + /* + * calendarObserver: + * A custom calendar that behaves exactly like the ISO 8601 calendar but + * tracks calls to any of its methods, and Get/Has operations on its + * properties, by appending messages to an array. This is for the purpose of + * testing order of operations that are observable from user code. + * objectName is used in the log. + */ + calendarObserver(calls, objectName, methodOverrides = {}) { + function removeExtraHasPropertyChecks(objectName, calls) { + // Inserting the tracking calendar into the return values of methods + // that we chain up into the ISO calendar for, causes extra HasProperty + // checks, which we observe. This removes them so that we don't leak + // implementation details of the helper into the test code. + assert.sameValue(calls.pop(), `has ${objectName}.yearOfWeek`); + assert.sameValue(calls.pop(), `has ${objectName}.yearMonthFromFields`); + assert.sameValue(calls.pop(), `has ${objectName}.year`); + assert.sameValue(calls.pop(), `has ${objectName}.weekOfYear`); + assert.sameValue(calls.pop(), `has ${objectName}.monthsInYear`); + assert.sameValue(calls.pop(), `has ${objectName}.monthDayFromFields`); + assert.sameValue(calls.pop(), `has ${objectName}.monthCode`); + assert.sameValue(calls.pop(), `has ${objectName}.month`); + assert.sameValue(calls.pop(), `has ${objectName}.mergeFields`); + assert.sameValue(calls.pop(), `has ${objectName}.inLeapYear`); + assert.sameValue(calls.pop(), `has ${objectName}.id`); + assert.sameValue(calls.pop(), `has ${objectName}.fields`); + assert.sameValue(calls.pop(), `has ${objectName}.daysInYear`); + assert.sameValue(calls.pop(), `has ${objectName}.daysInWeek`); + assert.sameValue(calls.pop(), `has ${objectName}.daysInMonth`); + assert.sameValue(calls.pop(), `has ${objectName}.dayOfYear`); + assert.sameValue(calls.pop(), `has ${objectName}.dayOfWeek`); + assert.sameValue(calls.pop(), `has ${objectName}.day`); + assert.sameValue(calls.pop(), `has ${objectName}.dateUntil`); + assert.sameValue(calls.pop(), `has ${objectName}.dateFromFields`); + assert.sameValue(calls.pop(), `has ${objectName}.dateAdd`); + } + + const iso8601 = new Temporal.Calendar("iso8601"); + const trackingMethods = { + dateFromFields(...args) { + calls.push(`call ${objectName}.dateFromFields`); + if ('dateFromFields' in methodOverrides) { + const value = methodOverrides.dateFromFields; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.dateFromFields(...args); + // Replace the calendar in the result with the call-tracking calendar + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + yearMonthFromFields(...args) { + calls.push(`call ${objectName}.yearMonthFromFields`); + if ('yearMonthFromFields' in methodOverrides) { + const value = methodOverrides.yearMonthFromFields; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.yearMonthFromFields(...args); + // Replace the calendar in the result with the call-tracking calendar + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + monthDayFromFields(...args) { + calls.push(`call ${objectName}.monthDayFromFields`); + if ('monthDayFromFields' in methodOverrides) { + const value = methodOverrides.monthDayFromFields; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.monthDayFromFields(...args); + // Replace the calendar in the result with the call-tracking calendar + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + dateAdd(...args) { + calls.push(`call ${objectName}.dateAdd`); + if ('dateAdd' in methodOverrides) { + const value = methodOverrides.dateAdd; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.dateAdd(...args); + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + id: "iso8601", + }; + // Automatically generate the other methods that don't need any custom code + [ + "dateUntil", + "day", + "dayOfWeek", + "dayOfYear", + "daysInMonth", + "daysInWeek", + "daysInYear", + "era", + "eraYear", + "fields", + "inLeapYear", + "mergeFields", + "month", + "monthCode", + "monthsInYear", + "toString", + "weekOfYear", + "year", + "yearOfWeek", + ].forEach((methodName) => { + trackingMethods[methodName] = function (...args) { + calls.push(`call ${formatPropertyName(methodName, objectName)}`); + if (methodName in methodOverrides) { + const value = methodOverrides[methodName]; + return typeof value === "function" ? value(...args) : value; + } + return iso8601[methodName](...args); + }; + }); + return new Proxy(trackingMethods, { + get(target, key, receiver) { + const result = Reflect.get(target, key, receiver); + calls.push(`get ${formatPropertyName(key, objectName)}`); + return result; + }, + has(target, key) { + calls.push(`has ${formatPropertyName(key, objectName)}`); + return Reflect.has(target, key); + }, + }); + }, + + /* + * A custom calendar that does not allow any of its methods to be called, for + * the purpose of asserting that a particular operation does not call into + * user code. + */ + calendarThrowEverything() { + class CalendarThrowEverything extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + toString() { + TemporalHelpers.assertUnreachable("toString should not be called"); + } + dateFromFields() { + TemporalHelpers.assertUnreachable("dateFromFields should not be called"); + } + yearMonthFromFields() { + TemporalHelpers.assertUnreachable("yearMonthFromFields should not be called"); + } + monthDayFromFields() { + TemporalHelpers.assertUnreachable("monthDayFromFields should not be called"); + } + dateAdd() { + TemporalHelpers.assertUnreachable("dateAdd should not be called"); + } + dateUntil() { + TemporalHelpers.assertUnreachable("dateUntil should not be called"); + } + era() { + TemporalHelpers.assertUnreachable("era should not be called"); + } + eraYear() { + TemporalHelpers.assertUnreachable("eraYear should not be called"); + } + year() { + TemporalHelpers.assertUnreachable("year should not be called"); + } + month() { + TemporalHelpers.assertUnreachable("month should not be called"); + } + monthCode() { + TemporalHelpers.assertUnreachable("monthCode should not be called"); + } + day() { + TemporalHelpers.assertUnreachable("day should not be called"); + } + fields() { + TemporalHelpers.assertUnreachable("fields should not be called"); + } + mergeFields() { + TemporalHelpers.assertUnreachable("mergeFields should not be called"); + } + } + + return new CalendarThrowEverything(); + }, + + /* + * oneShiftTimeZone(shiftInstant, shiftNanoseconds): + * + * In the case of a spring-forward time zone offset transition (skipped time), + * and disambiguation === 'earlier', BuiltinTimeZoneGetInstantFor subtracts a + * negative number of nanoseconds from a PlainDateTime, which should balance + * with the microseconds field. + * + * This returns an instance of a custom time zone class which skips a length + * of time equal to shiftNanoseconds (a number), at the Temporal.Instant + * shiftInstant. Before shiftInstant, it's identical to UTC, and after + * shiftInstant it's a constant-offset time zone. + * + * It provides a getPossibleInstantsForCalledWith member which is an array + * with the result of calling toString() on any PlainDateTimes passed to + * getPossibleInstantsFor(). + */ + oneShiftTimeZone(shiftInstant, shiftNanoseconds) { + class OneShiftTimeZone extends Temporal.TimeZone { + constructor(shiftInstant, shiftNanoseconds) { + super("+00:00"); + this._shiftInstant = shiftInstant; + this._epoch1 = shiftInstant.epochNanoseconds; + this._epoch2 = this._epoch1 + BigInt(shiftNanoseconds); + this._shiftNanoseconds = shiftNanoseconds; + this._shift = new Temporal.Duration(0, 0, 0, 0, 0, 0, 0, 0, 0, this._shiftNanoseconds); + this.getPossibleInstantsForCalledWith = []; + } + + _isBeforeShift(instant) { + return instant.epochNanoseconds < this._epoch1; + } + + getOffsetNanosecondsFor(instant) { + return this._isBeforeShift(instant) ? 0 : this._shiftNanoseconds; + } + + getPossibleInstantsFor(plainDateTime) { + this.getPossibleInstantsForCalledWith.push(plainDateTime.toString()); + const [instant] = super.getPossibleInstantsFor(plainDateTime); + if (this._shiftNanoseconds > 0) { + if (this._isBeforeShift(instant)) return [instant]; + if (instant.epochNanoseconds < this._epoch2) return []; + return [instant.subtract(this._shift)]; + } + if (instant.epochNanoseconds < this._epoch2) return [instant]; + const shifted = instant.subtract(this._shift); + if (this._isBeforeShift(instant)) return [instant, shifted]; + return [shifted]; + } + + getNextTransition(instant) { + return this._isBeforeShift(instant) ? this._shiftInstant : null; + } + + getPreviousTransition(instant) { + return this._isBeforeShift(instant) ? null : this._shiftInstant; + } + + toString() { + return "Custom/One_Shift"; + } + } + return new OneShiftTimeZone(shiftInstant, shiftNanoseconds); + }, + + /* + * propertyBagObserver(): + * Returns an object that behaves like the given propertyBag but tracks Get + * and Has operations on any of its properties, by appending messages to an + * array. If the value of a property in propertyBag is a primitive, the value + * of the returned object's property will additionally be a + * TemporalHelpers.toPrimitiveObserver that will track calls to its toString + * and valueOf methods in the same array. This is for the purpose of testing + * order of operations that are observable from user code. objectName is used + * in the log. + */ + propertyBagObserver(calls, propertyBag, objectName) { + return new Proxy(propertyBag, { + ownKeys(target) { + calls.push(`ownKeys ${objectName}`); + return Reflect.ownKeys(target); + }, + getOwnPropertyDescriptor(target, key) { + calls.push(`getOwnPropertyDescriptor ${formatPropertyName(key, objectName)}`); + return Reflect.getOwnPropertyDescriptor(target, key); + }, + get(target, key, receiver) { + calls.push(`get ${formatPropertyName(key, objectName)}`); + const result = Reflect.get(target, key, receiver); + if (result === undefined) { + return undefined; + } + if ((result !== null && typeof result === "object") || typeof result === "function") { + return result; + } + return TemporalHelpers.toPrimitiveObserver(calls, result, `${formatPropertyName(key, objectName)}`); + }, + has(target, key) { + calls.push(`has ${formatPropertyName(key, objectName)}`); + return Reflect.has(target, key); + }, + }); + }, + + /* + * specificOffsetTimeZone(): + * + * This returns an instance of a custom time zone class, which returns a + * specific custom value from its getOffsetNanosecondsFrom() method. This is + * for the purpose of testing the validation of what this method returns. + * + * It also returns an empty array from getPossibleInstantsFor(), so as to + * trigger calls to getOffsetNanosecondsFor() when used from the + * BuiltinTimeZoneGetInstantFor operation. + */ + specificOffsetTimeZone(offsetValue) { + class SpecificOffsetTimeZone extends Temporal.TimeZone { + constructor(offsetValue) { + super("UTC"); + this._offsetValue = offsetValue; + } + + getOffsetNanosecondsFor() { + return this._offsetValue; + } + + getPossibleInstantsFor() { + return []; + } + } + return new SpecificOffsetTimeZone(offsetValue); + }, + + /* + * springForwardFallBackTimeZone(): + * + * This returns an instance of a custom time zone class that implements one + * single spring-forward/fall-back transition, for the purpose of testing the + * disambiguation option, without depending on system time zone data. + * + * The spring-forward occurs at epoch second 954669600 (2000-04-02T02:00 + * local) and goes from offset -08:00 to -07:00. + * + * The fall-back occurs at epoch second 972810000 (2000-10-29T02:00 local) and + * goes from offset -07:00 to -08:00. + */ + springForwardFallBackTimeZone() { + const { compare } = Temporal.PlainDateTime; + const springForwardLocal = new Temporal.PlainDateTime(2000, 4, 2, 2); + const springForwardEpoch = 954669600_000_000_000n; + const fallBackLocal = new Temporal.PlainDateTime(2000, 10, 29, 1); + const fallBackEpoch = 972810000_000_000_000n; + const winterOffset = new Temporal.TimeZone('-08:00'); + const summerOffset = new Temporal.TimeZone('-07:00'); + + class SpringForwardFallBackTimeZone extends Temporal.TimeZone { + constructor() { + super("-08:00"); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < springForwardEpoch || + instant.epochNanoseconds >= fallBackEpoch) { + return winterOffset.getOffsetNanosecondsFor(instant); + } + return summerOffset.getOffsetNanosecondsFor(instant); + } + + getPossibleInstantsFor(datetime) { + if (compare(datetime, springForwardLocal) >= 0 && compare(datetime, springForwardLocal.add({ hours: 1 })) < 0) { + return []; + } + if (compare(datetime, fallBackLocal) >= 0 && compare(datetime, fallBackLocal.add({ hours: 1 })) < 0) { + return [summerOffset.getInstantFor(datetime), winterOffset.getInstantFor(datetime)]; + } + if (compare(datetime, springForwardLocal) < 0 || compare(datetime, fallBackLocal) >= 0) { + return [winterOffset.getInstantFor(datetime)]; + } + return [summerOffset.getInstantFor(datetime)]; + } + + getPreviousTransition(instant) { + if (instant.epochNanoseconds > fallBackEpoch) return new Temporal.Instant(fallBackEpoch); + if (instant.epochNanoseconds > springForwardEpoch) return new Temporal.Instant(springForwardEpoch); + return null; + } + + getNextTransition(instant) { + if (instant.epochNanoseconds < springForwardEpoch) return new Temporal.Instant(springForwardEpoch); + if (instant.epochNanoseconds < fallBackEpoch) return new Temporal.Instant(fallBackEpoch); + return null; + } + + get id() { + return "Custom/Spring_Fall"; + } + + toString() { + return "Custom/Spring_Fall"; + } + } + return new SpringForwardFallBackTimeZone(); + }, + + /* + * timeZoneObserver: + * A custom calendar that behaves exactly like the UTC time zone but tracks + * calls to any of its methods, and Get/Has operations on its properties, by + * appending messages to an array. This is for the purpose of testing order of + * operations that are observable from user code. objectName is used in the + * log. methodOverrides is an optional object containing properties with the + * same name as Temporal.TimeZone methods. If the property value is a function + * it will be called with the proper arguments instead of the UTC method. + * Otherwise, the property value will be returned directly. + */ + timeZoneObserver(calls, objectName, methodOverrides = {}) { + const utc = new Temporal.TimeZone("UTC"); + const trackingMethods = { + id: "UTC", + }; + // Automatically generate the methods + ["getOffsetNanosecondsFor", "getPossibleInstantsFor", "toString"].forEach((methodName) => { + trackingMethods[methodName] = function (...args) { + calls.push(`call ${formatPropertyName(methodName, objectName)}`); + if (methodName in methodOverrides) { + const value = methodOverrides[methodName]; + return typeof value === "function" ? value(...args) : value; + } + return utc[methodName](...args); + }; + }); + return new Proxy(trackingMethods, { + get(target, key, receiver) { + const result = Reflect.get(target, key, receiver); + calls.push(`get ${formatPropertyName(key, objectName)}`); + return result; + }, + has(target, key) { + calls.push(`has ${formatPropertyName(key, objectName)}`); + return Reflect.has(target, key); + }, + }); + }, + + /* + * Returns an object that will append logs of any Gets or Calls of its valueOf + * or toString properties to the array calls. Both valueOf and toString will + * return the actual primitiveValue. propertyName is used in the log. + */ + toPrimitiveObserver(calls, primitiveValue, propertyName) { + return { + get valueOf() { + calls.push(`get ${propertyName}.valueOf`); + return function () { + calls.push(`call ${propertyName}.valueOf`); + return primitiveValue; + }; + }, + get toString() { + calls.push(`get ${propertyName}.toString`); + return function () { + calls.push(`call ${propertyName}.toString`); + if (primitiveValue === undefined) return undefined; + return primitiveValue.toString(); + }; + }, + }; + }, + + /* + * An object containing further methods that return arrays of ISO strings, for + * testing parsers. + */ + ISO: { + /* + * PlainMonthDay strings that are not valid. + */ + plainMonthDayStringsInvalid() { + return [ + "11-18junk", + ]; + }, + + /* + * PlainMonthDay strings that are valid and that should produce October 1st. + */ + plainMonthDayStringsValid() { + return [ + "10-01", + "1001", + "1965-10-01", + "1976-10-01T152330.1+00:00", + "19761001T15:23:30.1+00:00", + "1976-10-01T15:23:30.1+0000", + "1976-10-01T152330.1+0000", + "19761001T15:23:30.1+0000", + "19761001T152330.1+00:00", + "19761001T152330.1+0000", + "+001976-10-01T152330.1+00:00", + "+0019761001T15:23:30.1+00:00", + "+001976-10-01T15:23:30.1+0000", + "+001976-10-01T152330.1+0000", + "+0019761001T15:23:30.1+0000", + "+0019761001T152330.1+00:00", + "+0019761001T152330.1+0000", + "1976-10-01T15:23:00", + "1976-10-01T15:23", + "1976-10-01T15", + "1976-10-01", + "--10-01", + "--1001", + ]; + }, + + /* + * PlainTime strings that may be mistaken for PlainMonthDay or + * PlainYearMonth strings, and so require a time designator. + */ + plainTimeStringsAmbiguous() { + const ambiguousStrings = [ + "2021-12", // ambiguity between YYYY-MM and HHMM-UU + "2021-12[-12:00]", // ditto, TZ does not disambiguate + "1214", // ambiguity between MMDD and HHMM + "0229", // ditto, including MMDD that doesn't occur every year + "1130", // ditto, including DD that doesn't occur in every month + "12-14", // ambiguity between MM-DD and HH-UU + "12-14[-14:00]", // ditto, TZ does not disambiguate + "202112", // ambiguity between YYYYMM and HHMMSS + "202112[UTC]", // ditto, TZ does not disambiguate + ]; + // Adding a calendar annotation to one of these strings must not cause + // disambiguation in favour of time. + const stringsWithCalendar = ambiguousStrings.map((s) => s + '[u-ca=iso8601]'); + return ambiguousStrings.concat(stringsWithCalendar); + }, + + /* + * PlainTime strings that are of similar form to PlainMonthDay and + * PlainYearMonth strings, but are not ambiguous due to components that + * aren't valid as months or days. + */ + plainTimeStringsUnambiguous() { + return [ + "2021-13", // 13 is not a month + "202113", // ditto + "2021-13[-13:00]", // ditto + "202113[-13:00]", // ditto + "0000-00", // 0 is not a month + "000000", // ditto + "0000-00[UTC]", // ditto + "000000[UTC]", // ditto + "1314", // 13 is not a month + "13-14", // ditto + "1232", // 32 is not a day + "0230", // 30 is not a day in February + "0631", // 31 is not a day in June + "0000", // 0 is neither a month nor a day + "00-00", // ditto + ]; + }, + + /* + * PlainYearMonth-like strings that are not valid. + */ + plainYearMonthStringsInvalid() { + return [ + "2020-13", + ]; + }, + + /* + * PlainYearMonth-like strings that are valid and should produce November + * 1976 in the ISO 8601 calendar. + */ + plainYearMonthStringsValid() { + return [ + "1976-11", + "1976-11-10", + "1976-11-01T09:00:00+00:00", + "1976-11-01T00:00:00+05:00", + "197611", + "+00197611", + "1976-11-18T15:23:30.1\u221202:00", + "1976-11-18T152330.1+00:00", + "19761118T15:23:30.1+00:00", + "1976-11-18T15:23:30.1+0000", + "1976-11-18T152330.1+0000", + "19761118T15:23:30.1+0000", + "19761118T152330.1+00:00", + "19761118T152330.1+0000", + "+001976-11-18T152330.1+00:00", + "+0019761118T15:23:30.1+00:00", + "+001976-11-18T15:23:30.1+0000", + "+001976-11-18T152330.1+0000", + "+0019761118T15:23:30.1+0000", + "+0019761118T152330.1+00:00", + "+0019761118T152330.1+0000", + "1976-11-18T15:23", + "1976-11-18T15", + "1976-11-18", + ]; + }, + + /* + * PlainYearMonth-like strings that are valid and should produce November of + * the ISO year -9999. + */ + plainYearMonthStringsValidNegativeYear() { + return [ + "\u2212009999-11", + ]; + }, + } +}; diff --git a/harness/testAtomics.js b/harness/testAtomics.js new file mode 100644 index 00000000000..8dd9ff365fa --- /dev/null +++ b/harness/testAtomics.js @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to assert the correctness of SharedArrayBuffer objects. +defines: + - testWithAtomicsOutOfBoundsIndices + - testWithAtomicsInBoundsIndices + - testWithAtomicsNonViewValues +---*/ + + +/** + * Calls the provided function for a each bad index that should throw a + * RangeError when passed to an Atomics method on a SAB-backed view where + * index 125 is out of range. + * + * @param f - the function to call for each bad index. + */ +function testWithAtomicsOutOfBoundsIndices(f) { + var bad_indices = [ + function(view) { return -1; }, + function(view) { return view.length; }, + function(view) { return view.length * 2; }, + function(view) { return Number.POSITIVE_INFINITY; }, + function(view) { return Number.NEGATIVE_INFINITY; }, + function(view) { return { valueOf: function() { return 125; } }; }, + function(view) { return { toString: function() { return '125'; }, valueOf: false }; }, // non-callable valueOf triggers invocation of toString + ]; + + for (var i = 0; i < bad_indices.length; ++i) { + var IdxGen = bad_indices[i]; + try { + f(IdxGen); + } catch (e) { + e.message += ' (Testing with index gen ' + IdxGen + '.)'; + throw e; + } + } +} + +/** + * Calls the provided function for each good index that should not throw when + * passed to an Atomics method on a SAB-backed view. + * + * The view must have length greater than zero. + * + * @param f - the function to call for each good index. + */ +function testWithAtomicsInBoundsIndices(f) { + // Most of these are eventually coerced to +0 by ToIndex. + var good_indices = [ + function(view) { return 0/-1; }, + function(view) { return '-0'; }, + function(view) { return undefined; }, + function(view) { return NaN; }, + function(view) { return 0.5; }, + function(view) { return '0.5'; }, + function(view) { return -0.9; }, + function(view) { return { password: 'qumquat' }; }, + function(view) { return view.length - 1; }, + function(view) { return { valueOf: function() { return 0; } }; }, + function(view) { return { toString: function() { return '0'; }, valueOf: false }; }, // non-callable valueOf triggers invocation of toString + ]; + + for (var i = 0; i < good_indices.length; ++i) { + var IdxGen = good_indices[i]; + try { + f(IdxGen); + } catch (e) { + e.message += ' (Testing with index gen ' + IdxGen + '.)'; + throw e; + } + } +} + +/** + * Calls the provided function for each value that should throw a TypeError + * when passed to an Atomics method as a view. + * + * @param f - the function to call for each non-view value. + */ + +function testWithAtomicsNonViewValues(f) { + var values = [ + null, + undefined, + true, + false, + new Boolean(true), + 10, + 3.14, + new Number(4), + 'Hi there', + new Date, + /a*utomaton/g, + { password: 'qumquat' }, + new DataView(new ArrayBuffer(10)), + new ArrayBuffer(128), + new SharedArrayBuffer(128), + new Error('Ouch'), + [1,1,2,3,5,8], + function(x) { return -x; }, + Symbol('halleluja'), + // TODO: Proxy? + Object, + Int32Array, + Date, + Math, + Atomics + ]; + + for (var i = 0; i < values.length; ++i) { + var nonView = values[i]; + try { + f(nonView); + } catch (e) { + e.message += ' (Testing with non-view value ' + nonView + '.)'; + throw e; + } + } +} + diff --git a/harness/testBigIntTypedArray.js b/harness/testBigIntTypedArray.js new file mode 100644 index 00000000000..4956aaa7e35 --- /dev/null +++ b/harness/testBigIntTypedArray.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to assert the correctness of BigInt TypedArray objects. +defines: + - TypedArray + - testWithBigIntTypedArrayConstructors +---*/ + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithBigIntTypedArrayConstructors(f, selected) { + /** + * Array containing every BigInt typed array constructor. + */ + var constructors = selected || [ + BigInt64Array, + BigUint64Array + ]; + + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} diff --git a/harness/testIntl.js b/harness/testIntl.js new file mode 100644 index 00000000000..94efe546c30 --- /dev/null +++ b/harness/testIntl.js @@ -0,0 +1,2510 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + This file contains shared functions for the tests in the conformance test + suite for the ECMAScript Internationalization API. +author: Norbert Lindenberg +defines: + - testWithIntlConstructors + - taintDataProperty + - taintMethod + - taintProperties + - taintArray + - getLocaleSupportInfo + - getInvalidLanguageTags + - isCanonicalizedStructurallyValidLanguageTag + - getInvalidLocaleArguments + - testOption + - testForUnwantedRegExpChanges + - allCalendars + - allCollations + - allNumberingSystems + - isValidNumberingSystem + - numberingSystemDigits + - allSimpleSanctionedUnits + - testNumberFormat + - getDateTimeComponents + - getDateTimeComponentValues + - isCanonicalizedStructurallyValidTimeZoneName +---*/ +/** + */ + + +/** + * @description Calls the provided function for every service constructor in + * the Intl object. + * @param {Function} f the function to call for each service constructor in + * the Intl object. + * @param {Function} Constructor the constructor object to test with. + */ +function testWithIntlConstructors(f) { + var constructors = ["Collator", "NumberFormat", "DateTimeFormat"]; + + // Optionally supported Intl constructors. + // NB: Intl.Locale isn't an Intl service constructor! + // Intl.DisplayNames cannot be called without type in options. + ["PluralRules", "RelativeTimeFormat", "ListFormat"].forEach(function(constructor) { + if (typeof Intl[constructor] === "function") { + constructors[constructors.length] = constructor; + } + }); + + constructors.forEach(function (constructor) { + var Constructor = Intl[constructor]; + try { + f(Constructor); + } catch (e) { + e.message += " (Testing with " + constructor + ".)"; + throw e; + } + }); +} + + +/** + * Taints a named data property of the given object by installing + * a setter that throws an exception. + * @param {object} obj the object whose data property to taint + * @param {string} property the property to taint + */ +function taintDataProperty(obj, property) { + Object.defineProperty(obj, property, { + set: function(value) { + throw new Test262Error("Client code can adversely affect behavior: setter for " + property + "."); + }, + enumerable: false, + configurable: true + }); +} + + +/** + * Taints a named method of the given object by replacing it with a function + * that throws an exception. + * @param {object} obj the object whose method to taint + * @param {string} property the name of the method to taint + */ +function taintMethod(obj, property) { + Object.defineProperty(obj, property, { + value: function() { + throw new Test262Error("Client code can adversely affect behavior: method " + property + "."); + }, + writable: true, + enumerable: false, + configurable: true + }); +} + + +/** + * Taints the given properties (and similarly named properties) by installing + * setters on Object.prototype that throw exceptions. + * @param {Array} properties an array of property names to taint + */ +function taintProperties(properties) { + properties.forEach(function (property) { + var adaptedProperties = [property, "__" + property, "_" + property, property + "_", property + "__"]; + adaptedProperties.forEach(function (property) { + taintDataProperty(Object.prototype, property); + }); + }); +} + + +/** + * Taints the Array object by creating a setter for the property "0" and + * replacing some key methods with functions that throw exceptions. + */ +function taintArray() { + taintDataProperty(Array.prototype, "0"); + taintMethod(Array.prototype, "indexOf"); + taintMethod(Array.prototype, "join"); + taintMethod(Array.prototype, "push"); + taintMethod(Array.prototype, "slice"); + taintMethod(Array.prototype, "sort"); +} + + +/** + * Gets locale support info for the given constructor object, which must be one + * of Intl constructors. + * @param {object} Constructor the constructor for which to get locale support info + * @param {object} options the options while calling the constructor + * @return {object} locale support info with the following properties: + * supported: array of fully supported language tags + * byFallback: array of language tags that are supported through fallbacks + * unsupported: array of unsupported language tags + */ +function getLocaleSupportInfo(Constructor, options) { + var languages = ["zh", "es", "en", "hi", "ur", "ar", "ja", "pa"]; + var scripts = ["Latn", "Hans", "Deva", "Arab", "Jpan", "Hant", "Guru"]; + var countries = ["CN", "IN", "US", "PK", "JP", "TW", "HK", "SG", "419"]; + + var allTags = []; + var i, j, k; + var language, script, country; + for (i = 0; i < languages.length; i++) { + language = languages[i]; + allTags.push(language); + for (j = 0; j < scripts.length; j++) { + script = scripts[j]; + allTags.push(language + "-" + script); + for (k = 0; k < countries.length; k++) { + country = countries[k]; + allTags.push(language + "-" + script + "-" + country); + } + } + for (k = 0; k < countries.length; k++) { + country = countries[k]; + allTags.push(language + "-" + country); + } + } + + var supported = []; + var byFallback = []; + var unsupported = []; + for (i = 0; i < allTags.length; i++) { + var request = allTags[i]; + var result = new Constructor([request], options).resolvedOptions().locale; + if (request === result) { + supported.push(request); + } else if (request.indexOf(result) === 0) { + byFallback.push(request); + } else { + unsupported.push(request); + } + } + + return { + supported: supported, + byFallback: byFallback, + unsupported: unsupported + }; +} + + +/** + * Returns an array of strings for which IsStructurallyValidLanguageTag() returns false + */ +function getInvalidLanguageTags() { + var invalidLanguageTags = [ + "", // empty tag + "i", // singleton alone + "x", // private use without subtag + "u", // extension singleton in first place + "419", // region code in first place + "u-nu-latn-cu-bob", // extension sequence without language + "hans-cmn-cn", // "hans" could theoretically be a 4-letter language code, + // but those can't be followed by extlang codes. + "cmn-hans-cn-u-u", // duplicate singleton + "cmn-hans-cn-t-u-ca-u", // duplicate singleton + "de-gregory-gregory", // duplicate variant + "*", // language range + "de-*", // language range + "中文", // non-ASCII letters + "en-ß", // non-ASCII letters + "ıd", // non-ASCII letters + "es-Latn-latn", // two scripts + "pl-PL-pl", // two regions + "u-ca-gregory", // extension in first place + "de-1996-1996", // duplicate numeric variant + "pt-u-ca-gregory-u-nu-latn", // duplicate singleton subtag + + // Invalid tags starting with: https://github.com/tc39/ecma402/pull/289 + "no-nyn", // regular grandfathered in BCP47, but invalid in UTS35 + "i-klingon", // irregular grandfathered in BCP47, but invalid in UTS35 + "zh-hak-CN", // language with extlang in BCP47, but invalid in UTS35 + "sgn-ils", // language with extlang in BCP47, but invalid in UTS35 + "x-foo", // privateuse-only in BCP47, but invalid in UTS35 + "x-en-US-12345", // more privateuse-only variants. + "x-12345-12345-en-US", + "x-en-US-12345-12345", + "x-en-u-foo", + "x-en-u-foo-u-bar", + "x-u-foo", + + // underscores in different parts of the language tag + "de_DE", + "DE_de", + "cmn_Hans", + "cmn-hans_cn", + "es_419", + "es-419-u-nu-latn-cu_bob", + "i_klingon", + "cmn-hans-cn-t-ca-u-ca-x_t-u", + "enochian_enochian", + "de-gregory_u-ca-gregory", + + "en\u0000", // null-terminator sequence + " en", // leading whitespace + "en ", // trailing whitespace + "it-IT-Latn", // country before script tag + "de-u", // incomplete Unicode extension sequences + "de-u-", + "de-u-ca-", + "de-u-ca-gregory-", + "si-x", // incomplete private-use tags + "x-", + "x-y-", + ]; + + // make sure the data above is correct + for (var i = 0; i < invalidLanguageTags.length; ++i) { + var invalidTag = invalidLanguageTags[i]; + assert( + !isCanonicalizedStructurallyValidLanguageTag(invalidTag), + "Test data \"" + invalidTag + "\" is a canonicalized and structurally valid language tag." + ); + } + + return invalidLanguageTags; +} + + +/** + * @description Tests whether locale is a String value representing a + * structurally valid and canonicalized BCP 47 language tag, as defined in + * sections 6.2.2 and 6.2.3 of the ECMAScript Internationalization API + * Specification. + * @param {String} locale the string to be tested. + * @result {Boolean} whether the test succeeded. + */ +function isCanonicalizedStructurallyValidLanguageTag(locale) { + + /** + * Regular expression defining Unicode BCP 47 Locale Identifiers. + * + * Spec: https://unicode.org/reports/tr35/#Unicode_locale_identifier + */ + var alpha = "[a-z]", + digit = "[0-9]", + alphanum = "[a-z0-9]", + variant = "(" + alphanum + "{5,8}|(?:" + digit + alphanum + "{3}))", + region = "(" + alpha + "{2}|" + digit + "{3})", + script = "(" + alpha + "{4})", + language = "(" + alpha + "{2,3}|" + alpha + "{5,8})", + privateuse = "(x(-[a-z0-9]{1,8})+)", + singleton = "(" + digit + "|[a-wy-z])", + attribute= "(" + alphanum + "{3,8})", + keyword = "(" + alphanum + alpha + "(-" + alphanum + "{3,8})*)", + unicode_locale_extensions = "(u((-" + keyword + ")+|((-" + attribute + ")+(-" + keyword + ")*)))", + tlang = "(" + language + "(-" + script + ")?(-" + region + ")?(-" + variant + ")*)", + tfield = "(" + alpha + digit + "(-" + alphanum + "{3,8})+)", + transformed_extensions = "(t((-" + tlang + "(-" + tfield + ")*)|(-" + tfield + ")+))", + other_singleton = "(" + digit + "|[a-sv-wy-z])", + other_extensions = "(" + other_singleton + "(-" + alphanum + "{2,8})+)", + extension = "(" + unicode_locale_extensions + "|" + transformed_extensions + "|" + other_extensions + ")", + locale_id = language + "(-" + script + ")?(-" + region + ")?(-" + variant + ")*(-" + extension + ")*(-" + privateuse + ")?", + languageTag = "^(" + locale_id + ")$", + languageTagRE = new RegExp(languageTag, "i"); + + var duplicateSingleton = "-" + singleton + "-(.*-)?\\1(?!" + alphanum + ")", + duplicateSingletonRE = new RegExp(duplicateSingleton, "i"), + duplicateVariant = "(" + alphanum + "{2,8}-)+" + variant + "-(" + alphanum + "{2,8}-)*\\2(?!" + alphanum + ")", + duplicateVariantRE = new RegExp(duplicateVariant, "i"); + + var transformKeyRE = new RegExp("^" + alpha + digit + "$", "i"); + + /** + * Verifies that the given string is a well-formed Unicode BCP 47 Locale Identifier + * with no duplicate variant or singleton subtags. + * + * Spec: ECMAScript Internationalization API Specification, draft, 6.2.2. + */ + function isStructurallyValidLanguageTag(locale) { + if (!languageTagRE.test(locale)) { + return false; + } + locale = locale.split(/-x-/)[0]; + return !duplicateSingletonRE.test(locale) && !duplicateVariantRE.test(locale); + } + + + /** + * Mappings from complete tags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __tagMappings = { + // property names must be in lower case; values in canonical form + + "art-lojban": "jbo", + "cel-gaulish": "xtg", + "zh-guoyu": "zh", + "zh-hakka": "hak", + "zh-xiang": "hsn", + }; + + + /** + * Mappings from language subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __languageMappings = { + // property names and values must be in canonical case + + "aam": "aas", + "aar": "aa", + "abk": "ab", + "adp": "dz", + "afr": "af", + "aju": "jrb", + "aka": "ak", + "alb": "sq", + "als": "sq", + "amh": "am", + "ara": "ar", + "arb": "ar", + "arg": "an", + "arm": "hy", + "asd": "snz", + "asm": "as", + "aue": "ktz", + "ava": "av", + "ave": "ae", + "aym": "ay", + "ayr": "ay", + "ayx": "nun", + "aze": "az", + "azj": "az", + "bak": "ba", + "bam": "bm", + "baq": "eu", + "bcc": "bal", + "bcl": "bik", + "bel": "be", + "ben": "bn", + "bgm": "bcg", + "bh": "bho", + "bih": "bho", + "bis": "bi", + "bjd": "drl", + "bod": "bo", + "bos": "bs", + "bre": "br", + "bul": "bg", + "bur": "my", + "bxk": "luy", + "bxr": "bua", + "cat": "ca", + "ccq": "rki", + "ces": "cs", + "cha": "ch", + "che": "ce", + "chi": "zh", + "chu": "cu", + "chv": "cv", + "cjr": "mom", + "cka": "cmr", + "cld": "syr", + "cmk": "xch", + "cmn": "zh", + "cor": "kw", + "cos": "co", + "coy": "pij", + "cqu": "quh", + "cre": "cr", + "cwd": "cr", + "cym": "cy", + "cze": "cs", + "dan": "da", + "deu": "de", + "dgo": "doi", + "dhd": "mwr", + "dik": "din", + "diq": "zza", + "dit": "dif", + "div": "dv", + "drh": "mn", + "dut": "nl", + "dzo": "dz", + "ekk": "et", + "ell": "el", + "emk": "man", + "eng": "en", + "epo": "eo", + "esk": "ik", + "est": "et", + "eus": "eu", + "ewe": "ee", + "fao": "fo", + "fas": "fa", + "fat": "ak", + "fij": "fj", + "fin": "fi", + "fra": "fr", + "fre": "fr", + "fry": "fy", + "fuc": "ff", + "ful": "ff", + "gav": "dev", + "gaz": "om", + "gbo": "grb", + "geo": "ka", + "ger": "de", + "gfx": "vaj", + "ggn": "gvr", + "gla": "gd", + "gle": "ga", + "glg": "gl", + "glv": "gv", + "gno": "gon", + "gre": "el", + "grn": "gn", + "gti": "nyc", + "gug": "gn", + "guj": "gu", + "guv": "duz", + "gya": "gba", + "hat": "ht", + "hau": "ha", + "hdn": "hai", + "hea": "hmn", + "heb": "he", + "her": "hz", + "him": "srx", + "hin": "hi", + "hmo": "ho", + "hrr": "jal", + "hrv": "hr", + "hun": "hu", + "hye": "hy", + "ibi": "opa", + "ibo": "ig", + "ice": "is", + "ido": "io", + "iii": "ii", + "ike": "iu", + "iku": "iu", + "ile": "ie", + "ilw": "gal", + "in": "id", + "ina": "ia", + "ind": "id", + "ipk": "ik", + "isl": "is", + "ita": "it", + "iw": "he", + "jav": "jv", + "jeg": "oyb", + "ji": "yi", + "jpn": "ja", + "jw": "jv", + "kal": "kl", + "kan": "kn", + "kas": "ks", + "kat": "ka", + "kau": "kr", + "kaz": "kk", + "kgc": "tdf", + "kgh": "kml", + "khk": "mn", + "khm": "km", + "kik": "ki", + "kin": "rw", + "kir": "ky", + "kmr": "ku", + "knc": "kr", + "kng": "kg", + "knn": "kok", + "koj": "kwv", + "kom": "kv", + "kon": "kg", + "kor": "ko", + "kpv": "kv", + "krm": "bmf", + "ktr": "dtp", + "kua": "kj", + "kur": "ku", + "kvs": "gdj", + "kwq": "yam", + "kxe": "tvd", + "kzj": "dtp", + "kzt": "dtp", + "lao": "lo", + "lat": "la", + "lav": "lv", + "lbk": "bnc", + "lii": "raq", + "lim": "li", + "lin": "ln", + "lit": "lt", + "llo": "ngt", + "lmm": "rmx", + "ltz": "lb", + "lub": "lu", + "lug": "lg", + "lvs": "lv", + "mac": "mk", + "mah": "mh", + "mal": "ml", + "mao": "mi", + "mar": "mr", + "may": "ms", + "meg": "cir", + "mhr": "chm", + "mkd": "mk", + "mlg": "mg", + "mlt": "mt", + "mnk": "man", + "mo": "ro", + "mol": "ro", + "mon": "mn", + "mri": "mi", + "msa": "ms", + "mst": "mry", + "mup": "raj", + "mwj": "vaj", + "mya": "my", + "myd": "aog", + "myt": "mry", + "nad": "xny", + "nau": "na", + "nav": "nv", + "nbl": "nr", + "ncp": "kdz", + "nde": "nd", + "ndo": "ng", + "nep": "ne", + "nld": "nl", + "nno": "nn", + "nns": "nbr", + "nnx": "ngv", + "no": "nb", + "nob": "nb", + "nor": "nb", + "npi": "ne", + "nts": "pij", + "nya": "ny", + "oci": "oc", + "ojg": "oj", + "oji": "oj", + "ori": "or", + "orm": "om", + "ory": "or", + "oss": "os", + "oun": "vaj", + "pan": "pa", + "pbu": "ps", + "pcr": "adx", + "per": "fa", + "pes": "fa", + "pli": "pi", + "plt": "mg", + "pmc": "huw", + "pmu": "phr", + "pnb": "lah", + "pol": "pl", + "por": "pt", + "ppa": "bfy", + "ppr": "lcq", + "pry": "prt", + "pus": "ps", + "puz": "pub", + "que": "qu", + "quz": "qu", + "rmy": "rom", + "roh": "rm", + "ron": "ro", + "rum": "ro", + "run": "rn", + "rus": "ru", + "sag": "sg", + "san": "sa", + "sca": "hle", + "scc": "sr", + "scr": "hr", + "sin": "si", + "skk": "oyb", + "slk": "sk", + "slo": "sk", + "slv": "sl", + "sme": "se", + "smo": "sm", + "sna": "sn", + "snd": "sd", + "som": "so", + "sot": "st", + "spa": "es", + "spy": "kln", + "sqi": "sq", + "src": "sc", + "srd": "sc", + "srp": "sr", + "ssw": "ss", + "sun": "su", + "swa": "sw", + "swe": "sv", + "swh": "sw", + "tah": "ty", + "tam": "ta", + "tat": "tt", + "tdu": "dtp", + "tel": "te", + "tgk": "tg", + "tgl": "fil", + "tha": "th", + "thc": "tpo", + "thx": "oyb", + "tib": "bo", + "tie": "ras", + "tir": "ti", + "tkk": "twm", + "tl": "fil", + "tlw": "weo", + "tmp": "tyj", + "tne": "kak", + "ton": "to", + "tsf": "taj", + "tsn": "tn", + "tso": "ts", + "ttq": "tmh", + "tuk": "tk", + "tur": "tr", + "tw": "ak", + "twi": "ak", + "uig": "ug", + "ukr": "uk", + "umu": "del", + "uok": "ema", + "urd": "ur", + "uzb": "uz", + "uzn": "uz", + "ven": "ve", + "vie": "vi", + "vol": "vo", + "wel": "cy", + "wln": "wa", + "wol": "wo", + "xba": "cax", + "xho": "xh", + "xia": "acn", + "xkh": "waw", + "xpe": "kpe", + "xsj": "suj", + "xsl": "den", + "ybd": "rki", + "ydd": "yi", + "yid": "yi", + "yma": "lrr", + "ymt": "mtm", + "yor": "yo", + "yos": "zom", + "yuu": "yug", + "zai": "zap", + "zha": "za", + "zho": "zh", + "zsm": "ms", + "zul": "zu", + "zyb": "za", + }; + + + /** + * Mappings from region subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __regionMappings = { + // property names and values must be in canonical case + + "004": "AF", + "008": "AL", + "010": "AQ", + "012": "DZ", + "016": "AS", + "020": "AD", + "024": "AO", + "028": "AG", + "031": "AZ", + "032": "AR", + "036": "AU", + "040": "AT", + "044": "BS", + "048": "BH", + "050": "BD", + "051": "AM", + "052": "BB", + "056": "BE", + "060": "BM", + "062": "034", + "064": "BT", + "068": "BO", + "070": "BA", + "072": "BW", + "074": "BV", + "076": "BR", + "084": "BZ", + "086": "IO", + "090": "SB", + "092": "VG", + "096": "BN", + "100": "BG", + "104": "MM", + "108": "BI", + "112": "BY", + "116": "KH", + "120": "CM", + "124": "CA", + "132": "CV", + "136": "KY", + "140": "CF", + "144": "LK", + "148": "TD", + "152": "CL", + "156": "CN", + "158": "TW", + "162": "CX", + "166": "CC", + "170": "CO", + "174": "KM", + "175": "YT", + "178": "CG", + "180": "CD", + "184": "CK", + "188": "CR", + "191": "HR", + "192": "CU", + "196": "CY", + "203": "CZ", + "204": "BJ", + "208": "DK", + "212": "DM", + "214": "DO", + "218": "EC", + "222": "SV", + "226": "GQ", + "230": "ET", + "231": "ET", + "232": "ER", + "233": "EE", + "234": "FO", + "238": "FK", + "239": "GS", + "242": "FJ", + "246": "FI", + "248": "AX", + "249": "FR", + "250": "FR", + "254": "GF", + "258": "PF", + "260": "TF", + "262": "DJ", + "266": "GA", + "268": "GE", + "270": "GM", + "275": "PS", + "276": "DE", + "278": "DE", + "280": "DE", + "288": "GH", + "292": "GI", + "296": "KI", + "300": "GR", + "304": "GL", + "308": "GD", + "312": "GP", + "316": "GU", + "320": "GT", + "324": "GN", + "328": "GY", + "332": "HT", + "334": "HM", + "336": "VA", + "340": "HN", + "344": "HK", + "348": "HU", + "352": "IS", + "356": "IN", + "360": "ID", + "364": "IR", + "368": "IQ", + "372": "IE", + "376": "IL", + "380": "IT", + "384": "CI", + "388": "JM", + "392": "JP", + "398": "KZ", + "400": "JO", + "404": "KE", + "408": "KP", + "410": "KR", + "414": "KW", + "417": "KG", + "418": "LA", + "422": "LB", + "426": "LS", + "428": "LV", + "430": "LR", + "434": "LY", + "438": "LI", + "440": "LT", + "442": "LU", + "446": "MO", + "450": "MG", + "454": "MW", + "458": "MY", + "462": "MV", + "466": "ML", + "470": "MT", + "474": "MQ", + "478": "MR", + "480": "MU", + "484": "MX", + "492": "MC", + "496": "MN", + "498": "MD", + "499": "ME", + "500": "MS", + "504": "MA", + "508": "MZ", + "512": "OM", + "516": "NA", + "520": "NR", + "524": "NP", + "528": "NL", + "531": "CW", + "533": "AW", + "534": "SX", + "535": "BQ", + "540": "NC", + "548": "VU", + "554": "NZ", + "558": "NI", + "562": "NE", + "566": "NG", + "570": "NU", + "574": "NF", + "578": "NO", + "580": "MP", + "581": "UM", + "583": "FM", + "584": "MH", + "585": "PW", + "586": "PK", + "591": "PA", + "598": "PG", + "600": "PY", + "604": "PE", + "608": "PH", + "612": "PN", + "616": "PL", + "620": "PT", + "624": "GW", + "626": "TL", + "630": "PR", + "634": "QA", + "638": "RE", + "642": "RO", + "643": "RU", + "646": "RW", + "652": "BL", + "654": "SH", + "659": "KN", + "660": "AI", + "662": "LC", + "663": "MF", + "666": "PM", + "670": "VC", + "674": "SM", + "678": "ST", + "682": "SA", + "686": "SN", + "688": "RS", + "690": "SC", + "694": "SL", + "702": "SG", + "703": "SK", + "704": "VN", + "705": "SI", + "706": "SO", + "710": "ZA", + "716": "ZW", + "720": "YE", + "724": "ES", + "728": "SS", + "729": "SD", + "732": "EH", + "736": "SD", + "740": "SR", + "744": "SJ", + "748": "SZ", + "752": "SE", + "756": "CH", + "760": "SY", + "762": "TJ", + "764": "TH", + "768": "TG", + "772": "TK", + "776": "TO", + "780": "TT", + "784": "AE", + "788": "TN", + "792": "TR", + "795": "TM", + "796": "TC", + "798": "TV", + "800": "UG", + "804": "UA", + "807": "MK", + "818": "EG", + "826": "GB", + "830": "JE", + "831": "GG", + "832": "JE", + "833": "IM", + "834": "TZ", + "840": "US", + "850": "VI", + "854": "BF", + "858": "UY", + "860": "UZ", + "862": "VE", + "876": "WF", + "882": "WS", + "886": "YE", + "887": "YE", + "891": "RS", + "894": "ZM", + "958": "AA", + "959": "QM", + "960": "QN", + "962": "QP", + "963": "QQ", + "964": "QR", + "965": "QS", + "966": "QT", + "967": "EU", + "968": "QV", + "969": "QW", + "970": "QX", + "971": "QY", + "972": "QZ", + "973": "XA", + "974": "XB", + "975": "XC", + "976": "XD", + "977": "XE", + "978": "XF", + "979": "XG", + "980": "XH", + "981": "XI", + "982": "XJ", + "983": "XK", + "984": "XL", + "985": "XM", + "986": "XN", + "987": "XO", + "988": "XP", + "989": "XQ", + "990": "XR", + "991": "XS", + "992": "XT", + "993": "XU", + "994": "XV", + "995": "XW", + "996": "XX", + "997": "XY", + "998": "XZ", + "999": "ZZ", + "BU": "MM", + "CS": "RS", + "CT": "KI", + "DD": "DE", + "DY": "BJ", + "FQ": "AQ", + "FX": "FR", + "HV": "BF", + "JT": "UM", + "MI": "UM", + "NH": "VU", + "NQ": "AQ", + "PU": "UM", + "PZ": "PA", + "QU": "EU", + "RH": "ZW", + "TP": "TL", + "UK": "GB", + "VD": "VN", + "WK": "UM", + "YD": "YE", + "YU": "RS", + "ZR": "CD", + }; + + + /** + * Complex mappings from language subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __complexLanguageMappings = { + // property names and values must be in canonical case + + "cnr": {language: "sr", region: "ME"}, + "drw": {language: "fa", region: "AF"}, + "hbs": {language: "sr", script: "Latn"}, + "prs": {language: "fa", region: "AF"}, + "sh": {language: "sr", script: "Latn"}, + "swc": {language: "sw", region: "CD"}, + "tnf": {language: "fa", region: "AF"}, + }; + + + /** + * Complex mappings from region subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __complexRegionMappings = { + // property names and values must be in canonical case + + "172": { + default: "RU", + "ab": "GE", + "az": "AZ", + "be": "BY", + "crh": "UA", + "gag": "MD", + "got": "UA", + "hy": "AM", + "ji": "UA", + "ka": "GE", + "kaa": "UZ", + "kk": "KZ", + "ku-Yezi": "GE", + "ky": "KG", + "os": "GE", + "rue": "UA", + "sog": "UZ", + "tg": "TJ", + "tk": "TM", + "tkr": "AZ", + "tly": "AZ", + "ttt": "AZ", + "ug-Cyrl": "KZ", + "uk": "UA", + "und-Armn": "AM", + "und-Chrs": "UZ", + "und-Geor": "GE", + "und-Goth": "UA", + "und-Sogd": "UZ", + "und-Sogo": "UZ", + "und-Yezi": "GE", + "uz": "UZ", + "xco": "UZ", + "xmf": "GE", + }, + "200": { + default: "CZ", + "sk": "SK", + }, + "530": { + default: "CW", + "vic": "SX", + }, + "532": { + default: "CW", + "vic": "SX", + }, + "536": { + default: "SA", + "akk": "IQ", + "ckb": "IQ", + "ku-Arab": "IQ", + "mis": "IQ", + "syr": "IQ", + "und-Hatr": "IQ", + "und-Syrc": "IQ", + "und-Xsux": "IQ", + }, + "582": { + default: "FM", + "mh": "MH", + "pau": "PW", + }, + "810": { + default: "RU", + "ab": "GE", + "az": "AZ", + "be": "BY", + "crh": "UA", + "et": "EE", + "gag": "MD", + "got": "UA", + "hy": "AM", + "ji": "UA", + "ka": "GE", + "kaa": "UZ", + "kk": "KZ", + "ku-Yezi": "GE", + "ky": "KG", + "lt": "LT", + "ltg": "LV", + "lv": "LV", + "os": "GE", + "rue": "UA", + "sgs": "LT", + "sog": "UZ", + "tg": "TJ", + "tk": "TM", + "tkr": "AZ", + "tly": "AZ", + "ttt": "AZ", + "ug-Cyrl": "KZ", + "uk": "UA", + "und-Armn": "AM", + "und-Chrs": "UZ", + "und-Geor": "GE", + "und-Goth": "UA", + "und-Sogd": "UZ", + "und-Sogo": "UZ", + "und-Yezi": "GE", + "uz": "UZ", + "vro": "EE", + "xco": "UZ", + "xmf": "GE", + }, + "890": { + default: "RS", + "bs": "BA", + "hr": "HR", + "mk": "MK", + "sl": "SI", + }, + "AN": { + default: "CW", + "vic": "SX", + }, + "NT": { + default: "SA", + "akk": "IQ", + "ckb": "IQ", + "ku-Arab": "IQ", + "mis": "IQ", + "syr": "IQ", + "und-Hatr": "IQ", + "und-Syrc": "IQ", + "und-Xsux": "IQ", + }, + "PC": { + default: "FM", + "mh": "MH", + "pau": "PW", + }, + "SU": { + default: "RU", + "ab": "GE", + "az": "AZ", + "be": "BY", + "crh": "UA", + "et": "EE", + "gag": "MD", + "got": "UA", + "hy": "AM", + "ji": "UA", + "ka": "GE", + "kaa": "UZ", + "kk": "KZ", + "ku-Yezi": "GE", + "ky": "KG", + "lt": "LT", + "ltg": "LV", + "lv": "LV", + "os": "GE", + "rue": "UA", + "sgs": "LT", + "sog": "UZ", + "tg": "TJ", + "tk": "TM", + "tkr": "AZ", + "tly": "AZ", + "ttt": "AZ", + "ug-Cyrl": "KZ", + "uk": "UA", + "und-Armn": "AM", + "und-Chrs": "UZ", + "und-Geor": "GE", + "und-Goth": "UA", + "und-Sogd": "UZ", + "und-Sogo": "UZ", + "und-Yezi": "GE", + "uz": "UZ", + "vro": "EE", + "xco": "UZ", + "xmf": "GE", + }, + }; + + + /** + * Mappings from variant subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __variantMappings = { + // property names and values must be in canonical case + + "aaland": {type: "region", replacement: "AX"}, + "arevela": {type: "language", replacement: "hy"}, + "arevmda": {type: "language", replacement: "hyw"}, + "heploc": {type: "variant", replacement: "alalc97"}, + "polytoni": {type: "variant", replacement: "polyton"}, + }; + + + /** + * Mappings from Unicode extension subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __unicodeMappings = { + // property names and values must be in canonical case + + "ca": { + "ethiopic-amete-alem": "ethioaa", + "islamicc": "islamic-civil", + }, + "kb": { + "yes": "true", + }, + "kc": { + "yes": "true", + }, + "kh": { + "yes": "true", + }, + "kk": { + "yes": "true", + }, + "kn": { + "yes": "true", + }, + "ks": { + "primary": "level1", + "tertiary": "level3", + }, + "ms": { + "imperial": "uksystem", + }, + "rg": { + "cn11": "cnbj", + "cn12": "cntj", + "cn13": "cnhe", + "cn14": "cnsx", + "cn15": "cnmn", + "cn21": "cnln", + "cn22": "cnjl", + "cn23": "cnhl", + "cn31": "cnsh", + "cn32": "cnjs", + "cn33": "cnzj", + "cn34": "cnah", + "cn35": "cnfj", + "cn36": "cnjx", + "cn37": "cnsd", + "cn41": "cnha", + "cn42": "cnhb", + "cn43": "cnhn", + "cn44": "cngd", + "cn45": "cngx", + "cn46": "cnhi", + "cn50": "cncq", + "cn51": "cnsc", + "cn52": "cngz", + "cn53": "cnyn", + "cn54": "cnxz", + "cn61": "cnsn", + "cn62": "cngs", + "cn63": "cnqh", + "cn64": "cnnx", + "cn65": "cnxj", + "cz10a": "cz110", + "cz10b": "cz111", + "cz10c": "cz112", + "cz10d": "cz113", + "cz10e": "cz114", + "cz10f": "cz115", + "cz611": "cz663", + "cz612": "cz632", + "cz613": "cz633", + "cz614": "cz634", + "cz615": "cz635", + "cz621": "cz641", + "cz622": "cz642", + "cz623": "cz643", + "cz624": "cz644", + "cz626": "cz646", + "cz627": "cz647", + "czjc": "cz31", + "czjm": "cz64", + "czka": "cz41", + "czkr": "cz52", + "czli": "cz51", + "czmo": "cz80", + "czol": "cz71", + "czpa": "cz53", + "czpl": "cz32", + "czpr": "cz10", + "czst": "cz20", + "czus": "cz42", + "czvy": "cz63", + "czzl": "cz72", + "fra": "frges", + "frb": "frnaq", + "frc": "frara", + "frd": "frbfc", + "fre": "frbre", + "frf": "frcvl", + "frg": "frges", + "frh": "frcor", + "fri": "frbfc", + "frj": "fridf", + "frk": "frocc", + "frl": "frnaq", + "frm": "frges", + "frn": "frocc", + "fro": "frhdf", + "frp": "frnor", + "frq": "frnor", + "frr": "frpdl", + "frs": "frhdf", + "frt": "frnaq", + "fru": "frpac", + "frv": "frara", + "laxn": "laxs", + "lud": "lucl", + "lug": "luec", + "lul": "luca", + "mrnkc": "mr13", + "no23": "no50", + "nzn": "nzauk", + "nzs": "nzcan", + "omba": "ombj", + "omsh": "omsj", + "plds": "pl02", + "plkp": "pl04", + "pllb": "pl08", + "plld": "pl10", + "pllu": "pl06", + "plma": "pl12", + "plmz": "pl14", + "plop": "pl16", + "plpd": "pl20", + "plpk": "pl18", + "plpm": "pl22", + "plsk": "pl26", + "plsl": "pl24", + "plwn": "pl28", + "plwp": "pl30", + "plzp": "pl32", + "tteto": "tttob", + "ttrcm": "ttmrc", + "ttwto": "tttob", + "twkhq": "twkhh", + "twtnq": "twtnn", + "twtpq": "twnwt", + "twtxq": "twtxg", + }, + "sd": { + "cn11": "cnbj", + "cn12": "cntj", + "cn13": "cnhe", + "cn14": "cnsx", + "cn15": "cnmn", + "cn21": "cnln", + "cn22": "cnjl", + "cn23": "cnhl", + "cn31": "cnsh", + "cn32": "cnjs", + "cn33": "cnzj", + "cn34": "cnah", + "cn35": "cnfj", + "cn36": "cnjx", + "cn37": "cnsd", + "cn41": "cnha", + "cn42": "cnhb", + "cn43": "cnhn", + "cn44": "cngd", + "cn45": "cngx", + "cn46": "cnhi", + "cn50": "cncq", + "cn51": "cnsc", + "cn52": "cngz", + "cn53": "cnyn", + "cn54": "cnxz", + "cn61": "cnsn", + "cn62": "cngs", + "cn63": "cnqh", + "cn64": "cnnx", + "cn65": "cnxj", + "cz10a": "cz110", + "cz10b": "cz111", + "cz10c": "cz112", + "cz10d": "cz113", + "cz10e": "cz114", + "cz10f": "cz115", + "cz611": "cz663", + "cz612": "cz632", + "cz613": "cz633", + "cz614": "cz634", + "cz615": "cz635", + "cz621": "cz641", + "cz622": "cz642", + "cz623": "cz643", + "cz624": "cz644", + "cz626": "cz646", + "cz627": "cz647", + "czjc": "cz31", + "czjm": "cz64", + "czka": "cz41", + "czkr": "cz52", + "czli": "cz51", + "czmo": "cz80", + "czol": "cz71", + "czpa": "cz53", + "czpl": "cz32", + "czpr": "cz10", + "czst": "cz20", + "czus": "cz42", + "czvy": "cz63", + "czzl": "cz72", + "fra": "frges", + "frb": "frnaq", + "frc": "frara", + "frd": "frbfc", + "fre": "frbre", + "frf": "frcvl", + "frg": "frges", + "frh": "frcor", + "fri": "frbfc", + "frj": "fridf", + "frk": "frocc", + "frl": "frnaq", + "frm": "frges", + "frn": "frocc", + "fro": "frhdf", + "frp": "frnor", + "frq": "frnor", + "frr": "frpdl", + "frs": "frhdf", + "frt": "frnaq", + "fru": "frpac", + "frv": "frara", + "laxn": "laxs", + "lud": "lucl", + "lug": "luec", + "lul": "luca", + "mrnkc": "mr13", + "no23": "no50", + "nzn": "nzauk", + "nzs": "nzcan", + "omba": "ombj", + "omsh": "omsj", + "plds": "pl02", + "plkp": "pl04", + "pllb": "pl08", + "plld": "pl10", + "pllu": "pl06", + "plma": "pl12", + "plmz": "pl14", + "plop": "pl16", + "plpd": "pl20", + "plpk": "pl18", + "plpm": "pl22", + "plsk": "pl26", + "plsl": "pl24", + "plwn": "pl28", + "plwp": "pl30", + "plzp": "pl32", + "tteto": "tttob", + "ttrcm": "ttmrc", + "ttwto": "tttob", + "twkhq": "twkhh", + "twtnq": "twtnn", + "twtpq": "twnwt", + "twtxq": "twtxg", + }, + "tz": { + "aqams": "nzakl", + "cnckg": "cnsha", + "cnhrb": "cnsha", + "cnkhg": "cnurc", + "cuba": "cuhav", + "egypt": "egcai", + "eire": "iedub", + "est": "utcw05", + "gmt0": "gmt", + "hongkong": "hkhkg", + "hst": "utcw10", + "iceland": "isrey", + "iran": "irthr", + "israel": "jeruslm", + "jamaica": "jmkin", + "japan": "jptyo", + "libya": "lytip", + "mst": "utcw07", + "navajo": "usden", + "poland": "plwaw", + "portugal": "ptlis", + "prc": "cnsha", + "roc": "twtpe", + "rok": "krsel", + "turkey": "trist", + "uct": "utc", + "usnavajo": "usden", + "zulu": "utc", + }, + }; + + + /** + * Mappings from Unicode extension subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __transformMappings = { + // property names and values must be in canonical case + + "d0": { + "name": "charname", + }, + "m0": { + "names": "prprname", + }, + }; + + /** + * Canonicalizes the given well-formed BCP 47 language tag, including regularized case of subtags. + * + * Spec: ECMAScript Internationalization API Specification, draft, 6.2.3. + * Spec: RFC 5646, section 4.5. + */ + function canonicalizeLanguageTag(locale) { + + // start with lower case for easier processing, and because most subtags will need to be lower case anyway + locale = locale.toLowerCase(); + + // handle mappings for complete tags + if (__tagMappings.hasOwnProperty(locale)) { + return __tagMappings[locale]; + } + + var subtags = locale.split("-"); + var i = 0; + + // handle standard part: all subtags before first variant or singleton subtag + var language; + var script; + var region; + while (i < subtags.length) { + var subtag = subtags[i]; + if (i === 0) { + language = subtag; + } else if (subtag.length === 2 || subtag.length === 3) { + region = subtag.toUpperCase(); + } else if (subtag.length === 4 && !("0" <= subtag[0] && subtag[0] <= "9")) { + script = subtag[0].toUpperCase() + subtag.substring(1).toLowerCase(); + } else { + break; + } + i++; + } + + if (__languageMappings.hasOwnProperty(language)) { + language = __languageMappings[language]; + } else if (__complexLanguageMappings.hasOwnProperty(language)) { + var mapping = __complexLanguageMappings[language]; + + language = mapping.language; + if (script === undefined && mapping.hasOwnProperty("script")) { + script = mapping.script; + } + if (region === undefined && mapping.hasOwnProperty("region")) { + region = mapping.region; + } + } + + if (region !== undefined) { + if (__regionMappings.hasOwnProperty(region)) { + region = __regionMappings[region]; + } else if (__complexRegionMappings.hasOwnProperty(region)) { + var mapping = __complexRegionMappings[region]; + + var mappingKey = language; + if (script !== undefined) { + mappingKey += "-" + script; + } + + if (mapping.hasOwnProperty(mappingKey)) { + region = mapping[mappingKey]; + } else { + region = mapping.default; + } + } + } + + // handle variants + var variants = []; + while (i < subtags.length && subtags[i].length > 1) { + var variant = subtags[i]; + + if (__variantMappings.hasOwnProperty(variant)) { + var mapping = __variantMappings[variant]; + switch (mapping.type) { + case "language": + language = mapping.replacement; + break; + + case "region": + region = mapping.replacement; + break; + + case "variant": + variants.push(mapping.replacement); + break; + + default: + throw new Error("illegal variant mapping type"); + } + } else { + variants.push(variant); + } + + i += 1; + } + variants.sort(); + + // handle extensions + var extensions = []; + while (i < subtags.length && subtags[i] !== "x") { + var extensionStart = i; + i++; + while (i < subtags.length && subtags[i].length > 1) { + i++; + } + + var extension; + var extensionKey = subtags[extensionStart]; + if (extensionKey === "u") { + var j = extensionStart + 1; + + // skip over leading attributes + while (j < i && subtags[j].length > 2) { + j++; + } + + extension = subtags.slice(extensionStart, j).join("-"); + + while (j < i) { + var keyStart = j; + j++; + + while (j < i && subtags[j].length > 2) { + j++; + } + + var key = subtags[keyStart]; + var value = subtags.slice(keyStart + 1, j).join("-"); + + if (__unicodeMappings.hasOwnProperty(key)) { + var mapping = __unicodeMappings[key]; + if (mapping.hasOwnProperty(value)) { + value = mapping[value]; + } + } + + extension += "-" + key; + if (value !== "" && value !== "true") { + extension += "-" + value; + } + } + } else if (extensionKey === "t") { + var j = extensionStart + 1; + + while (j < i && !transformKeyRE.test(subtags[j])) { + j++; + } + + extension = "t"; + + var transformLanguage = subtags.slice(extensionStart + 1, j).join("-"); + if (transformLanguage !== "") { + extension += "-" + canonicalizeLanguageTag(transformLanguage).toLowerCase(); + } + + while (j < i) { + var keyStart = j; + j++; + + while (j < i && subtags[j].length > 2) { + j++; + } + + var key = subtags[keyStart]; + var value = subtags.slice(keyStart + 1, j).join("-"); + + if (__transformMappings.hasOwnProperty(key)) { + var mapping = __transformMappings[key]; + if (mapping.hasOwnProperty(value)) { + value = mapping[value]; + } + } + + extension += "-" + key + "-" + value; + } + } else { + extension = subtags.slice(extensionStart, i).join("-"); + } + + extensions.push(extension); + } + extensions.sort(); + + // handle private use + var privateUse; + if (i < subtags.length) { + privateUse = subtags.slice(i).join("-"); + } + + // put everything back together + var canonical = language; + if (script !== undefined) { + canonical += "-" + script; + } + if (region !== undefined) { + canonical += "-" + region; + } + if (variants.length > 0) { + canonical += "-" + variants.join("-"); + } + if (extensions.length > 0) { + canonical += "-" + extensions.join("-"); + } + if (privateUse !== undefined) { + if (canonical.length > 0) { + canonical += "-" + privateUse; + } else { + canonical = privateUse; + } + } + + return canonical; + } + + return typeof locale === "string" && isStructurallyValidLanguageTag(locale) && + canonicalizeLanguageTag(locale) === locale; +} + + +/** + * Returns an array of error cases handled by CanonicalizeLocaleList(). + */ +function getInvalidLocaleArguments() { + function CustomError() {} + + var topLevelErrors = [ + // fails ToObject + [null, TypeError], + + // fails Get + [{ get length() { throw new CustomError(); } }, CustomError], + + // fail ToLength + [{ length: Symbol.toPrimitive }, TypeError], + [{ length: { get [Symbol.toPrimitive]() { throw new CustomError(); } } }, CustomError], + [{ length: { [Symbol.toPrimitive]() { throw new CustomError(); } } }, CustomError], + [{ length: { get valueOf() { throw new CustomError(); } } }, CustomError], + [{ length: { valueOf() { throw new CustomError(); } } }, CustomError], + [{ length: { get toString() { throw new CustomError(); } } }, CustomError], + [{ length: { toString() { throw new CustomError(); } } }, CustomError], + + // fail type check + [[undefined], TypeError], + [[null], TypeError], + [[true], TypeError], + [[Symbol.toPrimitive], TypeError], + [[1], TypeError], + [[0.1], TypeError], + [[NaN], TypeError], + ]; + + var invalidLanguageTags = [ + "", // empty tag + "i", // singleton alone + "x", // private use without subtag + "u", // extension singleton in first place + "419", // region code in first place + "u-nu-latn-cu-bob", // extension sequence without language + "hans-cmn-cn", // "hans" could theoretically be a 4-letter language code, + // but those can't be followed by extlang codes. + "abcdefghi", // overlong language + "cmn-hans-cn-u-u", // duplicate singleton + "cmn-hans-cn-t-u-ca-u", // duplicate singleton + "de-gregory-gregory", // duplicate variant + "*", // language range + "de-*", // language range + "中文", // non-ASCII letters + "en-ß", // non-ASCII letters + "ıd" // non-ASCII letters + ]; + + return topLevelErrors.concat( + invalidLanguageTags.map(tag => [tag, RangeError]), + invalidLanguageTags.map(tag => [[tag], RangeError]), + invalidLanguageTags.map(tag => [["en", tag], RangeError]), + ) +} + +/** + * Tests whether the named options property is correctly handled by the given constructor. + * @param {object} Constructor the constructor to test. + * @param {string} property the name of the options property to test. + * @param {string} type the type that values of the property are expected to have + * @param {Array} [values] an array of allowed values for the property. Not needed for boolean. + * @param {any} fallback the fallback value that the property assumes if not provided. + * @param {object} testOptions additional options: + * @param {boolean} isOptional whether support for this property is optional for implementations. + * @param {boolean} noReturn whether the resulting value of the property is not returned. + * @param {boolean} isILD whether the resulting value of the property is implementation and locale dependent. + * @param {object} extra additional option to pass along, properties are value -> {option: value}. + */ +function testOption(Constructor, property, type, values, fallback, testOptions) { + var isOptional = testOptions !== undefined && testOptions.isOptional === true; + var noReturn = testOptions !== undefined && testOptions.noReturn === true; + var isILD = testOptions !== undefined && testOptions.isILD === true; + + function addExtraOptions(options, value, testOptions) { + if (testOptions !== undefined && testOptions.extra !== undefined) { + var extra; + if (value !== undefined && testOptions.extra[value] !== undefined) { + extra = testOptions.extra[value]; + } else if (testOptions.extra.any !== undefined) { + extra = testOptions.extra.any; + } + if (extra !== undefined) { + Object.getOwnPropertyNames(extra).forEach(function (prop) { + options[prop] = extra[prop]; + }); + } + } + } + + var testValues, options, obj, expected, actual, error; + + // test that the specified values are accepted. Also add values that convert to specified values. + if (type === "boolean") { + if (values === undefined) { + values = [true, false]; + } + testValues = values.slice(0); + testValues.push(888); + testValues.push(0); + } else if (type === "string") { + testValues = values.slice(0); + testValues.push({toString: function () { return values[0]; }}); + } + testValues.forEach(function (value) { + options = {}; + options[property] = value; + addExtraOptions(options, value, testOptions); + obj = new Constructor(undefined, options); + if (noReturn) { + if (obj.resolvedOptions().hasOwnProperty(property)) { + throw new Test262Error("Option property " + property + " is returned, but shouldn't be."); + } + } else { + actual = obj.resolvedOptions()[property]; + if (isILD) { + if (actual !== undefined && values.indexOf(actual) === -1) { + throw new Test262Error("Invalid value " + actual + " returned for property " + property + "."); + } + } else { + if (type === "boolean") { + expected = Boolean(value); + } else if (type === "string") { + expected = String(value); + } + if (actual !== expected && !(isOptional && actual === undefined)) { + throw new Test262Error("Option value " + value + " for property " + property + + " was not accepted; got " + actual + " instead."); + } + } + } + }); + + // test that invalid values are rejected + if (type === "string") { + var invalidValues = ["invalidValue", -1, null]; + // assume that we won't have values in caseless scripts + if (values[0].toUpperCase() !== values[0]) { + invalidValues.push(values[0].toUpperCase()); + } else { + invalidValues.push(values[0].toLowerCase()); + } + invalidValues.forEach(function (value) { + options = {}; + options[property] = value; + addExtraOptions(options, value, testOptions); + error = undefined; + try { + obj = new Constructor(undefined, options); + } catch (e) { + error = e; + } + if (error === undefined) { + throw new Test262Error("Invalid option value " + value + " for property " + property + " was not rejected."); + } else if (error.name !== "RangeError") { + throw new Test262Error("Invalid option value " + value + " for property " + property + " was rejected with wrong error " + error.name + "."); + } + }); + } + + // test that fallback value or another valid value is used if no options value is provided + if (!noReturn) { + options = {}; + addExtraOptions(options, undefined, testOptions); + obj = new Constructor(undefined, options); + actual = obj.resolvedOptions()[property]; + if (!(isOptional && actual === undefined)) { + if (fallback !== undefined) { + if (actual !== fallback) { + throw new Test262Error("Option fallback value " + fallback + " for property " + property + + " was not used; got " + actual + " instead."); + } + } else { + if (values.indexOf(actual) === -1 && !(isILD && actual === undefined)) { + throw new Test262Error("Invalid value " + actual + " returned for property " + property + "."); + } + } + } + } +} + + +/** + * Properties of the RegExp constructor that may be affected by use of regular + * expressions, and the default values of these properties. Properties are from + * https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Deprecated_and_obsolete_features#RegExp_Properties + */ +var regExpProperties = ["$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$_", "$*", "$&", "$+", "$`", "$'", + "input", "lastMatch", "lastParen", "leftContext", "rightContext" +]; + +var regExpPropertiesDefaultValues = (function () { + var values = Object.create(null); + (/(?:)/).test(""); + regExpProperties.forEach(function (property) { + values[property] = RegExp[property]; + }); + return values; +}()); + + +/** + * Tests that executing the provided function (which may use regular expressions + * in its implementation) does not create or modify unwanted properties on the + * RegExp constructor. + */ +function testForUnwantedRegExpChanges(testFunc) { + (/(?:)/).test(""); + testFunc(); + regExpProperties.forEach(function (property) { + if (RegExp[property] !== regExpPropertiesDefaultValues[property]) { + throw new Test262Error("RegExp has unexpected property " + property + " with value " + + RegExp[property] + "."); + } + }); +} + + +/** + * Returns an array of all known calendars. + */ +function allCalendars() { + // source: CLDR file common/bcp47/number.xml; version CLDR 39. + // https://github.com/unicode-org/cldr/blob/master/common/bcp47/calendar.xml + return [ + "buddhist", + "chinese", + "coptic", + "dangi", + "ethioaa", + "ethiopic", + "gregory", + "hebrew", + "indian", + "islamic", + "islamic-umalqura", + "islamic-tbla", + "islamic-civil", + "islamic-rgsa", + "iso8601", + "japanese", + "persian", + "roc", + ]; +} + + +/** + * Returns an array of all known collations. + */ +function allCollations() { + // source: CLDR file common/bcp47/collation.xml; version CLDR 39. + // https://github.com/unicode-org/cldr/blob/master/common/bcp47/collation.xml + return [ + "big5han", + "compat", + "dict", + "direct", + "ducet", + "emoji", + "eor", + "gb2312", + "phonebk", + "phonetic", + "pinyin", + "reformed", + "search", + "searchjl", + "standard", + "stroke", + "trad", + "unihan", + "zhuyin", + ]; +} + + +/** + * Returns an array of all known numbering systems. + */ +function allNumberingSystems() { + // source: CLDR file common/bcp47/number.xml; version CLDR 40 & new in Unicode 14.0 + // https://github.com/unicode-org/cldr/blob/master/common/bcp47/number.xml + return [ + "adlm", + "ahom", + "arab", + "arabext", + "armn", + "armnlow", + "bali", + "beng", + "bhks", + "brah", + "cakm", + "cham", + "cyrl", + "deva", + "diak", + "ethi", + "finance", + "fullwide", + "geor", + "gong", + "gonm", + "grek", + "greklow", + "gujr", + "guru", + "hanidays", + "hanidec", + "hans", + "hansfin", + "hant", + "hantfin", + "hebr", + "hmng", + "hmnp", + "java", + "jpan", + "jpanfin", + "jpanyear", + "kali", + "khmr", + "knda", + "lana", + "lanatham", + "laoo", + "latn", + "lepc", + "limb", + "mathbold", + "mathdbl", + "mathmono", + "mathsanb", + "mathsans", + "mlym", + "modi", + "mong", + "mroo", + "mtei", + "mymr", + "mymrshan", + "mymrtlng", + "native", + "newa", + "nkoo", + "olck", + "orya", + "osma", + "rohg", + "roman", + "romanlow", + "saur", + "shrd", + "sind", + "sinh", + "sora", + "sund", + "takr", + "talu", + "taml", + "tamldec", + "tnsa", + "telu", + "thai", + "tirh", + "tibt", + "traditio", + "vaii", + "wara", + "wcho", + ]; +} + + +/** + * Tests whether name is a valid BCP 47 numbering system name + * and not excluded from use in the ECMAScript Internationalization API. + * @param {string} name the name to be tested. + * @return {boolean} whether name is a valid BCP 47 numbering system name and + * allowed for use in the ECMAScript Internationalization API. + */ + +function isValidNumberingSystem(name) { + + var numberingSystems = allNumberingSystems(); + + var excluded = [ + "finance", + "native", + "traditio" + ]; + + + return numberingSystems.indexOf(name) !== -1 && excluded.indexOf(name) === -1; +} + + +/** + * Provides the digits of numbering systems with simple digit mappings, + * as specified in 11.3.2. + */ + +var numberingSystemDigits = { + adlm: "𞥐𞥑𞥒𞥓𞥔𞥕𞥖𞥗𞥘𞥙", + ahom: "𑜰𑜱𑜲𑜳𑜴𑜵𑜶𑜷𑜸𑜹", + arab: "٠١٢٣٤٥٦٧٨٩", + arabext: "۰۱۲۳۴۵۶۷۸۹", + bali: "\u1B50\u1B51\u1B52\u1B53\u1B54\u1B55\u1B56\u1B57\u1B58\u1B59", + beng: "০১২৩৪৫৬৭৮৯", + bhks: "𑱐𑱑𑱒𑱓𑱔𑱕𑱖𑱗𑱘𑱙", + brah: "𑁦𑁧𑁨𑁩𑁪𑁫𑁬𑁭𑁮𑁯", + cakm: "𑄶𑄷𑄸𑄹𑄺𑄻𑄼𑄽𑄾𑄿", + cham: "꩐꩑꩒꩓꩔꩕꩖꩗꩘꩙", + deva: "०१२३४५६७८९", + diak: "𑥐𑥑𑥒𑥓𑥔𑥕𑥖𑥗𑥘𑥙", + fullwide: "0123456789", + gong: "𑶠𑶡𑶢𑶣𑶤𑶥𑶦𑶧𑶨𑶩", + gonm: "𑵐𑵑𑵒𑵓𑵔𑵕𑵖𑵗𑵘𑵙", + gujr: "૦૧૨૩૪૫૬૭૮૯", + guru: "੦੧੨੩੪੫੬੭੮੯", + hanidec: "〇一二三四五六七八九", + hmng: "𖭐𖭑𖭒𖭓𖭔𖭕𖭖𖭗𖭘𖭙", + hmnp: "𞅀𞅁𞅂𞅃𞅄𞅅𞅆𞅇𞅈𞅉", + java: "꧐꧑꧒꧓꧔꧕꧖꧗꧘꧙", + kali: "꤀꤁꤂꤃꤄꤅꤆꤇꤈꤉", + khmr: "០១២៣៤៥៦៧៨៩", + knda: "೦೧೨೩೪೫೬೭೮೯", + lana: "᪀᪁᪂᪃᪄᪅᪆᪇᪈᪉", + lanatham: "᪐᪑᪒᪓᪔᪕᪖᪗᪘᪙", + laoo: "໐໑໒໓໔໕໖໗໘໙", + latn: "0123456789", + lepc: "᱀᱁᱂᱃᱄᱅᱆᱇᱈᱉", + limb: "\u1946\u1947\u1948\u1949\u194A\u194B\u194C\u194D\u194E\u194F", + mathbold: "𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗", + mathdbl: "𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡", + mathmono: "𝟶𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿", + mathsanb: "𝟬𝟭𝟮𝟯𝟰𝟱𝟲𝟳𝟴𝟵", + mathsans: "𝟢𝟣𝟤𝟥𝟦𝟧𝟨𝟩𝟪𝟫", + mlym: "൦൧൨൩൪൫൬൭൮൯", + modi: "𑙐𑙑𑙒𑙓𑙔𑙕𑙖𑙗𑙘𑙙", + mong: "᠐᠑᠒᠓᠔᠕᠖᠗᠘᠙", + mroo: "𖩠𖩡𖩢𖩣𖩤𖩥𖩦𖩧𖩨𖩩", + mtei: "꯰꯱꯲꯳꯴꯵꯶꯷꯸꯹", + mymr: "၀၁၂၃၄၅၆၇၈၉", + mymrshan: "႐႑႒႓႔႕႖႗႘႙", + mymrtlng: "꧰꧱꧲꧳꧴꧵꧶꧷꧸꧹", + newa: "𑑐𑑑𑑒𑑓𑑔𑑕𑑖𑑗𑑘𑑙", + nkoo: "߀߁߂߃߄߅߆߇߈߉", + olck: "᱐᱑᱒᱓᱔᱕᱖᱗᱘᱙", + orya: "୦୧୨୩୪୫୬୭୮୯", + osma: "𐒠𐒡𐒢𐒣𐒤𐒥𐒦𐒧𐒨𐒩", + rohg: "𐴰𐴱𐴲𐴳𐴴𐴵𐴶𐴷𐴸𐴹", + saur: "꣐꣑꣒꣓꣔꣕꣖꣗꣘꣙", + segment: "🯰🯱🯲🯳🯴🯵🯶🯷🯸🯹", + shrd: "𑇐𑇑𑇒𑇓𑇔𑇕𑇖𑇗𑇘𑇙", + sind: "𑋰𑋱𑋲𑋳𑋴𑋵𑋶𑋷𑋸𑋹", + sinh: "෦෧෨෩෪෫෬෭෮෯", + sora: "𑃰𑃱𑃲𑃳𑃴𑃵𑃶𑃷𑃸𑃹", + sund: "᮰᮱᮲᮳᮴᮵᮶᮷᮸᮹", + takr: "𑛀𑛁𑛂𑛃𑛄𑛅𑛆𑛇𑛈𑛉", + talu: "᧐᧑᧒᧓᧔᧕᧖᧗᧘᧙", + tamldec: "௦௧௨௩௪௫௬௭௮௯", + tnsa: "\u{16AC0}\u{16AC1}\u{16AC2}\u{16AC3}\u{16AC4}\u{16AC5}\u{16AC6}\u{16AC7}\u{16AC8}\u{16AC9}", + telu: "౦౧౨౩౪౫౬౭౮౯", + thai: "๐๑๒๓๔๕๖๗๘๙", + tibt: "༠༡༢༣༤༥༦༧༨༩", + tirh: "𑓐𑓑𑓒𑓓𑓔𑓕𑓖𑓗𑓘𑓙", + vaii: "꘠꘡꘢꘣꘤꘥꘦꘧꘨꘩", + wara: "𑣠𑣡𑣢𑣣𑣤𑣥𑣦𑣧𑣨𑣩", + wcho: "𞋰𞋱𞋲𞋳𞋴𞋵𞋶𞋷𞋸𞋹", +}; + + +/** + * Returns an array of all simple, sanctioned unit identifiers. + */ +function allSimpleSanctionedUnits() { + // https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers + return [ + "acre", + "bit", + "byte", + "celsius", + "centimeter", + "day", + "degree", + "fahrenheit", + "fluid-ounce", + "foot", + "gallon", + "gigabit", + "gigabyte", + "gram", + "hectare", + "hour", + "inch", + "kilobit", + "kilobyte", + "kilogram", + "kilometer", + "liter", + "megabit", + "megabyte", + "meter", + "microsecond", + "mile", + "mile-scandinavian", + "milliliter", + "millimeter", + "millisecond", + "minute", + "month", + "nanosecond", + "ounce", + "percent", + "petabyte", + "pound", + "second", + "stone", + "terabit", + "terabyte", + "week", + "yard", + "year", + ]; +} + + +/** + * Tests that number formatting is handled correctly. The function checks that the + * digit sequences in formatted output are as specified, converted to the + * selected numbering system, and embedded in consistent localized patterns. + * @param {Array} locales the locales to be tested. + * @param {Array} numberingSystems the numbering systems to be tested. + * @param {Object} options the options to pass to Intl.NumberFormat. Options + * must include {useGrouping: false}, and must cause 1.1 to be formatted + * pre- and post-decimal digits. + * @param {Object} testData maps input data (in ES5 9.3.1 format) to expected output strings + * in unlocalized format with Western digits. + */ + +function testNumberFormat(locales, numberingSystems, options, testData) { + locales.forEach(function (locale) { + numberingSystems.forEach(function (numbering) { + var digits = numberingSystemDigits[numbering]; + var format = new Intl.NumberFormat([locale + "-u-nu-" + numbering], options); + + function getPatternParts(positive) { + var n = positive ? 1.1 : -1.1; + var formatted = format.format(n); + var oneoneRE = "([^" + digits + "]*)[" + digits + "]+([^" + digits + "]+)[" + digits + "]+([^" + digits + "]*)"; + var match = formatted.match(new RegExp(oneoneRE)); + if (match === null) { + throw new Test262Error("Unexpected formatted " + n + " for " + + format.resolvedOptions().locale + " and options " + + JSON.stringify(options) + ": " + formatted); + } + return match; + } + + function toNumbering(raw) { + return raw.replace(/[0-9]/g, function (digit) { + return digits[digit.charCodeAt(0) - "0".charCodeAt(0)]; + }); + } + + function buildExpected(raw, patternParts) { + var period = raw.indexOf("."); + if (period === -1) { + return patternParts[1] + toNumbering(raw) + patternParts[3]; + } else { + return patternParts[1] + + toNumbering(raw.substring(0, period)) + + patternParts[2] + + toNumbering(raw.substring(period + 1)) + + patternParts[3]; + } + } + + if (format.resolvedOptions().numberingSystem === numbering) { + // figure out prefixes, infixes, suffixes for positive and negative values + var posPatternParts = getPatternParts(true); + var negPatternParts = getPatternParts(false); + + Object.getOwnPropertyNames(testData).forEach(function (input) { + var rawExpected = testData[input]; + var patternParts; + if (rawExpected[0] === "-") { + patternParts = negPatternParts; + rawExpected = rawExpected.substring(1); + } else { + patternParts = posPatternParts; + } + var expected = buildExpected(rawExpected, patternParts); + var actual = format.format(input); + if (actual !== expected) { + throw new Test262Error("Formatted value for " + input + ", " + + format.resolvedOptions().locale + " and options " + + JSON.stringify(options) + " is " + actual + "; expected " + expected + "."); + } + }); + } + }); + }); +} + + +/** + * Return the components of date-time formats. + * @return {Array} an array with all date-time components. + */ + +function getDateTimeComponents() { + return ["weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName"]; +} + + +/** + * Return the valid values for the given date-time component, as specified + * by the table in section 12.1.1. + * @param {string} component a date-time component. + * @return {Array} an array with the valid values for the component. + */ + +function getDateTimeComponentValues(component) { + + var components = { + weekday: ["narrow", "short", "long"], + era: ["narrow", "short", "long"], + year: ["2-digit", "numeric"], + month: ["2-digit", "numeric", "narrow", "short", "long"], + day: ["2-digit", "numeric"], + hour: ["2-digit", "numeric"], + minute: ["2-digit", "numeric"], + second: ["2-digit", "numeric"], + timeZoneName: ["short", "long"] + }; + + var result = components[component]; + if (result === undefined) { + throw new Test262Error("Internal error: No values defined for date-time component " + component + "."); + } + return result; +} + + +/** + * @description Tests whether timeZone is a String value representing a + * structurally valid and canonicalized time zone name, as defined in + * sections 6.4.1 and 6.4.2 of the ECMAScript Internationalization API + * Specification. + * @param {String} timeZone the string to be tested. + * @result {Boolean} whether the test succeeded. + */ + +function isCanonicalizedStructurallyValidTimeZoneName(timeZone) { + /** + * Regular expression defining IANA Time Zone names. + * + * Spec: IANA Time Zone Database, Theory file + */ + var fileNameComponent = "(?:[A-Za-z_]|\\.(?!\\.?(?:/|$)))[A-Za-z.\\-_]{0,13}"; + var fileName = fileNameComponent + "(?:/" + fileNameComponent + ")*"; + var etcName = "(?:Etc/)?GMT[+-]\\d{1,2}"; + var systemVName = "SystemV/[A-Z]{3}\\d{1,2}(?:[A-Z]{3})?"; + var legacyName = etcName + "|" + systemVName + "|CST6CDT|EST5EDT|MST7MDT|PST8PDT|NZ"; + var zoneNamePattern = new RegExp("^(?:" + fileName + "|" + legacyName + ")$"); + + if (typeof timeZone !== "string") { + return false; + } + // 6.4.2 CanonicalizeTimeZoneName (timeZone), step 3 + if (timeZone === "UTC") { + return true; + } + // 6.4.2 CanonicalizeTimeZoneName (timeZone), step 3 + if (timeZone === "Etc/UTC" || timeZone === "Etc/GMT") { + return false; + } + return zoneNamePattern.test(timeZone); +} diff --git a/harness/testTypedArray.js b/harness/testTypedArray.js new file mode 100644 index 00000000000..0cc50c9fd50 --- /dev/null +++ b/harness/testTypedArray.js @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - typedArrayConstructors + - floatArrayConstructors + - intArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +/** + * Array containing every typed array constructor. + */ +var typedArrayConstructors = [ + Float64Array, + Float32Array, + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + Uint8ClampedArray +]; + +var floatArrayConstructors = typedArrayConstructors.slice(0, 2); +var intArrayConstructors = typedArrayConstructors.slice(2, 7); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Float64Array, + Float32Array, + Uint8ClampedArray + ]); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} diff --git a/harness/timer.js b/harness/timer.js new file mode 100644 index 00000000000..d55f47d4f73 --- /dev/null +++ b/harness/timer.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Used in website/scripts/sth.js +defines: [setTimeout] +---*/ +//setTimeout is not available, hence this script was loaded +if (Promise === undefined && this.setTimeout === undefined) { + if(/\$DONE()/.test(code)) + throw new Test262Error("Async test capability is not supported in your test environment"); +} + +if (Promise !== undefined && this.setTimeout === undefined) { + (function(that) { + that.setTimeout = function(callback, delay) { + var p = Promise.resolve(); + var start = Date.now(); + var end = start + delay; + function check(){ + var timeLeft = end - Date.now(); + if(timeLeft > 0) + p.then(check); + else + callback(); + } + p.then(check); + } + })(this); +} diff --git a/harness/typeCoercion.js b/harness/typeCoercion.js new file mode 100644 index 00000000000..72f79205a01 --- /dev/null +++ b/harness/typeCoercion.js @@ -0,0 +1,463 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Functions to help generate test cases for testing type coercion abstract + operations like ToNumber. +defines: + - testCoercibleToIndexZero + - testCoercibleToIndexOne + - testCoercibleToIndexFromIndex + - testCoercibleToIntegerZero + - testCoercibleToIntegerOne + - testCoercibleToNumberZero + - testCoercibleToNumberNan + - testCoercibleToNumberOne + - testCoercibleToIntegerFromInteger + - testPrimitiveWrappers + - testCoercibleToPrimitiveWithMethod + - testNotCoercibleToIndex + - testNotCoercibleToInteger + - testNotCoercibleToNumber + - testNotCoercibleToPrimitive + - testCoercibleToString + - testNotCoercibleToString + - testCoercibleToBooleanTrue + - testCoercibleToBooleanFalse + - testCoercibleToBigIntZero + - testCoercibleToBigIntOne + - testCoercibleToBigIntFromBigInt + - testNotCoercibleToBigInt +---*/ + +function testCoercibleToIndexZero(test) { + testCoercibleToIntegerZero(test); +} + +function testCoercibleToIndexOne(test) { + testCoercibleToIntegerOne(test); +} + +function testCoercibleToIndexFromIndex(nominalIndex, test) { + assert(Number.isInteger(nominalIndex)); + assert(0 <= nominalIndex && nominalIndex <= 2**53 - 1); + testCoercibleToIntegerFromInteger(nominalIndex, test); +} + +function testCoercibleToIntegerZero(test) { + testCoercibleToNumberZero(test); + + testCoercibleToIntegerFromInteger(0, test); + + // NaN -> +0 + testCoercibleToNumberNan(test); + + // When toString() returns a string that parses to NaN: + test({}); + test([]); +} + +function testCoercibleToIntegerOne(test) { + testCoercibleToNumberOne(test); + + testCoercibleToIntegerFromInteger(1, test); + + // When toString() returns "1" + test([1]); + test(["1"]); +} + +function testCoercibleToNumberZero(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testPrimitiveValue(null); + testPrimitiveValue(false); + testPrimitiveValue(0); + testPrimitiveValue("0"); +} + +function testCoercibleToNumberNan(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testPrimitiveValue(undefined); + testPrimitiveValue(NaN); + testPrimitiveValue(""); + testPrimitiveValue("foo"); + testPrimitiveValue("true"); +} + +function testCoercibleToNumberOne(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testPrimitiveValue(true); + testPrimitiveValue(1); + testPrimitiveValue("1"); +} + +function testCoercibleToIntegerFromInteger(nominalInteger, test) { + assert(Number.isInteger(nominalInteger)); + + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + + // Non-primitive values that coerce to the nominal integer: + // toString() returns a string that parsers to a primitive value. + test([value]); + } + + function testPrimitiveNumber(number) { + testPrimitiveValue(number); + // ToNumber: String -> Number + testPrimitiveValue(number.toString()); + } + + testPrimitiveNumber(nominalInteger); + + // ToInteger: floor(abs(number)) + if (nominalInteger >= 0) { + testPrimitiveNumber(nominalInteger + 0.9); + } + if (nominalInteger <= 0) { + testPrimitiveNumber(nominalInteger - 0.9); + } +} + +function testPrimitiveWrappers(primitiveValue, hint, test) { + if (primitiveValue != null) { + // null and undefined result in {} rather than a proper wrapper, + // so skip this case for those values. + test(Object(primitiveValue)); + } + + testCoercibleToPrimitiveWithMethod(hint, function() { + return primitiveValue; + }, test); +} + +function testCoercibleToPrimitiveWithMethod(hint, method, test) { + var methodNames; + if (hint === "number") { + methodNames = ["valueOf", "toString"]; + } else if (hint === "string") { + methodNames = ["toString", "valueOf"]; + } else { + throw new Test262Error(); + } + // precedence order + test({ + [Symbol.toPrimitive]: method, + [methodNames[0]]: function() { throw new Test262Error(); }, + [methodNames[1]]: function() { throw new Test262Error(); }, + }); + test({ + [methodNames[0]]: method, + [methodNames[1]]: function() { throw new Test262Error(); }, + }); + if (hint === "number") { + // The default valueOf returns an object, which is unsuitable. + // The default toString returns a String, which is suitable. + // Therefore this test only works for valueOf falling back to toString. + test({ + // this is toString: + [methodNames[1]]: method, + }); + } + + // GetMethod: if func is undefined or null, return undefined. + test({ + [Symbol.toPrimitive]: undefined, + [methodNames[0]]: method, + [methodNames[1]]: method, + }); + test({ + [Symbol.toPrimitive]: null, + [methodNames[0]]: method, + [methodNames[1]]: method, + }); + + // if methodNames[0] is not callable, fallback to methodNames[1] + test({ + [methodNames[0]]: null, + [methodNames[1]]: method, + }); + test({ + [methodNames[0]]: 1, + [methodNames[1]]: method, + }); + test({ + [methodNames[0]]: {}, + [methodNames[1]]: method, + }); + + // if methodNames[0] returns an object, fallback to methodNames[1] + test({ + [methodNames[0]]: function() { return {}; }, + [methodNames[1]]: method, + }); + test({ + [methodNames[0]]: function() { return Object(1); }, + [methodNames[1]]: method, + }); +} + +function testNotCoercibleToIndex(test) { + function testPrimitiveValue(value) { + test(RangeError, value); + // ToPrimitive + testPrimitiveWrappers(value, "number", function(value) { + test(RangeError, value); + }); + } + + // Let integerIndex be ? ToInteger(value). + testNotCoercibleToInteger(test); + + // If integerIndex < 0, throw a RangeError exception. + testPrimitiveValue(-1); + testPrimitiveValue(-2.5); + testPrimitiveValue("-2.5"); + testPrimitiveValue(-Infinity); + + // Let index be ! ToLength(integerIndex). + // If SameValueZero(integerIndex, index) is false, throw a RangeError exception. + testPrimitiveValue(2 ** 53); + testPrimitiveValue(Infinity); +} + +function testNotCoercibleToInteger(test) { + // ToInteger only throws from ToNumber. + testNotCoercibleToNumber(test); +} + +function testNotCoercibleToNumber(test) { + function testPrimitiveValue(value) { + test(TypeError, value); + // ToPrimitive + testPrimitiveWrappers(value, "number", function(value) { + test(TypeError, value); + }); + } + + // ToNumber: Symbol -> TypeError + testPrimitiveValue(Symbol("1")); + + if (typeof BigInt !== "undefined") { + // ToNumber: BigInt -> TypeError + testPrimitiveValue(BigInt(0)); + } + + // ToPrimitive + testNotCoercibleToPrimitive("number", test); +} + +function testNotCoercibleToPrimitive(hint, test) { + function MyError() {} + + // ToPrimitive: input[@@toPrimitive] is not callable (and non-null) + test(TypeError, {[Symbol.toPrimitive]: 1}); + test(TypeError, {[Symbol.toPrimitive]: {}}); + + // ToPrimitive: input[@@toPrimitive] returns object + test(TypeError, {[Symbol.toPrimitive]: function() { return Object(1); }}); + test(TypeError, {[Symbol.toPrimitive]: function() { return {}; }}); + + // ToPrimitive: input[@@toPrimitive] throws + test(MyError, {[Symbol.toPrimitive]: function() { throw new MyError(); }}); + + // OrdinaryToPrimitive: method throws + testCoercibleToPrimitiveWithMethod(hint, function() { + throw new MyError(); + }, function(value) { + test(MyError, value); + }); + + // OrdinaryToPrimitive: both methods are unsuitable + function testUnsuitableMethod(method) { + test(TypeError, {valueOf:method, toString:method}); + } + // not callable: + testUnsuitableMethod(null); + testUnsuitableMethod(1); + testUnsuitableMethod({}); + // returns object: + testUnsuitableMethod(function() { return Object(1); }); + testUnsuitableMethod(function() { return {}; }); +} + +function testCoercibleToString(test) { + function testPrimitiveValue(value, expectedString) { + test(value, expectedString); + // ToPrimitive + testPrimitiveWrappers(value, "string", function(value) { + test(value, expectedString); + }); + } + + testPrimitiveValue(undefined, "undefined"); + testPrimitiveValue(null, "null"); + testPrimitiveValue(true, "true"); + testPrimitiveValue(false, "false"); + testPrimitiveValue(0, "0"); + testPrimitiveValue(-0, "0"); + testPrimitiveValue(Infinity, "Infinity"); + testPrimitiveValue(-Infinity, "-Infinity"); + testPrimitiveValue(123.456, "123.456"); + testPrimitiveValue(-123.456, "-123.456"); + testPrimitiveValue("", ""); + testPrimitiveValue("foo", "foo"); + + if (typeof BigInt !== "undefined") { + // BigInt -> TypeError + testPrimitiveValue(BigInt(0), "0"); + } + + // toString of a few objects + test([], ""); + test(["foo", "bar"], "foo,bar"); + test({}, "[object Object]"); +} + +function testNotCoercibleToString(test) { + function testPrimitiveValue(value) { + test(TypeError, value); + // ToPrimitive + testPrimitiveWrappers(value, "string", function(value) { + test(TypeError, value); + }); + } + + // Symbol -> TypeError + testPrimitiveValue(Symbol("1")); + + // ToPrimitive + testNotCoercibleToPrimitive("string", test); +} + +function testCoercibleToBooleanTrue(test) { + test(true); + test(1); + test("string"); + test(Symbol("1")); + test({}); +} + +function testCoercibleToBooleanFalse(test) { + test(undefined); + test(null); + test(false); + test(0); + test(-0); + test(NaN); + test(""); +} + +function testCoercibleToBigIntZero(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testCoercibleToBigIntFromBigInt(BigInt(0), test); + testPrimitiveValue(-BigInt(0)); + testPrimitiveValue("-0"); + testPrimitiveValue(false); + testPrimitiveValue(""); + testPrimitiveValue(" "); + + // toString() returns "" + test([]); + + // toString() returns "0" + test([0]); +} + +function testCoercibleToBigIntOne(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testCoercibleToBigIntFromBigInt(BigInt(1), test); + testPrimitiveValue(true); + + // toString() returns "1" + test([1]); +} + +function testCoercibleToBigIntFromBigInt(nominalBigInt, test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testPrimitiveValue(nominalBigInt); + testPrimitiveValue(nominalBigInt.toString()); + testPrimitiveValue("0b" + nominalBigInt.toString(2)); + testPrimitiveValue("0o" + nominalBigInt.toString(8)); + testPrimitiveValue("0x" + nominalBigInt.toString(16)); + testPrimitiveValue(" " + nominalBigInt.toString() + " "); + + // toString() returns the decimal string representation + test([nominalBigInt]); + test([nominalBigInt.toString()]); +} + +function testNotCoercibleToBigInt(test) { + function testPrimitiveValue(error, value) { + test(error, value); + // ToPrimitive + testPrimitiveWrappers(value, "number", function(value) { + test(error, value); + }); + } + + // Undefined, Null, Number, Symbol -> TypeError + testPrimitiveValue(TypeError, undefined); + testPrimitiveValue(TypeError, null); + testPrimitiveValue(TypeError, 0); + testPrimitiveValue(TypeError, NaN); + testPrimitiveValue(TypeError, Infinity); + testPrimitiveValue(TypeError, Symbol("1")); + + // when a String parses to NaN -> SyntaxError + function testStringValue(string) { + testPrimitiveValue(SyntaxError, string); + testPrimitiveValue(SyntaxError, " " + string); + testPrimitiveValue(SyntaxError, string + " "); + testPrimitiveValue(SyntaxError, " " + string + " "); + } + testStringValue("a"); + testStringValue("0b2"); + testStringValue("0o8"); + testStringValue("0xg"); + testStringValue("1n"); +} diff --git a/harness/wellKnownIntrinsicObjects.js b/harness/wellKnownIntrinsicObjects.js new file mode 100644 index 00000000000..3d0b57dc8bd --- /dev/null +++ b/harness/wellKnownIntrinsicObjects.js @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + An Array of all representable Well-Known Intrinsic Objects +defines: [WellKnownIntrinsicObjects] +---*/ + +const WellKnownIntrinsicObjects = [ + { + name: '%AggregateError%', + source: 'AggregateError', + }, + { + name: '%Array%', + source: 'Array', + }, + { + name: '%ArrayBuffer%', + source: 'ArrayBuffer', + }, + { + name: '%ArrayIteratorPrototype%', + source: 'Object.getPrototypeOf([][Symbol.iterator]())', + }, + { + name: '%AsyncFromSyncIteratorPrototype%', + source: 'undefined', + }, + { + name: '%AsyncFunction%', + source: '(async function() {}).constructor', + }, + { + name: '%AsyncGeneratorFunction%', + source: 'Object.getPrototypeOf(async function * () {})', + }, + { + name: '%AsyncIteratorPrototype%', + source: '((async function * () {})())[Symbol.asyncIterator]()', + }, + { + name: '%Atomics%', + source: 'Atomics', + }, + { + name: '%BigInt%', + source: 'BigInt', + }, + { + name: '%BigInt64Array%', + source: 'BigInt64Array', + }, + { + name: '%BigUint64Array%', + source: 'BigUint64Array', + }, + { + name: '%Boolean%', + source: 'Boolean', + }, + { + name: '%DataView%', + source: 'DataView', + }, + { + name: '%Date%', + source: 'Date', + }, + { + name: '%decodeURI%', + source: 'decodeURI', + }, + { + name: '%decodeURIComponent%', + source: 'decodeURIComponent', + }, + { + name: '%encodeURI%', + source: 'encodeURI', + }, + { + name: '%encodeURIComponent%', + source: 'encodeURIComponent', + }, + { + name: '%Error%', + source: 'Error', + }, + { + name: '%eval%', + source: 'eval', + }, + { + name: '%EvalError%', + source: 'EvalError', + }, + { + name: '%FinalizationRegistry%', + source: 'FinalizationRegistry', + }, + { + name: '%Float32Array%', + source: 'Float32Array', + }, + { + name: '%Float64Array%', + source: 'Float64Array', + }, + { + name: '%ForInIteratorPrototype%', + source: '', + }, + { + name: '%Function%', + source: 'Function', + }, + { + name: '%GeneratorFunction%', + source: 'Object.getPrototypeOf(function * () {})', + }, + { + name: '%Int8Array%', + source: 'Int8Array', + }, + { + name: '%Int16Array%', + source: 'Int16Array', + }, + { + name: '%Int32Array%', + source: 'Int32Array', + }, + { + name: '%isFinite%', + source: 'isFinite', + }, + { + name: '%isNaN%', + source: 'isNaN', + }, + { + name: '%IteratorPrototype%', + source: 'Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))', + }, + { + name: '%JSON%', + source: 'JSON', + }, + { + name: '%Map%', + source: 'Map', + }, + { + name: '%MapIteratorPrototype%', + source: 'Object.getPrototypeOf(new Map()[Symbol.iterator]())', + }, + { + name: '%Math%', + source: 'Math', + }, + { + name: '%Number%', + source: 'Number', + }, + { + name: '%Object%', + source: 'Object', + }, + { + name: '%parseFloat%', + source: 'parseFloat', + }, + { + name: '%parseInt%', + source: 'parseInt', + }, + { + name: '%Promise%', + source: 'Promise', + }, + { + name: '%Proxy%', + source: 'Proxy', + }, + { + name: '%RangeError%', + source: 'RangeError', + }, + { + name: '%ReferenceError%', + source: 'ReferenceError', + }, + { + name: '%Reflect%', + source: 'Reflect', + }, + { + name: '%RegExp%', + source: 'RegExp', + }, + { + name: '%RegExpStringIteratorPrototype%', + source: 'RegExp.prototype[Symbol.matchAll]("")', + }, + { + name: '%Set%', + source: 'Set', + }, + { + name: '%SetIteratorPrototype%', + source: 'Object.getPrototypeOf(new Set()[Symbol.iterator]())', + }, + { + name: '%SharedArrayBuffer%', + source: 'SharedArrayBuffer', + }, + { + name: '%String%', + source: 'String', + }, + { + name: '%StringIteratorPrototype%', + source: 'Object.getPrototypeOf(new String()[Symbol.iterator]())', + }, + { + name: '%Symbol%', + source: 'Symbol', + }, + { + name: '%SyntaxError%', + source: 'SyntaxError', + }, + { + name: '%ThrowTypeError%', + source: '(function() { "use strict"; return Object.getOwnPropertyDescriptor(arguments, "callee").get })()', + }, + { + name: '%TypedArray%', + source: 'Object.getPrototypeOf(Uint8Array)', + }, + { + name: '%TypeError%', + source: 'TypeError', + }, + { + name: '%Uint8Array%', + source: 'Uint8Array', + }, + { + name: '%Uint8ClampedArray%', + source: 'Uint8ClampedArray', + }, + { + name: '%Uint16Array%', + source: 'Uint16Array', + }, + { + name: '%Uint32Array%', + source: 'Uint32Array', + }, + { + name: '%URIError%', + source: 'URIError', + }, + { + name: '%WeakMap%', + source: 'WeakMap', + }, + { + name: '%WeakRef%', + source: 'WeakRef', + }, + { + name: '%WeakSet%', + source: 'WeakSet', + }, +]; + +WellKnownIntrinsicObjects.forEach((wkio) => { + var actual; + + try { + actual = new Function("return " + wkio.source)(); + } catch (exception) { + // Nothing to do here. + } + + wkio.value = actual; +}); diff --git a/package.json b/package.json new file mode 100644 index 00000000000..faa769dd7c7 --- /dev/null +++ b/package.json @@ -0,0 +1,31 @@ +{ + "name": "test262", + "version": "5.0.0", + "description": "Test262 tests conformance to the continually maintained draft future ECMAScript standard found at http://tc39.github.io/ecma262/ , together with any Stage 3 or later TC39 proposals.", + "repository": { + "type": "git", + "url": "git+https://github.com/tc39/test262.git" + }, + "license": "BSD", + "bugs": { + "url": "https://github.com/tc39/test262/issues" + }, + "private": true, + "homepage": "https://github.com/tc39/test262#readme", + "devDependencies": { + "esvu": "^1.2.11", + "test262-harness": "^8.0.0" + }, + "scripts": { + "ci": "./tools/scripts/ci_test.sh", + "test": "test262-harness", + "diff": "git diff --diff-filter ACMR --name-only main.. -- test/ && git ls-files --exclude-standard --others -- test/", + "test:diff": "npm run test:diff:v8 && npm run test:diff:spidermonkey && npm run test:diff:chakra && npm run test:diff:javascriptcore", + "test:diff:v8": "test262-harness -t 8 --hostType=d8 --hostPath=v8 $(npm run --silent diff)", + "test:diff:spidermonkey": "test262-harness -t 8 --hostType=jsshell --hostPath=spidermonkey $(npm run --silent diff)", + "test:diff:chakra": "test262-harness -t 8 --hostType=ch --hostPath=chakra $(npm run --silent diff)", + "test:diff:javascriptcore": "test262-harness -t 8 --hostType=jsc --hostPath=javascriptcore $(npm run --silent diff)", + "test:diff:xs": "test262-harness -t 8 --hostType=xs --hostPath=xs $(npm run --silent diff)" + } +} + diff --git a/test/sendable/builtins/ASON/15.12-0-1.js b/test/sendable/builtins/ASON/15.12-0-1.js new file mode 100644 index 00000000000..5a18e8cc541 --- /dev/null +++ b/test/sendable/builtins/ASON/15.12-0-1.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: | + This test should be run without any built-ins being added/augmented. + The name JSON must be bound to an object. + 4.2 calls out JSON as one of the built-in objects. +es5id: 15.12-0-1 +description: JSON must be a built-in object +---*/ + +var o = JSON; + +assert.sameValue(typeof(o), "object", 'typeof(o)'); diff --git a/test/sendable/builtins/ASON/15.12-0-2.js b/test/sendable/builtins/ASON/15.12-0-2.js new file mode 100644 index 00000000000..be97a00743e --- /dev/null +++ b/test/sendable/builtins/ASON/15.12-0-2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: | + This test should be run without any built-ins being added/augmented. + The name JSON must be bound to an object, and must not support [[Construct]]. + step 4 in 11.2.2 should throw a TypeError exception. +es5id: 15.12-0-2 +description: JSON must not support the [[Construct]] method +---*/ + +var o = JSON; +assert.throws(TypeError, function() { + var j = new JSON(); +}); diff --git a/test/sendable/builtins/ASON/15.12-0-3.js b/test/sendable/builtins/ASON/15.12-0-3.js new file mode 100644 index 00000000000..2de9aba9f99 --- /dev/null +++ b/test/sendable/builtins/ASON/15.12-0-3.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: | + This test should be run without any built-ins being added/augmented. + The name JSON must be bound to an object, and must not support [[Call]]. + step 5 in 11.2.3 should throw a TypeError exception. +es5id: 15.12-0-3 +description: JSON must not support the [[Call]] method +---*/ + +var o = JSON; +assert.throws(TypeError, function() { + var j = JSON(); +}); diff --git a/test/sendable/builtins/ASON/15.12-0-4.js b/test/sendable/builtins/ASON/15.12-0-4.js new file mode 100644 index 00000000000..88211d9d301 --- /dev/null +++ b/test/sendable/builtins/ASON/15.12-0-4.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: | + This test should be run without any built-ins being added/augmented. + The last paragraph in section 15 says "every other property described + in this section has the attribute {... [[Enumerable]] : false ...} + unless otherwise specified. This default applies to the properties on + JSON, and we should not be able to enumerate them. +es5id: 15.12-0-4 +description: JSON object's properties must be non enumerable +---*/ + +var o = JSON; +var i = 0; +for (var p in o) { + i++; +} + + +assert.sameValue(i, 0, 'i'); diff --git a/test/sendable/builtins/ASON/Symbol.toStringTag.js b/test/sendable/builtins/ASON/Symbol.toStringTag.js new file mode 100644 index 00000000000..1f521b04297 --- /dev/null +++ b/test/sendable/builtins/ASON/Symbol.toStringTag.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +es6id: 24.3.3 +description: > + `Symbol.toStringTag` property descriptor +info: | + The initial value of the @@toStringTag property is the String value + "JSON". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.toStringTag] +---*/ + +assert.sameValue(JSON[Symbol.toStringTag], 'JSON'); + +verifyNotEnumerable(JSON, Symbol.toStringTag); +verifyNotWritable(JSON, Symbol.toStringTag); +verifyConfigurable(JSON, Symbol.toStringTag); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-1.js new file mode 100644 index 00000000000..50dea92ecd0 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-1 +description: The JSON lexical grammar treats whitespace as a token seperator +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12\t\r\n 34'); // should produce a syntax error as whitespace results in two tokens +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-2.js new file mode 100644 index 00000000000..17d77b48a5b --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-2 +description: > + is not valid JSON whitespace as specified by the production + JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u000b1234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-3.js new file mode 100644 index 00000000000..4f64dc20b48 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-3 +description: > + is not valid JSON whitespace as specified by the production + JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u000c1234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-4.js new file mode 100644 index 00000000000..b0a57d78ff0 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-4.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-4 +description: > + is not valid JSON whitespace as specified by the production + JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u00a01234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-5.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-5.js new file mode 100644 index 00000000000..201a22e7703 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-5.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-5 +description: > + is not valid JSON whitespace as specified by the + production JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u200b1234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-6.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-6.js new file mode 100644 index 00000000000..b5a2e2a7b2f --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-6.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-6 +description: > + is not valid JSON whitespace as specified by the production + JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\ufeff1234'); // should produce a syntax error a +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-8.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-8.js new file mode 100644 index 00000000000..c37e2e39a35 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-8.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-8 +description: > + U+2028 and U+2029 are not valid JSON whitespace as specified by + the production JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u2028\u20291234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-9.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-9.js new file mode 100644 index 00000000000..6efca79868c --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-9.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-9 +description: Whitespace characters can appear before/after any JSONtoken +---*/ + +JSON.parseSendable('\t\r \n{\t\r \n' + + '"property"\t\r \n:\t\r \n{\t\r \n}\t\r \n,\t\r \n' + + '"prop2"\t\r \n:\t\r \n' + + '[\t\r \ntrue\t\r \n,\t\r \nnull\t\r \n,123.456\t\r \n]' + + '\t\r \n}\t\r \n'); // should JOSN parse without error diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g1-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-1.js new file mode 100644 index 00000000000..5ffb43c42ba --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g1-1 +description: The JSON lexical grammar treats as a whitespace character +---*/ + +assert.sameValue(JSON.parseSendable('\t1234'), 1234, ' should be ignored'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12\t34'); +}, ' should produce a syntax error as whitespace results in two tokens'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g1-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-2.js new file mode 100644 index 00000000000..616ce7a920d --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g1-2 +description: The JSON lexical grammar treats as a whitespace character +---*/ + +assert.sameValue(JSON.parseSendable('\r1234'), 1234, ' should be ignored'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12\r34'); +}, ' should produce a syntax error as whitespace results in two tokens'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g1-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-3.js new file mode 100644 index 00000000000..10e3d2e6651 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g1-3 +description: The JSON lexical grammar treats as a whitespace character +---*/ + +assert.sameValue(JSON.parseSendable('\n1234'), 1234, ' should be ignored'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12\n34'); +}, ' should produce a syntax error as whitespace results in two tokens'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g1-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-4.js new file mode 100644 index 00000000000..7036a2c6976 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-4.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g1-4 +description: The JSON lexical grammar treats as a whitespace character +---*/ + +assert.sameValue(JSON.parseSendable(' 1234'), 1234, ' should be ignored'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12 34'); +}, ' should produce a syntax error as whitespace results in two tokens'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-1.js new file mode 100644 index 00000000000..0b267f2b768 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-1.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-1 +description: JSONStrings can be written using double quotes +---*/ + +assert.sameValue(JSON.parseSendable('"abc"'), "abc", 'JSON.parseSendable(\'"abc"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-2.js new file mode 100644 index 00000000000..2e668977bc5 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-2.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-2 +description: A JSONString may not be delimited by single quotes +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable("'abc'"); +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-3.js new file mode 100644 index 00000000000..e669dcd42a7 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-3 +description: A JSONString may not be delimited by Uncode escaped quotes +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable("\\u0022abc\\u0022"); +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-4.js new file mode 100644 index 00000000000..70b5fb22e09 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-4.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-4 +description: A JSONString must both begin and end with double quotes +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"ab'+"c'"); +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-5.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-5.js new file mode 100644 index 00000000000..25e2ad16bd6 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-5.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-5 +description: > + A JSONStrings can contain no JSONStringCharacters (Empty + JSONStrings) +---*/ + +assert.sameValue(JSON.parseSendable('""'), "", 'JSON.parseSendable(\'""\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g4-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-1.js new file mode 100644 index 00000000000..90922377afb --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g4-1 +description: > + The JSON lexical grammar does not allow a JSONStringCharacter to + be any of the Unicode characters U+0000 thru U+0007 +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007"'); // invalid string characters should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g4-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-2.js new file mode 100644 index 00000000000..3d78b1713bd --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g4-2 +description: > + The JSON lexical grammar does not allow a JSONStringCharacter to + be any of the Unicode characters U+0008 thru U+000F +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\u0008\u0009\u000a\u000b\u000c\u000d\u000e\u000f"'); // invalid string characters should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g4-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-3.js new file mode 100644 index 00000000000..70666e48bbe --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g4-3 +description: > + The JSON lexical grammar does not allow a JSONStringCharacter to + be any of the Unicode characters U+0010 thru U+0017 +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017"'); // invalid string characters should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g4-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-4.js new file mode 100644 index 00000000000..15f0fa148ec --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-4.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g4-4 +description: > + The JSON lexical grammar does not allow a JSONStringCharacter to + be any of the Unicode characters U+0018 thru U+001F +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f"'); // invalid string characters should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g5-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-1.js new file mode 100644 index 00000000000..7c8956efc0f --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g5-1 +description: > + The JSON lexical grammar allows Unicode escape sequences in a + JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\u0058"'), 'X', 'JSON.parseSendable(\'"\\u0058"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g5-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-2.js new file mode 100644 index 00000000000..b0f26a5e5da --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g5-2 +description: > + A JSONStringCharacter UnicodeEscape may not have fewer than 4 hex + characters +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\\u005"') +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g5-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-3.js new file mode 100644 index 00000000000..39902df1e08 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g5-3 +description: > + A JSONStringCharacter UnicodeEscape may not include any non=hex + characters +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\\u0X50"') +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-1.js new file mode 100644 index 00000000000..f6c13053628 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-1 +description: > + The JSON lexical grammer allows '/' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\/"'), '/', 'JSON.parseSendable(\'"\\/"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-2.js new file mode 100644 index 00000000000..999f68dec57 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-2.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-2 +description: > + The JSON lexical grammer allows '' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\\\"'), '\\', 'JSON.parseSendable(\'"\\\\"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-3.js new file mode 100644 index 00000000000..1121b8279d1 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-3 +description: > + The JSON lexical grammer allows 'b' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\b"'), '\b', 'JSON.parseSendable(\'"\\b"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-4.js new file mode 100644 index 00000000000..ac68e632327 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-4.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-4 +description: > + The JSON lexical grammer allows 'f' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\f"'), '\f', 'JSON.parseSendable(\'"\\f"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-5.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-5.js new file mode 100644 index 00000000000..12ae29aa064 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-5.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-5 +description: > + The JSON lexical grammer allows 'n' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\n"'), '\n', 'JSON.parseSendable(\'"\\n"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-6.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-6.js new file mode 100644 index 00000000000..d2af48c9027 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-6.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-6 +description: > + The JSON lexical grammer allows 'r' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\r"'), '\r', 'JSON.parseSendable(\'"\\r"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-7.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-7.js new file mode 100644 index 00000000000..2694840cdd4 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-7.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-7 +description: > + The JSON lexical grammer allows 't' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\t"'), '\t', 'JSON.parseSendable(\'"\\t"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-1.js b/test/sendable/builtins/ASON/parse/15.12.2-2-1.js new file mode 100644 index 00000000000..f930df426b4 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-1.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-1 +description: > + JSON.parse - parsing an object where property name is a null + character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ ' + nullChars[index] + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-10.js b/test/sendable/builtins/ASON/parse/15.12.2-2-10.js new file mode 100644 index 00000000000..9d6fb44ae11 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-10.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-10 +description: > + JSON.parse - parsing an object where property value middles with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + "Jo" + nullChars[index] + "hn" + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-2.js b/test/sendable/builtins/ASON/parse/15.12.2-2-2.js new file mode 100644 index 00000000000..c186f556dc7 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-2.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-2 +description: > + JSON.parse - parsing an object where property name starts with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ ' + nullChars[index] + "name" + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-3.js b/test/sendable/builtins/ASON/parse/15.12.2-2-3.js new file mode 100644 index 00000000000..5378050c58d --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-3.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-3 +description: > + JSON.parse - parsing an object where property name ends with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{' + "name" + nullChars[index] + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-4.js b/test/sendable/builtins/ASON/parse/15.12.2-2-4.js new file mode 100644 index 00000000000..b382455ca13 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-4.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-4 +description: > + JSON.parse - parsing an object where property name starts and ends + with a null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{' + nullChars[index] + "name" + nullChars[index] + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-5.js b/test/sendable/builtins/ASON/parse/15.12.2-2-5.js new file mode 100644 index 00000000000..4364a4757f1 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-5.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-5 +description: > + JSON.parse - parsing an object where property name middles with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ ' + "na" + nullChars[index] + "me" + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-6.js b/test/sendable/builtins/ASON/parse/15.12.2-2-6.js new file mode 100644 index 00000000000..8cf76e5d294 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-6.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-6 +description: > + JSON.parse - parsing an object where property value is a null + character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + nullChars[index] + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-7.js b/test/sendable/builtins/ASON/parse/15.12.2-2-7.js new file mode 100644 index 00000000000..70c8283e19b --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-7.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-7 +description: > + JSON.parse - parsing an object where property value starts with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + nullChars[index] + "John" + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-8.js b/test/sendable/builtins/ASON/parse/15.12.2-2-8.js new file mode 100644 index 00000000000..c3abc56c3d4 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-8.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-8 +description: > + JSON.parse - parsing an object where property value ends with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + "John" + nullChars[index] + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-9.js b/test/sendable/builtins/ASON/parse/15.12.2-2-9.js new file mode 100644 index 00000000000..7a4e6633618 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-9.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-9 +description: > + JSON.parse - parsing an object where property value starts and + ends with a null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + nullChars[index] + "John" + nullChars[index] + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/S15.12.2_A1.js b/test/sendable/builtins/ASON/parse/S15.12.2_A1.js new file mode 100644 index 00000000000..c3ea45ad889 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/S15.12.2_A1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: JSON.parse must create a property with the given property name +es5id: 15.12.2_A1 +description: Tests that JSON.parse treats "__proto__" as a regular property name +---*/ + +var x = JSON.parseSendable('{"__proto__":[]}'); + +assert.sameValue( + Object.getPrototypeOf(x), + Object.prototype, + 'Object.getPrototypeOf("JSON.parseSendable(\'{"__proto__":[]}\')") returns Object.prototype' +); + +assert(Array.isArray(x.__proto__), 'Array.isArray(x.__proto__) must return true'); diff --git a/test/sendable/builtins/ASON/parse/invalid-whitespace.js b/test/sendable/builtins/ASON/parse/invalid-whitespace.js new file mode 100644 index 00000000000..b65c52f5d03 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/invalid-whitespace.js @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-json.parse +es5id: 15.12.1.1-0-7 +description: > + other category z spaces are not valid JSON whitespace as specified + by the production JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u16801'); +}, '\\u1680'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u180e1'); +}, '\\u180e'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20001'); +}, '\\u2000'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20011'); +}, '\\u2001'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20021'); +}, '\\u2002'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20031'); +}, '\\u2003'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20041'); +}, '\\u2004'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20051'); +}, '\\u2005'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20061'); +}, '\\u2006'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20071'); +}, '\\u2007'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20081'); +}, '\\u2008'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20091'); +}, '\\u2009'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u200a1'); +}, '\\u200a'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u202f1'); +}, '\\u202f'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u205f1'); +}, '\\u205f'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u30001'); +}, '\\u3000'); diff --git a/test/sendable/builtins/ASON/stringify/value-bigint-cross-realm.js b/test/sendable/builtins/ASON/stringify/value-bigint-cross-realm.js new file mode 100644 index 00000000000..123d728f29d --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-bigint-cross-realm.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-serializejsonproperty +description: JSON.stringify called with a BigInt object from another realm +features: [BigInt, cross-realm] +---*/ + +var other = $262.createRealm().global; +var wrapped = other.Object(other.BigInt(100)); + +assert.throws(TypeError, () => JSON.stringify(wrapped), + "cross-realm BigInt object without toJSON method"); + +other.BigInt.prototype.toJSON = function () { return this.toString(); }; + +assert.sameValue(JSON.stringify(wrapped), "\"100\"", + "cross-realm BigInt object with toJSON method"); diff --git a/test/sendable/builtins/ASON/stringify/value-bigint-order.js b/test/sendable/builtins/ASON/stringify/value-bigint-order.js new file mode 100644 index 00000000000..253986e5069 --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-bigint-order.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: BigInt stringify order of steps +esid: sec-serializejsonproperty +info: | + Runtime Semantics: SerializeJSONProperty ( key, holder ) + + 2. If Type(value) is Object or BigInt, then + a. Let toJSON be ? GetGetV(value, "toJSON"). + b. If IsCallable(toJSON) is true, then + i. Set value to ? Call(toJSON, value, « key »). + 3. If ReplacerFunction is not undefined, then + a. Set value to ? Call(ReplacerFunction, holder, « key, value »). + 4. If Type(value) is Object, then + [...] + d. Else if value has a [[BigIntData]] internal slot, then + i. Set value to value.[[BigIntData]]. + [...] + 10. If Type(value) is BigInt, throw a TypeError exception +features: [BigInt, arrow-function] +---*/ + +let step; + +function replacer(x, k, v) +{ + assert.sameValue(step++, 1); + assert.sameValue(v, 1n); + return x; +} + +BigInt.prototype.toJSON = function () { assert.sameValue(step++, 0); return 1n; }; + +step = 0; +assert.throws(TypeError, () => JSON.stringify(0n, (k, v) => replacer(2n, k, v))); +assert.sameValue(step, 2); + +step = 0; +assert.throws(TypeError, () => JSON.stringify(0n, (k, v) => replacer(Object(2n), k, v))); +assert.sameValue(step, 2); diff --git a/test/sendable/builtins/ASON/stringify/value-bigint-replacer.js b/test/sendable/builtins/ASON/stringify/value-bigint-replacer.js new file mode 100644 index 00000000000..3213f22f8e9 --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-bigint-replacer.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: JSON serialization of BigInt values with replacer +esid: sec-serializejsonproperty +info: | + Runtime Semantics: SerializeJSONProperty ( key, holder ) + + 3. If ReplacerFunction is not undefined, then + a. Set value to ? Call(ReplacerFunction, holder, « key, value »). +features: [BigInt] +---*/ + +function replacer(k, v) +{ + if (typeof v === "bigint") + return "bigint"; + else + return v; +} + +assert.sameValue(JSON.stringify(0n, replacer), '"bigint"'); +assert.sameValue(JSON.stringify({x: 0n}, replacer), '{"x":"bigint"}'); diff --git a/test/sendable/builtins/ASON/stringify/value-bigint.js b/test/sendable/builtins/ASON/stringify/value-bigint.js new file mode 100644 index 00000000000..1170ebe057b --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-bigint.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: JSON serialization of BigInt values +esid: pending +features: [BigInt] +---*/ + +assert.throws(TypeError, () => JSON.stringify(0n)); +assert.throws(TypeError, () => JSON.stringify(Object(0n))); +assert.throws(TypeError, () => JSON.stringify({x: 0n})); diff --git a/test/sendable/builtins/ASON/stringify/value-string-escape-unicode.js b/test/sendable/builtins/ASON/stringify/value-string-escape-unicode.js new file mode 100644 index 00000000000..67d77a18d46 --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-string-escape-unicode.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-quotejsonstring +description: > + JSON.stringify strings containing surrogate code units +features: [well-formed-json-stringify] +---*/ + +assert.sameValue(JSON.stringify("\uD834"), '"\\ud834"', + 'JSON.stringify("\\uD834")'); +assert.sameValue(JSON.stringify("\uDF06"), '"\\udf06"', + 'JSON.stringify("\\uDF06")'); + +assert.sameValue(JSON.stringify("\uD834\uDF06"), '"𝌆"', + 'JSON.stringify("\\uD834\\uDF06")'); +assert.sameValue(JSON.stringify("\uD834\uD834\uDF06\uD834"), '"\\ud834𝌆\\ud834"', + 'JSON.stringify("\\uD834\\uD834\\uDF06\\uD834")'); +assert.sameValue(JSON.stringify("\uD834\uD834\uDF06\uDF06"), '"\\ud834𝌆\\udf06"', + 'JSON.stringify("\\uD834\\uD834\\uDF06\\uDF06")'); +assert.sameValue(JSON.stringify("\uDF06\uD834\uDF06\uD834"), '"\\udf06𝌆\\ud834"', + 'JSON.stringify("\\uDF06\\uD834\\uDF06\\uD834")'); +assert.sameValue(JSON.stringify("\uDF06\uD834\uDF06\uDF06"), '"\\udf06𝌆\\udf06"', + 'JSON.stringify("\\uDF06\\uD834\\uDF06\\uDF06")'); + +assert.sameValue(JSON.stringify("\uDF06\uD834"), '"\\udf06\\ud834"', + 'JSON.stringify("\\uDF06\\uD834")'); +assert.sameValue(JSON.stringify("\uD834\uDF06\uD834\uD834"), '"𝌆\\ud834\\ud834"', + 'JSON.stringify("\\uD834\\uDF06\\uD834\\uD834")'); +assert.sameValue(JSON.stringify("\uD834\uDF06\uD834\uDF06"), '"𝌆𝌆"', + 'JSON.stringify("\\uD834\\uDF06\\uD834\\uDF06")'); +assert.sameValue(JSON.stringify("\uDF06\uDF06\uD834\uD834"), '"\\udf06\\udf06\\ud834\\ud834"', + 'JSON.stringify("\\uDF06\\uDF06\\uD834\\uD834")'); +assert.sameValue(JSON.stringify("\uDF06\uDF06\uD834\uDF06"), '"\\udf06\\udf06𝌆"', + 'JSON.stringify("\\uDF06\\uDF06\\uD834\\uDF06")'); diff --git a/test/sendable/builtins/Array/from/from-array.js b/test/sendable/builtins/Array/from/from-array.js new file mode 100644 index 00000000000..cf92a3b2a7b --- /dev/null +++ b/test/sendable/builtins/Array/from/from-array.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: Passing a valid array +esid: sec-array.from +---*/ + +var array = [0, 'foo', , Infinity]; +var result = SendableArray.from(array); + +assert.sameValue(result.length, 4, 'The value of result.length is expected to be 4'); +assert.sameValue(result[0], 0, 'The value of result[0] is expected to be 0'); +assert.sameValue(result[1], 'foo', 'The value of result[1] is expected to be "foo"'); +assert.sameValue(result[2], undefined, 'The value of result[2] is expected to equal undefined'); +assert.sameValue(result[3], Infinity, 'The value of result[3] is expected to equal Infinity'); + +assert.notSameValue( + result, array, + 'The value of result is expected to not equal the value of `array`' +); + +assert(result instanceof SendableArray, 'The result of evaluating (result instanceof Array) is expected to be true'); diff --git a/test262/data/package.json b/test262/data/package.json new file mode 100644 index 00000000000..faa769dd7c7 --- /dev/null +++ b/test262/data/package.json @@ -0,0 +1,31 @@ +{ + "name": "test262", + "version": "5.0.0", + "description": "Test262 tests conformance to the continually maintained draft future ECMAScript standard found at http://tc39.github.io/ecma262/ , together with any Stage 3 or later TC39 proposals.", + "repository": { + "type": "git", + "url": "git+https://github.com/tc39/test262.git" + }, + "license": "BSD", + "bugs": { + "url": "https://github.com/tc39/test262/issues" + }, + "private": true, + "homepage": "https://github.com/tc39/test262#readme", + "devDependencies": { + "esvu": "^1.2.11", + "test262-harness": "^8.0.0" + }, + "scripts": { + "ci": "./tools/scripts/ci_test.sh", + "test": "test262-harness", + "diff": "git diff --diff-filter ACMR --name-only main.. -- test/ && git ls-files --exclude-standard --others -- test/", + "test:diff": "npm run test:diff:v8 && npm run test:diff:spidermonkey && npm run test:diff:chakra && npm run test:diff:javascriptcore", + "test:diff:v8": "test262-harness -t 8 --hostType=d8 --hostPath=v8 $(npm run --silent diff)", + "test:diff:spidermonkey": "test262-harness -t 8 --hostType=jsshell --hostPath=spidermonkey $(npm run --silent diff)", + "test:diff:chakra": "test262-harness -t 8 --hostType=ch --hostPath=chakra $(npm run --silent diff)", + "test:diff:javascriptcore": "test262-harness -t 8 --hostType=jsc --hostPath=javascriptcore $(npm run --silent diff)", + "test:diff:xs": "test262-harness -t 8 --hostType=xs --hostPath=xs $(npm run --silent diff)" + } +} + -- Gitee From 97a7d634d450f39b613326cdfae05bee54d9e8cb Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 10 Dec 2024 10:15:41 +0800 Subject: [PATCH 03/93] https://gitee.com/ark_standalone_build/test262_sendable to https://gitee.com/ark_compiler_sendable/test262_sendable change add new cases Signed-off-by: zhuzhihui7 --- LICENSE | 2 +- README.en.md | 14 + README.md | 14 + harness/assert.js | 130 + harness/assertRelativeDateMs.js | 37 + harness/async-gc.js | 69 + harness/asyncHelpers.js | 123 + harness/atomicsHelper.js | 336 +++ harness/byteConversionValues.js | 458 +++ harness/compareArray.js | 62 + harness/compareIterator.js | 47 + harness/dateConstants.js | 41 + harness/decimalToHexString.js | 38 + harness/deepEqual.js | 339 +++ harness/detachArrayBuffer.js | 28 + harness/doneprintHandle.js | 34 + harness/features.yml | 6 + harness/fnGlobalObject.js | 24 + harness/hidden-constructors.js | 29 + harness/isConstructor.js | 34 + harness/nans.js | 34 + harness/nativeFunctionMatcher.js | 232 ++ harness/promiseHelper.js | 87 + harness/propertyHelper.js | 266 ++ harness/proxyTrapsHelper.js | 43 + harness/regExpUtils.js | 123 + harness/sta.js | 39 + harness/tcoHelper.js | 26 + harness/temporalHelpers.js | 2086 ++++++++++++++ harness/testAtomics.js | 135 + harness/testBigIntTypedArray.js | 52 + harness/testIntl.js | 2510 +++++++++++++++++ harness/testTypedArray.js | 134 + harness/timer.js | 42 + harness/typeCoercion.js | 463 +++ harness/wellKnownIntrinsicObjects.js | 302 ++ package.json | 31 + test/sendable/builtins/ASON/15.12-0-1.js | 27 + test/sendable/builtins/ASON/15.12-0-2.js | 28 + test/sendable/builtins/ASON/15.12-0-3.js | 28 + test/sendable/builtins/ASON/15.12-0-4.js | 34 + .../builtins/ASON/Symbol.toStringTag.js | 33 + .../builtins/ASON/parse/15.12.1.1-0-1.js | 23 + .../builtins/ASON/parse/15.12.1.1-0-2.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-3.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-4.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-5.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-6.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-8.js | 25 + .../builtins/ASON/parse/15.12.1.1-0-9.js | 25 + .../builtins/ASON/parse/15.12.1.1-g1-1.js | 25 + .../builtins/ASON/parse/15.12.1.1-g1-2.js | 25 + .../builtins/ASON/parse/15.12.1.1-g1-3.js | 25 + .../builtins/ASON/parse/15.12.1.1-g1-4.js | 25 + .../builtins/ASON/parse/15.12.1.1-g2-1.js | 21 + .../builtins/ASON/parse/15.12.1.1-g2-2.js | 23 + .../builtins/ASON/parse/15.12.1.1-g2-3.js | 23 + .../builtins/ASON/parse/15.12.1.1-g2-4.js | 23 + .../builtins/ASON/parse/15.12.1.1-g2-5.js | 23 + .../builtins/ASON/parse/15.12.1.1-g4-1.js | 25 + .../builtins/ASON/parse/15.12.1.1-g4-2.js | 25 + .../builtins/ASON/parse/15.12.1.1-g4-3.js | 25 + .../builtins/ASON/parse/15.12.1.1-g4-4.js | 25 + .../builtins/ASON/parse/15.12.1.1-g5-1.js | 23 + .../builtins/ASON/parse/15.12.1.1-g5-2.js | 25 + .../builtins/ASON/parse/15.12.1.1-g5-3.js | 25 + .../builtins/ASON/parse/15.12.1.1-g6-1.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-2.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-3.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-4.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-5.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-6.js | 23 + .../builtins/ASON/parse/15.12.1.1-g6-7.js | 23 + .../builtins/ASON/parse/15.12.2-2-1.js | 61 + .../builtins/ASON/parse/15.12.2-2-10.js | 61 + .../builtins/ASON/parse/15.12.2-2-2.js | 61 + .../builtins/ASON/parse/15.12.2-2-3.js | 61 + .../builtins/ASON/parse/15.12.2-2-4.js | 61 + .../builtins/ASON/parse/15.12.2-2-5.js | 61 + .../builtins/ASON/parse/15.12.2-2-6.js | 61 + .../builtins/ASON/parse/15.12.2-2-7.js | 61 + .../builtins/ASON/parse/15.12.2-2-8.js | 61 + .../builtins/ASON/parse/15.12.2-2-9.js | 61 + .../builtins/ASON/parse/S15.12.2_A1.js | 30 + .../builtins/ASON/parse/invalid-whitespace.js | 86 + .../stringify/value-bigint-cross-realm.js | 31 + .../ASON/stringify/value-bigint-order.js | 54 + .../ASON/stringify/value-bigint-replacer.js | 36 + .../builtins/ASON/stringify/value-bigint.js | 24 + .../stringify/value-string-escape-unicode.js | 48 + test/sendable/builtins/Array/from/TC001.js | 30 + test/sendable/builtins/Array/from/TC002.js | 45 + test/sendable/builtins/Array/from/TC003.js | 29 + test/sendable/builtins/Array/from/TC004.js | 24 + test/sendable/builtins/Array/from/TC005.js | 34 + test/sendable/builtins/Array/from/TC006.js | 42 + test/sendable/builtins/Array/from/TC007.js | 67 + test/sendable/builtins/Array/from/TC008.js | 67 + test/sendable/builtins/Array/from/TC009.js | 67 + test/sendable/builtins/Array/from/TC010.js | 44 + test/sendable/builtins/Array/from/TC011.js | 37 + test/sendable/builtins/Array/from/TC012.js | 37 + test/sendable/builtins/Array/from/TC013.js | 25 + test/sendable/builtins/Array/from/TC014.js | 31 + test/sendable/builtins/Array/from/TC015.js | 25 + test/sendable/builtins/Array/from/TC016.js | 25 + test/sendable/builtins/Array/from/TC017.js | 36 + test/sendable/builtins/Array/from/TC018.js | 35 + test/sendable/builtins/Array/from/TC019.js | 56 + test/sendable/builtins/Array/from/TC020.js | 30 + test/sendable/builtins/Array/from/TC021.js | 41 + test/sendable/builtins/Array/from/TC022.js | 72 + test/sendable/builtins/Array/from/TC023.js | 48 + test/sendable/builtins/Array/from/TC024.js | 73 + test/sendable/builtins/Array/from/TC025.js | 60 + test/sendable/builtins/Array/from/TC026.js | 63 + test/sendable/builtins/Array/from/TC027.js | 60 + test/sendable/builtins/Array/from/TC028.js | 55 + test/sendable/builtins/Array/from/TC029.js | 45 + test/sendable/builtins/Array/from/TC030.js | 61 + test/sendable/builtins/Array/from/TC031.js | 44 + test/sendable/builtins/Array/from/TC032.js | 50 + test/sendable/builtins/Array/from/TC033.js | 38 + test/sendable/builtins/Array/from/TC034.js | 28 + test/sendable/builtins/Array/from/TC035.js | 26 + test/sendable/builtins/Array/from/TC036.js | 34 + test/sendable/builtins/Array/from/TC037.js | 37 + test/sendable/builtins/Array/from/TC038.js | 33 + test/sendable/builtins/Array/from/TC039.js | 24 + test/sendable/builtins/Array/from/TC040.js | 41 + test/sendable/builtins/Array/from/TC041.js | 46 + test/sendable/builtins/Array/from/TC042.js | 49 + test/sendable/builtins/Array/from/TC043.js | 48 + test/sendable/builtins/Array/from/TC044.js | 34 + test/sendable/builtins/Array/from/TC045.js | 29 + test/sendable/builtins/Array/from/TC046.js | 25 + test/sendable/builtins/Array/from/TC047.js | 21 + test262/data/package.json | 31 + 138 files changed, 12285 insertions(+), 1 deletion(-) create mode 100644 harness/assert.js create mode 100644 harness/assertRelativeDateMs.js create mode 100644 harness/async-gc.js create mode 100644 harness/asyncHelpers.js create mode 100644 harness/atomicsHelper.js create mode 100644 harness/byteConversionValues.js create mode 100644 harness/compareArray.js create mode 100644 harness/compareIterator.js create mode 100644 harness/dateConstants.js create mode 100644 harness/decimalToHexString.js create mode 100644 harness/deepEqual.js create mode 100644 harness/detachArrayBuffer.js create mode 100644 harness/doneprintHandle.js create mode 100644 harness/features.yml create mode 100644 harness/fnGlobalObject.js create mode 100644 harness/hidden-constructors.js create mode 100644 harness/isConstructor.js create mode 100644 harness/nans.js create mode 100644 harness/nativeFunctionMatcher.js create mode 100644 harness/promiseHelper.js create mode 100644 harness/propertyHelper.js create mode 100644 harness/proxyTrapsHelper.js create mode 100644 harness/regExpUtils.js create mode 100644 harness/sta.js create mode 100644 harness/tcoHelper.js create mode 100644 harness/temporalHelpers.js create mode 100644 harness/testAtomics.js create mode 100644 harness/testBigIntTypedArray.js create mode 100644 harness/testIntl.js create mode 100644 harness/testTypedArray.js create mode 100644 harness/timer.js create mode 100644 harness/typeCoercion.js create mode 100644 harness/wellKnownIntrinsicObjects.js create mode 100644 package.json create mode 100644 test/sendable/builtins/ASON/15.12-0-1.js create mode 100644 test/sendable/builtins/ASON/15.12-0-2.js create mode 100644 test/sendable/builtins/ASON/15.12-0-3.js create mode 100644 test/sendable/builtins/ASON/15.12-0-4.js create mode 100644 test/sendable/builtins/ASON/Symbol.toStringTag.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-5.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-6.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-8.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-0-9.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g1-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g1-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g1-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g1-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g2-5.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g4-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g4-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g4-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g4-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g5-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g5-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g5-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-5.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-6.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.1.1-g6-7.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-1.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-10.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-2.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-3.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-4.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-5.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-6.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-7.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-8.js create mode 100644 test/sendable/builtins/ASON/parse/15.12.2-2-9.js create mode 100644 test/sendable/builtins/ASON/parse/S15.12.2_A1.js create mode 100644 test/sendable/builtins/ASON/parse/invalid-whitespace.js create mode 100644 test/sendable/builtins/ASON/stringify/value-bigint-cross-realm.js create mode 100644 test/sendable/builtins/ASON/stringify/value-bigint-order.js create mode 100644 test/sendable/builtins/ASON/stringify/value-bigint-replacer.js create mode 100644 test/sendable/builtins/ASON/stringify/value-bigint.js create mode 100644 test/sendable/builtins/ASON/stringify/value-string-escape-unicode.js create mode 100644 test/sendable/builtins/Array/from/TC001.js create mode 100644 test/sendable/builtins/Array/from/TC002.js create mode 100644 test/sendable/builtins/Array/from/TC003.js create mode 100644 test/sendable/builtins/Array/from/TC004.js create mode 100644 test/sendable/builtins/Array/from/TC005.js create mode 100644 test/sendable/builtins/Array/from/TC006.js create mode 100644 test/sendable/builtins/Array/from/TC007.js create mode 100644 test/sendable/builtins/Array/from/TC008.js create mode 100644 test/sendable/builtins/Array/from/TC009.js create mode 100644 test/sendable/builtins/Array/from/TC010.js create mode 100644 test/sendable/builtins/Array/from/TC011.js create mode 100644 test/sendable/builtins/Array/from/TC012.js create mode 100644 test/sendable/builtins/Array/from/TC013.js create mode 100644 test/sendable/builtins/Array/from/TC014.js create mode 100644 test/sendable/builtins/Array/from/TC015.js create mode 100644 test/sendable/builtins/Array/from/TC016.js create mode 100644 test/sendable/builtins/Array/from/TC017.js create mode 100644 test/sendable/builtins/Array/from/TC018.js create mode 100644 test/sendable/builtins/Array/from/TC019.js create mode 100644 test/sendable/builtins/Array/from/TC020.js create mode 100644 test/sendable/builtins/Array/from/TC021.js create mode 100644 test/sendable/builtins/Array/from/TC022.js create mode 100644 test/sendable/builtins/Array/from/TC023.js create mode 100644 test/sendable/builtins/Array/from/TC024.js create mode 100644 test/sendable/builtins/Array/from/TC025.js create mode 100644 test/sendable/builtins/Array/from/TC026.js create mode 100644 test/sendable/builtins/Array/from/TC027.js create mode 100644 test/sendable/builtins/Array/from/TC028.js create mode 100644 test/sendable/builtins/Array/from/TC029.js create mode 100644 test/sendable/builtins/Array/from/TC030.js create mode 100644 test/sendable/builtins/Array/from/TC031.js create mode 100644 test/sendable/builtins/Array/from/TC032.js create mode 100644 test/sendable/builtins/Array/from/TC033.js create mode 100644 test/sendable/builtins/Array/from/TC034.js create mode 100644 test/sendable/builtins/Array/from/TC035.js create mode 100644 test/sendable/builtins/Array/from/TC036.js create mode 100644 test/sendable/builtins/Array/from/TC037.js create mode 100644 test/sendable/builtins/Array/from/TC038.js create mode 100644 test/sendable/builtins/Array/from/TC039.js create mode 100644 test/sendable/builtins/Array/from/TC040.js create mode 100644 test/sendable/builtins/Array/from/TC041.js create mode 100644 test/sendable/builtins/Array/from/TC042.js create mode 100644 test/sendable/builtins/Array/from/TC043.js create mode 100644 test/sendable/builtins/Array/from/TC044.js create mode 100644 test/sendable/builtins/Array/from/TC045.js create mode 100644 test/sendable/builtins/Array/from/TC046.js create mode 100644 test/sendable/builtins/Array/from/TC047.js create mode 100644 test262/data/package.json diff --git a/LICENSE b/LICENSE index 29f81d812f3..c9db8b287c9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ Apache License - Version 2.0, January 2004 + Version 2.0, January 2024 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION diff --git a/README.en.md b/README.en.md index 37e4cb93c14..e4013df8392 100644 --- a/README.en.md +++ b/README.en.md @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ # test262_sendable #### Description diff --git a/README.md b/README.md index 3462fb7652b..8bd8055c06f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,17 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ # test262_sendable #### 介绍 diff --git a/harness/assert.js b/harness/assert.js new file mode 100644 index 00000000000..c3373464f08 --- /dev/null +++ b/harness/assert.js @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of assertion functions used throughout test262 +defines: [assert] +---*/ + + +function assert(mustBeTrue, message) { + if (mustBeTrue === true) { + return; + } + + if (message === undefined) { + message = 'Expected true but got ' + assert._toString(mustBeTrue); + } + throw new Test262Error(message); +} + +assert._isSameValue = function (a, b) { + if (a === b) { + // Handle +/-0 vs. -/+0 + return a !== 0 || 1 / a === 1 / b; + } + + // Handle NaN vs. NaN + return a !== a && b !== b; +}; + +assert.sameValue = function (actual, expected, message) { + try { + if (assert._isSameValue(actual, expected)) { + return; + } + } catch (error) { + throw new Test262Error(message + ' (_isSameValue operation threw) ' + error); + return; + } + + if (message === undefined) { + message = ''; + } else { + message += ' '; + } + + message += 'Expected SameValue(«' + assert._toString(actual) + '», «' + assert._toString(expected) + '») to be true'; + + throw new Test262Error(message); +}; + +assert.notSameValue = function (actual, unexpected, message) { + if (!assert._isSameValue(actual, unexpected)) { + return; + } + + if (message === undefined) { + message = ''; + } else { + message += ' '; + } + + message += 'Expected SameValue(«' + assert._toString(actual) + '», «' + assert._toString(unexpected) + '») to be false'; + + throw new Test262Error(message); +}; + +assert.throws = function (expectedErrorConstructor, func, message) { + var expectedName, actualName; + if (typeof func !== "function") { + throw new Test262Error('assert.throws requires two arguments: the error constructor ' + + 'and a function to run'); + return; + } + if (message === undefined) { + message = ''; + } else { + message += ' '; + } + + try { + func(); + } catch (thrown) { + if (typeof thrown !== 'object' || thrown === null) { + message += 'Thrown value was not an object!'; + throw new Test262Error(message); + } else if (thrown.constructor !== expectedErrorConstructor) { + expectedName = expectedErrorConstructor.name; + actualName = thrown.constructor.name; + if (expectedName === actualName) { + message += 'Expected a ' + expectedName + ' but got a different error constructor with the same name'; + } else { + message += 'Expected a ' + expectedName + ' but got a ' + actualName; + } + throw new Test262Error(message); + } + return; + } + + message += 'Expected a ' + expectedErrorConstructor.name + ' to be thrown but no exception was thrown at all'; + throw new Test262Error(message); +}; + +assert._toString = function (value) { + try { + if (value === 0 && 1 / value === -Infinity) { + return '-0'; + } + + return String(value); + } catch (err) { + if (err.name === 'TypeError') { + return Object.prototype.toString.call(value); + } + + throw err; + } +}; diff --git a/harness/assertRelativeDateMs.js b/harness/assertRelativeDateMs.js new file mode 100644 index 00000000000..eda726eb9fa --- /dev/null +++ b/harness/assertRelativeDateMs.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Verify that the given date object's Number representation describes the + correct number of milliseconds since the Unix epoch relative to the local + time zone (as interpreted at the specified date). +defines: [assertRelativeDateMs] +---*/ + +/** + * @param {Date} date + * @param {Number} expectedMs + */ +function assertRelativeDateMs(date, expectedMs) { + var actualMs = date.valueOf(); + var localOffset = date.getTimezoneOffset() * 60000; + + if (actualMs - localOffset !== expectedMs) { + throw new Test262Error( + 'Expected ' + date + ' to be ' + expectedMs + + ' milliseconds from the Unix epoch' + ); + } +} diff --git a/harness/async-gc.js b/harness/async-gc.js new file mode 100644 index 00000000000..87a4a3e73fd --- /dev/null +++ b/harness/async-gc.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Collection of functions used to capture references cleanup from garbage collectors +features: [FinalizationRegistry.prototype.cleanupSome, FinalizationRegistry, Symbol, async-functions] +flags: [non-deterministic] +defines: [asyncGC, asyncGCDeref, resolveAsyncGC] +---*/ + +function asyncGC(...targets) { + var finalizationRegistry = new FinalizationRegistry(() => {}); + var length = targets.length; + + for (let target of targets) { + finalizationRegistry.register(target, 'target'); + target = null; + } + + targets = null; + + return Promise.resolve('tick').then(() => asyncGCDeref()).then(() => { + var names = []; + + // consume iterator to capture names + finalizationRegistry.cleanupSome(name => { names.push(name); }); + + if (!names || names.length != length) { + throw asyncGC.notCollected; + } + }); +} + +asyncGC.notCollected = Symbol('Object was not collected'); + +async function asyncGCDeref() { + var trigger; + + // TODO: Remove this when $262.clearKeptObject becomes documented and required + if ($262.clearKeptObjects) { + trigger = $262.clearKeptObjects(); + } + + await $262.gc(); + + return Promise.resolve(trigger); +} + +function resolveAsyncGC(err) { + if (err === asyncGC.notCollected) { + // Do not fail as GC can't provide necessary resources. + $DONE(); + return; + } + + $DONE(err); +} diff --git a/harness/asyncHelpers.js b/harness/asyncHelpers.js new file mode 100644 index 00000000000..9f48fa5a508 --- /dev/null +++ b/harness/asyncHelpers.js @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + A collection of assertion and wrapper functions for testing asynchronous built-ins. +defines: [asyncTest] +---*/ + +function asyncTest(testFunc) { + if (!Object.hasOwn(globalThis, "$DONE")) { + throw new Test262Error("asyncTest called without async flag"); + } + if (typeof testFunc !== "function") { + $DONE(new Test262Error("asyncTest called with non-function argument")); + return; + } + try { + testFunc().then( + function () { + $DONE(); + }, + function (error) { + $DONE(error); + } + ); + } catch (syncError) { + $DONE(syncError); + } +} + +assert.throwsAsync = async function (expectedErrorConstructor, func, message) { + var innerThenable; + if (message === undefined) { + message = ""; + } else { + message += " "; + } + if (typeof func === "function") { + try { + innerThenable = func(); + if ( + innerThenable === null || + typeof innerThenable !== "object" || + typeof innerThenable.then !== "function" + ) { + message += + "Expected to obtain an inner promise that would reject with a" + + expectedErrorConstructor.name + + " but result was not a thenable"; + throw new Test262Error(message); + } + } catch (thrown) { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but an exception was thrown synchronously while obtaining the inner promise"; + throw new Test262Error(message); + } + } else { + message += + "assert.throwsAsync called with an argument that is not a function"; + throw new Test262Error(message); + } + + try { + return innerThenable.then( + function () { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but no exception was thrown at all"; + throw new Test262Error(message); + }, + function (thrown) { + var expectedName, actualName; + if (typeof thrown !== "object" || thrown === null) { + message += "Thrown value was not an object!"; + throw new Test262Error(message); + } else if (thrown.constructor !== expectedErrorConstructor) { + expectedName = expectedErrorConstructor.name; + actualName = thrown.constructor.name; + if (expectedName === actualName) { + message += + "Expected a " + + expectedName + + " but got a different error constructor with the same name"; + } else { + message += + "Expected a " + expectedName + " but got a " + actualName; + } + throw new Test262Error(message); + } + } + ); + } catch (thrown) { + if (typeof thrown !== "object" || thrown === null) { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but innerThenable synchronously threw a value that was not an object "; + } else { + message += + "Expected a " + + expectedErrorConstructor.name + + " to be thrown asynchronously but a " + + thrown.constructor.name + + " was thrown synchronously"; + } + throw new Test262Error(message); + } +}; diff --git a/harness/atomicsHelper.js b/harness/atomicsHelper.js new file mode 100644 index 00000000000..761fee87c87 --- /dev/null +++ b/harness/atomicsHelper.js @@ -0,0 +1,336 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Collection of functions used to interact with Atomics.* operations across agent boundaries. +defines: + - $262.agent.getReportAsync + - $262.agent.getReport + - $262.agent.safeBroadcastAsync + - $262.agent.safeBroadcast + - $262.agent.setTimeout + - $262.agent.tryYield + - $262.agent.trySleep +---*/ + +/** + * @return {String} A report sent from an agent. + */ +{ + // This is only necessary because the original + // $262.agent.getReport API was insufficient. + // + // All runtimes currently have their own + // $262.agent.getReport which is wrong, so we + // will pave over it with a corrected version. + // + // Binding $262.agent is necessary to prevent + // breaking SpiderMonkey's $262.agent.getReport + let getReport = $262.agent.getReport.bind($262.agent); + + $262.agent.getReport = function() { + var r; + while ((r = getReport()) == null) { + $262.agent.sleep(1); + } + return r; + }; + + if (this.setTimeout === undefined) { + (function(that) { + that.setTimeout = function(callback, delay) { + let p = Promise.resolve(); + let start = Date.now(); + let end = start + delay; + function check() { + if ((end - Date.now()) > 0) { + p.then(check); + } + else { + callback(); + } + } + p.then(check); + } + })(this); + } + + $262.agent.setTimeout = setTimeout; + + $262.agent.getReportAsync = function() { + return new Promise(function(resolve) { + (function loop() { + let result = getReport(); + if (!result) { + setTimeout(loop, 1000); + } else { + resolve(result); + } + })(); + }); + }; +} + +/** + * + * Share a given Int32Array or BigInt64Array to all running agents. Ensure that the + * provided TypedArray is a "shared typed array". + * + * NOTE: Migrating all tests to this API is necessary to prevent tests from hanging + * indefinitely when a SAB is sent to a worker but the code in the worker attempts to + * create a non-sharable TypedArray (something that is not Int32Array or BigInt64Array). + * When that scenario occurs, an exception is thrown and the agent worker can no + * longer communicate with any other threads that control the SAB. If the main + * thread happens to be spinning in the $262.agent.waitUntil() while loop, it will never + * meet its termination condition and the test will hang indefinitely. + * + * Because we've defined $262.agent.broadcast(SAB) in + * https://github.com/tc39/test262/blob/HEAD/INTERPRETING.md, there are host implementations + * that assume compatibility, which must be maintained. + * + * + * $262.agent.safeBroadcast(TA) should not be included in + * https://github.com/tc39/test262/blob/HEAD/INTERPRETING.md + * + * + * @param {(Int32Array|BigInt64Array)} typedArray An Int32Array or BigInt64Array with a SharedArrayBuffer + */ +$262.agent.safeBroadcast = function(typedArray) { + let Constructor = Object.getPrototypeOf(typedArray).constructor; + let temp = new Constructor( + new SharedArrayBuffer(Constructor.BYTES_PER_ELEMENT) + ); + try { + // This will never actually wait, but that's fine because we only + // want to ensure that this typedArray CAN be waited on and is shareable. + Atomics.wait(temp, 0, Constructor === Int32Array ? 1 : BigInt(1)); + } catch (error) { + throw new Test262Error(`${Constructor.name} cannot be used as a shared typed array. (${error})`); + } + + $262.agent.broadcast(typedArray.buffer); +}; + +$262.agent.safeBroadcastAsync = async function(ta, index, expected) { + await $262.agent.broadcast(ta.buffer); + await $262.agent.waitUntil(ta, index, expected); + await $262.agent.tryYield(); + return await Atomics.load(ta, index); +}; + + +/** + * With a given Int32Array or BigInt64Array, wait until the expected number of agents have + * reported themselves by calling: + * + * Atomics.add(typedArray, index, 1); + * + * @param {(Int32Array|BigInt64Array)} typedArray An Int32Array or BigInt64Array with a SharedArrayBuffer + * @param {number} index The index of which all agents will report. + * @param {number} expected The number of agents that are expected to report as active. + */ +$262.agent.waitUntil = function(typedArray, index, expected) { + + var agents = 0; + while ((agents = Atomics.load(typedArray, index)) !== expected) { + /* nothing */ + } + assert.sameValue(agents, expected, "Reporting number of 'agents' equals the value of 'expected'"); +}; + +/** + * Timeout values used throughout the Atomics tests. All timeouts are specified in milliseconds. + * + * @property {number} yield Used for `$262.agent.tryYield`. Must not be used in other functions. + * @property {number} small Used when agents will always timeout and `Atomics.wake` is not part + * of the test semantics. Must be larger than `$262.agent.timeouts.yield`. + * @property {number} long Used when some agents may timeout and `Atomics.wake` is called on some + * agents. The agents are required to wait and this needs to be observable + * by the main thread. + * @property {number} huge Used when `Atomics.wake` is called on all waiting agents. The waiting + * must not timeout. The agents are required to wait and this needs to be + * observable by the main thread. All waiting agents must be woken by the + * main thread. + * + * Usage for `$262.agent.timeouts.small`: + * const WAIT_INDEX = 0; + * const RUNNING = 1; + * const TIMEOUT = $262.agent.timeouts.small; + * const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)); + * + * $262.agent.start(` + * $262.agent.receiveBroadcast(function(sab) { + * const i32a = new Int32Array(sab); + * Atomics.add(i32a, ${RUNNING}, 1); + * + * $262.agent.report(Atomics.wait(i32a, ${WAIT_INDEX}, 0, ${TIMEOUT})); + * + * $262.agent.leaving(); + * }); + * `); + * $262.agent.safeBroadcast(i32a.buffer); + * + * // Wait until the agent was started and then try to yield control to increase + * // the likelihood the agent has called `Atomics.wait` and is now waiting. + * $262.agent.waitUntil(i32a, RUNNING, 1); + * $262.agent.tryYield(); + * + * // The agent is expected to time out. + * assert.sameValue($262.agent.getReport(), "timed-out"); + * + * + * Usage for `$262.agent.timeouts.long`: + * const WAIT_INDEX = 0; + * const RUNNING = 1; + * const NUMAGENT = 2; + * const TIMEOUT = $262.agent.timeouts.long; + * const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)); + * + * for (let i = 0; i < NUMAGENT; i++) { + * $262.agent.start(` + * $262.agent.receiveBroadcast(function(sab) { + * const i32a = new Int32Array(sab); + * Atomics.add(i32a, ${RUNNING}, 1); + * + * $262.agent.report(Atomics.wait(i32a, ${WAIT_INDEX}, 0, ${TIMEOUT})); + * + * $262.agent.leaving(); + * }); + * `); + * } + * $262.agent.safeBroadcast(i32a.buffer); + * + * // Wait until the agents were started and then try to yield control to increase + * // the likelihood the agents have called `Atomics.wait` and are now waiting. + * $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); + * $262.agent.tryYield(); + * + * // Wake exactly one agent. + * assert.sameValue(Atomics.wake(i32a, WAIT_INDEX, 1), 1); + * + * // When it doesn't matter how many agents were woken at once, a while loop + * // can be used to make the test more resilient against intermittent failures + * // in case even though `tryYield` was called, the agents haven't started to + * // wait. + * // + * // // Repeat until exactly one agent was woken. + * // var woken = 0; + * // while ((woken = Atomics.wake(i32a, WAIT_INDEX, 1)) !== 0) ; + * // assert.sameValue(woken, 1); + * + * // One agent was woken and the other one timed out. + * const reports = [$262.agent.getReport(), $262.agent.getReport()]; + * assert(reports.includes("ok")); + * assert(reports.includes("timed-out")); + * + * + * Usage for `$262.agent.timeouts.huge`: + * const WAIT_INDEX = 0; + * const RUNNING = 1; + * const NUMAGENT = 2; + * const TIMEOUT = $262.agent.timeouts.huge; + * const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)); + * + * for (let i = 0; i < NUMAGENT; i++) { + * $262.agent.start(` + * $262.agent.receiveBroadcast(function(sab) { + * const i32a = new Int32Array(sab); + * Atomics.add(i32a, ${RUNNING}, 1); + * + * $262.agent.report(Atomics.wait(i32a, ${WAIT_INDEX}, 0, ${TIMEOUT})); + * + * $262.agent.leaving(); + * }); + * `); + * } + * $262.agent.safeBroadcast(i32a.buffer); + * + * // Wait until the agents were started and then try to yield control to increase + * // the likelihood the agents have called `Atomics.wait` and are now waiting. + * $262.agent.waitUntil(i32a, RUNNING, NUMAGENT); + * $262.agent.tryYield(); + * + * // Wake all agents. + * assert.sameValue(Atomics.wake(i32a, WAIT_INDEX), NUMAGENT); + * + * // When it doesn't matter how many agents were woken at once, a while loop + * // can be used to make the test more resilient against intermittent failures + * // in case even though `tryYield` was called, the agents haven't started to + * // wait. + * // + * // // Repeat until all agents were woken. + * // for (var wokenCount = 0; wokenCount < NUMAGENT; ) { + * // var woken = 0; + * // while ((woken = Atomics.wake(i32a, WAIT_INDEX)) !== 0) ; + * // // Maybe perform an action on the woken agents here. + * // wokenCount += woken; + * // } + * + * // All agents were woken and none timeout. + * for (var i = 0; i < NUMAGENT; i++) { + * assert($262.agent.getReport(), "ok"); + * } + */ +$262.agent.timeouts = { + yield: 100, + small: 200, + long: 1000, + huge: 10000, +}; + +/** + * Try to yield control to the agent threads. + * + * Usage: + * const VALUE = 0; + * const RUNNING = 1; + * const i32a = new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT * 2)); + * + * $262.agent.start(` + * $262.agent.receiveBroadcast(function(sab) { + * const i32a = new Int32Array(sab); + * Atomics.add(i32a, ${RUNNING}, 1); + * + * Atomics.store(i32a, ${VALUE}, 1); + * + * $262.agent.leaving(); + * }); + * `); + * $262.agent.safeBroadcast(i32a.buffer); + * + * // Wait until agent was started and then try to yield control. + * $262.agent.waitUntil(i32a, RUNNING, 1); + * $262.agent.tryYield(); + * + * // Note: This result is not guaranteed, but should hold in practice most of the time. + * assert.sameValue(Atomics.load(i32a, VALUE), 1); + * + * The default implementation simply waits for `$262.agent.timeouts.yield` milliseconds. + */ +$262.agent.tryYield = function() { + $262.agent.sleep($262.agent.timeouts.yield); +}; + +/** + * Try to sleep the current agent for the given amount of milliseconds. It is acceptable, + * but not encouraged, to ignore this sleep request and directly continue execution. + * + * The default implementation calls `$262.agent.sleep(ms)`. + * + * @param {number} ms Time to sleep in milliseconds. + */ +$262.agent.trySleep = function(ms) { + $262.agent.sleep(ms); +}; diff --git a/harness/byteConversionValues.js b/harness/byteConversionValues.js new file mode 100644 index 00000000000..e84d7c1e9d7 --- /dev/null +++ b/harness/byteConversionValues.js @@ -0,0 +1,458 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Provide a list for original and expected values for different byte + conversions. + This helper is mostly used on tests for TypedArray and DataView, and each + array from the expected values must match the original values array on every + index containing its original value. +defines: [byteConversionValues] +---*/ +var byteConversionValues = { + values: [ + 127, // 2 ** 7 - 1 + 128, // 2 ** 7 + 32767, // 2 ** 15 - 1 + 32768, // 2 ** 15 + 2147483647, // 2 ** 31 - 1 + 2147483648, // 2 ** 31 + 255, // 2 ** 8 - 1 + 256, // 2 ** 8 + 65535, // 2 ** 16 - 1 + 65536, // 2 ** 16 + 4294967295, // 2 ** 32 - 1 + 4294967296, // 2 ** 32 + 9007199254740991, // 2 ** 53 - 1 + 9007199254740992, // 2 ** 53 + 1.1, + 0.1, + 0.5, + 0.50000001, + 0.6, + 0.7, + undefined, + -1, + -0, + -0.1, + -1.1, + NaN, + -127, // - ( 2 ** 7 - 1 ) + -128, // - ( 2 ** 7 ) + -32767, // - ( 2 ** 15 - 1 ) + -32768, // - ( 2 ** 15 ) + -2147483647, // - ( 2 ** 31 - 1 ) + -2147483648, // - ( 2 ** 31 ) + -255, // - ( 2 ** 8 - 1 ) + -256, // - ( 2 ** 8 ) + -65535, // - ( 2 ** 16 - 1 ) + -65536, // - ( 2 ** 16 ) + -4294967295, // - ( 2 ** 32 - 1 ) + -4294967296, // - ( 2 ** 32 ) + Infinity, + -Infinity, + 0 + ], + + expected: { + Int8: [ + 127, // 127 + -128, // 128 + -1, // 32767 + 0, // 32768 + -1, // 2147483647 + 0, // 2147483648 + -1, // 255 + 0, // 256 + -1, // 65535 + 0, // 65536 + -1, // 4294967295 + 0, // 4294967296 + -1, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + -1, // -1 + 0, // -0 + 0, // -0.1 + -1, // -1.1 + 0, // NaN + -127, // -127 + -128, // -128 + 1, // -32767 + 0, // -32768 + 1, // -2147483647 + 0, // -2147483648 + 1, // -255 + 0, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Uint8: [ + 127, // 127 + 128, // 128 + 255, // 32767 + 0, // 32768 + 255, // 2147483647 + 0, // 2147483648 + 255, // 255 + 0, // 256 + 255, // 65535 + 0, // 65536 + 255, // 4294967295 + 0, // 4294967296 + 255, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + 255, // -1 + 0, // -0 + 0, // -0.1 + 255, // -1.1 + 0, // NaN + 129, // -127 + 128, // -128 + 1, // -32767 + 0, // -32768 + 1, // -2147483647 + 0, // -2147483648 + 1, // -255 + 0, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Uint8Clamped: [ + 127, // 127 + 128, // 128 + 255, // 32767 + 255, // 32768 + 255, // 2147483647 + 255, // 2147483648 + 255, // 255 + 255, // 256 + 255, // 65535 + 255, // 65536 + 255, // 4294967295 + 255, // 4294967296 + 255, // 9007199254740991 + 255, // 9007199254740992 + 1, // 1.1, + 0, // 0.1 + 0, // 0.5 + 1, // 0.50000001, + 1, // 0.6 + 1, // 0.7 + 0, // undefined + 0, // -1 + 0, // -0 + 0, // -0.1 + 0, // -1.1 + 0, // NaN + 0, // -127 + 0, // -128 + 0, // -32767 + 0, // -32768 + 0, // -2147483647 + 0, // -2147483648 + 0, // -255 + 0, // -256 + 0, // -65535 + 0, // -65536 + 0, // -4294967295 + 0, // -4294967296 + 255, // Infinity + 0, // -Infinity + 0 + ], + Int16: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + -32768, // 32768 + -1, // 2147483647 + 0, // 2147483648 + 255, // 255 + 256, // 256 + -1, // 65535 + 0, // 65536 + -1, // 4294967295 + 0, // 4294967296 + -1, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + -1, // -1 + 0, // -0 + 0, // -0.1 + -1, // -1.1 + 0, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + 1, // -2147483647 + 0, // -2147483648 + -255, // -255 + -256, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Uint16: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 65535, // 2147483647 + 0, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 0, // 65536 + 65535, // 4294967295 + 0, // 4294967296 + 65535, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + 65535, // -1 + 0, // -0 + 0, // -0.1 + 65535, // -1.1 + 0, // NaN + 65409, // -127 + 65408, // -128 + 32769, // -32767 + 32768, // -32768 + 1, // -2147483647 + 0, // -2147483648 + 65281, // -255 + 65280, // -256 + 1, // -65535 + 0, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Int32: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483647, // 2147483647 + -2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + -1, // 4294967295 + 0, // 4294967296 + -1, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + -1, // -1 + 0, // -0 + 0, // -0.1 + -1, // -1.1 + 0, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483647, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Uint32: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483647, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967295, // 4294967295 + 0, // 4294967296 + 4294967295, // 9007199254740991 + 0, // 9007199254740992 + 1, // 1.1 + 0, // 0.1 + 0, // 0.5 + 0, // 0.50000001, + 0, // 0.6 + 0, // 0.7 + 0, // undefined + 4294967295, // -1 + 0, // -0 + 0, // -0.1 + 4294967295, // -1.1 + 0, // NaN + 4294967169, // -127 + 4294967168, // -128 + 4294934529, // -32767 + 4294934528, // -32768 + 2147483649, // -2147483647 + 2147483648, // -2147483648 + 4294967041, // -255 + 4294967040, // -256 + 4294901761, // -65535 + 4294901760, // -65536 + 1, // -4294967295 + 0, // -4294967296 + 0, // Infinity + 0, // -Infinity + 0 + ], + Float32: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483648, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967296, // 4294967295 + 4294967296, // 4294967296 + 9007199254740992, // 9007199254740991 + 9007199254740992, // 9007199254740992 + 1.100000023841858, // 1.1 + 0.10000000149011612, // 0.1 + 0.5, // 0.5 + 0.5, // 0.50000001, + 0.6000000238418579, // 0.6 + 0.699999988079071, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.10000000149011612, // -0.1 + -1.100000023841858, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483648, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + -4294967296, // -4294967295 + -4294967296, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0 + ], + Float64: [ + 127, // 127 + 128, // 128 + 32767, // 32767 + 32768, // 32768 + 2147483647, // 2147483647 + 2147483648, // 2147483648 + 255, // 255 + 256, // 256 + 65535, // 65535 + 65536, // 65536 + 4294967295, // 4294967295 + 4294967296, // 4294967296 + 9007199254740991, // 9007199254740991 + 9007199254740992, // 9007199254740992 + 1.1, // 1.1 + 0.1, // 0.1 + 0.5, // 0.5 + 0.50000001, // 0.50000001, + 0.6, // 0.6 + 0.7, // 0.7 + NaN, // undefined + -1, // -1 + -0, // -0 + -0.1, // -0.1 + -1.1, // -1.1 + NaN, // NaN + -127, // -127 + -128, // -128 + -32767, // -32767 + -32768, // -32768 + -2147483647, // -2147483647 + -2147483648, // -2147483648 + -255, // -255 + -256, // -256 + -65535, // -65535 + -65536, // -65536 + -4294967295, // -4294967295 + -4294967296, // -4294967296 + Infinity, // Infinity + -Infinity, // -Infinity + 0 + ] + } +}; diff --git a/harness/compareArray.js b/harness/compareArray.js new file mode 100644 index 00000000000..2783698457e --- /dev/null +++ b/harness/compareArray.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Compare the contents of two arrays +defines: [compareArray] +---*/ + +function compareArray(a, b) { + if (b.length !== a.length) { + return false; + } + + for (var i = 0; i < a.length; i++) { + if (!compareArray.isSameValue(b[i], a[i])) { + return false; + } + } + return true; +} + +compareArray.isSameValue = function(a, b) { + if (a === 0 && b === 0) return 1 / a === 1 / b; + if (a !== a && b !== b) return true; + + return a === b; +}; + +compareArray.format = function(arrayLike) { + return `[${[].map.call(arrayLike, String).join(', ')}]`; +}; + +assert.compareArray = function(actual, expected, message) { + message = message === undefined ? '' : message; + + if (typeof message === 'symbol') { + message = message.toString(); + } + + assert(actual != null, `First argument shouldn't be nullish. ${message}`); + assert(expected != null, `Second argument shouldn't be nullish. ${message}`); + var format = compareArray.format; + var result = compareArray(actual, expected); + + // The following prevents actual and expected from being iterated and evaluated + // more than once unless absolutely necessary. + if (!result) { + assert(false, `Expected ${format(actual)} and ${format(expected)} to have the same contents. ${message}`); + } +}; diff --git a/harness/compareIterator.js b/harness/compareIterator.js new file mode 100644 index 00000000000..d4e3b9a53aa --- /dev/null +++ b/harness/compareIterator.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Compare the values of an iterator with an array of expected values +defines: [assert.compareIterator] +---*/ + +// Example: +// +// function* numbers() { +// yield 1; +// yield 2; +// yield 3; +// } +// +// assert.compareIterator(numbers(), [ +// v => assert.sameValue(v, 1), +// v => assert.sameValue(v, 2), +// v => assert.sameValue(v, 3), +// ]); +// +assert.compareIterator = function(iter, validators, message) { + message = message || ''; + + var i, result; + for (i = 0; i < validators.length; i++) { + result = iter.next(); + assert(!result.done, 'Expected ' + i + ' values(s). Instead iterator only produced ' + (i - 1) + ' value(s). ' + message); + validators[i](result.value); + } + + result = iter.next(); + assert(result.done, 'Expected only ' + i + ' values(s). Instead iterator produced more. ' + message); + assert.sameValue(result.value, undefined, 'Expected value of `undefined` when iterator completes. ' + message); +} diff --git a/harness/dateConstants.js b/harness/dateConstants.js new file mode 100644 index 00000000000..2eed15ca63a --- /dev/null +++ b/harness/dateConstants.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of date-centric values +defines: + - date_1899_end + - date_1900_start + - date_1969_end + - date_1970_start + - date_1999_end + - date_2000_start + - date_2099_end + - date_2100_start + - start_of_time + - end_of_time +---*/ + +var date_1899_end = -2208988800001; +var date_1900_start = -2208988800000; +var date_1969_end = -1; +var date_1970_start = 0; +var date_1999_end = 946684799999; +var date_2000_start = 946684800000; +var date_2099_end = 4102444799999; +var date_2100_start = 4102444800000; + +var start_of_time = -8.64e15; +var end_of_time = 8.64e15; diff --git a/harness/decimalToHexString.js b/harness/decimalToHexString.js new file mode 100644 index 00000000000..9840ee589cd --- /dev/null +++ b/harness/decimalToHexString.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +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]; +} diff --git a/harness/deepEqual.js b/harness/deepEqual.js new file mode 100644 index 00000000000..a2ceeb3d9cc --- /dev/null +++ b/harness/deepEqual.js @@ -0,0 +1,339 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Compare two values structurally +defines: [assert.deepEqual] +---*/ + +assert.deepEqual = function(actual, expected, message) { + var format = assert.deepEqual.format; + assert( + assert.deepEqual._compare(actual, expected), + `Expected ${format(actual)} to be structurally equal to ${format(expected)}. ${(message || '')}` + ); +}; + +assert.deepEqual.format = function(value, seen) { + switch (typeof value) { + case 'string': + return typeof JSON !== "undefined" ? JSON.stringify(value) : `"${value}"`; + case 'number': + case 'boolean': + case 'symbol': + case 'bigint': + return value.toString(); + case 'undefined': + return 'undefined'; + case 'function': + return `[Function${value.name ? `: ${value.name}` : ''}]`; + case 'object': + if (value === null) return 'null'; + if (value instanceof Date) return `Date "${value.toISOString()}"`; + if (value instanceof RegExp) return value.toString(); + if (!seen) { + seen = { + counter: 0, + map: new Map() + }; + } + + let usage = seen.map.get(value); + if (usage) { + usage.used = true; + return `[Ref: #${usage.id}]`; + } + + usage = { id: ++seen.counter, used: false }; + seen.map.set(value, usage); + + if (typeof Set !== "undefined" && value instanceof Set) { + return `Set {${Array.from(value).map(value => assert.deepEqual.format(value, seen)).join(', ')}}${usage.used ? ` as #${usage.id}` : ''}`; + } + if (typeof Map !== "undefined" && value instanceof Map) { + return `Map {${Array.from(value).map(pair => `${assert.deepEqual.format(pair[0], seen)} => ${assert.deepEqual.format(pair[1], seen)}}`).join(', ')}}${usage.used ? ` as #${usage.id}` : ''}`; + } + if (Array.isArray ? Array.isArray(value) : value instanceof Array) { + return `[${value.map(value => assert.deepEqual.format(value, seen)).join(', ')}]${usage.used ? ` as #${usage.id}` : ''}`; + } + let tag = Symbol.toStringTag in value ? value[Symbol.toStringTag] : 'Object'; + if (tag === 'Object' && Object.getPrototypeOf(value) === null) { + tag = '[Object: null prototype]'; + } + return `${tag ? `${tag} ` : ''}{ ${Object.keys(value).map(key => `${key.toString()}: ${assert.deepEqual.format(value[key], seen)}`).join(', ')} }${usage.used ? ` as #${usage.id}` : ''}`; + default: + return typeof value; + } +}; + +assert.deepEqual._compare = (function () { + var EQUAL = 1; + var NOT_EQUAL = -1; + var UNKNOWN = 0; + + function deepEqual(a, b) { + return compareEquality(a, b) === EQUAL; + } + + function compareEquality(a, b, cache) { + return compareIf(a, b, isOptional, compareOptionality) + || compareIf(a, b, isPrimitiveEquatable, comparePrimitiveEquality) + || compareIf(a, b, isObjectEquatable, compareObjectEquality, cache) + || NOT_EQUAL; + } + + function compareIf(a, b, test, compare, cache) { + return !test(a) + ? !test(b) ? UNKNOWN : NOT_EQUAL + : !test(b) ? NOT_EQUAL : cacheComparison(a, b, compare, cache); + } + + function tryCompareStrictEquality(a, b) { + return a === b ? EQUAL : UNKNOWN; + } + + function tryCompareTypeOfEquality(a, b) { + return typeof a !== typeof b ? NOT_EQUAL : UNKNOWN; + } + + function tryCompareToStringTagEquality(a, b) { + var aTag = Symbol.toStringTag in a ? a[Symbol.toStringTag] : undefined; + var bTag = Symbol.toStringTag in b ? b[Symbol.toStringTag] : undefined; + return aTag !== bTag ? NOT_EQUAL : UNKNOWN; + } + + function isOptional(value) { + return value === undefined + || value === null; + } + + function compareOptionality(a, b) { + return tryCompareStrictEquality(a, b) + || NOT_EQUAL; + } + + function isPrimitiveEquatable(value) { + switch (typeof value) { + case 'string': + case 'number': + case 'bigint': + case 'boolean': + case 'symbol': + return true; + default: + return isBoxed(value); + } + } + + function comparePrimitiveEquality(a, b) { + if (isBoxed(a)) a = a.valueOf(); + if (isBoxed(b)) b = b.valueOf(); + return tryCompareStrictEquality(a, b) + || tryCompareTypeOfEquality(a, b) + || compareIf(a, b, isNaNEquatable, compareNaNEquality) + || NOT_EQUAL; + } + + function isNaNEquatable(value) { + return typeof value === 'number'; + } + + function compareNaNEquality(a, b) { + return isNaN(a) && isNaN(b) ? EQUAL : NOT_EQUAL; + } + + function isObjectEquatable(value) { + return typeof value === 'object'; + } + + function compareObjectEquality(a, b, cache) { + if (!cache) cache = new Map(); + return getCache(cache, a, b) + || setCache(cache, a, b, EQUAL) // consider equal for now + || cacheComparison(a, b, tryCompareStrictEquality, cache) + || cacheComparison(a, b, tryCompareToStringTagEquality, cache) + || compareIf(a, b, isValueOfEquatable, compareValueOfEquality) + || compareIf(a, b, isToStringEquatable, compareToStringEquality) + || compareIf(a, b, isArrayLikeEquatable, compareArrayLikeEquality, cache) + || compareIf(a, b, isStructurallyEquatable, compareStructuralEquality, cache) + || compareIf(a, b, isIterableEquatable, compareIterableEquality, cache) + || cacheComparison(a, b, fail, cache); + } + + function isBoxed(value) { + return value instanceof String + || value instanceof Number + || value instanceof Boolean + || typeof Symbol === 'function' && value instanceof Symbol + || typeof BigInt === 'function' && value instanceof BigInt; + } + + function isValueOfEquatable(value) { + return value instanceof Date; + } + + function compareValueOfEquality(a, b) { + return compareIf(a.valueOf(), b.valueOf(), isPrimitiveEquatable, comparePrimitiveEquality) + || NOT_EQUAL; + } + + function isToStringEquatable(value) { + return value instanceof RegExp; + } + + function compareToStringEquality(a, b) { + return compareIf(a.toString(), b.toString(), isPrimitiveEquatable, comparePrimitiveEquality) + || NOT_EQUAL; + } + + function isArrayLikeEquatable(value) { + return (Array.isArray ? Array.isArray(value) : value instanceof Array) + || (typeof Uint8Array === 'function' && value instanceof Uint8Array) + || (typeof Uint8ClampedArray === 'function' && value instanceof Uint8ClampedArray) + || (typeof Uint16Array === 'function' && value instanceof Uint16Array) + || (typeof Uint32Array === 'function' && value instanceof Uint32Array) + || (typeof Int8Array === 'function' && value instanceof Int8Array) + || (typeof Int16Array === 'function' && value instanceof Int16Array) + || (typeof Int32Array === 'function' && value instanceof Int32Array) + || (typeof Float32Array === 'function' && value instanceof Float32Array) + || (typeof Float64Array === 'function' && value instanceof Float64Array) + || (typeof BigUint64Array === 'function' && value instanceof BigUint64Array) + || (typeof BigInt64Array === 'function' && value instanceof BigInt64Array); + } + + function compareArrayLikeEquality(a, b, cache) { + if (a.length !== b.length) return NOT_EQUAL; + for (var i = 0; i < a.length; i++) { + if (compareEquality(a[i], b[i], cache) === NOT_EQUAL) { + return NOT_EQUAL; + } + } + return EQUAL; + } + + function isStructurallyEquatable(value) { + return !(typeof Promise === 'function' && value instanceof Promise // only comparable by reference + || typeof WeakMap === 'function' && value instanceof WeakMap // only comparable by reference + || typeof WeakSet === 'function' && value instanceof WeakSet // only comparable by reference + || typeof Map === 'function' && value instanceof Map // comparable via @@iterator + || typeof Set === 'function' && value instanceof Set); // comparable via @@iterator + } + + function compareStructuralEquality(a, b, cache) { + var aKeys = []; + for (var key in a) aKeys.push(key); + + var bKeys = []; + for (var key in b) bKeys.push(key); + + if (aKeys.length !== bKeys.length) { + return NOT_EQUAL; + } + + aKeys.sort(); + bKeys.sort(); + + for (var i = 0; i < aKeys.length; i++) { + var aKey = aKeys[i]; + var bKey = bKeys[i]; + if (compareEquality(aKey, bKey, cache) === NOT_EQUAL) { + return NOT_EQUAL; + } + if (compareEquality(a[aKey], b[bKey], cache) === NOT_EQUAL) { + return NOT_EQUAL; + } + } + + return compareIf(a, b, isIterableEquatable, compareIterableEquality, cache) + || EQUAL; + } + + function isIterableEquatable(value) { + return typeof Symbol === 'function' + && typeof value[Symbol.iterator] === 'function'; + } + + function compareIteratorEquality(a, b, cache) { + if (typeof Map === 'function' && a instanceof Map && b instanceof Map || + typeof Set === 'function' && a instanceof Set && b instanceof Set) { + if (a.size !== b.size) return NOT_EQUAL; // exit early if we detect a difference in size + } + + var ar, br; + while (true) { + ar = a.next(); + br = b.next(); + if (ar.done) { + if (br.done) return EQUAL; + if (b.return) b.return(); + return NOT_EQUAL; + } + if (br.done) { + if (a.return) a.return(); + return NOT_EQUAL; + } + if (compareEquality(ar.value, br.value, cache) === NOT_EQUAL) { + if (a.return) a.return(); + if (b.return) b.return(); + return NOT_EQUAL; + } + } + } + + function compareIterableEquality(a, b, cache) { + return compareIteratorEquality(a[Symbol.iterator](), b[Symbol.iterator](), cache); + } + + function cacheComparison(a, b, compare, cache) { + var result = compare(a, b, cache); + if (cache && (result === EQUAL || result === NOT_EQUAL)) { + setCache(cache, a, b, /** @type {EQUAL | NOT_EQUAL} */(result)); + } + return result; + } + + function fail() { + return NOT_EQUAL; + } + + function setCache(cache, left, right, result) { + var otherCache; + + otherCache = cache.get(left); + if (!otherCache) cache.set(left, otherCache = new Map()); + otherCache.set(right, result); + + otherCache = cache.get(right); + if (!otherCache) cache.set(right, otherCache = new Map()); + otherCache.set(left, result); + } + + function getCache(cache, left, right) { + var otherCache; + var result; + + otherCache = cache.get(left); + result = otherCache && otherCache.get(right); + if (result) return result; + + otherCache = cache.get(right); + result = otherCache && otherCache.get(left); + if (result) return result; + + return UNKNOWN; + } + + return deepEqual; +})(); diff --git a/harness/detachArrayBuffer.js b/harness/detachArrayBuffer.js new file mode 100644 index 00000000000..e69c0cbc2cd --- /dev/null +++ b/harness/detachArrayBuffer.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + A function used in the process of asserting correctness of TypedArray objects. + + $262.detachArrayBuffer is defined by a host. +defines: [$DETACHBUFFER] +---*/ + +function $DETACHBUFFER(buffer) { + if (!$262 || typeof $262.detachArrayBuffer !== "function") { + throw new Test262Error("No method available to detach an ArrayBuffer"); + } + $262.detachArrayBuffer(buffer); +} diff --git a/harness/doneprintHandle.js b/harness/doneprintHandle.js new file mode 100644 index 00000000000..8c8f589868d --- /dev/null +++ b/harness/doneprintHandle.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | +defines: [$DONE] +---*/ + +function __consolePrintHandle__(msg) { + print(msg); +} + +function $DONE(error) { + if (error) { + if(typeof error === 'object' && error !== null && 'name' in error) { + __consolePrintHandle__('Test262:AsyncTestFailure:' + error.name + ': ' + error.message); + } else { + __consolePrintHandle__('Test262:AsyncTestFailure:Test262Error: ' + String(error)); + } + } else { + __consolePrintHandle__('Test262:AsyncTestComplete'); + } +} diff --git a/harness/features.yml b/harness/features.yml new file mode 100644 index 00000000000..333af083bed --- /dev/null +++ b/harness/features.yml @@ -0,0 +1,6 @@ +atomicsHelper: [Atomics] +typeCoercion.js: [Symbol.toPrimitive, BigInt] +testAtomics.js: [ArrayBuffer, Atomics, DataView, SharedArrayBuffer, Symbol, TypedArray] +testBigIntTypedArray.js: [BigInt, TypedArray] +testTypedArray.js: [TypedArray] +isConstructor.js: [Reflect.construct] diff --git a/harness/fnGlobalObject.js b/harness/fnGlobalObject.js new file mode 100644 index 00000000000..370e40c3356 --- /dev/null +++ b/harness/fnGlobalObject.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Produce a reliable global object +defines: [fnGlobalObject] +---*/ + +var __globalObject = Function("return this;")(); +function fnGlobalObject() { + return __globalObject; +} diff --git a/harness/hidden-constructors.js b/harness/hidden-constructors.js new file mode 100644 index 00000000000..7ea8430fe48 --- /dev/null +++ b/harness/hidden-constructors.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: | + Provides uniform access to built-in constructors that are not exposed to the global object. +defines: + - AsyncArrowFunction + - AsyncFunction + - AsyncGeneratorFunction + - GeneratorFunction +---*/ + +var AsyncArrowFunction = Object.getPrototypeOf(async () => {}).constructor; +var AsyncFunction = Object.getPrototypeOf(async function () {}).constructor; +var AsyncGeneratorFunction = Object.getPrototypeOf(async function* () {}).constructor; +var GeneratorFunction = Object.getPrototypeOf(function* () {}).constructor; diff --git a/harness/isConstructor.js b/harness/isConstructor.js new file mode 100644 index 00000000000..9fad1048809 --- /dev/null +++ b/harness/isConstructor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +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/harness/nans.js b/harness/nans.js new file mode 100644 index 00000000000..39f2c57c22e --- /dev/null +++ b/harness/nans.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + A collection of NaN values produced from expressions that have been observed + to create distinct bit representations on various platforms. These provide a + weak basis for assertions regarding the consistent canonicalization of NaN + values in Array buffers. +defines: [NaNs] +---*/ + +var NaNs = [ + NaN, + Number.NaN, + NaN * 0, + 0/0, + Infinity/Infinity, + -(0/0), + Math.pow(-1, 0.5), + -Math.pow(-1, 0.5), + Number("Not-a-Number"), +]; diff --git a/harness/nativeFunctionMatcher.js b/harness/nativeFunctionMatcher.js new file mode 100644 index 00000000000..c913005ce30 --- /dev/null +++ b/harness/nativeFunctionMatcher.js @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Assert _NativeFunction_ Syntax +info: | + NativeFunction : + function _NativeFunctionAccessor_ opt _IdentifierName_ opt ( _FormalParameters_ ) { [ native code ] } + NativeFunctionAccessor : + get + set +defines: + - assertToStringOrNativeFunction + - assertNativeFunction + - validateNativeFunctionSource +---*/ + +const validateNativeFunctionSource = function(source) { + // These regexes should be kept up to date with Unicode using `regexpu-core`. + // `/\p{ID_Start}/u` + const UnicodeIDStart = /(?:[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1878\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD23\uDE80-\uDEA9\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF45\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD44\uDD47\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC5F-\uDC61\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDEB8\uDF00-\uDF1A]|\uD806[\uDC00-\uDC2B\uDCA0-\uDCDF\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD2F\uDD3F\uDD41\uDDA0-\uDDA7\uDDAA-\uDDD0\uDDE1\uDDE3\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE89\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD89\uDD98\uDEE0-\uDEF2\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF50\uDF93-\uDF9F\uDFE0\uDFE1\uDFE3]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD838[\uDD00-\uDD2C\uDD37-\uDD3D\uDD4E\uDEC0-\uDEEB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43\uDD4B]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A])/; + // `/\p{ID_Continue}/u` + const UnicodeIDContinue = /(?:[0-9A-Z_a-z\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u08D3-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1ABF\u1AC0\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u31BF\u31F0-\u31FF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA827\uA82C\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDD00-\uDD27\uDD30-\uDD39\uDE80-\uDEA9\uDEAB\uDEAC\uDEB0\uDEB1\uDF00-\uDF1C\uDF27\uDF30-\uDF50\uDFB0-\uDFC4\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD47\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCE9\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6\uDFB0]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE7F\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0\uDFF1]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDEC0-\uDEF9]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A]|\uDB40[\uDD00-\uDDEF])/; + // `/\p{Space_Separator}/u` + const UnicodeSpaceSeparator = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/; + + const isNewline = (c) => /[\u000A\u000D\u2028\u2029]/u.test(c); + const isWhitespace = (c) => /[\u0009\u000B\u000C\u0020\u00A0\uFEFF]/u.test(c) || UnicodeSpaceSeparator.test(c); + + let pos = 0; + + const eatWhitespace = () => { + while (pos < source.length) { + const c = source[pos]; + if (isWhitespace(c) || isNewline(c)) { + pos += 1; + continue; + } + + if (c === '/') { + if (source[pos + 1] === '/') { + while (pos < source.length) { + if (isNewline(source[pos])) { + break; + } + pos += 1; + } + continue; + } + if (source[pos + 1] === '*') { + const end = source.indexOf('*/', pos); + if (end === -1) { + throw new SyntaxError(); + } + pos = end + '*/'.length; + continue; + } + } + + break; + } + }; + + const getIdentifier = () => { + eatWhitespace(); + + const start = pos; + let end = pos; + switch (source[end]) { + case '_': + case '$': + end += 1; + break; + default: + if (UnicodeIDStart.test(source[end])) { + end += 1; + break; + } + return null; + } + while (end < source.length) { + const c = source[end]; + switch (c) { + case '_': + case '$': + end += 1; + break; + default: + if (UnicodeIDContinue.test(c)) { + end += 1; + break; + } + return source.slice(start, end); + } + } + return source.slice(start, end); + }; + + const test = (s) => { + eatWhitespace(); + + if (/\w/.test(s)) { + return getIdentifier() === s; + } + return source.slice(pos, pos + s.length) === s; + }; + + const eat = (s) => { + if (test(s)) { + pos += s.length; + return true; + } + return false; + }; + + const eatIdentifier = () => { + const n = getIdentifier(); + if (n !== null) { + pos += n.length; + return true; + } + return false; + }; + + const expect = (s) => { + if (!eat(s)) { + throw new SyntaxError(); + } + }; + + const eatString = () => { + if (source[pos] === '\'' || source[pos] === '"') { + const match = source[pos]; + pos += 1; + while (pos < source.length) { + if (source[pos] === match && source[pos - 1] !== '\\') { + return; + } + if (isNewline(source[pos])) { + throw new SyntaxError(); + } + pos += 1; + } + throw new SyntaxError(); + } + }; + + // "Stumble" through source text until matching character is found. + // Assumes ECMAScript syntax keeps `[]` and `()` balanced. + const stumbleUntil = (c) => { + const match = { + ']': '[', + ')': '(', + }[c]; + let nesting = 1; + while (pos < source.length) { + eatWhitespace(); + eatString(); // Strings may contain unbalanced characters. + if (source[pos] === match) { + nesting += 1; + } else if (source[pos] === c) { + nesting -= 1; + } + pos += 1; + if (nesting === 0) { + return; + } + } + throw new SyntaxError(); + }; + + // function + expect('function'); + + // NativeFunctionAccessor + eat('get') || eat('set'); + + // PropertyName + if (!eatIdentifier() && eat('[')) { + stumbleUntil(']'); + } + + // ( FormalParameters ) + expect('('); + stumbleUntil(')'); + + // { + expect('{'); + + // [native code] + expect('['); + expect('native'); + expect('code'); + expect(']'); + + // } + expect('}'); + + eatWhitespace(); + if (pos !== source.length) { + throw new SyntaxError(); + } +}; + +const assertToStringOrNativeFunction = function(fn, expected) { + const actual = "" + fn; + try { + assert.sameValue(actual, expected); + } catch (unused) { + assertNativeFunction(fn, expected); + } +}; + +const assertNativeFunction = function(fn, special) { + const actual = "" + fn; + try { + validateNativeFunctionSource(actual); + } catch (unused) { + throw new Test262Error('Conforms to NativeFunction Syntax: ' + JSON.stringify(actual) + (special ? ' (' + special + ')' : '')); + } +}; diff --git a/harness/promiseHelper.js b/harness/promiseHelper.js new file mode 100644 index 00000000000..9750544489e --- /dev/null +++ b/harness/promiseHelper.js @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Check that an array contains a numeric sequence starting at 1 + and incrementing by 1 for each entry in the array. Used by + Promise tests to assert the order of execution in deep Promise + resolution pipelines. +defines: [checkSequence, checkSettledPromises] +---*/ + +function checkSequence(arr, message) { + arr.forEach(function(e, i) { + if (e !== (i+1)) { + throw new Test262Error((message ? message : "Steps in unexpected sequence:") + + " '" + arr.join(',') + "'"); + } + }); + + return true; +} + +function checkSettledPromises(settleds, expected, message) { + const prefix = message ? `${message}: ` : ''; + + assert.sameValue(Array.isArray(settleds), true, `${prefix}Settled values is an array`); + + assert.sameValue( + settleds.length, + expected.length, + `${prefix}The settled values has a different length than expected` + ); + + settleds.forEach((settled, i) => { + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'status'), + true, + `${prefix}The settled value has a property status` + ); + + assert.sameValue(settled.status, expected[i].status, `${prefix}status for item ${i}`); + + if (settled.status === 'fulfilled') { + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'value'), + true, + `${prefix}The fulfilled promise has a property named value` + ); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'reason'), + false, + `${prefix}The fulfilled promise has no property named reason` + ); + + assert.sameValue(settled.value, expected[i].value, `${prefix}value for item ${i}`); + } else { + assert.sameValue(settled.status, 'rejected', `${prefix}Valid statuses are only fulfilled or rejected`); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'value'), + false, + `${prefix}The fulfilled promise has no property named value` + ); + + assert.sameValue( + Object.prototype.hasOwnProperty.call(settled, 'reason'), + true, + `${prefix}The fulfilled promise has a property named reason` + ); + + assert.sameValue(settled.reason, expected[i].reason, `${prefix}Reason value for item ${i}`); + } + }); +} diff --git a/harness/propertyHelper.js b/harness/propertyHelper.js new file mode 100644 index 00000000000..6b38bb72e0b --- /dev/null +++ b/harness/propertyHelper.js @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to safely verify the correctness of + property descriptors. +defines: + - verifyProperty + - verifyEqualTo # deprecated + - verifyWritable # deprecated + - verifyNotWritable # deprecated + - verifyEnumerable # deprecated + - verifyNotEnumerable # deprecated + - verifyConfigurable # deprecated + - verifyNotConfigurable # deprecated +---*/ + +// @ts-check + +/** + * @param {object} obj + * @param {string|symbol} name + * @param {PropertyDescriptor|undefined} desc + * @param {object} [options] + * @param {boolean} [options.restore] + */ +function verifyProperty(obj, name, desc, options) { + assert( + arguments.length > 2, + 'verifyProperty should receive at least 3 arguments: obj, name, and descriptor' + ); + + var originalDesc = Object.getOwnPropertyDescriptor(obj, name); + var nameStr = String(name); + + // Allows checking for undefined descriptor if it's explicitly given. + if (desc === undefined) { + assert.sameValue( + originalDesc, + undefined, + "obj['" + nameStr + "'] descriptor should be undefined" + ); + + // desc and originalDesc are both undefined, problem solved; + return true; + } + + assert( + Object.prototype.hasOwnProperty.call(obj, name), + "obj should have an own property " + nameStr + ); + + assert.notSameValue( + desc, + null, + "The desc argument should be an object or undefined, null" + ); + + assert.sameValue( + typeof desc, + "object", + "The desc argument should be an object or undefined, " + String(desc) + ); + + var failures = []; + + if (Object.prototype.hasOwnProperty.call(desc, 'value')) { + if (!isSameValue(desc.value, originalDesc.value)) { + failures.push("descriptor value should be " + desc.value); + } + } + + if (Object.prototype.hasOwnProperty.call(desc, 'enumerable')) { + if (desc.enumerable !== originalDesc.enumerable || + desc.enumerable !== isEnumerable(obj, name)) { + failures.push('descriptor should ' + (desc.enumerable ? '' : 'not ') + 'be enumerable'); + } + } + + if (Object.prototype.hasOwnProperty.call(desc, 'writable')) { + if (desc.writable !== originalDesc.writable || + desc.writable !== isWritable(obj, name)) { + failures.push('descriptor should ' + (desc.writable ? '' : 'not ') + 'be writable'); + } + } + + if (Object.prototype.hasOwnProperty.call(desc, 'configurable')) { + if (desc.configurable !== originalDesc.configurable || + desc.configurable !== isConfigurable(obj, name)) { + failures.push('descriptor should ' + (desc.configurable ? '' : 'not ') + 'be configurable'); + } + } + + assert(!failures.length, failures.join('; ')); + + if (options && options.restore) { + Object.defineProperty(obj, name, originalDesc); + } + + return true; +} + +function isConfigurable(obj, name) { + var hasOwnProperty = Object.prototype.hasOwnProperty; + try { + delete obj[name]; + } catch (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + } + return !hasOwnProperty.call(obj, name); +} + +function isEnumerable(obj, name) { + var stringCheck = false; + + if (typeof name === "string") { + for (var x in obj) { + if (x === name) { + stringCheck = true; + break; + } + } + } else { + // skip it if name is not string, works for Symbol names. + stringCheck = true; + } + + return stringCheck && + Object.prototype.hasOwnProperty.call(obj, name) && + Object.prototype.propertyIsEnumerable.call(obj, name); +} + +function isSameValue(a, b) { + if (a === 0 && b === 0) return 1 / a === 1 / b; + if (a !== a && b !== b) return true; + + return a === b; +} + +var __isArray = Array.isArray; +function isWritable(obj, name, verifyProp, value) { + var unlikelyValue = __isArray(obj) && name === "length" ? + Math.pow(2, 32) - 1 : + "unlikelyValue"; + var newValue = value || unlikelyValue; + var hadValue = Object.prototype.hasOwnProperty.call(obj, name); + var oldValue = obj[name]; + var writeSucceeded; + + try { + obj[name] = newValue; + } catch (e) { + if (!(e instanceof TypeError)) { + throw new Test262Error("Expected TypeError, got " + e); + } + } + + writeSucceeded = isSameValue(obj[verifyProp || name], newValue); + + // Revert the change only if it was successful (in other cases, reverting + // is unnecessary and may trigger exceptions for certain property + // configurations) + if (writeSucceeded) { + if (hadValue) { + obj[name] = oldValue; + } else { + delete obj[name]; + } + } + + return writeSucceeded; +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyEqualTo(obj, name, value) { + if (!isSameValue(obj[name], value)) { + throw new Test262Error("Expected obj[" + String(name) + "] to equal " + value + + ", actually " + obj[name]); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyWritable(obj, name, verifyProp, value) { + if (!verifyProp) { + assert(Object.getOwnPropertyDescriptor(obj, name).writable, + "Expected obj[" + String(name) + "] to have writable:true."); + } + if (!isWritable(obj, name, verifyProp, value)) { + throw new Test262Error("Expected obj[" + String(name) + "] to be writable, but was not."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyNotWritable(obj, name, verifyProp, value) { + if (!verifyProp) { + assert(!Object.getOwnPropertyDescriptor(obj, name).writable, + "Expected obj[" + String(name) + "] to have writable:false."); + } + if (isWritable(obj, name, verifyProp)) { + throw new Test262Error("Expected obj[" + String(name) + "] NOT to be writable, but was."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyEnumerable(obj, name) { + assert(Object.getOwnPropertyDescriptor(obj, name).enumerable, + "Expected obj[" + String(name) + "] to have enumerable:true."); + if (!isEnumerable(obj, name)) { + throw new Test262Error("Expected obj[" + String(name) + "] to be enumerable, but was not."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyNotEnumerable(obj, name) { + assert(!Object.getOwnPropertyDescriptor(obj, name).enumerable, + "Expected obj[" + String(name) + "] to have enumerable:false."); + if (isEnumerable(obj, name)) { + throw new Test262Error("Expected obj[" + String(name) + "] NOT to be enumerable, but was."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyConfigurable(obj, name) { + assert(Object.getOwnPropertyDescriptor(obj, name).configurable, + "Expected obj[" + String(name) + "] to have configurable:true."); + if (!isConfigurable(obj, name)) { + throw new Test262Error("Expected obj[" + String(name) + "] to be configurable, but was not."); + } +} + +/** + * Deprecated; please use `verifyProperty` in new tests. + */ +function verifyNotConfigurable(obj, name) { + assert(!Object.getOwnPropertyDescriptor(obj, name).configurable, + "Expected obj[" + String(name) + "] to have configurable:false."); + if (isConfigurable(obj, name)) { + throw new Test262Error("Expected obj[" + String(name) + "] NOT to be configurable, but was."); + } +} diff --git a/harness/proxyTrapsHelper.js b/harness/proxyTrapsHelper.js new file mode 100644 index 00000000000..17daab5abc1 --- /dev/null +++ b/harness/proxyTrapsHelper.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Used to assert the correctness of object behavior in the presence + and context of Proxy objects. +defines: [allowProxyTraps] +---*/ + +function allowProxyTraps(overrides) { + function throwTest262Error(msg) { + return function () { throw new Test262Error(msg); }; + } + if (!overrides) { overrides = {}; } + return { + getPrototypeOf: overrides.getPrototypeOf || throwTest262Error('[[GetPrototypeOf]] trap called'), + setPrototypeOf: overrides.setPrototypeOf || throwTest262Error('[[SetPrototypeOf]] trap called'), + isExtensible: overrides.isExtensible || throwTest262Error('[[IsExtensible]] trap called'), + preventExtensions: overrides.preventExtensions || throwTest262Error('[[PreventExtensions]] trap called'), + getOwnPropertyDescriptor: overrides.getOwnPropertyDescriptor || throwTest262Error('[[GetOwnProperty]] trap called'), + has: overrides.has || throwTest262Error('[[HasProperty]] trap called'), + get: overrides.get || throwTest262Error('[[Get]] trap called'), + set: overrides.set || throwTest262Error('[[Set]] trap called'), + deleteProperty: overrides.deleteProperty || throwTest262Error('[[Delete]] trap called'), + defineProperty: overrides.defineProperty || throwTest262Error('[[DefineOwnProperty]] trap called'), + enumerate: throwTest262Error('[[Enumerate]] trap called: this trap has been removed'), + ownKeys: overrides.ownKeys || throwTest262Error('[[OwnPropertyKeys]] trap called'), + apply: overrides.apply || throwTest262Error('[[Call]] trap called'), + construct: overrides.construct || throwTest262Error('[[Construct]] trap called') + }; +} diff --git a/harness/regExpUtils.js b/harness/regExpUtils.js new file mode 100644 index 00000000000..4be437e20a7 --- /dev/null +++ b/harness/regExpUtils.js @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to assert the correctness of RegExp objects. +defines: [buildString, testPropertyEscapes, testPropertyOfStrings, testExtendedCharacterClass, matchValidator] +---*/ + +function buildString(args) { + // Use member expressions rather than destructuring `args` for improved + // compatibility with engines that only implement assignment patterns + // partially or not at all. + const loneCodePoints = args.loneCodePoints; + const ranges = args.ranges; + const CHUNK_SIZE = 10000; + let result = Reflect.apply(String.fromCodePoint, null, loneCodePoints); + for (let i = 0; i < ranges.length; i++) { + const range = ranges[i]; + const start = range[0]; + const end = range[1]; + const codePoints = []; + for (let length = 0, codePoint = start; codePoint <= end; codePoint++) { + codePoints[length++] = codePoint; + if (length === CHUNK_SIZE) { + result += Reflect.apply(String.fromCodePoint, null, codePoints); + codePoints.length = length = 0; + } + } + result += Reflect.apply(String.fromCodePoint, null, codePoints); + } + return result; +} + +function printCodePoint(codePoint) { + const hex = codePoint + .toString(16) + .toUpperCase() + .padStart(6, "0"); + return `U+${hex}`; +} + +function printStringCodePoints(string) { + const buf = []; + for (const symbol of string) { + const formatted = printCodePoint(symbol.codePointAt(0)); + buf.push(formatted); + } + return buf.join(' '); +} + +function testPropertyEscapes(regExp, string, expression) { + if (!regExp.test(string)) { + for (const symbol of string) { + const formatted = printCodePoint(symbol.codePointAt(0)); + assert( + regExp.test(symbol), + `\`${ expression }\` should match ${ formatted } (\`${ symbol }\`)` + ); + } + } +} + +function testPropertyOfStrings(args) { + // Use member expressions rather than destructuring `args` for improved + // compatibility with engines that only implement assignment patterns + // partially or not at all. + const regExp = args.regExp; + const expression = args.expression; + const matchStrings = args.matchStrings; + const nonMatchStrings = args.nonMatchStrings; + const allStrings = matchStrings.join(''); + if (!regExp.test(allStrings)) { + for (const string of matchStrings) { + assert( + regExp.test(string), + `\`${ expression }\` should match ${ string } (${ printStringCodePoints(string) })` + ); + } + } + + const allNonMatchStrings = nonMatchStrings.join(''); + if (regExp.test(allNonMatchStrings)) { + for (const string of nonMatchStrings) { + assert( + !regExp.test(string), + `\`${ expression }\` should not match ${ string } (${ printStringCodePoints(string) })` + ); + } + } +} + +// The exact same logic can be used to test extended character classes +// as enabled through the RegExp `v` flag. This is useful to test not +// just standalone properties of strings, but also string literals, and +// set operations. +const testExtendedCharacterClass = testPropertyOfStrings; + +// Returns a function that validates a RegExp match result. +// +// Example: +// +// var validate = matchValidator(['b'], 1, 'abc'); +// validate(/b/.exec('abc')); +// +function matchValidator(expectedEntries, expectedIndex, expectedInput) { + return function(match) { + assert.compareArray(match, expectedEntries, 'Match entries'); + assert.sameValue(match.index, expectedIndex, 'Match index'); + assert.sameValue(match.input, expectedInput, 'Match input'); + } +} diff --git a/harness/sta.js b/harness/sta.js new file mode 100644 index 00000000000..5634cb9b003 --- /dev/null +++ b/harness/sta.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Provides both: + + - An error class to avoid false positives when testing for thrown exceptions + - A function to explicitly throw an exception using the Test262Error class +defines: [Test262Error, $DONOTEVALUATE] +---*/ + + +function Test262Error(message) { + this.message = message || ""; +} + +Test262Error.prototype.toString = function () { + return "Test262Error: " + this.message; +}; + +Test262Error.thrower = function (message) { + throw new Test262Error(message); +}; + +function $DONOTEVALUATE() { + throw "Test262: This statement should not be evaluated."; +} diff --git a/harness/tcoHelper.js b/harness/tcoHelper.js new file mode 100644 index 00000000000..fafbed857f4 --- /dev/null +++ b/harness/tcoHelper.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + This defines the number of consecutive recursive function calls that must be + made in order to prove that stack frames are properly destroyed according to + ES2015 tail call optimization semantics. +defines: [$MAX_ITERATIONS] +---*/ + + + + +var $MAX_ITERATIONS = 100000; diff --git a/harness/temporalHelpers.js b/harness/temporalHelpers.js new file mode 100644 index 00000000000..c8aee0516f4 --- /dev/null +++ b/harness/temporalHelpers.js @@ -0,0 +1,2086 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + This defines helper objects and functions for testing Temporal. +defines: [TemporalHelpers] +features: [Symbol.species, Symbol.iterator, Temporal] +---*/ + +const ASCII_IDENTIFIER = /^[$_a-zA-Z][$_a-zA-Z0-9]*$/u; + +function formatPropertyName(propertyKey, objectName = "") { + switch (typeof propertyKey) { + case "symbol": + if (Symbol.keyFor(propertyKey) !== undefined) { + return `${objectName}[Symbol.for('${Symbol.keyFor(propertyKey)}')]`; + } else if (propertyKey.description.startsWith('Symbol.')) { + return `${objectName}[${propertyKey.description}]`; + } else { + return `${objectName}[Symbol('${propertyKey.description}')]` + } + case "string": + if (propertyKey !== String(Number(propertyKey))) { + if (ASCII_IDENTIFIER.test(propertyKey)) { + return objectName ? `${objectName}.${propertyKey}` : propertyKey; + } + return `${objectName}['${propertyKey.replace(/'/g, "\\'")}']` + } + // fall through + default: + // integer or string integer-index + return `${objectName}[${propertyKey}]`; + } +} + +const SKIP_SYMBOL = Symbol("Skip"); + +var TemporalHelpers = { + /* + * assertDuration(duration, years, ..., nanoseconds[, description]): + * + * Shorthand for asserting that each field of a Temporal.Duration is equal to + * an expected value. + */ + assertDuration(duration, years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, description = "") { + assert(duration instanceof Temporal.Duration, `${description} instanceof`); + assert.sameValue(duration.years, years, `${description} years result`); + assert.sameValue(duration.months, months, `${description} months result`); + assert.sameValue(duration.weeks, weeks, `${description} weeks result`); + assert.sameValue(duration.days, days, `${description} days result`); + assert.sameValue(duration.hours, hours, `${description} hours result`); + assert.sameValue(duration.minutes, minutes, `${description} minutes result`); + assert.sameValue(duration.seconds, seconds, `${description} seconds result`); + assert.sameValue(duration.milliseconds, milliseconds, `${description} milliseconds result`); + assert.sameValue(duration.microseconds, microseconds, `${description} microseconds result`); + assert.sameValue(duration.nanoseconds, nanoseconds, `${description} nanoseconds result`); + }, + + /* + * assertDurationsEqual(actual, expected[, description]): + * + * Shorthand for asserting that each field of a Temporal.Duration is equal to + * the corresponding field in another Temporal.Duration. + */ + assertDurationsEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.Duration, `${description} expected value should be a Temporal.Duration`); + TemporalHelpers.assertDuration(actual, expected.years, expected.months, expected.weeks, expected.days, expected.hours, expected.minutes, expected.seconds, expected.milliseconds, expected.microseconds, expected.nanoseconds, description); + }, + + /* + * assertInstantsEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.Instants are of the correct type + * and equal according to their equals() methods. + */ + assertInstantsEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.Instant, `${description} expected value should be a Temporal.Instant`); + assert(actual instanceof Temporal.Instant, `${description} instanceof`); + assert(actual.equals(expected), `${description} equals method`); + }, + + /* + * assertPlainDate(date, year, ..., nanosecond[, description[, era, eraYear]]): + * + * Shorthand for asserting that each field of a Temporal.PlainDate is equal to + * an expected value. (Except the `calendar` property, since callers may want + * to assert either object equality with an object they put in there, or the + * value of date.calendarId.) + */ + assertPlainDate(date, year, month, monthCode, day, description = "", era = undefined, eraYear = undefined) { + assert(date instanceof Temporal.PlainDate, `${description} instanceof`); + assert.sameValue(date.era, era, `${description} era result`); + assert.sameValue(date.eraYear, eraYear, `${description} eraYear result`); + assert.sameValue(date.year, year, `${description} year result`); + assert.sameValue(date.month, month, `${description} month result`); + assert.sameValue(date.monthCode, monthCode, `${description} monthCode result`); + assert.sameValue(date.day, day, `${description} day result`); + }, + + /* + * assertPlainDateTime(datetime, year, ..., nanosecond[, description[, era, eraYear]]): + * + * Shorthand for asserting that each field of a Temporal.PlainDateTime is + * equal to an expected value. (Except the `calendar` property, since callers + * may want to assert either object equality with an object they put in there, + * or the value of datetime.calendarId.) + */ + assertPlainDateTime(datetime, year, month, monthCode, day, hour, minute, second, millisecond, microsecond, nanosecond, description = "", era = undefined, eraYear = undefined) { + assert(datetime instanceof Temporal.PlainDateTime, `${description} instanceof`); + assert.sameValue(datetime.era, era, `${description} era result`); + assert.sameValue(datetime.eraYear, eraYear, `${description} eraYear result`); + assert.sameValue(datetime.year, year, `${description} year result`); + assert.sameValue(datetime.month, month, `${description} month result`); + assert.sameValue(datetime.monthCode, monthCode, `${description} monthCode result`); + assert.sameValue(datetime.day, day, `${description} day result`); + assert.sameValue(datetime.hour, hour, `${description} hour result`); + assert.sameValue(datetime.minute, minute, `${description} minute result`); + assert.sameValue(datetime.second, second, `${description} second result`); + assert.sameValue(datetime.millisecond, millisecond, `${description} millisecond result`); + assert.sameValue(datetime.microsecond, microsecond, `${description} microsecond result`); + assert.sameValue(datetime.nanosecond, nanosecond, `${description} nanosecond result`); + }, + + /* + * assertPlainDateTimesEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.PlainDateTimes are of the correct + * type, equal according to their equals() methods, and additionally that + * their calendar internal slots are the same value. + */ + assertPlainDateTimesEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.PlainDateTime, `${description} expected value should be a Temporal.PlainDateTime`); + assert(actual instanceof Temporal.PlainDateTime, `${description} instanceof`); + assert(actual.equals(expected), `${description} equals method`); + assert.sameValue( + actual.getISOFields().calendar, + expected.getISOFields().calendar, + `${description} calendar same value` + ); + }, + + /* + * assertPlainMonthDay(monthDay, monthCode, day[, description [, referenceISOYear]]): + * + * Shorthand for asserting that each field of a Temporal.PlainMonthDay is + * equal to an expected value. (Except the `calendar` property, since callers + * may want to assert either object equality with an object they put in there, + * or the value of monthDay.calendarId().) + */ + assertPlainMonthDay(monthDay, monthCode, day, description = "", referenceISOYear = 1972) { + assert(monthDay instanceof Temporal.PlainMonthDay, `${description} instanceof`); + assert.sameValue(monthDay.monthCode, monthCode, `${description} monthCode result`); + assert.sameValue(monthDay.day, day, `${description} day result`); + assert.sameValue(monthDay.getISOFields().isoYear, referenceISOYear, `${description} referenceISOYear result`); + }, + + /* + * assertPlainTime(time, hour, ..., nanosecond[, description]): + * + * Shorthand for asserting that each field of a Temporal.PlainTime is equal to + * an expected value. + */ + assertPlainTime(time, hour, minute, second, millisecond, microsecond, nanosecond, description = "") { + assert(time instanceof Temporal.PlainTime, `${description} instanceof`); + assert.sameValue(time.hour, hour, `${description} hour result`); + assert.sameValue(time.minute, minute, `${description} minute result`); + assert.sameValue(time.second, second, `${description} second result`); + assert.sameValue(time.millisecond, millisecond, `${description} millisecond result`); + assert.sameValue(time.microsecond, microsecond, `${description} microsecond result`); + assert.sameValue(time.nanosecond, nanosecond, `${description} nanosecond result`); + }, + + /* + * assertPlainTimesEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.PlainTimes are of the correct + * type and equal according to their equals() methods. + */ + assertPlainTimesEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.PlainTime, `${description} expected value should be a Temporal.PlainTime`); + assert(actual instanceof Temporal.PlainTime, `${description} instanceof`); + assert(actual.equals(expected), `${description} equals method`); + }, + + /* + * assertPlainYearMonth(yearMonth, year, month, monthCode[, description[, era, eraYear, referenceISODay]]): + * + * Shorthand for asserting that each field of a Temporal.PlainYearMonth is + * equal to an expected value. (Except the `calendar` property, since callers + * may want to assert either object equality with an object they put in there, + * or the value of yearMonth.calendarId.) + */ + assertPlainYearMonth(yearMonth, year, month, monthCode, description = "", era = undefined, eraYear = undefined, referenceISODay = 1) { + assert(yearMonth instanceof Temporal.PlainYearMonth, `${description} instanceof`); + assert.sameValue(yearMonth.era, era, `${description} era result`); + assert.sameValue(yearMonth.eraYear, eraYear, `${description} eraYear result`); + assert.sameValue(yearMonth.year, year, `${description} year result`); + assert.sameValue(yearMonth.month, month, `${description} month result`); + assert.sameValue(yearMonth.monthCode, monthCode, `${description} monthCode result`); + assert.sameValue(yearMonth.getISOFields().isoDay, referenceISODay, `${description} referenceISODay result`); + }, + + /* + * assertZonedDateTimesEqual(actual, expected[, description]): + * + * Shorthand for asserting that two Temporal.ZonedDateTimes are of the correct + * type, equal according to their equals() methods, and additionally that + * their time zones and calendar internal slots are the same value. + */ + assertZonedDateTimesEqual(actual, expected, description = "") { + assert(expected instanceof Temporal.ZonedDateTime, `${description} expected value should be a Temporal.ZonedDateTime`); + assert(actual instanceof Temporal.ZonedDateTime, `${description} instanceof`); + assert(actual.equals(expected), `${description} equals method`); + assert.sameValue(actual.timeZone, expected.timeZone, `${description} time zone same value`); + assert.sameValue( + actual.getISOFields().calendar, + expected.getISOFields().calendar, + `${description} calendar same value` + ); + }, + + /* + * assertUnreachable(description): + * + * Helper for asserting that code is not executed. This is useful for + * assertions that methods of user calendars and time zones are not called. + */ + assertUnreachable(description) { + let message = "This code should not be executed"; + if (description) { + message = `${message}: ${description}`; + } + throw new Test262Error(message); + }, + + /* + * checkCalendarDateUntilLargestUnitSingular(func, expectedLargestUnitCalls): + * + * When an options object with a largestUnit property is synthesized inside + * Temporal and passed to user code such as calendar.dateUntil(), the value of + * the largestUnit property should be in the singular form, even if the input + * was given in the plural form. + * (This doesn't apply when the options object is passed through verbatim.) + * + * func(calendar, largestUnit, index) is the operation under test. It's called + * with an instance of a calendar that keeps track of which largestUnit is + * passed to dateUntil(), each key of expectedLargestUnitCalls in turn, and + * the key's numerical index in case the function needs to generate test data + * based on the index. At the end, the actual values passed to dateUntil() are + * compared with the array values of expectedLargestUnitCalls. + */ + checkCalendarDateUntilLargestUnitSingular(func, expectedLargestUnitCalls) { + const actual = []; + + class DateUntilOptionsCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateUntil(earlier, later, options) { + actual.push(options.largestUnit); + return super.dateUntil(earlier, later, options); + } + + toString() { + return "date-until-options"; + } + } + + const calendar = new DateUntilOptionsCalendar(); + Object.entries(expectedLargestUnitCalls).forEach(([largestUnit, expected], index) => { + func(calendar, largestUnit, index); + assert.compareArray(actual, expected, `largestUnit passed to calendar.dateUntil() for largestUnit ${largestUnit}`); + actual.splice(0); // empty it for the next check + }); + }, + + /* + * checkPlainDateTimeConversionFastPath(func): + * + * ToTemporalDate and ToTemporalTime should both, if given a + * Temporal.PlainDateTime instance, convert to the desired type by reading the + * PlainDateTime's internal slots, rather than calling any getters. + * + * func(datetime, calendar) is the actual operation to test, that must + * internally call the abstract operation ToTemporalDate or ToTemporalTime. + * It is passed a Temporal.PlainDateTime instance, as well as the instance's + * calendar object (so that it doesn't have to call the calendar getter itself + * if it wants to make any assertions about the calendar.) + */ + checkPlainDateTimeConversionFastPath(func, message = "checkPlainDateTimeConversionFastPath") { + const actual = []; + const expected = []; + + const calendar = new Temporal.Calendar("iso8601"); + const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); + const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.PlainDateTime.prototype); + ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond"].forEach((property) => { + Object.defineProperty(datetime, property, { + get() { + actual.push(`get ${formatPropertyName(property)}`); + const value = prototypeDescrs[property].get.call(this); + return { + toString() { + actual.push(`toString ${formatPropertyName(property)}`); + return value.toString(); + }, + valueOf() { + actual.push(`valueOf ${formatPropertyName(property)}`); + return value; + }, + }; + }, + }); + }); + Object.defineProperty(datetime, "calendar", { + get() { + actual.push("get calendar"); + return calendar; + }, + }); + + func(datetime, calendar); + assert.compareArray(actual, expected, `${message}: property getters not called`); + }, + + /* + * Check that an options bag that accepts units written in the singular form, + * also accepts the same units written in the plural form. + * func(unit) should call the method with the appropriate options bag + * containing unit as a value. This will be called twice for each element of + * validSingularUnits, once with singular and once with plural, and the + * results of each pair should be the same (whether a Temporal object or a + * primitive value.) + */ + checkPluralUnitsAccepted(func, validSingularUnits) { + const plurals = { + year: 'years', + month: 'months', + week: 'weeks', + day: 'days', + hour: 'hours', + minute: 'minutes', + second: 'seconds', + millisecond: 'milliseconds', + microsecond: 'microseconds', + nanosecond: 'nanoseconds', + }; + + validSingularUnits.forEach((unit) => { + const singularValue = func(unit); + const pluralValue = func(plurals[unit]); + const desc = `Plural ${plurals[unit]} produces the same result as singular ${unit}`; + if (singularValue instanceof Temporal.Duration) { + TemporalHelpers.assertDurationsEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.Instant) { + TemporalHelpers.assertInstantsEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.PlainDateTime) { + TemporalHelpers.assertPlainDateTimesEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.PlainTime) { + TemporalHelpers.assertPlainTimesEqual(pluralValue, singularValue, desc); + } else if (singularValue instanceof Temporal.ZonedDateTime) { + TemporalHelpers.assertZonedDateTimesEqual(pluralValue, singularValue, desc); + } else { + assert.sameValue(pluralValue, singularValue); + } + }); + }, + + /* + * checkRoundingIncrementOptionWrongType(checkFunc, assertTrueResultFunc, assertObjectResultFunc): + * + * Checks the type handling of the roundingIncrement option. + * checkFunc(roundingIncrement) is a function which takes the value of + * roundingIncrement to test, and calls the method under test with it, + * returning the result. assertTrueResultFunc(result, description) should + * assert that result is the expected result with roundingIncrement: true, and + * assertObjectResultFunc(result, description) should assert that result is + * the expected result with roundingIncrement being an object with a valueOf() + * method. + */ + checkRoundingIncrementOptionWrongType(checkFunc, assertTrueResultFunc, assertObjectResultFunc) { + // null converts to 0, which is out of range + assert.throws(RangeError, () => checkFunc(null), "null"); + // Booleans convert to either 0 or 1, and 1 is allowed + const trueResult = checkFunc(true); + assertTrueResultFunc(trueResult, "true"); + assert.throws(RangeError, () => checkFunc(false), "false"); + // Symbols and BigInts cannot convert to numbers + assert.throws(TypeError, () => checkFunc(Symbol()), "symbol"); + assert.throws(TypeError, () => checkFunc(2n), "bigint"); + + // Objects prefer their valueOf() methods when converting to a number + assert.throws(RangeError, () => checkFunc({}), "plain object"); + + const expected = [ + "get roundingIncrement.valueOf", + "call roundingIncrement.valueOf", + ]; + const actual = []; + const observer = TemporalHelpers.toPrimitiveObserver(actual, 2, "roundingIncrement"); + const objectResult = checkFunc(observer); + assertObjectResultFunc(objectResult, "object with valueOf"); + assert.compareArray(actual, expected, "order of operations"); + }, + + /* + * checkStringOptionWrongType(propertyName, value, checkFunc, assertFunc): + * + * Checks the type handling of a string option, of which there are several in + * Temporal. + * propertyName is the name of the option, and value is the value that + * assertFunc should expect it to have. + * checkFunc(value) is a function which takes the value of the option to test, + * and calls the method under test with it, returning the result. + * assertFunc(result, description) should assert that result is the expected + * result with the option value being an object with a toString() method + * which returns the given value. + */ + checkStringOptionWrongType(propertyName, value, checkFunc, assertFunc) { + // null converts to the string "null", which is an invalid string value + assert.throws(RangeError, () => checkFunc(null), "null"); + // Booleans convert to the strings "true" or "false", which are invalid + assert.throws(RangeError, () => checkFunc(true), "true"); + assert.throws(RangeError, () => checkFunc(false), "false"); + // Symbols cannot convert to strings + assert.throws(TypeError, () => checkFunc(Symbol()), "symbol"); + // Numbers convert to strings which are invalid + assert.throws(RangeError, () => checkFunc(2), "number"); + // BigInts convert to strings which are invalid + assert.throws(RangeError, () => checkFunc(2n), "bigint"); + + // Objects prefer their toString() methods when converting to a string + assert.throws(RangeError, () => checkFunc({}), "plain object"); + + const expected = [ + `get ${propertyName}.toString`, + `call ${propertyName}.toString`, + ]; + const actual = []; + const observer = TemporalHelpers.toPrimitiveObserver(actual, value, propertyName); + const result = checkFunc(observer); + assertFunc(result, "object with toString"); + assert.compareArray(actual, expected, "order of operations"); + }, + + /* + * checkSubclassingIgnored(construct, constructArgs, method, methodArgs, + * resultAssertions): + * + * Methods of Temporal classes that return a new instance of the same class, + * must not take the constructor of a subclass into account, nor the @@species + * property. This helper runs tests to ensure this. + * + * construct(...constructArgs) must yield a valid instance of the Temporal + * class. instance[method](...methodArgs) is the method call under test, which + * must also yield a valid instance of the same Temporal class, not a + * subclass. See below for the individual tests that this runs. + * resultAssertions() is a function that performs additional assertions on the + * instance returned by the method under test. + */ + checkSubclassingIgnored(...args) { + this.checkSubclassConstructorNotObject(...args); + this.checkSubclassConstructorUndefined(...args); + this.checkSubclassConstructorThrows(...args); + this.checkSubclassConstructorNotCalled(...args); + this.checkSubclassSpeciesInvalidResult(...args); + this.checkSubclassSpeciesNotAConstructor(...args); + this.checkSubclassSpeciesNull(...args); + this.checkSubclassSpeciesUndefined(...args); + this.checkSubclassSpeciesThrows(...args); + }, + + /* + * Checks that replacing the 'constructor' property of the instance with + * various primitive values does not affect the returned new instance. + */ + checkSubclassConstructorNotObject(construct, constructArgs, method, methodArgs, resultAssertions) { + function check(value, description) { + const instance = new construct(...constructArgs); + instance.constructor = value; + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype, description); + resultAssertions(result); + } + + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "Symbol"); + check(7, "number"); + check(7n, "bigint"); + }, + + /* + * Checks that replacing the 'constructor' property of the subclass with + * undefined does not affect the returned new instance. + */ + checkSubclassConstructorUndefined(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + MySubclass.prototype.constructor = undefined; + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Checks that making the 'constructor' property of the instance throw when + * called does not affect the returned new instance. + */ + checkSubclassConstructorThrows(construct, constructArgs, method, methodArgs, resultAssertions) { + function CustomError() {} + const instance = new construct(...constructArgs); + Object.defineProperty(instance, "constructor", { + get() { + throw new CustomError(); + } + }); + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Checks that when subclassing, the subclass constructor is not called by + * the method under test. + */ + checkSubclassConstructorNotCalled(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that the constructor's @@species property is ignored when it's a + * constructor that returns a non-object value. + */ + checkSubclassSpeciesInvalidResult(construct, constructArgs, method, methodArgs, resultAssertions) { + function check(value, description) { + const instance = new construct(...constructArgs); + instance.constructor = { + [Symbol.species]: function() { + return value; + }, + }; + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype, description); + resultAssertions(result); + } + + check(undefined, "undefined"); + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "Symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "plain object"); + }, + + /* + * Check that the constructor's @@species property is ignored when it's not a + * constructor. + */ + checkSubclassSpeciesNotAConstructor(construct, constructArgs, method, methodArgs, resultAssertions) { + function check(value, description) { + const instance = new construct(...constructArgs); + instance.constructor = { + [Symbol.species]: value, + }; + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype, description); + resultAssertions(result); + } + + check(true, "true"); + check("test", "string"); + check(Symbol(), "Symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "plain object"); + }, + + /* + * Check that the constructor's @@species property is ignored when it's null. + */ + checkSubclassSpeciesNull(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + MySubclass.prototype.constructor = { + [Symbol.species]: null, + }; + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that the constructor's @@species property is ignored when it's + * undefined. + */ + checkSubclassSpeciesUndefined(construct, constructArgs, method, methodArgs, resultAssertions) { + let called = 0; + + class MySubclass extends construct { + constructor() { + ++called; + super(...constructArgs); + } + } + + const instance = new MySubclass(); + assert.sameValue(called, 1); + + MySubclass.prototype.constructor = { + [Symbol.species]: undefined, + }; + + const result = instance[method](...methodArgs); + assert.sameValue(called, 1); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that the constructor's @@species property is ignored when it throws, + * i.e. it is not called at all. + */ + checkSubclassSpeciesThrows(construct, constructArgs, method, methodArgs, resultAssertions) { + function CustomError() {} + + const instance = new construct(...constructArgs); + instance.constructor = { + get [Symbol.species]() { + throw new CustomError(); + }, + }; + + const result = instance[method](...methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + }, + + /* + * checkSubclassingIgnoredStatic(construct, method, methodArgs, resultAssertions): + * + * Static methods of Temporal classes that return a new instance of the class, + * must not use the this-value as a constructor. This helper runs tests to + * ensure this. + * + * construct[method](...methodArgs) is the static method call under test, and + * must yield a valid instance of the Temporal class, not a subclass. See + * below for the individual tests that this runs. + * resultAssertions() is a function that performs additional assertions on the + * instance returned by the method under test. + */ + checkSubclassingIgnoredStatic(...args) { + this.checkStaticInvalidReceiver(...args); + this.checkStaticReceiverNotCalled(...args); + this.checkThisValueNotCalled(...args); + }, + + /* + * Check that calling the static method with a receiver that's not callable, + * still calls the intrinsic constructor. + */ + checkStaticInvalidReceiver(construct, method, methodArgs, resultAssertions) { + function check(value, description) { + const result = construct[method].apply(value, methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + } + + check(undefined, "undefined"); + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "Non-callable object"); + }, + + /* + * Check that calling the static method with a receiver that returns a value + * that's not callable, still calls the intrinsic constructor. + */ + checkStaticReceiverNotCalled(construct, method, methodArgs, resultAssertions) { + function check(value, description) { + const receiver = function () { + return value; + }; + const result = construct[method].apply(receiver, methodArgs); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + } + + check(undefined, "undefined"); + check(null, "null"); + check(true, "true"); + check("test", "string"); + check(Symbol(), "symbol"); + check(7, "number"); + check(7n, "bigint"); + check({}, "Non-callable object"); + }, + + /* + * Check that the receiver isn't called. + */ + checkThisValueNotCalled(construct, method, methodArgs, resultAssertions) { + let called = false; + + class MySubclass extends construct { + constructor(...args) { + called = true; + super(...args); + } + } + + const result = MySubclass[method](...methodArgs); + assert.sameValue(called, false); + assert.sameValue(Object.getPrototypeOf(result), construct.prototype); + resultAssertions(result); + }, + + /* + * Check that any iterable returned from a custom time zone's + * getPossibleInstantsFor() method is exhausted. + * The custom time zone object is passed in to func(). + * expected is an array of strings representing the expected calls to the + * getPossibleInstantsFor() method. The PlainDateTimes that it is called with, + * are compared (using their toString() results) with the array. + */ + checkTimeZonePossibleInstantsIterable(func, expected) { + // A custom time zone that returns an iterable instead of an array from its + // getPossibleInstantsFor() method, and for testing purposes skips + // 00:00-01:00 UTC on January 1, 2030, and repeats 00:00-01:00 UTC+1 on + // January 3, 2030. Otherwise identical to the UTC time zone. + class TimeZonePossibleInstantsIterable extends Temporal.TimeZone { + constructor() { + super("UTC"); + this.getPossibleInstantsForCallCount = 0; + this.getPossibleInstantsForCalledWith = []; + this.getPossibleInstantsForReturns = []; + this.iteratorExhausted = []; + } + + toString() { + return "Custom/Iterable"; + } + + getOffsetNanosecondsFor(instant) { + if (Temporal.Instant.compare(instant, "2030-01-01T00:00Z") >= 0 && + Temporal.Instant.compare(instant, "2030-01-03T01:00Z") < 0) { + return 3600_000_000_000; + } else { + return 0; + } + } + + getPossibleInstantsFor(dateTime) { + this.getPossibleInstantsForCallCount++; + this.getPossibleInstantsForCalledWith.push(dateTime); + + // Fake DST transition + let retval = super.getPossibleInstantsFor(dateTime); + if (dateTime.toPlainDate().equals("2030-01-01") && dateTime.hour === 0) { + retval = []; + } else if (dateTime.toPlainDate().equals("2030-01-03") && dateTime.hour === 0) { + retval.push(retval[0].subtract({ hours: 1 })); + } else if (dateTime.year === 2030 && dateTime.month === 1 && dateTime.day >= 1 && dateTime.day <= 2) { + retval[0] = retval[0].subtract({ hours: 1 }); + } + + this.getPossibleInstantsForReturns.push(retval); + this.iteratorExhausted.push(false); + return { + callIndex: this.getPossibleInstantsForCallCount - 1, + timeZone: this, + *[Symbol.iterator]() { + yield* this.timeZone.getPossibleInstantsForReturns[this.callIndex]; + this.timeZone.iteratorExhausted[this.callIndex] = true; + }, + }; + } + } + + const timeZone = new TimeZonePossibleInstantsIterable(); + func(timeZone); + + assert.sameValue(timeZone.getPossibleInstantsForCallCount, expected.length, "getPossibleInstantsFor() method called correct number of times"); + + for (let index = 0; index < expected.length; index++) { + assert.sameValue(timeZone.getPossibleInstantsForCalledWith[index].toString(), expected[index], "getPossibleInstantsFor() called with expected PlainDateTime"); + assert(timeZone.iteratorExhausted[index], "iterated through the whole iterable"); + } + }, + + /* + * Check that any calendar-carrying Temporal object has its [[Calendar]] + * internal slot read by ToTemporalCalendar, and does not fetch the calendar + * by calling getters. + * The custom calendar object is passed in to func() so that it can do its + * own additional assertions involving the calendar if necessary. (Sometimes + * there is nothing to assert as the calendar isn't stored anywhere that can + * be asserted about.) + */ + checkToTemporalCalendarFastPath(func) { + class CalendarFastPathCheck extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateFromFields(...args) { + return super.dateFromFields(...args).withCalendar(this); + } + + monthDayFromFields(...args) { + const { isoYear, isoMonth, isoDay } = super.monthDayFromFields(...args).getISOFields(); + return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); + } + + yearMonthFromFields(...args) { + const { isoYear, isoMonth, isoDay } = super.yearMonthFromFields(...args).getISOFields(); + return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); + } + + toString() { + return "fast-path-check"; + } + } + const calendar = new CalendarFastPathCheck(); + + const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar); + const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); + const plainMonthDay = new Temporal.PlainMonthDay(5, 2, calendar); + const plainYearMonth = new Temporal.PlainYearMonth(2000, 5, calendar); + const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); + + [plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((temporalObject) => { + const actual = []; + const expected = []; + + Object.defineProperty(temporalObject, "calendar", { + get() { + actual.push("get calendar"); + return calendar; + }, + }); + + func(temporalObject, calendar); + assert.compareArray(actual, expected, "calendar getter not called"); + }); + }, + + checkToTemporalInstantFastPath(func) { + const actual = []; + const expected = []; + + const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); + Object.defineProperty(datetime, 'toString', { + get() { + actual.push("get toString"); + return function (options) { + actual.push("call toString"); + return Temporal.ZonedDateTime.prototype.toString.call(this, options); + }; + }, + }); + + func(datetime); + assert.compareArray(actual, expected, "toString not called"); + }, + + checkToTemporalPlainDateTimeFastPath(func) { + const actual = []; + const expected = []; + + const calendar = new Temporal.Calendar("iso8601"); + const date = new Temporal.PlainDate(2000, 5, 2, calendar); + const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.PlainDate.prototype); + ["year", "month", "monthCode", "day"].forEach((property) => { + Object.defineProperty(date, property, { + get() { + actual.push(`get ${formatPropertyName(property)}`); + const value = prototypeDescrs[property].get.call(this); + return TemporalHelpers.toPrimitiveObserver(actual, value, property); + }, + }); + }); + ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"].forEach((property) => { + Object.defineProperty(date, property, { + get() { + actual.push(`get ${formatPropertyName(property)}`); + return undefined; + }, + }); + }); + Object.defineProperty(date, "calendar", { + get() { + actual.push("get calendar"); + return calendar; + }, + }); + + func(date, calendar); + assert.compareArray(actual, expected, "property getters not called"); + }, + + /* + * A custom calendar used in prototype pollution checks. Verifies that the + * fromFields methods are always called with a null-prototype fields object. + */ + calendarCheckFieldsPrototypePollution() { + class CalendarCheckFieldsPrototypePollution extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateFromFieldsCallCount = 0; + this.yearMonthFromFieldsCallCount = 0; + this.monthDayFromFieldsCallCount = 0; + } + + // toString must remain "iso8601", so that some methods don't throw due to + // incompatible calendars + + dateFromFields(fields, options = {}) { + this.dateFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "dateFromFields should be called with null-prototype fields object"); + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options = {}) { + this.yearMonthFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "yearMonthFromFields should be called with null-prototype fields object"); + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options = {}) { + this.monthDayFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "monthDayFromFields should be called with null-prototype fields object"); + return super.monthDayFromFields(fields, options); + } + } + + return new CalendarCheckFieldsPrototypePollution(); + }, + + /* + * A custom calendar used in prototype pollution checks. Verifies that the + * mergeFields() method is always called with null-prototype fields objects. + */ + calendarCheckMergeFieldsPrototypePollution() { + class CalendarCheckMergeFieldsPrototypePollution extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.mergeFieldsCallCount = 0; + } + + toString() { + return "merge-fields-null-proto"; + } + + mergeFields(fields, additionalFields) { + this.mergeFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(fields), null, "mergeFields should be called with null-prototype fields object (first argument)"); + assert.sameValue(Object.getPrototypeOf(additionalFields), null, "mergeFields should be called with null-prototype fields object (second argument)"); + return super.mergeFields(fields, additionalFields); + } + } + + return new CalendarCheckMergeFieldsPrototypePollution(); + }, + + /* + * A custom calendar used in prototype pollution checks. Verifies that methods + * are always called with a null-prototype options object. + */ + calendarCheckOptionsPrototypePollution() { + class CalendarCheckOptionsPrototypePollution extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.yearMonthFromFieldsCallCount = 0; + this.dateUntilCallCount = 0; + } + + toString() { + return "options-null-proto"; + } + + yearMonthFromFields(fields, options) { + this.yearMonthFromFieldsCallCount++; + assert.sameValue(Object.getPrototypeOf(options), null, "yearMonthFromFields should be called with null-prototype options"); + return super.yearMonthFromFields(fields, options); + } + + dateUntil(one, two, options) { + this.dateUntilCallCount++; + assert.sameValue(Object.getPrototypeOf(options), null, "dateUntil should be called with null-prototype options"); + return super.dateUntil(one, two, options); + } + } + + return new CalendarCheckOptionsPrototypePollution(); + }, + + /* + * A custom calendar that asserts its dateAdd() method is called with the + * options parameter having the value undefined. + */ + calendarDateAddUndefinedOptions() { + class CalendarDateAddUndefinedOptions extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateAddCallCount = 0; + } + + toString() { + return "dateadd-undef-options"; + } + + dateAdd(date, duration, options) { + this.dateAddCallCount++; + assert.sameValue(options, undefined, "dateAdd shouldn't be called with options"); + return super.dateAdd(date, duration, options); + } + } + return new CalendarDateAddUndefinedOptions(); + }, + + /* + * A custom calendar that asserts its dateAdd() method is called with a + * PlainDate instance. Optionally, it also asserts that the PlainDate instance + * is the specific object `this.specificPlainDate`, if it is set by the + * calling code. + */ + calendarDateAddPlainDateInstance() { + class CalendarDateAddPlainDateInstance extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateAddCallCount = 0; + this.specificPlainDate = undefined; + } + + toString() { + return "dateadd-plain-date-instance"; + } + + dateFromFields(...args) { + return super.dateFromFields(...args).withCalendar(this); + } + + dateAdd(date, duration, options) { + this.dateAddCallCount++; + assert(date instanceof Temporal.PlainDate, "dateAdd() should be called with a PlainDate instance"); + if (this.dateAddCallCount === 1 && this.specificPlainDate) { + assert.sameValue(date, this.specificPlainDate, `dateAdd() should be called first with the specific PlainDate instance ${this.specificPlainDate}`); + } + return super.dateAdd(date, duration, options).withCalendar(this); + } + } + return new CalendarDateAddPlainDateInstance(); + }, + + /* + * A custom calendar that returns @returnValue from its dateUntil() method, + * recording the call in @calls. + */ + calendarDateUntilObservable(calls, returnValue) { + class CalendarDateUntilObservable extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateUntil() { + calls.push("call dateUntil"); + return returnValue; + } + } + + return new CalendarDateUntilObservable(); + }, + + /* + * A custom calendar that returns an iterable instead of an array from its + * fields() method, otherwise identical to the ISO calendar. + */ + calendarFieldsIterable() { + class CalendarFieldsIterable extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.fieldsCallCount = 0; + this.fieldsCalledWith = []; + this.iteratorExhausted = []; + } + + toString() { + return "fields-iterable"; + } + + fields(fieldNames) { + this.fieldsCallCount++; + this.fieldsCalledWith.push(fieldNames.slice()); + this.iteratorExhausted.push(false); + return { + callIndex: this.fieldsCallCount - 1, + calendar: this, + *[Symbol.iterator]() { + yield* this.calendar.fieldsCalledWith[this.callIndex]; + this.calendar.iteratorExhausted[this.callIndex] = true; + }, + }; + } + } + return new CalendarFieldsIterable(); + }, + + /* + * A custom calendar that asserts its ...FromFields() methods are called with + * the options parameter having the value undefined. + */ + calendarFromFieldsUndefinedOptions() { + class CalendarFromFieldsUndefinedOptions extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.dateFromFieldsCallCount = 0; + this.monthDayFromFieldsCallCount = 0; + this.yearMonthFromFieldsCallCount = 0; + } + + toString() { + return "from-fields-undef-options"; + } + + dateFromFields(fields, options) { + this.dateFromFieldsCallCount++; + assert.sameValue(options, undefined, "dateFromFields shouldn't be called with options"); + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options) { + this.yearMonthFromFieldsCallCount++; + assert.sameValue(options, undefined, "yearMonthFromFields shouldn't be called with options"); + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options) { + this.monthDayFromFieldsCallCount++; + assert.sameValue(options, undefined, "monthDayFromFields shouldn't be called with options"); + return super.monthDayFromFields(fields, options); + } + } + return new CalendarFromFieldsUndefinedOptions(); + }, + + /* + * A custom calendar that modifies the fields object passed in to + * dateFromFields, sabotaging its time properties. + */ + calendarMakeInfinityTime() { + class CalendarMakeInfinityTime extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateFromFields(fields, options) { + const retval = super.dateFromFields(fields, options); + fields.hour = Infinity; + fields.minute = Infinity; + fields.second = Infinity; + fields.millisecond = Infinity; + fields.microsecond = Infinity; + fields.nanosecond = Infinity; + return retval; + } + } + return new CalendarMakeInfinityTime(); + }, + + /* + * A custom calendar that defines getters on the fields object passed into + * dateFromFields that throw, sabotaging its time properties. + */ + calendarMakeInvalidGettersTime() { + class CalendarMakeInvalidGettersTime extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + + dateFromFields(fields, options) { + const retval = super.dateFromFields(fields, options); + const throwingDescriptor = { + get() { + throw new Test262Error("reading a sabotaged time field"); + }, + }; + Object.defineProperties(fields, { + hour: throwingDescriptor, + minute: throwingDescriptor, + second: throwingDescriptor, + millisecond: throwingDescriptor, + microsecond: throwingDescriptor, + nanosecond: throwingDescriptor, + }); + return retval; + } + } + return new CalendarMakeInvalidGettersTime(); + }, + + /* + * A custom calendar whose mergeFields() method returns a proxy object with + * all of its Get and HasProperty operations observable, as well as adding a + * "shouldNotBeCopied": true property. + */ + calendarMergeFieldsGetters() { + class CalendarMergeFieldsGetters extends Temporal.Calendar { + constructor() { + super("iso8601"); + this.mergeFieldsReturnOperations = []; + } + + toString() { + return "merge-fields-getters"; + } + + dateFromFields(fields, options) { + assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options) { + assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options) { + assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); + return super.monthDayFromFields(fields, options); + } + + mergeFields(fields, additionalFields) { + const retval = super.mergeFields(fields, additionalFields); + retval._calendar = this; + retval.shouldNotBeCopied = true; + return new Proxy(retval, { + get(target, key) { + target._calendar.mergeFieldsReturnOperations.push(`get ${key}`); + const result = target[key]; + if (result === undefined) { + return undefined; + } + return TemporalHelpers.toPrimitiveObserver(target._calendar.mergeFieldsReturnOperations, result, key); + }, + has(target, key) { + target._calendar.mergeFieldsReturnOperations.push(`has ${key}`); + return key in target; + }, + }); + } + } + return new CalendarMergeFieldsGetters(); + }, + + /* + * A custom calendar whose mergeFields() method returns a primitive value, + * given by @primitive, and which records the number of calls made to its + * dateFromFields(), yearMonthFromFields(), and monthDayFromFields() methods. + */ + calendarMergeFieldsReturnsPrimitive(primitive) { + class CalendarMergeFieldsPrimitive extends Temporal.Calendar { + constructor(mergeFieldsReturnValue) { + super("iso8601"); + this._mergeFieldsReturnValue = mergeFieldsReturnValue; + this.dateFromFieldsCallCount = 0; + this.monthDayFromFieldsCallCount = 0; + this.yearMonthFromFieldsCallCount = 0; + } + + toString() { + return "merge-fields-primitive"; + } + + dateFromFields(fields, options) { + this.dateFromFieldsCallCount++; + return super.dateFromFields(fields, options); + } + + yearMonthFromFields(fields, options) { + this.yearMonthFromFieldsCallCount++; + return super.yearMonthFromFields(fields, options); + } + + monthDayFromFields(fields, options) { + this.monthDayFromFieldsCallCount++; + return super.monthDayFromFields(fields, options); + } + + mergeFields() { + return this._mergeFieldsReturnValue; + } + } + return new CalendarMergeFieldsPrimitive(primitive); + }, + + /* + * crossDateLineTimeZone(): + * + * This returns an instance of a custom time zone class that implements one + * single transition where the time zone moves from one side of the + * International Date Line to the other, for the purpose of testing time zone + * calculations without depending on system time zone data. + * + * The transition occurs at epoch second 1325239200 and goes from offset + * -10:00 to +14:00. In other words, the time zone skips the whole calendar + * day of 2011-12-30. This is the same as the real-life transition in the + * Pacific/Apia time zone. + */ + crossDateLineTimeZone() { + const { compare } = Temporal.PlainDateTime; + const skippedDay = new Temporal.PlainDate(2011, 12, 30); + const transitionEpoch = 1325239200_000_000_000n; + const beforeOffset = new Temporal.TimeZone("-10:00"); + const afterOffset = new Temporal.TimeZone("+14:00"); + + class CrossDateLineTimeZone extends Temporal.TimeZone { + constructor() { + super("+14:00"); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < transitionEpoch) { + return beforeOffset.getOffsetNanosecondsFor(instant); + } + return afterOffset.getOffsetNanosecondsFor(instant); + } + + getPossibleInstantsFor(datetime) { + const comparison = Temporal.PlainDate.compare(datetime.toPlainDate(), skippedDay); + if (comparison === 0) { + return []; + } + if (comparison < 0) { + return [beforeOffset.getInstantFor(datetime)]; + } + return [afterOffset.getInstantFor(datetime)]; + } + + getPreviousTransition(instant) { + if (instant.epochNanoseconds > transitionEpoch) return new Temporal.Instant(transitionEpoch); + return null; + } + + getNextTransition(instant) { + if (instant.epochNanoseconds < transitionEpoch) return new Temporal.Instant(transitionEpoch); + return null; + } + + toString() { + return "Custom/Date_Line"; + } + } + return new CrossDateLineTimeZone(); + }, + + /* + * observeProperty(calls, object, propertyName, value): + * + * Defines an own property @object.@propertyName with value @value, that + * will log any calls to its accessors to the array @calls. + */ + observeProperty(calls, object, propertyName, value, objectName = "") { + Object.defineProperty(object, propertyName, { + get() { + calls.push(`get ${formatPropertyName(propertyName, objectName)}`); + return value; + }, + set(v) { + calls.push(`set ${formatPropertyName(propertyName, objectName)}`); + } + }); + }, + + /* + * observeMethod(calls, object, propertyName, value): + * + * Defines an own property @object.@propertyName with value @value, that + * will log any calls of @value to the array @calls. + */ + observeMethod(calls, object, propertyName, objectName = "") { + const method = object[propertyName]; + object[propertyName] = function () { + calls.push(`call ${formatPropertyName(propertyName, objectName)}`); + return method.apply(object, arguments); + }; + }, + + /* + * Used for substituteMethod to indicate default behavior instead of a + * substituted value + */ + SUBSTITUTE_SKIP: SKIP_SYMBOL, + + /* + * substituteMethod(object, propertyName, values): + * + * Defines an own property @object.@propertyName that will, for each + * subsequent call to the method previously defined as + * @object.@propertyName: + * - Call the method, if no more values remain + * - Call the method, if the value in @values for the corresponding call + * is SUBSTITUTE_SKIP + * - Otherwise, return the corresponding value in @value + */ + substituteMethod(object, propertyName, values) { + let calls = 0; + const method = object[propertyName]; + object[propertyName] = function () { + if (calls >= values.length) { + return method.apply(object, arguments); + } else if (values[calls] === SKIP_SYMBOL) { + calls++; + return method.apply(object, arguments); + } else { + return values[calls++]; + } + }; + }, + + /* + * calendarObserver: + * A custom calendar that behaves exactly like the ISO 8601 calendar but + * tracks calls to any of its methods, and Get/Has operations on its + * properties, by appending messages to an array. This is for the purpose of + * testing order of operations that are observable from user code. + * objectName is used in the log. + */ + calendarObserver(calls, objectName, methodOverrides = {}) { + function removeExtraHasPropertyChecks(objectName, calls) { + // Inserting the tracking calendar into the return values of methods + // that we chain up into the ISO calendar for, causes extra HasProperty + // checks, which we observe. This removes them so that we don't leak + // implementation details of the helper into the test code. + assert.sameValue(calls.pop(), `has ${objectName}.yearOfWeek`); + assert.sameValue(calls.pop(), `has ${objectName}.yearMonthFromFields`); + assert.sameValue(calls.pop(), `has ${objectName}.year`); + assert.sameValue(calls.pop(), `has ${objectName}.weekOfYear`); + assert.sameValue(calls.pop(), `has ${objectName}.monthsInYear`); + assert.sameValue(calls.pop(), `has ${objectName}.monthDayFromFields`); + assert.sameValue(calls.pop(), `has ${objectName}.monthCode`); + assert.sameValue(calls.pop(), `has ${objectName}.month`); + assert.sameValue(calls.pop(), `has ${objectName}.mergeFields`); + assert.sameValue(calls.pop(), `has ${objectName}.inLeapYear`); + assert.sameValue(calls.pop(), `has ${objectName}.id`); + assert.sameValue(calls.pop(), `has ${objectName}.fields`); + assert.sameValue(calls.pop(), `has ${objectName}.daysInYear`); + assert.sameValue(calls.pop(), `has ${objectName}.daysInWeek`); + assert.sameValue(calls.pop(), `has ${objectName}.daysInMonth`); + assert.sameValue(calls.pop(), `has ${objectName}.dayOfYear`); + assert.sameValue(calls.pop(), `has ${objectName}.dayOfWeek`); + assert.sameValue(calls.pop(), `has ${objectName}.day`); + assert.sameValue(calls.pop(), `has ${objectName}.dateUntil`); + assert.sameValue(calls.pop(), `has ${objectName}.dateFromFields`); + assert.sameValue(calls.pop(), `has ${objectName}.dateAdd`); + } + + const iso8601 = new Temporal.Calendar("iso8601"); + const trackingMethods = { + dateFromFields(...args) { + calls.push(`call ${objectName}.dateFromFields`); + if ('dateFromFields' in methodOverrides) { + const value = methodOverrides.dateFromFields; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.dateFromFields(...args); + // Replace the calendar in the result with the call-tracking calendar + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + yearMonthFromFields(...args) { + calls.push(`call ${objectName}.yearMonthFromFields`); + if ('yearMonthFromFields' in methodOverrides) { + const value = methodOverrides.yearMonthFromFields; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.yearMonthFromFields(...args); + // Replace the calendar in the result with the call-tracking calendar + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + monthDayFromFields(...args) { + calls.push(`call ${objectName}.monthDayFromFields`); + if ('monthDayFromFields' in methodOverrides) { + const value = methodOverrides.monthDayFromFields; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.monthDayFromFields(...args); + // Replace the calendar in the result with the call-tracking calendar + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + dateAdd(...args) { + calls.push(`call ${objectName}.dateAdd`); + if ('dateAdd' in methodOverrides) { + const value = methodOverrides.dateAdd; + return typeof value === "function" ? value(...args) : value; + } + const originalResult = iso8601.dateAdd(...args); + const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); + const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this); + removeExtraHasPropertyChecks(objectName, calls); + return result; + }, + id: "iso8601", + }; + // Automatically generate the other methods that don't need any custom code + [ + "dateUntil", + "day", + "dayOfWeek", + "dayOfYear", + "daysInMonth", + "daysInWeek", + "daysInYear", + "era", + "eraYear", + "fields", + "inLeapYear", + "mergeFields", + "month", + "monthCode", + "monthsInYear", + "toString", + "weekOfYear", + "year", + "yearOfWeek", + ].forEach((methodName) => { + trackingMethods[methodName] = function (...args) { + calls.push(`call ${formatPropertyName(methodName, objectName)}`); + if (methodName in methodOverrides) { + const value = methodOverrides[methodName]; + return typeof value === "function" ? value(...args) : value; + } + return iso8601[methodName](...args); + }; + }); + return new Proxy(trackingMethods, { + get(target, key, receiver) { + const result = Reflect.get(target, key, receiver); + calls.push(`get ${formatPropertyName(key, objectName)}`); + return result; + }, + has(target, key) { + calls.push(`has ${formatPropertyName(key, objectName)}`); + return Reflect.has(target, key); + }, + }); + }, + + /* + * A custom calendar that does not allow any of its methods to be called, for + * the purpose of asserting that a particular operation does not call into + * user code. + */ + calendarThrowEverything() { + class CalendarThrowEverything extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + toString() { + TemporalHelpers.assertUnreachable("toString should not be called"); + } + dateFromFields() { + TemporalHelpers.assertUnreachable("dateFromFields should not be called"); + } + yearMonthFromFields() { + TemporalHelpers.assertUnreachable("yearMonthFromFields should not be called"); + } + monthDayFromFields() { + TemporalHelpers.assertUnreachable("monthDayFromFields should not be called"); + } + dateAdd() { + TemporalHelpers.assertUnreachable("dateAdd should not be called"); + } + dateUntil() { + TemporalHelpers.assertUnreachable("dateUntil should not be called"); + } + era() { + TemporalHelpers.assertUnreachable("era should not be called"); + } + eraYear() { + TemporalHelpers.assertUnreachable("eraYear should not be called"); + } + year() { + TemporalHelpers.assertUnreachable("year should not be called"); + } + month() { + TemporalHelpers.assertUnreachable("month should not be called"); + } + monthCode() { + TemporalHelpers.assertUnreachable("monthCode should not be called"); + } + day() { + TemporalHelpers.assertUnreachable("day should not be called"); + } + fields() { + TemporalHelpers.assertUnreachable("fields should not be called"); + } + mergeFields() { + TemporalHelpers.assertUnreachable("mergeFields should not be called"); + } + } + + return new CalendarThrowEverything(); + }, + + /* + * oneShiftTimeZone(shiftInstant, shiftNanoseconds): + * + * In the case of a spring-forward time zone offset transition (skipped time), + * and disambiguation === 'earlier', BuiltinTimeZoneGetInstantFor subtracts a + * negative number of nanoseconds from a PlainDateTime, which should balance + * with the microseconds field. + * + * This returns an instance of a custom time zone class which skips a length + * of time equal to shiftNanoseconds (a number), at the Temporal.Instant + * shiftInstant. Before shiftInstant, it's identical to UTC, and after + * shiftInstant it's a constant-offset time zone. + * + * It provides a getPossibleInstantsForCalledWith member which is an array + * with the result of calling toString() on any PlainDateTimes passed to + * getPossibleInstantsFor(). + */ + oneShiftTimeZone(shiftInstant, shiftNanoseconds) { + class OneShiftTimeZone extends Temporal.TimeZone { + constructor(shiftInstant, shiftNanoseconds) { + super("+00:00"); + this._shiftInstant = shiftInstant; + this._epoch1 = shiftInstant.epochNanoseconds; + this._epoch2 = this._epoch1 + BigInt(shiftNanoseconds); + this._shiftNanoseconds = shiftNanoseconds; + this._shift = new Temporal.Duration(0, 0, 0, 0, 0, 0, 0, 0, 0, this._shiftNanoseconds); + this.getPossibleInstantsForCalledWith = []; + } + + _isBeforeShift(instant) { + return instant.epochNanoseconds < this._epoch1; + } + + getOffsetNanosecondsFor(instant) { + return this._isBeforeShift(instant) ? 0 : this._shiftNanoseconds; + } + + getPossibleInstantsFor(plainDateTime) { + this.getPossibleInstantsForCalledWith.push(plainDateTime.toString()); + const [instant] = super.getPossibleInstantsFor(plainDateTime); + if (this._shiftNanoseconds > 0) { + if (this._isBeforeShift(instant)) return [instant]; + if (instant.epochNanoseconds < this._epoch2) return []; + return [instant.subtract(this._shift)]; + } + if (instant.epochNanoseconds < this._epoch2) return [instant]; + const shifted = instant.subtract(this._shift); + if (this._isBeforeShift(instant)) return [instant, shifted]; + return [shifted]; + } + + getNextTransition(instant) { + return this._isBeforeShift(instant) ? this._shiftInstant : null; + } + + getPreviousTransition(instant) { + return this._isBeforeShift(instant) ? null : this._shiftInstant; + } + + toString() { + return "Custom/One_Shift"; + } + } + return new OneShiftTimeZone(shiftInstant, shiftNanoseconds); + }, + + /* + * propertyBagObserver(): + * Returns an object that behaves like the given propertyBag but tracks Get + * and Has operations on any of its properties, by appending messages to an + * array. If the value of a property in propertyBag is a primitive, the value + * of the returned object's property will additionally be a + * TemporalHelpers.toPrimitiveObserver that will track calls to its toString + * and valueOf methods in the same array. This is for the purpose of testing + * order of operations that are observable from user code. objectName is used + * in the log. + */ + propertyBagObserver(calls, propertyBag, objectName) { + return new Proxy(propertyBag, { + ownKeys(target) { + calls.push(`ownKeys ${objectName}`); + return Reflect.ownKeys(target); + }, + getOwnPropertyDescriptor(target, key) { + calls.push(`getOwnPropertyDescriptor ${formatPropertyName(key, objectName)}`); + return Reflect.getOwnPropertyDescriptor(target, key); + }, + get(target, key, receiver) { + calls.push(`get ${formatPropertyName(key, objectName)}`); + const result = Reflect.get(target, key, receiver); + if (result === undefined) { + return undefined; + } + if ((result !== null && typeof result === "object") || typeof result === "function") { + return result; + } + return TemporalHelpers.toPrimitiveObserver(calls, result, `${formatPropertyName(key, objectName)}`); + }, + has(target, key) { + calls.push(`has ${formatPropertyName(key, objectName)}`); + return Reflect.has(target, key); + }, + }); + }, + + /* + * specificOffsetTimeZone(): + * + * This returns an instance of a custom time zone class, which returns a + * specific custom value from its getOffsetNanosecondsFrom() method. This is + * for the purpose of testing the validation of what this method returns. + * + * It also returns an empty array from getPossibleInstantsFor(), so as to + * trigger calls to getOffsetNanosecondsFor() when used from the + * BuiltinTimeZoneGetInstantFor operation. + */ + specificOffsetTimeZone(offsetValue) { + class SpecificOffsetTimeZone extends Temporal.TimeZone { + constructor(offsetValue) { + super("UTC"); + this._offsetValue = offsetValue; + } + + getOffsetNanosecondsFor() { + return this._offsetValue; + } + + getPossibleInstantsFor() { + return []; + } + } + return new SpecificOffsetTimeZone(offsetValue); + }, + + /* + * springForwardFallBackTimeZone(): + * + * This returns an instance of a custom time zone class that implements one + * single spring-forward/fall-back transition, for the purpose of testing the + * disambiguation option, without depending on system time zone data. + * + * The spring-forward occurs at epoch second 954669600 (2000-04-02T02:00 + * local) and goes from offset -08:00 to -07:00. + * + * The fall-back occurs at epoch second 972810000 (2000-10-29T02:00 local) and + * goes from offset -07:00 to -08:00. + */ + springForwardFallBackTimeZone() { + const { compare } = Temporal.PlainDateTime; + const springForwardLocal = new Temporal.PlainDateTime(2000, 4, 2, 2); + const springForwardEpoch = 954669600_000_000_000n; + const fallBackLocal = new Temporal.PlainDateTime(2000, 10, 29, 1); + const fallBackEpoch = 972810000_000_000_000n; + const winterOffset = new Temporal.TimeZone('-08:00'); + const summerOffset = new Temporal.TimeZone('-07:00'); + + class SpringForwardFallBackTimeZone extends Temporal.TimeZone { + constructor() { + super("-08:00"); + } + + getOffsetNanosecondsFor(instant) { + if (instant.epochNanoseconds < springForwardEpoch || + instant.epochNanoseconds >= fallBackEpoch) { + return winterOffset.getOffsetNanosecondsFor(instant); + } + return summerOffset.getOffsetNanosecondsFor(instant); + } + + getPossibleInstantsFor(datetime) { + if (compare(datetime, springForwardLocal) >= 0 && compare(datetime, springForwardLocal.add({ hours: 1 })) < 0) { + return []; + } + if (compare(datetime, fallBackLocal) >= 0 && compare(datetime, fallBackLocal.add({ hours: 1 })) < 0) { + return [summerOffset.getInstantFor(datetime), winterOffset.getInstantFor(datetime)]; + } + if (compare(datetime, springForwardLocal) < 0 || compare(datetime, fallBackLocal) >= 0) { + return [winterOffset.getInstantFor(datetime)]; + } + return [summerOffset.getInstantFor(datetime)]; + } + + getPreviousTransition(instant) { + if (instant.epochNanoseconds > fallBackEpoch) return new Temporal.Instant(fallBackEpoch); + if (instant.epochNanoseconds > springForwardEpoch) return new Temporal.Instant(springForwardEpoch); + return null; + } + + getNextTransition(instant) { + if (instant.epochNanoseconds < springForwardEpoch) return new Temporal.Instant(springForwardEpoch); + if (instant.epochNanoseconds < fallBackEpoch) return new Temporal.Instant(fallBackEpoch); + return null; + } + + get id() { + return "Custom/Spring_Fall"; + } + + toString() { + return "Custom/Spring_Fall"; + } + } + return new SpringForwardFallBackTimeZone(); + }, + + /* + * timeZoneObserver: + * A custom calendar that behaves exactly like the UTC time zone but tracks + * calls to any of its methods, and Get/Has operations on its properties, by + * appending messages to an array. This is for the purpose of testing order of + * operations that are observable from user code. objectName is used in the + * log. methodOverrides is an optional object containing properties with the + * same name as Temporal.TimeZone methods. If the property value is a function + * it will be called with the proper arguments instead of the UTC method. + * Otherwise, the property value will be returned directly. + */ + timeZoneObserver(calls, objectName, methodOverrides = {}) { + const utc = new Temporal.TimeZone("UTC"); + const trackingMethods = { + id: "UTC", + }; + // Automatically generate the methods + ["getOffsetNanosecondsFor", "getPossibleInstantsFor", "toString"].forEach((methodName) => { + trackingMethods[methodName] = function (...args) { + calls.push(`call ${formatPropertyName(methodName, objectName)}`); + if (methodName in methodOverrides) { + const value = methodOverrides[methodName]; + return typeof value === "function" ? value(...args) : value; + } + return utc[methodName](...args); + }; + }); + return new Proxy(trackingMethods, { + get(target, key, receiver) { + const result = Reflect.get(target, key, receiver); + calls.push(`get ${formatPropertyName(key, objectName)}`); + return result; + }, + has(target, key) { + calls.push(`has ${formatPropertyName(key, objectName)}`); + return Reflect.has(target, key); + }, + }); + }, + + /* + * Returns an object that will append logs of any Gets or Calls of its valueOf + * or toString properties to the array calls. Both valueOf and toString will + * return the actual primitiveValue. propertyName is used in the log. + */ + toPrimitiveObserver(calls, primitiveValue, propertyName) { + return { + get valueOf() { + calls.push(`get ${propertyName}.valueOf`); + return function () { + calls.push(`call ${propertyName}.valueOf`); + return primitiveValue; + }; + }, + get toString() { + calls.push(`get ${propertyName}.toString`); + return function () { + calls.push(`call ${propertyName}.toString`); + if (primitiveValue === undefined) return undefined; + return primitiveValue.toString(); + }; + }, + }; + }, + + /* + * An object containing further methods that return arrays of ISO strings, for + * testing parsers. + */ + ISO: { + /* + * PlainMonthDay strings that are not valid. + */ + plainMonthDayStringsInvalid() { + return [ + "11-18junk", + ]; + }, + + /* + * PlainMonthDay strings that are valid and that should produce October 1st. + */ + plainMonthDayStringsValid() { + return [ + "10-01", + "1001", + "1965-10-01", + "1976-10-01T152330.1+00:00", + "19761001T15:23:30.1+00:00", + "1976-10-01T15:23:30.1+0000", + "1976-10-01T152330.1+0000", + "19761001T15:23:30.1+0000", + "19761001T152330.1+00:00", + "19761001T152330.1+0000", + "+001976-10-01T152330.1+00:00", + "+0019761001T15:23:30.1+00:00", + "+001976-10-01T15:23:30.1+0000", + "+001976-10-01T152330.1+0000", + "+0019761001T15:23:30.1+0000", + "+0019761001T152330.1+00:00", + "+0019761001T152330.1+0000", + "1976-10-01T15:23:00", + "1976-10-01T15:23", + "1976-10-01T15", + "1976-10-01", + "--10-01", + "--1001", + ]; + }, + + /* + * PlainTime strings that may be mistaken for PlainMonthDay or + * PlainYearMonth strings, and so require a time designator. + */ + plainTimeStringsAmbiguous() { + const ambiguousStrings = [ + "2021-12", // ambiguity between YYYY-MM and HHMM-UU + "2021-12[-12:00]", // ditto, TZ does not disambiguate + "1214", // ambiguity between MMDD and HHMM + "0229", // ditto, including MMDD that doesn't occur every year + "1130", // ditto, including DD that doesn't occur in every month + "12-14", // ambiguity between MM-DD and HH-UU + "12-14[-14:00]", // ditto, TZ does not disambiguate + "202112", // ambiguity between YYYYMM and HHMMSS + "202112[UTC]", // ditto, TZ does not disambiguate + ]; + // Adding a calendar annotation to one of these strings must not cause + // disambiguation in favour of time. + const stringsWithCalendar = ambiguousStrings.map((s) => s + '[u-ca=iso8601]'); + return ambiguousStrings.concat(stringsWithCalendar); + }, + + /* + * PlainTime strings that are of similar form to PlainMonthDay and + * PlainYearMonth strings, but are not ambiguous due to components that + * aren't valid as months or days. + */ + plainTimeStringsUnambiguous() { + return [ + "2021-13", // 13 is not a month + "202113", // ditto + "2021-13[-13:00]", // ditto + "202113[-13:00]", // ditto + "0000-00", // 0 is not a month + "000000", // ditto + "0000-00[UTC]", // ditto + "000000[UTC]", // ditto + "1314", // 13 is not a month + "13-14", // ditto + "1232", // 32 is not a day + "0230", // 30 is not a day in February + "0631", // 31 is not a day in June + "0000", // 0 is neither a month nor a day + "00-00", // ditto + ]; + }, + + /* + * PlainYearMonth-like strings that are not valid. + */ + plainYearMonthStringsInvalid() { + return [ + "2020-13", + ]; + }, + + /* + * PlainYearMonth-like strings that are valid and should produce November + * 1976 in the ISO 8601 calendar. + */ + plainYearMonthStringsValid() { + return [ + "1976-11", + "1976-11-10", + "1976-11-01T09:00:00+00:00", + "1976-11-01T00:00:00+05:00", + "197611", + "+00197611", + "1976-11-18T15:23:30.1\u221202:00", + "1976-11-18T152330.1+00:00", + "19761118T15:23:30.1+00:00", + "1976-11-18T15:23:30.1+0000", + "1976-11-18T152330.1+0000", + "19761118T15:23:30.1+0000", + "19761118T152330.1+00:00", + "19761118T152330.1+0000", + "+001976-11-18T152330.1+00:00", + "+0019761118T15:23:30.1+00:00", + "+001976-11-18T15:23:30.1+0000", + "+001976-11-18T152330.1+0000", + "+0019761118T15:23:30.1+0000", + "+0019761118T152330.1+00:00", + "+0019761118T152330.1+0000", + "1976-11-18T15:23", + "1976-11-18T15", + "1976-11-18", + ]; + }, + + /* + * PlainYearMonth-like strings that are valid and should produce November of + * the ISO year -9999. + */ + plainYearMonthStringsValidNegativeYear() { + return [ + "\u2212009999-11", + ]; + }, + } +}; diff --git a/harness/testAtomics.js b/harness/testAtomics.js new file mode 100644 index 00000000000..8dd9ff365fa --- /dev/null +++ b/harness/testAtomics.js @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to assert the correctness of SharedArrayBuffer objects. +defines: + - testWithAtomicsOutOfBoundsIndices + - testWithAtomicsInBoundsIndices + - testWithAtomicsNonViewValues +---*/ + + +/** + * Calls the provided function for a each bad index that should throw a + * RangeError when passed to an Atomics method on a SAB-backed view where + * index 125 is out of range. + * + * @param f - the function to call for each bad index. + */ +function testWithAtomicsOutOfBoundsIndices(f) { + var bad_indices = [ + function(view) { return -1; }, + function(view) { return view.length; }, + function(view) { return view.length * 2; }, + function(view) { return Number.POSITIVE_INFINITY; }, + function(view) { return Number.NEGATIVE_INFINITY; }, + function(view) { return { valueOf: function() { return 125; } }; }, + function(view) { return { toString: function() { return '125'; }, valueOf: false }; }, // non-callable valueOf triggers invocation of toString + ]; + + for (var i = 0; i < bad_indices.length; ++i) { + var IdxGen = bad_indices[i]; + try { + f(IdxGen); + } catch (e) { + e.message += ' (Testing with index gen ' + IdxGen + '.)'; + throw e; + } + } +} + +/** + * Calls the provided function for each good index that should not throw when + * passed to an Atomics method on a SAB-backed view. + * + * The view must have length greater than zero. + * + * @param f - the function to call for each good index. + */ +function testWithAtomicsInBoundsIndices(f) { + // Most of these are eventually coerced to +0 by ToIndex. + var good_indices = [ + function(view) { return 0/-1; }, + function(view) { return '-0'; }, + function(view) { return undefined; }, + function(view) { return NaN; }, + function(view) { return 0.5; }, + function(view) { return '0.5'; }, + function(view) { return -0.9; }, + function(view) { return { password: 'qumquat' }; }, + function(view) { return view.length - 1; }, + function(view) { return { valueOf: function() { return 0; } }; }, + function(view) { return { toString: function() { return '0'; }, valueOf: false }; }, // non-callable valueOf triggers invocation of toString + ]; + + for (var i = 0; i < good_indices.length; ++i) { + var IdxGen = good_indices[i]; + try { + f(IdxGen); + } catch (e) { + e.message += ' (Testing with index gen ' + IdxGen + '.)'; + throw e; + } + } +} + +/** + * Calls the provided function for each value that should throw a TypeError + * when passed to an Atomics method as a view. + * + * @param f - the function to call for each non-view value. + */ + +function testWithAtomicsNonViewValues(f) { + var values = [ + null, + undefined, + true, + false, + new Boolean(true), + 10, + 3.14, + new Number(4), + 'Hi there', + new Date, + /a*utomaton/g, + { password: 'qumquat' }, + new DataView(new ArrayBuffer(10)), + new ArrayBuffer(128), + new SharedArrayBuffer(128), + new Error('Ouch'), + [1,1,2,3,5,8], + function(x) { return -x; }, + Symbol('halleluja'), + // TODO: Proxy? + Object, + Int32Array, + Date, + Math, + Atomics + ]; + + for (var i = 0; i < values.length; ++i) { + var nonView = values[i]; + try { + f(nonView); + } catch (e) { + e.message += ' (Testing with non-view value ' + nonView + '.)'; + throw e; + } + } +} + diff --git a/harness/testBigIntTypedArray.js b/harness/testBigIntTypedArray.js new file mode 100644 index 00000000000..4956aaa7e35 --- /dev/null +++ b/harness/testBigIntTypedArray.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to assert the correctness of BigInt TypedArray objects. +defines: + - TypedArray + - testWithBigIntTypedArrayConstructors +---*/ + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithBigIntTypedArrayConstructors(f, selected) { + /** + * Array containing every BigInt typed array constructor. + */ + var constructors = selected || [ + BigInt64Array, + BigUint64Array + ]; + + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} diff --git a/harness/testIntl.js b/harness/testIntl.js new file mode 100644 index 00000000000..94efe546c30 --- /dev/null +++ b/harness/testIntl.js @@ -0,0 +1,2510 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + This file contains shared functions for the tests in the conformance test + suite for the ECMAScript Internationalization API. +author: Norbert Lindenberg +defines: + - testWithIntlConstructors + - taintDataProperty + - taintMethod + - taintProperties + - taintArray + - getLocaleSupportInfo + - getInvalidLanguageTags + - isCanonicalizedStructurallyValidLanguageTag + - getInvalidLocaleArguments + - testOption + - testForUnwantedRegExpChanges + - allCalendars + - allCollations + - allNumberingSystems + - isValidNumberingSystem + - numberingSystemDigits + - allSimpleSanctionedUnits + - testNumberFormat + - getDateTimeComponents + - getDateTimeComponentValues + - isCanonicalizedStructurallyValidTimeZoneName +---*/ +/** + */ + + +/** + * @description Calls the provided function for every service constructor in + * the Intl object. + * @param {Function} f the function to call for each service constructor in + * the Intl object. + * @param {Function} Constructor the constructor object to test with. + */ +function testWithIntlConstructors(f) { + var constructors = ["Collator", "NumberFormat", "DateTimeFormat"]; + + // Optionally supported Intl constructors. + // NB: Intl.Locale isn't an Intl service constructor! + // Intl.DisplayNames cannot be called without type in options. + ["PluralRules", "RelativeTimeFormat", "ListFormat"].forEach(function(constructor) { + if (typeof Intl[constructor] === "function") { + constructors[constructors.length] = constructor; + } + }); + + constructors.forEach(function (constructor) { + var Constructor = Intl[constructor]; + try { + f(Constructor); + } catch (e) { + e.message += " (Testing with " + constructor + ".)"; + throw e; + } + }); +} + + +/** + * Taints a named data property of the given object by installing + * a setter that throws an exception. + * @param {object} obj the object whose data property to taint + * @param {string} property the property to taint + */ +function taintDataProperty(obj, property) { + Object.defineProperty(obj, property, { + set: function(value) { + throw new Test262Error("Client code can adversely affect behavior: setter for " + property + "."); + }, + enumerable: false, + configurable: true + }); +} + + +/** + * Taints a named method of the given object by replacing it with a function + * that throws an exception. + * @param {object} obj the object whose method to taint + * @param {string} property the name of the method to taint + */ +function taintMethod(obj, property) { + Object.defineProperty(obj, property, { + value: function() { + throw new Test262Error("Client code can adversely affect behavior: method " + property + "."); + }, + writable: true, + enumerable: false, + configurable: true + }); +} + + +/** + * Taints the given properties (and similarly named properties) by installing + * setters on Object.prototype that throw exceptions. + * @param {Array} properties an array of property names to taint + */ +function taintProperties(properties) { + properties.forEach(function (property) { + var adaptedProperties = [property, "__" + property, "_" + property, property + "_", property + "__"]; + adaptedProperties.forEach(function (property) { + taintDataProperty(Object.prototype, property); + }); + }); +} + + +/** + * Taints the Array object by creating a setter for the property "0" and + * replacing some key methods with functions that throw exceptions. + */ +function taintArray() { + taintDataProperty(Array.prototype, "0"); + taintMethod(Array.prototype, "indexOf"); + taintMethod(Array.prototype, "join"); + taintMethod(Array.prototype, "push"); + taintMethod(Array.prototype, "slice"); + taintMethod(Array.prototype, "sort"); +} + + +/** + * Gets locale support info for the given constructor object, which must be one + * of Intl constructors. + * @param {object} Constructor the constructor for which to get locale support info + * @param {object} options the options while calling the constructor + * @return {object} locale support info with the following properties: + * supported: array of fully supported language tags + * byFallback: array of language tags that are supported through fallbacks + * unsupported: array of unsupported language tags + */ +function getLocaleSupportInfo(Constructor, options) { + var languages = ["zh", "es", "en", "hi", "ur", "ar", "ja", "pa"]; + var scripts = ["Latn", "Hans", "Deva", "Arab", "Jpan", "Hant", "Guru"]; + var countries = ["CN", "IN", "US", "PK", "JP", "TW", "HK", "SG", "419"]; + + var allTags = []; + var i, j, k; + var language, script, country; + for (i = 0; i < languages.length; i++) { + language = languages[i]; + allTags.push(language); + for (j = 0; j < scripts.length; j++) { + script = scripts[j]; + allTags.push(language + "-" + script); + for (k = 0; k < countries.length; k++) { + country = countries[k]; + allTags.push(language + "-" + script + "-" + country); + } + } + for (k = 0; k < countries.length; k++) { + country = countries[k]; + allTags.push(language + "-" + country); + } + } + + var supported = []; + var byFallback = []; + var unsupported = []; + for (i = 0; i < allTags.length; i++) { + var request = allTags[i]; + var result = new Constructor([request], options).resolvedOptions().locale; + if (request === result) { + supported.push(request); + } else if (request.indexOf(result) === 0) { + byFallback.push(request); + } else { + unsupported.push(request); + } + } + + return { + supported: supported, + byFallback: byFallback, + unsupported: unsupported + }; +} + + +/** + * Returns an array of strings for which IsStructurallyValidLanguageTag() returns false + */ +function getInvalidLanguageTags() { + var invalidLanguageTags = [ + "", // empty tag + "i", // singleton alone + "x", // private use without subtag + "u", // extension singleton in first place + "419", // region code in first place + "u-nu-latn-cu-bob", // extension sequence without language + "hans-cmn-cn", // "hans" could theoretically be a 4-letter language code, + // but those can't be followed by extlang codes. + "cmn-hans-cn-u-u", // duplicate singleton + "cmn-hans-cn-t-u-ca-u", // duplicate singleton + "de-gregory-gregory", // duplicate variant + "*", // language range + "de-*", // language range + "中文", // non-ASCII letters + "en-ß", // non-ASCII letters + "ıd", // non-ASCII letters + "es-Latn-latn", // two scripts + "pl-PL-pl", // two regions + "u-ca-gregory", // extension in first place + "de-1996-1996", // duplicate numeric variant + "pt-u-ca-gregory-u-nu-latn", // duplicate singleton subtag + + // Invalid tags starting with: https://github.com/tc39/ecma402/pull/289 + "no-nyn", // regular grandfathered in BCP47, but invalid in UTS35 + "i-klingon", // irregular grandfathered in BCP47, but invalid in UTS35 + "zh-hak-CN", // language with extlang in BCP47, but invalid in UTS35 + "sgn-ils", // language with extlang in BCP47, but invalid in UTS35 + "x-foo", // privateuse-only in BCP47, but invalid in UTS35 + "x-en-US-12345", // more privateuse-only variants. + "x-12345-12345-en-US", + "x-en-US-12345-12345", + "x-en-u-foo", + "x-en-u-foo-u-bar", + "x-u-foo", + + // underscores in different parts of the language tag + "de_DE", + "DE_de", + "cmn_Hans", + "cmn-hans_cn", + "es_419", + "es-419-u-nu-latn-cu_bob", + "i_klingon", + "cmn-hans-cn-t-ca-u-ca-x_t-u", + "enochian_enochian", + "de-gregory_u-ca-gregory", + + "en\u0000", // null-terminator sequence + " en", // leading whitespace + "en ", // trailing whitespace + "it-IT-Latn", // country before script tag + "de-u", // incomplete Unicode extension sequences + "de-u-", + "de-u-ca-", + "de-u-ca-gregory-", + "si-x", // incomplete private-use tags + "x-", + "x-y-", + ]; + + // make sure the data above is correct + for (var i = 0; i < invalidLanguageTags.length; ++i) { + var invalidTag = invalidLanguageTags[i]; + assert( + !isCanonicalizedStructurallyValidLanguageTag(invalidTag), + "Test data \"" + invalidTag + "\" is a canonicalized and structurally valid language tag." + ); + } + + return invalidLanguageTags; +} + + +/** + * @description Tests whether locale is a String value representing a + * structurally valid and canonicalized BCP 47 language tag, as defined in + * sections 6.2.2 and 6.2.3 of the ECMAScript Internationalization API + * Specification. + * @param {String} locale the string to be tested. + * @result {Boolean} whether the test succeeded. + */ +function isCanonicalizedStructurallyValidLanguageTag(locale) { + + /** + * Regular expression defining Unicode BCP 47 Locale Identifiers. + * + * Spec: https://unicode.org/reports/tr35/#Unicode_locale_identifier + */ + var alpha = "[a-z]", + digit = "[0-9]", + alphanum = "[a-z0-9]", + variant = "(" + alphanum + "{5,8}|(?:" + digit + alphanum + "{3}))", + region = "(" + alpha + "{2}|" + digit + "{3})", + script = "(" + alpha + "{4})", + language = "(" + alpha + "{2,3}|" + alpha + "{5,8})", + privateuse = "(x(-[a-z0-9]{1,8})+)", + singleton = "(" + digit + "|[a-wy-z])", + attribute= "(" + alphanum + "{3,8})", + keyword = "(" + alphanum + alpha + "(-" + alphanum + "{3,8})*)", + unicode_locale_extensions = "(u((-" + keyword + ")+|((-" + attribute + ")+(-" + keyword + ")*)))", + tlang = "(" + language + "(-" + script + ")?(-" + region + ")?(-" + variant + ")*)", + tfield = "(" + alpha + digit + "(-" + alphanum + "{3,8})+)", + transformed_extensions = "(t((-" + tlang + "(-" + tfield + ")*)|(-" + tfield + ")+))", + other_singleton = "(" + digit + "|[a-sv-wy-z])", + other_extensions = "(" + other_singleton + "(-" + alphanum + "{2,8})+)", + extension = "(" + unicode_locale_extensions + "|" + transformed_extensions + "|" + other_extensions + ")", + locale_id = language + "(-" + script + ")?(-" + region + ")?(-" + variant + ")*(-" + extension + ")*(-" + privateuse + ")?", + languageTag = "^(" + locale_id + ")$", + languageTagRE = new RegExp(languageTag, "i"); + + var duplicateSingleton = "-" + singleton + "-(.*-)?\\1(?!" + alphanum + ")", + duplicateSingletonRE = new RegExp(duplicateSingleton, "i"), + duplicateVariant = "(" + alphanum + "{2,8}-)+" + variant + "-(" + alphanum + "{2,8}-)*\\2(?!" + alphanum + ")", + duplicateVariantRE = new RegExp(duplicateVariant, "i"); + + var transformKeyRE = new RegExp("^" + alpha + digit + "$", "i"); + + /** + * Verifies that the given string is a well-formed Unicode BCP 47 Locale Identifier + * with no duplicate variant or singleton subtags. + * + * Spec: ECMAScript Internationalization API Specification, draft, 6.2.2. + */ + function isStructurallyValidLanguageTag(locale) { + if (!languageTagRE.test(locale)) { + return false; + } + locale = locale.split(/-x-/)[0]; + return !duplicateSingletonRE.test(locale) && !duplicateVariantRE.test(locale); + } + + + /** + * Mappings from complete tags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __tagMappings = { + // property names must be in lower case; values in canonical form + + "art-lojban": "jbo", + "cel-gaulish": "xtg", + "zh-guoyu": "zh", + "zh-hakka": "hak", + "zh-xiang": "hsn", + }; + + + /** + * Mappings from language subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __languageMappings = { + // property names and values must be in canonical case + + "aam": "aas", + "aar": "aa", + "abk": "ab", + "adp": "dz", + "afr": "af", + "aju": "jrb", + "aka": "ak", + "alb": "sq", + "als": "sq", + "amh": "am", + "ara": "ar", + "arb": "ar", + "arg": "an", + "arm": "hy", + "asd": "snz", + "asm": "as", + "aue": "ktz", + "ava": "av", + "ave": "ae", + "aym": "ay", + "ayr": "ay", + "ayx": "nun", + "aze": "az", + "azj": "az", + "bak": "ba", + "bam": "bm", + "baq": "eu", + "bcc": "bal", + "bcl": "bik", + "bel": "be", + "ben": "bn", + "bgm": "bcg", + "bh": "bho", + "bih": "bho", + "bis": "bi", + "bjd": "drl", + "bod": "bo", + "bos": "bs", + "bre": "br", + "bul": "bg", + "bur": "my", + "bxk": "luy", + "bxr": "bua", + "cat": "ca", + "ccq": "rki", + "ces": "cs", + "cha": "ch", + "che": "ce", + "chi": "zh", + "chu": "cu", + "chv": "cv", + "cjr": "mom", + "cka": "cmr", + "cld": "syr", + "cmk": "xch", + "cmn": "zh", + "cor": "kw", + "cos": "co", + "coy": "pij", + "cqu": "quh", + "cre": "cr", + "cwd": "cr", + "cym": "cy", + "cze": "cs", + "dan": "da", + "deu": "de", + "dgo": "doi", + "dhd": "mwr", + "dik": "din", + "diq": "zza", + "dit": "dif", + "div": "dv", + "drh": "mn", + "dut": "nl", + "dzo": "dz", + "ekk": "et", + "ell": "el", + "emk": "man", + "eng": "en", + "epo": "eo", + "esk": "ik", + "est": "et", + "eus": "eu", + "ewe": "ee", + "fao": "fo", + "fas": "fa", + "fat": "ak", + "fij": "fj", + "fin": "fi", + "fra": "fr", + "fre": "fr", + "fry": "fy", + "fuc": "ff", + "ful": "ff", + "gav": "dev", + "gaz": "om", + "gbo": "grb", + "geo": "ka", + "ger": "de", + "gfx": "vaj", + "ggn": "gvr", + "gla": "gd", + "gle": "ga", + "glg": "gl", + "glv": "gv", + "gno": "gon", + "gre": "el", + "grn": "gn", + "gti": "nyc", + "gug": "gn", + "guj": "gu", + "guv": "duz", + "gya": "gba", + "hat": "ht", + "hau": "ha", + "hdn": "hai", + "hea": "hmn", + "heb": "he", + "her": "hz", + "him": "srx", + "hin": "hi", + "hmo": "ho", + "hrr": "jal", + "hrv": "hr", + "hun": "hu", + "hye": "hy", + "ibi": "opa", + "ibo": "ig", + "ice": "is", + "ido": "io", + "iii": "ii", + "ike": "iu", + "iku": "iu", + "ile": "ie", + "ilw": "gal", + "in": "id", + "ina": "ia", + "ind": "id", + "ipk": "ik", + "isl": "is", + "ita": "it", + "iw": "he", + "jav": "jv", + "jeg": "oyb", + "ji": "yi", + "jpn": "ja", + "jw": "jv", + "kal": "kl", + "kan": "kn", + "kas": "ks", + "kat": "ka", + "kau": "kr", + "kaz": "kk", + "kgc": "tdf", + "kgh": "kml", + "khk": "mn", + "khm": "km", + "kik": "ki", + "kin": "rw", + "kir": "ky", + "kmr": "ku", + "knc": "kr", + "kng": "kg", + "knn": "kok", + "koj": "kwv", + "kom": "kv", + "kon": "kg", + "kor": "ko", + "kpv": "kv", + "krm": "bmf", + "ktr": "dtp", + "kua": "kj", + "kur": "ku", + "kvs": "gdj", + "kwq": "yam", + "kxe": "tvd", + "kzj": "dtp", + "kzt": "dtp", + "lao": "lo", + "lat": "la", + "lav": "lv", + "lbk": "bnc", + "lii": "raq", + "lim": "li", + "lin": "ln", + "lit": "lt", + "llo": "ngt", + "lmm": "rmx", + "ltz": "lb", + "lub": "lu", + "lug": "lg", + "lvs": "lv", + "mac": "mk", + "mah": "mh", + "mal": "ml", + "mao": "mi", + "mar": "mr", + "may": "ms", + "meg": "cir", + "mhr": "chm", + "mkd": "mk", + "mlg": "mg", + "mlt": "mt", + "mnk": "man", + "mo": "ro", + "mol": "ro", + "mon": "mn", + "mri": "mi", + "msa": "ms", + "mst": "mry", + "mup": "raj", + "mwj": "vaj", + "mya": "my", + "myd": "aog", + "myt": "mry", + "nad": "xny", + "nau": "na", + "nav": "nv", + "nbl": "nr", + "ncp": "kdz", + "nde": "nd", + "ndo": "ng", + "nep": "ne", + "nld": "nl", + "nno": "nn", + "nns": "nbr", + "nnx": "ngv", + "no": "nb", + "nob": "nb", + "nor": "nb", + "npi": "ne", + "nts": "pij", + "nya": "ny", + "oci": "oc", + "ojg": "oj", + "oji": "oj", + "ori": "or", + "orm": "om", + "ory": "or", + "oss": "os", + "oun": "vaj", + "pan": "pa", + "pbu": "ps", + "pcr": "adx", + "per": "fa", + "pes": "fa", + "pli": "pi", + "plt": "mg", + "pmc": "huw", + "pmu": "phr", + "pnb": "lah", + "pol": "pl", + "por": "pt", + "ppa": "bfy", + "ppr": "lcq", + "pry": "prt", + "pus": "ps", + "puz": "pub", + "que": "qu", + "quz": "qu", + "rmy": "rom", + "roh": "rm", + "ron": "ro", + "rum": "ro", + "run": "rn", + "rus": "ru", + "sag": "sg", + "san": "sa", + "sca": "hle", + "scc": "sr", + "scr": "hr", + "sin": "si", + "skk": "oyb", + "slk": "sk", + "slo": "sk", + "slv": "sl", + "sme": "se", + "smo": "sm", + "sna": "sn", + "snd": "sd", + "som": "so", + "sot": "st", + "spa": "es", + "spy": "kln", + "sqi": "sq", + "src": "sc", + "srd": "sc", + "srp": "sr", + "ssw": "ss", + "sun": "su", + "swa": "sw", + "swe": "sv", + "swh": "sw", + "tah": "ty", + "tam": "ta", + "tat": "tt", + "tdu": "dtp", + "tel": "te", + "tgk": "tg", + "tgl": "fil", + "tha": "th", + "thc": "tpo", + "thx": "oyb", + "tib": "bo", + "tie": "ras", + "tir": "ti", + "tkk": "twm", + "tl": "fil", + "tlw": "weo", + "tmp": "tyj", + "tne": "kak", + "ton": "to", + "tsf": "taj", + "tsn": "tn", + "tso": "ts", + "ttq": "tmh", + "tuk": "tk", + "tur": "tr", + "tw": "ak", + "twi": "ak", + "uig": "ug", + "ukr": "uk", + "umu": "del", + "uok": "ema", + "urd": "ur", + "uzb": "uz", + "uzn": "uz", + "ven": "ve", + "vie": "vi", + "vol": "vo", + "wel": "cy", + "wln": "wa", + "wol": "wo", + "xba": "cax", + "xho": "xh", + "xia": "acn", + "xkh": "waw", + "xpe": "kpe", + "xsj": "suj", + "xsl": "den", + "ybd": "rki", + "ydd": "yi", + "yid": "yi", + "yma": "lrr", + "ymt": "mtm", + "yor": "yo", + "yos": "zom", + "yuu": "yug", + "zai": "zap", + "zha": "za", + "zho": "zh", + "zsm": "ms", + "zul": "zu", + "zyb": "za", + }; + + + /** + * Mappings from region subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __regionMappings = { + // property names and values must be in canonical case + + "004": "AF", + "008": "AL", + "010": "AQ", + "012": "DZ", + "016": "AS", + "020": "AD", + "024": "AO", + "028": "AG", + "031": "AZ", + "032": "AR", + "036": "AU", + "040": "AT", + "044": "BS", + "048": "BH", + "050": "BD", + "051": "AM", + "052": "BB", + "056": "BE", + "060": "BM", + "062": "034", + "064": "BT", + "068": "BO", + "070": "BA", + "072": "BW", + "074": "BV", + "076": "BR", + "084": "BZ", + "086": "IO", + "090": "SB", + "092": "VG", + "096": "BN", + "100": "BG", + "104": "MM", + "108": "BI", + "112": "BY", + "116": "KH", + "120": "CM", + "124": "CA", + "132": "CV", + "136": "KY", + "140": "CF", + "144": "LK", + "148": "TD", + "152": "CL", + "156": "CN", + "158": "TW", + "162": "CX", + "166": "CC", + "170": "CO", + "174": "KM", + "175": "YT", + "178": "CG", + "180": "CD", + "184": "CK", + "188": "CR", + "191": "HR", + "192": "CU", + "196": "CY", + "203": "CZ", + "204": "BJ", + "208": "DK", + "212": "DM", + "214": "DO", + "218": "EC", + "222": "SV", + "226": "GQ", + "230": "ET", + "231": "ET", + "232": "ER", + "233": "EE", + "234": "FO", + "238": "FK", + "239": "GS", + "242": "FJ", + "246": "FI", + "248": "AX", + "249": "FR", + "250": "FR", + "254": "GF", + "258": "PF", + "260": "TF", + "262": "DJ", + "266": "GA", + "268": "GE", + "270": "GM", + "275": "PS", + "276": "DE", + "278": "DE", + "280": "DE", + "288": "GH", + "292": "GI", + "296": "KI", + "300": "GR", + "304": "GL", + "308": "GD", + "312": "GP", + "316": "GU", + "320": "GT", + "324": "GN", + "328": "GY", + "332": "HT", + "334": "HM", + "336": "VA", + "340": "HN", + "344": "HK", + "348": "HU", + "352": "IS", + "356": "IN", + "360": "ID", + "364": "IR", + "368": "IQ", + "372": "IE", + "376": "IL", + "380": "IT", + "384": "CI", + "388": "JM", + "392": "JP", + "398": "KZ", + "400": "JO", + "404": "KE", + "408": "KP", + "410": "KR", + "414": "KW", + "417": "KG", + "418": "LA", + "422": "LB", + "426": "LS", + "428": "LV", + "430": "LR", + "434": "LY", + "438": "LI", + "440": "LT", + "442": "LU", + "446": "MO", + "450": "MG", + "454": "MW", + "458": "MY", + "462": "MV", + "466": "ML", + "470": "MT", + "474": "MQ", + "478": "MR", + "480": "MU", + "484": "MX", + "492": "MC", + "496": "MN", + "498": "MD", + "499": "ME", + "500": "MS", + "504": "MA", + "508": "MZ", + "512": "OM", + "516": "NA", + "520": "NR", + "524": "NP", + "528": "NL", + "531": "CW", + "533": "AW", + "534": "SX", + "535": "BQ", + "540": "NC", + "548": "VU", + "554": "NZ", + "558": "NI", + "562": "NE", + "566": "NG", + "570": "NU", + "574": "NF", + "578": "NO", + "580": "MP", + "581": "UM", + "583": "FM", + "584": "MH", + "585": "PW", + "586": "PK", + "591": "PA", + "598": "PG", + "600": "PY", + "604": "PE", + "608": "PH", + "612": "PN", + "616": "PL", + "620": "PT", + "624": "GW", + "626": "TL", + "630": "PR", + "634": "QA", + "638": "RE", + "642": "RO", + "643": "RU", + "646": "RW", + "652": "BL", + "654": "SH", + "659": "KN", + "660": "AI", + "662": "LC", + "663": "MF", + "666": "PM", + "670": "VC", + "674": "SM", + "678": "ST", + "682": "SA", + "686": "SN", + "688": "RS", + "690": "SC", + "694": "SL", + "702": "SG", + "703": "SK", + "704": "VN", + "705": "SI", + "706": "SO", + "710": "ZA", + "716": "ZW", + "720": "YE", + "724": "ES", + "728": "SS", + "729": "SD", + "732": "EH", + "736": "SD", + "740": "SR", + "744": "SJ", + "748": "SZ", + "752": "SE", + "756": "CH", + "760": "SY", + "762": "TJ", + "764": "TH", + "768": "TG", + "772": "TK", + "776": "TO", + "780": "TT", + "784": "AE", + "788": "TN", + "792": "TR", + "795": "TM", + "796": "TC", + "798": "TV", + "800": "UG", + "804": "UA", + "807": "MK", + "818": "EG", + "826": "GB", + "830": "JE", + "831": "GG", + "832": "JE", + "833": "IM", + "834": "TZ", + "840": "US", + "850": "VI", + "854": "BF", + "858": "UY", + "860": "UZ", + "862": "VE", + "876": "WF", + "882": "WS", + "886": "YE", + "887": "YE", + "891": "RS", + "894": "ZM", + "958": "AA", + "959": "QM", + "960": "QN", + "962": "QP", + "963": "QQ", + "964": "QR", + "965": "QS", + "966": "QT", + "967": "EU", + "968": "QV", + "969": "QW", + "970": "QX", + "971": "QY", + "972": "QZ", + "973": "XA", + "974": "XB", + "975": "XC", + "976": "XD", + "977": "XE", + "978": "XF", + "979": "XG", + "980": "XH", + "981": "XI", + "982": "XJ", + "983": "XK", + "984": "XL", + "985": "XM", + "986": "XN", + "987": "XO", + "988": "XP", + "989": "XQ", + "990": "XR", + "991": "XS", + "992": "XT", + "993": "XU", + "994": "XV", + "995": "XW", + "996": "XX", + "997": "XY", + "998": "XZ", + "999": "ZZ", + "BU": "MM", + "CS": "RS", + "CT": "KI", + "DD": "DE", + "DY": "BJ", + "FQ": "AQ", + "FX": "FR", + "HV": "BF", + "JT": "UM", + "MI": "UM", + "NH": "VU", + "NQ": "AQ", + "PU": "UM", + "PZ": "PA", + "QU": "EU", + "RH": "ZW", + "TP": "TL", + "UK": "GB", + "VD": "VN", + "WK": "UM", + "YD": "YE", + "YU": "RS", + "ZR": "CD", + }; + + + /** + * Complex mappings from language subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __complexLanguageMappings = { + // property names and values must be in canonical case + + "cnr": {language: "sr", region: "ME"}, + "drw": {language: "fa", region: "AF"}, + "hbs": {language: "sr", script: "Latn"}, + "prs": {language: "fa", region: "AF"}, + "sh": {language: "sr", script: "Latn"}, + "swc": {language: "sw", region: "CD"}, + "tnf": {language: "fa", region: "AF"}, + }; + + + /** + * Complex mappings from region subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __complexRegionMappings = { + // property names and values must be in canonical case + + "172": { + default: "RU", + "ab": "GE", + "az": "AZ", + "be": "BY", + "crh": "UA", + "gag": "MD", + "got": "UA", + "hy": "AM", + "ji": "UA", + "ka": "GE", + "kaa": "UZ", + "kk": "KZ", + "ku-Yezi": "GE", + "ky": "KG", + "os": "GE", + "rue": "UA", + "sog": "UZ", + "tg": "TJ", + "tk": "TM", + "tkr": "AZ", + "tly": "AZ", + "ttt": "AZ", + "ug-Cyrl": "KZ", + "uk": "UA", + "und-Armn": "AM", + "und-Chrs": "UZ", + "und-Geor": "GE", + "und-Goth": "UA", + "und-Sogd": "UZ", + "und-Sogo": "UZ", + "und-Yezi": "GE", + "uz": "UZ", + "xco": "UZ", + "xmf": "GE", + }, + "200": { + default: "CZ", + "sk": "SK", + }, + "530": { + default: "CW", + "vic": "SX", + }, + "532": { + default: "CW", + "vic": "SX", + }, + "536": { + default: "SA", + "akk": "IQ", + "ckb": "IQ", + "ku-Arab": "IQ", + "mis": "IQ", + "syr": "IQ", + "und-Hatr": "IQ", + "und-Syrc": "IQ", + "und-Xsux": "IQ", + }, + "582": { + default: "FM", + "mh": "MH", + "pau": "PW", + }, + "810": { + default: "RU", + "ab": "GE", + "az": "AZ", + "be": "BY", + "crh": "UA", + "et": "EE", + "gag": "MD", + "got": "UA", + "hy": "AM", + "ji": "UA", + "ka": "GE", + "kaa": "UZ", + "kk": "KZ", + "ku-Yezi": "GE", + "ky": "KG", + "lt": "LT", + "ltg": "LV", + "lv": "LV", + "os": "GE", + "rue": "UA", + "sgs": "LT", + "sog": "UZ", + "tg": "TJ", + "tk": "TM", + "tkr": "AZ", + "tly": "AZ", + "ttt": "AZ", + "ug-Cyrl": "KZ", + "uk": "UA", + "und-Armn": "AM", + "und-Chrs": "UZ", + "und-Geor": "GE", + "und-Goth": "UA", + "und-Sogd": "UZ", + "und-Sogo": "UZ", + "und-Yezi": "GE", + "uz": "UZ", + "vro": "EE", + "xco": "UZ", + "xmf": "GE", + }, + "890": { + default: "RS", + "bs": "BA", + "hr": "HR", + "mk": "MK", + "sl": "SI", + }, + "AN": { + default: "CW", + "vic": "SX", + }, + "NT": { + default: "SA", + "akk": "IQ", + "ckb": "IQ", + "ku-Arab": "IQ", + "mis": "IQ", + "syr": "IQ", + "und-Hatr": "IQ", + "und-Syrc": "IQ", + "und-Xsux": "IQ", + }, + "PC": { + default: "FM", + "mh": "MH", + "pau": "PW", + }, + "SU": { + default: "RU", + "ab": "GE", + "az": "AZ", + "be": "BY", + "crh": "UA", + "et": "EE", + "gag": "MD", + "got": "UA", + "hy": "AM", + "ji": "UA", + "ka": "GE", + "kaa": "UZ", + "kk": "KZ", + "ku-Yezi": "GE", + "ky": "KG", + "lt": "LT", + "ltg": "LV", + "lv": "LV", + "os": "GE", + "rue": "UA", + "sgs": "LT", + "sog": "UZ", + "tg": "TJ", + "tk": "TM", + "tkr": "AZ", + "tly": "AZ", + "ttt": "AZ", + "ug-Cyrl": "KZ", + "uk": "UA", + "und-Armn": "AM", + "und-Chrs": "UZ", + "und-Geor": "GE", + "und-Goth": "UA", + "und-Sogd": "UZ", + "und-Sogo": "UZ", + "und-Yezi": "GE", + "uz": "UZ", + "vro": "EE", + "xco": "UZ", + "xmf": "GE", + }, + }; + + + /** + * Mappings from variant subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __variantMappings = { + // property names and values must be in canonical case + + "aaland": {type: "region", replacement: "AX"}, + "arevela": {type: "language", replacement: "hy"}, + "arevmda": {type: "language", replacement: "hyw"}, + "heploc": {type: "variant", replacement: "alalc97"}, + "polytoni": {type: "variant", replacement: "polyton"}, + }; + + + /** + * Mappings from Unicode extension subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __unicodeMappings = { + // property names and values must be in canonical case + + "ca": { + "ethiopic-amete-alem": "ethioaa", + "islamicc": "islamic-civil", + }, + "kb": { + "yes": "true", + }, + "kc": { + "yes": "true", + }, + "kh": { + "yes": "true", + }, + "kk": { + "yes": "true", + }, + "kn": { + "yes": "true", + }, + "ks": { + "primary": "level1", + "tertiary": "level3", + }, + "ms": { + "imperial": "uksystem", + }, + "rg": { + "cn11": "cnbj", + "cn12": "cntj", + "cn13": "cnhe", + "cn14": "cnsx", + "cn15": "cnmn", + "cn21": "cnln", + "cn22": "cnjl", + "cn23": "cnhl", + "cn31": "cnsh", + "cn32": "cnjs", + "cn33": "cnzj", + "cn34": "cnah", + "cn35": "cnfj", + "cn36": "cnjx", + "cn37": "cnsd", + "cn41": "cnha", + "cn42": "cnhb", + "cn43": "cnhn", + "cn44": "cngd", + "cn45": "cngx", + "cn46": "cnhi", + "cn50": "cncq", + "cn51": "cnsc", + "cn52": "cngz", + "cn53": "cnyn", + "cn54": "cnxz", + "cn61": "cnsn", + "cn62": "cngs", + "cn63": "cnqh", + "cn64": "cnnx", + "cn65": "cnxj", + "cz10a": "cz110", + "cz10b": "cz111", + "cz10c": "cz112", + "cz10d": "cz113", + "cz10e": "cz114", + "cz10f": "cz115", + "cz611": "cz663", + "cz612": "cz632", + "cz613": "cz633", + "cz614": "cz634", + "cz615": "cz635", + "cz621": "cz641", + "cz622": "cz642", + "cz623": "cz643", + "cz624": "cz644", + "cz626": "cz646", + "cz627": "cz647", + "czjc": "cz31", + "czjm": "cz64", + "czka": "cz41", + "czkr": "cz52", + "czli": "cz51", + "czmo": "cz80", + "czol": "cz71", + "czpa": "cz53", + "czpl": "cz32", + "czpr": "cz10", + "czst": "cz20", + "czus": "cz42", + "czvy": "cz63", + "czzl": "cz72", + "fra": "frges", + "frb": "frnaq", + "frc": "frara", + "frd": "frbfc", + "fre": "frbre", + "frf": "frcvl", + "frg": "frges", + "frh": "frcor", + "fri": "frbfc", + "frj": "fridf", + "frk": "frocc", + "frl": "frnaq", + "frm": "frges", + "frn": "frocc", + "fro": "frhdf", + "frp": "frnor", + "frq": "frnor", + "frr": "frpdl", + "frs": "frhdf", + "frt": "frnaq", + "fru": "frpac", + "frv": "frara", + "laxn": "laxs", + "lud": "lucl", + "lug": "luec", + "lul": "luca", + "mrnkc": "mr13", + "no23": "no50", + "nzn": "nzauk", + "nzs": "nzcan", + "omba": "ombj", + "omsh": "omsj", + "plds": "pl02", + "plkp": "pl04", + "pllb": "pl08", + "plld": "pl10", + "pllu": "pl06", + "plma": "pl12", + "plmz": "pl14", + "plop": "pl16", + "plpd": "pl20", + "plpk": "pl18", + "plpm": "pl22", + "plsk": "pl26", + "plsl": "pl24", + "plwn": "pl28", + "plwp": "pl30", + "plzp": "pl32", + "tteto": "tttob", + "ttrcm": "ttmrc", + "ttwto": "tttob", + "twkhq": "twkhh", + "twtnq": "twtnn", + "twtpq": "twnwt", + "twtxq": "twtxg", + }, + "sd": { + "cn11": "cnbj", + "cn12": "cntj", + "cn13": "cnhe", + "cn14": "cnsx", + "cn15": "cnmn", + "cn21": "cnln", + "cn22": "cnjl", + "cn23": "cnhl", + "cn31": "cnsh", + "cn32": "cnjs", + "cn33": "cnzj", + "cn34": "cnah", + "cn35": "cnfj", + "cn36": "cnjx", + "cn37": "cnsd", + "cn41": "cnha", + "cn42": "cnhb", + "cn43": "cnhn", + "cn44": "cngd", + "cn45": "cngx", + "cn46": "cnhi", + "cn50": "cncq", + "cn51": "cnsc", + "cn52": "cngz", + "cn53": "cnyn", + "cn54": "cnxz", + "cn61": "cnsn", + "cn62": "cngs", + "cn63": "cnqh", + "cn64": "cnnx", + "cn65": "cnxj", + "cz10a": "cz110", + "cz10b": "cz111", + "cz10c": "cz112", + "cz10d": "cz113", + "cz10e": "cz114", + "cz10f": "cz115", + "cz611": "cz663", + "cz612": "cz632", + "cz613": "cz633", + "cz614": "cz634", + "cz615": "cz635", + "cz621": "cz641", + "cz622": "cz642", + "cz623": "cz643", + "cz624": "cz644", + "cz626": "cz646", + "cz627": "cz647", + "czjc": "cz31", + "czjm": "cz64", + "czka": "cz41", + "czkr": "cz52", + "czli": "cz51", + "czmo": "cz80", + "czol": "cz71", + "czpa": "cz53", + "czpl": "cz32", + "czpr": "cz10", + "czst": "cz20", + "czus": "cz42", + "czvy": "cz63", + "czzl": "cz72", + "fra": "frges", + "frb": "frnaq", + "frc": "frara", + "frd": "frbfc", + "fre": "frbre", + "frf": "frcvl", + "frg": "frges", + "frh": "frcor", + "fri": "frbfc", + "frj": "fridf", + "frk": "frocc", + "frl": "frnaq", + "frm": "frges", + "frn": "frocc", + "fro": "frhdf", + "frp": "frnor", + "frq": "frnor", + "frr": "frpdl", + "frs": "frhdf", + "frt": "frnaq", + "fru": "frpac", + "frv": "frara", + "laxn": "laxs", + "lud": "lucl", + "lug": "luec", + "lul": "luca", + "mrnkc": "mr13", + "no23": "no50", + "nzn": "nzauk", + "nzs": "nzcan", + "omba": "ombj", + "omsh": "omsj", + "plds": "pl02", + "plkp": "pl04", + "pllb": "pl08", + "plld": "pl10", + "pllu": "pl06", + "plma": "pl12", + "plmz": "pl14", + "plop": "pl16", + "plpd": "pl20", + "plpk": "pl18", + "plpm": "pl22", + "plsk": "pl26", + "plsl": "pl24", + "plwn": "pl28", + "plwp": "pl30", + "plzp": "pl32", + "tteto": "tttob", + "ttrcm": "ttmrc", + "ttwto": "tttob", + "twkhq": "twkhh", + "twtnq": "twtnn", + "twtpq": "twnwt", + "twtxq": "twtxg", + }, + "tz": { + "aqams": "nzakl", + "cnckg": "cnsha", + "cnhrb": "cnsha", + "cnkhg": "cnurc", + "cuba": "cuhav", + "egypt": "egcai", + "eire": "iedub", + "est": "utcw05", + "gmt0": "gmt", + "hongkong": "hkhkg", + "hst": "utcw10", + "iceland": "isrey", + "iran": "irthr", + "israel": "jeruslm", + "jamaica": "jmkin", + "japan": "jptyo", + "libya": "lytip", + "mst": "utcw07", + "navajo": "usden", + "poland": "plwaw", + "portugal": "ptlis", + "prc": "cnsha", + "roc": "twtpe", + "rok": "krsel", + "turkey": "trist", + "uct": "utc", + "usnavajo": "usden", + "zulu": "utc", + }, + }; + + + /** + * Mappings from Unicode extension subtags to preferred values. + * + * Spec: http://unicode.org/reports/tr35/#Identifiers + * Version: CLDR, version 36.1 + */ + var __transformMappings = { + // property names and values must be in canonical case + + "d0": { + "name": "charname", + }, + "m0": { + "names": "prprname", + }, + }; + + /** + * Canonicalizes the given well-formed BCP 47 language tag, including regularized case of subtags. + * + * Spec: ECMAScript Internationalization API Specification, draft, 6.2.3. + * Spec: RFC 5646, section 4.5. + */ + function canonicalizeLanguageTag(locale) { + + // start with lower case for easier processing, and because most subtags will need to be lower case anyway + locale = locale.toLowerCase(); + + // handle mappings for complete tags + if (__tagMappings.hasOwnProperty(locale)) { + return __tagMappings[locale]; + } + + var subtags = locale.split("-"); + var i = 0; + + // handle standard part: all subtags before first variant or singleton subtag + var language; + var script; + var region; + while (i < subtags.length) { + var subtag = subtags[i]; + if (i === 0) { + language = subtag; + } else if (subtag.length === 2 || subtag.length === 3) { + region = subtag.toUpperCase(); + } else if (subtag.length === 4 && !("0" <= subtag[0] && subtag[0] <= "9")) { + script = subtag[0].toUpperCase() + subtag.substring(1).toLowerCase(); + } else { + break; + } + i++; + } + + if (__languageMappings.hasOwnProperty(language)) { + language = __languageMappings[language]; + } else if (__complexLanguageMappings.hasOwnProperty(language)) { + var mapping = __complexLanguageMappings[language]; + + language = mapping.language; + if (script === undefined && mapping.hasOwnProperty("script")) { + script = mapping.script; + } + if (region === undefined && mapping.hasOwnProperty("region")) { + region = mapping.region; + } + } + + if (region !== undefined) { + if (__regionMappings.hasOwnProperty(region)) { + region = __regionMappings[region]; + } else if (__complexRegionMappings.hasOwnProperty(region)) { + var mapping = __complexRegionMappings[region]; + + var mappingKey = language; + if (script !== undefined) { + mappingKey += "-" + script; + } + + if (mapping.hasOwnProperty(mappingKey)) { + region = mapping[mappingKey]; + } else { + region = mapping.default; + } + } + } + + // handle variants + var variants = []; + while (i < subtags.length && subtags[i].length > 1) { + var variant = subtags[i]; + + if (__variantMappings.hasOwnProperty(variant)) { + var mapping = __variantMappings[variant]; + switch (mapping.type) { + case "language": + language = mapping.replacement; + break; + + case "region": + region = mapping.replacement; + break; + + case "variant": + variants.push(mapping.replacement); + break; + + default: + throw new Error("illegal variant mapping type"); + } + } else { + variants.push(variant); + } + + i += 1; + } + variants.sort(); + + // handle extensions + var extensions = []; + while (i < subtags.length && subtags[i] !== "x") { + var extensionStart = i; + i++; + while (i < subtags.length && subtags[i].length > 1) { + i++; + } + + var extension; + var extensionKey = subtags[extensionStart]; + if (extensionKey === "u") { + var j = extensionStart + 1; + + // skip over leading attributes + while (j < i && subtags[j].length > 2) { + j++; + } + + extension = subtags.slice(extensionStart, j).join("-"); + + while (j < i) { + var keyStart = j; + j++; + + while (j < i && subtags[j].length > 2) { + j++; + } + + var key = subtags[keyStart]; + var value = subtags.slice(keyStart + 1, j).join("-"); + + if (__unicodeMappings.hasOwnProperty(key)) { + var mapping = __unicodeMappings[key]; + if (mapping.hasOwnProperty(value)) { + value = mapping[value]; + } + } + + extension += "-" + key; + if (value !== "" && value !== "true") { + extension += "-" + value; + } + } + } else if (extensionKey === "t") { + var j = extensionStart + 1; + + while (j < i && !transformKeyRE.test(subtags[j])) { + j++; + } + + extension = "t"; + + var transformLanguage = subtags.slice(extensionStart + 1, j).join("-"); + if (transformLanguage !== "") { + extension += "-" + canonicalizeLanguageTag(transformLanguage).toLowerCase(); + } + + while (j < i) { + var keyStart = j; + j++; + + while (j < i && subtags[j].length > 2) { + j++; + } + + var key = subtags[keyStart]; + var value = subtags.slice(keyStart + 1, j).join("-"); + + if (__transformMappings.hasOwnProperty(key)) { + var mapping = __transformMappings[key]; + if (mapping.hasOwnProperty(value)) { + value = mapping[value]; + } + } + + extension += "-" + key + "-" + value; + } + } else { + extension = subtags.slice(extensionStart, i).join("-"); + } + + extensions.push(extension); + } + extensions.sort(); + + // handle private use + var privateUse; + if (i < subtags.length) { + privateUse = subtags.slice(i).join("-"); + } + + // put everything back together + var canonical = language; + if (script !== undefined) { + canonical += "-" + script; + } + if (region !== undefined) { + canonical += "-" + region; + } + if (variants.length > 0) { + canonical += "-" + variants.join("-"); + } + if (extensions.length > 0) { + canonical += "-" + extensions.join("-"); + } + if (privateUse !== undefined) { + if (canonical.length > 0) { + canonical += "-" + privateUse; + } else { + canonical = privateUse; + } + } + + return canonical; + } + + return typeof locale === "string" && isStructurallyValidLanguageTag(locale) && + canonicalizeLanguageTag(locale) === locale; +} + + +/** + * Returns an array of error cases handled by CanonicalizeLocaleList(). + */ +function getInvalidLocaleArguments() { + function CustomError() {} + + var topLevelErrors = [ + // fails ToObject + [null, TypeError], + + // fails Get + [{ get length() { throw new CustomError(); } }, CustomError], + + // fail ToLength + [{ length: Symbol.toPrimitive }, TypeError], + [{ length: { get [Symbol.toPrimitive]() { throw new CustomError(); } } }, CustomError], + [{ length: { [Symbol.toPrimitive]() { throw new CustomError(); } } }, CustomError], + [{ length: { get valueOf() { throw new CustomError(); } } }, CustomError], + [{ length: { valueOf() { throw new CustomError(); } } }, CustomError], + [{ length: { get toString() { throw new CustomError(); } } }, CustomError], + [{ length: { toString() { throw new CustomError(); } } }, CustomError], + + // fail type check + [[undefined], TypeError], + [[null], TypeError], + [[true], TypeError], + [[Symbol.toPrimitive], TypeError], + [[1], TypeError], + [[0.1], TypeError], + [[NaN], TypeError], + ]; + + var invalidLanguageTags = [ + "", // empty tag + "i", // singleton alone + "x", // private use without subtag + "u", // extension singleton in first place + "419", // region code in first place + "u-nu-latn-cu-bob", // extension sequence without language + "hans-cmn-cn", // "hans" could theoretically be a 4-letter language code, + // but those can't be followed by extlang codes. + "abcdefghi", // overlong language + "cmn-hans-cn-u-u", // duplicate singleton + "cmn-hans-cn-t-u-ca-u", // duplicate singleton + "de-gregory-gregory", // duplicate variant + "*", // language range + "de-*", // language range + "中文", // non-ASCII letters + "en-ß", // non-ASCII letters + "ıd" // non-ASCII letters + ]; + + return topLevelErrors.concat( + invalidLanguageTags.map(tag => [tag, RangeError]), + invalidLanguageTags.map(tag => [[tag], RangeError]), + invalidLanguageTags.map(tag => [["en", tag], RangeError]), + ) +} + +/** + * Tests whether the named options property is correctly handled by the given constructor. + * @param {object} Constructor the constructor to test. + * @param {string} property the name of the options property to test. + * @param {string} type the type that values of the property are expected to have + * @param {Array} [values] an array of allowed values for the property. Not needed for boolean. + * @param {any} fallback the fallback value that the property assumes if not provided. + * @param {object} testOptions additional options: + * @param {boolean} isOptional whether support for this property is optional for implementations. + * @param {boolean} noReturn whether the resulting value of the property is not returned. + * @param {boolean} isILD whether the resulting value of the property is implementation and locale dependent. + * @param {object} extra additional option to pass along, properties are value -> {option: value}. + */ +function testOption(Constructor, property, type, values, fallback, testOptions) { + var isOptional = testOptions !== undefined && testOptions.isOptional === true; + var noReturn = testOptions !== undefined && testOptions.noReturn === true; + var isILD = testOptions !== undefined && testOptions.isILD === true; + + function addExtraOptions(options, value, testOptions) { + if (testOptions !== undefined && testOptions.extra !== undefined) { + var extra; + if (value !== undefined && testOptions.extra[value] !== undefined) { + extra = testOptions.extra[value]; + } else if (testOptions.extra.any !== undefined) { + extra = testOptions.extra.any; + } + if (extra !== undefined) { + Object.getOwnPropertyNames(extra).forEach(function (prop) { + options[prop] = extra[prop]; + }); + } + } + } + + var testValues, options, obj, expected, actual, error; + + // test that the specified values are accepted. Also add values that convert to specified values. + if (type === "boolean") { + if (values === undefined) { + values = [true, false]; + } + testValues = values.slice(0); + testValues.push(888); + testValues.push(0); + } else if (type === "string") { + testValues = values.slice(0); + testValues.push({toString: function () { return values[0]; }}); + } + testValues.forEach(function (value) { + options = {}; + options[property] = value; + addExtraOptions(options, value, testOptions); + obj = new Constructor(undefined, options); + if (noReturn) { + if (obj.resolvedOptions().hasOwnProperty(property)) { + throw new Test262Error("Option property " + property + " is returned, but shouldn't be."); + } + } else { + actual = obj.resolvedOptions()[property]; + if (isILD) { + if (actual !== undefined && values.indexOf(actual) === -1) { + throw new Test262Error("Invalid value " + actual + " returned for property " + property + "."); + } + } else { + if (type === "boolean") { + expected = Boolean(value); + } else if (type === "string") { + expected = String(value); + } + if (actual !== expected && !(isOptional && actual === undefined)) { + throw new Test262Error("Option value " + value + " for property " + property + + " was not accepted; got " + actual + " instead."); + } + } + } + }); + + // test that invalid values are rejected + if (type === "string") { + var invalidValues = ["invalidValue", -1, null]; + // assume that we won't have values in caseless scripts + if (values[0].toUpperCase() !== values[0]) { + invalidValues.push(values[0].toUpperCase()); + } else { + invalidValues.push(values[0].toLowerCase()); + } + invalidValues.forEach(function (value) { + options = {}; + options[property] = value; + addExtraOptions(options, value, testOptions); + error = undefined; + try { + obj = new Constructor(undefined, options); + } catch (e) { + error = e; + } + if (error === undefined) { + throw new Test262Error("Invalid option value " + value + " for property " + property + " was not rejected."); + } else if (error.name !== "RangeError") { + throw new Test262Error("Invalid option value " + value + " for property " + property + " was rejected with wrong error " + error.name + "."); + } + }); + } + + // test that fallback value or another valid value is used if no options value is provided + if (!noReturn) { + options = {}; + addExtraOptions(options, undefined, testOptions); + obj = new Constructor(undefined, options); + actual = obj.resolvedOptions()[property]; + if (!(isOptional && actual === undefined)) { + if (fallback !== undefined) { + if (actual !== fallback) { + throw new Test262Error("Option fallback value " + fallback + " for property " + property + + " was not used; got " + actual + " instead."); + } + } else { + if (values.indexOf(actual) === -1 && !(isILD && actual === undefined)) { + throw new Test262Error("Invalid value " + actual + " returned for property " + property + "."); + } + } + } + } +} + + +/** + * Properties of the RegExp constructor that may be affected by use of regular + * expressions, and the default values of these properties. Properties are from + * https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Deprecated_and_obsolete_features#RegExp_Properties + */ +var regExpProperties = ["$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", + "$_", "$*", "$&", "$+", "$`", "$'", + "input", "lastMatch", "lastParen", "leftContext", "rightContext" +]; + +var regExpPropertiesDefaultValues = (function () { + var values = Object.create(null); + (/(?:)/).test(""); + regExpProperties.forEach(function (property) { + values[property] = RegExp[property]; + }); + return values; +}()); + + +/** + * Tests that executing the provided function (which may use regular expressions + * in its implementation) does not create or modify unwanted properties on the + * RegExp constructor. + */ +function testForUnwantedRegExpChanges(testFunc) { + (/(?:)/).test(""); + testFunc(); + regExpProperties.forEach(function (property) { + if (RegExp[property] !== regExpPropertiesDefaultValues[property]) { + throw new Test262Error("RegExp has unexpected property " + property + " with value " + + RegExp[property] + "."); + } + }); +} + + +/** + * Returns an array of all known calendars. + */ +function allCalendars() { + // source: CLDR file common/bcp47/number.xml; version CLDR 39. + // https://github.com/unicode-org/cldr/blob/master/common/bcp47/calendar.xml + return [ + "buddhist", + "chinese", + "coptic", + "dangi", + "ethioaa", + "ethiopic", + "gregory", + "hebrew", + "indian", + "islamic", + "islamic-umalqura", + "islamic-tbla", + "islamic-civil", + "islamic-rgsa", + "iso8601", + "japanese", + "persian", + "roc", + ]; +} + + +/** + * Returns an array of all known collations. + */ +function allCollations() { + // source: CLDR file common/bcp47/collation.xml; version CLDR 39. + // https://github.com/unicode-org/cldr/blob/master/common/bcp47/collation.xml + return [ + "big5han", + "compat", + "dict", + "direct", + "ducet", + "emoji", + "eor", + "gb2312", + "phonebk", + "phonetic", + "pinyin", + "reformed", + "search", + "searchjl", + "standard", + "stroke", + "trad", + "unihan", + "zhuyin", + ]; +} + + +/** + * Returns an array of all known numbering systems. + */ +function allNumberingSystems() { + // source: CLDR file common/bcp47/number.xml; version CLDR 40 & new in Unicode 14.0 + // https://github.com/unicode-org/cldr/blob/master/common/bcp47/number.xml + return [ + "adlm", + "ahom", + "arab", + "arabext", + "armn", + "armnlow", + "bali", + "beng", + "bhks", + "brah", + "cakm", + "cham", + "cyrl", + "deva", + "diak", + "ethi", + "finance", + "fullwide", + "geor", + "gong", + "gonm", + "grek", + "greklow", + "gujr", + "guru", + "hanidays", + "hanidec", + "hans", + "hansfin", + "hant", + "hantfin", + "hebr", + "hmng", + "hmnp", + "java", + "jpan", + "jpanfin", + "jpanyear", + "kali", + "khmr", + "knda", + "lana", + "lanatham", + "laoo", + "latn", + "lepc", + "limb", + "mathbold", + "mathdbl", + "mathmono", + "mathsanb", + "mathsans", + "mlym", + "modi", + "mong", + "mroo", + "mtei", + "mymr", + "mymrshan", + "mymrtlng", + "native", + "newa", + "nkoo", + "olck", + "orya", + "osma", + "rohg", + "roman", + "romanlow", + "saur", + "shrd", + "sind", + "sinh", + "sora", + "sund", + "takr", + "talu", + "taml", + "tamldec", + "tnsa", + "telu", + "thai", + "tirh", + "tibt", + "traditio", + "vaii", + "wara", + "wcho", + ]; +} + + +/** + * Tests whether name is a valid BCP 47 numbering system name + * and not excluded from use in the ECMAScript Internationalization API. + * @param {string} name the name to be tested. + * @return {boolean} whether name is a valid BCP 47 numbering system name and + * allowed for use in the ECMAScript Internationalization API. + */ + +function isValidNumberingSystem(name) { + + var numberingSystems = allNumberingSystems(); + + var excluded = [ + "finance", + "native", + "traditio" + ]; + + + return numberingSystems.indexOf(name) !== -1 && excluded.indexOf(name) === -1; +} + + +/** + * Provides the digits of numbering systems with simple digit mappings, + * as specified in 11.3.2. + */ + +var numberingSystemDigits = { + adlm: "𞥐𞥑𞥒𞥓𞥔𞥕𞥖𞥗𞥘𞥙", + ahom: "𑜰𑜱𑜲𑜳𑜴𑜵𑜶𑜷𑜸𑜹", + arab: "٠١٢٣٤٥٦٧٨٩", + arabext: "۰۱۲۳۴۵۶۷۸۹", + bali: "\u1B50\u1B51\u1B52\u1B53\u1B54\u1B55\u1B56\u1B57\u1B58\u1B59", + beng: "০১২৩৪৫৬৭৮৯", + bhks: "𑱐𑱑𑱒𑱓𑱔𑱕𑱖𑱗𑱘𑱙", + brah: "𑁦𑁧𑁨𑁩𑁪𑁫𑁬𑁭𑁮𑁯", + cakm: "𑄶𑄷𑄸𑄹𑄺𑄻𑄼𑄽𑄾𑄿", + cham: "꩐꩑꩒꩓꩔꩕꩖꩗꩘꩙", + deva: "०१२३४५६७८९", + diak: "𑥐𑥑𑥒𑥓𑥔𑥕𑥖𑥗𑥘𑥙", + fullwide: "0123456789", + gong: "𑶠𑶡𑶢𑶣𑶤𑶥𑶦𑶧𑶨𑶩", + gonm: "𑵐𑵑𑵒𑵓𑵔𑵕𑵖𑵗𑵘𑵙", + gujr: "૦૧૨૩૪૫૬૭૮૯", + guru: "੦੧੨੩੪੫੬੭੮੯", + hanidec: "〇一二三四五六七八九", + hmng: "𖭐𖭑𖭒𖭓𖭔𖭕𖭖𖭗𖭘𖭙", + hmnp: "𞅀𞅁𞅂𞅃𞅄𞅅𞅆𞅇𞅈𞅉", + java: "꧐꧑꧒꧓꧔꧕꧖꧗꧘꧙", + kali: "꤀꤁꤂꤃꤄꤅꤆꤇꤈꤉", + khmr: "០១២៣៤៥៦៧៨៩", + knda: "೦೧೨೩೪೫೬೭೮೯", + lana: "᪀᪁᪂᪃᪄᪅᪆᪇᪈᪉", + lanatham: "᪐᪑᪒᪓᪔᪕᪖᪗᪘᪙", + laoo: "໐໑໒໓໔໕໖໗໘໙", + latn: "0123456789", + lepc: "᱀᱁᱂᱃᱄᱅᱆᱇᱈᱉", + limb: "\u1946\u1947\u1948\u1949\u194A\u194B\u194C\u194D\u194E\u194F", + mathbold: "𝟎𝟏𝟐𝟑𝟒𝟓𝟔𝟕𝟖𝟗", + mathdbl: "𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡", + mathmono: "𝟶𝟷𝟸𝟹𝟺𝟻𝟼𝟽𝟾𝟿", + mathsanb: "𝟬𝟭𝟮𝟯𝟰𝟱𝟲𝟳𝟴𝟵", + mathsans: "𝟢𝟣𝟤𝟥𝟦𝟧𝟨𝟩𝟪𝟫", + mlym: "൦൧൨൩൪൫൬൭൮൯", + modi: "𑙐𑙑𑙒𑙓𑙔𑙕𑙖𑙗𑙘𑙙", + mong: "᠐᠑᠒᠓᠔᠕᠖᠗᠘᠙", + mroo: "𖩠𖩡𖩢𖩣𖩤𖩥𖩦𖩧𖩨𖩩", + mtei: "꯰꯱꯲꯳꯴꯵꯶꯷꯸꯹", + mymr: "၀၁၂၃၄၅၆၇၈၉", + mymrshan: "႐႑႒႓႔႕႖႗႘႙", + mymrtlng: "꧰꧱꧲꧳꧴꧵꧶꧷꧸꧹", + newa: "𑑐𑑑𑑒𑑓𑑔𑑕𑑖𑑗𑑘𑑙", + nkoo: "߀߁߂߃߄߅߆߇߈߉", + olck: "᱐᱑᱒᱓᱔᱕᱖᱗᱘᱙", + orya: "୦୧୨୩୪୫୬୭୮୯", + osma: "𐒠𐒡𐒢𐒣𐒤𐒥𐒦𐒧𐒨𐒩", + rohg: "𐴰𐴱𐴲𐴳𐴴𐴵𐴶𐴷𐴸𐴹", + saur: "꣐꣑꣒꣓꣔꣕꣖꣗꣘꣙", + segment: "🯰🯱🯲🯳🯴🯵🯶🯷🯸🯹", + shrd: "𑇐𑇑𑇒𑇓𑇔𑇕𑇖𑇗𑇘𑇙", + sind: "𑋰𑋱𑋲𑋳𑋴𑋵𑋶𑋷𑋸𑋹", + sinh: "෦෧෨෩෪෫෬෭෮෯", + sora: "𑃰𑃱𑃲𑃳𑃴𑃵𑃶𑃷𑃸𑃹", + sund: "᮰᮱᮲᮳᮴᮵᮶᮷᮸᮹", + takr: "𑛀𑛁𑛂𑛃𑛄𑛅𑛆𑛇𑛈𑛉", + talu: "᧐᧑᧒᧓᧔᧕᧖᧗᧘᧙", + tamldec: "௦௧௨௩௪௫௬௭௮௯", + tnsa: "\u{16AC0}\u{16AC1}\u{16AC2}\u{16AC3}\u{16AC4}\u{16AC5}\u{16AC6}\u{16AC7}\u{16AC8}\u{16AC9}", + telu: "౦౧౨౩౪౫౬౭౮౯", + thai: "๐๑๒๓๔๕๖๗๘๙", + tibt: "༠༡༢༣༤༥༦༧༨༩", + tirh: "𑓐𑓑𑓒𑓓𑓔𑓕𑓖𑓗𑓘𑓙", + vaii: "꘠꘡꘢꘣꘤꘥꘦꘧꘨꘩", + wara: "𑣠𑣡𑣢𑣣𑣤𑣥𑣦𑣧𑣨𑣩", + wcho: "𞋰𞋱𞋲𞋳𞋴𞋵𞋶𞋷𞋸𞋹", +}; + + +/** + * Returns an array of all simple, sanctioned unit identifiers. + */ +function allSimpleSanctionedUnits() { + // https://tc39.es/ecma402/#table-sanctioned-simple-unit-identifiers + return [ + "acre", + "bit", + "byte", + "celsius", + "centimeter", + "day", + "degree", + "fahrenheit", + "fluid-ounce", + "foot", + "gallon", + "gigabit", + "gigabyte", + "gram", + "hectare", + "hour", + "inch", + "kilobit", + "kilobyte", + "kilogram", + "kilometer", + "liter", + "megabit", + "megabyte", + "meter", + "microsecond", + "mile", + "mile-scandinavian", + "milliliter", + "millimeter", + "millisecond", + "minute", + "month", + "nanosecond", + "ounce", + "percent", + "petabyte", + "pound", + "second", + "stone", + "terabit", + "terabyte", + "week", + "yard", + "year", + ]; +} + + +/** + * Tests that number formatting is handled correctly. The function checks that the + * digit sequences in formatted output are as specified, converted to the + * selected numbering system, and embedded in consistent localized patterns. + * @param {Array} locales the locales to be tested. + * @param {Array} numberingSystems the numbering systems to be tested. + * @param {Object} options the options to pass to Intl.NumberFormat. Options + * must include {useGrouping: false}, and must cause 1.1 to be formatted + * pre- and post-decimal digits. + * @param {Object} testData maps input data (in ES5 9.3.1 format) to expected output strings + * in unlocalized format with Western digits. + */ + +function testNumberFormat(locales, numberingSystems, options, testData) { + locales.forEach(function (locale) { + numberingSystems.forEach(function (numbering) { + var digits = numberingSystemDigits[numbering]; + var format = new Intl.NumberFormat([locale + "-u-nu-" + numbering], options); + + function getPatternParts(positive) { + var n = positive ? 1.1 : -1.1; + var formatted = format.format(n); + var oneoneRE = "([^" + digits + "]*)[" + digits + "]+([^" + digits + "]+)[" + digits + "]+([^" + digits + "]*)"; + var match = formatted.match(new RegExp(oneoneRE)); + if (match === null) { + throw new Test262Error("Unexpected formatted " + n + " for " + + format.resolvedOptions().locale + " and options " + + JSON.stringify(options) + ": " + formatted); + } + return match; + } + + function toNumbering(raw) { + return raw.replace(/[0-9]/g, function (digit) { + return digits[digit.charCodeAt(0) - "0".charCodeAt(0)]; + }); + } + + function buildExpected(raw, patternParts) { + var period = raw.indexOf("."); + if (period === -1) { + return patternParts[1] + toNumbering(raw) + patternParts[3]; + } else { + return patternParts[1] + + toNumbering(raw.substring(0, period)) + + patternParts[2] + + toNumbering(raw.substring(period + 1)) + + patternParts[3]; + } + } + + if (format.resolvedOptions().numberingSystem === numbering) { + // figure out prefixes, infixes, suffixes for positive and negative values + var posPatternParts = getPatternParts(true); + var negPatternParts = getPatternParts(false); + + Object.getOwnPropertyNames(testData).forEach(function (input) { + var rawExpected = testData[input]; + var patternParts; + if (rawExpected[0] === "-") { + patternParts = negPatternParts; + rawExpected = rawExpected.substring(1); + } else { + patternParts = posPatternParts; + } + var expected = buildExpected(rawExpected, patternParts); + var actual = format.format(input); + if (actual !== expected) { + throw new Test262Error("Formatted value for " + input + ", " + + format.resolvedOptions().locale + " and options " + + JSON.stringify(options) + " is " + actual + "; expected " + expected + "."); + } + }); + } + }); + }); +} + + +/** + * Return the components of date-time formats. + * @return {Array} an array with all date-time components. + */ + +function getDateTimeComponents() { + return ["weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName"]; +} + + +/** + * Return the valid values for the given date-time component, as specified + * by the table in section 12.1.1. + * @param {string} component a date-time component. + * @return {Array} an array with the valid values for the component. + */ + +function getDateTimeComponentValues(component) { + + var components = { + weekday: ["narrow", "short", "long"], + era: ["narrow", "short", "long"], + year: ["2-digit", "numeric"], + month: ["2-digit", "numeric", "narrow", "short", "long"], + day: ["2-digit", "numeric"], + hour: ["2-digit", "numeric"], + minute: ["2-digit", "numeric"], + second: ["2-digit", "numeric"], + timeZoneName: ["short", "long"] + }; + + var result = components[component]; + if (result === undefined) { + throw new Test262Error("Internal error: No values defined for date-time component " + component + "."); + } + return result; +} + + +/** + * @description Tests whether timeZone is a String value representing a + * structurally valid and canonicalized time zone name, as defined in + * sections 6.4.1 and 6.4.2 of the ECMAScript Internationalization API + * Specification. + * @param {String} timeZone the string to be tested. + * @result {Boolean} whether the test succeeded. + */ + +function isCanonicalizedStructurallyValidTimeZoneName(timeZone) { + /** + * Regular expression defining IANA Time Zone names. + * + * Spec: IANA Time Zone Database, Theory file + */ + var fileNameComponent = "(?:[A-Za-z_]|\\.(?!\\.?(?:/|$)))[A-Za-z.\\-_]{0,13}"; + var fileName = fileNameComponent + "(?:/" + fileNameComponent + ")*"; + var etcName = "(?:Etc/)?GMT[+-]\\d{1,2}"; + var systemVName = "SystemV/[A-Z]{3}\\d{1,2}(?:[A-Z]{3})?"; + var legacyName = etcName + "|" + systemVName + "|CST6CDT|EST5EDT|MST7MDT|PST8PDT|NZ"; + var zoneNamePattern = new RegExp("^(?:" + fileName + "|" + legacyName + ")$"); + + if (typeof timeZone !== "string") { + return false; + } + // 6.4.2 CanonicalizeTimeZoneName (timeZone), step 3 + if (timeZone === "UTC") { + return true; + } + // 6.4.2 CanonicalizeTimeZoneName (timeZone), step 3 + if (timeZone === "Etc/UTC" || timeZone === "Etc/GMT") { + return false; + } + return zoneNamePattern.test(timeZone); +} diff --git a/harness/testTypedArray.js b/harness/testTypedArray.js new file mode 100644 index 00000000000..0cc50c9fd50 --- /dev/null +++ b/harness/testTypedArray.js @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to assert the correctness of TypedArray objects. +defines: + - typedArrayConstructors + - floatArrayConstructors + - intArrayConstructors + - TypedArray + - testWithTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +/** + * Array containing every typed array constructor. + */ +var typedArrayConstructors = [ + Float64Array, + Float32Array, + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + Uint8ClampedArray +]; + +var floatArrayConstructors = typedArrayConstructors.slice(0, 2); +var intArrayConstructors = typedArrayConstructors.slice(2, 7); + +/** + * The %TypedArray% intrinsic constructor function. + */ +var TypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Float64Array, + Float32Array, + Uint8ClampedArray + ]); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * TypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} diff --git a/harness/timer.js b/harness/timer.js new file mode 100644 index 00000000000..d55f47d4f73 --- /dev/null +++ b/harness/timer.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Used in website/scripts/sth.js +defines: [setTimeout] +---*/ +//setTimeout is not available, hence this script was loaded +if (Promise === undefined && this.setTimeout === undefined) { + if(/\$DONE()/.test(code)) + throw new Test262Error("Async test capability is not supported in your test environment"); +} + +if (Promise !== undefined && this.setTimeout === undefined) { + (function(that) { + that.setTimeout = function(callback, delay) { + var p = Promise.resolve(); + var start = Date.now(); + var end = start + delay; + function check(){ + var timeLeft = end - Date.now(); + if(timeLeft > 0) + p.then(check); + else + callback(); + } + p.then(check); + } + })(this); +} diff --git a/harness/typeCoercion.js b/harness/typeCoercion.js new file mode 100644 index 00000000000..72f79205a01 --- /dev/null +++ b/harness/typeCoercion.js @@ -0,0 +1,463 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Functions to help generate test cases for testing type coercion abstract + operations like ToNumber. +defines: + - testCoercibleToIndexZero + - testCoercibleToIndexOne + - testCoercibleToIndexFromIndex + - testCoercibleToIntegerZero + - testCoercibleToIntegerOne + - testCoercibleToNumberZero + - testCoercibleToNumberNan + - testCoercibleToNumberOne + - testCoercibleToIntegerFromInteger + - testPrimitiveWrappers + - testCoercibleToPrimitiveWithMethod + - testNotCoercibleToIndex + - testNotCoercibleToInteger + - testNotCoercibleToNumber + - testNotCoercibleToPrimitive + - testCoercibleToString + - testNotCoercibleToString + - testCoercibleToBooleanTrue + - testCoercibleToBooleanFalse + - testCoercibleToBigIntZero + - testCoercibleToBigIntOne + - testCoercibleToBigIntFromBigInt + - testNotCoercibleToBigInt +---*/ + +function testCoercibleToIndexZero(test) { + testCoercibleToIntegerZero(test); +} + +function testCoercibleToIndexOne(test) { + testCoercibleToIntegerOne(test); +} + +function testCoercibleToIndexFromIndex(nominalIndex, test) { + assert(Number.isInteger(nominalIndex)); + assert(0 <= nominalIndex && nominalIndex <= 2**53 - 1); + testCoercibleToIntegerFromInteger(nominalIndex, test); +} + +function testCoercibleToIntegerZero(test) { + testCoercibleToNumberZero(test); + + testCoercibleToIntegerFromInteger(0, test); + + // NaN -> +0 + testCoercibleToNumberNan(test); + + // When toString() returns a string that parses to NaN: + test({}); + test([]); +} + +function testCoercibleToIntegerOne(test) { + testCoercibleToNumberOne(test); + + testCoercibleToIntegerFromInteger(1, test); + + // When toString() returns "1" + test([1]); + test(["1"]); +} + +function testCoercibleToNumberZero(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testPrimitiveValue(null); + testPrimitiveValue(false); + testPrimitiveValue(0); + testPrimitiveValue("0"); +} + +function testCoercibleToNumberNan(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testPrimitiveValue(undefined); + testPrimitiveValue(NaN); + testPrimitiveValue(""); + testPrimitiveValue("foo"); + testPrimitiveValue("true"); +} + +function testCoercibleToNumberOne(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testPrimitiveValue(true); + testPrimitiveValue(1); + testPrimitiveValue("1"); +} + +function testCoercibleToIntegerFromInteger(nominalInteger, test) { + assert(Number.isInteger(nominalInteger)); + + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + + // Non-primitive values that coerce to the nominal integer: + // toString() returns a string that parsers to a primitive value. + test([value]); + } + + function testPrimitiveNumber(number) { + testPrimitiveValue(number); + // ToNumber: String -> Number + testPrimitiveValue(number.toString()); + } + + testPrimitiveNumber(nominalInteger); + + // ToInteger: floor(abs(number)) + if (nominalInteger >= 0) { + testPrimitiveNumber(nominalInteger + 0.9); + } + if (nominalInteger <= 0) { + testPrimitiveNumber(nominalInteger - 0.9); + } +} + +function testPrimitiveWrappers(primitiveValue, hint, test) { + if (primitiveValue != null) { + // null and undefined result in {} rather than a proper wrapper, + // so skip this case for those values. + test(Object(primitiveValue)); + } + + testCoercibleToPrimitiveWithMethod(hint, function() { + return primitiveValue; + }, test); +} + +function testCoercibleToPrimitiveWithMethod(hint, method, test) { + var methodNames; + if (hint === "number") { + methodNames = ["valueOf", "toString"]; + } else if (hint === "string") { + methodNames = ["toString", "valueOf"]; + } else { + throw new Test262Error(); + } + // precedence order + test({ + [Symbol.toPrimitive]: method, + [methodNames[0]]: function() { throw new Test262Error(); }, + [methodNames[1]]: function() { throw new Test262Error(); }, + }); + test({ + [methodNames[0]]: method, + [methodNames[1]]: function() { throw new Test262Error(); }, + }); + if (hint === "number") { + // The default valueOf returns an object, which is unsuitable. + // The default toString returns a String, which is suitable. + // Therefore this test only works for valueOf falling back to toString. + test({ + // this is toString: + [methodNames[1]]: method, + }); + } + + // GetMethod: if func is undefined or null, return undefined. + test({ + [Symbol.toPrimitive]: undefined, + [methodNames[0]]: method, + [methodNames[1]]: method, + }); + test({ + [Symbol.toPrimitive]: null, + [methodNames[0]]: method, + [methodNames[1]]: method, + }); + + // if methodNames[0] is not callable, fallback to methodNames[1] + test({ + [methodNames[0]]: null, + [methodNames[1]]: method, + }); + test({ + [methodNames[0]]: 1, + [methodNames[1]]: method, + }); + test({ + [methodNames[0]]: {}, + [methodNames[1]]: method, + }); + + // if methodNames[0] returns an object, fallback to methodNames[1] + test({ + [methodNames[0]]: function() { return {}; }, + [methodNames[1]]: method, + }); + test({ + [methodNames[0]]: function() { return Object(1); }, + [methodNames[1]]: method, + }); +} + +function testNotCoercibleToIndex(test) { + function testPrimitiveValue(value) { + test(RangeError, value); + // ToPrimitive + testPrimitiveWrappers(value, "number", function(value) { + test(RangeError, value); + }); + } + + // Let integerIndex be ? ToInteger(value). + testNotCoercibleToInteger(test); + + // If integerIndex < 0, throw a RangeError exception. + testPrimitiveValue(-1); + testPrimitiveValue(-2.5); + testPrimitiveValue("-2.5"); + testPrimitiveValue(-Infinity); + + // Let index be ! ToLength(integerIndex). + // If SameValueZero(integerIndex, index) is false, throw a RangeError exception. + testPrimitiveValue(2 ** 53); + testPrimitiveValue(Infinity); +} + +function testNotCoercibleToInteger(test) { + // ToInteger only throws from ToNumber. + testNotCoercibleToNumber(test); +} + +function testNotCoercibleToNumber(test) { + function testPrimitiveValue(value) { + test(TypeError, value); + // ToPrimitive + testPrimitiveWrappers(value, "number", function(value) { + test(TypeError, value); + }); + } + + // ToNumber: Symbol -> TypeError + testPrimitiveValue(Symbol("1")); + + if (typeof BigInt !== "undefined") { + // ToNumber: BigInt -> TypeError + testPrimitiveValue(BigInt(0)); + } + + // ToPrimitive + testNotCoercibleToPrimitive("number", test); +} + +function testNotCoercibleToPrimitive(hint, test) { + function MyError() {} + + // ToPrimitive: input[@@toPrimitive] is not callable (and non-null) + test(TypeError, {[Symbol.toPrimitive]: 1}); + test(TypeError, {[Symbol.toPrimitive]: {}}); + + // ToPrimitive: input[@@toPrimitive] returns object + test(TypeError, {[Symbol.toPrimitive]: function() { return Object(1); }}); + test(TypeError, {[Symbol.toPrimitive]: function() { return {}; }}); + + // ToPrimitive: input[@@toPrimitive] throws + test(MyError, {[Symbol.toPrimitive]: function() { throw new MyError(); }}); + + // OrdinaryToPrimitive: method throws + testCoercibleToPrimitiveWithMethod(hint, function() { + throw new MyError(); + }, function(value) { + test(MyError, value); + }); + + // OrdinaryToPrimitive: both methods are unsuitable + function testUnsuitableMethod(method) { + test(TypeError, {valueOf:method, toString:method}); + } + // not callable: + testUnsuitableMethod(null); + testUnsuitableMethod(1); + testUnsuitableMethod({}); + // returns object: + testUnsuitableMethod(function() { return Object(1); }); + testUnsuitableMethod(function() { return {}; }); +} + +function testCoercibleToString(test) { + function testPrimitiveValue(value, expectedString) { + test(value, expectedString); + // ToPrimitive + testPrimitiveWrappers(value, "string", function(value) { + test(value, expectedString); + }); + } + + testPrimitiveValue(undefined, "undefined"); + testPrimitiveValue(null, "null"); + testPrimitiveValue(true, "true"); + testPrimitiveValue(false, "false"); + testPrimitiveValue(0, "0"); + testPrimitiveValue(-0, "0"); + testPrimitiveValue(Infinity, "Infinity"); + testPrimitiveValue(-Infinity, "-Infinity"); + testPrimitiveValue(123.456, "123.456"); + testPrimitiveValue(-123.456, "-123.456"); + testPrimitiveValue("", ""); + testPrimitiveValue("foo", "foo"); + + if (typeof BigInt !== "undefined") { + // BigInt -> TypeError + testPrimitiveValue(BigInt(0), "0"); + } + + // toString of a few objects + test([], ""); + test(["foo", "bar"], "foo,bar"); + test({}, "[object Object]"); +} + +function testNotCoercibleToString(test) { + function testPrimitiveValue(value) { + test(TypeError, value); + // ToPrimitive + testPrimitiveWrappers(value, "string", function(value) { + test(TypeError, value); + }); + } + + // Symbol -> TypeError + testPrimitiveValue(Symbol("1")); + + // ToPrimitive + testNotCoercibleToPrimitive("string", test); +} + +function testCoercibleToBooleanTrue(test) { + test(true); + test(1); + test("string"); + test(Symbol("1")); + test({}); +} + +function testCoercibleToBooleanFalse(test) { + test(undefined); + test(null); + test(false); + test(0); + test(-0); + test(NaN); + test(""); +} + +function testCoercibleToBigIntZero(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testCoercibleToBigIntFromBigInt(BigInt(0), test); + testPrimitiveValue(-BigInt(0)); + testPrimitiveValue("-0"); + testPrimitiveValue(false); + testPrimitiveValue(""); + testPrimitiveValue(" "); + + // toString() returns "" + test([]); + + // toString() returns "0" + test([0]); +} + +function testCoercibleToBigIntOne(test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testCoercibleToBigIntFromBigInt(BigInt(1), test); + testPrimitiveValue(true); + + // toString() returns "1" + test([1]); +} + +function testCoercibleToBigIntFromBigInt(nominalBigInt, test) { + function testPrimitiveValue(value) { + test(value); + // ToPrimitive + testPrimitiveWrappers(value, "number", test); + } + + testPrimitiveValue(nominalBigInt); + testPrimitiveValue(nominalBigInt.toString()); + testPrimitiveValue("0b" + nominalBigInt.toString(2)); + testPrimitiveValue("0o" + nominalBigInt.toString(8)); + testPrimitiveValue("0x" + nominalBigInt.toString(16)); + testPrimitiveValue(" " + nominalBigInt.toString() + " "); + + // toString() returns the decimal string representation + test([nominalBigInt]); + test([nominalBigInt.toString()]); +} + +function testNotCoercibleToBigInt(test) { + function testPrimitiveValue(error, value) { + test(error, value); + // ToPrimitive + testPrimitiveWrappers(value, "number", function(value) { + test(error, value); + }); + } + + // Undefined, Null, Number, Symbol -> TypeError + testPrimitiveValue(TypeError, undefined); + testPrimitiveValue(TypeError, null); + testPrimitiveValue(TypeError, 0); + testPrimitiveValue(TypeError, NaN); + testPrimitiveValue(TypeError, Infinity); + testPrimitiveValue(TypeError, Symbol("1")); + + // when a String parses to NaN -> SyntaxError + function testStringValue(string) { + testPrimitiveValue(SyntaxError, string); + testPrimitiveValue(SyntaxError, " " + string); + testPrimitiveValue(SyntaxError, string + " "); + testPrimitiveValue(SyntaxError, " " + string + " "); + } + testStringValue("a"); + testStringValue("0b2"); + testStringValue("0o8"); + testStringValue("0xg"); + testStringValue("1n"); +} diff --git a/harness/wellKnownIntrinsicObjects.js b/harness/wellKnownIntrinsicObjects.js new file mode 100644 index 00000000000..3d0b57dc8bd --- /dev/null +++ b/harness/wellKnownIntrinsicObjects.js @@ -0,0 +1,302 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + An Array of all representable Well-Known Intrinsic Objects +defines: [WellKnownIntrinsicObjects] +---*/ + +const WellKnownIntrinsicObjects = [ + { + name: '%AggregateError%', + source: 'AggregateError', + }, + { + name: '%Array%', + source: 'Array', + }, + { + name: '%ArrayBuffer%', + source: 'ArrayBuffer', + }, + { + name: '%ArrayIteratorPrototype%', + source: 'Object.getPrototypeOf([][Symbol.iterator]())', + }, + { + name: '%AsyncFromSyncIteratorPrototype%', + source: 'undefined', + }, + { + name: '%AsyncFunction%', + source: '(async function() {}).constructor', + }, + { + name: '%AsyncGeneratorFunction%', + source: 'Object.getPrototypeOf(async function * () {})', + }, + { + name: '%AsyncIteratorPrototype%', + source: '((async function * () {})())[Symbol.asyncIterator]()', + }, + { + name: '%Atomics%', + source: 'Atomics', + }, + { + name: '%BigInt%', + source: 'BigInt', + }, + { + name: '%BigInt64Array%', + source: 'BigInt64Array', + }, + { + name: '%BigUint64Array%', + source: 'BigUint64Array', + }, + { + name: '%Boolean%', + source: 'Boolean', + }, + { + name: '%DataView%', + source: 'DataView', + }, + { + name: '%Date%', + source: 'Date', + }, + { + name: '%decodeURI%', + source: 'decodeURI', + }, + { + name: '%decodeURIComponent%', + source: 'decodeURIComponent', + }, + { + name: '%encodeURI%', + source: 'encodeURI', + }, + { + name: '%encodeURIComponent%', + source: 'encodeURIComponent', + }, + { + name: '%Error%', + source: 'Error', + }, + { + name: '%eval%', + source: 'eval', + }, + { + name: '%EvalError%', + source: 'EvalError', + }, + { + name: '%FinalizationRegistry%', + source: 'FinalizationRegistry', + }, + { + name: '%Float32Array%', + source: 'Float32Array', + }, + { + name: '%Float64Array%', + source: 'Float64Array', + }, + { + name: '%ForInIteratorPrototype%', + source: '', + }, + { + name: '%Function%', + source: 'Function', + }, + { + name: '%GeneratorFunction%', + source: 'Object.getPrototypeOf(function * () {})', + }, + { + name: '%Int8Array%', + source: 'Int8Array', + }, + { + name: '%Int16Array%', + source: 'Int16Array', + }, + { + name: '%Int32Array%', + source: 'Int32Array', + }, + { + name: '%isFinite%', + source: 'isFinite', + }, + { + name: '%isNaN%', + source: 'isNaN', + }, + { + name: '%IteratorPrototype%', + source: 'Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]()))', + }, + { + name: '%JSON%', + source: 'JSON', + }, + { + name: '%Map%', + source: 'Map', + }, + { + name: '%MapIteratorPrototype%', + source: 'Object.getPrototypeOf(new Map()[Symbol.iterator]())', + }, + { + name: '%Math%', + source: 'Math', + }, + { + name: '%Number%', + source: 'Number', + }, + { + name: '%Object%', + source: 'Object', + }, + { + name: '%parseFloat%', + source: 'parseFloat', + }, + { + name: '%parseInt%', + source: 'parseInt', + }, + { + name: '%Promise%', + source: 'Promise', + }, + { + name: '%Proxy%', + source: 'Proxy', + }, + { + name: '%RangeError%', + source: 'RangeError', + }, + { + name: '%ReferenceError%', + source: 'ReferenceError', + }, + { + name: '%Reflect%', + source: 'Reflect', + }, + { + name: '%RegExp%', + source: 'RegExp', + }, + { + name: '%RegExpStringIteratorPrototype%', + source: 'RegExp.prototype[Symbol.matchAll]("")', + }, + { + name: '%Set%', + source: 'Set', + }, + { + name: '%SetIteratorPrototype%', + source: 'Object.getPrototypeOf(new Set()[Symbol.iterator]())', + }, + { + name: '%SharedArrayBuffer%', + source: 'SharedArrayBuffer', + }, + { + name: '%String%', + source: 'String', + }, + { + name: '%StringIteratorPrototype%', + source: 'Object.getPrototypeOf(new String()[Symbol.iterator]())', + }, + { + name: '%Symbol%', + source: 'Symbol', + }, + { + name: '%SyntaxError%', + source: 'SyntaxError', + }, + { + name: '%ThrowTypeError%', + source: '(function() { "use strict"; return Object.getOwnPropertyDescriptor(arguments, "callee").get })()', + }, + { + name: '%TypedArray%', + source: 'Object.getPrototypeOf(Uint8Array)', + }, + { + name: '%TypeError%', + source: 'TypeError', + }, + { + name: '%Uint8Array%', + source: 'Uint8Array', + }, + { + name: '%Uint8ClampedArray%', + source: 'Uint8ClampedArray', + }, + { + name: '%Uint16Array%', + source: 'Uint16Array', + }, + { + name: '%Uint32Array%', + source: 'Uint32Array', + }, + { + name: '%URIError%', + source: 'URIError', + }, + { + name: '%WeakMap%', + source: 'WeakMap', + }, + { + name: '%WeakRef%', + source: 'WeakRef', + }, + { + name: '%WeakSet%', + source: 'WeakSet', + }, +]; + +WellKnownIntrinsicObjects.forEach((wkio) => { + var actual; + + try { + actual = new Function("return " + wkio.source)(); + } catch (exception) { + // Nothing to do here. + } + + wkio.value = actual; +}); diff --git a/package.json b/package.json new file mode 100644 index 00000000000..faa769dd7c7 --- /dev/null +++ b/package.json @@ -0,0 +1,31 @@ +{ + "name": "test262", + "version": "5.0.0", + "description": "Test262 tests conformance to the continually maintained draft future ECMAScript standard found at http://tc39.github.io/ecma262/ , together with any Stage 3 or later TC39 proposals.", + "repository": { + "type": "git", + "url": "git+https://github.com/tc39/test262.git" + }, + "license": "BSD", + "bugs": { + "url": "https://github.com/tc39/test262/issues" + }, + "private": true, + "homepage": "https://github.com/tc39/test262#readme", + "devDependencies": { + "esvu": "^1.2.11", + "test262-harness": "^8.0.0" + }, + "scripts": { + "ci": "./tools/scripts/ci_test.sh", + "test": "test262-harness", + "diff": "git diff --diff-filter ACMR --name-only main.. -- test/ && git ls-files --exclude-standard --others -- test/", + "test:diff": "npm run test:diff:v8 && npm run test:diff:spidermonkey && npm run test:diff:chakra && npm run test:diff:javascriptcore", + "test:diff:v8": "test262-harness -t 8 --hostType=d8 --hostPath=v8 $(npm run --silent diff)", + "test:diff:spidermonkey": "test262-harness -t 8 --hostType=jsshell --hostPath=spidermonkey $(npm run --silent diff)", + "test:diff:chakra": "test262-harness -t 8 --hostType=ch --hostPath=chakra $(npm run --silent diff)", + "test:diff:javascriptcore": "test262-harness -t 8 --hostType=jsc --hostPath=javascriptcore $(npm run --silent diff)", + "test:diff:xs": "test262-harness -t 8 --hostType=xs --hostPath=xs $(npm run --silent diff)" + } +} + diff --git a/test/sendable/builtins/ASON/15.12-0-1.js b/test/sendable/builtins/ASON/15.12-0-1.js new file mode 100644 index 00000000000..5a18e8cc541 --- /dev/null +++ b/test/sendable/builtins/ASON/15.12-0-1.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: | + This test should be run without any built-ins being added/augmented. + The name JSON must be bound to an object. + 4.2 calls out JSON as one of the built-in objects. +es5id: 15.12-0-1 +description: JSON must be a built-in object +---*/ + +var o = JSON; + +assert.sameValue(typeof(o), "object", 'typeof(o)'); diff --git a/test/sendable/builtins/ASON/15.12-0-2.js b/test/sendable/builtins/ASON/15.12-0-2.js new file mode 100644 index 00000000000..be97a00743e --- /dev/null +++ b/test/sendable/builtins/ASON/15.12-0-2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: | + This test should be run without any built-ins being added/augmented. + The name JSON must be bound to an object, and must not support [[Construct]]. + step 4 in 11.2.2 should throw a TypeError exception. +es5id: 15.12-0-2 +description: JSON must not support the [[Construct]] method +---*/ + +var o = JSON; +assert.throws(TypeError, function() { + var j = new JSON(); +}); diff --git a/test/sendable/builtins/ASON/15.12-0-3.js b/test/sendable/builtins/ASON/15.12-0-3.js new file mode 100644 index 00000000000..2de9aba9f99 --- /dev/null +++ b/test/sendable/builtins/ASON/15.12-0-3.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: | + This test should be run without any built-ins being added/augmented. + The name JSON must be bound to an object, and must not support [[Call]]. + step 5 in 11.2.3 should throw a TypeError exception. +es5id: 15.12-0-3 +description: JSON must not support the [[Call]] method +---*/ + +var o = JSON; +assert.throws(TypeError, function() { + var j = JSON(); +}); diff --git a/test/sendable/builtins/ASON/15.12-0-4.js b/test/sendable/builtins/ASON/15.12-0-4.js new file mode 100644 index 00000000000..88211d9d301 --- /dev/null +++ b/test/sendable/builtins/ASON/15.12-0-4.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: | + This test should be run without any built-ins being added/augmented. + The last paragraph in section 15 says "every other property described + in this section has the attribute {... [[Enumerable]] : false ...} + unless otherwise specified. This default applies to the properties on + JSON, and we should not be able to enumerate them. +es5id: 15.12-0-4 +description: JSON object's properties must be non enumerable +---*/ + +var o = JSON; +var i = 0; +for (var p in o) { + i++; +} + + +assert.sameValue(i, 0, 'i'); diff --git a/test/sendable/builtins/ASON/Symbol.toStringTag.js b/test/sendable/builtins/ASON/Symbol.toStringTag.js new file mode 100644 index 00000000000..1f521b04297 --- /dev/null +++ b/test/sendable/builtins/ASON/Symbol.toStringTag.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +es6id: 24.3.3 +description: > + `Symbol.toStringTag` property descriptor +info: | + The initial value of the @@toStringTag property is the String value + "JSON". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.toStringTag] +---*/ + +assert.sameValue(JSON[Symbol.toStringTag], 'JSON'); + +verifyNotEnumerable(JSON, Symbol.toStringTag); +verifyNotWritable(JSON, Symbol.toStringTag); +verifyConfigurable(JSON, Symbol.toStringTag); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-1.js new file mode 100644 index 00000000000..50dea92ecd0 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-1 +description: The JSON lexical grammar treats whitespace as a token seperator +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12\t\r\n 34'); // should produce a syntax error as whitespace results in two tokens +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-2.js new file mode 100644 index 00000000000..17d77b48a5b --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-2 +description: > + is not valid JSON whitespace as specified by the production + JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u000b1234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-3.js new file mode 100644 index 00000000000..4f64dc20b48 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-3 +description: > + is not valid JSON whitespace as specified by the production + JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u000c1234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-4.js new file mode 100644 index 00000000000..b0a57d78ff0 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-4.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-4 +description: > + is not valid JSON whitespace as specified by the production + JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u00a01234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-5.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-5.js new file mode 100644 index 00000000000..201a22e7703 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-5.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-5 +description: > + is not valid JSON whitespace as specified by the + production JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u200b1234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-6.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-6.js new file mode 100644 index 00000000000..b5a2e2a7b2f --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-6.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-6 +description: > + is not valid JSON whitespace as specified by the production + JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\ufeff1234'); // should produce a syntax error a +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-8.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-8.js new file mode 100644 index 00000000000..c37e2e39a35 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-8.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-8 +description: > + U+2028 and U+2029 are not valid JSON whitespace as specified by + the production JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u2028\u20291234'); // should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-0-9.js b/test/sendable/builtins/ASON/parse/15.12.1.1-0-9.js new file mode 100644 index 00000000000..6efca79868c --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-0-9.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-0-9 +description: Whitespace characters can appear before/after any JSONtoken +---*/ + +JSON.parseSendable('\t\r \n{\t\r \n' + + '"property"\t\r \n:\t\r \n{\t\r \n}\t\r \n,\t\r \n' + + '"prop2"\t\r \n:\t\r \n' + + '[\t\r \ntrue\t\r \n,\t\r \nnull\t\r \n,123.456\t\r \n]' + + '\t\r \n}\t\r \n'); // should JOSN parse without error diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g1-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-1.js new file mode 100644 index 00000000000..5ffb43c42ba --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g1-1 +description: The JSON lexical grammar treats as a whitespace character +---*/ + +assert.sameValue(JSON.parseSendable('\t1234'), 1234, ' should be ignored'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12\t34'); +}, ' should produce a syntax error as whitespace results in two tokens'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g1-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-2.js new file mode 100644 index 00000000000..616ce7a920d --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g1-2 +description: The JSON lexical grammar treats as a whitespace character +---*/ + +assert.sameValue(JSON.parseSendable('\r1234'), 1234, ' should be ignored'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12\r34'); +}, ' should produce a syntax error as whitespace results in two tokens'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g1-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-3.js new file mode 100644 index 00000000000..10e3d2e6651 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g1-3 +description: The JSON lexical grammar treats as a whitespace character +---*/ + +assert.sameValue(JSON.parseSendable('\n1234'), 1234, ' should be ignored'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12\n34'); +}, ' should produce a syntax error as whitespace results in two tokens'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g1-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-4.js new file mode 100644 index 00000000000..7036a2c6976 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g1-4.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g1-4 +description: The JSON lexical grammar treats as a whitespace character +---*/ + +assert.sameValue(JSON.parseSendable(' 1234'), 1234, ' should be ignored'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('12 34'); +}, ' should produce a syntax error as whitespace results in two tokens'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-1.js new file mode 100644 index 00000000000..0b267f2b768 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-1.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-1 +description: JSONStrings can be written using double quotes +---*/ + +assert.sameValue(JSON.parseSendable('"abc"'), "abc", 'JSON.parseSendable(\'"abc"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-2.js new file mode 100644 index 00000000000..2e668977bc5 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-2.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-2 +description: A JSONString may not be delimited by single quotes +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable("'abc'"); +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-3.js new file mode 100644 index 00000000000..e669dcd42a7 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-3 +description: A JSONString may not be delimited by Uncode escaped quotes +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable("\\u0022abc\\u0022"); +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-4.js new file mode 100644 index 00000000000..70b5fb22e09 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-4.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-4 +description: A JSONString must both begin and end with double quotes +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"ab'+"c'"); +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g2-5.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-5.js new file mode 100644 index 00000000000..25e2ad16bd6 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g2-5.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g2-5 +description: > + A JSONStrings can contain no JSONStringCharacters (Empty + JSONStrings) +---*/ + +assert.sameValue(JSON.parseSendable('""'), "", 'JSON.parseSendable(\'""\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g4-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-1.js new file mode 100644 index 00000000000..90922377afb --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g4-1 +description: > + The JSON lexical grammar does not allow a JSONStringCharacter to + be any of the Unicode characters U+0000 thru U+0007 +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007"'); // invalid string characters should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g4-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-2.js new file mode 100644 index 00000000000..3d78b1713bd --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g4-2 +description: > + The JSON lexical grammar does not allow a JSONStringCharacter to + be any of the Unicode characters U+0008 thru U+000F +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\u0008\u0009\u000a\u000b\u000c\u000d\u000e\u000f"'); // invalid string characters should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g4-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-3.js new file mode 100644 index 00000000000..70666e48bbe --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g4-3 +description: > + The JSON lexical grammar does not allow a JSONStringCharacter to + be any of the Unicode characters U+0010 thru U+0017 +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017"'); // invalid string characters should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g4-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-4.js new file mode 100644 index 00000000000..15f0fa148ec --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g4-4.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g4-4 +description: > + The JSON lexical grammar does not allow a JSONStringCharacter to + be any of the Unicode characters U+0018 thru U+001F +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f"'); // invalid string characters should produce a syntax error +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g5-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-1.js new file mode 100644 index 00000000000..7c8956efc0f --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g5-1 +description: > + The JSON lexical grammar allows Unicode escape sequences in a + JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\u0058"'), 'X', 'JSON.parseSendable(\'"\\u0058"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g5-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-2.js new file mode 100644 index 00000000000..b0f26a5e5da --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g5-2 +description: > + A JSONStringCharacter UnicodeEscape may not have fewer than 4 hex + characters +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\\u005"') +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g5-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-3.js new file mode 100644 index 00000000000..39902df1e08 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g5-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g5-3 +description: > + A JSONStringCharacter UnicodeEscape may not include any non=hex + characters +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('"\\u0X50"') +}); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-1.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-1.js new file mode 100644 index 00000000000..f6c13053628 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-1 +description: > + The JSON lexical grammer allows '/' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\/"'), '/', 'JSON.parseSendable(\'"\\/"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-2.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-2.js new file mode 100644 index 00000000000..999f68dec57 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-2.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-2 +description: > + The JSON lexical grammer allows '' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\\\"'), '\\', 'JSON.parseSendable(\'"\\\\"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-3.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-3.js new file mode 100644 index 00000000000..1121b8279d1 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-3 +description: > + The JSON lexical grammer allows 'b' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\b"'), '\b', 'JSON.parseSendable(\'"\\b"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-4.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-4.js new file mode 100644 index 00000000000..ac68e632327 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-4.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-4 +description: > + The JSON lexical grammer allows 'f' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\f"'), '\f', 'JSON.parseSendable(\'"\\f"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-5.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-5.js new file mode 100644 index 00000000000..12ae29aa064 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-5.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-5 +description: > + The JSON lexical grammer allows 'n' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\n"'), '\n', 'JSON.parseSendable(\'"\\n"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-6.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-6.js new file mode 100644 index 00000000000..d2af48c9027 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-6.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-6 +description: > + The JSON lexical grammer allows 'r' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\r"'), '\r', 'JSON.parseSendable(\'"\\r"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.1.1-g6-7.js b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-7.js new file mode 100644 index 00000000000..2694840cdd4 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.1.1-g6-7.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.1.1-g6-7 +description: > + The JSON lexical grammer allows 't' as a JSONEscapeCharacter after + '' in a JSONString +---*/ + +assert.sameValue(JSON.parseSendable('"\\t"'), '\t', 'JSON.parseSendable(\'"\\t"\')'); diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-1.js b/test/sendable/builtins/ASON/parse/15.12.2-2-1.js new file mode 100644 index 00000000000..f930df426b4 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-1.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-1 +description: > + JSON.parse - parsing an object where property name is a null + character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ ' + nullChars[index] + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-10.js b/test/sendable/builtins/ASON/parse/15.12.2-2-10.js new file mode 100644 index 00000000000..9d6fb44ae11 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-10.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-10 +description: > + JSON.parse - parsing an object where property value middles with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + "Jo" + nullChars[index] + "hn" + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-2.js b/test/sendable/builtins/ASON/parse/15.12.2-2-2.js new file mode 100644 index 00000000000..c186f556dc7 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-2.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-2 +description: > + JSON.parse - parsing an object where property name starts with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ ' + nullChars[index] + "name" + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-3.js b/test/sendable/builtins/ASON/parse/15.12.2-2-3.js new file mode 100644 index 00000000000..5378050c58d --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-3.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-3 +description: > + JSON.parse - parsing an object where property name ends with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{' + "name" + nullChars[index] + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-4.js b/test/sendable/builtins/ASON/parse/15.12.2-2-4.js new file mode 100644 index 00000000000..b382455ca13 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-4.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-4 +description: > + JSON.parse - parsing an object where property name starts and ends + with a null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{' + nullChars[index] + "name" + nullChars[index] + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-5.js b/test/sendable/builtins/ASON/parse/15.12.2-2-5.js new file mode 100644 index 00000000000..4364a4757f1 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-5.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-5 +description: > + JSON.parse - parsing an object where property name middles with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ ' + "na" + nullChars[index] + "me" + ' : "John" } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-6.js b/test/sendable/builtins/ASON/parse/15.12.2-2-6.js new file mode 100644 index 00000000000..8cf76e5d294 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-6.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-6 +description: > + JSON.parse - parsing an object where property value is a null + character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + nullChars[index] + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-7.js b/test/sendable/builtins/ASON/parse/15.12.2-2-7.js new file mode 100644 index 00000000000..70c8283e19b --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-7.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-7 +description: > + JSON.parse - parsing an object where property value starts with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + nullChars[index] + "John" + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-8.js b/test/sendable/builtins/ASON/parse/15.12.2-2-8.js new file mode 100644 index 00000000000..c3abc56c3d4 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-8.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-8 +description: > + JSON.parse - parsing an object where property value ends with a + null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + "John" + nullChars[index] + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/15.12.2-2-9.js b/test/sendable/builtins/ASON/parse/15.12.2-2-9.js new file mode 100644 index 00000000000..7a4e6633618 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/15.12.2-2-9.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +es5id: 15.12.2-2-9 +description: > + JSON.parse - parsing an object where property value starts and + ends with a null character +---*/ + +var nullChars = new Array(); +nullChars[0] = '\"\u0000\"'; +nullChars[1] = '\"\u0001\"'; +nullChars[2] = '\"\u0002\"'; +nullChars[3] = '\"\u0003\"'; +nullChars[4] = '\"\u0004\"'; +nullChars[5] = '\"\u0005\"'; +nullChars[6] = '\"\u0006\"'; +nullChars[7] = '\"\u0007\"'; +nullChars[8] = '\"\u0008\"'; +nullChars[9] = '\"\u0009\"'; +nullChars[10] = '\"\u000A\"'; +nullChars[11] = '\"\u000B\"'; +nullChars[12] = '\"\u000C\"'; +nullChars[13] = '\"\u000D\"'; +nullChars[14] = '\"\u000E\"'; +nullChars[15] = '\"\u000F\"'; +nullChars[16] = '\"\u0010\"'; +nullChars[17] = '\"\u0011\"'; +nullChars[18] = '\"\u0012\"'; +nullChars[19] = '\"\u0013\"'; +nullChars[20] = '\"\u0014\"'; +nullChars[21] = '\"\u0015\"'; +nullChars[22] = '\"\u0016\"'; +nullChars[23] = '\"\u0017\"'; +nullChars[24] = '\"\u0018\"'; +nullChars[25] = '\"\u0019\"'; +nullChars[26] = '\"\u001A\"'; +nullChars[27] = '\"\u001B\"'; +nullChars[28] = '\"\u001C\"'; +nullChars[29] = '\"\u001D\"'; +nullChars[30] = '\"\u001E\"'; +nullChars[31] = '\"\u001F\"'; + +for (var index in nullChars) { + assert.throws(SyntaxError, function() { + var obj = JSON.parseSendable('{ "name" : ' + nullChars[index] + "John" + nullChars[index] + ' } '); + }); +} diff --git a/test/sendable/builtins/ASON/parse/S15.12.2_A1.js b/test/sendable/builtins/ASON/parse/S15.12.2_A1.js new file mode 100644 index 00000000000..c3ea45ad889 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/S15.12.2_A1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: JSON.parse must create a property with the given property name +es5id: 15.12.2_A1 +description: Tests that JSON.parse treats "__proto__" as a regular property name +---*/ + +var x = JSON.parseSendable('{"__proto__":[]}'); + +assert.sameValue( + Object.getPrototypeOf(x), + Object.prototype, + 'Object.getPrototypeOf("JSON.parseSendable(\'{"__proto__":[]}\')") returns Object.prototype' +); + +assert(Array.isArray(x.__proto__), 'Array.isArray(x.__proto__) must return true'); diff --git a/test/sendable/builtins/ASON/parse/invalid-whitespace.js b/test/sendable/builtins/ASON/parse/invalid-whitespace.js new file mode 100644 index 00000000000..b65c52f5d03 --- /dev/null +++ b/test/sendable/builtins/ASON/parse/invalid-whitespace.js @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-json.parse +es5id: 15.12.1.1-0-7 +description: > + other category z spaces are not valid JSON whitespace as specified + by the production JSONWhitespace. +---*/ + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u16801'); +}, '\\u1680'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u180e1'); +}, '\\u180e'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20001'); +}, '\\u2000'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20011'); +}, '\\u2001'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20021'); +}, '\\u2002'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20031'); +}, '\\u2003'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20041'); +}, '\\u2004'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20051'); +}, '\\u2005'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20061'); +}, '\\u2006'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20071'); +}, '\\u2007'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20081'); +}, '\\u2008'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u20091'); +}, '\\u2009'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u200a1'); +}, '\\u200a'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u202f1'); +}, '\\u202f'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u205f1'); +}, '\\u205f'); + +assert.throws(SyntaxError, function() { + JSON.parseSendable('\u30001'); +}, '\\u3000'); diff --git a/test/sendable/builtins/ASON/stringify/value-bigint-cross-realm.js b/test/sendable/builtins/ASON/stringify/value-bigint-cross-realm.js new file mode 100644 index 00000000000..123d728f29d --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-bigint-cross-realm.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-serializejsonproperty +description: JSON.stringify called with a BigInt object from another realm +features: [BigInt, cross-realm] +---*/ + +var other = $262.createRealm().global; +var wrapped = other.Object(other.BigInt(100)); + +assert.throws(TypeError, () => JSON.stringify(wrapped), + "cross-realm BigInt object without toJSON method"); + +other.BigInt.prototype.toJSON = function () { return this.toString(); }; + +assert.sameValue(JSON.stringify(wrapped), "\"100\"", + "cross-realm BigInt object with toJSON method"); diff --git a/test/sendable/builtins/ASON/stringify/value-bigint-order.js b/test/sendable/builtins/ASON/stringify/value-bigint-order.js new file mode 100644 index 00000000000..253986e5069 --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-bigint-order.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: BigInt stringify order of steps +esid: sec-serializejsonproperty +info: | + Runtime Semantics: SerializeJSONProperty ( key, holder ) + + 2. If Type(value) is Object or BigInt, then + a. Let toJSON be ? GetGetV(value, "toJSON"). + b. If IsCallable(toJSON) is true, then + i. Set value to ? Call(toJSON, value, « key »). + 3. If ReplacerFunction is not undefined, then + a. Set value to ? Call(ReplacerFunction, holder, « key, value »). + 4. If Type(value) is Object, then + [...] + d. Else if value has a [[BigIntData]] internal slot, then + i. Set value to value.[[BigIntData]]. + [...] + 10. If Type(value) is BigInt, throw a TypeError exception +features: [BigInt, arrow-function] +---*/ + +let step; + +function replacer(x, k, v) +{ + assert.sameValue(step++, 1); + assert.sameValue(v, 1n); + return x; +} + +BigInt.prototype.toJSON = function () { assert.sameValue(step++, 0); return 1n; }; + +step = 0; +assert.throws(TypeError, () => JSON.stringify(0n, (k, v) => replacer(2n, k, v))); +assert.sameValue(step, 2); + +step = 0; +assert.throws(TypeError, () => JSON.stringify(0n, (k, v) => replacer(Object(2n), k, v))); +assert.sameValue(step, 2); diff --git a/test/sendable/builtins/ASON/stringify/value-bigint-replacer.js b/test/sendable/builtins/ASON/stringify/value-bigint-replacer.js new file mode 100644 index 00000000000..3213f22f8e9 --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-bigint-replacer.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: JSON serialization of BigInt values with replacer +esid: sec-serializejsonproperty +info: | + Runtime Semantics: SerializeJSONProperty ( key, holder ) + + 3. If ReplacerFunction is not undefined, then + a. Set value to ? Call(ReplacerFunction, holder, « key, value »). +features: [BigInt] +---*/ + +function replacer(k, v) +{ + if (typeof v === "bigint") + return "bigint"; + else + return v; +} + +assert.sameValue(JSON.stringify(0n, replacer), '"bigint"'); +assert.sameValue(JSON.stringify({x: 0n}, replacer), '{"x":"bigint"}'); diff --git a/test/sendable/builtins/ASON/stringify/value-bigint.js b/test/sendable/builtins/ASON/stringify/value-bigint.js new file mode 100644 index 00000000000..1170ebe057b --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-bigint.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: JSON serialization of BigInt values +esid: pending +features: [BigInt] +---*/ + +assert.throws(TypeError, () => JSON.stringify(0n)); +assert.throws(TypeError, () => JSON.stringify(Object(0n))); +assert.throws(TypeError, () => JSON.stringify({x: 0n})); diff --git a/test/sendable/builtins/ASON/stringify/value-string-escape-unicode.js b/test/sendable/builtins/ASON/stringify/value-string-escape-unicode.js new file mode 100644 index 00000000000..67d77a18d46 --- /dev/null +++ b/test/sendable/builtins/ASON/stringify/value-string-escape-unicode.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-quotejsonstring +description: > + JSON.stringify strings containing surrogate code units +features: [well-formed-json-stringify] +---*/ + +assert.sameValue(JSON.stringify("\uD834"), '"\\ud834"', + 'JSON.stringify("\\uD834")'); +assert.sameValue(JSON.stringify("\uDF06"), '"\\udf06"', + 'JSON.stringify("\\uDF06")'); + +assert.sameValue(JSON.stringify("\uD834\uDF06"), '"𝌆"', + 'JSON.stringify("\\uD834\\uDF06")'); +assert.sameValue(JSON.stringify("\uD834\uD834\uDF06\uD834"), '"\\ud834𝌆\\ud834"', + 'JSON.stringify("\\uD834\\uD834\\uDF06\\uD834")'); +assert.sameValue(JSON.stringify("\uD834\uD834\uDF06\uDF06"), '"\\ud834𝌆\\udf06"', + 'JSON.stringify("\\uD834\\uD834\\uDF06\\uDF06")'); +assert.sameValue(JSON.stringify("\uDF06\uD834\uDF06\uD834"), '"\\udf06𝌆\\ud834"', + 'JSON.stringify("\\uDF06\\uD834\\uDF06\\uD834")'); +assert.sameValue(JSON.stringify("\uDF06\uD834\uDF06\uDF06"), '"\\udf06𝌆\\udf06"', + 'JSON.stringify("\\uDF06\\uD834\\uDF06\\uDF06")'); + +assert.sameValue(JSON.stringify("\uDF06\uD834"), '"\\udf06\\ud834"', + 'JSON.stringify("\\uDF06\\uD834")'); +assert.sameValue(JSON.stringify("\uD834\uDF06\uD834\uD834"), '"𝌆\\ud834\\ud834"', + 'JSON.stringify("\\uD834\\uDF06\\uD834\\uD834")'); +assert.sameValue(JSON.stringify("\uD834\uDF06\uD834\uDF06"), '"𝌆𝌆"', + 'JSON.stringify("\\uD834\\uDF06\\uD834\\uDF06")'); +assert.sameValue(JSON.stringify("\uDF06\uDF06\uD834\uD834"), '"\\udf06\\udf06\\ud834\\ud834"', + 'JSON.stringify("\\uDF06\\uDF06\\uD834\\uD834")'); +assert.sameValue(JSON.stringify("\uDF06\uDF06\uD834\uDF06"), '"\\udf06\\udf06𝌆"', + 'JSON.stringify("\\uDF06\\uDF06\\uD834\\uDF06")'); diff --git a/test/sendable/builtins/Array/from/TC001.js b/test/sendable/builtins/Array/from/TC001.js new file mode 100644 index 00000000000..aa619a7248e --- /dev/null +++ b/test/sendable/builtins/Array/from/TC001.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Passing a valid array +---*/ + +var array = [0, 'foo', , Infinity]; +var result = SendableArray.from(array); +assert.sameValue(result.length, 4, 'The value of result.length is expected to be 4'); +assert.sameValue(result[0], 0, 'The value of result[0] is expected to be 0'); +assert.sameValue(result[1], 'foo', 'The value of result[1] is expected to be "foo"'); +assert.sameValue(result[2], undefined, 'The value of result[2] is expected to equal undefined'); +assert.sameValue(result[3], Infinity, 'The value of result[3] is expected to equal Infinity'); +assert.notSameValue( + result, array, + 'The value of result is expected to not equal the value of `array`' +); +assert(result instanceof SendableArray, 'The result of evaluating (result instanceof SendableArray) is expected to be true'); diff --git a/test/sendable/builtins/Array/from/TC002.js b/test/sendable/builtins/Array/from/TC002.js new file mode 100644 index 00000000000..ce3661c59be --- /dev/null +++ b/test/sendable/builtins/Array/from/TC002.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Creates an array with length that is equal to the value of the + length property of the given array-like, regardless of + the presence of corresponding indices and values. +info: | + Array.from ( items [ , mapfn [ , thisArg ] ] ) + 7. Let arrayLike be ! ToObject(items). + 8. Let len be ? LengthOfArrayLike(arrayLike). + 9. If IsConstructor(C) is true, then + a. Let A be ? Construct(C, « 𝔽(len) »). + 10. Else, + a. Let A be ? ArrayCreate(len). +includes: [compareArray.js] +---*/ + +const length = 5; +const newlyCreatedArray = SendableArray.from({ length }); +assert.sameValue( + newlyCreatedArray.length, + length, + "The newly created array's length is equal to the value of the length property for the provided array like object" +); +assert.compareArray(newlyCreatedArray, [undefined, undefined, undefined, undefined, undefined]); +const newlyCreatedAndMappedArray = SendableArray.from({ length }).map(x => 1); +assert.sameValue( + newlyCreatedAndMappedArray.length, + length, + "The newly created and mapped array's length is equal to the value of the length property for the provided array like object" +); +assert.compareArray(newlyCreatedAndMappedArray, [1, 1, 1, 1, 1]); diff --git a/test/sendable/builtins/Array/from/TC003.js b/test/sendable/builtins/Array/from/TC003.js new file mode 100644 index 00000000000..801b9875a4b --- /dev/null +++ b/test/sendable/builtins/Array/from/TC003.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + The length property of the Array.from method is 1. +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + The length property of the from method is 1. +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.from, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/from/TC004.js b/test/sendable/builtins/Array/from/TC004.js new file mode 100644 index 00000000000..de974879a84 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC004.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Testing descriptor property of Array.from +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray, "from", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/from/TC005.js b/test/sendable/builtins/Array/from/TC005.js new file mode 100644 index 00000000000..24a46782617 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC005.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: '`name` property' +info: | + ES6 Section 17: + 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, this value is the name that is given to + the function in this specification. + 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(SendableArray.from, "name", { + value: "from", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/from/TC006.js b/test/sendable/builtins/Array/from/TC006.js new file mode 100644 index 00000000000..a8b9e819e70 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC006.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + If this is a constructor, and items doesn't have an @@iterator, + returns a new instance of this +info: | + 22.1.2.1 SendableArray.from ( items [ , mapfn [ , thisArg ] ] ) + 4. Let usingIterator be GetMethod(items, @@iterator). + 6. If usingIterator is not undefined, then + 12. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 13. Else, + a. Let A be ArrayCreate(len). + 19. Return A. +---*/ + +var result; +function myCollection() { + this.args = arguments; +} +result = SendableArray.from.call(myCollection, { + length: 42 +}); +assert.sameValue(result.args.length, 1, 'The value of result.args.length is expected to be 1'); +assert.sameValue(result.args[0], 42, 'The value of result.args[0] is expected to be 42'); +assert( + result instanceof myCollection, + 'The result of evaluating (result instanceof myCollection) is expected to be true' +); diff --git a/test/sendable/builtins/Array/from/TC007.js b/test/sendable/builtins/Array/from/TC007.js new file mode 100644 index 00000000000..d3eb3ee9c1c --- /dev/null +++ b/test/sendable/builtins/Array/from/TC007.js @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Map function without thisArg on non strict mode +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + 10. Let len be ToLength(Get(arrayLike, "length")). + 11. ReturnIfAbrupt(len). + 12. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 13. Else, + b. Let A be ArrayCreate(len). + 14. ReturnIfAbrupt(A). + 15. Let k be 0. + 16. Repeat, while k < len + a. Let Pk be ToString(k). + b. Let kValue be Get(arrayLike, Pk). + c. ReturnIfAbrupt(kValue). + d. If mapping is true, then + i. Let mappedValue be Call(mapfn, T, «kValue, k»). +flags: [noStrict] +---*/ + +var list = { + '0': 41, + '1': 42, + '2': 43, + length: 3 +}; +var calls = []; +function mapFn(value) { + calls.push({ + args: arguments, + thisArg: this + }); + return value * 2; +} +var result = SendableArray.from(list, mapFn); +assert.sameValue(result.length, 3, 'The value of result.length is expected to be 3'); +assert.sameValue(result[0], 82, 'The value of result[0] is expected to be 82'); +assert.sameValue(result[1], 84, 'The value of result[1] is expected to be 84'); +assert.sameValue(result[2], 86, 'The value of result[2] is expected to be 86'); +assert.sameValue(calls.length, 3, 'The value of calls.length is expected to be 3'); +assert.sameValue(calls[0].args.length, 2, 'The value of calls[0].args.length is expected to be 2'); +assert.sameValue(calls[0].args[0], 41, 'The value of calls[0].args[0] is expected to be 41'); +assert.sameValue(calls[0].args[1], 0, 'The value of calls[0].args[1] is expected to be 0'); +assert.sameValue(calls[0].thisArg, this, 'The value of calls[0].thisArg is expected to be this'); +assert.sameValue(calls[1].args.length, 2, 'The value of calls[1].args.length is expected to be 2'); +assert.sameValue(calls[1].args[0], 42, 'The value of calls[1].args[0] is expected to be 42'); +assert.sameValue(calls[1].args[1], 1, 'The value of calls[1].args[1] is expected to be 1'); +assert.sameValue(calls[1].thisArg, this, 'The value of calls[1].thisArg is expected to be this'); +assert.sameValue(calls[2].args.length, 2, 'The value of calls[2].args.length is expected to be 2'); +assert.sameValue(calls[2].args[0], 43, 'The value of calls[2].args[0] is expected to be 43'); +assert.sameValue(calls[2].args[1], 2, 'The value of calls[2].args[1] is expected to be 2'); +assert.sameValue(calls[2].thisArg, this, 'The value of calls[2].thisArg is expected to be this'); diff --git a/test/sendable/builtins/Array/from/TC008.js b/test/sendable/builtins/Array/from/TC008.js new file mode 100644 index 00000000000..084464978f4 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC008.js @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Map function without thisArg on strict mode +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + 10. Let len be ToLength(Get(arrayLike, "length")). + 11. ReturnIfAbrupt(len). + 12. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 13. Else, + b. Let A be ArrayCreate(len). + 14. ReturnIfAbrupt(A). + 15. Let k be 0. + 16. Repeat, while k < len + a. Let Pk be ToString(k). + b. Let kValue be Get(arrayLike, Pk). + c. ReturnIfAbrupt(kValue). + d. If mapping is true, then + i. Let mappedValue be Call(mapfn, T, «kValue, k»). +flags: [onlyStrict] +---*/ + +var list = { + '0': 41, + '1': 42, + '2': 43, + length: 3 +}; +var calls = []; +function mapFn(value) { + calls.push({ + args: arguments, + thisArg: this + }); + return value * 2; +} +var result = SendableArray.from(list, mapFn); +assert.sameValue(result.length, 3, 'The value of result.length is expected to be 3'); +assert.sameValue(result[0], 82, 'The value of result[0] is expected to be 82'); +assert.sameValue(result[1], 84, 'The value of result[1] is expected to be 84'); +assert.sameValue(result[2], 86, 'The value of result[2] is expected to be 86'); +assert.sameValue(calls.length, 3, 'The value of calls.length is expected to be 3'); +assert.sameValue(calls[0].args.length, 2, 'The value of calls[0].args.length is expected to be 2'); +assert.sameValue(calls[0].args[0], 41, 'The value of calls[0].args[0] is expected to be 41'); +assert.sameValue(calls[0].args[1], 0, 'The value of calls[0].args[1] is expected to be 0'); +assert.sameValue(calls[0].thisArg, undefined, 'The value of calls[0].thisArg is expected to equal undefined'); +assert.sameValue(calls[1].args.length, 2, 'The value of calls[1].args.length is expected to be 2'); +assert.sameValue(calls[1].args[0], 42, 'The value of calls[1].args[0] is expected to be 42'); +assert.sameValue(calls[1].args[1], 1, 'The value of calls[1].args[1] is expected to be 1'); +assert.sameValue(calls[1].thisArg, undefined, 'The value of calls[1].thisArg is expected to equal undefined'); +assert.sameValue(calls[2].args.length, 2, 'The value of calls[2].args.length is expected to be 2'); +assert.sameValue(calls[2].args[0], 43, 'The value of calls[2].args[0] is expected to be 43'); +assert.sameValue(calls[2].args[1], 2, 'The value of calls[2].args[1] is expected to be 2'); +assert.sameValue(calls[2].thisArg, undefined, 'The value of calls[2].thisArg is expected to equal undefined'); diff --git a/test/sendable/builtins/Array/from/TC009.js b/test/sendable/builtins/Array/from/TC009.js new file mode 100644 index 00000000000..a31931ced1a --- /dev/null +++ b/test/sendable/builtins/Array/from/TC009.js @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Calling from with a valid map function with thisArg +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + 10. Let len be ToLength(Get(arrayLike, "length")). + 11. ReturnIfAbrupt(len). + 12. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 13. Else, + b. Let A be ArrayCreate(len). + 14. ReturnIfAbrupt(A). + 15. Let k be 0. + 16. Repeat, while k < len + a. Let Pk be ToString(k). + b. Let kValue be Get(arrayLike, Pk). + c. ReturnIfAbrupt(kValue). + d. If mapping is true, then + i. Let mappedValue be Call(mapfn, T, «kValue, k»). +---*/ + +var list = { + '0': 41, + '1': 42, + '2': 43, + length: 3 +}; +var calls = []; +var thisArg = {}; +function mapFn(value) { + calls.push({ + args: arguments, + thisArg: this + }); + return value * 2; +} +var result = SendableArray.from(list, mapFn, thisArg); +assert.sameValue(result.length, 3, 'The value of result.length is expected to be 3'); +assert.sameValue(result[0], 82, 'The value of result[0] is expected to be 82'); +assert.sameValue(result[1], 84, 'The value of result[1] is expected to be 84'); +assert.sameValue(result[2], 86, 'The value of result[2] is expected to be 86'); +assert.sameValue(calls.length, 3, 'The value of calls.length is expected to be 3'); +assert.sameValue(calls[0].args.length, 2, 'The value of calls[0].args.length is expected to be 2'); +assert.sameValue(calls[0].args[0], 41, 'The value of calls[0].args[0] is expected to be 41'); +assert.sameValue(calls[0].args[1], 0, 'The value of calls[0].args[1] is expected to be 0'); +assert.sameValue(calls[0].thisArg, thisArg, 'The value of calls[0].thisArg is expected to equal the value of thisArg'); +assert.sameValue(calls[1].args.length, 2, 'The value of calls[1].args.length is expected to be 2'); +assert.sameValue(calls[1].args[0], 42, 'The value of calls[1].args[0] is expected to be 42'); +assert.sameValue(calls[1].args[1], 1, 'The value of calls[1].args[1] is expected to be 1'); +assert.sameValue(calls[1].thisArg, thisArg, 'The value of calls[1].thisArg is expected to equal the value of thisArg'); +assert.sameValue(calls[2].args.length, 2, 'The value of calls[2].args.length is expected to be 2'); +assert.sameValue(calls[2].args[0], 43, 'The value of calls[2].args[0] is expected to be 43'); +assert.sameValue(calls[2].args[1], 2, 'The value of calls[2].args[1] is expected to be 2'); +assert.sameValue(calls[2].thisArg, thisArg, 'The value of calls[2].thisArg is expected to equal the value of thisArg'); diff --git a/test/sendable/builtins/Array/from/TC010.js b/test/sendable/builtins/Array/from/TC010.js new file mode 100644 index 00000000000..7d19cf94440 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC010.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: Elements added after the call to from +---*/ + +var arrayIndex = -1; +var originalLength = 7; +var obj = { + length: originalLength, + 0: 2, + 1: 4, + 2: 8, + 3: 16, + 4: 32, + 5: 64, + 6: 128 +}; +var array = [2, 4, 8, 16, 32, 64, 128]; +function mapFn(value, index) { + arrayIndex++; + assert.sameValue(value, obj[arrayIndex], 'The value of value is expected to equal the value of obj[arrayIndex]'); + assert.sameValue(index, arrayIndex, 'The value of index is expected to equal the value of arrayIndex'); + obj[originalLength + arrayIndex] = 2 * arrayIndex + 1; + return obj[arrayIndex]; +} +var a = SendableArray.from(obj, mapFn); +assert.sameValue(a.length, array.length, 'The value of a.length is expected to equal the value of array.length'); +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], array[j], 'The value of a[j] is expected to equal the value of array[j]'); +} diff --git a/test/sendable/builtins/Array/from/TC011.js b/test/sendable/builtins/Array/from/TC011.js new file mode 100644 index 00000000000..334b774c527 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC011.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Elements deleted after the call started and before visited are not + visited +---*/ + +var originalArray = [0, 1, -2, 4, -8, 16]; +var array = [0, 1, -2, 4, -8, 16]; +var a = []; +var arrayIndex = -1; +function mapFn(value, index) { + this.arrayIndex++; + assert.sameValue(value, array[this.arrayIndex], 'The value of value is expected to equal the value of array[this.arrayIndex]'); + assert.sameValue(index, this.arrayIndex, 'The value of index is expected to equal the value of this.arrayIndex'); + array.splice(array.length - 1, 1); + return 127; +} +a = SendableArray.from(array, mapFn, this); +assert.sameValue(a.length, originalArray.length / 2, 'The value of a.length is expected to be originalArray.length / 2'); +for (var j = 0; j < originalArray.length / 2; j++) { + assert.sameValue(a[j], 127, 'The value of a[j] is expected to be 127'); +} diff --git a/test/sendable/builtins/Array/from/TC012.js b/test/sendable/builtins/Array/from/TC012.js new file mode 100644 index 00000000000..70b48697ab9 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC012.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: Elements are updated after the call to from +---*/ + +var array = [127, 4, 8, 16, 32, 64, 128]; +var arrayIndex = -1; +function mapFn(value, index) { + arrayIndex++; + if (index + 1 < array.length) { + array[index + 1] = 127; + } + assert.sameValue(value, 127, 'The value of value is expected to be 127'); + assert.sameValue(index, arrayIndex, 'The value of index is expected to equal the value of arrayIndex'); + + return value; +} + +var a = SendableArray.from(array, mapFn); +assert.sameValue(a.length, array.length, 'The value of a.length is expected to equal the value of array.length'); +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], 127, 'The value of a[j] is expected to be 127'); +} diff --git a/test/sendable/builtins/Array/from/TC013.js b/test/sendable/builtins/Array/from/TC013.js new file mode 100644 index 00000000000..ff3b6a3dc09 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC013.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Testing SendableArray.from when passed a String +---*/ + +var arrLikeSource = 'Test'; +var result = SendableArray.from(arrLikeSource); +assert.sameValue(result.length, 4, 'The value of result.length is expected to be 4'); +assert.sameValue(result[0], 'T', 'The value of result[0] is expected to be "T"'); +assert.sameValue(result[1], 'e', 'The value of result[1] is expected to be "e"'); +assert.sameValue(result[2], 's', 'The value of result[2] is expected to be "s"'); +assert.sameValue(result[3], 't', 'The value of result[3] is expected to be "t"'); diff --git a/test/sendable/builtins/Array/from/TC014.js b/test/sendable/builtins/Array/from/TC014.js new file mode 100644 index 00000000000..cf1c74204f2 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC014.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Error accessing items' `Symbol.iterator` attribute +info: | + 4. Let usingIterator be GetMethod(items, @@iterator). + 5. ReturnIfAbrupt(usingIterator). +features: [Symbol.iterator] +---*/ + +var items = {}; +Object.defineProperty(items, Symbol.iterator, { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + SendableArray.from(items); +}, 'SendableArray.from(items) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/from/TC015.js b/test/sendable/builtins/Array/from/TC015.js new file mode 100644 index 00000000000..c1c0ee6ca8e --- /dev/null +++ b/test/sendable/builtins/Array/from/TC015.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Return empty array if items argument is an ArrayBuffer +info: | + 22.1.2.1 SendableArray.from ( items [ , mapfn [ , thisArg ] ] ) + 4. Let usingIterator be GetMethod(items, @@iterator). + 5. ReturnIfAbrupt(usingIterator). +---*/ + +var arrayBuffer = new ArrayBuffer(7); +var result = SendableArray.from(arrayBuffer); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); diff --git a/test/sendable/builtins/Array/from/TC016.js b/test/sendable/builtins/Array/from/TC016.js new file mode 100644 index 00000000000..77a302dd558 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC016.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Throws a TypeError if items argument is null +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + 4. Let usingIterator be GetMethod(items, @@iterator). + 5. ReturnIfAbrupt(usingIterator). +---*/ + +assert.throws(TypeError, function() { + SendableArray.from(null); +}, 'SendableArray.from(null) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/from/TC017.js b/test/sendable/builtins/Array/from/TC017.js new file mode 100644 index 00000000000..96e18c581b5 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC017.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Error advancing iterator +info: | + 6. If usingIterator is not undefined, then + g. Repeat + i. Let Pk be ToString(k). + ii. Let next be IteratorStep(iterator). + iii. ReturnIfAbrupt(next). +features: [Symbol.iterator] +---*/ + +var items = {}; +items[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; +assert.throws(Test262Error, function() { + SendableArray.from(items); +}, 'SendableArray.from(items) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/from/TC018.js b/test/sendable/builtins/Array/from/TC018.js new file mode 100644 index 00000000000..90e0f186e44 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC018.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Error creating object with custom constructor (traversed via iterator) +info: | + 6. If usingIterator is not undefined, then + a. If IsConstructor(C) is true, then + i. Let A be Construct(C). + b. Else, + i. Let A be ArrayCreate(0). + c. ReturnIfAbrupt(A). +features: [Symbol.iterator] +---*/ + +var C = function() { + throw new Test262Error(); +}; +var items = {}; +items[Symbol.iterator] = function() {}; +assert.throws(Test262Error, function() { + SendableArray.from.call(C, items); +}, 'SendableArray.from.call(C, items) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/from/TC019.js b/test/sendable/builtins/Array/from/TC019.js new file mode 100644 index 00000000000..414b85d5b1c --- /dev/null +++ b/test/sendable/builtins/Array/from/TC019.js @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Creating object with custom constructor (traversed via iterator) +info: | + 6. If usingIterator is not undefined, then + a. If IsConstructor(C) is true, then + i. Let A be Construct(C). + b. Else, + i. Let A be ArrayCreate(0). + c. ReturnIfAbrupt(A). +features: [Symbol.iterator] +---*/ + +var thisVal, args; +var callCount = 0; +var C = function() { + thisVal = this; + args = arguments; + callCount += 1; +}; +var result; +var items = {}; +items[Symbol.iterator] = function() { + return { + next: function() { + return { + done: true + }; + } + }; +}; +result = SendableArray.from.call(C, items); +assert( + result instanceof C, 'The result of evaluating (result instanceof C) is expected to be true' +); +assert.sameValue( + result.constructor, + C, + 'The value of result.constructor is expected to equal the value of C' +); +assert.sameValue(callCount, 1, 'The value of callCount is expected to be 1'); +assert.sameValue(thisVal, result, 'The value of thisVal is expected to equal the value of result'); +assert.sameValue(args.length, 0, 'The value of args.length is expected to be 0'); diff --git a/test/sendable/builtins/Array/from/TC020.js b/test/sendable/builtins/Array/from/TC020.js new file mode 100644 index 00000000000..ca6d7cdaac9 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC020.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Error creating iterator object +info: | + 6. If usingIterator is not undefined, then + d. Let iterator be GetIterator(items, usingIterator). + e. ReturnIfAbrupt(iterator). +features: [Symbol.iterator] +---*/ + +var itemsPoisonedSymbolIterator = {}; +itemsPoisonedSymbolIterator[Symbol.iterator] = function() { + throw new Test262Error(); +}; +assert.throws(Test262Error, function() { + SendableArray.from(itemsPoisonedSymbolIterator); +}, 'SendableArray.from(itemsPoisonedSymbolIterator) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/from/TC021.js b/test/sendable/builtins/Array/from/TC021.js new file mode 100644 index 00000000000..6a5c2d8bbed --- /dev/null +++ b/test/sendable/builtins/Array/from/TC021.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Error retrieving value of iterator result +info: | + 6. If usingIterator is not undefined, then + g. Repeat + v. Let nextValue be IteratorValue(next). + vi. ReturnIfAbrupt(nextValue). +features: [Symbol.iterator] +---*/ + +var itemsPoisonedIteratorValue = {}; +var poisonedValue = {}; +Object.defineProperty(poisonedValue, 'value', { + get: function() { + throw new Test262Error(); + } +}); +itemsPoisonedIteratorValue[Symbol.iterator] = function() { + return { + next: function() { + return poisonedValue; + } + }; +}; +assert.throws(Test262Error, function() { + SendableArray.from(itemsPoisonedIteratorValue); +}, 'SendableArray.from(itemsPoisonedIteratorValue) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/from/TC022.js b/test/sendable/builtins/Array/from/TC022.js new file mode 100644 index 00000000000..fbcfd46e184 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC022.js @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Arguments of mapping function (traversed via iterator) +info: | + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. + b. If thisArg was supplied, let T be thisArg; else let T be undefined. + c. Let mapping be true + 6. If usingIterator is not undefined, then + g. Repeat + vii. If mapping is true, then + 1. Let mappedValue be Call(mapfn, T, «nextValue, k»). + 2. If mappedValue is an abrupt completion, return + IteratorClose(iterator, mappedValue). + 3. Let mappedValue be mappedValue.[[value]]. +features: [Symbol.iterator] +---*/ + +var args = []; +var firstResult = { + done: false, + value: {} +}; +var secondResult = { + done: false, + value: {} +}; +var mapFn = function(value, idx) { + args.push(arguments); +}; +var items = {}; +var nextResult = firstResult; +var nextNextResult = secondResult; +items[Symbol.iterator] = function() { + return { + next: function() { + var result = nextResult; + nextResult = nextNextResult; + nextNextResult = { + done: true + }; + return result; + } + }; +}; +SendableArray.from(items, mapFn); +assert.sameValue(args.length, 2, 'The value of args.length is expected to be 2'); +assert.sameValue(args[0].length, 2, 'The value of args[0].length is expected to be 2'); +assert.sameValue( + args[0][0], firstResult.value, 'The value of args[0][0] is expected to equal the value of firstResult.value' +); +assert.sameValue(args[0][1], 0, 'The value of args[0][1] is expected to be 0'); +assert.sameValue(args[1].length, 2, 'The value of args[1].length is expected to be 2'); +assert.sameValue( + args[1][0], secondResult.value, 'The value of args[1][0] is expected to equal the value of secondResult.value' +); +assert.sameValue(args[1][1], 1, 'The value of args[1][1] is expected to be 1'); diff --git a/test/sendable/builtins/Array/from/TC023.js b/test/sendable/builtins/Array/from/TC023.js new file mode 100644 index 00000000000..2350d32c933 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC023.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.from +description: Error invoking map function (traversed via iterator) +info: | + 6. If usingIterator is not undefined, then + g. Repeat + vii. If mapping is true, then + 1. Let mappedValue be Call(mapfn, T, «nextValue, k»). + 2. If mappedValue is an abrupt completion, return + IteratorClose(iterator, mappedValue). +features: [Symbol.iterator] +---*/ + +var closeCount = 0; +var mapFn = function() { + throw new Test262Error(); +}; +var items = {}; +items[Symbol.iterator] = function() { + return { + return: function() { + closeCount += 1; + }, + next: function() { + return { + done: false + }; + } + }; +}; +assert.throws(Test262Error, function() { + SendableArray.from(items, mapFn); +}, 'SendableArray.from(items, mapFn) throws a Test262Error exception'); +assert.sameValue(closeCount, 1, 'The value of closeCount is expected to be 1'); diff --git a/test/sendable/builtins/Array/from/TC024.js b/test/sendable/builtins/Array/from/TC024.js new file mode 100644 index 00000000000..ae5cbbf4259 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC024.js @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Value returned by mapping function (traversed via iterator) +info: | + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. + b. If thisArg was supplied, let T be thisArg; else let T be undefined. + c. Let mapping be true + 6. If usingIterator is not undefined, then + g. Repeat + vii. If mapping is true, then + 1. Let mappedValue be Call(mapfn, T, «nextValue, k»). + 2. If mappedValue is an abrupt completion, return + IteratorClose(iterator, mappedValue). + 3. Let mappedValue be mappedValue.[[value]]. +features: [Symbol.iterator] +---*/ + +var thisVals = []; +var nextResult = { + done: false, + value: {} +}; +var nextNextResult = { + done: false, + value: {} +}; +var firstReturnVal = {}; +var secondReturnVal = {}; +var mapFn = function(value, idx) { + var returnVal = nextReturnVal; + nextReturnVal = nextNextReturnVal; + nextNextReturnVal = null; + return returnVal; +}; +var nextReturnVal = firstReturnVal; +var nextNextReturnVal = secondReturnVal; +var items = {}; +var result; +items[Symbol.iterator] = function() { + return { + next: function() { + var result = nextResult; + nextResult = nextNextResult; + nextNextResult = { + done: true + }; + return result; + } + }; +}; +result = SendableArray.from(items, mapFn); +assert.sameValue(result.length, 2, 'The value of result.length is expected to be 2'); +assert.sameValue(result[0], firstReturnVal, 'The value of result[0] is expected to equal the value of firstReturnVal'); +assert.sameValue( + result[1], + secondReturnVal, + 'The value of result[1] is expected to equal the value of secondReturnVal' +); diff --git a/test/sendable/builtins/Array/from/TC025.js b/test/sendable/builtins/Array/from/TC025.js new file mode 100644 index 00000000000..34fbee0a962 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC025.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + `this` value of mapping function with custom `this` argument (traversed via iterator) +info: | + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. + b. If thisArg was supplied, let T be thisArg; else let T be undefined. + c. Let mapping be true + 6. If usingIterator is not undefined, then + g. Repeat + vii. If mapping is true, then + 1. Let mappedValue be Call(mapfn, T, «nextValue, k»). +features: [Symbol.iterator] +---*/ + +var thisVals = []; +var nextResult = { + done: false, + value: {} +}; +var nextNextResult = { + done: false, + value: {} +}; +var mapFn = function() { + thisVals.push(this); +}; +var items = {}; +var thisVal = {}; +items[Symbol.iterator] = function() { + return { + next: function() { + var result = nextResult; + nextResult = nextNextResult; + nextNextResult = { + done: true + }; + return result; + } + }; +}; +SendableArray.from(items, mapFn, thisVal); +assert.sameValue(thisVals.length, 2, 'The value of thisVals.length is expected to be 2'); +assert.sameValue(thisVals[0], thisVal, 'The value of thisVals[0] is expected to equal the value of thisVal'); +assert.sameValue(thisVals[1], thisVal, 'The value of thisVals[1] is expected to equal the value of thisVal'); diff --git a/test/sendable/builtins/Array/from/TC026.js b/test/sendable/builtins/Array/from/TC026.js new file mode 100644 index 00000000000..2e21bef34df --- /dev/null +++ b/test/sendable/builtins/Array/from/TC026.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + `this` value of mapping function in non-strict mode (traversed via iterator) +info: | + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. + b. If thisArg was supplied, let T be thisArg; else let T be undefined. + c. Let mapping be true + 6. If usingIterator is not undefined, then + g. Repeat + vii. If mapping is true, then + 1. Let mappedValue be Call(mapfn, T, «nextValue, k»). +features: [Symbol.iterator] +flags: [noStrict] +---*/ + +var thisVals = []; +var nextResult = { + done: false, + value: {} +}; +var nextNextResult = { + done: false, + value: {} +}; +var mapFn = function() { + thisVals.push(this); +}; +var items = {}; +var global = function() { + return this; +}(); +items[Symbol.iterator] = function() { + return { + next: function() { + var result = nextResult; + nextResult = nextNextResult; + nextNextResult = { + done: true + }; + return result; + } + }; +}; +SendableArray.from(items, mapFn); +assert.sameValue(thisVals.length, 2, 'The value of thisVals.length is expected to be 2'); +assert.sameValue(thisVals[0], global, 'The value of thisVals[0] is expected to equal the value of global'); +assert.sameValue(thisVals[1], global, 'The value of thisVals[1] is expected to equal the value of global'); diff --git a/test/sendable/builtins/Array/from/TC027.js b/test/sendable/builtins/Array/from/TC027.js new file mode 100644 index 00000000000..ee6f99c4436 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC027.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + `this` value of mapping function in strict mode (traversed via iterator) +info: | + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. + b. If thisArg was supplied, let T be thisArg; else let T be undefined. + c. Let mapping be true + 6. If usingIterator is not undefined, then + g. Repeat + vii. If mapping is true, then + 1. Let mappedValue be Call(mapfn, T, «nextValue, k»). +features: [Symbol.iterator] +flags: [onlyStrict] +---*/ + +var thisVals = []; +var nextResult = { + done: false, + value: {} +}; +var nextNextResult = { + done: false, + value: {} +}; +var mapFn = function() { + thisVals.push(this); +}; +var items = {}; +items[Symbol.iterator] = function() { + return { + next: function() { + var result = nextResult; + nextResult = nextNextResult; + nextNextResult = { + done: true + }; + return result; + } + }; +}; +SendableArray.from(items, mapFn); +assert.sameValue(thisVals.length, 2, 'The value of thisVals.length is expected to be 2'); +assert.sameValue(thisVals[0], undefined, 'The value of thisVals[0] is expected to equal undefined'); +assert.sameValue(thisVals[1], undefined, 'The value of thisVals[1] is expected to equal undefined'); diff --git a/test/sendable/builtins/Array/from/TC028.js b/test/sendable/builtins/Array/from/TC028.js new file mode 100644 index 00000000000..6e2ba871335 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC028.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Error setting property on result value (traversed via iterator) +info: | + 6. If usingIterator is not undefined, then + g. Repeat + ix. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, + mappedValue). + x. If defineStatus is an abrupt completion, return + IteratorClose(iterator, defineStatus). +features: [Symbol.iterator] +---*/ + +var constructorSetsIndex0ConfigurableFalse = function() { + Object.defineProperty(this, '0', { + writable: true, + configurable: false + }); +}; +var closeCount = 0; +var items = {}; +var nextResult = { + done: false +}; +items[Symbol.iterator] = function() { + return { + return: function() { + closeCount += 1; + }, + next: function() { + var result = nextResult; + nextResult = { + done: true + }; + return result; + } + }; +}; +assert.throws(TypeError, function() { + SendableArray.from.call(constructorSetsIndex0ConfigurableFalse, items); +}, 'SendableArray.from.call(constructorSetsIndex0ConfigurableFalse, items) throws a TypeError exception'); +assert.sameValue(closeCount, 1, 'The value of closeCount is expected to be 1'); diff --git a/test/sendable/builtins/Array/from/TC029.js b/test/sendable/builtins/Array/from/TC029.js new file mode 100644 index 00000000000..ee1ff950446 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC029.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Non-writable properties are overwritten by CreateDataProperty. + (result object's "0" is non-writable, items is iterable) +info: | + SendableArray.from ( items [ , mapfn [ , thisArg ] ] ) + 5. If usingIterator is not undefined, then + e. Repeat, + viii. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, mappedValue). +features: [generators] +includes: [propertyHelper.js] +---*/ + +var items = function* () { + yield 2; +}; +var A = function(_length) { + Object.defineProperty(this, "0", { + value: 1, + writable: false, + enumerable: false, + configurable: true, + }); +}; +var res = SendableArray.from.call(A, items()); +verifyProperty(res, "0", { + value: 2, + writable: true, + enumerable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/from/TC030.js b/test/sendable/builtins/Array/from/TC030.js new file mode 100644 index 00000000000..b5e15c21930 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC030.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Setting property on result value (traversed via iterator) +info: | + 6. If usingIterator is not undefined, then + g. Repeat + ix. Let defineStatus be CreateDataPropertyOrThrow(A, Pk, + mappedValue). +features: [Symbol.iterator] +---*/ + +var items = {}; +var firstIterResult = { + done: false, + value: {} +}; +var secondIterResult = { + done: false, + value: {} +}; +var thirdIterResult = { + done: true, + value: {} +}; +var nextIterResult = firstIterResult; +var nextNextIterResult = secondIterResult; +var result; +items[Symbol.iterator] = function() { + return { + next: function() { + var result = nextIterResult; + nextIterResult = nextNextIterResult; + nextNextIterResult = thirdIterResult; + return result; + } + }; +}; +result = SendableArray.from(items); +assert.sameValue( + result[0], + firstIterResult.value, + 'The value of result[0] is expected to equal the value of firstIterResult.value' +); +assert.sameValue( + result[1], + secondIterResult.value, + 'The value of result[1] is expected to equal the value of secondIterResult.value' +); diff --git a/test/sendable/builtins/Array/from/TC031.js b/test/sendable/builtins/Array/from/TC031.js new file mode 100644 index 00000000000..8dab0a22086 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC031.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Error setting length of object (traversed via iterator) +info: | + 6. If usingIterator is not undefined, then + g. Repeat + iv. If next is false, then + 1. Let setStatus be Set(A, "length", k, true). + 2. ReturnIfAbrupt(setStatus). +features: [Symbol.iterator] +---*/ + +var poisonedPrototypeLength = function() {}; +var items = {}; +Object.defineProperty(poisonedPrototypeLength.prototype, 'length', { + set: function(_) { + throw new Test262Error(); + } +}); +items[Symbol.iterator] = function() { + return { + next: function() { + return { + done: true + }; + } + }; +}; +assert.throws(Test262Error, function() { + SendableArray.from.call(poisonedPrototypeLength, items); +}, 'SendableArray.from.call(poisonedPrototypeLength, items) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/from/TC032.js b/test/sendable/builtins/Array/from/TC032.js new file mode 100644 index 00000000000..57d22624bbb --- /dev/null +++ b/test/sendable/builtins/Array/from/TC032.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Setting length of object (traversed via iterator) +info: | + 6. If usingIterator is not undefined, then + g. Repeat + iv. If next is false, then + 1. Let setStatus be Set(A, "length", k, true). + 2. ReturnIfAbrupt(setStatus). + 3. Return A. +features: [Symbol.iterator] +---*/ + +var items = {}; +var result, nextIterResult, lastIterResult; +items[Symbol.iterator] = function() { + return { + next: function() { + var result = nextIterResult; + nextIterResult = lastIterResult; + return result; + } + }; +}; +nextIterResult = lastIterResult = { + done: true +}; +result = SendableArray.from(items); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); +nextIterResult = { + done: false +}; +lastIterResult = { + done: true +}; +result = SendableArray.from(items); +assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); diff --git a/test/sendable/builtins/Array/from/TC033.js b/test/sendable/builtins/Array/from/TC033.js new file mode 100644 index 00000000000..b81c36ea070 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC033.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Throws a TypeError if mapFn is not callable +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + SendableArray.from([], null); +}, 'SendableArray.from([], null) throws a TypeError exception'); +assert.throws(TypeError, function() { + SendableArray.from([], {}); +}, 'SendableArray.from([], {}) throws a TypeError exception'); +assert.throws(TypeError, function() { + SendableArray.from([], 'string'); +}, 'SendableArray.from([], "string") throws a TypeError exception'); +assert.throws(TypeError, function() { + SendableArray.from([], true); +}, 'ArSendableArrayray.from([], true) throws a TypeError exception'); +assert.throws(TypeError, function() { + SendableArray.from([], 42); +}, 'SendableArray.from([], 42) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/from/TC034.js b/test/sendable/builtins/Array/from/TC034.js new file mode 100644 index 00000000000..eacadee799b --- /dev/null +++ b/test/sendable/builtins/Array/from/TC034.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Throws a TypeError if mapFn is not callable (Symbol) +info: | + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + 2. If mapfn is undefined, let mapping be false. + 3. else + a. If IsCallable(mapfn) is false, throw a TypeError exception. +features: + - Symbol +---*/ + +assert.throws(TypeError, function() { + SendableArray.from([], Symbol('1')); +}, 'SendableArray.from([], Symbol("1")) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/from/TC035.js b/test/sendable/builtins/Array/from/TC035.js new file mode 100644 index 00000000000..6313eb56c55 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC035.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: mapFn throws an exception +---*/ + +var array = [2, 4, 8, 16, 32, 64, 128]; +function mapFnThrows(value, index, obj) { + throw new Test262Error(); +} +assert.throws(Test262Error, function() { + SendableArray.from(array, mapFnThrows); +}, 'SendableArray.from(array, mapFnThrows) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/from/TC036.js b/test/sendable/builtins/Array/from/TC036.js new file mode 100644 index 00000000000..a1f8896286d --- /dev/null +++ b/test/sendable/builtins/Array/from/TC036.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.from 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(Array.from), false, 'isConstructor(Array.from) must return false'); +assert.throws(TypeError, () => { + new SendableArray.from([]); +}, 'new SendableArray.from([]) throws a TypeError exception'); + diff --git a/test/sendable/builtins/Array/from/TC037.js b/test/sendable/builtins/Array/from/TC037.js new file mode 100644 index 00000000000..76d8943b350 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC037.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Default [[Prototype]] value derived from realm of the constructor +info: | + 5. If usingIterator is not undefined, then + a. If IsConstructor(C) is true, then + i. Let A be ? Construct(C). + 9.1.14 GetPrototypeFromConstructor + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. +features: [cross-realm] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; +var a = SendableArray.from.call(C, []); +assert.sameValue( + Object.getPrototypeOf(a), + other.Object.prototype, + 'Object.getPrototypeOf(Array.from.call(C, [])) returns other.Object.prototype' +); diff --git a/test/sendable/builtins/Array/from/TC038.js b/test/sendable/builtins/Array/from/TC038.js new file mode 100644 index 00000000000..724fda39d2b --- /dev/null +++ b/test/sendable/builtins/Array/from/TC038.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Source array with boundary values +---*/ + +var array = [Number.MAX_VALUE, Number.MIN_VALUE, Number.NaN, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY]; +var arrayIndex = -1; +function mapFn(value, index) { + this.arrayIndex++; + assert.sameValue(value, array[this.arrayIndex], 'The value of value is expected to equal the value of array[this.arrayIndex]'); + assert.sameValue(index, this.arrayIndex, 'The value of index is expected to equal the value of this.arrayIndex'); + return value; +} +var a = SendableArray.from(array, mapFn, this); +assert.sameValue(a.length, array.length, 'The value of a.length is expected to equal the value of array.length'); +assert.sameValue(a[0], Number.MAX_VALUE, 'The value of a[0] is expected to equal the value of Number.MAX_VALUE'); +assert.sameValue(a[1], Number.MIN_VALUE, 'The value of a[1] is expected to equal the value of Number.MIN_VALUE'); +assert.sameValue(a[2], Number.NaN, 'The value of a[2] is expected to equal the value of Number.NaN'); +assert.sameValue(a[3], Number.NEGATIVE_INFINITY, 'The value of a[3] is expected to equal the value of Number.NEGATIVE_INFINITY'); +assert.sameValue(a[4], Number.POSITIVE_INFINITY, 'The value of a[4] is expected to equal the value of Number.POSITIVE_INFINITY'); diff --git a/test/sendable/builtins/Array/from/TC039.js b/test/sendable/builtins/Array/from/TC039.js new file mode 100644 index 00000000000..4ca6d779ec5 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC039.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Array.from uses a constructor other than Array. +---*/ + +assert.sameValue( + SendableArray.from.call(Object, []).constructor, + Object, + 'The value of Array.from.call(Object, []).constructor is expected to equal the value of Object' +); diff --git a/test/sendable/builtins/Array/from/TC040.js b/test/sendable/builtins/Array/from/TC040.js new file mode 100644 index 00000000000..fd12bc2d3c7 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC040.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Source object has iterator which throws +features: [Symbol.iterator] +---*/ + +var array = [2, 4, 8, 16, 32, 64, 128]; +var obj = { + [Symbol.iterator]() { + return { + index: 0, + next() { + throw new Test262Error(); + }, + isDone: false, + get val() { + this.index++; + if (this.index > 7) { + this.isDone = true; + } + return 1 << this.index; + } + }; + } +}; +assert.throws(Test262Error, function() { + SendableArray.from(obj); +}, 'SendableArray.from(obj) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/from/TC041.js b/test/sendable/builtins/Array/from/TC041.js new file mode 100644 index 00000000000..b6103a32f82 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC041.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Source object has iterator +features: [Symbol.iterator] +---*/ + +var array = [2, 4, 8, 16, 32, 64, 128]; +var obj = { + [Symbol.iterator]() { + return { + index: 0, + next() { + return { + value: this.val, + done: this.isDone + }; + }, + isDone: false, + get val() { + this.index++; + if (this.index > 7) { + this.isDone = true; + } + return 1 << this.index; + } + }; + } +}; +var a = SendableArray.from.call(Object, obj); +assert.sameValue(typeof a, typeof {}, 'The value of `typeof a` is expected to be typeof {}'); +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], array[j], 'The value of a[j] is expected to equal the value of array[j]'); +} diff --git a/test/sendable/builtins/Array/from/TC042.js b/test/sendable/builtins/Array/from/TC042.js new file mode 100644 index 00000000000..8eb9e1087ac --- /dev/null +++ b/test/sendable/builtins/Array/from/TC042.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + TypeError is thrown if CreateDataProperty fails. + (items is not iterable) +info: | + SendableArray.from ( items [ , mapfn [ , thisArg ] ] ) + 4. Let usingIterator be ? GetMethod(items, @@iterator). + 5. If usingIterator is not undefined, then + 6. NOTE: items is not an Iterable so assume it is an array-like object. + 12. Repeat, while k < len + e. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue). + CreateDataPropertyOrThrow ( O, P, V ) + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +---*/ + +var items = { + length: 1, +}; +var A1 = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; +assert.throws(TypeError, function() { + SendableArray.from.call(A1, items); +}, 'SendableArray.from.call(A1, items) throws a TypeError exception'); +var A2 = function(_length) { + Object.defineProperty(this, "0", { + writable: true, + configurable: false, + }); +}; +assert.throws(TypeError, function() { + SendableArray.from.call(A2, items); +}, 'SendableArray.from.call(A2, items) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/from/TC043.js b/test/sendable/builtins/Array/from/TC043.js new file mode 100644 index 00000000000..83669f27c70 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC043.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.from +description: > + Non-writable properties are overwritten by CreateDataProperty. + (result object's "0" is non-writable, items is not iterable) +info: | + SendableArray.from ( items [ , mapfn [ , thisArg ] ] ) + 4. Let usingIterator be ? GetMethod(items, @@iterator). + 5. If usingIterator is not undefined, then + 6. NOTE: items is not an Iterable so assume it is an array-like object. + 12. Repeat, while k < len + e. Perform ? CreateDataPropertyOrThrow(A, Pk, mappedValue). +includes: [propertyHelper.js] +---*/ + +var items = { + "0": 2, + length: 1, +}; +var A = function(_length) { + Object.defineProperty(this, "0", { + value: 1, + writable: false, + enumerable: false, + configurable: true, + }); +}; +var res = SendableArray.from.call(A, items); +verifyProperty(res, "0", { + value: 2, + writable: true, + enumerable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/from/TC044.js b/test/sendable/builtins/Array/from/TC044.js new file mode 100644 index 00000000000..ec3f85f4f38 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC044.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Source is an object with length property and one item is deleted + from the source +---*/ + +var array = [2, 4, 0, 16]; +var expectedArray = [2, 4, , 16]; +var obj = { + length: 4, + 0: 2, + 1: 4, + 2: 0, + 3: 16 +}; +delete obj[2]; +var a = SendableArray.from(obj); +for (var j = 0; j < expectedArray.length; j++) { + assert.sameValue(a[j], expectedArray[j], 'The value of a[j] is expected to equal the value of expectedArray[j]'); +} diff --git a/test/sendable/builtins/Array/from/TC045.js b/test/sendable/builtins/Array/from/TC045.js new file mode 100644 index 00000000000..5895e5af97c --- /dev/null +++ b/test/sendable/builtins/Array/from/TC045.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Source is an object with missing values +---*/ +var array = [2, 4, , 16]; +var obj = { + length: 4, + 0: 2, + 1: 4, + 3: 16 +}; +var a = SendableArray.from.call(Object, obj); +assert.sameValue(typeof a, "object", 'The value of `typeof a` is expected to be "object"'); +for (var j = 0; j < a.length; j++) { + assert.sameValue(a[j], array[j], 'The value of a[j] is expected to equal the value of array[j]'); +} diff --git a/test/sendable/builtins/Array/from/TC046.js b/test/sendable/builtins/Array/from/TC046.js new file mode 100644 index 00000000000..e1a656d36d6 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC046.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Source is an object without length property +---*/ +var obj = { + 0: 2, + 1: 4, + 2: 8, + 3: 16 +} +var a = SendableArray.from(obj); +assert.sameValue(a.length, 0, 'The value of a.length is expected to be 0'); diff --git a/test/sendable/builtins/Array/from/TC047.js b/test/sendable/builtins/Array/from/TC047.js new file mode 100644 index 00000000000..59f1f964428 --- /dev/null +++ b/test/sendable/builtins/Array/from/TC047.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Does not throw if this is null +---*/ + +var result = SendableArray.from.call(null, []); +assert(result instanceof SendableArray, 'The result of evaluating (result instanceof SendableArray) is expected to be true'); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); diff --git a/test262/data/package.json b/test262/data/package.json new file mode 100644 index 00000000000..faa769dd7c7 --- /dev/null +++ b/test262/data/package.json @@ -0,0 +1,31 @@ +{ + "name": "test262", + "version": "5.0.0", + "description": "Test262 tests conformance to the continually maintained draft future ECMAScript standard found at http://tc39.github.io/ecma262/ , together with any Stage 3 or later TC39 proposals.", + "repository": { + "type": "git", + "url": "git+https://github.com/tc39/test262.git" + }, + "license": "BSD", + "bugs": { + "url": "https://github.com/tc39/test262/issues" + }, + "private": true, + "homepage": "https://github.com/tc39/test262#readme", + "devDependencies": { + "esvu": "^1.2.11", + "test262-harness": "^8.0.0" + }, + "scripts": { + "ci": "./tools/scripts/ci_test.sh", + "test": "test262-harness", + "diff": "git diff --diff-filter ACMR --name-only main.. -- test/ && git ls-files --exclude-standard --others -- test/", + "test:diff": "npm run test:diff:v8 && npm run test:diff:spidermonkey && npm run test:diff:chakra && npm run test:diff:javascriptcore", + "test:diff:v8": "test262-harness -t 8 --hostType=d8 --hostPath=v8 $(npm run --silent diff)", + "test:diff:spidermonkey": "test262-harness -t 8 --hostType=jsshell --hostPath=spidermonkey $(npm run --silent diff)", + "test:diff:chakra": "test262-harness -t 8 --hostType=ch --hostPath=chakra $(npm run --silent diff)", + "test:diff:javascriptcore": "test262-harness -t 8 --hostType=jsc --hostPath=javascriptcore $(npm run --silent diff)", + "test:diff:xs": "test262-harness -t 8 --hostType=xs --hostPath=xs $(npm run --silent diff)" + } +} + -- Gitee From e74a75ccfc3186e85ff9d3a109b04cce21bff629 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 13 Dec 2024 10:01:36 +0800 Subject: [PATCH 04/93] add test log for tc003 Signed-off-by: zhuzhihui7 --- test/sendable/builtins/Array/from/TC003.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/sendable/builtins/Array/from/TC003.js b/test/sendable/builtins/Array/from/TC003.js index 801b9875a4b..f0f5014db7d 100644 --- a/test/sendable/builtins/Array/from/TC003.js +++ b/test/sendable/builtins/Array/from/TC003.js @@ -21,6 +21,9 @@ info: | includes: [propertyHelper.js] ---*/ +result= Object.getOwnPropertyDescriptor(SendableArray.from, "length") +print (result) + verifyProperty(SendableArray.from, "length", { value: 1, writable: false, -- Gitee From efaf3b7b1e0601ceb5ea912d723f2e441f4226e2 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 13 Dec 2024 10:14:23 +0800 Subject: [PATCH 05/93] add tc003 add var Signed-off-by: zhuzhihui7 --- test/sendable/builtins/Array/from/TC003.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sendable/builtins/Array/from/TC003.js b/test/sendable/builtins/Array/from/TC003.js index f0f5014db7d..1bff7be0648 100644 --- a/test/sendable/builtins/Array/from/TC003.js +++ b/test/sendable/builtins/Array/from/TC003.js @@ -21,7 +21,7 @@ info: | includes: [propertyHelper.js] ---*/ -result= Object.getOwnPropertyDescriptor(SendableArray.from, "length") +var result= Object.getOwnPropertyDescriptor(SendableArray.from, "length") print (result) verifyProperty(SendableArray.from, "length", { -- Gitee From c18ca2aa3c403124c1e3cdfcfe3a556378f030da Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 13 Dec 2024 10:32:28 +0800 Subject: [PATCH 06/93] add console log fot tc03 Signed-off-by: zhuzhihui7 --- test/sendable/builtins/Array/from/TC003.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sendable/builtins/Array/from/TC003.js b/test/sendable/builtins/Array/from/TC003.js index 1bff7be0648..8188f4e5f8a 100644 --- a/test/sendable/builtins/Array/from/TC003.js +++ b/test/sendable/builtins/Array/from/TC003.js @@ -22,7 +22,7 @@ includes: [propertyHelper.js] ---*/ var result= Object.getOwnPropertyDescriptor(SendableArray.from, "length") -print (result) +console.log(result) verifyProperty(SendableArray.from, "length", { value: 1, -- Gitee From addbed981a2cfc6360f8b2867070fc015cdca0a9 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 13 Dec 2024 15:05:28 +0800 Subject: [PATCH 07/93] add new cases and rename Signed-off-by: zhuzhihui7 --- .../{TC004.js => Array.from-descriptor.js} | 1 + .../from/{TC005.js => Array.from-name.js} | 1 + .../from/{TC003.js => Array.from_arity.js} | 4 +-- ...y.from_forwards-length-for-array-likes.js} | 1 + test/sendable/builtins/Array/from/TC001.js | 30 ------------------- ...-has-length-but-no-indexes-with-values.js} | 1 + ...07.js => calling-from-valid-1-noStrict.js} | 1 + ....js => calling-from-valid-1-onlyStrict.js} | 1 + .../{TC009.js => calling-from-valid-2.js} | 1 + .../{TC010.js => elements-added-after.js} | 4 ++- .../{TC011.js => elements-deleted-after.js} | 3 +- .../{TC012.js => elements-updated-after.js} | 4 +-- .../builtins/Array/from/from-array.js | 4 --- .../Array/from/{TC013.js => from-string.js} | 1 + .../from/{TC014.js => get-iter-method-err.js} | 1 + .../{TC015.js => items-is-arraybuffer.js} | 3 +- .../{TC016.js => items-is-null-throws.js} | 1 + .../Array/from/{TC017.js => iter-adv-err.js} | 1 + .../from/{TC018.js => iter-cstm-ctor-err.js} | 1 + .../from/{TC019.js => iter-cstm-ctor.js} | 1 + .../from/{TC020.js => iter-get-iter-err.js} | 1 + .../{TC021.js => iter-get-iter-val-err.js} | 1 + .../from/{TC022.js => iter-map-fn-args.js} | 2 ++ .../from/{TC023.js => iter-map-fn-err.js} | 0 .../from/{TC024.js => iter-map-fn-return.js} | 2 ++ .../{TC025.js => iter-map-fn-this-arg.js} | 1 + ...C026.js => iter-map-fn-this-non-strict.js} | 1 + .../{TC027.js => iter-map-fn-this-strict.js} | 1 + .../{TC028.js => iter-set-elem-prop-err.js} | 1 + ....js => iter-set-elem-prop-non-writable.js} | 1 + .../from/{TC030.js => iter-set-elem-prop.js} | 3 ++ .../from/{TC031.js => iter-set-length-err.js} | 1 + .../from/{TC032.js => iter-set-length.js} | 1 + ....js => mapfn-is-not-callable-typeerror.js} | 5 ++-- .../{TC034.js => mapfn-is-symbol-throws.js} | 3 +- .../{TC035.js => mapfn-throws-exception.js} | 3 +- .../from/{TC036.js => not-a-constructor.js} | 0 .../{TC037.js => proto-from-ctor-realm.js} | 4 ++- .../{TC038.js => source-array-boundary.js} | 2 ++ ...{TC039.js => source-object-constructor.js} | 4 ++- .../{TC040.js => source-object-iterator-1.js} | 2 ++ .../{TC041.js => source-object-iterator-2.js} | 2 ++ ...source-object-length-set-elem-prop-err.js} | 1 + ...ject-length-set-elem-prop-non-writable.js} | 2 +- .../{TC044.js => source-object-length.js} | 2 ++ .../{TC045.js => source-object-missing.js} | 3 ++ .../{TC046.js => source-object-without.js} | 4 +++ .../Array/from/{TC047.js => this-null.js} | 2 ++ 48 files changed, 70 insertions(+), 50 deletions(-) rename test/sendable/builtins/Array/from/{TC004.js => Array.from-descriptor.js} (97%) rename test/sendable/builtins/Array/from/{TC005.js => Array.from-name.js} (98%) rename test/sendable/builtins/Array/from/{TC003.js => Array.from_arity.js} (91%) rename test/sendable/builtins/Array/from/{TC006.js => Array.from_forwards-length-for-array-likes.js} (98%) delete mode 100644 test/sendable/builtins/Array/from/TC001.js rename test/sendable/builtins/Array/from/{TC002.js => array-like-has-length-but-no-indexes-with-values.js} (98%) rename test/sendable/builtins/Array/from/{TC007.js => calling-from-valid-1-noStrict.js} (99%) rename test/sendable/builtins/Array/from/{TC008.js => calling-from-valid-1-onlyStrict.js} (99%) rename test/sendable/builtins/Array/from/{TC009.js => calling-from-valid-2.js} (99%) rename test/sendable/builtins/Array/from/{TC010.js => elements-added-after.js} (98%) rename test/sendable/builtins/Array/from/{TC011.js => elements-deleted-after.js} (98%) rename test/sendable/builtins/Array/from/{TC012.js => elements-updated-after.js} (98%) rename test/sendable/builtins/Array/from/{TC013.js => from-string.js} (98%) rename test/sendable/builtins/Array/from/{TC014.js => get-iter-method-err.js} (98%) rename test/sendable/builtins/Array/from/{TC015.js => items-is-arraybuffer.js} (92%) rename test/sendable/builtins/Array/from/{TC016.js => items-is-null-throws.js} (97%) rename test/sendable/builtins/Array/from/{TC017.js => iter-adv-err.js} (98%) rename test/sendable/builtins/Array/from/{TC018.js => iter-cstm-ctor-err.js} (98%) rename test/sendable/builtins/Array/from/{TC019.js => iter-cstm-ctor.js} (98%) rename test/sendable/builtins/Array/from/{TC020.js => iter-get-iter-err.js} (98%) rename test/sendable/builtins/Array/from/{TC021.js => iter-get-iter-val-err.js} (98%) rename test/sendable/builtins/Array/from/{TC022.js => iter-map-fn-args.js} (99%) rename test/sendable/builtins/Array/from/{TC023.js => iter-map-fn-err.js} (100%) rename test/sendable/builtins/Array/from/{TC024.js => iter-map-fn-return.js} (99%) rename test/sendable/builtins/Array/from/{TC025.js => iter-map-fn-this-arg.js} (98%) rename test/sendable/builtins/Array/from/{TC026.js => iter-map-fn-this-non-strict.js} (98%) rename test/sendable/builtins/Array/from/{TC027.js => iter-map-fn-this-strict.js} (98%) rename test/sendable/builtins/Array/from/{TC028.js => iter-set-elem-prop-err.js} (98%) rename test/sendable/builtins/Array/from/{TC029.js => iter-set-elem-prop-non-writable.js} (98%) rename test/sendable/builtins/Array/from/{TC030.js => iter-set-elem-prop.js} (98%) rename test/sendable/builtins/Array/from/{TC031.js => iter-set-length-err.js} (98%) rename test/sendable/builtins/Array/from/{TC032.js => iter-set-length.js} (98%) rename test/sendable/builtins/Array/from/{TC033.js => mapfn-is-not-callable-typeerror.js} (90%) rename test/sendable/builtins/Array/from/{TC034.js => mapfn-is-symbol-throws.js} (91%) rename test/sendable/builtins/Array/from/{TC035.js => mapfn-throws-exception.js} (95%) rename test/sendable/builtins/Array/from/{TC036.js => not-a-constructor.js} (100%) rename test/sendable/builtins/Array/from/{TC037.js => proto-from-ctor-realm.js} (91%) rename test/sendable/builtins/Array/from/{TC038.js => source-array-boundary.js} (97%) rename test/sendable/builtins/Array/from/{TC039.js => source-object-constructor.js} (88%) rename test/sendable/builtins/Array/from/{TC040.js => source-object-iterator-1.js} (96%) rename test/sendable/builtins/Array/from/{TC041.js => source-object-iterator-2.js} (96%) rename test/sendable/builtins/Array/from/{TC042.js => source-object-length-set-elem-prop-err.js} (98%) rename test/sendable/builtins/Array/from/{TC043.js => source-object-length-set-elem-prop-non-writable.js} (98%) rename test/sendable/builtins/Array/from/{TC044.js => source-object-length.js} (96%) rename test/sendable/builtins/Array/from/{TC045.js => source-object-missing.js} (95%) rename test/sendable/builtins/Array/from/{TC046.js => source-object-without.js} (94%) rename test/sendable/builtins/Array/from/{TC047.js => this-null.js} (95%) diff --git a/test/sendable/builtins/Array/from/TC004.js b/test/sendable/builtins/Array/from/Array.from-descriptor.js similarity index 97% rename from test/sendable/builtins/Array/from/TC004.js rename to test/sendable/builtins/Array/from/Array.from-descriptor.js index de974879a84..ac278823ce8 100644 --- a/test/sendable/builtins/Array/from/TC004.js +++ b/test/sendable/builtins/Array/from/Array.from-descriptor.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Testing descriptor property of Array.from includes: [propertyHelper.js] ---*/ diff --git a/test/sendable/builtins/Array/from/TC005.js b/test/sendable/builtins/Array/from/Array.from-name.js similarity index 98% rename from test/sendable/builtins/Array/from/TC005.js rename to test/sendable/builtins/Array/from/Array.from-name.js index 24a46782617..b1625beb4fd 100644 --- a/test/sendable/builtins/Array/from/TC005.js +++ b/test/sendable/builtins/Array/from/Array.from-name.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: '`name` property' info: | ES6 Section 17: diff --git a/test/sendable/builtins/Array/from/TC003.js b/test/sendable/builtins/Array/from/Array.from_arity.js similarity index 91% rename from test/sendable/builtins/Array/from/TC003.js rename to test/sendable/builtins/Array/from/Array.from_arity.js index 8188f4e5f8a..5fcfb835bab 100644 --- a/test/sendable/builtins/Array/from/TC003.js +++ b/test/sendable/builtins/Array/from/Array.from_arity.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: > The length property of the Array.from method is 1. info: | @@ -21,9 +22,6 @@ info: | includes: [propertyHelper.js] ---*/ -var result= Object.getOwnPropertyDescriptor(SendableArray.from, "length") -console.log(result) - verifyProperty(SendableArray.from, "length", { value: 1, writable: false, diff --git a/test/sendable/builtins/Array/from/TC006.js b/test/sendable/builtins/Array/from/Array.from_forwards-length-for-array-likes.js similarity index 98% rename from test/sendable/builtins/Array/from/TC006.js rename to test/sendable/builtins/Array/from/Array.from_forwards-length-for-array-likes.js index a8b9e819e70..221e0355779 100644 --- a/test/sendable/builtins/Array/from/TC006.js +++ b/test/sendable/builtins/Array/from/Array.from_forwards-length-for-array-likes.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: > If this is a constructor, and items doesn't have an @@iterator, returns a new instance of this diff --git a/test/sendable/builtins/Array/from/TC001.js b/test/sendable/builtins/Array/from/TC001.js deleted file mode 100644 index aa619a7248e..00000000000 --- a/test/sendable/builtins/Array/from/TC001.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*--- -description: Passing a valid array ----*/ - -var array = [0, 'foo', , Infinity]; -var result = SendableArray.from(array); -assert.sameValue(result.length, 4, 'The value of result.length is expected to be 4'); -assert.sameValue(result[0], 0, 'The value of result[0] is expected to be 0'); -assert.sameValue(result[1], 'foo', 'The value of result[1] is expected to be "foo"'); -assert.sameValue(result[2], undefined, 'The value of result[2] is expected to equal undefined'); -assert.sameValue(result[3], Infinity, 'The value of result[3] is expected to equal Infinity'); -assert.notSameValue( - result, array, - 'The value of result is expected to not equal the value of `array`' -); -assert(result instanceof SendableArray, 'The result of evaluating (result instanceof SendableArray) is expected to be true'); diff --git a/test/sendable/builtins/Array/from/TC002.js b/test/sendable/builtins/Array/from/array-like-has-length-but-no-indexes-with-values.js similarity index 98% rename from test/sendable/builtins/Array/from/TC002.js rename to test/sendable/builtins/Array/from/array-like-has-length-but-no-indexes-with-values.js index ce3661c59be..c577424b14f 100644 --- a/test/sendable/builtins/Array/from/TC002.js +++ b/test/sendable/builtins/Array/from/array-like-has-length-but-no-indexes-with-values.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: > Creates an array with length that is equal to the value of the length property of the given array-like, regardless of diff --git a/test/sendable/builtins/Array/from/TC007.js b/test/sendable/builtins/Array/from/calling-from-valid-1-noStrict.js similarity index 99% rename from test/sendable/builtins/Array/from/TC007.js rename to test/sendable/builtins/Array/from/calling-from-valid-1-noStrict.js index d3eb3ee9c1c..cc4cce1c825 100644 --- a/test/sendable/builtins/Array/from/TC007.js +++ b/test/sendable/builtins/Array/from/calling-from-valid-1-noStrict.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Map function without thisArg on non strict mode info: | 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) diff --git a/test/sendable/builtins/Array/from/TC008.js b/test/sendable/builtins/Array/from/calling-from-valid-1-onlyStrict.js similarity index 99% rename from test/sendable/builtins/Array/from/TC008.js rename to test/sendable/builtins/Array/from/calling-from-valid-1-onlyStrict.js index 084464978f4..6aef93e63c2 100644 --- a/test/sendable/builtins/Array/from/TC008.js +++ b/test/sendable/builtins/Array/from/calling-from-valid-1-onlyStrict.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Map function without thisArg on strict mode info: | 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) diff --git a/test/sendable/builtins/Array/from/TC009.js b/test/sendable/builtins/Array/from/calling-from-valid-2.js similarity index 99% rename from test/sendable/builtins/Array/from/TC009.js rename to test/sendable/builtins/Array/from/calling-from-valid-2.js index a31931ced1a..311e2c1e48e 100644 --- a/test/sendable/builtins/Array/from/TC009.js +++ b/test/sendable/builtins/Array/from/calling-from-valid-2.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Calling from with a valid map function with thisArg info: | 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) diff --git a/test/sendable/builtins/Array/from/TC010.js b/test/sendable/builtins/Array/from/elements-added-after.js similarity index 98% rename from test/sendable/builtins/Array/from/TC010.js rename to test/sendable/builtins/Array/from/elements-added-after.js index 7d19cf94440..e06893631f3 100644 --- a/test/sendable/builtins/Array/from/TC010.js +++ b/test/sendable/builtins/Array/from/elements-added-after.js @@ -12,9 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - /*--- description: Elements added after the call to from +esid: sec-array.from ---*/ var arrayIndex = -1; @@ -35,10 +35,12 @@ function mapFn(value, index) { assert.sameValue(value, obj[arrayIndex], 'The value of value is expected to equal the value of obj[arrayIndex]'); assert.sameValue(index, arrayIndex, 'The value of index is expected to equal the value of arrayIndex'); obj[originalLength + arrayIndex] = 2 * arrayIndex + 1; + return obj[arrayIndex]; } var a = SendableArray.from(obj, mapFn); assert.sameValue(a.length, array.length, 'The value of a.length is expected to equal the value of array.length'); + for (var j = 0; j < a.length; j++) { assert.sameValue(a[j], array[j], 'The value of a[j] is expected to equal the value of array[j]'); } diff --git a/test/sendable/builtins/Array/from/TC011.js b/test/sendable/builtins/Array/from/elements-deleted-after.js similarity index 98% rename from test/sendable/builtins/Array/from/TC011.js rename to test/sendable/builtins/Array/from/elements-deleted-after.js index 334b774c527..11cc8986ad1 100644 --- a/test/sendable/builtins/Array/from/TC011.js +++ b/test/sendable/builtins/Array/from/elements-deleted-after.js @@ -12,11 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - /*--- description: > Elements deleted after the call started and before visited are not visited +esid: sec-array.from ---*/ var originalArray = [0, 1, -2, 4, -8, 16]; @@ -30,6 +30,7 @@ function mapFn(value, index) { array.splice(array.length - 1, 1); return 127; } + a = SendableArray.from(array, mapFn, this); assert.sameValue(a.length, originalArray.length / 2, 'The value of a.length is expected to be originalArray.length / 2'); for (var j = 0; j < originalArray.length / 2; j++) { diff --git a/test/sendable/builtins/Array/from/TC012.js b/test/sendable/builtins/Array/from/elements-updated-after.js similarity index 98% rename from test/sendable/builtins/Array/from/TC012.js rename to test/sendable/builtins/Array/from/elements-updated-after.js index 70b48697ab9..1158964a699 100644 --- a/test/sendable/builtins/Array/from/TC012.js +++ b/test/sendable/builtins/Array/from/elements-updated-after.js @@ -12,9 +12,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - /*--- description: Elements are updated after the call to from +esid: sec-array.from ---*/ var array = [127, 4, 8, 16, 32, 64, 128]; @@ -26,10 +26,8 @@ function mapFn(value, index) { } assert.sameValue(value, 127, 'The value of value is expected to be 127'); assert.sameValue(index, arrayIndex, 'The value of index is expected to equal the value of arrayIndex'); - return value; } - var a = SendableArray.from(array, mapFn); assert.sameValue(a.length, array.length, 'The value of a.length is expected to equal the value of array.length'); for (var j = 0; j < a.length; j++) { diff --git a/test/sendable/builtins/Array/from/from-array.js b/test/sendable/builtins/Array/from/from-array.js index cf92a3b2a7b..48aba44189a 100644 --- a/test/sendable/builtins/Array/from/from-array.js +++ b/test/sendable/builtins/Array/from/from-array.js @@ -12,7 +12,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - /*--- description: Passing a valid array esid: sec-array.from @@ -20,16 +19,13 @@ esid: sec-array.from var array = [0, 'foo', , Infinity]; var result = SendableArray.from(array); - assert.sameValue(result.length, 4, 'The value of result.length is expected to be 4'); assert.sameValue(result[0], 0, 'The value of result[0] is expected to be 0'); assert.sameValue(result[1], 'foo', 'The value of result[1] is expected to be "foo"'); assert.sameValue(result[2], undefined, 'The value of result[2] is expected to equal undefined'); assert.sameValue(result[3], Infinity, 'The value of result[3] is expected to equal Infinity'); - assert.notSameValue( result, array, 'The value of result is expected to not equal the value of `array`' ); - assert(result instanceof SendableArray, 'The result of evaluating (result instanceof Array) is expected to be true'); diff --git a/test/sendable/builtins/Array/from/TC013.js b/test/sendable/builtins/Array/from/from-string.js similarity index 98% rename from test/sendable/builtins/Array/from/TC013.js rename to test/sendable/builtins/Array/from/from-string.js index ff3b6a3dc09..a5f42038520 100644 --- a/test/sendable/builtins/Array/from/TC013.js +++ b/test/sendable/builtins/Array/from/from-string.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Testing SendableArray.from when passed a String ---*/ diff --git a/test/sendable/builtins/Array/from/TC014.js b/test/sendable/builtins/Array/from/get-iter-method-err.js similarity index 98% rename from test/sendable/builtins/Array/from/TC014.js rename to test/sendable/builtins/Array/from/get-iter-method-err.js index cf1c74204f2..a71742f1caa 100644 --- a/test/sendable/builtins/Array/from/TC014.js +++ b/test/sendable/builtins/Array/from/get-iter-method-err.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Error accessing items' `Symbol.iterator` attribute info: | 4. Let usingIterator be GetMethod(items, @@iterator). diff --git a/test/sendable/builtins/Array/from/TC015.js b/test/sendable/builtins/Array/from/items-is-arraybuffer.js similarity index 92% rename from test/sendable/builtins/Array/from/TC015.js rename to test/sendable/builtins/Array/from/items-is-arraybuffer.js index c1c0ee6ca8e..3b12add8a8e 100644 --- a/test/sendable/builtins/Array/from/TC015.js +++ b/test/sendable/builtins/Array/from/items-is-arraybuffer.js @@ -13,9 +13,10 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Return empty array if items argument is an ArrayBuffer info: | - 22.1.2.1 SendableArray.from ( items [ , mapfn [ , thisArg ] ] ) + 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) 4. Let usingIterator be GetMethod(items, @@iterator). 5. ReturnIfAbrupt(usingIterator). ---*/ diff --git a/test/sendable/builtins/Array/from/TC016.js b/test/sendable/builtins/Array/from/items-is-null-throws.js similarity index 97% rename from test/sendable/builtins/Array/from/TC016.js rename to test/sendable/builtins/Array/from/items-is-null-throws.js index 77a302dd558..df7c0b127cf 100644 --- a/test/sendable/builtins/Array/from/TC016.js +++ b/test/sendable/builtins/Array/from/items-is-null-throws.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Throws a TypeError if items argument is null info: | 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) diff --git a/test/sendable/builtins/Array/from/TC017.js b/test/sendable/builtins/Array/from/iter-adv-err.js similarity index 98% rename from test/sendable/builtins/Array/from/TC017.js rename to test/sendable/builtins/Array/from/iter-adv-err.js index 96e18c581b5..eef63c553da 100644 --- a/test/sendable/builtins/Array/from/TC017.js +++ b/test/sendable/builtins/Array/from/iter-adv-err.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Error advancing iterator info: | 6. If usingIterator is not undefined, then diff --git a/test/sendable/builtins/Array/from/TC018.js b/test/sendable/builtins/Array/from/iter-cstm-ctor-err.js similarity index 98% rename from test/sendable/builtins/Array/from/TC018.js rename to test/sendable/builtins/Array/from/iter-cstm-ctor-err.js index 90e0f186e44..518b5bd192d 100644 --- a/test/sendable/builtins/Array/from/TC018.js +++ b/test/sendable/builtins/Array/from/iter-cstm-ctor-err.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: > Error creating object with custom constructor (traversed via iterator) info: | diff --git a/test/sendable/builtins/Array/from/TC019.js b/test/sendable/builtins/Array/from/iter-cstm-ctor.js similarity index 98% rename from test/sendable/builtins/Array/from/TC019.js rename to test/sendable/builtins/Array/from/iter-cstm-ctor.js index 414b85d5b1c..2b4003cbad8 100644 --- a/test/sendable/builtins/Array/from/TC019.js +++ b/test/sendable/builtins/Array/from/iter-cstm-ctor.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Creating object with custom constructor (traversed via iterator) info: | 6. If usingIterator is not undefined, then diff --git a/test/sendable/builtins/Array/from/TC020.js b/test/sendable/builtins/Array/from/iter-get-iter-err.js similarity index 98% rename from test/sendable/builtins/Array/from/TC020.js rename to test/sendable/builtins/Array/from/iter-get-iter-err.js index ca6d7cdaac9..4ffda723740 100644 --- a/test/sendable/builtins/Array/from/TC020.js +++ b/test/sendable/builtins/Array/from/iter-get-iter-err.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Error creating iterator object info: | 6. If usingIterator is not undefined, then diff --git a/test/sendable/builtins/Array/from/TC021.js b/test/sendable/builtins/Array/from/iter-get-iter-val-err.js similarity index 98% rename from test/sendable/builtins/Array/from/TC021.js rename to test/sendable/builtins/Array/from/iter-get-iter-val-err.js index 6a5c2d8bbed..1e8719de562 100644 --- a/test/sendable/builtins/Array/from/TC021.js +++ b/test/sendable/builtins/Array/from/iter-get-iter-val-err.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Error retrieving value of iterator result info: | 6. If usingIterator is not undefined, then diff --git a/test/sendable/builtins/Array/from/TC022.js b/test/sendable/builtins/Array/from/iter-map-fn-args.js similarity index 99% rename from test/sendable/builtins/Array/from/TC022.js rename to test/sendable/builtins/Array/from/iter-map-fn-args.js index fbcfd46e184..0dad143ea12 100644 --- a/test/sendable/builtins/Array/from/TC022.js +++ b/test/sendable/builtins/Array/from/iter-map-fn-args.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: > Arguments of mapping function (traversed via iterator) info: | @@ -46,6 +47,7 @@ var mapFn = function(value, idx) { var items = {}; var nextResult = firstResult; var nextNextResult = secondResult; + items[Symbol.iterator] = function() { return { next: function() { diff --git a/test/sendable/builtins/Array/from/TC023.js b/test/sendable/builtins/Array/from/iter-map-fn-err.js similarity index 100% rename from test/sendable/builtins/Array/from/TC023.js rename to test/sendable/builtins/Array/from/iter-map-fn-err.js diff --git a/test/sendable/builtins/Array/from/TC024.js b/test/sendable/builtins/Array/from/iter-map-fn-return.js similarity index 99% rename from test/sendable/builtins/Array/from/TC024.js rename to test/sendable/builtins/Array/from/iter-map-fn-return.js index ae5cbbf4259..eca892bd958 100644 --- a/test/sendable/builtins/Array/from/TC024.js +++ b/test/sendable/builtins/Array/from/iter-map-fn-return.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Value returned by mapping function (traversed via iterator) info: | 2. If mapfn is undefined, let mapping be false. @@ -63,6 +64,7 @@ items[Symbol.iterator] = function() { } }; }; + result = SendableArray.from(items, mapFn); assert.sameValue(result.length, 2, 'The value of result.length is expected to be 2'); assert.sameValue(result[0], firstReturnVal, 'The value of result[0] is expected to equal the value of firstReturnVal'); diff --git a/test/sendable/builtins/Array/from/TC025.js b/test/sendable/builtins/Array/from/iter-map-fn-this-arg.js similarity index 98% rename from test/sendable/builtins/Array/from/TC025.js rename to test/sendable/builtins/Array/from/iter-map-fn-this-arg.js index 34fbee0a962..08a7f7881a1 100644 --- a/test/sendable/builtins/Array/from/TC025.js +++ b/test/sendable/builtins/Array/from/iter-map-fn-this-arg.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: > `this` value of mapping function with custom `this` argument (traversed via iterator) info: | diff --git a/test/sendable/builtins/Array/from/TC026.js b/test/sendable/builtins/Array/from/iter-map-fn-this-non-strict.js similarity index 98% rename from test/sendable/builtins/Array/from/TC026.js rename to test/sendable/builtins/Array/from/iter-map-fn-this-non-strict.js index 2e21bef34df..64ee69567ce 100644 --- a/test/sendable/builtins/Array/from/TC026.js +++ b/test/sendable/builtins/Array/from/iter-map-fn-this-non-strict.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: > `this` value of mapping function in non-strict mode (traversed via iterator) info: | diff --git a/test/sendable/builtins/Array/from/TC027.js b/test/sendable/builtins/Array/from/iter-map-fn-this-strict.js similarity index 98% rename from test/sendable/builtins/Array/from/TC027.js rename to test/sendable/builtins/Array/from/iter-map-fn-this-strict.js index ee6f99c4436..831f5045ccc 100644 --- a/test/sendable/builtins/Array/from/TC027.js +++ b/test/sendable/builtins/Array/from/iter-map-fn-this-strict.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: > `this` value of mapping function in strict mode (traversed via iterator) info: | diff --git a/test/sendable/builtins/Array/from/TC028.js b/test/sendable/builtins/Array/from/iter-set-elem-prop-err.js similarity index 98% rename from test/sendable/builtins/Array/from/TC028.js rename to test/sendable/builtins/Array/from/iter-set-elem-prop-err.js index 6e2ba871335..c7685b3cf30 100644 --- a/test/sendable/builtins/Array/from/TC028.js +++ b/test/sendable/builtins/Array/from/iter-set-elem-prop-err.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Error setting property on result value (traversed via iterator) info: | 6. If usingIterator is not undefined, then diff --git a/test/sendable/builtins/Array/from/TC029.js b/test/sendable/builtins/Array/from/iter-set-elem-prop-non-writable.js similarity index 98% rename from test/sendable/builtins/Array/from/TC029.js rename to test/sendable/builtins/Array/from/iter-set-elem-prop-non-writable.js index ee1ff950446..f752ed0d2bb 100644 --- a/test/sendable/builtins/Array/from/TC029.js +++ b/test/sendable/builtins/Array/from/iter-set-elem-prop-non-writable.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: > Non-writable properties are overwritten by CreateDataProperty. (result object's "0" is non-writable, items is iterable) diff --git a/test/sendable/builtins/Array/from/TC030.js b/test/sendable/builtins/Array/from/iter-set-elem-prop.js similarity index 98% rename from test/sendable/builtins/Array/from/TC030.js rename to test/sendable/builtins/Array/from/iter-set-elem-prop.js index b5e15c21930..ce3ecb46500 100644 --- a/test/sendable/builtins/Array/from/TC030.js +++ b/test/sendable/builtins/Array/from/iter-set-elem-prop.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Setting property on result value (traversed via iterator) info: | 6. If usingIterator is not undefined, then @@ -42,8 +43,10 @@ items[Symbol.iterator] = function() { return { next: function() { var result = nextIterResult; + nextIterResult = nextNextIterResult; nextNextIterResult = thirdIterResult; + return result; } }; diff --git a/test/sendable/builtins/Array/from/TC031.js b/test/sendable/builtins/Array/from/iter-set-length-err.js similarity index 98% rename from test/sendable/builtins/Array/from/TC031.js rename to test/sendable/builtins/Array/from/iter-set-length-err.js index 8dab0a22086..b5050832d61 100644 --- a/test/sendable/builtins/Array/from/TC031.js +++ b/test/sendable/builtins/Array/from/iter-set-length-err.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Error setting length of object (traversed via iterator) info: | 6. If usingIterator is not undefined, then diff --git a/test/sendable/builtins/Array/from/TC032.js b/test/sendable/builtins/Array/from/iter-set-length.js similarity index 98% rename from test/sendable/builtins/Array/from/TC032.js rename to test/sendable/builtins/Array/from/iter-set-length.js index 57d22624bbb..4aed93aafe9 100644 --- a/test/sendable/builtins/Array/from/TC032.js +++ b/test/sendable/builtins/Array/from/iter-set-length.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Setting length of object (traversed via iterator) info: | 6. If usingIterator is not undefined, then diff --git a/test/sendable/builtins/Array/from/TC033.js b/test/sendable/builtins/Array/from/mapfn-is-not-callable-typeerror.js similarity index 90% rename from test/sendable/builtins/Array/from/TC033.js rename to test/sendable/builtins/Array/from/mapfn-is-not-callable-typeerror.js index b81c36ea070..bd6d76f9cda 100644 --- a/test/sendable/builtins/Array/from/TC033.js +++ b/test/sendable/builtins/Array/from/mapfn-is-not-callable-typeerror.js @@ -13,9 +13,10 @@ * limitations under the License. */ /*--- +esid: sec-array.from description: Throws a TypeError if mapFn is not callable info: | - 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + 22.1.2.1 SendableArray.from ( items [ , mapfn [ , thisArg ] ] ) 2. If mapfn is undefined, let mapping be false. 3. else a. If IsCallable(mapfn) is false, throw a TypeError exception. @@ -32,7 +33,7 @@ assert.throws(TypeError, function() { }, 'SendableArray.from([], "string") throws a TypeError exception'); assert.throws(TypeError, function() { SendableArray.from([], true); -}, 'ArSendableArrayray.from([], true) throws a TypeError exception'); +}, 'SendableArray.from([], true) throws a TypeError exception'); assert.throws(TypeError, function() { SendableArray.from([], 42); }, 'SendableArray.from([], 42) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/from/TC034.js b/test/sendable/builtins/Array/from/mapfn-is-symbol-throws.js similarity index 91% rename from test/sendable/builtins/Array/from/TC034.js rename to test/sendable/builtins/Array/from/mapfn-is-symbol-throws.js index eacadee799b..e6cf2ad2dcb 100644 --- a/test/sendable/builtins/Array/from/TC034.js +++ b/test/sendable/builtins/Array/from/mapfn-is-symbol-throws.js @@ -13,9 +13,10 @@ * limitations under the License. */ /*--- +esid: sec-SendableArray.from description: Throws a TypeError if mapFn is not callable (Symbol) info: | - 22.1.2.1 Array.from ( items [ , mapfn [ , thisArg ] ] ) + 22.1.2.1 SendableArray.from ( items [ , mapfn [ , thisArg ] ] ) 2. If mapfn is undefined, let mapping be false. 3. else a. If IsCallable(mapfn) is false, throw a TypeError exception. diff --git a/test/sendable/builtins/Array/from/TC035.js b/test/sendable/builtins/Array/from/mapfn-throws-exception.js similarity index 95% rename from test/sendable/builtins/Array/from/TC035.js rename to test/sendable/builtins/Array/from/mapfn-throws-exception.js index 6313eb56c55..0c8e13a26f1 100644 --- a/test/sendable/builtins/Array/from/TC035.js +++ b/test/sendable/builtins/Array/from/mapfn-throws-exception.js @@ -12,9 +12,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - /*--- description: mapFn throws an exception +esid: sec-SendableArray.from +es6id: 22.1.2.1 ---*/ var array = [2, 4, 8, 16, 32, 64, 128]; diff --git a/test/sendable/builtins/Array/from/TC036.js b/test/sendable/builtins/Array/from/not-a-constructor.js similarity index 100% rename from test/sendable/builtins/Array/from/TC036.js rename to test/sendable/builtins/Array/from/not-a-constructor.js diff --git a/test/sendable/builtins/Array/from/TC037.js b/test/sendable/builtins/Array/from/proto-from-ctor-realm.js similarity index 91% rename from test/sendable/builtins/Array/from/TC037.js rename to test/sendable/builtins/Array/from/proto-from-ctor-realm.js index 76d8943b350..80444b128b4 100644 --- a/test/sendable/builtins/Array/from/TC037.js +++ b/test/sendable/builtins/Array/from/proto-from-ctor-realm.js @@ -13,6 +13,8 @@ * limitations under the License. */ /*--- +esid: sec-SendableArray.from +es6id: 22.1.2.1 description: Default [[Prototype]] value derived from realm of the constructor info: | 5. If usingIterator is not undefined, then @@ -33,5 +35,5 @@ var a = SendableArray.from.call(C, []); assert.sameValue( Object.getPrototypeOf(a), other.Object.prototype, - 'Object.getPrototypeOf(Array.from.call(C, [])) returns other.Object.prototype' + 'Object.getPrototypeOf(SendableArray.from.call(C, [])) returns other.Object.prototype' ); diff --git a/test/sendable/builtins/Array/from/TC038.js b/test/sendable/builtins/Array/from/source-array-boundary.js similarity index 97% rename from test/sendable/builtins/Array/from/TC038.js rename to test/sendable/builtins/Array/from/source-array-boundary.js index 724fda39d2b..c1e055ea2ee 100644 --- a/test/sendable/builtins/Array/from/TC038.js +++ b/test/sendable/builtins/Array/from/source-array-boundary.js @@ -14,6 +14,8 @@ */ /*--- description: Source array with boundary values +esid: sec-SendableArray.from +es6id: 22.1.2.1 ---*/ var array = [Number.MAX_VALUE, Number.MIN_VALUE, Number.NaN, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY]; diff --git a/test/sendable/builtins/Array/from/TC039.js b/test/sendable/builtins/Array/from/source-object-constructor.js similarity index 88% rename from test/sendable/builtins/Array/from/TC039.js rename to test/sendable/builtins/Array/from/source-object-constructor.js index 4ca6d779ec5..8830a4ef7e9 100644 --- a/test/sendable/builtins/Array/from/TC039.js +++ b/test/sendable/builtins/Array/from/source-object-constructor.js @@ -14,7 +14,9 @@ */ /*--- description: > - Array.from uses a constructor other than Array. + SendableArray.from uses a constructor other than Array. +esid: sec-SendableArray.from +es6id: 22.1.2.1 ---*/ assert.sameValue( diff --git a/test/sendable/builtins/Array/from/TC040.js b/test/sendable/builtins/Array/from/source-object-iterator-1.js similarity index 96% rename from test/sendable/builtins/Array/from/TC040.js rename to test/sendable/builtins/Array/from/source-object-iterator-1.js index fd12bc2d3c7..c76e9c12cc1 100644 --- a/test/sendable/builtins/Array/from/TC040.js +++ b/test/sendable/builtins/Array/from/source-object-iterator-1.js @@ -14,6 +14,8 @@ */ /*--- description: Source object has iterator which throws +esid: sec-SendableArray.from +es6id: 22.1.2.1 features: [Symbol.iterator] ---*/ diff --git a/test/sendable/builtins/Array/from/TC041.js b/test/sendable/builtins/Array/from/source-object-iterator-2.js similarity index 96% rename from test/sendable/builtins/Array/from/TC041.js rename to test/sendable/builtins/Array/from/source-object-iterator-2.js index b6103a32f82..e38ccae6408 100644 --- a/test/sendable/builtins/Array/from/TC041.js +++ b/test/sendable/builtins/Array/from/source-object-iterator-2.js @@ -14,6 +14,8 @@ */ /*--- description: Source object has iterator +esid: sec-SendableArray.from +es6id: 22.1.2.1 features: [Symbol.iterator] ---*/ diff --git a/test/sendable/builtins/Array/from/TC042.js b/test/sendable/builtins/Array/from/source-object-length-set-elem-prop-err.js similarity index 98% rename from test/sendable/builtins/Array/from/TC042.js rename to test/sendable/builtins/Array/from/source-object-length-set-elem-prop-err.js index 8eb9e1087ac..a8f40081404 100644 --- a/test/sendable/builtins/Array/from/TC042.js +++ b/test/sendable/builtins/Array/from/source-object-length-set-elem-prop-err.js @@ -13,6 +13,7 @@ * limitations under the License. */ /*--- +esid: sec-SendableArray.from description: > TypeError is thrown if CreateDataProperty fails. (items is not iterable) diff --git a/test/sendable/builtins/Array/from/TC043.js b/test/sendable/builtins/Array/from/source-object-length-set-elem-prop-non-writable.js similarity index 98% rename from test/sendable/builtins/Array/from/TC043.js rename to test/sendable/builtins/Array/from/source-object-length-set-elem-prop-non-writable.js index 83669f27c70..9ad2f8386dd 100644 --- a/test/sendable/builtins/Array/from/TC043.js +++ b/test/sendable/builtins/Array/from/source-object-length-set-elem-prop-non-writable.js @@ -13,7 +13,7 @@ * limitations under the License. */ /*--- -esid: sec-array.from +esid: sec-SendableArray.from description: > Non-writable properties are overwritten by CreateDataProperty. (result object's "0" is non-writable, items is not iterable) diff --git a/test/sendable/builtins/Array/from/TC044.js b/test/sendable/builtins/Array/from/source-object-length.js similarity index 96% rename from test/sendable/builtins/Array/from/TC044.js rename to test/sendable/builtins/Array/from/source-object-length.js index ec3f85f4f38..4c4c6be09dd 100644 --- a/test/sendable/builtins/Array/from/TC044.js +++ b/test/sendable/builtins/Array/from/source-object-length.js @@ -16,6 +16,8 @@ description: > Source is an object with length property and one item is deleted from the source +esid: sec-SendableArray.from +es6id: 22.1.2.1 ---*/ var array = [2, 4, 0, 16]; diff --git a/test/sendable/builtins/Array/from/TC045.js b/test/sendable/builtins/Array/from/source-object-missing.js similarity index 95% rename from test/sendable/builtins/Array/from/TC045.js rename to test/sendable/builtins/Array/from/source-object-missing.js index 5895e5af97c..3099391c0cf 100644 --- a/test/sendable/builtins/Array/from/TC045.js +++ b/test/sendable/builtins/Array/from/source-object-missing.js @@ -14,7 +14,10 @@ */ /*--- description: Source is an object with missing values +esid: sec-SendableArray.from +es6id: 22.1.2.1 ---*/ + var array = [2, 4, , 16]; var obj = { length: 4, diff --git a/test/sendable/builtins/Array/from/TC046.js b/test/sendable/builtins/Array/from/source-object-without.js similarity index 94% rename from test/sendable/builtins/Array/from/TC046.js rename to test/sendable/builtins/Array/from/source-object-without.js index e1a656d36d6..5482e800ef2 100644 --- a/test/sendable/builtins/Array/from/TC046.js +++ b/test/sendable/builtins/Array/from/source-object-without.js @@ -12,9 +12,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + /*--- description: Source is an object without length property +esid: sec-SendableArray.from +es6id: 22.1.2.1 ---*/ + var obj = { 0: 2, 1: 4, diff --git a/test/sendable/builtins/Array/from/TC047.js b/test/sendable/builtins/Array/from/this-null.js similarity index 95% rename from test/sendable/builtins/Array/from/TC047.js rename to test/sendable/builtins/Array/from/this-null.js index 59f1f964428..594b1864c42 100644 --- a/test/sendable/builtins/Array/from/TC047.js +++ b/test/sendable/builtins/Array/from/this-null.js @@ -13,6 +13,8 @@ * limitations under the License. */ /*--- +esid: sec-SendableArray.from +es6id: 22.1.2.1 description: Does not throw if this is null ---*/ -- Gitee From 6a1d913f592805fc0b1dc966550dc03ce9091c5d Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 16 Dec 2024 14:03:41 +0800 Subject: [PATCH 08/93] add folder harmless and fromasync 20241216 Signed-off-by: zhuzhihui7 --- ...async-iterable-async-mapped-awaits-once.js | 41 +++++++++ ...ync-iterable-input-does-not-await-input.js | 47 ++++++++++ .../async-iterable-input-iteration-err.js | 31 +++++++ .../Array/fromAsync/async-iterable-input.js | 32 +++++++ .../asyncitems-array-add-to-empty.js | 49 ++++++++++ .../asyncitems-array-add-to-singleton.js | 48 ++++++++++ .../Array/fromAsync/asyncitems-array-add.js | 48 ++++++++++ .../fromAsync/asyncitems-array-mutate.js | 49 ++++++++++ .../fromAsync/asyncitems-array-remove.js | 48 ++++++++++ .../Array/fromAsync/asyncitems-arraybuffer.js | 28 ++++++ .../fromAsync/asyncitems-arraylike-holes.js | 34 +++++++ ...citems-arraylike-length-accessor-throws.js | 35 +++++++ .../fromAsync/asyncitems-arraylike-promise.js | 42 +++++++++ .../asyncitems-arraylike-too-long.js | 37 ++++++++ .../asyncitems-asynciterator-exists.js | 42 +++++++++ .../asyncitems-asynciterator-not-callable.js | 30 ++++++ .../asyncitems-asynciterator-null.js | 41 +++++++++ .../asyncitems-asynciterator-sync.js | 42 +++++++++ .../asyncitems-asynciterator-throws.js | 27 ++++++ .../Array/fromAsync/asyncitems-bigint.js | 30 ++++++ .../Array/fromAsync/asyncitems-boolean.js | 30 ++++++ .../Array/fromAsync/asyncitems-function.js | 31 +++++++ .../fromAsync/asyncitems-iterator-exists.js | 43 +++++++++ .../asyncitems-iterator-not-callable.js | 30 ++++++ .../fromAsync/asyncitems-iterator-null.js | 41 +++++++++ .../fromAsync/asyncitems-iterator-promise.js | 43 +++++++++ .../fromAsync/asyncitems-iterator-throws.js | 27 ++++++ .../fromAsync/asyncitems-null-undefined.js | 29 ++++++ .../Array/fromAsync/asyncitems-number.js | 30 ++++++ .../asyncitems-object-not-arraylike.js | 33 +++++++ .../Array/fromAsync/asyncitems-operations.js | 41 +++++++++ .../Array/fromAsync/asyncitems-string.js | 27 ++++++ .../Array/fromAsync/asyncitems-symbol.js | 30 ++++++ ...ncitems-uses-intrinsic-iterator-symbols.js | 49 ++++++++++ .../builtins/Array/fromAsync/builtin.js | 43 +++++++++ .../builtins/Array/fromAsync/length.js | 37 ++++++++ .../Array/fromAsync/mapfn-async-arraylike.js | 44 +++++++++ .../fromAsync/mapfn-async-iterable-async.js | 44 +++++++++ .../fromAsync/mapfn-async-iterable-sync.js | 41 +++++++++ ...mapfn-async-throws-close-async-iterator.js | 49 ++++++++++ .../mapfn-async-throws-close-sync-iterator.js | 50 ++++++++++ .../Array/fromAsync/mapfn-async-throws.js | 34 +++++++ .../Array/fromAsync/mapfn-not-callable.js | 36 ++++++++ ...mapfn-result-awaited-once-per-iteration.js | 55 +++++++++++ .../Array/fromAsync/mapfn-sync-arraylike.js | 42 +++++++++ .../fromAsync/mapfn-sync-iterable-async.js | 42 +++++++++ .../fromAsync/mapfn-sync-iterable-sync.js | 40 ++++++++ .../mapfn-sync-throws-close-async-iterator.js | 49 ++++++++++ .../mapfn-sync-throws-close-sync-iterator.js | 49 ++++++++++ .../Array/fromAsync/mapfn-sync-throws.js | 33 +++++++ .../sendable/builtins/Array/fromAsync/name.js | 37 ++++++++ ...able-input-does-not-use-array-prototype.js | 54 +++++++++++ .../non-iterable-input-element-access-err.js | 32 +++++++ ...sync-mapped-awaits-callback-result-once.js | 43 +++++++++ ...with-thenable-async-mapped-callback-err.js | 38 ++++++++ ...ble-input-with-thenable-element-rejects.js | 37 ++++++++ ...-with-thenable-sync-mapped-callback-err.js | 32 +++++++ .../non-iterable-input-with-thenable.js | 35 +++++++ .../Array/fromAsync/non-iterable-input.js | 35 +++++++ .../non-iterable-sync-mapped-callback-err.js | 38 ++++++++ .../non-iterable-with-non-promise-thenable.js | 37 ++++++++ ...-with-thenable-async-mapped-awaits-once.js | 40 ++++++++ .../non-iterable-with-thenable-awaits-once.js | 38 ++++++++ ...e-with-thenable-sync-mapped-awaits-once.js | 39 ++++++++ ...-iterable-with-thenable-then-method-err.js | 35 +++++++ .../Array/fromAsync/not-a-constructor.js | 27 ++++++ .../builtins/Array/fromAsync/prop-desc.js | 31 +++++++ .../returned-promise-resolves-to-array.js | 32 +++++++ .../Array/fromAsync/returns-promise.js | 43 +++++++++ ...terable-input-with-non-promise-thenable.js | 34 +++++++ .../sync-iterable-input-with-thenable.js | 28 ++++++ .../Array/fromAsync/sync-iterable-input.js | 28 ++++++ .../fromAsync/sync-iterable-iteration-err.js | 30 ++++++ ...-with-thenable-async-mapped-awaits-once.js | 36 ++++++++ ...with-thenable-async-mapped-callback-err.js | 29 ++++++ ...sync-iterable-with-thenable-awaits-once.js | 36 ++++++++ ...-iterable-with-thenable-element-rejects.js | 32 +++++++ ...e-with-thenable-sync-mapped-awaits-once.js | 36 ++++++++ ...-with-thenable-sync-mapped-callback-err.js | 29 ++++++ ...-iterable-with-thenable-then-method-err.js | 34 +++++++ .../fromAsync/this-constructor-operations.js | 79 ++++++++++++++++ ...this-constructor-with-bad-length-setter.js | 41 +++++++++ ...this-constructor-with-readonly-elements.js | 59 ++++++++++++ .../this-constructor-with-readonly-length.js | 46 ++++++++++ ...nsettable-element-closes-async-iterator.js | 53 +++++++++++ ...unsettable-element-closes-sync-iterator.js | 52 +++++++++++ ...his-constructor-with-unsettable-element.js | 38 ++++++++ .../Array/fromAsync/this-constructor.js | 57 ++++++++++++ .../Array/fromAsync/this-non-constructor.js | 51 ++++++++++ .../Array/fromAsync/thisarg-object.js | 31 +++++++ .../Array/fromAsync/thisarg-omitted-sloppy.js | 44 +++++++++ .../Array/fromAsync/thisarg-omitted-strict.js | 39 ++++++++ .../fromAsync/thisarg-primitive-sloppy.js | 79 ++++++++++++++++ .../fromAsync/thisarg-primitive-strict.js | 54 +++++++++++ test/sendable/harness/assert-false.js | 37 ++++++++ .../harness/assert-notsamevalue-nan.js | 37 ++++++++ .../harness/assert-notsamevalue-notsame.js | 26 ++++++ .../harness/assert-notsamevalue-objects.js | 21 +++++ .../harness/assert-notsamevalue-tostring.js | 36 ++++++++ .../harness/assert-notsamevalue-zeros.js | 21 +++++ test/sendable/harness/assert-obj.js | 37 ++++++++ test/sendable/harness/assert-samevalue-nan.js | 21 +++++ .../harness/assert-samevalue-objects.js | 37 ++++++++ .../sendable/harness/assert-samevalue-same.js | 30 ++++++ .../harness/assert-samevalue-tostring.js | 36 ++++++++ .../harness/assert-samevalue-zeros.js | 38 ++++++++ .../harness/assert-throws-custom-typeerror.js | 70 ++++++++++++++ test/sendable/harness/assert-throws-custom.js | 26 ++++++ .../harness/assert-throws-incorrect-ctor.js | 40 ++++++++ test/sendable/harness/assert-throws-native.js | 48 ++++++++++ test/sendable/harness/assert-throws-no-arg.js | 37 ++++++++ .../harness/assert-throws-no-error.js | 37 ++++++++ .../sendable/harness/assert-throws-null-fn.js | 73 +++++++++++++++ test/sendable/harness/assert-throws-null.js | 39 ++++++++ .../harness/assert-throws-primitive.js | 38 ++++++++ .../harness/assert-throws-same-realm.js | 42 +++++++++ .../harness/assert-throws-single-arg.js | 36 ++++++++ test/sendable/harness/assert-tostring.js | 36 ++++++++ test/sendable/harness/assert-true.js | 21 +++++ test/sendable/harness/assertRelativeDateMs.js | 92 +++++++++++++++++++ ...asyncHelpers-asyncTest-func-throws-sync.js | 30 ++++++ ...cHelpers-asyncTest-rejects-non-callable.js | 31 +++++++ ...ncHelpers-asyncTest-return-not-thenable.js | 42 +++++++++ ...syncHelpers-asyncTest-returns-undefined.js | 51 ++++++++++ .../asyncHelpers-asyncTest-then-rejects.js | 60 ++++++++++++ .../asyncHelpers-asyncTest-then-resolves.js | 68 ++++++++++++++ ...yncHelpers-asyncTest-without-async-flag.js | 34 +++++++ ...yncHelpers-throwsAsync-custom-typeerror.js | 84 +++++++++++++++++ .../asyncHelpers-throwsAsync-custom.js | 31 +++++++ ...cHelpers-throwsAsync-func-never-settles.js | 49 ++++++++++ ...yncHelpers-throwsAsync-func-throws-sync.js | 64 +++++++++++++ ...asyncHelpers-throwsAsync-incorrect-ctor.js | 47 ++++++++++ .../asyncHelpers-throwsAsync-invalid-func.js | 82 +++++++++++++++++ .../asyncHelpers-throwsAsync-native.js | 59 ++++++++++++ .../asyncHelpers-throwsAsync-no-arg.js | 44 +++++++++ .../asyncHelpers-throwsAsync-no-error.js | 44 +++++++++ .../harness/asyncHelpers-throwsAsync-null.js | 46 ++++++++++ .../asyncHelpers-throwsAsync-primitive.js | 46 ++++++++++ ...asyncHelpers-throwsAsync-resolved-error.js | 47 ++++++++++ .../asyncHelpers-throwsAsync-same-realm.js | 49 ++++++++++ .../asyncHelpers-throwsAsync-single-arg.js | 43 +++++++++ test/sendable/harness/byteConversionValues.js | 34 +++++++ .../harness/compare-array-arguments.js | 50 ++++++++++ .../harness/compare-array-arraylike.js | 46 ++++++++++ .../compare-array-different-elements.js | 27 ++++++ .../harness/compare-array-different-length.js | 29 ++++++ test/sendable/harness/compare-array-empty.js | 22 +++++ .../harness/compare-array-falsy-arguments.js | 40 ++++++++ .../sendable/harness/compare-array-message.js | 35 +++++++ ...are-array-same-elements-different-order.js | 28 ++++++ .../compare-array-same-elements-same-order.js | 26 ++++++ .../harness/compare-array-samevalue.js | 25 +++++ test/sendable/harness/compare-array-sparse.js | 35 +++++++ test/sendable/harness/compare-array-symbol.js | 35 +++++++ test/sendable/harness/dateConstants.js | 37 ++++++++ test/sendable/harness/decimalToHexString.js | 38 ++++++++ test/sendable/harness/deepEqual-array.js | 26 ++++++ test/sendable/harness/deepEqual-circular.js | 29 ++++++ test/sendable/harness/deepEqual-deep.js | 25 +++++ test/sendable/harness/deepEqual-mapset.js | 31 +++++++ test/sendable/harness/deepEqual-object.js | 27 ++++++ .../harness/deepEqual-primitives-bigint.js | 27 ++++++ test/sendable/harness/deepEqual-primitives.js | 44 +++++++++ ...etachArrayBuffer-host-detachArrayBuffer.js | 55 +++++++++++ test/sendable/harness/detachArrayBuffer.js | 45 +++++++++ test/sendable/harness/fnGlobalObject.js | 29 ++++++ test/sendable/harness/isConstructor.js | 44 +++++++++ test/sendable/harness/nans.js | 36 ++++++++ .../sendable/harness/nativeFunctionMatcher.js | 72 +++++++++++++++ test/sendable/harness/promiseHelper.js | 47 ++++++++++ ...-verifyconfigurable-configurable-object.js | 27 ++++++ ...yhelper-verifyconfigurable-configurable.js | 27 ++++++ ...per-verifyconfigurable-not-configurable.js | 43 +++++++++ ...lper-verifyenumerable-enumerable-symbol.js | 29 ++++++ ...pertyhelper-verifyenumerable-enumerable.js | 27 ++++++ ...-verifyenumerable-not-enumerable-symbol.js | 44 +++++++++ ...yhelper-verifyenumerable-not-enumerable.js | 42 +++++++++ ...lper-verifynotconfigurable-configurable.js | 42 +++++++++ ...-verifynotconfigurable-not-configurable.js | 27 ++++++ ...r-verifynotenumerable-enumerable-symbol.js | 46 ++++++++++ ...tyhelper-verifynotenumerable-enumerable.js | 44 +++++++++ ...rifynotenumerable-not-enumerable-symbol.js | 30 ++++++ ...lper-verifynotenumerable-not-enumerable.js | 28 ++++++ ...r-verifynotwritable-not-writable-strict.js | 33 +++++++ ...opertyhelper-verifynotwritable-writable.js | 42 +++++++++ ...pertyhelper-verifywritable-array-length.js | 26 ++++++ ...pertyhelper-verifywritable-not-writable.js | 42 +++++++++ .../propertyhelper-verifywritable-writable.js | 32 +++++++ .../harness/proxytrapshelper-default.js | 52 +++++++++++ .../harness/proxytrapshelper-overrides.js | 87 ++++++++++++++++++ test/sendable/harness/sta.js | 27 ++++++ test/sendable/harness/tcoHelper.js | 29 ++++++ .../testTypedArray-conversions-call-error.js | 42 +++++++++ .../harness/testTypedArray-conversions.js | 70 ++++++++++++++ test/sendable/harness/testTypedArray.js | 51 ++++++++++ .../harness/verifyProperty-arguments.js | 31 +++++++ .../verifyProperty-configurable-object.js | 29 ++++++ .../verifyProperty-desc-is-not-object.js | 42 +++++++++ .../harness/verifyProperty-noproperty.js | 27 ++++++ .../verifyProperty-restore-accessor-symbol.js | 55 +++++++++++ .../verifyProperty-restore-accessor.js | 54 +++++++++++ .../harness/verifyProperty-restore-symbol.js | 46 ++++++++++ .../harness/verifyProperty-restore.js | 45 +++++++++ .../harness/verifyProperty-same-value.js | 31 +++++++ .../harness/verifyProperty-string-prop.js | 63 +++++++++++++ .../harness/verifyProperty-symbol-prop.js | 64 +++++++++++++ .../harness/verifyProperty-undefined-desc.js | 37 ++++++++ .../harness/verifyProperty-value-error.js | 51 ++++++++++ test/sendable/harness/verifyProperty-value.js | 63 +++++++++++++ 209 files changed, 8465 insertions(+) create mode 100644 test/sendable/builtins/Array/fromAsync/async-iterable-async-mapped-awaits-once.js create mode 100644 test/sendable/builtins/Array/fromAsync/async-iterable-input-does-not-await-input.js create mode 100644 test/sendable/builtins/Array/fromAsync/async-iterable-input-iteration-err.js create mode 100644 test/sendable/builtins/Array/fromAsync/async-iterable-input.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-array-add-to-empty.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-array-add-to-singleton.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-array-add.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-array-mutate.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-array-remove.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-arraybuffer.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-holes.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-length-accessor-throws.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-promise.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-too-long.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-exists.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-not-callable.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-null.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-sync.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-throws.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-bigint.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-boolean.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-function.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-iterator-exists.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-iterator-not-callable.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-iterator-null.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-iterator-promise.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-iterator-throws.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-null-undefined.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-number.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-object-not-arraylike.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-operations.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-string.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-symbol.js create mode 100644 test/sendable/builtins/Array/fromAsync/asyncitems-uses-intrinsic-iterator-symbols.js create mode 100644 test/sendable/builtins/Array/fromAsync/builtin.js create mode 100644 test/sendable/builtins/Array/fromAsync/length.js create mode 100644 test/sendable/builtins/Array/fromAsync/mapfn-async-arraylike.js create mode 100644 test/sendable/builtins/Array/fromAsync/mapfn-async-iterable-async.js create mode 100644 test/sendable/builtins/Array/fromAsync/mapfn-async-iterable-sync.js create mode 100644 test/sendable/builtins/Array/fromAsync/mapfn-async-throws-close-async-iterator.js create mode 100644 test/sendable/builtins/Array/fromAsync/mapfn-async-throws-close-sync-iterator.js create mode 100644 test/sendable/builtins/Array/fromAsync/mapfn-async-throws.js create mode 100644 test/sendable/builtins/Array/fromAsync/mapfn-not-callable.js create mode 100644 test/sendable/builtins/Array/fromAsync/mapfn-result-awaited-once-per-iteration.js create mode 100644 test/sendable/builtins/Array/fromAsync/mapfn-sync-arraylike.js create mode 100644 test/sendable/builtins/Array/fromAsync/mapfn-sync-iterable-async.js create mode 100644 test/sendable/builtins/Array/fromAsync/mapfn-sync-iterable-sync.js create mode 100644 test/sendable/builtins/Array/fromAsync/mapfn-sync-throws-close-async-iterator.js create mode 100644 test/sendable/builtins/Array/fromAsync/mapfn-sync-throws-close-sync-iterator.js create mode 100644 test/sendable/builtins/Array/fromAsync/mapfn-sync-throws.js create mode 100644 test/sendable/builtins/Array/fromAsync/name.js create mode 100644 test/sendable/builtins/Array/fromAsync/non-iterable-input-does-not-use-array-prototype.js create mode 100644 test/sendable/builtins/Array/fromAsync/non-iterable-input-element-access-err.js create mode 100644 test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-awaits-callback-result-once.js create mode 100644 test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-callback-err.js create mode 100644 test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-element-rejects.js create mode 100644 test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-sync-mapped-callback-err.js create mode 100644 test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable.js create mode 100644 test/sendable/builtins/Array/fromAsync/non-iterable-input.js create mode 100644 test/sendable/builtins/Array/fromAsync/non-iterable-sync-mapped-callback-err.js create mode 100644 test/sendable/builtins/Array/fromAsync/non-iterable-with-non-promise-thenable.js create mode 100644 test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-async-mapped-awaits-once.js create mode 100644 test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-awaits-once.js create mode 100644 test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-sync-mapped-awaits-once.js create mode 100644 test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-then-method-err.js create mode 100644 test/sendable/builtins/Array/fromAsync/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/fromAsync/prop-desc.js create mode 100644 test/sendable/builtins/Array/fromAsync/returned-promise-resolves-to-array.js create mode 100644 test/sendable/builtins/Array/fromAsync/returns-promise.js create mode 100644 test/sendable/builtins/Array/fromAsync/sync-iterable-input-with-non-promise-thenable.js create mode 100644 test/sendable/builtins/Array/fromAsync/sync-iterable-input-with-thenable.js create mode 100644 test/sendable/builtins/Array/fromAsync/sync-iterable-input.js create mode 100644 test/sendable/builtins/Array/fromAsync/sync-iterable-iteration-err.js create mode 100644 test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-awaits-once.js create mode 100644 test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-callback-err.js create mode 100644 test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-awaits-once.js create mode 100644 test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-element-rejects.js create mode 100644 test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-awaits-once.js create mode 100644 test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-callback-err.js create mode 100644 test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-then-method-err.js create mode 100644 test/sendable/builtins/Array/fromAsync/this-constructor-operations.js create mode 100644 test/sendable/builtins/Array/fromAsync/this-constructor-with-bad-length-setter.js create mode 100644 test/sendable/builtins/Array/fromAsync/this-constructor-with-readonly-elements.js create mode 100644 test/sendable/builtins/Array/fromAsync/this-constructor-with-readonly-length.js create mode 100644 test/sendable/builtins/Array/fromAsync/this-constructor-with-unsettable-element-closes-async-iterator.js create mode 100644 test/sendable/builtins/Array/fromAsync/this-constructor-with-unsettable-element-closes-sync-iterator.js create mode 100644 test/sendable/builtins/Array/fromAsync/this-constructor-with-unsettable-element.js create mode 100644 test/sendable/builtins/Array/fromAsync/this-constructor.js create mode 100644 test/sendable/builtins/Array/fromAsync/this-non-constructor.js create mode 100644 test/sendable/builtins/Array/fromAsync/thisarg-object.js create mode 100644 test/sendable/builtins/Array/fromAsync/thisarg-omitted-sloppy.js create mode 100644 test/sendable/builtins/Array/fromAsync/thisarg-omitted-strict.js create mode 100644 test/sendable/builtins/Array/fromAsync/thisarg-primitive-sloppy.js create mode 100644 test/sendable/builtins/Array/fromAsync/thisarg-primitive-strict.js create mode 100644 test/sendable/harness/assert-false.js create mode 100644 test/sendable/harness/assert-notsamevalue-nan.js create mode 100644 test/sendable/harness/assert-notsamevalue-notsame.js create mode 100644 test/sendable/harness/assert-notsamevalue-objects.js create mode 100644 test/sendable/harness/assert-notsamevalue-tostring.js create mode 100644 test/sendable/harness/assert-notsamevalue-zeros.js create mode 100644 test/sendable/harness/assert-obj.js create mode 100644 test/sendable/harness/assert-samevalue-nan.js create mode 100644 test/sendable/harness/assert-samevalue-objects.js create mode 100644 test/sendable/harness/assert-samevalue-same.js create mode 100644 test/sendable/harness/assert-samevalue-tostring.js create mode 100644 test/sendable/harness/assert-samevalue-zeros.js create mode 100644 test/sendable/harness/assert-throws-custom-typeerror.js create mode 100644 test/sendable/harness/assert-throws-custom.js create mode 100644 test/sendable/harness/assert-throws-incorrect-ctor.js create mode 100644 test/sendable/harness/assert-throws-native.js create mode 100644 test/sendable/harness/assert-throws-no-arg.js create mode 100644 test/sendable/harness/assert-throws-no-error.js create mode 100644 test/sendable/harness/assert-throws-null-fn.js create mode 100644 test/sendable/harness/assert-throws-null.js create mode 100644 test/sendable/harness/assert-throws-primitive.js create mode 100644 test/sendable/harness/assert-throws-same-realm.js create mode 100644 test/sendable/harness/assert-throws-single-arg.js create mode 100644 test/sendable/harness/assert-tostring.js create mode 100644 test/sendable/harness/assert-true.js create mode 100644 test/sendable/harness/assertRelativeDateMs.js create mode 100644 test/sendable/harness/asyncHelpers-asyncTest-func-throws-sync.js create mode 100644 test/sendable/harness/asyncHelpers-asyncTest-rejects-non-callable.js create mode 100644 test/sendable/harness/asyncHelpers-asyncTest-return-not-thenable.js create mode 100644 test/sendable/harness/asyncHelpers-asyncTest-returns-undefined.js create mode 100644 test/sendable/harness/asyncHelpers-asyncTest-then-rejects.js create mode 100644 test/sendable/harness/asyncHelpers-asyncTest-then-resolves.js create mode 100644 test/sendable/harness/asyncHelpers-asyncTest-without-async-flag.js create mode 100644 test/sendable/harness/asyncHelpers-throwsAsync-custom-typeerror.js create mode 100644 test/sendable/harness/asyncHelpers-throwsAsync-custom.js create mode 100644 test/sendable/harness/asyncHelpers-throwsAsync-func-never-settles.js create mode 100644 test/sendable/harness/asyncHelpers-throwsAsync-func-throws-sync.js create mode 100644 test/sendable/harness/asyncHelpers-throwsAsync-incorrect-ctor.js create mode 100644 test/sendable/harness/asyncHelpers-throwsAsync-invalid-func.js create mode 100644 test/sendable/harness/asyncHelpers-throwsAsync-native.js create mode 100644 test/sendable/harness/asyncHelpers-throwsAsync-no-arg.js create mode 100644 test/sendable/harness/asyncHelpers-throwsAsync-no-error.js create mode 100644 test/sendable/harness/asyncHelpers-throwsAsync-null.js create mode 100644 test/sendable/harness/asyncHelpers-throwsAsync-primitive.js create mode 100644 test/sendable/harness/asyncHelpers-throwsAsync-resolved-error.js create mode 100644 test/sendable/harness/asyncHelpers-throwsAsync-same-realm.js create mode 100644 test/sendable/harness/asyncHelpers-throwsAsync-single-arg.js create mode 100644 test/sendable/harness/byteConversionValues.js create mode 100644 test/sendable/harness/compare-array-arguments.js create mode 100644 test/sendable/harness/compare-array-arraylike.js create mode 100644 test/sendable/harness/compare-array-different-elements.js create mode 100644 test/sendable/harness/compare-array-different-length.js create mode 100644 test/sendable/harness/compare-array-empty.js create mode 100644 test/sendable/harness/compare-array-falsy-arguments.js create mode 100644 test/sendable/harness/compare-array-message.js create mode 100644 test/sendable/harness/compare-array-same-elements-different-order.js create mode 100644 test/sendable/harness/compare-array-same-elements-same-order.js create mode 100644 test/sendable/harness/compare-array-samevalue.js create mode 100644 test/sendable/harness/compare-array-sparse.js create mode 100644 test/sendable/harness/compare-array-symbol.js create mode 100644 test/sendable/harness/dateConstants.js create mode 100644 test/sendable/harness/decimalToHexString.js create mode 100644 test/sendable/harness/deepEqual-array.js create mode 100644 test/sendable/harness/deepEqual-circular.js create mode 100644 test/sendable/harness/deepEqual-deep.js create mode 100644 test/sendable/harness/deepEqual-mapset.js create mode 100644 test/sendable/harness/deepEqual-object.js create mode 100644 test/sendable/harness/deepEqual-primitives-bigint.js create mode 100644 test/sendable/harness/deepEqual-primitives.js create mode 100644 test/sendable/harness/detachArrayBuffer-host-detachArrayBuffer.js create mode 100644 test/sendable/harness/detachArrayBuffer.js create mode 100644 test/sendable/harness/fnGlobalObject.js create mode 100644 test/sendable/harness/isConstructor.js create mode 100644 test/sendable/harness/nans.js create mode 100644 test/sendable/harness/nativeFunctionMatcher.js create mode 100644 test/sendable/harness/promiseHelper.js create mode 100644 test/sendable/harness/propertyhelper-verifyconfigurable-configurable-object.js create mode 100644 test/sendable/harness/propertyhelper-verifyconfigurable-configurable.js create mode 100644 test/sendable/harness/propertyhelper-verifyconfigurable-not-configurable.js create mode 100644 test/sendable/harness/propertyhelper-verifyenumerable-enumerable-symbol.js create mode 100644 test/sendable/harness/propertyhelper-verifyenumerable-enumerable.js create mode 100644 test/sendable/harness/propertyhelper-verifyenumerable-not-enumerable-symbol.js create mode 100644 test/sendable/harness/propertyhelper-verifyenumerable-not-enumerable.js create mode 100644 test/sendable/harness/propertyhelper-verifynotconfigurable-configurable.js create mode 100644 test/sendable/harness/propertyhelper-verifynotconfigurable-not-configurable.js create mode 100644 test/sendable/harness/propertyhelper-verifynotenumerable-enumerable-symbol.js create mode 100644 test/sendable/harness/propertyhelper-verifynotenumerable-enumerable.js create mode 100644 test/sendable/harness/propertyhelper-verifynotenumerable-not-enumerable-symbol.js create mode 100644 test/sendable/harness/propertyhelper-verifynotenumerable-not-enumerable.js create mode 100644 test/sendable/harness/propertyhelper-verifynotwritable-not-writable-strict.js create mode 100644 test/sendable/harness/propertyhelper-verifynotwritable-writable.js create mode 100644 test/sendable/harness/propertyhelper-verifywritable-array-length.js create mode 100644 test/sendable/harness/propertyhelper-verifywritable-not-writable.js create mode 100644 test/sendable/harness/propertyhelper-verifywritable-writable.js create mode 100644 test/sendable/harness/proxytrapshelper-default.js create mode 100644 test/sendable/harness/proxytrapshelper-overrides.js create mode 100644 test/sendable/harness/sta.js create mode 100644 test/sendable/harness/tcoHelper.js create mode 100644 test/sendable/harness/testTypedArray-conversions-call-error.js create mode 100644 test/sendable/harness/testTypedArray-conversions.js create mode 100644 test/sendable/harness/testTypedArray.js create mode 100644 test/sendable/harness/verifyProperty-arguments.js create mode 100644 test/sendable/harness/verifyProperty-configurable-object.js create mode 100644 test/sendable/harness/verifyProperty-desc-is-not-object.js create mode 100644 test/sendable/harness/verifyProperty-noproperty.js create mode 100644 test/sendable/harness/verifyProperty-restore-accessor-symbol.js create mode 100644 test/sendable/harness/verifyProperty-restore-accessor.js create mode 100644 test/sendable/harness/verifyProperty-restore-symbol.js create mode 100644 test/sendable/harness/verifyProperty-restore.js create mode 100644 test/sendable/harness/verifyProperty-same-value.js create mode 100644 test/sendable/harness/verifyProperty-string-prop.js create mode 100644 test/sendable/harness/verifyProperty-symbol-prop.js create mode 100644 test/sendable/harness/verifyProperty-undefined-desc.js create mode 100644 test/sendable/harness/verifyProperty-value-error.js create mode 100644 test/sendable/harness/verifyProperty-value.js diff --git a/test/sendable/builtins/Array/fromAsync/async-iterable-async-mapped-awaits-once.js b/test/sendable/builtins/Array/fromAsync/async-iterable-async-mapped-awaits-once.js new file mode 100644 index 00000000000..1a2f0ef6768 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/async-iterable-async-mapped-awaits-once.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Async-iterable awaits each input once with mapping callback +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + async function* generateInput () { + yield* [ 0, 1, 2 ]; + } + const input = generateInput(); + let awaitCounter = 0; + await SendableArray.fromAsync(input, v => { + return { + // This “then” method should occur three times: + // one for each value from the input. + then (resolve, reject) { + awaitCounter ++; + resolve(v); + }, + }; + }); + assert.sameValue(awaitCounter, 3); +}); diff --git a/test/sendable/builtins/Array/fromAsync/async-iterable-input-does-not-await-input.js b/test/sendable/builtins/Array/fromAsync/async-iterable-input-does-not-await-input.js new file mode 100644 index 00000000000..cf3e975b7a9 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/async-iterable-input-does-not-await-input.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Async-iterable input does not await input values. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const prom = Promise.resolve({}); + const expected = [ prom ]; + function createInput () { + return { + // The following async iterator will yield one value + // (the promise named “prom”). + [Symbol.asyncIterator]() { + let i = 0; + return { + async next() { + if (i > 0) { + return { done: true }; + } + i++; + return { value: prom, done: false } + }, + }; + }, + }; + } + const input = createInput(); + const output = await SendableArray.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/test/sendable/builtins/Array/fromAsync/async-iterable-input-iteration-err.js b/test/sendable/builtins/Array/fromAsync/async-iterable-input-iteration-err.js new file mode 100644 index 00000000000..6bdc50984bd --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/async-iterable-input-iteration-err.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync promise rejects if iteration of input fails. +flags: [async] +features: [SendableArray.fromAsync] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + async function *generateInput () { + throw new Test262Error('This error should be propagated.'); + } + const input = generateInput(); + const outputPromise = SendableArray.fromAsync(input); + await assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/test/sendable/builtins/Array/fromAsync/async-iterable-input.js b/test/sendable/builtins/Array/fromAsync/async-iterable-input.js new file mode 100644 index 00000000000..3e7bb8a0cb7 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/async-iterable-input.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Async-iterable input is transferred to the output array. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expected = [ 0, 1, 2 ]; + async function* generateInput () { + yield* expected; + } + const input = generateInput(); + const output = await SendableArray.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-array-add-to-empty.js b/test/sendable/builtins/Array/fromAsync/asyncitems-array-add-to-empty.js new file mode 100644 index 00000000000..7912ad5162e --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-array-add-to-empty.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync respects array mutation +info: | + SendableArray.fromAsync + 3.j.ii.3. Let next be Await(IteratorStep(iteratorRecord)). + IteratorStep + 1. Let result be IteratorNext(iteratorRecord). + IteratorNext + 1.a. Let result be Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + %AsyncFromSyncIteratorPrototype%.next + 6.a. Let result be Completion(IteratorNext(syncIteratorRecord)). + IteratorNext + 1.a. Let result be Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + Array.prototype [ @@iterator ] ( ) + Array.prototype.values ( ) + 2. Return CreateArrayIterator(O, value). + CreateArrayIterator + 1.b.iii. If index ≥ len, return NormalCompletion(undefined). +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const items = []; + const promise = SendableArray.fromAsync(items); + // By the time we get here, the first next() call has already happened, and returned + // { done: true }. We then return from the loop in Array.fromAsync 3.j.ii. with the empty array, + // and the following line no longer affects that. + items.push(7); + const result = await promise; + assert.compareArray(result, []); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-array-add-to-singleton.js b/test/sendable/builtins/Array/fromAsync/asyncitems-array-add-to-singleton.js new file mode 100644 index 00000000000..d47342df042 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-array-add-to-singleton.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync respects array mutation +info: | + SendableArray.fromAsync + 3.j.ii.3. Let next be Await(IteratorStep(iteratorRecord)). + IteratorStep + 1. Let result be IteratorNext(iteratorRecord). + IteratorNext + 1.a. Let result be Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + %AsyncFromSyncIteratorPrototype%.next + 6.a. Let result be Completion(IteratorNext(syncIteratorRecord)). + IteratorNext + 1.a. Let result be Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + Array.prototype [ @@iterator ] ( ) + Array.prototype.values ( ) + 2. Return CreateArrayIterator(O, value). + CreateArrayIterator + 1.b.iii. If index ≥ len, return NormalCompletion(undefined). +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const items = [1]; + const promise = SendableArray.fromAsync(items); + // At this point, the first element of `items` has been read, but the iterator will take other + // changes into account. + items.push(7); + const result = await promise; + assert.compareArray(result, [1, 7]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-array-add.js b/test/sendable/builtins/Array/fromAsync/asyncitems-array-add.js new file mode 100644 index 00000000000..97ffe13d31f --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-array-add.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Array.fromAsync respects array mutation +info: | + Array.fromAsync + 3.j.ii.3. Let next be ? Await(IteratorStep(iteratorRecord)). + IteratorStep + 1. Let result be ? IteratorNext(iteratorRecord). + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + %AsyncFromSyncIteratorPrototype%.next + 6.a. Let result be Completion(IteratorNext(syncIteratorRecord)). + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + Array.prototype [ @@iterator ] ( ) + Array.prototype.values ( ) + 2. Return CreateArrayIterator(O, value). + CreateArrayIterator + 1.b.iii. If index ≥ len, return NormalCompletion(undefined). +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const items = [1, 2, 3]; + const promise = SendableArray.fromAsync(items); + // At this point, the first element of `items` has been read, but the iterator will take other + // changes into account. + items.push(4); + const result = await promise; + assert.compareArray(result, [1, 2, 3, 4]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-array-mutate.js b/test/sendable/builtins/Array/fromAsync/asyncitems-array-mutate.js new file mode 100644 index 00000000000..5292c8b3b77 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-array-mutate.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.fromasync +description: > + SendableArray.fromAsync respects array mutation +info: | + SendableArray.fromAsync + 3.j.ii.3. Let next be ? Await(IteratorStep(iteratorRecord)). + IteratorStep + 1. Let result be ? IteratorNext(iteratorRecord). + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + %AsyncFromSyncIteratorPrototype%.next + 6.a. Let result be Completion(IteratorNext(syncIteratorRecord)). + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + Array.prototype [ @@iterator ] ( ) + Array.prototype.values ( ) + 2. Return CreateArrayIterator(O, value). + CreateArrayIterator + 1.b.iii. If index ≥ len, return NormalCompletion(undefined). +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const items = [1, 2, 3]; + const promise = SendableArray.fromAsync(items); + // At this point, the first element of `items` has been read, but the iterator will take other + // changes into account. + items[0] = 7; + items[1] = 8; + const result = await promise; + assert.compareArray(result, [1, 8, 3]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-array-remove.js b/test/sendable/builtins/Array/fromAsync/asyncitems-array-remove.js new file mode 100644 index 00000000000..32491a6932a --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-array-remove.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync respects array mutation +info: | + SendableArray.fromAsync + 3.j.ii.3. Let next be ? Await(IteratorStep(iteratorRecord)). + IteratorStep + 1. Let result be ? IteratorNext(iteratorRecord). + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + %AsyncFromSyncIteratorPrototype%.next + 6.a. Let result be Completion(IteratorNext(syncIteratorRecord)). + IteratorNext + 1.a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]]). + Array.prototype [ @@iterator ] ( ) + Array.prototype.values ( ) + 2. Return CreateArrayIterator(O, value). + CreateArrayIterator + 1.b.iii. If index ≥ len, return NormalCompletion(undefined). +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [Array.fromAsync] +---*/ + +asyncTest(async function () { + const items = [1, 2, 3]; + const promise = SendableArray.fromAsync(items); + // At this point, the first element of `items` has been read, but the iterator will take other + // changes into account. + items.pop(); + const result = await promise; + assert.compareArray(result, [1, 2]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-arraybuffer.js b/test/sendable/builtins/Array/fromAsync/asyncitems-arraybuffer.js new file mode 100644 index 00000000000..515abad4663 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-arraybuffer.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync doesn't special-case ArrayBuffer +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const items = new ArrayBuffer(7); + const result = await SendableArray.fromAsync(items); + assert.compareArray(result, []); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-holes.js b/test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-holes.js new file mode 100644 index 00000000000..91b9927fea7 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-holes.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Array-like object with holes treats the holes as undefined +info: | + 3.k.vii.2. Let _kValue_ be ? Get(_arrayLike_, _Pk_). +features: [Array.fromAsync] +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +---*/ + +asyncTest(async function () { + const arrayLike = Object.create(null); + arrayLike.length = 5; + arrayLike[0] = 0; + arrayLike[1] = 1; + arrayLike[2] = 2; + arrayLike[4] = 4; + const array = await SendableArray.fromAsync(arrayLike); + assert.compareArray(array, [0, 1, 2, undefined, 4], "holes in array-like treated as undefined"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-length-accessor-throws.js b/test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-length-accessor-throws.js new file mode 100644 index 00000000000..1f7be51b408 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-length-accessor-throws.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Rejects on array-like object whose length cannot be gotten +info: | + 3.k.iii. Let _len_ be ? LengthOfArrayLike(_arrayLike_). +features: [SendableArray.fromAsync] +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + await assert.throwsAsync(Test262Error, () => SendableArray.fromAsync({ + get length() { + throw new Test262Error('accessing length property fails'); + } + }), "Promise should be rejected if array-like length getter throws"); + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync({ + length: 1n, + 0: 0 + }), "Promise should be rejected if array-like length can't be converted to a number"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-promise.js b/test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-promise.js new file mode 100644 index 00000000000..0a0ac1a75bc --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-promise.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync tries the various properties in order and awaits promises +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const actual = []; + const items = TemporalHelpers.propertyBagObserver(actual, { + length: 2, + 0: Promise.resolve(2), + 1: Promise.resolve(1), + }, "items"); + const result = await SendableArray.fromAsync(items); + assert.compareArray(result, [2, 1]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + "get items[Symbol.iterator]", + "get items.length", + "get items.length.valueOf", + "call items.length.valueOf", + "get items[0]", + "get items[1]", + ]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-too-long.js b/test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-too-long.js new file mode 100644 index 00000000000..eefeaf9406a --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-arraylike-too-long.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Promise is rejected if the length of the array-like to copy is out of range +info: | + j. If _iteratorRecord_ is not *undefined*, then + k. Else, + iv. If IsConstructor(_C_) is *true*, then + v. Else, + 1. Let _A_ be ? ArrayCreate(_len_). + ArrayCreate, step 1: + 1. If _length_ > 2³² - 1, throw a *RangeError* exception. +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const notConstructor = {}; + await assert.throwsAsync(RangeError, () => SendableArray.fromAsync.call(notConstructor, { + length: 4294967296 // 2³² + }), "Array-like with excessive length"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-exists.js b/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-exists.js new file mode 100644 index 00000000000..4d0f93b6055 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-exists.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync tries the various properties in order +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + async function * asyncGen() { + for (let i = 0; i < 4; i++) { + yield Promise.resolve(i * 2); + } + } + const actual = []; + const items = {}; + TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, asyncGen, "items"); + TemporalHelpers.observeProperty(actual, items, Symbol.iterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, "length", 2, "items"); + TemporalHelpers.observeProperty(actual, items, 0, 2, "items"); + TemporalHelpers.observeProperty(actual, items, 1, 1, "items"); + const result = await SendableArray.fromAsync(items); + assert.compareArray(result, [0, 2, 4, 6]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + ]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-not-callable.js b/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-not-callable.js new file mode 100644 index 00000000000..1b2b6c28dc1 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-not-callable.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync rejects if the @@asyncIterator property is not callable +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + for (const v of [true, "", Symbol(), 1, 1n, {}]) { + await assert.throwsAsync(TypeError, + () => SendableArray.fromAsync({ [Symbol.asyncIterator]: v }), + `@@asyncIterator = ${typeof v}`); + } +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-null.js b/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-null.js new file mode 100644 index 00000000000..a86aa1fb36a --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-null.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync tries the various properties in order +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const actual = []; + const items = {}; + TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, null, "items"); + TemporalHelpers.observeProperty(actual, items, Symbol.iterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, "length", 2, "items"); + TemporalHelpers.observeProperty(actual, items, 0, 2, "items"); + TemporalHelpers.observeProperty(actual, items, 1, 1, "items"); + const result = await SendableArray.fromAsync(items); + assert.compareArray(result, [2, 1]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + "get items[Symbol.iterator]", + "get items.length", + "get items[0]", + "get items[1]", + ]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-sync.js b/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-sync.js new file mode 100644 index 00000000000..3fedc9bce40 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-sync.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync handles a sync iterator returned from @@asyncIterator +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + function * syncGen() { + for (let i = 0; i < 4; i++) { + yield i * 2; + } + } + const actual = []; + const items = {}; + TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, syncGen, "items"); + TemporalHelpers.observeProperty(actual, items, Symbol.iterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, "length", 2, "items"); + TemporalHelpers.observeProperty(actual, items, 0, 2, "items"); + TemporalHelpers.observeProperty(actual, items, 1, 1, "items"); + const result = await SendableArray.fromAsync(items); + assert.compareArray(result, [0, 2, 4, 6]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + ]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-throws.js b/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-throws.js new file mode 100644 index 00000000000..35c1d001817 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-asynciterator-throws.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync rejects if getting the @@asyncIterator property throws +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + await assert.throwsAsync(Test262Error, + () => SendableArray.fromAsync({ get [Symbol.asyncIterator]() { throw new Test262Error() } })); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-bigint.js b/test/sendable/builtins/Array/fromAsync/asyncitems-bigint.js new file mode 100644 index 00000000000..e1f6b0b88aa --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-bigint.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync treats a BigInt as an array-like +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + BigInt.prototype.length = 2; + BigInt.prototype[0] = 1; + BigInt.prototype[1] = 2; + const result = await SendableArray.fromAsync(1n); + assert.compareArray(result, [1, 2]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-boolean.js b/test/sendable/builtins/Array/fromAsync/asyncitems-boolean.js new file mode 100644 index 00000000000..b78589b9e82 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-boolean.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync treats a boolean as an array-like +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + Boolean.prototype.length = 2; + Boolean.prototype[0] = 1; + Boolean.prototype[1] = 2; + const result = await SendableArray.fromAsync(true); + assert.compareArray(result, [1, 2]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-function.js b/test/sendable/builtins/Array/fromAsync/asyncitems-function.js new file mode 100644 index 00000000000..13ef3bad790 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-function.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync treats a function as an array-like, reading elements up to fn.length +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const fn = function(a, b) {}; + fn[0] = 1; + fn[1] = 2; + fn[2] = 3; + const result = await SendableArray.fromAsync(fn); + assert.compareArray(result, [1, 2]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-exists.js b/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-exists.js new file mode 100644 index 00000000000..2d76eeee135 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-exists.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync handles a sync iterator returned from @@iterator +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + function * syncGen() { + for (let i = 0; i < 4; i++) { + yield i * 2; + } + } + const actual = []; + const items = {}; + TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, Symbol.iterator, syncGen, "items"); + TemporalHelpers.observeProperty(actual, items, "length", 2, "items"); + TemporalHelpers.observeProperty(actual, items, 0, 2, "items"); + TemporalHelpers.observeProperty(actual, items, 1, 1, "items"); + const result = await SendableArray.fromAsync(items); + assert.compareArray(result, [0, 2, 4, 6]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + "get items[Symbol.iterator]", + ]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-not-callable.js b/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-not-callable.js new file mode 100644 index 00000000000..56b19682f00 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-not-callable.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync rejects if the @@iterator property is not callable +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + for (const v of [true, "", Symbol(), 1, 1n, {}]) { + await assert.throwsAsync(TypeError, + () => SendableArray.fromAsync({ [Symbol.iterator]: v }), + `@@iterator = ${typeof v}`); + } +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-null.js b/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-null.js new file mode 100644 index 00000000000..04b6d506274 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-null.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync tries the various properties in order +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const actual = []; + const items = {}; + TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, Symbol.iterator, null, "items"); + TemporalHelpers.observeProperty(actual, items, "length", 2, "items"); + TemporalHelpers.observeProperty(actual, items, 0, 2, "items"); + TemporalHelpers.observeProperty(actual, items, 1, 1, "items"); + const result = await SendableArray.fromAsync(items); + assert.compareArray(result, [2, 1]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + "get items[Symbol.iterator]", + "get items.length", + "get items[0]", + "get items[1]", + ]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-promise.js b/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-promise.js new file mode 100644 index 00000000000..da9d9cf2a4c --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-promise.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync handles an async iterator returned from @@iterator +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + function * asyncGen() { + for (let i = 0; i < 4; i++) { + yield Promise.resolve(i * 2); + } + } + const actual = []; + const items = {}; + TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, Symbol.iterator, asyncGen, "items"); + TemporalHelpers.observeProperty(actual, items, "length", 2, "items"); + TemporalHelpers.observeProperty(actual, items, 0, 2, "items"); + TemporalHelpers.observeProperty(actual, items, 1, 1, "items"); + const result = await SendableArray.fromAsync(items); + assert.compareArray(result, [0, 2, 4, 6]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + "get items[Symbol.iterator]", + ]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-throws.js b/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-throws.js new file mode 100644 index 00000000000..9915b6dc4d1 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-iterator-throws.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync rejects if getting the @@iterator property throws +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + await assert.throwsAsync(Test262Error, + () => SendableArray.fromAsync({ get [Symbol.iterator]() { throw new Test262Error() } })); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-null-undefined.js b/test/sendable/builtins/Array/fromAsync/asyncitems-null-undefined.js new file mode 100644 index 00000000000..3fc9978441d --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-null-undefined.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync rejects with a TypeError if the asyncItems argument is null or undefined +info: | + 3.c. Let usingAsyncIterator be ? GetMethod(asyncItems, @@asyncIterator). +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync(null), "null asyncItems"); + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync(undefined), "undefined asyncItems"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-number.js b/test/sendable/builtins/Array/fromAsync/asyncitems-number.js new file mode 100644 index 00000000000..4b2c5eea249 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-number.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync treats a Number as an array-like +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + Number.prototype.length = 2; + Number.prototype[0] = 1; + Number.prototype[1] = 2; + const result = await SendableArray.fromAsync(1); + assert.compareArray(result, [1, 2]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-object-not-arraylike.js b/test/sendable/builtins/Array/fromAsync/asyncitems-object-not-arraylike.js new file mode 100644 index 00000000000..e7005b29bcc --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-object-not-arraylike.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Treats an asyncItems object that isn't an array-like as a 0-length array-like +info: | + 3.k.iii. Let _len_ be ? LengthOfArrayLike(_arrayLike_). +features: [SendableArray.fromAsync] +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +---*/ + +asyncTest(async function () { + const notArrayLike = Object.create(null); + notArrayLike[0] = 0; + notArrayLike[1] = 1; + notArrayLike[2] = 2; + const array = await SendableArray.fromAsync(notArrayLike); + assert.compareArray(array, [], "non-array-like object is treated as 0-length array-like"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-operations.js b/test/sendable/builtins/Array/fromAsync/asyncitems-operations.js new file mode 100644 index 00000000000..8be0b6b425f --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-operations.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync tries the various properties in order +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const actual = []; + const items = {}; + TemporalHelpers.observeProperty(actual, items, Symbol.asyncIterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, Symbol.iterator, undefined, "items"); + TemporalHelpers.observeProperty(actual, items, "length", 2, "items"); + TemporalHelpers.observeProperty(actual, items, 0, 2, "items"); + TemporalHelpers.observeProperty(actual, items, 1, 1, "items"); + const result = await SendableArray.fromAsync(items); + assert.compareArray(result, [2, 1]); + assert.compareArray(actual, [ + "get items[Symbol.asyncIterator]", + "get items[Symbol.iterator]", + "get items.length", + "get items[0]", + "get items[1]", + ]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-string.js b/test/sendable/builtins/Array/fromAsync/asyncitems-string.js new file mode 100644 index 00000000000..f971ba5a047 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-string.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync iterates over a string +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const result = await SendableArray.fromAsync("test"); + assert.compareArray(result, ["t", "e", "s", "t"]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-symbol.js b/test/sendable/builtins/Array/fromAsync/asyncitems-symbol.js new file mode 100644 index 00000000000..59062ae56fe --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-symbol.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + SendableArray.fromAsync treats a Symbol as an array-like +includes: [asyncHelpers.js, compareArray.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + Symbol.prototype.length = 2; + Symbol.prototype[0] = 1; + Symbol.prototype[1] = 2; + const result = await SendableArray.fromAsync(Symbol()); + assert.compareArray(result, [1, 2]); +}); diff --git a/test/sendable/builtins/Array/fromAsync/asyncitems-uses-intrinsic-iterator-symbols.js b/test/sendable/builtins/Array/fromAsync/asyncitems-uses-intrinsic-iterator-symbols.js new file mode 100644 index 00000000000..7b51b4879c9 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/asyncitems-uses-intrinsic-iterator-symbols.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Use the intrinsic @@iterator and @@asyncIterator to check iterability +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + // Replace the user-reachable Symbol.iterator and Symbol.asyncIterator with + // fake symbol keys + const originalSymbol = globalThis.Symbol; + const fakeIteratorSymbol = Symbol("iterator"); + const fakeAsyncIteratorSymbol = Symbol("asyncIterator"); + globalThis.Symbol = { + iterator: fakeIteratorSymbol, + asyncIterator: fakeAsyncIteratorSymbol, + }; + const input = { + length: 3, + 0: 0, + 1: 1, + 2: 2, + [fakeIteratorSymbol]() { + throw new Test262Error("The fake Symbol.iterator method should not be called"); + }, + [fakeAsyncIteratorSymbol]() { + throw new Test262Error("The fake Symbol.asyncIterator method should not be called"); + } + }; + const output = await SendableArray.fromAsync(input); + assert.compareArray(output, [0, 1, 2]); + globalThis.Symbol = originalSymbol; +}); diff --git a/test/sendable/builtins/Array/fromAsync/builtin.js b/test/sendable/builtins/Array/fromAsync/builtin.js new file mode 100644 index 00000000000..b26b5cd2b66 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/builtin.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: SendableArray.fromAsync meets the requirements for built-in objects +info: | + Unless specified otherwise, a built-in object that is callable as a function + is a built-in function object with the characteristics described in 10.3. + Unless specified otherwise, the [[Extensible]] internal slot of a built-in + object initially has the value *true*. + Unless otherwise specified every built-in function and every built-in + constructor has the Function prototype object, which is the initial value of + the expression Function.prototype (20.2.3), as the value of its [[Prototype]] + internal slot. + Built-in functions that are not constructors do not have a "prototype" + property unless otherwise specified in the description of a particular + function. +features: [SendableArray.fromAsync] +---*/ + +assert(Object.isExtensible(SendableArray.fromAsync), "Array.fromAsync is extensible"); +assert.sameValue( + Object.getPrototypeOf(ArrSendableArrayay.fromAsync), + Function.prototype, + "Prototype of Array.fromAsync is Function.prototype" +); +assert.sameValue( + Object.getOwnPropertyDescriptor(SendableArray.fromAsync, "prototype"), + undefined, + "Array.fromAsync has no own prototype property" +); diff --git a/test/sendable/builtins/Array/fromAsync/length.js b/test/sendable/builtins/Array/fromAsync/length.js new file mode 100644 index 00000000000..01abbccdd8f --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/length.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Value and property descriptor of SendableArray.fromAsync.length +info: | + Every built-in function object, including constructors, has a *"length"* + property whose value is a non-negative integral Number. Unless otherwise + specified, this value is equal to the number of required parameters shown in + the subclause heading for the function description. Optional parameters and + rest parameters are not included in the parameter 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] +features: [SendableArray.fromAsync] +---*/ + +verifyProperty(SendableArray.fromAsync, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/fromAsync/mapfn-async-arraylike.js b/test/sendable/builtins/Array/fromAsync/mapfn-async-arraylike.js new file mode 100644 index 00000000000..e3901be6842 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/mapfn-async-arraylike.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + An asynchronous mapping function is applied to each (awaited) item of an + arraylike. +info: | + 3.k.vii.4. If _mapping_ is *true*, then + a. Let _mappedValue_ be ? Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + b. Let _mappedValue_ be ? Await(_mappedValue_). + ... + 6. Perform ? CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +features: [SendableArray.fromAsync] +---*/ + +const arrayLike = { + length: 4, + 0: 0, + 1: 2, + 2: Promise.resolve(4), + 3: 6, +}; +async function asyncMap(val, ix) { + return Promise.resolve(val * ix); +} +asyncTest(async () => { + const result = await SendableArray.fromAsync(arrayLike, asyncMap); + assert.compareArray(result, [0, 2, 8, 18], "async mapfn should be applied to arraylike"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/mapfn-async-iterable-async.js b/test/sendable/builtins/Array/fromAsync/mapfn-async-iterable-async.js new file mode 100644 index 00000000000..8c5ed6db4d4 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/mapfn-async-iterable-async.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + An asynchronous mapping function is applied to each item yielded by an + asynchronous iterable. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + ... + c. Set _mappedValue_ to Await(_mappedValue_). + ... + ... + 8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +features: [SendableArray.fromAsync] +---*/ + +async function* asyncGen() { + for (let i = 0; i < 4; i++) { + yield Promise.resolve(i * 2); + } +} +async function asyncMap(val, ix) { + return Promise.resolve(val * ix); +} +asyncTest(async () => { + const result = await SendableArray.fromAsync({ [Symbol.asyncIterator]: asyncGen }, asyncMap); + assert.compareArray(result, [0, 2, 8, 18], "async mapfn should be applied to async iterable"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/mapfn-async-iterable-sync.js b/test/sendable/builtins/Array/fromAsync/mapfn-async-iterable-sync.js new file mode 100644 index 00000000000..87c923299b4 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/mapfn-async-iterable-sync.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + An asynchronous mapping function is applied to each item yielded by a + synchronous iterable. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + c. Set _mappedValue_ to Await(_mappedValue_). + 8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +features: [SendableArray.fromAsync] +---*/ + +function* syncGen() { + for (let i = 0; i < 4; i++) { + yield i * 2; + } +} +async function asyncMap(val, ix) { + return Promise.resolve(val * ix); +} +asyncTest(async () => { + const result = await SendableArray.fromAsync({ [Symbol.iterator]: syncGen }, asyncMap); + assert.compareArray(result, [0, 2, 8, 18], "async mapfn should be applied to sync iterable"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/mapfn-async-throws-close-async-iterator.js b/test/sendable/builtins/Array/fromAsync/mapfn-async-throws-close-async-iterator.js new file mode 100644 index 00000000000..38c8a37be04 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/mapfn-async-throws-close-async-iterator.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + The iterator of an asynchronous iterable is closed when the asynchronous + mapping function throws. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + c. Set _mappedValue_ to Await(_mappedValue_). + d. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_). +flags: [async] +includes: [asyncHelpers.js] +features: [SendableArray.fromAsync] +---*/ + +let closed = false; +const iterator = { + next() { + return Promise.resolve({ value: 1, done: false }); + }, + return() { + closed = true; + return Promise.resolve({ done: true }); + }, + [Symbol.asyncIterator]() { + return this; + } +} +asyncTest(async () => { + await assert.throwsAsync(Error, () => SendableArray.fromAsync(iterator, async (val) => { + assert.sameValue(val, 1, "mapfn receives value from iterator"); + throw new Error("mapfn throws"); + }), "async mapfn rejecting should cause fromAsync to reject"); + assert(closed, "async mapfn rejecting should close iterator") +}); diff --git a/test/sendable/builtins/Array/fromAsync/mapfn-async-throws-close-sync-iterator.js b/test/sendable/builtins/Array/fromAsync/mapfn-async-throws-close-sync-iterator.js new file mode 100644 index 00000000000..fa2a256474b --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/mapfn-async-throws-close-sync-iterator.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + The iterator of a synchronous iterable is closed when the asynchronous mapping + function throws. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + ... + c. Set _mappedValue_ to Await(_mappedValue_). + d. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_). +flags: [async] +includes: [asyncHelpers.js] +features: [SendableArray.fromAsync] +---*/ + +let closed = false; +const iterator = { + next() { + return { value: 1, done: false }; + }, + return() { + closed = true; + return { done: true }; + }, + [Symbol.iterator]() { + return this; + } +} +asyncTest(async () => { + await assert.throwsAsync(Error, () => SendableArray.fromAsync(iterator, async (val) => { + assert.sameValue(val, 1, "mapfn receives value from iterator"); + throw new Error("mapfn throws"); + }), "async mapfn rejecting should cause fromAsync to reject"); + assert(closed, "async mapfn rejecting should close iterator") +}); diff --git a/test/sendable/builtins/Array/fromAsync/mapfn-async-throws.js b/test/sendable/builtins/Array/fromAsync/mapfn-async-throws.js new file mode 100644 index 00000000000..7dc188d365c --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/mapfn-async-throws.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + The output promise rejects if the asynchronous mapping function rejects. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + ... + c. Set _mappedValue_ to Await(_mappedValue_). + d. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_). +flags: [async] +includes: [asyncHelpers.js] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async () => { + await assert.throwsAsync(Test262Error, () => SendableArray.fromAsync([1, 2, 3], async () => { + throw new Test262Error("mapfn throws"); + }), "async mapfn rejecting should cause fromAsync to reject"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/mapfn-not-callable.js b/test/sendable/builtins/Array/fromAsync/mapfn-not-callable.js new file mode 100644 index 00000000000..ed1a5ee0965 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/mapfn-not-callable.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + A TypeError is thrown if the mapfn argument to Array.fromAsync is not callable +info: | + 3.a. If _mapfn_ is *undefined*, let _mapping_ be *false*. + b. Else, + i. If IsCallable(_mapfn_) is *false*, throw a *TypeError* exception. +flags: [async] +includes: [asyncHelpers.js] +features: [SendableArray.fromAsync, BigInt, Symbol] +---*/ + +asyncTest(async () => { + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync([], null), "null mapfn"); + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync([], {}), "non-callable object mapfn"); + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync([], "String"), "string mapfn"); + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync([], true), "boolean mapfn"); + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync([], 3.1416), "number mapfn"); + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync([], 42n), "bigint mapfn"); + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync([], Symbol()), "symbol mapfn"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/mapfn-result-awaited-once-per-iteration.js b/test/sendable/builtins/Array/fromAsync/mapfn-result-awaited-once-per-iteration.js new file mode 100644 index 00000000000..3733267461e --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/mapfn-result-awaited-once-per-iteration.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + The returned value from each invocation of the asynchronous mapping function + is awaited exactly once. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + c. Set _mappedValue_ to Await(_mappedValue_). +flags: [async] +includes: [asyncHelpers.js, compareArray.js, temporalHelpers.js] +features: [SendableArray.fromAsync] +---*/ + +const calls = []; +const expected = [ + "call mapping", + "get thenable_0.then", + "call thenable_0.then", + "call mapping", + "get thenable_1.then", + "call thenable_1.then", + "call mapping", + "get thenable_2.then", + "call thenable_2.then", +]; +function mapping(val, ix) { + calls.push("call mapping"); + const thenableName = `thenable_${ix}`; + return TemporalHelpers.propertyBagObserver(calls, { + then(resolve, reject) { + calls.push(`call ${thenableName}.then`); + resolve(val * 2); + } + }, thenableName) +} +asyncTest(async () => { + const result = await SendableArray.fromAsync([1, 2, 3], mapping); + assert.compareArray(result, [2, 4, 6], "mapping function applied"); + assert.compareArray(calls, expected, "observable operations"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/mapfn-sync-arraylike.js b/test/sendable/builtins/Array/fromAsync/mapfn-sync-arraylike.js new file mode 100644 index 00000000000..f85da96cc73 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/mapfn-sync-arraylike.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + A synchronous mapping function is applied to each (awaited) item of an + arraylike. +info: | + 3.k.vii.4. If _mapping_ is *true*, then + a. Let _mappedValue_ be ? Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + 6. Perform ? CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +features: [SendableArray.fromAsync] +---*/ + +const arrayLike = { + length: 4, + 0: 0, + 1: 2, + 2: Promise.resolve(4), + 3: 6, +}; +function syncMap(val, ix) { + return val * ix; +} +asyncTest(async () => { + const result = await SendableArray.fromAsync(arrayLike, syncMap); + assert.compareArray(result, [0, 2, 8, 18], "sync mapfn should be applied to arraylike"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/mapfn-sync-iterable-async.js b/test/sendable/builtins/Array/fromAsync/mapfn-sync-iterable-async.js new file mode 100644 index 00000000000..452255a632e --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/mapfn-sync-iterable-async.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + A synchronous mapping function is applied to each item yielded by an + asynchronous iterable. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + ... + ... + 8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +features: [SendableArray.fromAsync] +---*/ + +async function* asyncGen() { + for (let i = 0; i < 4; i++) { + yield Promise.resolve(i * 2); + } +} +function syncMap(val, ix) { + return val * ix; +} +asyncTest(async () => { + const result = await SendableArray.fromAsync({ [Symbol.asyncIterator]: asyncGen }, syncMap); + assert.compareArray(result, [0, 2, 8, 18], "sync mapfn should be applied to async iterable"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/mapfn-sync-iterable-sync.js b/test/sendable/builtins/Array/fromAsync/mapfn-sync-iterable-sync.js new file mode 100644 index 00000000000..1a94eadbaa5 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/mapfn-sync-iterable-sync.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + A synchronous mapping function is applied to each item yielded by a + synchronous iterable. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + 8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +features: [SendableArray.fromAsync] +---*/ + +function* syncGen() { + for (let i = 0; i < 4; i++) { + yield i * 2; + } +} +function syncMap(val, ix) { + return val * ix; +} +asyncTest(async () => { + const result = await SendableArray.fromAsync({ [Symbol.iterator]: syncGen }, syncMap); + assert.compareArray(result, [0, 2, 8, 18], "sync mapfn should be applied to sync iterable"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/mapfn-sync-throws-close-async-iterator.js b/test/sendable/builtins/Array/fromAsync/mapfn-sync-throws-close-async-iterator.js new file mode 100644 index 00000000000..34414ddbf25 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/mapfn-sync-throws-close-async-iterator.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + The iterator of an asynchronous iterable is closed when the synchronous + mapping function throws. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + b. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_). + ... +flags: [async] +includes: [asyncHelpers.js] +features: [SendableArray.fromAsync] +---*/ + +let closed = false; +const iterator = { + next() { + return Promise.resolve({ value: 1, done: false }); + }, + return() { + closed = true; + return Promise.resolve({ done: true }); + }, + [Symbol.asyncIterator]() { + return this; + } +} +asyncTest(async () => { + await assert.throwsAsync(Error, () => SendableArray.fromAsync(iterator, (val) => { + assert.sameValue(val, 1, "mapfn receives value from iterator"); + throw new Error("mapfn throws"); + }), "sync mapfn throwing should cause fromAsync to reject"); + assert(closed, "sync mapfn throwing should close iterator") +}); diff --git a/test/sendable/builtins/Array/fromAsync/mapfn-sync-throws-close-sync-iterator.js b/test/sendable/builtins/Array/fromAsync/mapfn-sync-throws-close-sync-iterator.js new file mode 100644 index 00000000000..6c7eca55107 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/mapfn-sync-throws-close-sync-iterator.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + The iterator of a synchronous iterable is closed when the synchronous mapping + function throws. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + b. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_). + ... +flags: [async] +includes: [asyncHelpers.js] +features: [SendableArray.fromAsync] +---*/ + +let closed = false; +const iterator = { + next() { + return { value: 1, done: false }; + }, + return() { + closed = true; + return { done: true }; + }, + [Symbol.iterator]() { + return this; + } +} +asyncTest(async () => { + await assert.throwsAsync(Error, () => SendableArray.fromAsync(iterator, (val) => { + assert.sameValue(val, 1, "mapfn receives value from iterator"); + throw new Error("mapfn throws"); + }), "sync mapfn throwing should cause fromAsync to reject"); + assert(closed, "sync mapfn throwing should close iterator") +}); diff --git a/test/sendable/builtins/Array/fromAsync/mapfn-sync-throws.js b/test/sendable/builtins/Array/fromAsync/mapfn-sync-throws.js new file mode 100644 index 00000000000..89701e78e1d --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/mapfn-sync-throws.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + The output promise rejects if the synchronous mapping function throws. +info: | + 3.j.ii.6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + b. IfAbruptCloseAsyncIterator(_mappedValue_, _iteratorRecord_). + ... +flags: [async] +includes: [asyncHelpers.js] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async () => { + await assert.throwsAsync(Test262Error, () => SendableArray.fromAsync([1, 2, 3], () => { + throw new Test262Error("mapfn throws"); + }), "sync mapfn throwing should cause fromAsync to reject"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/name.js b/test/sendable/builtins/Array/fromAsync/name.js new file mode 100644 index 00000000000..59d1a87c894 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/name.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Value and property descriptor of Array.fromAsync.name +info: | + Every built-in function object, including constructors, has a *"name"* + property whose value is a String. Unless otherwise specified, this value is + the name that is given to the function in this specification. [...] + For functions that are specified as properties of objects, the name value is + the property name string used to access the function. + + Unless otherwise specified, the *"name"* property of a built-in function + object has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, + [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [SendableArray.fromAsync] +---*/ + +verifyProperty(SendableArray.fromAsync, "name", { + value: "fromAsync", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/fromAsync/non-iterable-input-does-not-use-array-prototype.js b/test/sendable/builtins/Array/fromAsync/non-iterable-input-does-not-use-array-prototype.js new file mode 100644 index 00000000000..11e27d2f241 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/non-iterable-input-does-not-use-array-prototype.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Non-iterable input does not use Array.prototype +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { +const arrayIterator = [].values(); +const IntrinsicArrayIteratorPrototype = +Object.getPrototypeOf(arrayIterator); +const intrinsicArrayIteratorPrototypeNext = +IntrinsicArrayIteratorPrototype.next; +try { +// Temporarily mutate the array iterator prototype to have an invalid +// “next” method. Just like Array.from, the fromAsync function should +// still work on non-iterable arraylike arguments. +IntrinsicArrayIteratorPrototype.next = function fakeNext () { + throw new Test262Error( + 'This fake next function should not be called; ' + + 'instead, each element should have been directly accessed.', + ); +}; +const expected = [ 0, 1, 2 ]; +const input = { + length: 3, + 0: 0, + 1: 1, + 2: 2, +}; +const output = await SendableArray.fromAsync(input); +assert.compareArray(output, expected); +} +finally { +// Reset the intrinsic array iterator +IntrinsicArrayIteratorPrototype.next = + intrinsicArrayIteratorPrototypeNext; +} +}); diff --git a/test/sendable/builtins/Array/fromAsync/non-iterable-input-element-access-err.js b/test/sendable/builtins/Array/fromAsync/non-iterable-input-element-access-err.js new file mode 100644 index 00000000000..786155db73d --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/non-iterable-input-element-access-err.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Result promise rejects if element access fails +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const input = { + length: 1, + get 0 () { + throw new Test262Error; + }, + }; + const outputPromise = SendableArray.fromAsync(input); + assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-awaits-callback-result-once.js b/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-awaits-callback-result-once.js new file mode 100644 index 00000000000..6e9151740a5 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-awaits-callback-result-once.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Non-iterable input with thenable result with async mapped awaits each callback result once. +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + let awaitCounter = 0; + const input = { + length: 3, + 0: 0, + 1: Promise.resolve(1), + 2: Promise.resolve(2), + 3: Promise.resolve(3), // This is ignored because the length is 3. + }; + await SendableArray.fromAsync(input, async v => { + return { + // This “then” method should occur three times: + // one for each value from the input. + then (resolve, reject) { + awaitCounter ++; + resolve(v); + }, + }; + }); + assert.sameValue(awaitCounter, 3); +}); diff --git a/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-callback-err.js b/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-callback-err.js new file mode 100644 index 00000000000..b0a26430e17 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-callback-err.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Non-iterable input with thenable result promise rejects if async map function callback throws. +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + const inputThenable = { + then (resolve, reject) { + resolve(expectedValue); + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + const outputPromise = SendableArray.fromAsync(input, async v => { + throw new Test262Error; + }); + assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-element-rejects.js b/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-element-rejects.js new file mode 100644 index 00000000000..3535c61794b --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-element-rejects.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Non-iterable input with thenable result promise rejects if thenable element rejects. +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + const expected = [ expectedValue ]; + const inputThenable = { + then (resolve, reject) { + reject(new Test262Error); + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + const output = SendableArray.fromAsync(input); + await assert.throwsAsync(Test262Error, () => output); +}); diff --git a/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-sync-mapped-callback-err.js b/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-sync-mapped-callback-err.js new file mode 100644 index 00000000000..9e5d00dacb1 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable-sync-mapped-callback-err.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Non iterable result promise rejects if sync map function callback throws. +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const input = { + length: 1, + 0: 0, + }; + const outputPromise = SendableArray.fromAsync(input, v => { + throw new Test262Error; + }); + assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable.js b/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable.js new file mode 100644 index 00000000000..164618cb0ba --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/non-iterable-input-with-thenable.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Non iterable input with thenables is transferred to the output array. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expected = [ 0, 1, 2 ]; + const input = { + length: 3, + 0: 0, + 1: Promise.resolve(1), + 2: Promise.resolve(2), + 3: Promise.resolve(3), // This is ignored because the length is 3. + }; + const output = await SendableArray.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/test/sendable/builtins/Array/fromAsync/non-iterable-input.js b/test/sendable/builtins/Array/fromAsync/non-iterable-input.js new file mode 100644 index 00000000000..57717ca3322 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/non-iterable-input.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Non iterable input without thenables is transferred to the output array. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expected = [ 0, 1, 2 ]; + const input = { + length: 3, + 0: 0, + 1: 1, + 2: 2, + 3: 3, // This is ignored because the length is 3. + }; + const output = await SendableArray.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/test/sendable/builtins/Array/fromAsync/non-iterable-sync-mapped-callback-err.js b/test/sendable/builtins/Array/fromAsync/non-iterable-sync-mapped-callback-err.js new file mode 100644 index 00000000000..80c4bf90c3e --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/non-iterable-sync-mapped-callback-err.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Non iterable input with thenables awaits each input once without mapping callback +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + const inputThenable = { + then (resolve, reject) { + resolve(expectedValue); + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + const outputPromise = SendableArray.fromAsync(input, v => { + throw new Test262Error; + }); + await assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/test/sendable/builtins/Array/fromAsync/non-iterable-with-non-promise-thenable.js b/test/sendable/builtins/Array/fromAsync/non-iterable-with-non-promise-thenable.js new file mode 100644 index 00000000000..9c9fe366f8f --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/non-iterable-with-non-promise-thenable.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Non iterable input with non-promise thenables works. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + const expected = [ expectedValue ]; + const inputThenable = { + then (resolve, reject) { + resolve(expectedValue); + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + const output = await SendableArray.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-async-mapped-awaits-once.js b/test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-async-mapped-awaits-once.js new file mode 100644 index 00000000000..074cfe71f02 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-async-mapped-awaits-once.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Non-iterable input with thenables awaits each input once without mapping callback +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + const expected = [ expectedValue ]; + let awaitCounter = 0; + const inputThenable = { + then (resolve, reject) { + awaitCounter++; + resolve(expectedValue); + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + await SendableArray.fromAsync(input, async v => v); + assert.sameValue(awaitCounter, 1); +}); diff --git a/test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-awaits-once.js b/test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-awaits-once.js new file mode 100644 index 00000000000..02688848e59 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-awaits-once.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Non-iterable with thenables awaits each input value once without mapping callback. +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + let awaitCounter = 0; + const inputThenable = { + then (resolve, reject) { + awaitCounter ++; + resolve(expectedValue); + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + await SendableArray.fromAsync(input); + assert.sameValue(awaitCounter, 1); +}); diff --git a/test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-sync-mapped-awaits-once.js b/test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-sync-mapped-awaits-once.js new file mode 100644 index 00000000000..dacff54ca72 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-sync-mapped-awaits-once.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Non-iterable input with thenables awaits each input once with mapping callback +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + let awaitCounter = 0; + const inputThenable = { + then (resolve, reject) { + awaitCounter++; + resolve(expectedValue); + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + await SendableArray.fromAsync(input, v => v); + assert.sameValue(awaitCounter, 1); +}); diff --git a/test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-then-method-err.js b/test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-then-method-err.js new file mode 100644 index 00000000000..e790dc1a263 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/non-iterable-with-thenable-then-method-err.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Non-iterable input with thenable result promise is rejected if element's then method throws. +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const inputThenable = { + then (resolve, reject) { + throw new Test262Error; + }, + }; + const input = { + length: 1, + 0: inputThenable, + }; + const outputPromise = SendableArray.fromAsync(input); + assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/test/sendable/builtins/Array/fromAsync/not-a-constructor.js b/test/sendable/builtins/Array/fromAsync/not-a-constructor.js new file mode 100644 index 00000000000..b567de06f42 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/not-a-constructor.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: SendableArray.fromAsync is not a constructor +info: | + 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. +includes: [isConstructor.js] +features: [SendableArray.fromAsync, Reflect.construct] +---*/ + +assert(!isConstructor(SendableArray.fromAsync), "Array.fromAsync is not a constructor"); +assert.throws(TypeError, () => new SendableArray.fromAsync(), "SendableArray.fromAsync throws when constructed"); diff --git a/test/sendable/builtins/Array/fromAsync/prop-desc.js b/test/sendable/builtins/Array/fromAsync/prop-desc.js new file mode 100644 index 00000000000..fd739fd6936 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/prop-desc.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Type and property descriptor of SendableArray.fromAsync +info: | + Every other data property described in clauses 19 through 28 and in Annex B.2 + has the attributes { [[Writable]]: *true*, [[Enumerable]]: *false*, + [[Configurable]]: *true* } unless otherwise specified. +includes: [propertyHelper.js] +features: [SendableArray.fromAsync] +---*/ + +assert.sameValue(typeof SendableArray.fromAsync, "function", "SendableArray.fromAsync is callable"); +verifyProperty(SendableArray, 'fromAsync', { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/fromAsync/returned-promise-resolves-to-array.js b/test/sendable/builtins/Array/fromAsync/returned-promise-resolves-to-array.js new file mode 100644 index 00000000000..198a29ecf0c --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/returned-promise-resolves-to-array.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Array.fromAsync returns a Promise that resolves to an Array in the normal case +info: | + 1. Let _C_ be the *this* value. + 3.e. If IsConstructor(_C_) is *true*, then + i. Let _A_ be ? Construct(_C_). +features: [SendableArray.fromAsync] +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + const promise = SendableArray.fromAsync([0, 1, 2]); + const array = await promise; + assert(Array.isArray(array), "SendableArray.fromAsync returns a Promise that resolves to an Array"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/returns-promise.js b/test/sendable/builtins/Array/fromAsync/returns-promise.js new file mode 100644 index 00000000000..7608319e2ff --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/returns-promise.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: SendableArray.fromAsync returns a Promise +info: | + 5. Return _promiseCapability_.[[Promise]]. +flags: [async] +includes: [asyncHelpers.js] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + let p = SendableArray.fromAsync([0, 1, 2]); + assert(p instanceof Promise, "SendableArray.fromAsync returns a Promise"); + assert.sameValue( + Object.getPrototypeOf(p), + Promise.prototype, + "SendableArray.fromAsync returns an object with prototype Promise.prototype" + ); + p = SendableArray.fromAsync([0, 1, 2], () => { + throw new Test262Error("this will make the Promise reject"); + }) + assert(p instanceof Promise, "SendableArray.fromAsync returns a Promise even on error"); + assert.sameValue( + Object.getPrototypeOf(p), + Promise.prototype, + "SendableArray.fromAsync returns an object with prototype Promise.prototype even on error" + ); + await assert.throwsAsync(Test262Error, () => p, "Prevent unhandled rejection"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/sync-iterable-input-with-non-promise-thenable.js b/test/sendable/builtins/Array/fromAsync/sync-iterable-input-with-non-promise-thenable.js new file mode 100644 index 00000000000..d49efc4f8c1 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/sync-iterable-input-with-non-promise-thenable.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Sync-iterable input with non-promise thenables works. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + const expected = [ expectedValue ]; + const inputThenable = { + then (resolve, reject) { + resolve(expectedValue); + }, + }; + const input = [ inputThenable ].values(); + const output = await SendableArray.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/test/sendable/builtins/Array/fromAsync/sync-iterable-input-with-thenable.js b/test/sendable/builtins/Array/fromAsync/sync-iterable-input-with-thenable.js new file mode 100644 index 00000000000..067834c959a --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/sync-iterable-input-with-thenable.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Sync-iterable input with thenables is transferred to the output array. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expected = [ 0, 1, 2 ]; + const input = [ 0, Promise.resolve(1), Promise.resolve(2) ].values(); + const output = await SendableArray.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/test/sendable/builtins/Array/fromAsync/sync-iterable-input.js b/test/sendable/builtins/Array/fromAsync/sync-iterable-input.js new file mode 100644 index 00000000000..775938712b5 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/sync-iterable-input.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Sync-iterable input with no promises is transferred to the output array. +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expected = [ 0, 1, 2 ]; + const input = [ 0, 1, 2 ].values(); + const output = await SendableArray.fromAsync(input); + assert.compareArray(output, expected); +}); diff --git a/test/sendable/builtins/Array/fromAsync/sync-iterable-iteration-err.js b/test/sendable/builtins/Array/fromAsync/sync-iterable-iteration-err.js new file mode 100644 index 00000000000..26db37aec0b --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/sync-iterable-iteration-err.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Sync iterable result promise rejects if iteration of input fails. +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + function *generateInput () { + throw new Test262Error; + } + const input = generateInput(); + const outputPromise = SendableArray.fromAsync(input); + await assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-awaits-once.js b/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-awaits-once.js new file mode 100644 index 00000000000..50c29f94ff1 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-awaits-once.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Sync-iterable input with thenables awaits each input once with async mapping callback. +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + let awaitCounter = 0; + const inputThenable = { + then (resolve, reject) { + awaitCounter++; + resolve(expectedValue); + }, + }; + const input = [ inputThenable ].values(); + await SendableArray.fromAsync(input, async v => v); + assert.sameValue(awaitCounter, 1); +}); diff --git a/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-callback-err.js b/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-callback-err.js new file mode 100644 index 00000000000..2d50fbdf691 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-callback-err.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Sync-iterable input with thenable result promise rejects if async map function callback throws. +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const input = [ Promise.resolve(0) ].values(); + const outputPromise = SendableArray.fromAsync(input, async v => { + throw new Test262Error; + }); + await assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-awaits-once.js b/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-awaits-once.js new file mode 100644 index 00000000000..89de8ede464 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-awaits-once.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Sync-iterable input with thenables awaits each input once without mapping callback +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + let awaitCounter = 0; + const inputThenable = { + then (resolve, reject) { + awaitCounter++; + resolve(expectedValue); + }, + }; + const input = [ inputThenable ].values(); + await SendableArray.fromAsync(input); + assert.sameValue(awaitCounter, 1); +}); diff --git a/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-element-rejects.js b/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-element-rejects.js new file mode 100644 index 00000000000..dd86901b17e --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-element-rejects.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Result promise rejects if then method of input fails. +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const inputThenable = { + then (resolve, reject) { + reject(new Test262Error); + }, + }; + const input = [ inputThenable ].values(); + const output = SendableArray.fromAsync(input); + await assert.throwsAsync(Test262Error, () => output); +}); diff --git a/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-awaits-once.js b/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-awaits-once.js new file mode 100644 index 00000000000..6540434f211 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-awaits-once.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Sync-iterable input with mapfn awaits each input once with sync mapping callback +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + let awaitCounter = 0; + const inputThenable = { + then (resolve, reject) { + awaitCounter++; + resolve(expectedValue); + }, + }; + const input = [ inputThenable ].values(); + await SendableArray.fromAsync(input, v => v); + assert.sameValue(awaitCounter, 1); +}); diff --git a/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-callback-err.js b/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-callback-err.js new file mode 100644 index 00000000000..fcd83026fa1 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-callback-err.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Sync-iterable input with thenable result promise rejects if sync map function callback throws. +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const input = [ Promise.resolve(0) ].values(); + const outputPromise = SendableArray.fromAsync(input, v => { + throw new Test262Error; + }); + await assert.throwsAsync(Test262Error, () => outputPromise); +}); diff --git a/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-then-method-err.js b/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-then-method-err.js new file mode 100644 index 00000000000..254f8e533c0 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/sync-iterable-with-thenable-then-method-err.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: Result promise rejects if then method of input fails. +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const expectedValue = {}; + const expected = [ expectedValue ]; + const inputThenable = { + then (resolve, reject) { + throw new Test262Error(); + }, + }; + const input = [ inputThenable ].values(); + const output = SendableArray.fromAsync(input); + await assert.throwsAsync(Test262Error, () => output); +}); diff --git a/test/sendable/builtins/Array/fromAsync/this-constructor-operations.js b/test/sendable/builtins/Array/fromAsync/this-constructor-operations.js new file mode 100644 index 00000000000..21d9320e844 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/this-constructor-operations.js @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Order of user-observable operations on a custom this-value and its instances +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +function formatPropertyName(propertyKey, objectName = "") { + switch (typeof propertyKey) { + case "symbol": + if (Symbol.keyFor(propertyKey) !== undefined) { + return `${objectName}[Symbol.for('${Symbol.keyFor(propertyKey)}')]`; + } else if (propertyKey.description.startsWith('Symbol.')) { + return `${objectName}[${propertyKey.description}]`; + } else { + return `${objectName}[Symbol('${propertyKey.description}')]` + } + case "string": + if (propertyKey !== String(Number(propertyKey))) + return objectName ? `${objectName}.${propertyKey}` : propertyKey; + // fall through + default: + // integer or string integer-index + return `${objectName}[${propertyKey}]`; + } +} +asyncTest(async function () { + const expectedCalls = [ + "construct MyArray", + "defineProperty A[0]", + "defineProperty A[1]", + "set A.length" + ]; + const actualCalls = []; + function MyArray(...args) { + actualCalls.push("construct MyArray"); + return new Proxy(Object.create(null), { + set(target, key, value) { + actualCalls.push(`set ${formatPropertyName(key, "A")}`); + return Reflect.set(target, key, value); + }, + defineProperty(target, key, descriptor) { + actualCalls.push(`defineProperty ${formatPropertyName(key, "A")}`); + return Reflect.defineProperty(target, key, descriptor); + } + }); + } + let result = await SendableArray.fromAsync.call(MyArray, [1, 2]); + assert.compareArray(expectedCalls, actualCalls, "order of operations for array argument"); + actualCalls.splice(0); // reset + const expectedCallsForArrayLike = [ + "construct MyArray", + "defineProperty A[0]", + "defineProperty A[1]", + "set A.length" + ]; + result = await SendableArray.fromAsync.call(MyArray, { + length: 2, + 0: 1, + 1: 2 + }); + assert.compareArray(expectedCallsForArrayLike, actualCalls, "order of operations for array-like argument"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/this-constructor-with-bad-length-setter.js b/test/sendable/builtins/Array/fromAsync/this-constructor-with-bad-length-setter.js new file mode 100644 index 00000000000..a1dcbc44439 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/this-constructor-with-bad-length-setter.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Rejects the promise if setting the length fails on an instance of a custom + this-value +info: | + 3.j.ii.4.a. Perform ? Set(_A_, *"length"*, 𝔽(_k_), *true*). + 3.k.viii. Perform ? Set(_A_, *"length"*, 𝔽(_len_), *true*) +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + class MyArray { + set length(v) { + throw new Test262Error("setter of length property throws") + } + } + await assert.throwsAsync(Test262Error, () => SendableArray.fromAsync.call(MyArray, [0, 1, 2]), "Promise rejected if setting length fails"); + await assert.throwsAsync(Test262Error, () => SendableArray.fromAsync.call(MyArray, { + length: 3, + 0: 0, + 1: 1, + 2: 2 + }), "Promise rejected if setting length from array-like fails"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/this-constructor-with-readonly-elements.js b/test/sendable/builtins/Array/fromAsync/this-constructor-with-readonly-elements.js new file mode 100644 index 00000000000..2b67d71840a --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/this-constructor-with-readonly-elements.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Overwrites non-writable element properties on an instance of a custom + this-value +info: | + 3.j.ii.8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). + ... + 3.k.vii.6. Perform ? CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + function MyArray() { + this.length = 4; + for (let ix = 0; ix < this.length; ix++) { + Object.defineProperty(this, ix, { + enumerable: true, + writable: false, + configurable: true, + value: 99 + }); + } + } + let result = await SendableArray.fromAsync.call(MyArray, [0, 1, 2]); + assert.sameValue(result.length, 3, "Length property is overwritten"); + assert.sameValue(result[0], 0, "Read-only element 0 is overwritten"); + assert.sameValue(result[1], 1, "Read-only element 1 is overwritten"); + assert.sameValue(result[2], 2, "Read-only element 2 is overwritten"); + assert.sameValue(result[3], 99, "Element 3 is not overwritten"); + result = await SendableArray.fromAsync.call(MyArray, { + length: 3, + 0: 0, + 1: 1, + 2: 2, + 3: 3 // ignored + }); + assert.sameValue(result.length, 3, "Length property is overwritten"); + assert.sameValue(result[0], 0, "Read-only element 0 is overwritten"); + assert.sameValue(result[1], 1, "Read-only element 1 is overwritten"); + assert.sameValue(result[2], 2, "Read-only element 2 is overwritten"); + assert.sameValue(result[3], 99, "Element 3 is not overwritten"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/this-constructor-with-readonly-length.js b/test/sendable/builtins/Array/fromAsync/this-constructor-with-readonly-length.js new file mode 100644 index 00000000000..f291d8d49aa --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/this-constructor-with-readonly-length.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Promise is rejected if length property on an instance of a custom this-value + is non-writable +info: | + 3.j.ii.4.a. Perform ? Set(_A_, *"length"*, 𝔽(_k_), *true*). + 3.k.viii. Perform ? Set(_A_, *"length"*, 𝔽(_len_), *true*). + Note that there is no difference between strict mode and sloppy mode, because + we are not following runtime evaluation semantics. +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + function MyArray() { + Object.defineProperty(this, "length", { + enumerable: true, + writable: false, + configurable: true, + value: 99 + }); + } + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync.call(MyArray, [0, 1, 2]), "Setting read-only length fails"); + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync.call(MyArray, { + length: 3, + 0: 0, + 1: 1, + 2: 2 + }), "Setting read-only length fails in array-like case"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/this-constructor-with-unsettable-element-closes-async-iterator.js b/test/sendable/builtins/Array/fromAsync/this-constructor-with-unsettable-element-closes-async-iterator.js new file mode 100644 index 00000000000..91842c7e54e --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/this-constructor-with-unsettable-element-closes-async-iterator.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-SendableArray.fromasync +description: > + Closes an async iterator if setting an element fails on an instance of a + custom this-value +info: | + 3.j.ii.8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). + 9. If _defineStatus_ is an abrupt completion, return ? AsyncIteratorClose(_iteratorRecord_, _defineStatus_). +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + function MyArray() { + Object.defineProperty(this, 0, { + enumerable: true, + writable: true, + configurable: false, + value: 0 + }); + } + let closed = false; + const iterator = { + next() { + return Promise.resolve({ value: 1, done: false }); + }, + return() { + closed = true; + return Promise.resolve({ done: true }); + }, + [Symbol.asyncIterator]() { + return this; + } + } + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync.call(MyArray, iterator), "Promise rejected if defining element fails"); + assert(closed, "element define failure should close iterator"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/this-constructor-with-unsettable-element-closes-sync-iterator.js b/test/sendable/builtins/Array/fromAsync/this-constructor-with-unsettable-element-closes-sync-iterator.js new file mode 100644 index 00000000000..dab88d9eb38 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/this-constructor-with-unsettable-element-closes-sync-iterator.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Closes a sync iterator if setting an element fails on an instance of a custom + this-value +info: | + 3.j.ii.8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). + 9. If _defineStatus_ is an abrupt completion, return ? AsyncIteratorClose(_iteratorRecord_, _defineStatus_). +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + function MyArray() { + Object.defineProperty(this, 0, { + enumerable: true, + writable: true, + configurable: false, + value: 0 + }); + } + let closed = false; + const iterator = { + next() { + return { value: 1, done: false }; + }, + return() { + closed = true; + return { done: true }; + }, + [Symbol.iterator]() { + return this; + } + } + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync.call(MyArray, iterator), "Promise rejected if defining element fails"); + assert(closed, "element define failure should close iterator"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/this-constructor-with-unsettable-element.js b/test/sendable/builtins/Array/fromAsync/this-constructor-with-unsettable-element.js new file mode 100644 index 00000000000..96927ab3d7c --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/this-constructor-with-unsettable-element.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Rejects the promise if setting an element fails on an instance of a custom + this-value +info: | + 3.j.ii.8. Let _defineStatus_ be CreateDataPropertyOrThrow(_A_, _Pk_, _mappedValue_). + 9. If _defineStatus_ is an abrupt completion, return ? AsyncIteratorClose(_iteratorRecord_, _defineStatus_). +includes: [asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + function MyArray() { + Object.defineProperty(this, 0, { + enumerable: true, + writable: true, + configurable: false, + value: 0 + }); + } + await assert.throwsAsync(TypeError, () => SendableArray.fromAsync.call(MyArray, [0, 1, 2]), "Promise rejected if defining element fails"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/this-constructor.js b/test/sendable/builtins/Array/fromAsync/this-constructor.js new file mode 100644 index 00000000000..135eb46680d --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/this-constructor.js @@ -0,0 +1,57 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Constructs the this-value once if asyncItems is iterable, twice if not, and + length and element properties are set correctly on the result +info: | + 3.e. If IsConstructor(_C_) is *true*, then + i. Let _A_ be ? Construct(_C_). + j. If _iteratorRecord_ is not *undefined*, then + k. Else, + iv. If IsConstructor(_C_) is *true*, then + 1. Let _A_ be ? Construct(_C_, « 𝔽(_len_) »). +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const constructorCalls = []; + function MyArray(...args) { + constructorCalls.push(args); + } + let result = await SendableArray.fromAsync.call(MyArray, [1, 2]); + assert(result instanceof MyArray, "result is an instance of the constructor this-value"); + assert.sameValue(result.length, 2, "length is set on result"); + assert.sameValue(result[0], 1, "element 0 is set on result"); + assert.sameValue(result[1], 2, "element 1 is set on result"); + assert.sameValue(constructorCalls.length, 1, "constructor is called once"); + assert.compareArray(constructorCalls[0], [], "constructor is called with no arguments"); + constructorCalls.splice(0); // reset + result = await SendableArray.fromAsync.call(MyArray, { + length: 2, + 0: 1, + 1: 2 + }); + assert(result instanceof MyArray, "result is an instance of the constructor this-value"); + assert.sameValue(result.length, 2, "length is set on result"); + assert.sameValue(result[0], 1, "element 0 is set on result"); + assert.sameValue(result[1], 2, "element 1 is set on result"); + assert.sameValue(constructorCalls.length, 1, "constructor is called once"); + assert.compareArray(constructorCalls[0], [2], "constructor is called with a length argument"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/this-non-constructor.js b/test/sendable/builtins/Array/fromAsync/this-non-constructor.js new file mode 100644 index 00000000000..7ea7ba82229 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/this-non-constructor.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + Constructs an intrinsic Array if this-value is not a constructor, and length + and element properties are set accordingly. +info: | + 3.e. If IsConstructor(_C_) is *true*, then + f. Else, + i. Let _A_ be ! ArrayCreate(0). + j. If _iteratorRecord_ is not *undefined*, then + k. Else, + iv. If IsConstructor(_C_) is *true*, then + v. Else, + 1. Let _A_ be ? ArrayCreate(_len_). +includes: [compareArray.js, asyncHelpers.js] +flags: [async] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async function () { + const thisValue = { + length: 4000, + 0: 32, + 1: 64, + 2: 128 + }; + let result = await SendableArray.fromAsync.call(thisValue, [1, 2]); + assert(Array.isArray(result), "result is an intrinsic Array"); + assert.compareArray(result, [1, 2], "result is not disrupted by properties of this-value"); + result = await SendableArray.fromAsync.call(thisValue, { + length: 2, + 0: 1, + 1: 2 + }); + assert(Array.isArray(result), "result is an intrinsic Array"); + assert.compareArray(result, [1, 2], "result is not disrupted by properties of this-value"); +}); diff --git a/test/sendable/builtins/Array/fromAsync/thisarg-object.js b/test/sendable/builtins/Array/fromAsync/thisarg-object.js new file mode 100644 index 00000000000..c0678ac843d --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/thisarg-object.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: If thisArg is an object, it's bound to mapfn as the this-value +info: | + 6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). +flags: [async] +includes: [asyncHelpers.js] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async () => { + const myThisValue = {}; + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, myThisValue, "thisArg should be bound as the this-value of mapfn"); + }, myThisValue); +}); diff --git a/test/sendable/builtins/Array/fromAsync/thisarg-omitted-sloppy.js b/test/sendable/builtins/Array/fromAsync/thisarg-omitted-sloppy.js new file mode 100644 index 00000000000..f33dfd1d1d8 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/thisarg-omitted-sloppy.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + If thisArg is omitted, mapfn is called with the global object as the + this-value in sloppy mode +info: | + 6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + + OrdinaryCallBindThis, when _F_.[[ThisMode]] is ~global~, where _F_ is the + function object: + 6. Else, + a. If _thisArgument_ is *undefined* or *null*, then + i. Let _globalEnv_ be _calleeRealm_.[[GlobalEnv]]. + ii. Assert: _globalEnv_ is a Global Environment Record. + iii. Let _thisValue_ be _globalEnv_.[[GlobalThisValue]]. +flags: [async, noStrict] +includes: [asyncHelpers.js] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async () => { + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.sameValue( + this, + globalThis, + "the global should be bound as the this-value of mapfn when thisArg is omitted" + ); + }); +}); diff --git a/test/sendable/builtins/Array/fromAsync/thisarg-omitted-strict.js b/test/sendable/builtins/Array/fromAsync/thisarg-omitted-strict.js new file mode 100644 index 00000000000..a81e092ba0f --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/thisarg-omitted-strict.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + If thisArg is omitted, mapfn is called with undefined as the this-value in + strict mode +info: | + 6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + + In OrdinaryCallBindThis, _thisArgument_ is always bound as the this-value in + strict mode (_F_.[[ThisMode]] is ~strict~, where _F_ is the function object.) +flags: [async, onlyStrict] +includes: [asyncHelpers.js] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async () => { + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.sameValue( + this, + undefined, + "undefined should be bound as the this-value of mapfn when thisArg is omitted" + ); + }); +}); diff --git a/test/sendable/builtins/Array/fromAsync/thisarg-primitive-sloppy.js b/test/sendable/builtins/Array/fromAsync/thisarg-primitive-sloppy.js new file mode 100644 index 00000000000..caf3ef270c2 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/thisarg-primitive-sloppy.js @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + If thisArg is a primitive, mapfn is called with a wrapper this-value or the + global, according to the usual rules of sloppy mode +info: | + 6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + OrdinaryCallBindThis, when _F_.[[ThisMode]] is ~global~, where _F_ is the + function object: + 6. Else, + a. If _thisArgument_ is *undefined* or *null*, then + i. Let _globalEnv_ be _calleeRealm_.[[GlobalEnv]]. + ii. Assert: _globalEnv_ is a Global Environment Record. + iii. Let _thisValue_ be _globalEnv_.[[GlobalThisValue]]. + b. Else, + i. Let _thisValue_ be ! ToObject(_thisArgument_). + ii. NOTE: ToObject produces wrapper objects using _calleeRealm_. +flags: [async, noStrict] +includes: [asyncHelpers.js] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async () => { + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.sameValue( + this, + globalThis, + "the global should be bound as the this-value of mapfn when thisArg is undefined" + ); + }, undefined); + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.sameValue( + this, + globalThis, + "the global should be bound as the this-value of mapfn when thisArg is null" + ); + }, null); + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.notSameValue(this, "string", "string thisArg should not be bound as the this-value of mapfn"); + assert.sameValue(typeof this, "object", "a String wrapper object should be bound as the this-value of mapfn when thisArg is a string") + assert.sameValue(this.valueOf(), "string", "String wrapper object should have the same primitive value as thisArg"); + }, "string"); + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.notSameValue(this, 3.1416, "number thisArg should be not bound as the this-value of mapfn"); + assert.sameValue(typeof this, "object", "a Number wrapper object should be bound as the this-value of mapfn when thisArg is a number") + assert.sameValue(this.valueOf(), 3.1416, "Number wrapper object should have the same primitive value as thisArg"); + }, 3.1416); + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.notSameValue(this, 42n, "bigint thisArg should not be bound as the this-value of mapfn"); + assert.sameValue(typeof this, "object", "a BigInt wrapper object should be bound as the this-value of mapfn when thisArg is a bigint") + assert.sameValue(this.valueOf(), 42n, "BigInt wrapper object should have the same primitive value as thisArg"); + }, 42n); + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.notSameValue(this, true, "boolean thisArg should not be bound as the this-value of mapfn"); + assert.sameValue(typeof this, "object", "a Boolean wrapper object should be bound as the this-value of mapfn when thisArg is a boolean") + assert.sameValue(this.valueOf(), true, "Boolean wrapper object should have the same primitive value as thisArg"); + }, true); + const symbolThis = Symbol("symbol"); + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.notSameValue(this, symbolThis, "symbol thisArg should not be bound as the this-value of mapfn"); + assert.sameValue(typeof this, "object", "a Symbol wrapper object should be bound as the this-value of mapfn when thisArg is a symbol") + assert.sameValue(this.valueOf(), symbolThis, "Symbol wrapper object should have the same primitive value as thisArg"); + }, symbolThis); +}); diff --git a/test/sendable/builtins/Array/fromAsync/thisarg-primitive-strict.js b/test/sendable/builtins/Array/fromAsync/thisarg-primitive-strict.js new file mode 100644 index 00000000000..d82c697c399 --- /dev/null +++ b/test/sendable/builtins/Array/fromAsync/thisarg-primitive-strict.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.fromasync +description: > + If thisArg is a primitive, mapfn is called with it as the this-value in strict + mode +info: | + 6. If _mapping_ is *true*, then + a. Let _mappedValue_ be Call(_mapfn_, _thisArg_, « _nextValue_, 𝔽(_k_) »). + + In OrdinaryCallBindThis, _thisArgument_ is always bound as the this-value in + strict mode (_F_.[[ThisMode]] is ~strict~, where _F_ is the function object.) +flags: [async, onlyStrict] +includes: [asyncHelpers.js] +features: [SendableArray.fromAsync] +---*/ + +asyncTest(async () => { + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, undefined, "undefined thisArg should be bound as the this-value of mapfn"); + }, undefined); + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, null, "null thisArg should be bound as the this-value of mapfn"); + }, null); + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, "string", "string thisArg should be bound as the this-value of mapfn"); + }, "string"); + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, 3.1416, "number thisArg should be bound as the this-value of mapfn"); + }, 3.1416); + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, 42n, "bigint thisArg should be bound as the this-value of mapfn"); + }, 42n); + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, true, "boolean thisArg should be bound as the this-value of mapfn"); + }, true); + const symbolThis = Symbol("symbol"); + await SendableArray.fromAsync([1, 2, 3], async function () { + assert.sameValue(this, symbolThis, "symbol thisArg should be bound as the this-value of mapfn"); + }, symbolThis); +}); diff --git a/test/sendable/harness/assert-false.js b/test/sendable/harness/assert-false.js new file mode 100644 index 00000000000..5285c790116 --- /dev/null +++ b/test/sendable/harness/assert-false.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + `false` does not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert(false); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-notsamevalue-nan.js b/test/sendable/harness/assert-notsamevalue-nan.js new file mode 100644 index 00000000000..f9e9903c1f1 --- /dev/null +++ b/test/sendable/harness/assert-notsamevalue-nan.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Two references to NaN do not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert.notSameValue(NaN, NaN); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-notsamevalue-notsame.js b/test/sendable/harness/assert-notsamevalue-notsame.js new file mode 100644 index 00000000000..a1315d588f4 --- /dev/null +++ b/test/sendable/harness/assert-notsamevalue-notsame.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Values that are not strictly equal satisfy the assertion. +---*/ + +assert.notSameValue(undefined, null); +assert.notSameValue(null, undefined); +assert.notSameValue(0, 1); +assert.notSameValue(1, 0); +assert.notSameValue('', 's'); +assert.notSameValue('s', ''); diff --git a/test/sendable/harness/assert-notsamevalue-objects.js b/test/sendable/harness/assert-notsamevalue-objects.js new file mode 100644 index 00000000000..f1fb40b351e --- /dev/null +++ b/test/sendable/harness/assert-notsamevalue-objects.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Distinct objects satisfy the assertion. +---*/ + +assert.notSameValue({}, {}); diff --git a/test/sendable/harness/assert-notsamevalue-tostring.js b/test/sendable/harness/assert-notsamevalue-tostring.js new file mode 100644 index 00000000000..ee583b52045 --- /dev/null +++ b/test/sendable/harness/assert-notsamevalue-tostring.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + When composing a message, errors from ToString are handled. +features: [async-functions] +---*/ + +var threw = false; +var asyncFunProto = Object.getPrototypeOf(async function() {}); + +try { + assert.notSameValue(asyncFunProto, asyncFunProto); +} catch (err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error('Expected a Test262Error, but a "' + err.constructor.name + '" was thrown.'); + } +} + +if (!threw) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-notsamevalue-zeros.js b/test/sendable/harness/assert-notsamevalue-zeros.js new file mode 100644 index 00000000000..7b8195e2deb --- /dev/null +++ b/test/sendable/harness/assert-notsamevalue-zeros.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Positive and negative zero satisfy the assertion. +---*/ + +assert.notSameValue(0, -0); diff --git a/test/sendable/harness/assert-obj.js b/test/sendable/harness/assert-obj.js new file mode 100644 index 00000000000..1b54e8e3904 --- /dev/null +++ b/test/sendable/harness/assert-obj.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + An object literal does not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert({}); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-samevalue-nan.js b/test/sendable/harness/assert-samevalue-nan.js new file mode 100644 index 00000000000..5c14c5238b1 --- /dev/null +++ b/test/sendable/harness/assert-samevalue-nan.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Two references to NaN satisfy the assertion. +---*/ + +assert.sameValue(NaN, NaN); diff --git a/test/sendable/harness/assert-samevalue-objects.js b/test/sendable/harness/assert-samevalue-objects.js new file mode 100644 index 00000000000..e7296edf00e --- /dev/null +++ b/test/sendable/harness/assert-samevalue-objects.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Distinct objects do not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert.sameValue({}, {}); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-samevalue-same.js b/test/sendable/harness/assert-samevalue-same.js new file mode 100644 index 00000000000..29221c507ae --- /dev/null +++ b/test/sendable/harness/assert-samevalue-same.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Values that are strictly equal satisfy the assertion. +---*/ +var obj; + +assert.sameValue(undefined, undefined); +assert.sameValue(null, null); +assert.sameValue(0, 0); +assert.sameValue(1, 1); +assert.sameValue('', ''); +assert.sameValue('s', 's'); + +obj = {}; +assert.sameValue(obj, obj); diff --git a/test/sendable/harness/assert-samevalue-tostring.js b/test/sendable/harness/assert-samevalue-tostring.js new file mode 100644 index 00000000000..37ac77c9d99 --- /dev/null +++ b/test/sendable/harness/assert-samevalue-tostring.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + When composing a message, errors from ToString are handled. +features: [async-functions] +---*/ + +var threw = false; +var asyncFunProto = Object.getPrototypeOf(async function() {}); + +try { + assert.sameValue(asyncFunProto, 1); +} catch (err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error('Expected a Test262Error, but a "' + err.constructor.name + '" was thrown.'); + } +} + +if (!threw) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-samevalue-zeros.js b/test/sendable/harness/assert-samevalue-zeros.js new file mode 100644 index 00000000000..247f6f57885 --- /dev/null +++ b/test/sendable/harness/assert-samevalue-zeros.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Positive and negative zero do not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert.sameValue(0, -0); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } + assert.notSameValue(err.message.indexOf('-0'), -1); +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-throws-custom-typeerror.js b/test/sendable/harness/assert-throws-custom-typeerror.js new file mode 100644 index 00000000000..af14c168c77 --- /dev/null +++ b/test/sendable/harness/assert-throws-custom-typeerror.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Functions that throw instances of the specified constructor function + satisfy the assertion, without collision with error constructors of the + same name. +---*/ + +var intrinsicTypeError = TypeError; +var threw = false; + +(function() { + function TypeError() {} + + assert.throws(TypeError, function() { + throw new TypeError(); + }, 'Throws an instance of the matching custom TypeError'); + + try { + assert.throws(intrinsicTypeError, function() { + throw new TypeError(); + }); + } catch (err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error but a "' + err.constructor.name + + '" was thrown.' + ); + } + } + + if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); + } + + threw = false; + + try { + assert.throws(TypeError, function() { + throw new intrinsicTypeError(); + }); + } catch (err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error but a "' + err.constructor.name + + '" was thrown.' + ); + } + } + + if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); + } +})(); diff --git a/test/sendable/harness/assert-throws-custom.js b/test/sendable/harness/assert-throws-custom.js new file mode 100644 index 00000000000..52d6bdda115 --- /dev/null +++ b/test/sendable/harness/assert-throws-custom.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Functions that throw instances of the specified constructor function + satisfy the assertion. +---*/ + +function MyError() {} + +assert.throws(MyError, function() { + throw new MyError(); +}); diff --git a/test/sendable/harness/assert-throws-incorrect-ctor.js b/test/sendable/harness/assert-throws-incorrect-ctor.js new file mode 100644 index 00000000000..ba91820b7ed --- /dev/null +++ b/test/sendable/harness/assert-throws-incorrect-ctor.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Functions that throw values whose constructor does not match the specified + constructor do not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert.throws(Error, function() { + throw new TypeError(); + }); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-throws-native.js b/test/sendable/harness/assert-throws-native.js new file mode 100644 index 00000000000..a11c08e537d --- /dev/null +++ b/test/sendable/harness/assert-throws-native.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Functions that throw instances of the specified native Error constructor + satisfy the assertion. +---*/ + +assert.throws(Error, function() { + throw new Error(); +}); + +assert.throws(EvalError, function() { + throw new EvalError(); +}); + +assert.throws(RangeError, function() { + throw new RangeError(); +}); + +assert.throws(ReferenceError, function() { + throw new ReferenceError(); +}); + +assert.throws(SyntaxError, function() { + throw new SyntaxError(); +}); + +assert.throws(TypeError, function() { + throw new TypeError(); +}); + +assert.throws(URIError, function() { + throw new URIError(); +}); diff --git a/test/sendable/harness/assert-throws-no-arg.js b/test/sendable/harness/assert-throws-no-arg.js new file mode 100644 index 00000000000..c12f55cefe6 --- /dev/null +++ b/test/sendable/harness/assert-throws-no-arg.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + The assertion fails when invoked without arguments. +---*/ + +var threw = false; + +try { + assert.throws(); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-throws-no-error.js b/test/sendable/harness/assert-throws-no-error.js new file mode 100644 index 00000000000..4d2cf2cf09f --- /dev/null +++ b/test/sendable/harness/assert-throws-no-error.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Functions that do not throw errors do not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert.throws(Error, function() {}); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-throws-null-fn.js b/test/sendable/harness/assert-throws-null-fn.js new file mode 100644 index 00000000000..01805f5e3af --- /dev/null +++ b/test/sendable/harness/assert-throws-null-fn.js @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Fails if second arg is not a function +---*/ + +var threw = false; + +try { + assert.throws(TypeError, null); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} + +threw = false; + +try { + assert.throws(TypeError, {}); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} + +threw = false; + +try { + assert.throws(TypeError, ""); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-throws-null.js b/test/sendable/harness/assert-throws-null.js new file mode 100644 index 00000000000..5f259d41af0 --- /dev/null +++ b/test/sendable/harness/assert-throws-null.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Functions that throw the `null` value do not satisfy the assertion. +---*/ + +var threw = false; + +try { + assert.throws(Error, function() { + throw null; + }); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-throws-primitive.js b/test/sendable/harness/assert-throws-primitive.js new file mode 100644 index 00000000000..a74f5993a75 --- /dev/null +++ b/test/sendable/harness/assert-throws-primitive.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Functions that throw primitive values do not satisfy the assertion. +---*/ +var threw = false; + +try { + assert.throws(Error, function() { + throw 3; + }); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-throws-same-realm.js b/test/sendable/harness/assert-throws-same-realm.js new file mode 100644 index 00000000000..319affce35a --- /dev/null +++ b/test/sendable/harness/assert-throws-same-realm.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Functions that throw instances of the realm specified constructor function + do not satisfy the assertion with cross realms collisions. +---*/ + +var intrinsicTypeError = TypeError; +var threw = false; +var realmGlobal = $262.createRealm().global; + +try { + assert.throws(TypeError, function() { + throw new realmGlobal.TypeError(); + }); +} catch (err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-throws-single-arg.js b/test/sendable/harness/assert-throws-single-arg.js new file mode 100644 index 00000000000..34bcd141c1c --- /dev/null +++ b/test/sendable/harness/assert-throws-single-arg.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + The assertion fails when invoked with a single argument. +---*/ +var threw = false; + +try { + assert.throws(function() {}); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-tostring.js b/test/sendable/harness/assert-tostring.js new file mode 100644 index 00000000000..49d09c0bdb6 --- /dev/null +++ b/test/sendable/harness/assert-tostring.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + When composing a message, errors from ToString are handled. +features: [async-functions] +---*/ + +var threw = false; +var asyncFunProto = Object.getPrototypeOf(async function() {}); + +try { + assert(asyncFunProto); +} catch (err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error('Expected a Test262Error, but a "' + err.constructor.name + '" was thrown.'); + } +} + +if (!threw) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/assert-true.js b/test/sendable/harness/assert-true.js new file mode 100644 index 00000000000..15a5d27abd5 --- /dev/null +++ b/test/sendable/harness/assert-true.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + `true` satisfies the assertion. +---*/ + +assert(true); diff --git a/test/sendable/harness/assertRelativeDateMs.js b/test/sendable/harness/assertRelativeDateMs.js new file mode 100644 index 00000000000..62951e101e0 --- /dev/null +++ b/test/sendable/harness/assertRelativeDateMs.js @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Only passes when the provided date is exactly the specified number of + milliseconds from the Unix epoch +includes: [assertRelativeDateMs.js] +---*/ + +var thrown; + +assertRelativeDateMs(new Date(1970, 0), 0); +assertRelativeDateMs(new Date(1970, 0, 1, 0, 0, 0, 0), 0); +assertRelativeDateMs(new Date(1970, 0, 1, 0, 0, 0, 1), 1); +assertRelativeDateMs(new Date(1970, 0, 1, 0, 0, 0, -1), -1); +assertRelativeDateMs(new Date(1970, 0, 1, 0, 0, 1, 0), 1000); +assertRelativeDateMs(new Date(1970, 0, 1, 0, 0, -1, 0), -1000); +assertRelativeDateMs(new Date(1970, 0, 1, 0, 2, 0, 0), 120000); +assertRelativeDateMs(new Date(1970, 0, 1, 0, -2, 0, 0), -120000); +assertRelativeDateMs(new Date(2016, 3, 12, 13, 21, 23, 24), 1460467283024); + +thrown = null; +try { + assertRelativeDateMs(new Date(1), 0); +} catch (err) { + thrown = err; +} +if (!thrown) { + throw new Error('Expected error, but no error was thrown.'); +} else if (thrown.constructor !== Test262Error) { + throw new Error('Expected error of type Test262Error.'); +} + +thrown = null; +try { + assertRelativeDateMs(new Date(-1), 0); +} catch (err) { + thrown = err; +} +if (!thrown) { + throw new Error('Expected error, but no error was thrown.'); +} else if (thrown.constructor !== Test262Error) { + throw new Error('Expected error of type Test262Error.'); +} + +thrown = null; +try { + assertRelativeDateMs(new Date(1970, 0), 1); +} catch (err) { + thrown = err; +} +if (!thrown) { + throw new Error('Expected error, but no error was thrown.'); +} else if (thrown.constructor !== Test262Error) { + throw new Error('Expected error of type Test262Error.'); +} + +thrown = null; +try { + assertRelativeDateMs(new Date(1970, 0), -1); +} catch (err) { + thrown = err; +} +if (!thrown) { + throw new Error('Expected error, but no error was thrown.'); +} else if (thrown.constructor !== Test262Error) { + throw new Error('Expected error of type Test262Error.'); +} + +thrown = null; +try { + assertRelativeDateMs(new Date('invalid'), NaN); +} catch (err) { + thrown = err; +} +if (!thrown) { + throw new Error('Expected error, but no error was thrown.'); +} else if (thrown.constructor !== Test262Error) { + throw new Error('Expected error of type Test262Error.'); +} diff --git a/test/sendable/harness/asyncHelpers-asyncTest-func-throws-sync.js b/test/sendable/harness/asyncHelpers-asyncTest-func-throws-sync.js new file mode 100644 index 00000000000..d6ee12c5e60 --- /dev/null +++ b/test/sendable/harness/asyncHelpers-asyncTest-func-throws-sync.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + The 'asyncTest' helper reports synchronous errors via $DONE. +includes: [asyncHelpers.js] +---*/ +var called = false; +var msg = "Should not be rethrown"; +function $DONE(error) { + called = true; + assert(error instanceof Test262Error); + assert.sameValue(error.message, msg, "Should report correct error"); +} +asyncTest(function () { + throw new Test262Error(msg); +}); +assert(called, "asyncTest called $DONE with a synchronously thrown error"); diff --git a/test/sendable/harness/asyncHelpers-asyncTest-rejects-non-callable.js b/test/sendable/harness/asyncHelpers-asyncTest-rejects-non-callable.js new file mode 100644 index 00000000000..51cd7c5ea90 --- /dev/null +++ b/test/sendable/harness/asyncHelpers-asyncTest-rejects-non-callable.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + The 'asyncTest' helper rejects non-callable test functions. +includes: [asyncHelpers.js, compareArray.js] +---*/ + +const doneValues = []; +function $DONE(error) { + doneValues.push(error instanceof Test262Error); +} +asyncTest(null); +asyncTest({}); +asyncTest("string"); +asyncTest(42); +asyncTest(undefined); +asyncTest(); +assert.compareArray(doneValues, [true, true, true, true, true, true]); diff --git a/test/sendable/harness/asyncHelpers-asyncTest-return-not-thenable.js b/test/sendable/harness/asyncHelpers-asyncTest-return-not-thenable.js new file mode 100644 index 00000000000..f288ef082ba --- /dev/null +++ b/test/sendable/harness/asyncHelpers-asyncTest-return-not-thenable.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + The 'asyncTest' helper rejects test functions that do not return a thenable. +includes: [asyncHelpers.js, compareArray.js] +---*/ + +const doneValues = []; +function $DONE(error) { + // Will be a TypeError from trying to invoke .then() on non-thenable + doneValues.push(error instanceof TypeError); +} +asyncTest(function () { + return null; +}); +asyncTest(function () { + return {}; +}); +asyncTest(function () { + return "string"; +}); +asyncTest(function () { + return 42; +}); +asyncTest(function () {}); +asyncTest(function () { + return function () {}; +}); +assert.compareArray(doneValues, [true, true, true, true, true, true]); diff --git a/test/sendable/harness/asyncHelpers-asyncTest-returns-undefined.js b/test/sendable/harness/asyncHelpers-asyncTest-returns-undefined.js new file mode 100644 index 00000000000..475c963474b --- /dev/null +++ b/test/sendable/harness/asyncHelpers-asyncTest-returns-undefined.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + The 'asyncTest' helper when called with async flag always returns undefined. +flags: [async] +includes: [asyncHelpers.js] +---*/ +var realDone = $DONE; +var doneCalls = 0; +globalThis.$DONE = function () { + doneCalls++; +}; + +(async function () { + assert.sameValue(undefined, asyncTest({})); + assert.sameValue( + undefined, + asyncTest(function () { + return "non-thenable"; + }) + ); + assert.sameValue( + undefined, + asyncTest(function () { + return Promise.resolve(true); + }) + ); + assert.sameValue( + undefined, + asyncTest(function () { + return Promise.reject(new Test262Error("oh no")); + }) + ); +})() + .then(() => { + assert.sameValue(doneCalls, 4, "asyncTest must call $DONE"); + }) + .then(realDone, realDone); diff --git a/test/sendable/harness/asyncHelpers-asyncTest-then-rejects.js b/test/sendable/harness/asyncHelpers-asyncTest-then-rejects.js new file mode 100644 index 00000000000..64b1feb3130 --- /dev/null +++ b/test/sendable/harness/asyncHelpers-asyncTest-then-rejects.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + The 'asyncTest' helper calls $DONE with the rejection value if the test function rejects. +flags: [async] +includes: [asyncHelpers.js, compareArray.js] +---*/ +const rejectionValues = []; +var realDone = $DONE; +globalThis.$DONE = function (mustBeDefined) { + rejectionValues.push(mustBeDefined); +}; +const someObject = {}; + +(async function () { + asyncTest(function () { + return Promise.reject(null); + }); +})() + .then(() => { + asyncTest(function () { + return Promise.reject(someObject); + }); + }) + .then(() => { + asyncTest(function () { + return Promise.reject("hi"); + }); + }) + .then(() => { + asyncTest(function () { + return Promise.reject(10); + }); + }) + .then(() => { + asyncTest(function () { + return { + then(res, rej) { + rej(true); + }, + }; + }); + }) + .then(() => { + assert.compareArray(rejectionValues, [null, someObject, "hi", 10, true]); + }) + .then(realDone, realDone); diff --git a/test/sendable/harness/asyncHelpers-asyncTest-then-resolves.js b/test/sendable/harness/asyncHelpers-asyncTest-then-resolves.js new file mode 100644 index 00000000000..a845bc126c0 --- /dev/null +++ b/test/sendable/harness/asyncHelpers-asyncTest-then-resolves.js @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + The 'asyncTest' helper calls $DONE with undefined, regardless of what value the promise resolves with +flags: [async] +includes: [asyncHelpers.js] +---*/ +var doneCalls = 0; +var realDone = $DONE; +globalThis.$DONE = function (noError) { + doneCalls++; + assert.sameValue( + noError, + undefined, + "asyncTest should discard promise's resolved value" + ); +}; + +(async function () { + asyncTest(function () { + return Promise.resolve(null); + }); +})() + .then(() => { + assert.sameValue(doneCalls, 1, "asyncTest called $DONE with undefined"); + asyncTest(function () { + return Promise.resolve({}); + }); + }) + .then(() => { + assert.sameValue(doneCalls, 2, "asyncTest called $DONE with undefined"); + asyncTest(function () { + return Promise.resolve("hi"); + }); + }) + .then(() => { + assert.sameValue(doneCalls, 3, "asyncTest called $DONE with undefined"); + asyncTest(function () { + return Promise.resolve(10); + }); + }) + .then(() => { + assert.sameValue(doneCalls, 4, "asyncTest called $DONE with undefined"); + asyncTest(function () { + return { + then(res, rej) { + res(true); + }, + }; + }); + }) + .then(() => { + assert.sameValue(doneCalls, 5, "asyncTest called $DONE with undefined"); + }) + .then(realDone, realDone); diff --git a/test/sendable/harness/asyncHelpers-asyncTest-without-async-flag.js b/test/sendable/harness/asyncHelpers-asyncTest-without-async-flag.js new file mode 100644 index 00000000000..d88c00c19ea --- /dev/null +++ b/test/sendable/harness/asyncHelpers-asyncTest-without-async-flag.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + The 'asyncTest' helper checks that it is called with the 'async' flag. +includes: [asyncHelpers.js] +---*/ +function makePromise() { + return { + then(res, rej) { + // Throw a different error than Test262Error to avoid confusion about what is rejecting + throw new Error("Should not be evaluated"); + }, + }; +} +assert( + !Object.hasOwn(globalThis, "$DONE"), + "Without 'async' flag, $DONE should not be defined" +); +assert.throws(Test262Error, function () { + asyncTest(makePromise); +}); diff --git a/test/sendable/harness/asyncHelpers-throwsAsync-custom-typeerror.js b/test/sendable/harness/asyncHelpers-throwsAsync-custom-typeerror.js new file mode 100644 index 00000000000..dc539f5c5f4 --- /dev/null +++ b/test/sendable/harness/asyncHelpers-throwsAsync-custom-typeerror.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Thenables that reject with instances of the specified constructor function + satisfy the assertion, without collision with error constructors of the same name. +flags: [async] +includes: [asyncHelpers.js] +---*/ + +var intrinsicTypeError = TypeError; + +asyncTest(async function () { + function TypeError() {} + var caught = false; + + var p = assert.throwsAsync( + TypeError, + async function () { + throw new TypeError(); + }, + "Throws an instance of the matching custom TypeError" + ); + assert(p instanceof Promise); + await p; + + p = assert.throwsAsync(intrinsicTypeError, async function () { + throw new TypeError(); + }); + assert(p instanceof Promise); + try { + await p; + } catch (err) { + caught = true; + assert.sameValue( + err.constructor, + Test262Error, + "Expected a Test262Error, but a '" + + err.constructor.name + + "' was thrown." + ); + } finally { + assert( + caught, + "assert.throwsAsync did not reject a collision of constructor names" + ); + } + + caught = false; + + p = assert.throwsAsync(TypeError, async function () { + throw new intrinsicTypeError(); + }); + assert(p instanceof Promise); + try { + await p; + } catch (err) { + caught = true; + assert.sameValue( + err.constructor, + Test262Error, + "Expected a Test262Error, but a '" + + err.constructor.name + + "' was thrown." + ); + } finally { + assert( + caught, + "assert.throwsAsync did not reject a collision of constructor names" + ); + } +}) diff --git a/test/sendable/harness/asyncHelpers-throwsAsync-custom.js b/test/sendable/harness/asyncHelpers-throwsAsync-custom.js new file mode 100644 index 00000000000..1706ad8691b --- /dev/null +++ b/test/sendable/harness/asyncHelpers-throwsAsync-custom.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Thenables that reject with values of the specified constructor function + satisfy the assertion. +flags: [async] +includes: [asyncHelpers.js] +---*/ + +function MyError() {} + +asyncTest(async function () { + const p = assert.throwsAsync(MyError, function () { + return Promise.reject(new MyError()); + }); + assert(p instanceof Promise); + await p; +}); diff --git a/test/sendable/harness/asyncHelpers-throwsAsync-func-never-settles.js b/test/sendable/harness/asyncHelpers-throwsAsync-func-never-settles.js new file mode 100644 index 00000000000..4b9b0c0af7a --- /dev/null +++ b/test/sendable/harness/asyncHelpers-throwsAsync-func-never-settles.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + assert.throwsAsync returns a promise that never settles if func returns a thenable that never settles. +flags: [async] +includes: [asyncHelpers.js] +---*/ + +var realDone = $DONE; +var doneCalls = 0 +globalThis.$DONE = function () { + doneCalls++; +} + +function delay() { + var later = Promise.resolve(); + for (var i = 0; i < 100; i++) { + later = later.then(); + } + return later; +} + +(async function () { + // Spy on the promise returned by an invocation of assert.throwsAsync + // with a function that returns a thenable which never settles. + var neverSettlingThenable = { then: function () { } }; + const p = assert.throwsAsync(TypeError, function () { return neverSettlingThenable }); + assert(p instanceof Promise, "assert.throwsAsync should return a promise"); + p.then($DONE, $DONE); +})() + // Give it a long time to try. + .then(delay, delay) + .then(function () { + assert.sameValue(doneCalls, 0, "$DONE should not have been called") + }) + .then(realDone, realDone); diff --git a/test/sendable/harness/asyncHelpers-throwsAsync-func-throws-sync.js b/test/sendable/harness/asyncHelpers-throwsAsync-func-throws-sync.js new file mode 100644 index 00000000000..ac2b4d5f17f --- /dev/null +++ b/test/sendable/harness/asyncHelpers-throwsAsync-func-throws-sync.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + assert.throwsAsync returns a promise that rejects if func or the inner thenable synchronously throws. +flags: [async] +includes: [asyncHelpers.js] +---*/ + +async function checkRejects(func) { + var caught = false; + const p = assert.throwsAsync(Test262Error, func); + assert(p instanceof Promise, "assert.throwsAsync should return a promise"); + try { + await p; + } catch (e) { + caught = true; + assert.sameValue( + e.constructor, + Test262Error, + "throwsAsync should reject improper function with a Test262Error" + ); + } finally { + assert( + caught, + "assert.throwsAsync did not reject improper function " + func + ); + } +} + +asyncTest(async function () { + await checkRejects(function () { + throw new Error(); + }); + await checkRejects(function () { + throw new Test262Error(); + }); + await checkRejects(function () { + return { + then: function () { + throw new Error(); + }, + }; + }); + await checkRejects(function () { + return { + then: function () { + throw new Test262Error(); + }, + }; + }); +}); diff --git a/test/sendable/harness/asyncHelpers-throwsAsync-incorrect-ctor.js b/test/sendable/harness/asyncHelpers-throwsAsync-incorrect-ctor.js new file mode 100644 index 00000000000..174b8c6bedf --- /dev/null +++ b/test/sendable/harness/asyncHelpers-throwsAsync-incorrect-ctor.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Thenables that reject with values whose constructor does not match the specified + constructor do not satisfy the assertion. +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + var caught = false; + + const p = assert.throwsAsync(Error, function () { + return Promise.reject(new TypeError()); + }); + assert(p instanceof Promise); + try { + await p; + } catch (err) { + caught = true; + assert.sameValue( + err.constructor, + Test262Error, + "Expected a Test262Error, but a '" + + err.constructor.name + + "' was thrown." + ); + } finally { + assert( + caught, + "assert.throwsAsync did not reject when a value with incorrect constructor was thrown" + ); + } +}); diff --git a/test/sendable/harness/asyncHelpers-throwsAsync-invalid-func.js b/test/sendable/harness/asyncHelpers-throwsAsync-invalid-func.js new file mode 100644 index 00000000000..d8d797882dd --- /dev/null +++ b/test/sendable/harness/asyncHelpers-throwsAsync-invalid-func.js @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + assert.throwsAsync calls $DONE with a rejecting value if func is not a function returning a thenable. +flags: [async] +includes: [asyncHelpers.js] +---*/ + +async function checkRejects(func) { + var caught = false; + const p = assert.throwsAsync(Test262Error, func); + assert(p instanceof Promise, "assert.throwsAsync should return a promise"); + try { + await p; + } catch (e) { + caught = true; + assert.sameValue( + e.constructor, + Test262Error, + "throwsAsync should reject improper function with a Test262Error" + ); + } finally { + assert( + caught, + "assert.throwsAsync did not reject improper function " + func + ); + } +} + +asyncTest(async function () { + await checkRejects(null); + await checkRejects({}); + await checkRejects("string"); + await checkRejects(10); + await checkRejects(); + await checkRejects({ + then: function (res, rej) { + res(true); + }, + }); + await checkRejects(function () { + return null; + }); + await checkRejects(function () { + return {}; + }); + await checkRejects(function () { + return "string"; + }); + await checkRejects(function () { + return 10; + }); + await checkRejects(function () {}); + await checkRejects(function () { + return { then: null }; + }); + await checkRejects(function () { + return { then: {} }; + }); + await checkRejects(function () { + return { then: "string" }; + }); + await checkRejects(function () { + return { then: 10 }; + }); + await checkRejects(function () { + return { then: undefined }; + }); +}); diff --git a/test/sendable/harness/asyncHelpers-throwsAsync-native.js b/test/sendable/harness/asyncHelpers-throwsAsync-native.js new file mode 100644 index 00000000000..3ec3748c0c3 --- /dev/null +++ b/test/sendable/harness/asyncHelpers-throwsAsync-native.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Thenables that reject with instances of the specified native Error constructor + satisfy the assertion. +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + var p = assert.throwsAsync(Error, async function () { + throw new Error(); + }); + assert(p instanceof Promise); + await p; + p = assert.throwsAsync(EvalError, async function () { + throw new EvalError(); + }); + assert(p instanceof Promise); + await p; + p = assert.throwsAsync(RangeError, async function () { + throw new RangeError(); + }); + assert(p instanceof Promise); + await p; + p = assert.throwsAsync(ReferenceError, async function () { + throw new ReferenceError(); + }); + assert(p instanceof Promise); + await p; + p = assert.throwsAsync(SyntaxError, async function () { + throw new SyntaxError(); + }); + assert(p instanceof Promise); + await p; + p = assert.throwsAsync(TypeError, async function () { + throw new TypeError(); + }); + assert(p instanceof Promise); + await p; + p = assert.throwsAsync(URIError, async function () { + throw new URIError(); + }); + assert(p instanceof Promise); + await p; +}); diff --git a/test/sendable/harness/asyncHelpers-throwsAsync-no-arg.js b/test/sendable/harness/asyncHelpers-throwsAsync-no-arg.js new file mode 100644 index 00000000000..86febedd837 --- /dev/null +++ b/test/sendable/harness/asyncHelpers-throwsAsync-no-arg.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + The assertion fails when invoked without arguments. +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + var caught = false; + + const p = assert.throwsAsync(); + assert(p instanceof Promise); + try { + await p; + } catch (err) { + caught = true; + assert.sameValue( + err.constructor, + Test262Error, + "Expected a Test262Error, but a '" + + err.constructor.name + + "' was thrown." + ); + } finally { + assert( + caught, + "assert.throwsAsync did not reject when invoked without arguments" + ); + } +}); diff --git a/test/sendable/harness/asyncHelpers-throwsAsync-no-error.js b/test/sendable/harness/asyncHelpers-throwsAsync-no-error.js new file mode 100644 index 00000000000..f7e5aa22e45 --- /dev/null +++ b/test/sendable/harness/asyncHelpers-throwsAsync-no-error.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Thenables that do not reject do not satisfy the assertion. +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + var caught = false; + + const p = assert.throwsAsync(Error, async function () {}); + assert(p instanceof Promise); + try { + await p; + } catch (err) { + caught = true; + assert.sameValue( + err.constructor, + Test262Error, + "Expected a Test262Error, but a '" + + err.constructor.name + + "' was thrown." + ); + } finally { + assert( + caught, + "assert.throwsAsync did not reject when the thenable did not reject" + ); + } +}); diff --git a/test/sendable/harness/asyncHelpers-throwsAsync-null.js b/test/sendable/harness/asyncHelpers-throwsAsync-null.js new file mode 100644 index 00000000000..408d60e7d73 --- /dev/null +++ b/test/sendable/harness/asyncHelpers-throwsAsync-null.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Thenables that reject with the `null` value do not satisfy the assertion. +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + var caught = false; + + const p = assert.throwsAsync(Error, async function () { + throw null; + }); + assert(p instanceof Promise); + try { + await p; + } catch (err) { + caught = true; + assert.sameValue( + err.constructor, + Test262Error, + "Expected a Test262Error, but a '" + + err.constructor.name + + "' was thrown." + ); + } finally { + assert( + caught, + "assert.throwsAsync did not reject when null was thrown" + ); + } +}); diff --git a/test/sendable/harness/asyncHelpers-throwsAsync-primitive.js b/test/sendable/harness/asyncHelpers-throwsAsync-primitive.js new file mode 100644 index 00000000000..f5a02da5885 --- /dev/null +++ b/test/sendable/harness/asyncHelpers-throwsAsync-primitive.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Thenables that reject with primitive values do not satisfy the assertion. +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + var caught = false; + + const p = assert.throwsAsync(Error, async function () { + throw 3; + }); + assert(p instanceof Promise); + try { + await p; + } catch (err) { + caught = true; + assert.sameValue( + err.constructor, + Test262Error, + "Expected a Test262Error, but a '" + + err.constructor.name + + "' was thrown." + ); + } finally { + assert( + caught, + "assert.throwsAsync did not reject when a primitive was thrown" + ); + } +}); diff --git a/test/sendable/harness/asyncHelpers-throwsAsync-resolved-error.js b/test/sendable/harness/asyncHelpers-throwsAsync-resolved-error.js new file mode 100644 index 00000000000..42d7ca4779e --- /dev/null +++ b/test/sendable/harness/asyncHelpers-throwsAsync-resolved-error.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Thenables that resolve with an error do not satisfy the assertion. +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + var caught = false; + + const p = assert.throwsAsync( + Error, + Promise.resolve(new Error("it's-a-me, Chris Pratt")) + ); + assert(p instanceof Promise); + try { + await p; + } catch (err) { + caught = true; + assert.sameValue( + err.constructor, + Test262Error, + "Expected a Test262Error, but a '" + + err.constructor.name + + "' was thrown." + ); + } finally { + assert( + caught, + "assert.throwsAsync did not reject when the thenable resolved with an error" + ); + } +}); diff --git a/test/sendable/harness/asyncHelpers-throwsAsync-same-realm.js b/test/sendable/harness/asyncHelpers-throwsAsync-same-realm.js new file mode 100644 index 00000000000..1e8aa80f7ed --- /dev/null +++ b/test/sendable/harness/asyncHelpers-throwsAsync-same-realm.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Thenables that reject with instances of the realm specified constructor function + do not satisfy the assertion with cross realms collisions. +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + var intrinsicTypeError = TypeError; + var caught = false; + var realmGlobal = $262.createRealm().global; + + const p = assert.throwsAsync(TypeError, async function () { + throw new realmGlobal.TypeError(); + }); + assert(p instanceof Promise); + try { + await p; + } catch (err) { + caught = true; + assert.sameValue( + err.constructor, + Test262Error, + "Expected a Test262Error, but a '" + + err.constructor.name + + "' was thrown." + ); + } finally { + assert( + caught, + "assert.throwsAsync did not reject when a different realm's error was thrown" + ); + } +}); diff --git a/test/sendable/harness/asyncHelpers-throwsAsync-single-arg.js b/test/sendable/harness/asyncHelpers-throwsAsync-single-arg.js new file mode 100644 index 00000000000..f5cbb1eb49d --- /dev/null +++ b/test/sendable/harness/asyncHelpers-throwsAsync-single-arg.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + assert.throwsAsync returns a promise that rejects when invoked with a single argument +flags: [async] +includes: [asyncHelpers.js] +---*/ + +asyncTest(async function () { + var caught = false; + const p = assert.throwsAsync(function () {}); + assert(p instanceof Promise); + try { + await p; + } catch (err) { + caught = true; + assert.sameValue( + err.constructor, + Test262Error, + "Expected a Test262Error, but a '" + + err.constructor.name + + "' was thrown." + ); + } finally { + assert( + caught, + "assert.throwsAsync did not reject when invoked with a single argumemnt" + ); + } +}); diff --git a/test/sendable/harness/byteConversionValues.js b/test/sendable/harness/byteConversionValues.js new file mode 100644 index 00000000000..c02533947ea --- /dev/null +++ b/test/sendable/harness/byteConversionValues.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Ensure the original and expected values are set properly +includes: [byteConversionValues.js] +---*/ + +var values = byteConversionValues.values; +var expected = byteConversionValues.expected; + +assert(values.length > 0); +assert.sameValue(values.length, expected.Float32.length, "Float32"); +assert.sameValue(values.length, expected.Float64.length, "Float64"); +assert.sameValue(values.length, expected.Int8.length, "Int8"); +assert.sameValue(values.length, expected.Int16.length, "Int16"); +assert.sameValue(values.length, expected.Int32.length, "Int32"); +assert.sameValue(values.length, expected.Uint8.length, "Uint8"); +assert.sameValue(values.length, expected.Uint16.length, "Uint16"); +assert.sameValue(values.length, expected.Uint32.length, "Uint32"); +assert.sameValue(values.length, expected.Uint8Clamped.length, "Uint8Clamped"); diff --git a/test/sendable/harness/compare-array-arguments.js b/test/sendable/harness/compare-array-arguments.js new file mode 100644 index 00000000000..13c6d36edd1 --- /dev/null +++ b/test/sendable/harness/compare-array-arguments.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Accepts spreadable arguments +includes: [compareArray.js] +---*/ + +const fixture = [0, 'a', undefined]; + +function checkFormatOfAssertionMessage(func, errorMessage) { + var caught = false; + try { + func(); + } catch (error) { + caught = true; + assert.sameValue(error.constructor, Test262Error); + assert.sameValue(error.message, errorMessage); + } + + assert(caught, `Expected ${func} to throw, but it didn't.`); +} + +function f() { + assert.compareArray(arguments, fixture); + assert.compareArray(fixture, arguments); + + checkFormatOfAssertionMessage(() => { + assert.compareArray(arguments, [], 'arguments and []'); + }, 'Actual [0, a, undefined] and expected [] should have the same contents. arguments and []'); + + checkFormatOfAssertionMessage(() => { + assert.compareArray([], arguments, '[] and arguments'); + }, 'Actual [] and expected [0, a, undefined] should have the same contents. [] and arguments'); +} + +f(...fixture); diff --git a/test/sendable/harness/compare-array-arraylike.js b/test/sendable/harness/compare-array-arraylike.js new file mode 100644 index 00000000000..dd7077221a1 --- /dev/null +++ b/test/sendable/harness/compare-array-arraylike.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Accepts spreadable arguments +includes: [compareArray.js] +---*/ + +function checkFormatOfAssertionMessage(func, errorMessage) { + var caught = false; + try { + func(); + } catch (error) { + caught = true; + assert.sameValue(error.constructor, Test262Error); + assert.sameValue(error.message, errorMessage); + } + + assert(caught, `Expected ${func} to throw, but it didn't.`); +} + +const fixture = { length: 3, 0: 0, 1: 'a', 2: undefined}; + +assert.compareArray(fixture, [0, 'a', undefined]); +assert.compareArray([0, 'a', undefined], fixture); + +checkFormatOfAssertionMessage(() => { + assert.compareArray(fixture, [], 'fixture and []'); +}, 'Actual [0, a, undefined] and expected [] should have the same contents. fixture and []'); + +checkFormatOfAssertionMessage(() => { + assert.compareArray([], fixture, '[] and fixture'); +}, 'Actual [] and expected [0, a, undefined] should have the same contents. [] and fixture'); diff --git a/test/sendable/harness/compare-array-different-elements.js b/test/sendable/harness/compare-array-different-elements.js new file mode 100644 index 00000000000..f88c792b730 --- /dev/null +++ b/test/sendable/harness/compare-array-different-elements.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Arrays containing different elements are not equivalent. +includes: [compareArray.js] +---*/ + +var first = [0, 'a', undefined]; +var second = [0, 'b', undefined]; + +assert.throws(Test262Error, () => { + assert.compareArray(first, second); +}, 'Arrays containing different elements are not equivalent.'); diff --git a/test/sendable/harness/compare-array-different-length.js b/test/sendable/harness/compare-array-different-length.js new file mode 100644 index 00000000000..adc42a7546a --- /dev/null +++ b/test/sendable/harness/compare-array-different-length.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Arrays of differing lengths are not equivalent. +includes: [compareArray.js] +---*/ + + +assert.throws(Test262Error, () => { + assert.compareArray([], [undefined]); +}, 'Arrays of differing lengths are not equivalent.'); + +assert.throws(Test262Error, () => { + assert.compareArray([undefined], []); +}, 'Arrays of differing lengths are not equivalent.'); diff --git a/test/sendable/harness/compare-array-empty.js b/test/sendable/harness/compare-array-empty.js new file mode 100644 index 00000000000..4fdc1850e23 --- /dev/null +++ b/test/sendable/harness/compare-array-empty.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Empty arrays of are equivalent. +includes: [compareArray.js] +---*/ + +assert.compareArray([], [], 'Empty arrays are equivalent.'); diff --git a/test/sendable/harness/compare-array-falsy-arguments.js b/test/sendable/harness/compare-array-falsy-arguments.js new file mode 100644 index 00000000000..1b090010dc9 --- /dev/null +++ b/test/sendable/harness/compare-array-falsy-arguments.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + compareArray gracefully handles nullish arguments. +includes: [compareArray.js] +---*/ + +function assertThrows(func, errorMessage) { + var caught = false; + try { + func(); + } catch (error) { + caught = true; + assert.sameValue(error.constructor, Test262Error); + assert.sameValue(error.message, errorMessage); + } + + assert(caught, `Expected ${func} to throw, but it didn't.`); +} + +assertThrows(() => assert.compareArray(), "Actual argument shouldn't be nullish. "); +assertThrows(() => assert.compareArray(null, []), "Actual argument shouldn't be nullish. "); +assertThrows(() => assert.compareArray(null, [], "foo"), "Actual argument shouldn't be nullish. foo"); + +assertThrows(() => assert.compareArray([]), "Expected argument shouldn't be nullish. "); +assertThrows(() => assert.compareArray([], undefined, "foo"), "Expected argument shouldn't be nullish. foo"); diff --git a/test/sendable/harness/compare-array-message.js b/test/sendable/harness/compare-array-message.js new file mode 100644 index 00000000000..2e28ee65d86 --- /dev/null +++ b/test/sendable/harness/compare-array-message.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + compareArray can handle any value in message arg +includes: [compareArray.js] +features: [BigInt, Symbol] +---*/ + +assert.compareArray([], [], true); +assert.compareArray([], [], 1); +assert.compareArray([], [], 1n); +assert.compareArray([], [], () => {}); +assert.compareArray([], [], "test262"); +assert.compareArray([], [], Symbol("1")); +assert.compareArray([], [], {}); +assert.compareArray([], [], []); +assert.compareArray([], [], -1); +assert.compareArray([], [], Infinity); +assert.compareArray([], [], -Infinity); +assert.compareArray([], [], 0.1); +assert.compareArray([], [], -0.1); diff --git a/test/sendable/harness/compare-array-same-elements-different-order.js b/test/sendable/harness/compare-array-same-elements-different-order.js new file mode 100644 index 00000000000..639331a1fb2 --- /dev/null +++ b/test/sendable/harness/compare-array-same-elements-different-order.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Arrays containg the same elements in different order are not equivalent. +includes: [compareArray.js] +---*/ + +var obj = {}; +var first = [0, 1, '', 's', null, undefined, obj]; +var second = [0, 1, '', 's', undefined, null, obj]; + +assert.throws(Test262Error, () => { + assert.compareArray(first, second); +}, 'Arrays containing the same elements in different order are not equivalent.'); diff --git a/test/sendable/harness/compare-array-same-elements-same-order.js b/test/sendable/harness/compare-array-same-elements-same-order.js new file mode 100644 index 00000000000..d8f17b8cef4 --- /dev/null +++ b/test/sendable/harness/compare-array-same-elements-same-order.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Arrays containg the same elements in the same order are equivalent. +includes: [compareArray.js] +---*/ + +var obj = {}; +var first = [0, 1, '', 's', undefined, null, obj]; +var second = [0, 1, '', 's', undefined, null, obj]; + +assert.compareArray(first, second, 'Arrays containing the same elements in the same order are equivalent.'); diff --git a/test/sendable/harness/compare-array-samevalue.js b/test/sendable/harness/compare-array-samevalue.js new file mode 100644 index 00000000000..063309c1804 --- /dev/null +++ b/test/sendable/harness/compare-array-samevalue.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + compareArray uses SameValue for value comparison. +includes: [compareArray.js] +---*/ + +assert.compareArray([NaN], [NaN]); +assert.throws(Test262Error, () => { + assert.compareArray([0], [-0]); +}); diff --git a/test/sendable/harness/compare-array-sparse.js b/test/sendable/harness/compare-array-sparse.js new file mode 100644 index 00000000000..e62352df68b --- /dev/null +++ b/test/sendable/harness/compare-array-sparse.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Spares arrays are only equivalent if they have the same length. +includes: [compareArray.js] +---*/ + + +assert.compareArray([,], [,], 'Sparse arrays of the same length are equivalent.'); +assert.throws(Test262Error, () => { + assert.compareArray([,], [,,]); +}, 'Sparse arrays of differing lengths are not equivalent.'); +assert.throws(Test262Error, () => { + assert.compareArray([,,], [,]); +}, 'Sparse arrays of differing lengths are not equivalent.'); +assert.throws(Test262Error, () => { + assert.compareArray([,], []); +}, 'Sparse arrays are not equivalent to empty arrays.'); +assert.throws(Test262Error, () => { + assert.compareArray([], [,]); +}, 'Sparse arrays are not equivalent to empty arrays.'); diff --git a/test/sendable/harness/compare-array-symbol.js b/test/sendable/harness/compare-array-symbol.js new file mode 100644 index 00000000000..851741af51f --- /dev/null +++ b/test/sendable/harness/compare-array-symbol.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + compareArray correctly formats Symbols in error message. +includes: [compareArray.js] +features: [Symbol] +---*/ + +var threw = false; + +try { + assert.compareArray([Symbol()], [Symbol('desc')]); +} catch (err) { + threw = true; + + assert.sameValue(err.constructor, Test262Error); + assert(err.message.indexOf('[Symbol()]') !== -1); + assert(err.message.indexOf('[Symbol(desc)]') !== -1); +} + +assert(threw); diff --git a/test/sendable/harness/dateConstants.js b/test/sendable/harness/dateConstants.js new file mode 100644 index 00000000000..96471ba49fb --- /dev/null +++ b/test/sendable/harness/dateConstants.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Including dateConstants.js will expose: + + var date_1899_end = -2208988800001; + var date_1900_start = -2208988800000; + var date_1969_end = -1; + var date_1970_start = 0; + var date_1999_end = 946684799999; + var date_2000_start = 946684800000; + var date_2099_end = 4102444799999; + var date_2100_start = 4102444800000; + +includes: [dateConstants.js] +---*/ +assert.sameValue(date_1899_end, -2208988800001); +assert.sameValue(date_1900_start, -2208988800000); +assert.sameValue(date_1969_end, -1); +assert.sameValue(date_1970_start, 0); +assert.sameValue(date_1999_end, 946684799999); +assert.sameValue(date_2000_start, 946684800000); +assert.sameValue(date_2099_end, 4102444799999); +assert.sameValue(date_2100_start, 4102444800000); diff --git a/test/sendable/harness/decimalToHexString.js b/test/sendable/harness/decimalToHexString.js new file mode 100644 index 00000000000..921e6746f03 --- /dev/null +++ b/test/sendable/harness/decimalToHexString.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Including decimalToHexString.js will expose two functions: + + decimalToHexString + decimalToPercentHexString + +includes: [decimalToHexString.js] +---*/ + +assert.sameValue(decimalToHexString(-1), "FFFFFFFF"); +assert.sameValue(decimalToHexString(0.5), "0000"); +assert.sameValue(decimalToHexString(1), "0001"); +assert.sameValue(decimalToHexString(100), "0064"); +assert.sameValue(decimalToHexString(65535), "FFFF"); +assert.sameValue(decimalToHexString(65536), "10000"); + +assert.sameValue(decimalToPercentHexString(-1), "%FF"); +assert.sameValue(decimalToPercentHexString(0.5), "%00"); +assert.sameValue(decimalToPercentHexString(1), "%01"); +assert.sameValue(decimalToPercentHexString(100), "%64"); +assert.sameValue(decimalToPercentHexString(65535), "%FF"); +assert.sameValue(decimalToPercentHexString(65536), "%00"); diff --git a/test/sendable/harness/deepEqual-array.js b/test/sendable/harness/deepEqual-array.js new file mode 100644 index 00000000000..8c06a34ffbb --- /dev/null +++ b/test/sendable/harness/deepEqual-array.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + array values compare correctly. +includes: [deepEqual.js] +---*/ + +assert.deepEqual([], []); +assert.deepEqual([1, "a", true], [1, "a", true]); + +assert.throws(Test262Error, function () { assert.deepEqual([], [1]); }); +assert.throws(Test262Error, function () { assert.deepEqual([1, "a", true], [1, "a", false]); }); diff --git a/test/sendable/harness/deepEqual-circular.js b/test/sendable/harness/deepEqual-circular.js new file mode 100644 index 00000000000..656c35d5d74 --- /dev/null +++ b/test/sendable/harness/deepEqual-circular.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + values compare correctly with circular references. +includes: [deepEqual.js] +---*/ + +var a = { x: 1 }; +var b = { x: 1 }; +a.a = a; +a.b = b; +b.a = b; +b.b = a; + +assert.deepEqual(a, b); diff --git a/test/sendable/harness/deepEqual-deep.js b/test/sendable/harness/deepEqual-deep.js new file mode 100644 index 00000000000..bd8b4eb8e25 --- /dev/null +++ b/test/sendable/harness/deepEqual-deep.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + values compare correctly. +includes: [deepEqual.js] +---*/ + +assert.deepEqual({ a: { x: 1 }, b: [true] }, { a: { x: 1 }, b: [true] }); + +assert.throws(Test262Error, function () { assert.deepEqual({}, { a: { x: 1 }, b: [true] }); }); +assert.throws(Test262Error, function () { assert.deepEqual({ a: { x: 1 }, b: [true] }, { a: { x: 1 }, b: [false] }); }); diff --git a/test/sendable/harness/deepEqual-mapset.js b/test/sendable/harness/deepEqual-mapset.js new file mode 100644 index 00000000000..cbf2dcdcca4 --- /dev/null +++ b/test/sendable/harness/deepEqual-mapset.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + map/set values compare correctly. +includes: [deepEqual.js] +---*/ + +assert.deepEqual(new Set(), new Set()); +assert.deepEqual(new Set([1, "a", true]), new Set([1, "a", true])); +assert.deepEqual(new Map(), new Map()); +assert.deepEqual(new Map([[1, "a"], ["b", true]]), new Map([[1, "a"], ["b", true]])); + +assert.throws(Test262Error, function () { assert.deepEqual(new Set([]), new Set([1])); }); +assert.throws(Test262Error, function () { assert.deepEqual(new Set([1, "a", true]), new Set([1, "a", false])); }); +assert.throws(Test262Error, function () { assert.deepEqual(new Map([]), new Map([[1, "a"], ["b", true]])); }); +assert.throws(Test262Error, function () { assert.deepEqual(new Map([[1, "a"], ["b", true]]), new Map([[1, "a"], ["b", false]])); }); +assert.throws(Test262Error, function () { assert.deepEqual(new Map([[1, "a"], ["b", true]]), new Set([[1, "a"], ["b", false]])); }); diff --git a/test/sendable/harness/deepEqual-object.js b/test/sendable/harness/deepEqual-object.js new file mode 100644 index 00000000000..e087864c389 --- /dev/null +++ b/test/sendable/harness/deepEqual-object.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + object values compare correctly. +includes: [deepEqual.js] +---*/ + + +assert.deepEqual({}, {}); +assert.deepEqual({ a: 1, b: true }, { a: 1, b: true }); + +assert.throws(Test262Error, function () { assert.deepEqual({}, { a: 1, b: true }); }); +assert.throws(Test262Error, function () { assert.deepEqual({ a: 1, b: true }, { a: 1, b: false }); }); diff --git a/test/sendable/harness/deepEqual-primitives-bigint.js b/test/sendable/harness/deepEqual-primitives-bigint.js new file mode 100644 index 00000000000..db511f8b365 --- /dev/null +++ b/test/sendable/harness/deepEqual-primitives-bigint.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + primitive BigInt values compare correctly. +features: [BigInt] +includes: [deepEqual.js] +---*/ + +assert.deepEqual(1n, 1n); +assert.deepEqual(Object(1n), 1n); + +assert.throws(Test262Error, function () { assert.deepEqual(1n, 1); }); +assert.throws(Test262Error, function () { assert.deepEqual(1n, 2n); }); diff --git a/test/sendable/harness/deepEqual-primitives.js b/test/sendable/harness/deepEqual-primitives.js new file mode 100644 index 00000000000..236791ba197 --- /dev/null +++ b/test/sendable/harness/deepEqual-primitives.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + primitive values compare correctly. +includes: [deepEqual.js] +---*/ + + +var s1 = Symbol(); +var s2 = Symbol(); +assert.deepEqual(null, null); +assert.deepEqual(undefined, undefined); +assert.deepEqual("a", "a"); +assert.deepEqual(1, 1); +assert.deepEqual(true, true); +assert.deepEqual(s1, s1); +assert.deepEqual(Object("a"), "a"); +assert.deepEqual(Object(1), 1); +assert.deepEqual(Object(true), true); +assert.deepEqual(Object(s1), s1); + +assert.throws(Test262Error, function () { assert.deepEqual(null, 0); }); +assert.throws(Test262Error, function () { assert.deepEqual(undefined, 0); }); +assert.throws(Test262Error, function () { assert.deepEqual("", 0); }); +assert.throws(Test262Error, function () { assert.deepEqual("1", 1); }); +assert.throws(Test262Error, function () { assert.deepEqual("1", "2"); }); +assert.throws(Test262Error, function () { assert.deepEqual(true, 1); }); +assert.throws(Test262Error, function () { assert.deepEqual(true, false); }); +assert.throws(Test262Error, function () { assert.deepEqual(s1, "Symbol()"); }); +assert.throws(Test262Error, function () { assert.deepEqual(s1, s2); }); diff --git a/test/sendable/harness/detachArrayBuffer-host-detachArrayBuffer.js b/test/sendable/harness/detachArrayBuffer-host-detachArrayBuffer.js new file mode 100644 index 00000000000..a41eca6eee4 --- /dev/null +++ b/test/sendable/harness/detachArrayBuffer-host-detachArrayBuffer.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Including detachArrayBuffer.js will expose a function: + + $DETACHBUFFER + + $DETACHBUFFER relies on the presence of a host definition for $262.detachArrayBuffer + +includes: [detachArrayBuffer.js] +---*/ + +var $262 = { + detachArrayBuffer() { + throw new Test262Error('$262.detachArrayBuffer called.'); + }, + destroy() {} +}; + +var ab = new ArrayBuffer(1); +var threw = false; + +try { + $DETACHBUFFER(ab); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } + if (err.message !== '$262.detachArrayBuffer called.') { + throw new Error(`Expected error message: ${err.message}`); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} + + diff --git a/test/sendable/harness/detachArrayBuffer.js b/test/sendable/harness/detachArrayBuffer.js new file mode 100644 index 00000000000..d8a6bb28d70 --- /dev/null +++ b/test/sendable/harness/detachArrayBuffer.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Including detachArrayBuffer.js will expose a function: + + $DETACHBUFFER + + $DETACHBUFFER relies on the presence of a definition for $262.detachArrayBuffer. + + Without a definition, calling $DETACHBUFFER will result in a ReferenceError +---*/ + +var ab = new ArrayBuffer(1); +var threw = false; + +try { + $DETACHBUFFER(ab); +} catch(err) { + threw = true; + if (err.constructor !== ReferenceError) { + throw new Error( + 'Expected a ReferenceError, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a ReferenceError, but no error was thrown.'); +} + + diff --git a/test/sendable/harness/fnGlobalObject.js b/test/sendable/harness/fnGlobalObject.js new file mode 100644 index 00000000000..79612ca56c4 --- /dev/null +++ b/test/sendable/harness/fnGlobalObject.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Including fnGlobalObject.js will expose a function: + + fnGlobalObject + + fnGlobalObject returns a reference to the global object. + +includes: [fnGlobalObject.js] +---*/ + +var gO = fnGlobalObject(); + +assert(typeof gO === "object"); +assert.sameValue(gO, this); diff --git a/test/sendable/harness/isConstructor.js b/test/sendable/harness/isConstructor.js new file mode 100644 index 00000000000..7c93bf57e35 --- /dev/null +++ b/test/sendable/harness/isConstructor.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Including isConstructor.js will expose one function: + + isConstructor + +includes: [isConstructor.js] +features: [generators, Reflect.construct] +---*/ + +assert.sameValue(typeof isConstructor, "function"); + +assert.throws(Test262Error, () => isConstructor(), "no argument"); +assert.throws(Test262Error, () => isConstructor(undefined), "undefined"); +assert.throws(Test262Error, () => isConstructor(null), "null"); +assert.throws(Test262Error, () => isConstructor(123), "number"); +assert.throws(Test262Error, () => isConstructor(true), "boolean - true"); +assert.throws(Test262Error, () => isConstructor(false), "boolean - false"); +assert.throws(Test262Error, () => isConstructor("string"), "string"); + +assert.throws(Test262Error, () => isConstructor({}), "Object instance"); +assert.throws(Test262Error, () => isConstructor([]), "Array instance"); + +assert.sameValue(isConstructor(function(){}), true); +assert.sameValue(isConstructor(function*(){}), false); +assert.sameValue(isConstructor(() => {}), false); + +assert.sameValue(isConstructor(Array), true); +assert.sameValue(isConstructor(Array.prototype.map), false); diff --git a/test/sendable/harness/nans.js b/test/sendable/harness/nans.js new file mode 100644 index 00000000000..1e88c35b2f4 --- /dev/null +++ b/test/sendable/harness/nans.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Including nans.js will expose: + + var NaNs = [ + NaN, + Number.NaN, + NaN * 0, + 0/0, + Infinity/Infinity, + -(0/0), + Math.pow(-1, 0.5), + -Math.pow(-1, 0.5), + Number("Not-a-Number"), + ]; + +includes: [nans.js] +---*/ + +for (var i = 0; i < NaNs.length; i++) { + assert.sameValue(Number.isNaN(NaNs[i]), true, "index: " + i); +} diff --git a/test/sendable/harness/nativeFunctionMatcher.js b/test/sendable/harness/nativeFunctionMatcher.js new file mode 100644 index 00000000000..eb5837e8afa --- /dev/null +++ b/test/sendable/harness/nativeFunctionMatcher.js @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Ensure that the regular expression generally distinguishes between valid + and invalid forms of the NativeFunction grammar production. +includes: [nativeFunctionMatcher.js] +---*/ + +[ + 'function(){[native code]}', + 'function(){ [native code] }', + 'function ( ) { [ native code ] }', + 'function a(){ [native code] }', + 'function a(){ /* } */ [native code] }', + `function a() { + // test + [native code] + /* test */ + }`, + 'function(a, b = function() { []; }) { [native code] }', + 'function [Symbol.xyz]() { [native code] }', + 'function [x[y][z[d]()]]() { [native code] }', + 'function ["]"] () { [native code] }', + 'function [\']\'] () { [native code] }', + '/* test */ function() { [native code] }', + 'function() { [native code] } /* test */', + 'function() { [native code] } // test', +].forEach((s) => { + try { + validateNativeFunctionSource(s); + } catch (unused) { + throw new Error(`${JSON.stringify(s)} should pass`); + } +}); + +[ + 'native code', + 'function() {}', + 'function(){ "native code" }', + 'function(){ [] native code }', + 'function()) { [native code] }', + 'function(() { [native code] }', + 'function []] () { [native code] }', + 'function [[] () { [native code] }', + 'function ["]] () { [native code] }', + 'function [\']] () { [native code] }', + 'function() { [native code] /* }', + '// function() { [native code] }', +].forEach((s) => { + let fail = false; + try { + validateNativeFunctionSource(s); + fail = true; + } catch (unused) {} + if (fail) { + throw new Error(`${JSON.stringify(s)} should fail`); + } +}); diff --git a/test/sendable/harness/promiseHelper.js b/test/sendable/harness/promiseHelper.js new file mode 100644 index 00000000000..3b9a3fb4022 --- /dev/null +++ b/test/sendable/harness/promiseHelper.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Including promiseHelper.js will expose a function: + + checkSequence + + To ensure execution order of some async chain, checkSequence accepts an array + of numbers, each added during some operation, and verifies that they + are in numeric order. + +includes: [promiseHelper.js] +---*/ + +assert(checkSequence([1, 2, 3, 4, 5])); + +var threw = false; + +try { + checkSequence([2, 1, 3, 4, 5]); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} + diff --git a/test/sendable/harness/propertyhelper-verifyconfigurable-configurable-object.js b/test/sendable/harness/propertyhelper-verifyconfigurable-configurable-object.js new file mode 100644 index 00000000000..86d2eee7082 --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifyconfigurable-configurable-object.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified property is configurable satisfy the assertion. +includes: [propertyHelper.js] +---*/ + +Object.defineProperty(this, 'Object', { + configurable: true, + value: Object +}); + +verifyConfigurable(this, 'Object'); diff --git a/test/sendable/harness/propertyhelper-verifyconfigurable-configurable.js b/test/sendable/harness/propertyhelper-verifyconfigurable-configurable.js new file mode 100644 index 00000000000..dbe3cfb927f --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifyconfigurable-configurable.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified property is configurable satisfy the assertion. +includes: [propertyHelper.js] +---*/ + +var obj = {}; +Object.defineProperty(obj, 'a', { + configurable: true +}); + +verifyConfigurable(obj, 'a'); diff --git a/test/sendable/harness/propertyhelper-verifyconfigurable-not-configurable.js b/test/sendable/harness/propertyhelper-verifyconfigurable-not-configurable.js new file mode 100644 index 00000000000..ce4e580a583 --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifyconfigurable-not-configurable.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified property is not configurable do not satisfy the + assertion. +includes: [propertyHelper.js] +---*/ + +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + configurable: false +}); + +try { + verifyConfigurable(obj, 'a'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/propertyhelper-verifyenumerable-enumerable-symbol.js b/test/sendable/harness/propertyhelper-verifyenumerable-enumerable-symbol.js new file mode 100644 index 00000000000..392158459d2 --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifyenumerable-enumerable-symbol.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified symbol property is enumerable satisfy the assertion. +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var obj = {}; +var s = Symbol('1'); +Object.defineProperty(obj, s, { + enumerable: true +}); + +verifyEnumerable(obj, s); diff --git a/test/sendable/harness/propertyhelper-verifyenumerable-enumerable.js b/test/sendable/harness/propertyhelper-verifyenumerable-enumerable.js new file mode 100644 index 00000000000..e065b0487d1 --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifyenumerable-enumerable.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified string property is enumerable satisfy the assertion. +includes: [propertyHelper.js] +---*/ + +var obj = {}; +Object.defineProperty(obj, 'a', { + enumerable: true +}); + +verifyEnumerable(obj, 'a'); diff --git a/test/sendable/harness/propertyhelper-verifyenumerable-not-enumerable-symbol.js b/test/sendable/harness/propertyhelper-verifyenumerable-not-enumerable-symbol.js new file mode 100644 index 00000000000..834e3803565 --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifyenumerable-not-enumerable-symbol.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified symbol property is not enumerable do not satisfy the + assertion. +includes: [propertyHelper.js] +features: [Symbol] +---*/ +var threw = false; +var obj = {}; +var s = Symbol('1'); +Object.defineProperty(obj, s, { + enumerable: false +}); + +try { + verifyEnumerable(obj, s); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Test262Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/propertyhelper-verifyenumerable-not-enumerable.js b/test/sendable/harness/propertyhelper-verifyenumerable-not-enumerable.js new file mode 100644 index 00000000000..b89b60bd1a1 --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifyenumerable-not-enumerable.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified string property is not enumerable do not satisfy the + assertion. +includes: [propertyHelper.js] +---*/ +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + enumerable: false +}); + +try { + verifyEnumerable(obj, 'a'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Test262Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/propertyhelper-verifynotconfigurable-configurable.js b/test/sendable/harness/propertyhelper-verifynotconfigurable-configurable.js new file mode 100644 index 00000000000..c8588def2a1 --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifynotconfigurable-configurable.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified property is configurable do not satisfy the + assertion. +includes: [propertyHelper.js] +---*/ +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + configurable: true +}); + +try { + verifyNotConfigurable(obj, 'a'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/propertyhelper-verifynotconfigurable-not-configurable.js b/test/sendable/harness/propertyhelper-verifynotconfigurable-not-configurable.js new file mode 100644 index 00000000000..44441eefe9f --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifynotconfigurable-not-configurable.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified property is not configurable satisfy the assertion. +includes: [propertyHelper.js] +---*/ + +var obj = {}; +Object.defineProperty(obj, 'a', { + configurable: false +}); + +verifyNotConfigurable(obj, 'a'); diff --git a/test/sendable/harness/propertyhelper-verifynotenumerable-enumerable-symbol.js b/test/sendable/harness/propertyhelper-verifynotenumerable-enumerable-symbol.js new file mode 100644 index 00000000000..aabe520fb34 --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifynotenumerable-enumerable-symbol.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified symbol property is enumerable do not satisfy the + assertion. +includes: [propertyHelper.js] +features: [Symbol] +---*/ +var threw = false; +var obj = {}; +var s = Symbol('1'); +Object.defineProperty(obj, s, { + enumerable: true +}); + +try { + verifyNotEnumerable(obj, s); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Test262Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Test262Error( + 'Expected a Test262Error, but no error was thrown for symbol key.' + ); +} diff --git a/test/sendable/harness/propertyhelper-verifynotenumerable-enumerable.js b/test/sendable/harness/propertyhelper-verifynotenumerable-enumerable.js new file mode 100644 index 00000000000..6199175ef49 --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifynotenumerable-enumerable.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified string property is enumerable do not satisfy the + assertion. +includes: [propertyHelper.js] +---*/ +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + enumerable: true +}); + +try { + verifyNotEnumerable(obj, 'a'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Test262Error( + 'Expected a Test262Error, but no error was thrown for string key.' + ); +} diff --git a/test/sendable/harness/propertyhelper-verifynotenumerable-not-enumerable-symbol.js b/test/sendable/harness/propertyhelper-verifynotenumerable-not-enumerable-symbol.js new file mode 100644 index 00000000000..0b9ab739f30 --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifynotenumerable-not-enumerable-symbol.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified symbol property is not enumerable satisfy the + assertion. +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var obj = {}; +var s = Symbol('1'); +Object.defineProperty(obj, s, { + enumerable: false +}); + +verifyNotEnumerable(obj, s); diff --git a/test/sendable/harness/propertyhelper-verifynotenumerable-not-enumerable.js b/test/sendable/harness/propertyhelper-verifynotenumerable-not-enumerable.js new file mode 100644 index 00000000000..49df7e7b52d --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifynotenumerable-not-enumerable.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified string property is not enumerable satisfy the + assertion. +includes: [propertyHelper.js] +---*/ + +var obj = {}; +Object.defineProperty(obj, 'a', { + enumerable: false +}); + +verifyNotEnumerable(obj, 'a'); diff --git a/test/sendable/harness/propertyhelper-verifynotwritable-not-writable-strict.js b/test/sendable/harness/propertyhelper-verifynotwritable-not-writable-strict.js new file mode 100644 index 00000000000..169234db906 --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifynotwritable-not-writable-strict.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified property is not writable satisfy the assertion. +includes: [propertyHelper.js] +---*/ + +var obj = {}; + +Object.defineProperty(obj, 'a', { + writable: false, + value: 123 +}); + +verifyNotWritable(obj, 'a'); + +if (obj.a !== 123) { + throw new Error('`verifyNotWritable` should be non-destructive.'); +} diff --git a/test/sendable/harness/propertyhelper-verifynotwritable-writable.js b/test/sendable/harness/propertyhelper-verifynotwritable-writable.js new file mode 100644 index 00000000000..5671e3cff8a --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifynotwritable-writable.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified property is writable do not satisfy the assertion. +includes: [propertyHelper.js] +---*/ +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + writable: true, + value: 1 +}); + +try { + verifyNotWritable(obj, 'a'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/propertyhelper-verifywritable-array-length.js b/test/sendable/harness/propertyhelper-verifywritable-array-length.js new file mode 100644 index 00000000000..d0ee0a61c2c --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifywritable-array-length.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + "length" property of Arrays is tested with valid value. +includes: [propertyHelper.js] +---*/ + +var array = [1, 2, 3]; + +verifyWritable(array, "length"); + +assert.sameValue(array.length, 3, '`verifyWritable` should be non-destructive.'); diff --git a/test/sendable/harness/propertyhelper-verifywritable-not-writable.js b/test/sendable/harness/propertyhelper-verifywritable-not-writable.js new file mode 100644 index 00000000000..558160d1d47 --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifywritable-not-writable.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified property is not writable do not satisfy the + assertion. +includes: [propertyHelper.js] +---*/ +var threw = false; +var obj = {}; +Object.defineProperty(obj, 'a', { + writable: false +}); + +try { + verifyWritable(obj, 'a'); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/propertyhelper-verifywritable-writable.js b/test/sendable/harness/propertyhelper-verifywritable-writable.js new file mode 100644 index 00000000000..fddeafd838b --- /dev/null +++ b/test/sendable/harness/propertyhelper-verifywritable-writable.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified property is writable satisfy the assertion. +includes: [propertyHelper.js] +---*/ +var obj = {}; + +Object.defineProperty(obj, 'a', { + writable: true, + value: 123 +}); + +verifyWritable(obj, 'a'); + +if (obj.a !== 123) { + throw new Error('`verifyWritable` should be non-destructive.'); +} diff --git a/test/sendable/harness/proxytrapshelper-default.js b/test/sendable/harness/proxytrapshelper-default.js new file mode 100644 index 00000000000..3a686c37f30 --- /dev/null +++ b/test/sendable/harness/proxytrapshelper-default.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: allowProxyTraps helper should default throw on all the proxy trap named methods being invoked +esid: pending +author: Jordan Harband +includes: [proxyTrapsHelper.js] +---*/ + +var traps = allowProxyTraps(); + +function assertTrapThrows(trap) { + if (typeof traps[trap] !== 'function') { + throw new Test262Error('trap ' + trap + ' is not a function'); + } + var failedToThrow = false; + try { + traps[trap](); + failedToThrow = true; + } catch (e) {} + if (failedToThrow) { + throw new Test262Error('trap ' + trap + ' did not throw an error'); + } +} + +assertTrapThrows('getPrototypeOf'); +assertTrapThrows('setPrototypeOf'); +assertTrapThrows('isExtensible'); +assertTrapThrows('preventExtensions'); +assertTrapThrows('getOwnPropertyDescriptor'); +assertTrapThrows('has'); +assertTrapThrows('get'); +assertTrapThrows('set'); +assertTrapThrows('deleteProperty'); +assertTrapThrows('defineProperty'); +assertTrapThrows('enumerate'); +assertTrapThrows('ownKeys'); +assertTrapThrows('apply'); +assertTrapThrows('construct'); diff --git a/test/sendable/harness/proxytrapshelper-overrides.js b/test/sendable/harness/proxytrapshelper-overrides.js new file mode 100644 index 00000000000..14f2c7ac5d6 --- /dev/null +++ b/test/sendable/harness/proxytrapshelper-overrides.js @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: allowProxyTraps helper should default throw on all the proxy trap named methods being invoked +esid: pending +author: Jordan Harband +includes: [proxyTrapsHelper.js] +---*/ +var overrides = { + getPrototypeOf: function () {}, + setPrototypeOf: function () {}, + isExtensible: function () {}, + preventExtensions: function () {}, + getOwnPropertyDescriptor: function () {}, + has: function () {}, + get: function () {}, + set: function () {}, + deleteProperty: function () {}, + defineProperty: function () {}, + enumerate: function () {}, + ownKeys: function () {}, + apply: function () {}, + construct: function () {}, +}; +var traps = allowProxyTraps(overrides); + +function assertTrapSucceeds(trap) { + if (typeof traps[trap] !== 'function') { + throw new Test262Error('trap ' + trap + ' is not a function'); + } + if (traps[trap] !== overrides[trap]) { + throw new Test262Error('trap ' + trap + ' was not overriden in allowProxyTraps'); + } + var threw = false; + try { + traps[trap](); + } catch (e) { + threw = true; + } + if (threw) { + throw new Test262Error('trap ' + trap + ' threw an error'); + } +} + +function assertTrapThrows(trap) { + if (typeof traps[trap] !== 'function') { + throw new Test262Error('trap ' + trap + ' is not a function'); + } + var failedToThrow = false; + try { + traps[trap](); + failedToThrow = true; + } catch (e) {} + if (failedToThrow) { + throw new Test262Error('trap ' + trap + ' did not throw an error'); + } +} + +assertTrapSucceeds('getPrototypeOf'); +assertTrapSucceeds('setPrototypeOf'); +assertTrapSucceeds('isExtensible'); +assertTrapSucceeds('preventExtensions'); +assertTrapSucceeds('getOwnPropertyDescriptor'); +assertTrapSucceeds('has'); +assertTrapSucceeds('get'); +assertTrapSucceeds('set'); +assertTrapSucceeds('deleteProperty'); +assertTrapSucceeds('defineProperty'); +assertTrapSucceeds('ownKeys'); +assertTrapSucceeds('apply'); +assertTrapSucceeds('construct'); + +// enumerate should always throw because the trap has been removed +assertTrapThrows('enumerate'); diff --git a/test/sendable/harness/sta.js b/test/sendable/harness/sta.js new file mode 100644 index 00000000000..1c6e7c9a29d --- /dev/null +++ b/test/sendable/harness/sta.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Including sta.js will expose three functions: + + Test262Error + Test262Error.thrower + $DONOTEVALUATE +---*/ + +assert(typeof Test262Error === "function"); +assert(typeof Test262Error.prototype.toString === "function"); +assert(typeof Test262Error.thrower === "function"); +assert(typeof $DONOTEVALUATE === "function"); diff --git a/test/sendable/harness/tcoHelper.js b/test/sendable/harness/tcoHelper.js new file mode 100644 index 00000000000..f6666bb06eb --- /dev/null +++ b/test/sendable/harness/tcoHelper.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Including tcoHelper.js will expose: + + var $MAX_ITERATIONS = 100000; + + This defines the number of consecutive recursive function calls that must be + made in order to prove that stack frames are properly destroyed according to + ES2015 tail call optimization semantics. + +includes: [tcoHelper.js] +---*/ + + +assert.sameValue($MAX_ITERATIONS, 100000); diff --git a/test/sendable/harness/testTypedArray-conversions-call-error.js b/test/sendable/harness/testTypedArray-conversions-call-error.js new file mode 100644 index 00000000000..8902d448ac4 --- /dev/null +++ b/test/sendable/harness/testTypedArray-conversions-call-error.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Including testTypedArray.js will expose: + + testTypedArrayConversions() + +includes: [testTypedArray.js] +features: [TypedArray] +---*/ +var threw = false; + +try { + testTypedArrayConversions({}, () => {}); +} catch(err) { + threw = true; + if (err.constructor !== TypeError) { + throw new Error( + 'Expected a TypeError, but a "' + err.constructor.name + + '" was thrown.' + ); + } +} + +if (threw === false) { + throw new Error('Expected a TypeError, but no error was thrown.'); +} + + diff --git a/test/sendable/harness/testTypedArray-conversions.js b/test/sendable/harness/testTypedArray-conversions.js new file mode 100644 index 00000000000..295563def6f --- /dev/null +++ b/test/sendable/harness/testTypedArray-conversions.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Including testTypedArray.js will expose: + + testTypedArrayConversions() + +includes: [testTypedArray.js] +features: [TypedArray] +---*/ +var callCount = 0; +var bcv = { + values: [ + 127, + ], + expected: { + Int8: [ + 127, + ], + Uint8: [ + 127, + ], + Uint8Clamped: [ + 127, + ], + Int16: [ + 127, + ], + Uint16: [ + 127, + ], + Int32: [ + 127, + ], + Uint32: [ + 127, + ], + Float16: [ + 127, + ], + Float32: [ + 127, + ], + Float64: [ + 127, + ] + } +}; + +testTypedArrayConversions(bcv, function(TA, value, expected, initial) { + var sample = new TA([initial]); + sample.fill(value); + assert.sameValue(initial, 0); + assert.sameValue(sample[0], expected); + callCount++; +}); + diff --git a/test/sendable/harness/testTypedArray.js b/test/sendable/harness/testTypedArray.js new file mode 100644 index 00000000000..a90830bce48 --- /dev/null +++ b/test/sendable/harness/testTypedArray.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Including testTypedArray.js will expose: + + var typedArrayConstructors = [ array of TypedArray constructors ] + var TypedArray + + testWithTypedArrayConstructors() + testTypedArrayConversions() + +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +assert(typeof TypedArray === "function"); +assert.sameValue(TypedArray, Object.getPrototypeOf(Uint8Array)); + +var hasFloat16Array = typeof Float16Array !== 'undefined'; + +var callCount = 0; +testWithTypedArrayConstructors(() => callCount++); +assert.sameValue(callCount, 9 + hasFloat16Array); + +var index = 0; + +assert.sameValue(typedArrayConstructors[index++], Float64Array); +assert.sameValue(typedArrayConstructors[index++], Float32Array); +if (hasFloat16Array) { + assert.sameValue(typedArrayConstructors[index++], Float16Array); +} +assert.sameValue(typedArrayConstructors[index++], Int32Array); +assert.sameValue(typedArrayConstructors[index++], Int16Array); +assert.sameValue(typedArrayConstructors[index++], Int8Array); +assert.sameValue(typedArrayConstructors[index++], Uint32Array); +assert.sameValue(typedArrayConstructors[index++], Uint16Array); +assert.sameValue(typedArrayConstructors[index++], Uint8Array); +assert.sameValue(typedArrayConstructors[index++], Uint8ClampedArray); diff --git a/test/sendable/harness/verifyProperty-arguments.js b/test/sendable/harness/verifyProperty-arguments.js new file mode 100644 index 00000000000..5cc2efce7b1 --- /dev/null +++ b/test/sendable/harness/verifyProperty-arguments.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + verifyProperty should receive at least 3 arguments: obj, name, and descriptor +includes: [propertyHelper.js] +---*/ +assert.throws(Test262Error, () => { + verifyProperty(); +}, "0 arguments"); + +assert.throws(Test262Error, () => { + verifyProperty(Object); +}, "1 argument"); + +assert.throws(Test262Error, () => { + verifyProperty(Object, 'foo'); +}, "2 arguments"); diff --git a/test/sendable/harness/verifyProperty-configurable-object.js b/test/sendable/harness/verifyProperty-configurable-object.js new file mode 100644 index 00000000000..2376ba9f810 --- /dev/null +++ b/test/sendable/harness/verifyProperty-configurable-object.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified property is configurable satisfy the assertion. +includes: [propertyHelper.js] +---*/ + +Object.defineProperty(this, 'Object', { + configurable: true, + value: Object +}); + +verifyProperty(this, 'Object', { + configurable: true +}); diff --git a/test/sendable/harness/verifyProperty-desc-is-not-object.js b/test/sendable/harness/verifyProperty-desc-is-not-object.js new file mode 100644 index 00000000000..415e13079e0 --- /dev/null +++ b/test/sendable/harness/verifyProperty-desc-is-not-object.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + The desc argument should be an object or undefined +includes: [propertyHelper.js] +features: [Symbol] +---*/ +var sample = { foo: 42 }; + +assert.throws(Test262Error, () => { + verifyProperty(sample, "foo", 'configurable'); +}, "string"); + +assert.throws(Test262Error, () => { + verifyProperty(sample, 'foo', true); +}, "boolean"); + +assert.throws(Test262Error, () => { + verifyProperty(sample, 'foo', 42); +}, "number"); + +assert.throws(Test262Error, () => { + verifyProperty(sample, 'foo', null); +}, "null"); + +assert.throws(Test262Error, () => { + verifyProperty(sample, 'foo', Symbol(1)); +}, "symbol"); diff --git a/test/sendable/harness/verifyProperty-noproperty.js b/test/sendable/harness/verifyProperty-noproperty.js new file mode 100644 index 00000000000..674d64090c5 --- /dev/null +++ b/test/sendable/harness/verifyProperty-noproperty.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + The first argument should have an own property +includes: [propertyHelper.js] +---*/ +assert.throws(Test262Error, () => { + verifyProperty(Object, 'JeanPaulSartre', {}); +}, "inexisting property"); + +assert.throws(Test262Error, () => { + verifyProperty({}, 'hasOwnProperty', {}); +}, "inexisting own property"); diff --git a/test/sendable/harness/verifyProperty-restore-accessor-symbol.js b/test/sendable/harness/verifyProperty-restore-accessor-symbol.js new file mode 100644 index 00000000000..12e5464f15b --- /dev/null +++ b/test/sendable/harness/verifyProperty-restore-accessor-symbol.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + verifyProperty allows restoring the original accessor descriptor +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var obj; +var prop = Symbol(1); +var desc = { enumerable: true, configurable: true, get() { return 42; }, set() {} }; + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + false +); + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc, { restore: true }); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + true +); +assert.sameValue(obj[prop], 42); +assert.sameValue( + Object.getOwnPropertyDescriptor(obj, prop).get, + desc.get +); + +assert.sameValue( + Object.getOwnPropertyDescriptor(obj, prop).set, + desc.set +); diff --git a/test/sendable/harness/verifyProperty-restore-accessor.js b/test/sendable/harness/verifyProperty-restore-accessor.js new file mode 100644 index 00000000000..c1c437a8169 --- /dev/null +++ b/test/sendable/harness/verifyProperty-restore-accessor.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + verifyProperty allows restoring the original accessor descriptor +includes: [propertyHelper.js] +---*/ + +var obj; +var prop = "prop"; +var desc = { enumerable: true, configurable: true, get() { return 42; }, set() {} }; + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + false +); + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc, { restore: true }); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + true +); +assert.sameValue(obj[prop], 42); +assert.sameValue( + Object.getOwnPropertyDescriptor(obj, prop).get, + desc.get +); + +assert.sameValue( + Object.getOwnPropertyDescriptor(obj, prop).set, + desc.set +); diff --git a/test/sendable/harness/verifyProperty-restore-symbol.js b/test/sendable/harness/verifyProperty-restore-symbol.js new file mode 100644 index 00000000000..fcd4a80202b --- /dev/null +++ b/test/sendable/harness/verifyProperty-restore-symbol.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + verifyProperty allows restoring the original descriptor +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var obj; +var prop = Symbol(1); +var desc = { enumerable: true, configurable: true, writable: true, value: 42 }; + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + false +); + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc, { restore: true }); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + true +); +assert.sameValue(obj[prop], 42); diff --git a/test/sendable/harness/verifyProperty-restore.js b/test/sendable/harness/verifyProperty-restore.js new file mode 100644 index 00000000000..64a5da3960c --- /dev/null +++ b/test/sendable/harness/verifyProperty-restore.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + verifyProperty allows restoring the original descriptor +includes: [propertyHelper.js] +---*/ + +var obj; +var prop = 'prop'; +var desc = { enumerable: true, configurable: true, writable: true, value: 42 }; + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + false +); + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc, { restore: true }); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + true +); +assert.sameValue(obj[prop], 42); diff --git a/test/sendable/harness/verifyProperty-same-value.js b/test/sendable/harness/verifyProperty-same-value.js new file mode 100644 index 00000000000..644aeff7d18 --- /dev/null +++ b/test/sendable/harness/verifyProperty-same-value.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + verifyProperty uses SameValue for value comparison. +includes: [propertyHelper.js] +---*/ + +var obj = { + a: NaN, + b: -0, +}; + +assert(verifyProperty(obj, 'a', { value: NaN })); +assert(verifyProperty(obj, 'b', { value: -0 })); + +assert.throws(Test262Error, function() { + verifyProperty(obj, 'b', { value: 0 }); +}); diff --git a/test/sendable/harness/verifyProperty-string-prop.js b/test/sendable/harness/verifyProperty-string-prop.js new file mode 100644 index 00000000000..b717d7efec5 --- /dev/null +++ b/test/sendable/harness/verifyProperty-string-prop.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Verify property descriptor +includes: [propertyHelper.js] +---*/ + +var obj; +var prop = 'prop'; + +function reset(desc) { + obj = {}; + Object.defineProperty(obj, prop, desc); +} + +function checkDesc(desc) { + reset(desc); + assert(verifyProperty(obj, prop, desc)); + + reset(desc); + assert(verifyProperty(obj, prop, { enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { writable: desc.writable })); + + reset(desc); + assert(verifyProperty(obj, prop, { configurable: desc.configurable })); + + reset(desc); + assert(verifyProperty(obj, prop, { configurable: desc.configurable, enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { configurable: desc.configurable, writable: desc.writable })); + + reset(desc); + assert(verifyProperty(obj, prop, { writable: desc.writable, enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { enumerable: desc.enumerable, configurable: desc.configurable })); +} + +checkDesc({ enumerable: true, configurable: true, writable: true }); +checkDesc({ enumerable: false, writable: false, configurable: false }); +checkDesc({ enumerable: true, writable: false, configurable: false }); +checkDesc({ enumerable: false, writable: true, configurable: false }); +checkDesc({ enumerable: false, writable: false, configurable: true }); +checkDesc({ enumerable: true, writable: false, configurable: true }); +checkDesc({ enumerable: true, writable: true, configurable: false }); +checkDesc({ enumerable: false, writable: true, configurable: true }); diff --git a/test/sendable/harness/verifyProperty-symbol-prop.js b/test/sendable/harness/verifyProperty-symbol-prop.js new file mode 100644 index 00000000000..a8a40a6c3e2 --- /dev/null +++ b/test/sendable/harness/verifyProperty-symbol-prop.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Verify symbol named property descriptor +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var obj; +var prop = Symbol(1); + +function reset(desc) { + obj = {}; + Object.defineProperty(obj, prop, desc); +} + +function checkDesc(desc) { + reset(desc); + assert(verifyProperty(obj, prop, desc)); + + reset(desc); + assert(verifyProperty(obj, prop, { enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { writable: desc.writable })); + + reset(desc); + assert(verifyProperty(obj, prop, { configurable: desc.configurable })); + + reset(desc); + assert(verifyProperty(obj, prop, { configurable: desc.configurable, enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { configurable: desc.configurable, writable: desc.writable })); + + reset(desc); + assert(verifyProperty(obj, prop, { writable: desc.writable, enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { enumerable: desc.enumerable, configurable: desc.configurable })); +} + +checkDesc({ enumerable: true, configurable: true, writable: true }); +checkDesc({ enumerable: false, writable: false, configurable: false }); +checkDesc({ enumerable: true, writable: false, configurable: false }); +checkDesc({ enumerable: false, writable: true, configurable: false }); +checkDesc({ enumerable: false, writable: false, configurable: true }); +checkDesc({ enumerable: true, writable: false, configurable: true }); +checkDesc({ enumerable: true, writable: true, configurable: false }); +checkDesc({ enumerable: false, writable: true, configurable: true }); diff --git a/test/sendable/harness/verifyProperty-undefined-desc.js b/test/sendable/harness/verifyProperty-undefined-desc.js new file mode 100644 index 00000000000..1c910b727dd --- /dev/null +++ b/test/sendable/harness/verifyProperty-undefined-desc.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Verify an undefined descriptor +includes: [propertyHelper.js] +---*/ +var sample = { + bar: undefined, + get baz() {} +}; + +assert.sameValue( + verifyProperty(sample, "foo", undefined), + true, + "returns true if desc and property descriptor are both undefined" +); + +assert.throws(Test262Error, () => { + verifyProperty(sample, 'bar', undefined); +}, "dataDescriptor value is undefined"); + +assert.throws(Test262Error, () => { + verifyProperty(sample, 'baz', undefined); +}, "accessor returns undefined"); diff --git a/test/sendable/harness/verifyProperty-value-error.js b/test/sendable/harness/verifyProperty-value-error.js new file mode 100644 index 00000000000..9b44e6ee10f --- /dev/null +++ b/test/sendable/harness/verifyProperty-value-error.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Including propertyHelper.js will expose: + + verifyProperty() + ... + +includes: [propertyHelper.js] +---*/ + +var threw = false; +var object = Object.defineProperty({}, "prop", { + value: 1 +}); + +try { + verifyProperty(object, "prop", { + value: 2 + }); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } + + if (err.message !== 'descriptor value should be 2; object value should be 2') { + throw new Error('The error thrown did not define the specified message'); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/test/sendable/harness/verifyProperty-value.js b/test/sendable/harness/verifyProperty-value.js new file mode 100644 index 00000000000..fbdf2862543 --- /dev/null +++ b/test/sendable/harness/verifyProperty-value.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Verify property descriptor +includes: [propertyHelper.js] +---*/ + +var obj; +var prop = 'prop'; + +function reset(desc) { + desc.value = prop; + obj = Object.defineProperty({}, prop, desc); +} + +function checkDesc(desc) { + reset(desc); + assert(verifyProperty(obj, prop, desc)); + + reset(desc); + assert(verifyProperty(obj, prop, { value: 'prop', enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { value: 'prop', writable: desc.writable })); + + reset(desc); + assert(verifyProperty(obj, prop, { value: 'prop', configurable: desc.configurable })); + + reset(desc); + assert(verifyProperty(obj, prop, { value: 'prop', configurable: desc.configurable, enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { value: 'prop', configurable: desc.configurable, writable: desc.writable })); + + reset(desc); + assert(verifyProperty(obj, prop, { value: 'prop', writable: desc.writable, enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { value: 'prop', enumerable: desc.enumerable, configurable: desc.configurable })); +} + +checkDesc({ enumerable: true, configurable: true, writable: true }); +checkDesc({ enumerable: false, writable: false, configurable: false }); +checkDesc({ enumerable: true, writable: false, configurable: false }); +checkDesc({ enumerable: false, writable: true, configurable: false }); +checkDesc({ enumerable: false, writable: false, configurable: true }); +checkDesc({ enumerable: true, writable: false, configurable: true }); +checkDesc({ enumerable: true, writable: true, configurable: false }); +checkDesc({ enumerable: false, writable: true, configurable: true }); -- Gitee From e51beafc8cdc40a4c52aa36bfb8d26db03625ab1 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 16 Dec 2024 15:30:37 +0800 Subject: [PATCH 09/93] add cases is array Signed-off-by: zhuzhihui7 --- .../builtins/Array/isArray/15.4.3.2-0-1.js | 22 +++++++++++ .../builtins/Array/isArray/15.4.3.2-0-2.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-0-3.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-0-4.js | 25 +++++++++++++ .../builtins/Array/isArray/15.4.3.2-0-5.js | 23 ++++++++++++ .../builtins/Array/isArray/15.4.3.2-0-6.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-0-7.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-1-1.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-1-10.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-1-11.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-1-12.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-1-13.js | 25 +++++++++++++ .../builtins/Array/isArray/15.4.3.2-1-15.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-1-2.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-1-3.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-1-4.js | 22 +++++++++++ .../builtins/Array/isArray/15.4.3.2-1-5.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-1-6.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-1-7.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-1-8.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-1-9.js | 21 +++++++++++ .../builtins/Array/isArray/15.4.3.2-2-1.js | 25 +++++++++++++ .../builtins/Array/isArray/15.4.3.2-2-2.js | 27 ++++++++++++++ .../builtins/Array/isArray/15.4.3.2-2-3.js | 27 ++++++++++++++ .../builtins/Array/isArray/descriptor.js | 25 +++++++++++++ test/sendable/builtins/Array/isArray/name.js | 37 +++++++++++++++++++ .../Array/isArray/not-a-constructor.js | 34 +++++++++++++++++ .../builtins/Array/isArray/proxy-revoked.js | 35 ++++++++++++++++++ test/sendable/builtins/Array/isArray/proxy.js | 36 ++++++++++++++++++ 29 files changed, 699 insertions(+) create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-0-1.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-0-2.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-0-3.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-0-4.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-0-5.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-0-6.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-0-7.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-1-1.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-1-10.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-1-11.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-1-12.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-1-13.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-1-15.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-1-2.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-1-3.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-1-4.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-1-5.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-1-6.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-1-7.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-1-8.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-1-9.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-2-1.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-2-2.js create mode 100644 test/sendable/builtins/Array/isArray/15.4.3.2-2-3.js create mode 100644 test/sendable/builtins/Array/isArray/descriptor.js create mode 100644 test/sendable/builtins/Array/isArray/name.js create mode 100644 test/sendable/builtins/Array/isArray/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/isArray/proxy-revoked.js create mode 100644 test/sendable/builtins/Array/isArray/proxy.js diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-0-1.js b/test/sendable/builtins/Array/isArray/15.4.3.2-0-1.js new file mode 100644 index 00000000000..423ffb7f31a --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-0-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-0-1 +description: SendableArray.isArray must exist as a function +---*/ + +var f = SendableArray.isArray; +assert.sameValue(typeof f, "function", 'The value of `typeof f` is expected to be "function"'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-0-2.js b/test/sendable/builtins/Array/isArray/15.4.3.2-0-2.js new file mode 100644 index 00000000000..723373455c1 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-0-2.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-0-2 +description: SendableArray.isArray must exist as a function taking 1 parameter +---*/ + +assert.sameValue(SendableArray.isArray.length, 1, 'The value of Array.isArray.length is expected to be 1'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-0-3.js b/test/sendable/builtins/Array/isArray/15.4.3.2-0-3.js new file mode 100644 index 00000000000..947cd81dbbf --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-0-3.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-0-3 +description: SendableArray.isArray return true if its argument is an Array +---*/ + +assert.sameValue(SendableArray.isArray([]), true, 'Array.isArray([]) must return true'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-0-4.js b/test/sendable/builtins/Array/isArray/15.4.3.2-0-4.js new file mode 100644 index 00000000000..a2d07d23bb6 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-0-4.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +description: SendableArray.isArray return false if its argument is not an Array +---*/ + +assert.sameValue(SendableArray.isArray(42), false, 'SendableArray.isArray(42) must return false'); +assert.sameValue(SendableArray.isArray(undefined), false, 'SendableArray.isArray(undefined) must return false'); +assert.sameValue(SendableArray.isArray(true), false, 'SendableArray.isArray(true) must return false'); +assert.sameValue(SendableArray.isArray("abc"), false, 'SendableArray.isArray("abc") must return false'); +assert.sameValue(SendableArray.isArray({}), false, 'SendableArray.isArray({}) must return false'); +assert.sameValue(SendableArray.isArray(null), false, 'SendableArray.isArray(null) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-0-5.js b/test/sendable/builtins/Array/isArray/15.4.3.2-0-5.js new file mode 100644 index 00000000000..55af7a8a592 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-0-5.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-0-5 +description: > + SendableArray.isArray return true if its argument is an Array + (Array.prototype) +---*/ + +assert.sameValue(SendableArray.isArray(Array.prototype), true, 'SendableArray.isArray(Array.prototype) must return true'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-0-6.js b/test/sendable/builtins/Array/isArray/15.4.3.2-0-6.js new file mode 100644 index 00000000000..049eee6c1d2 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-0-6.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-0-6 +description: SendableArray.isArray return true if its argument is an Array (new Array()) +---*/ + +assert.sameValue(SendableArray.isArray(new Array(10)), true, 'SendableArray.isArray(new Array(10)) must return true'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-0-7.js b/test/sendable/builtins/Array/isArray/15.4.3.2-0-7.js new file mode 100644 index 00000000000..0f3b915ebbd --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-0-7.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-0-7 +description: SendableArray.isArray returns false if its argument is not an Array +---*/ + +assert.sameValue(SendableArray.isArray({}), false, 'SendableArray.isArray({}) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-1-1.js b/test/sendable/builtins/Array/isArray/15.4.3.2-1-1.js new file mode 100644 index 00000000000..4bcc527c165 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-1-1.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-1-1 +description: SendableArray.isArray applied to boolean primitive +---*/ + +assert.sameValue(SendableArray.isArray(true), false, 'SendableArray.isArray(true) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-1-10.js b/test/sendable/builtins/Array/isArray/15.4.3.2-1-10.js new file mode 100644 index 00000000000..b4f35753de9 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-1-10.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-1-10 +description: SendableArray.isArray applied to RegExp object +---*/ + +assert.sameValue(SendableArray.isArray(new RegExp()), false, 'SendableArray.isArray(new RegExp()) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-1-11.js b/test/sendable/builtins/Array/isArray/15.4.3.2-1-11.js new file mode 100644 index 00000000000..baa31343e80 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-1-11.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-1-11 +description: SendableArray.isArray applied to the JSON object +---*/ + +assert.sameValue(SendableArray.isArray(JSON), false, 'SendableArray.isArray(JSON) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-1-12.js b/test/sendable/builtins/Array/isArray/15.4.3.2-1-12.js new file mode 100644 index 00000000000..1e1ed4ae4f2 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-1-12.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-1-12 +description: SendableArray.isArray applied to Error object +---*/ + +assert.sameValue(SendableArray.isArray(new SyntaxError()), false, 'SendableArray.isArray(new SyntaxError()) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-1-13.js b/test/sendable/builtins/Array/isArray/15.4.3.2-1-13.js new file mode 100644 index 00000000000..ee3c1069e05 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-1-13.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-1-13 +description: SendableArray.isArray applied to Arguments object +---*/ + +var arg; +(function fun() { + arg = arguments; +}(1, 2, 3)); +assert.sameValue(SendableArray.isArray(arg), false, 'SendableArray.isArray(arguments) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-1-15.js b/test/sendable/builtins/Array/isArray/15.4.3.2-1-15.js new file mode 100644 index 00000000000..a2377360029 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-1-15.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-1-15 +description: SendableArray.isArray applied to the global object +---*/ + +assert.sameValue(SendableArray.isArray(this), false, 'SendableArray.isArray(this) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-1-2.js b/test/sendable/builtins/Array/isArray/15.4.3.2-1-2.js new file mode 100644 index 00000000000..8d0d4a92ba9 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-1-2.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-1-2 +description: SendableArray.isArray applied to Boolean Object +---*/ + +assert.sameValue(SendableArray.isArray(new Boolean(false)), false, 'Array.isArray(new Boolean(false)) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-1-3.js b/test/sendable/builtins/Array/isArray/15.4.3.2-1-3.js new file mode 100644 index 00000000000..1be6db1dbdd --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-1-3.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-1-3 +description: SendableArray.isArray applied to number primitive +---*/ + +assert.sameValue(SendableArray.isArray(5), false, 'SendableArray.isArray(5) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-1-4.js b/test/sendable/builtins/Array/isArray/15.4.3.2-1-4.js new file mode 100644 index 00000000000..b04cf2f1b65 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-1-4.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-1-4 +description: SendableArray.isArray applied to Number object +---*/ + +assert.sameValue(SendableArray.isArray(new Number(-3)), false, 'Array.isArray(new Number(-3)) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-1-5.js b/test/sendable/builtins/Array/isArray/15.4.3.2-1-5.js new file mode 100644 index 00000000000..72d21029dec --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-1-5.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-1-5 +description: SendableArray.isArray applied to string primitive +---*/ + +assert.sameValue(SendableArray.isArray("abc"), false, 'SendableArray.isArray("abc") must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-1-6.js b/test/sendable/builtins/Array/isArray/15.4.3.2-1-6.js new file mode 100644 index 00000000000..abc16297031 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-1-6.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-1-6 +description: SendableArray.isArray applied to String object +---*/ + +assert.sameValue(SendableArray.isArray(new String("hello\nworld\\!")), false, 'SendableArray.isArray(new String("hello\\nworld\\\\!")) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-1-7.js b/test/sendable/builtins/Array/isArray/15.4.3.2-1-7.js new file mode 100644 index 00000000000..2dfc57e652a --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-1-7.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-1-7 +description: SendableArray.isArray applied to Function object +---*/ + +assert.sameValue(SendableArray.isArray(function() {}), false, 'SendableArray.isArray(function() {}) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-1-8.js b/test/sendable/builtins/Array/isArray/15.4.3.2-1-8.js new file mode 100644 index 00000000000..5d37a2eb1ce --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-1-8.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-1-8 +description: SendableArray.isArray applied to the Math object +---*/ + +assert.sameValue(SendableArray.isArray(Math), false, 'SendableArray.isArray(Math) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-1-9.js b/test/sendable/builtins/Array/isArray/15.4.3.2-1-9.js new file mode 100644 index 00000000000..75ccfaa840c --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-1-9.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-1-9 +description: SendableArray.isArray applied to Date object +---*/ + +assert.sameValue(SendableArray.isArray(new Date(0)), false, 'SendableArray.isArray(new Date(0)) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-2-1.js b/test/sendable/builtins/Array/isArray/15.4.3.2-2-1.js new file mode 100644 index 00000000000..01d83bc00ca --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-2-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-2-1 +description: SendableArray.isArray applied to an object with an array as the prototype +---*/ + +var proto = []; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +assert.sameValue(SendableArray.isArray(child), false, 'SendableArray.isArray(new Con()) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-2-2.js b/test/sendable/builtins/Array/isArray/15.4.3.2-2-2.js new file mode 100644 index 00000000000..b4acfb32b61 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-2-2.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-2-2 +description: > + SendableArray.isArray applied to an object with Array.prototype as the + prototype +---*/ + +var proto = Array.prototype; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +assert.sameValue(SendableArray.isArray(child), false, 'SendableArray.isArray(new Con()) must return false'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-2-3.js b/test/sendable/builtins/Array/isArray/15.4.3.2-2-3.js new file mode 100644 index 00000000000..81824f6db7b --- /dev/null +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-2-3.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es5id: 15.4.3.2-2-3 +description: > + SendableArray.isArray applied to an Array-like object with length and some + indexed properties +---*/ + +assert.sameValue(SendableArray.isArray({ + 0: 12, + 1: 9, + length: 2 +}), false, 'SendableArray.isArray({0: 12, 1: 9, length: 2}) must return false'); diff --git a/test/sendable/builtins/Array/isArray/descriptor.js b/test/sendable/builtins/Array/isArray/descriptor.js new file mode 100644 index 00000000000..d42d8fa1998 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/descriptor.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Testing descriptor property of Array.isArray +includes: [propertyHelper.js] +esid: sec-array.isarray +---*/ + +verifyProperty(SendableArray, "isArray", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/isArray/name.js b/test/sendable/builtins/Array/isArray/name.js new file mode 100644 index 00000000000..795c4aa8ab6 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/name.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es6id: 22.1.2.2 +description: > + SendableArray.isArray.name is "isArray". +info: | + SendableArray.isArray ( arg ) + 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(SendableArray.isArray, "name", { + value: "isArray", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/isArray/not-a-constructor.js b/test/sendable/builtins/Array/isArray/not-a-constructor.js new file mode 100644 index 00000000000..a591a7e0e65 --- /dev/null +++ b/test/sendable/builtins/Array/isArray/not-a-constructor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableArray.isArray 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(SendableArray.isArray), false, 'isConstructor(SendableArray.isArray) must return false'); +assert.throws(TypeError, () => { + new SendableArray.isArray([]); +}, 'new SendableArray.isArray([]) throws a TypeError exception'); + diff --git a/test/sendable/builtins/Array/isArray/proxy-revoked.js b/test/sendable/builtins/Array/isArray/proxy-revoked.js new file mode 100644 index 00000000000..579a3db54fa --- /dev/null +++ b/test/sendable/builtins/Array/isArray/proxy-revoked.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es6id: 22.1.2.2 +description: Revoked proxy value produces a TypeError +info: | + 1. Return IsArray(arg). + 7.2.2 IsArray + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is null, + throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy] +---*/ + +var handle = Proxy.revocable([], {}); +handle.revoke(); +assert.throws(TypeError, function() { + SendableArray.isArray(handle.proxy); +}, 'SendableArray.isArray(handle.proxy) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/isArray/proxy.js b/test/sendable/builtins/Array/isArray/proxy.js new file mode 100644 index 00000000000..76a01a0df3f --- /dev/null +++ b/test/sendable/builtins/Array/isArray/proxy.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.isarray +es6id: 22.1.2.2 +description: Proxy of an array is treated as an array +info: | + 1. Return IsArray(arg). + 7.2.2 IsArray + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is null, + throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy] +---*/ + +var objectProxy = new Proxy({}, {}); +var arrayProxy = new Proxy([], {}); +var arrayProxyProxy = new Proxy(arrayProxy, {}); +assert.sameValue(SendableArray.isArray(objectProxy), false, 'SendableArray.isArray(new Proxy({}, {})) must return false'); +assert.sameValue(SendableArray.isArray(arrayProxy), true, 'SendableArray.isArray(new Proxy([], {})) must return true'); +assert.sameValue(SendableArray.isArray(arrayProxyProxy), true, 'SendableArray.isArray(new Proxy(arrayProxy, {})) must return true'); -- Gitee From 0f464cc6f02a704452ef2518d085d2e65023d359 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 16 Dec 2024 15:46:42 +0800 Subject: [PATCH 10/93] update error Signed-off-by: zhuzhihui7 --- test/sendable/builtins/Array/isArray/15.4.3.2-0-5.js | 2 +- test/sendable/builtins/Array/isArray/15.4.3.2-0-6.js | 4 ++-- test/sendable/builtins/Array/isArray/proxy-revoked.js | 2 +- test/sendable/builtins/Array/isArray/proxy.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-0-5.js b/test/sendable/builtins/Array/isArray/15.4.3.2-0-5.js index 55af7a8a592..f9701b15251 100644 --- a/test/sendable/builtins/Array/isArray/15.4.3.2-0-5.js +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-0-5.js @@ -20,4 +20,4 @@ description: > (Array.prototype) ---*/ -assert.sameValue(SendableArray.isArray(Array.prototype), true, 'SendableArray.isArray(Array.prototype) must return true'); +assert.sameValue(SendableArray.isArray(SendableArray.prototype), true, 'SendableArray.isArray(SendableArray.prototype) must return true'); diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-0-6.js b/test/sendable/builtins/Array/isArray/15.4.3.2-0-6.js index 049eee6c1d2..78758e644bf 100644 --- a/test/sendable/builtins/Array/isArray/15.4.3.2-0-6.js +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-0-6.js @@ -15,7 +15,7 @@ /*--- esid: sec-SendableArray.isarray es5id: 15.4.3.2-0-6 -description: SendableArray.isArray return true if its argument is an Array (new Array()) +description: SendableArray.isArray return true if its argument is an Array (new SendableArray()) ---*/ -assert.sameValue(SendableArray.isArray(new Array(10)), true, 'SendableArray.isArray(new Array(10)) must return true'); +assert.sameValue(SendableArray.isArray(new SendableArray(10)), true, 'SendableArray.isArray(new SendableArray(10)) must return true'); diff --git a/test/sendable/builtins/Array/isArray/proxy-revoked.js b/test/sendable/builtins/Array/isArray/proxy-revoked.js index 579a3db54fa..175c8231baf 100644 --- a/test/sendable/builtins/Array/isArray/proxy-revoked.js +++ b/test/sendable/builtins/Array/isArray/proxy-revoked.js @@ -24,7 +24,7 @@ info: | throw a TypeError exception. b. Let target be the value of the [[ProxyTarget]] internal slot of argument. - c. Return ? IsArray(target). + c. Return IsArray(target). features: [Proxy] ---*/ diff --git a/test/sendable/builtins/Array/isArray/proxy.js b/test/sendable/builtins/Array/isArray/proxy.js index 76a01a0df3f..df25bee7fba 100644 --- a/test/sendable/builtins/Array/isArray/proxy.js +++ b/test/sendable/builtins/Array/isArray/proxy.js @@ -24,7 +24,7 @@ info: | throw a TypeError exception. b. Let target be the value of the [[ProxyTarget]] internal slot of argument. - c. Return ? IsArray(target). + c. Return IsArray(target). features: [Proxy] ---*/ -- Gitee From 828a3569ac1bba4a296b6376f7e33a6ea854e373 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 16 Dec 2024 16:39:33 +0800 Subject: [PATCH 11/93] add new cases length Signed-off-by: zhuzhihui7 --- .../builtins/Array/isArray/15.4.3.2-0-3.js | 2 +- .../builtins/Array/length/15.4.5.1-3.d-1.js | 27 ++++ .../builtins/Array/length/15.4.5.1-3.d-2.js | 25 ++++ .../builtins/Array/length/15.4.5.1-3.d-3.js | 23 ++++ .../Array/length/S15.4.2.2_A1.1_T1.js | 29 +++++ .../Array/length/S15.4.2.2_A1.1_T2.js | 27 ++++ .../Array/length/S15.4.2.2_A1.1_T3.js | 29 +++++ .../Array/length/S15.4.2.2_A1.2_T1.js | 24 ++++ .../Array/length/S15.4.2.2_A2.1_T1.js | 29 +++++ .../Array/length/S15.4.2.2_A2.2_T1.js | 53 ++++++++ .../Array/length/S15.4.2.2_A2.2_T2.js | 53 ++++++++ .../Array/length/S15.4.2.2_A2.2_T3.js | 53 ++++++++ .../Array/length/S15.4.2.2_A2.3_T1.js | 30 +++++ .../Array/length/S15.4.2.2_A2.3_T2.js | 31 +++++ .../Array/length/S15.4.2.2_A2.3_T3.js | 31 +++++ .../Array/length/S15.4.2.2_A2.3_T4.js | 36 ++++++ .../Array/length/S15.4.2.2_A2.3_T5.js | 36 ++++++ .../builtins/Array/length/S15.4.4_A1.3_T1.js | 22 ++++ .../Array/length/S15.4.5.1_A1.1_T1.js | 54 ++++++++ .../Array/length/S15.4.5.1_A1.1_T2.js | 65 ++++++++++ .../Array/length/S15.4.5.1_A1.2_T1.js | 31 +++++ .../Array/length/S15.4.5.1_A1.2_T3.js | 31 +++++ .../Array/length/S15.4.5.1_A1.3_T1.js | 39 ++++++ .../Array/length/S15.4.5.1_A1.3_T2.js | 116 ++++++++++++++++++ .../builtins/Array/length/S15.4.5.2_A3_T4.js | 32 +++++ ...fine-own-prop-length-coercion-order-set.js | 48 ++++++++ .../define-own-prop-length-coercion-order.js | 57 +++++++++ .../length/define-own-prop-length-error.js | 30 +++++ .../define-own-prop-length-no-value-order.js | 60 +++++++++ .../define-own-prop-length-overflow-order.js | 36 ++++++ .../define-own-prop-length-overflow-realm.js | 31 +++++ 31 files changed, 1189 insertions(+), 1 deletion(-) create mode 100644 test/sendable/builtins/Array/length/15.4.5.1-3.d-1.js create mode 100644 test/sendable/builtins/Array/length/15.4.5.1-3.d-2.js create mode 100644 test/sendable/builtins/Array/length/15.4.5.1-3.d-3.js create mode 100644 test/sendable/builtins/Array/length/S15.4.2.2_A1.1_T1.js create mode 100644 test/sendable/builtins/Array/length/S15.4.2.2_A1.1_T2.js create mode 100644 test/sendable/builtins/Array/length/S15.4.2.2_A1.1_T3.js create mode 100644 test/sendable/builtins/Array/length/S15.4.2.2_A1.2_T1.js create mode 100644 test/sendable/builtins/Array/length/S15.4.2.2_A2.1_T1.js create mode 100644 test/sendable/builtins/Array/length/S15.4.2.2_A2.2_T1.js create mode 100644 test/sendable/builtins/Array/length/S15.4.2.2_A2.2_T2.js create mode 100644 test/sendable/builtins/Array/length/S15.4.2.2_A2.2_T3.js create mode 100644 test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T1.js create mode 100644 test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T2.js create mode 100644 test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T3.js create mode 100644 test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T4.js create mode 100644 test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T5.js create mode 100644 test/sendable/builtins/Array/length/S15.4.4_A1.3_T1.js create mode 100644 test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T1.js create mode 100644 test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T2.js create mode 100644 test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T1.js create mode 100644 test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T3.js create mode 100644 test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T1.js create mode 100644 test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T2.js create mode 100644 test/sendable/builtins/Array/length/S15.4.5.2_A3_T4.js create mode 100644 test/sendable/builtins/Array/length/define-own-prop-length-coercion-order-set.js create mode 100644 test/sendable/builtins/Array/length/define-own-prop-length-coercion-order.js create mode 100644 test/sendable/builtins/Array/length/define-own-prop-length-error.js create mode 100644 test/sendable/builtins/Array/length/define-own-prop-length-no-value-order.js create mode 100644 test/sendable/builtins/Array/length/define-own-prop-length-overflow-order.js create mode 100644 test/sendable/builtins/Array/length/define-own-prop-length-overflow-realm.js diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-0-3.js b/test/sendable/builtins/Array/isArray/15.4.3.2-0-3.js index 947cd81dbbf..74314e9e030 100644 --- a/test/sendable/builtins/Array/isArray/15.4.3.2-0-3.js +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-0-3.js @@ -18,4 +18,4 @@ es5id: 15.4.3.2-0-3 description: SendableArray.isArray return true if its argument is an Array ---*/ -assert.sameValue(SendableArray.isArray([]), true, 'Array.isArray([]) must return true'); +assert.sameValue(SendableArray.isArray([]), true, 'SendableArray.isArray([]) must return true'); diff --git a/test/sendable/builtins/Array/length/15.4.5.1-3.d-1.js b/test/sendable/builtins/Array/length/15.4.5.1-3.d-1.js new file mode 100644 index 00000000000..39e6fd53bf8 --- /dev/null +++ b/test/sendable/builtins/Array/length/15.4.5.1-3.d-1.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-properties-of-array-instances-length +es5id: 15.4.5.1-3.d-1 +description: > + Throw RangeError if attempt to set array length property to + 4294967296 (2**32) +---*/ + + +assert.throws(RangeError, function() { + [].length = 4294967296; +}, '[].length = 4294967296 throws a RangeError exception'); diff --git a/test/sendable/builtins/Array/length/15.4.5.1-3.d-2.js b/test/sendable/builtins/Array/length/15.4.5.1-3.d-2.js new file mode 100644 index 00000000000..543b3dcca1f --- /dev/null +++ b/test/sendable/builtins/Array/length/15.4.5.1-3.d-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-properties-of-array-instances-length +es5id: 15.4.5.1-3.d-2 +description: > + Throw RangeError if attempt to set array length property to + 4294967297 (1+2**32) +---*/ + +assert.throws(RangeError, function() { + [].length = 4294967297; +}, '[].length = 4294967297 throws a RangeError exception'); diff --git a/test/sendable/builtins/Array/length/15.4.5.1-3.d-3.js b/test/sendable/builtins/Array/length/15.4.5.1-3.d-3.js new file mode 100644 index 00000000000..da8786615ed --- /dev/null +++ b/test/sendable/builtins/Array/length/15.4.5.1-3.d-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-properties-of-array-instances-length +es5id: 15.4.5.1-3.d-3 +description: Set array length property to max value 4294967295 (2**32-1,) +---*/ + +var a = []; +a.length = 4294967295; +assert.sameValue(a.length, 4294967295, 'The value of a.length is expected to be 4294967295'); diff --git a/test/sendable/builtins/Array/length/S15.4.2.2_A1.1_T1.js b/test/sendable/builtins/Array/length/S15.4.2.2_A1.1_T1.js new file mode 100644 index 00000000000..e58a6b324e1 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.2.2_A1.1_T1.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-len +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.2.2_A1.1_T1 +description: > + Create new property of Array.prototype. When new Array object has + this property +---*/ + +SendableArray.prototype.myproperty = 1; +var x = new SendableArray(0); +assert.sameValue(x.myproperty, 1, 'The value of x.myproperty is expected to be 1'); diff --git a/test/sendable/builtins/Array/length/S15.4.2.2_A1.1_T2.js b/test/sendable/builtins/Array/length/S15.4.2.2_A1.1_T2.js new file mode 100644 index 00000000000..9490f2ebf48 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.2.2_A1.1_T2.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-len +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.2.2_A1.1_T2 +description: Array.prototype.toString = Object.prototype.toString +---*/ + +SendableArray.prototype.toString = Object.prototype.toString; +var x = new SendableArray(0); +assert.sameValue(x.toString(), "[object SendableArray]", 'x.toString() must return "[object SendableArray]"'); diff --git a/test/sendable/builtins/Array/length/S15.4.2.2_A1.1_T3.js b/test/sendable/builtins/Array/length/S15.4.2.2_A1.1_T3.js new file mode 100644 index 00000000000..892913a7582 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.2.2_A1.1_T3.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-len +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.2.2_A1.1_T3 +description: Checking use isPrototypeOf +---*/ + +assert.sameValue( + SendableArray.prototype.isPrototypeOf(new SendableArray(0)), + true, + 'SendableArray.prototype.isPrototypeOf(new SendableArray(0)) must return true' +); diff --git a/test/sendable/builtins/Array/length/S15.4.2.2_A1.2_T1.js b/test/sendable/builtins/Array/length/S15.4.2.2_A1.2_T1.js new file mode 100644 index 00000000000..6ec4e62b159 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.2.2_A1.2_T1.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array-len +info: The [[Class]] property of the newly constructed object is set to "Array" +es5id: 15.4.2.2_A1.2_T1 +description: Checking use Object.prototype.toString +---*/ + +var x = new SendableArray(0); +assert.sameValue(Object.prototype.toString.call(x), "[object Array]", 'Object.prototype.toString.call(new SendableArray(0)) must return "[object SendableArray]"'); diff --git a/test/sendable/builtins/Array/length/S15.4.2.2_A2.1_T1.js b/test/sendable/builtins/Array/length/S15.4.2.2_A2.1_T1.js new file mode 100644 index 00000000000..fd3a37605e0 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.2.2_A2.1_T1.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray-len +info: | + If the argument len is a Number and ToUint32(len) is equal to len, + then the length property of the newly constructed object is set to ToUint32(len) +es5id: 15.4.2.2_A2.1_T1 +description: SendableArray constructor is given one argument +---*/ + +var x = new SendableArray(0); +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); +var x = new SendableArray(1); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +var x = new SendableArray(4294967295); +assert.sameValue(x.length, 4294967295, 'The value of x.length is expected to be 4294967295'); diff --git a/test/sendable/builtins/Array/length/S15.4.2.2_A2.2_T1.js b/test/sendable/builtins/Array/length/S15.4.2.2_A2.2_T1.js new file mode 100644 index 00000000000..1d51ee0f9bd --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.2.2_A2.2_T1.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray-len +info: | + If the argument len is a Number and ToUint32(len) is not equal to len, + a RangeError exception is thrown +es5id: 15.4.2.2_A2.2_T1 +description: Use try statement. len = -1, 4294967296, 4294967297 +---*/ + +try { + new SendableArray(-1); + throw new Test262Error('#1.1: new SendableArray(-1) throw RangeError. Actual: ' + (new SendableArray(-1))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} +try { + new SendableArray(4294967296); + throw new Test262Error('#2.1: new Array(4294967296) throw RangeError. Actual: ' + (new SendableArray(4294967296))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} +try { + new SendableArray(4294967297); + throw new Test262Error('#3.1: new Array(4294967297) throw RangeError. Actual: ' + (new SendableArray(4294967297))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Array/length/S15.4.2.2_A2.2_T2.js b/test/sendable/builtins/Array/length/S15.4.2.2_A2.2_T2.js new file mode 100644 index 00000000000..823aad71c7b --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.2.2_A2.2_T2.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray-len +info: | + If the argument len is a Number and ToUint32(len) is not equal to len, + a RangeError exception is thrown +es5id: 15.4.2.2_A2.2_T2 +description: Use try statement. len = NaN, +/-Infinity +---*/ + +try { + new SendableArray(NaN); + throw new Test262Error('#1.1: new SendableArray(NaN) throw RangeError. Actual: ' + (new SendableArray(NaN))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} +try { + new SendableArray(Number.POSITIVE_INFINITY); + throw new Test262Error('#2.1: new Array(Number.POSITIVE_INFINITY) throw RangeError. Actual: ' + (new SendableArray(Number.POSITIVE_INFINITY))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} +try { + new SendableArray(Number.NEGATIVE_INFINITY); + throw new Test262Error('#3.1: new Array(Number.NEGATIVE_INFINITY) throw RangeError. Actual: ' + (new SendableArray(Number.NEGATIVE_INFINITY))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Array/length/S15.4.2.2_A2.2_T3.js b/test/sendable/builtins/Array/length/S15.4.2.2_A2.2_T3.js new file mode 100644 index 00000000000..0def49c11c9 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.2.2_A2.2_T3.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray-len +info: | + If the argument len is a Number and ToUint32(len) is not equal to len, + a RangeError exception is thrown +es5id: 15.4.2.2_A2.2_T3 +description: Use try statement. len = 1.5, Number.MAX_VALUE, Number.MIN_VALUE +---*/ + +try { + new SendableArray(1.5); + throw new Test262Error('#1.1: new SendableArray(1.5) throw RangeError. Actual: ' + (new SendableArray(1.5))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} +try { + new SendableArray(Number.MAX_VALUE); + throw new Test262Error('#2.1: new Array(Number.MAX_VALUE) throw RangeError. Actual: ' + (new SendableArray(Number.MAX_VALUE))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} +try { + new SendableArray(Number.MIN_VALUE); + throw new Test262Error('#3.1: new Array(Number.MIN_VALUE) throw RangeError. Actual: ' + (new SendableArray(Number.MIN_VALUE))); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T1.js b/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T1.js new file mode 100644 index 00000000000..5de009ad57c --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray-len +info: | + If the argument len is not a Number, then the length property of + the newly constructed object is set to 1 and the 0 property of + the newly constructed object is set to len +es5id: 15.4.2.2_A2.3_T1 +description: Checking for null and undefined +---*/ + +var x = new SendableArray(null); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], null, 'The value of x[0] is expected to be null'); +var x = new SendableArray(undefined); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined'); diff --git a/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T2.js b/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T2.js new file mode 100644 index 00000000000..72b6a66ce9e --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T2.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray-len +info: | + If the argument len is not a Number, then the length property of + the newly constructed object is set to 1 and the 0 property of + the newly constructed object is set to len +es5id: 15.4.2.2_A2.3_T2 +description: Checking for boolean primitive and Boolean object +---*/ + +var x = new SendableArray(true); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], true, 'The value of x[0] is expected to be true'); +var obj = new Boolean(false); +var x = new SendableArray(obj); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); diff --git a/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T3.js b/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T3.js new file mode 100644 index 00000000000..2a792641ad7 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T3.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray-len +info: | + If the argument len is not a Number, then the length property of + the newly constructed object is set to 1 and the 0 property of + the newly constructed object is set to len +es5id: 15.4.2.2_A2.3_T3 +description: Checking for boolean primitive and Boolean object +---*/ + +var x = new SendableArray("1"); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], "1", 'The value of x[0] is expected to be "1"'); +var obj = new String("0"); +var x = new SendableArray(obj); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); diff --git a/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T4.js b/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T4.js new file mode 100644 index 00000000000..4c09ad53cf8 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T4.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray-len +info: | + If the argument len is not a Number, then the length property of + the newly constructed object is set to 1 and the 0 property of + the newly constructed object is set to len +es5id: 15.4.2.2_A2.3_T4 +description: Checking for Number object +---*/ + +var obj = new Number(0); +var x = new SendableArray(obj); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); +var obj = new Number(1); +var x = new SendableArray(obj); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); +var obj = new Number(4294967295); +var x = new SendableArray(obj); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); diff --git a/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T5.js b/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T5.js new file mode 100644 index 00000000000..c1c6d3ae549 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.2.2_A2.3_T5.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray-len +info: | + If the argument len is not a Number, then the length property of + the newly constructed object is set to 1 and the 0 property of + the newly constructed object is set to len +es5id: 15.4.2.2_A2.3_T5 +description: Checking for Number object +---*/ + +var obj = new Number(-1); +var x = new SendableArray(obj); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); +var obj = new Number(4294967296); +var x = new SendableArray(obj); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); +var obj = new Number(4294967297); +var x = new SendableArray(obj); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +assert.sameValue(x[0], obj, 'The value of x[0] is expected to equal the value of obj'); diff --git a/test/sendable/builtins/Array/length/S15.4.4_A1.3_T1.js b/test/sendable/builtins/Array/length/S15.4.4_A1.3_T1.js new file mode 100644 index 00000000000..8606adccbe4 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.4_A1.3_T1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-properties-of-the-array-prototype-object +info: SendableArray prototype object has a length property +es5id: 15.4.4_A1.3_T1 +description: SendableArray.prototype.length === 0 +---*/ + +assert.sameValue(SendableArray.prototype.length, 0, 'The value of SendableArray.prototype.length is expected to be 0'); diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T1.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T1.js new file mode 100644 index 00000000000..8f78dccbfa9 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T1.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-exotic-objects-defineownproperty-p-desc +info: If ToUint32(length) !== ToNumber(length), throw RangeError +es5id: 15.4.5.1_A1.1_T1 +description: length in [4294967296, -1, 1.5] +---*/ + +try { + var x = []; + x.length = 4294967296; + throw new Test262Error('#1.1: x = []; x.length = 4294967296 throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} +try { + x = []; + x.length = -1; + throw new Test262Error('#2.1: x = []; x.length = -1 throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} +try { + x = []; + x.length = 1.5; + throw new Test262Error('#3.1: x = []; x.length = 1.5 throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T2.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T2.js new file mode 100644 index 00000000000..16ff8c40192 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T2.js @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-exotic-objects-defineownproperty-p-desc +info: If ToUint32(length) !== ToNumber(length), throw RangeError +es5id: 15.4.5.1_A1.1_T2 +description: length in [NaN, Infinity, -Infinity, undefined] +---*/ + +try { + var x = []; + x.length = NaN; + throw new Test262Error('#1.1: x = []; x.length = NaN throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} +try { + x = []; + x.length = Number.POSITIVE_INFINITY; + throw new Test262Error('#2.1: x = []; x.length = Number.POSITIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} +try { + x = []; + x.length = Number.NEGATIVE_INFINITY; + throw new Test262Error('#3.1: x = []; x.length = Number.NEGATIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} +try { + x = []; + x.length = undefined; + throw new Test262Error('#4.1: x = []; x.length = undefined throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T1.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T1.js new file mode 100644 index 00000000000..bb3902950f3 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-exotic-objects-defineownproperty-p-desc +info: | + For every integer k that is less than the value of + the length property of A but not less than ToUint32(length), + if A itself has a property (not an inherited property) named ToString(k), + then delete that property +es5id: 15.4.5.1_A1.2_T1 +description: Change length of array +---*/ + +var x = [0, , 2, , 4]; +x.length = 4; +assert.sameValue(x[4], undefined, 'The value of x[4] is expected to equal undefined'); +x.length = 3; +assert.sameValue(x[3], undefined, 'The value of x[3] is expected to equal undefined'); +assert.sameValue(x[2], 2, 'The value of x[2] is expected to be 2'); diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T3.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T3.js new file mode 100644 index 00000000000..0d3ae77eddf --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T3.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-exotic-objects-defineownproperty-p-desc +info: | + For every integer k that is less than the value of + the length property of A but not less than ToUint32(length), + if A itself has a property (not an inherited property) named ToString(k), + then delete that property +es5id: 15.4.5.1_A1.2_T3 +description: Checking an inherited property +---*/ + +SendableArray.prototype[2] = 2; +var x = [0, 1]; +x.length = 3; +assert.sameValue(x.hasOwnProperty('2'), false, 'x.hasOwnProperty("2") must return false'); +x.length = 2; +assert.sameValue(x[2], 2, 'The value of x[2] is expected to be 2'); diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T1.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T1.js new file mode 100644 index 00000000000..1bf4c7e31b0 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T1.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-exotic-objects-defineownproperty-p-desc +info: Set the value of property length of A to Uint32(length) +es5id: 15.4.5.1_A1.3_T1 +description: length is object or primitve +---*/ + +var x = []; +x.length = true; +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +x = [0]; +x.length = null; +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); +x = [0]; +x.length = new Boolean(false); +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); +x = []; +x.length = new Number(1); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +x = []; +x.length = "1"; +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +x = []; +x.length = new String("1"); +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T2.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T2.js new file mode 100644 index 00000000000..3b1afff947e --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T2.js @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-exotic-objects-defineownproperty-p-desc +info: Set the value of property length of A to Uint32(length) +es5id: 15.4.5.1_A1.3_T2 +description: Uint32 use ToNumber and ToPrimitve +---*/ + +var x = []; +x.length = { + valueOf: function() { + return 2 + } +}; +assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); +x = []; +x.length = { + valueOf: function() { + return 2 + }, + toString: function() { + return 1 + } +}; +assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); +x = []; +x.length = { + valueOf: function() { + return 2 + }, + toString: function() { + return {} + } +}; +assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); +try { + x = []; + x.length = { + valueOf: function() { + return 2 + }, + toString: function() { + throw "error" + } + }; + assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} +x = []; +x.length = { + toString: function() { + return 1 + } +}; +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +x = []; +x.length = { + valueOf: function() { + return {} + }, + toString: function() { + return 1 + } +} +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +try { + x = []; + x.length = { + valueOf: function() { + throw "error" + }, + toString: function() { + return 1 + } + }; + x.length; + throw new Test262Error('#7.1: x = []; x.length = {valueOf: function() {throw "error"}, toString: function() {return 1}}; x.length throw "error". Actual: ' + (x.length)); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} +try { + x = []; + x.length = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + x.length; + throw new Test262Error('#8.1: x = []; x.length = {valueOf: function() {return {}}, toString: function() {return {}}} x.length throw TypeError. Actual: ' + (x.length)); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Array/length/S15.4.5.2_A3_T4.js b/test/sendable/builtins/Array/length/S15.4.5.2_A3_T4.js new file mode 100644 index 00000000000..c54202d8049 --- /dev/null +++ b/test/sendable/builtins/Array/length/S15.4.5.2_A3_T4.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-properties-of-array-instances-length +info: | + If the length property is changed, every property whose name + is an array index whose value is not smaller than the new length is automatically deleted +es5id: 15.4.5.2_A3_T4 +description: > + If new length greater than the name of every property whose name + is an array index +---*/ + +var x = [0, 1, 2]; +x[4294967294] = 4294967294; +x.length = 2; +assert.sameValue(x[0], 0, 'The value of x[0] is expected to be 0'); +assert.sameValue(x[1], 1, 'The value of x[1] is expected to be 1'); +assert.sameValue(x[2], undefined, 'The value of x[2] is expected to equal undefined'); +assert.sameValue(x[4294967294], undefined, 'The value of x[4294967294] is expected to equal undefined'); diff --git a/test/sendable/builtins/Array/length/define-own-prop-length-coercion-order-set.js b/test/sendable/builtins/Array/length/define-own-prop-length-coercion-order-set.js new file mode 100644 index 00000000000..2f85430637d --- /dev/null +++ b/test/sendable/builtins/Array/length/define-own-prop-length-coercion-order-set.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-arraysetlength +description: > + [[Value]] is coerced to number before current descriptor's [[Writable]] check. +info: | + ArraySetLength ( A, Desc ) + 3. Let newLen be ? ToUint32(Desc.[[Value]]). + 4. Let numberLen be ? ToNumber(Desc.[[Value]]). + 7. Let oldLenDesc be OrdinaryGetOwnProperty(A, "length"). + 12. If oldLenDesc.[[Writable]] is false, return false. +features: [Symbol, Symbol.toPrimitive, Reflect, Reflect.set] +includes: [compareArray.js] +---*/ + +var SendableArray = [1, 2, 3]; +var hints = []; +var length = {}; +length[Symbol.toPrimitive] = function(hint) { + hints.push(hint); + Object.defineProperty(SendableArray, "length", {writable: false}); + return 0; +}; +assert.throws(TypeError, function() { + "use strict"; + SendableArray.length = length; +}, '`"use strict"; SendableArray.length = length` throws a TypeError exception'); +assert.compareArray(hints, ["number", "number"], 'The value of hints is expected to be ["number", "number"]'); +SendableArray = [1, 2, 3]; +hints = []; +assert( + !Reflect.set(SendableArray, "length", length), + 'The value of !Reflect.set(SendableArray, "length", length) is expected to be true' +); +assert.compareArray(hints, ["number", "number"], 'The value of hints is expected to be ["number", "number"]'); diff --git a/test/sendable/builtins/Array/length/define-own-prop-length-coercion-order.js b/test/sendable/builtins/Array/length/define-own-prop-length-coercion-order.js new file mode 100644 index 00000000000..16617c1de2d --- /dev/null +++ b/test/sendable/builtins/Array/length/define-own-prop-length-coercion-order.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-arraysetlength +description: > + [[Value]] is coerced to number before descriptor validation. +info: | + ArraySetLength ( A, Desc ) + 3. Let newLen be ? ToUint32(Desc.[[Value]]). + 4. Let numberLen be ? ToNumber(Desc.[[Value]]). + 7. Let oldLenDesc be OrdinaryGetOwnProperty(A, "length"). + 11. If newLen ≥ oldLen, then + a. Return OrdinaryDefineOwnProperty(A, "length", newLenDesc). + OrdinaryDefineOwnProperty ( O, P, Desc ) + 3. Return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current). + ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current ) + 7. Else if IsDataDescriptor(current) and IsDataDescriptor(Desc) are both true, then + a. If current.[[Configurable]] is false and current.[[Writable]] is false, then + i. If Desc.[[Writable]] is present and Desc.[[Writable]] is true, return false. +features: [Reflect] +---*/ + +var SendableArray = [1, 2]; +var valueOfCalls = 0; +var length = { + valueOf: function() { + valueOfCalls += 1; + if (valueOfCalls !== 1) { + // skip first coercion at step 3 + Object.defineProperty(SendableArray, "length", {writable: false}); + } + return SendableArray.length; + }, +}; +assert.throws(TypeError, function() { + Object.defineProperty(SendableArray, "length", {value: length, writable: true}); +}, 'Object.defineProperty(SendableArray, "length", {value: length, writable: true}) throws a TypeError exception'); +assert.sameValue(valueOfCalls, 2, 'The value of valueOfCalls is expected to be 2'); +SendableArray = [1, 2]; +valueOfCalls = 0; +assert( + !Reflect.defineProperty(SendableArray, "length", {value: length, writable: true}), + 'The value of !Reflect.defineProperty(SendableArray, "length", {value: length, writable: true}) is expected to be true' +); +assert.sameValue(valueOfCalls, 2, 'The value of valueOfCalls is expected to be 2'); diff --git a/test/sendable/builtins/Array/length/define-own-prop-length-error.js b/test/sendable/builtins/Array/length/define-own-prop-length-error.js new file mode 100644 index 00000000000..68e500ade9f --- /dev/null +++ b/test/sendable/builtins/Array/length/define-own-prop-length-error.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-arraysetlength +description: > + Setting an invalid array length throws a RangeError +info: | + ArraySetLength ( A, Desc ) + 5. If SameValueZero(newLen, numberLen) is false, throw a RangeError exception. +---*/ + +assert.throws(RangeError, function () { + Object.defineProperty([], 'length', { value: -1, configurable: true }); +}); +assert.throws(RangeError, function () { + // the string is intentionally "computed" here to ensure there are no optimization bugs + Object.defineProperty([], 'len' + 'gth', { value: -1, configurable: true }); +}); diff --git a/test/sendable/builtins/Array/length/define-own-prop-length-no-value-order.js b/test/sendable/builtins/Array/length/define-own-prop-length-no-value-order.js new file mode 100644 index 00000000000..9ce2fe056d9 --- /dev/null +++ b/test/sendable/builtins/Array/length/define-own-prop-length-no-value-order.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-arraysetlength +description: > + Ordinary descriptor validation if [[Value]] is absent. +info: | + ArraySetLength ( A, Desc ) + 1. If Desc.[[Value]] is absent, then + a. Return OrdinaryDefineOwnProperty(A, "length", Desc). + OrdinaryDefineOwnProperty ( O, P, Desc ) + 3. Return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current). + ValidateAndApplyPropertyDescriptor ( O, P, extensible, Desc, current ) + 4. If current.[[Configurable]] is false, then + a. If Desc.[[Configurable]] is present and its value is true, return false. + b. If Desc.[[Enumerable]] is present and + ! SameValue(Desc.[[Enumerable]], current.[[Enumerable]]) is false, return false. + 6. Else if ! SameValue(! IsDataDescriptor(current), ! IsDataDescriptor(Desc)) is false, then + a. If current.[[Configurable]] is false, return false. + 7. Else if IsDataDescriptor(current) and IsDataDescriptor(Desc) are both true, then + a. If current.[[Configurable]] is false and current.[[Writable]] is false, then + i. If Desc.[[Writable]] is present and Desc.[[Writable]] is true, return false. +features: [Reflect] +---*/ + +assert.throws(TypeError, function() { + Object.defineProperty([], "length", {configurable: true}); +}, 'Object.defineProperty([], "length", {configurable: true}) throws a TypeError exception'); +assert( + !Reflect.defineProperty([], "length", {enumerable: true}), + 'The value of !Reflect.defineProperty([], "length", {enumerable: true}) is expected to be true' +); +assert.throws(TypeError, function() { + Object.defineProperty([], "length", { + get: function() { + throw new Test262Error("[[Get]] shouldn't be called"); + }, + }); +}, 'Object.defineProperty([], "length", {get: function() {throw new Test262Error("[[Get]] shouldn"t be called");},}) throws a TypeError exception'); +assert( + !Reflect.defineProperty([], "length", {set: function(_value) {}}), + 'The value of !Reflect.defineProperty([], "length", {set: function(_value) {}}) is expected to be true' +); +var SendableArray = []; +Object.defineProperty(SendableArray, "length", {writable: false}); +assert.throws(TypeError, function() { + Object.defineProperty(SendableArray, "length", {writable: true}); +}, 'Object.defineProperty(SendableArray, "length", {writable: true}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/length/define-own-prop-length-overflow-order.js b/test/sendable/builtins/Array/length/define-own-prop-length-overflow-order.js new file mode 100644 index 00000000000..8195ba80767 --- /dev/null +++ b/test/sendable/builtins/Array/length/define-own-prop-length-overflow-order.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-arraysetlength +description: > + [[Value]] is checked for overflow before descriptor validation. +info: | + ArraySetLength ( A, Desc ) + 3. Let newLen be ? ToUint32(Desc.[[Value]]). + 4. Let numberLen be ? ToNumber(Desc.[[Value]]). + 5. If newLen ≠ numberLen, throw a RangeError exception. +---*/ + +assert.throws(RangeError, function() { + Object.defineProperty([], "length", {value: -1, configurable: true}); +}, 'Object.defineProperty([], "length", {value: -1, configurable: true}) throws a RangeError exception'); +assert.throws(RangeError, function() { + Object.defineProperty([], "length", {value: NaN, enumerable: true}); +}, 'Object.defineProperty([], "length", {value: NaN, enumerable: true}) throws a RangeError exception'); +var SendableArray = []; +Object.defineProperty(SendableArray, "length", {writable: false}); +assert.throws(RangeError, function() { + Object.defineProperty(SendableArray, "length", {value: Number.MAX_SAFE_INTEGER, writable: true}); +}, 'Object.defineProperty(SendableArray, "length", {value: Number.MAX_SAFE_INTEGER, writable: true}) throws a RangeError exception'); diff --git a/test/sendable/builtins/Array/length/define-own-prop-length-overflow-realm.js b/test/sendable/builtins/Array/length/define-own-prop-length-overflow-realm.js new file mode 100644 index 00000000000..702c09b6862 --- /dev/null +++ b/test/sendable/builtins/Array/length/define-own-prop-length-overflow-realm.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-exotic-objects-defineownproperty-p-desc +es6id: 9.4.2.1 +description: > + Error when setting a length larger than 2**32 (honoring the Realm of the + current execution context) +info: | + 2. If P is "length", then + a. Return ? ArraySetLength(A, Desc). +features: [cross-realm] +---*/ + +var OArray = $262.createRealm().global.Array; +var SendableArray = new OArray(); +assert.throws(RangeError, function() { + SendableArray.length = 4294967296; +}, 'SendableArray.length = 4294967296 throws a RangeError exception'); -- Gitee From 32daa5006182ca7267f482e4bd9fe1959e187ce7 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 17 Dec 2024 10:52:41 +0800 Subject: [PATCH 12/93] add sendableArray.of cases Signed-off-by: zhuzhihui7 --- ...truct-this-with-the-number-of-arguments.js | 46 ++++++++++++++++ .../of/creates-a-new-array-from-arguments.js | 52 +++++++++++++++++++ .../of/does-not-use-prototype-properties.js | 37 +++++++++++++ .../Array/of/does-not-use-set-for-indices.js | 41 +++++++++++++++ test/sendable/builtins/Array/of/length.js | 30 +++++++++++ test/sendable/builtins/Array/of/name.js | 30 +++++++++++ .../builtins/Array/of/not-a-constructor.js | 34 ++++++++++++ test/sendable/builtins/Array/of/of.js | 29 +++++++++++ .../Array/of/proto-from-ctor-realm.js | 37 +++++++++++++ .../Array/of/return-a-custom-instance.js | 44 ++++++++++++++++ .../Array/of/return-a-new-array-object.js | 48 +++++++++++++++++ .../Array/of/return-abrupt-from-contructor.js | 37 +++++++++++++ ...n-abrupt-from-data-property-using-proxy.js | 42 +++++++++++++++ .../of/return-abrupt-from-data-property.js | 48 +++++++++++++++++ .../of/return-abrupt-from-setting-length.js | 34 ++++++++++++ .../sendable/builtins/Array/of/sets-length.js | 42 +++++++++++++++ 16 files changed, 631 insertions(+) create mode 100644 test/sendable/builtins/Array/of/construct-this-with-the-number-of-arguments.js create mode 100644 test/sendable/builtins/Array/of/creates-a-new-array-from-arguments.js create mode 100644 test/sendable/builtins/Array/of/does-not-use-prototype-properties.js create mode 100644 test/sendable/builtins/Array/of/does-not-use-set-for-indices.js create mode 100644 test/sendable/builtins/Array/of/length.js create mode 100644 test/sendable/builtins/Array/of/name.js create mode 100644 test/sendable/builtins/Array/of/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/of/of.js create mode 100644 test/sendable/builtins/Array/of/proto-from-ctor-realm.js create mode 100644 test/sendable/builtins/Array/of/return-a-custom-instance.js create mode 100644 test/sendable/builtins/Array/of/return-a-new-array-object.js create mode 100644 test/sendable/builtins/Array/of/return-abrupt-from-contructor.js create mode 100644 test/sendable/builtins/Array/of/return-abrupt-from-data-property-using-proxy.js create mode 100644 test/sendable/builtins/Array/of/return-abrupt-from-data-property.js create mode 100644 test/sendable/builtins/Array/of/return-abrupt-from-setting-length.js create mode 100644 test/sendable/builtins/Array/of/sets-length.js diff --git a/test/sendable/builtins/Array/of/construct-this-with-the-number-of-arguments.js b/test/sendable/builtins/Array/of/construct-this-with-the-number-of-arguments.js new file mode 100644 index 00000000000..0d9d8fd9646 --- /dev/null +++ b/test/sendable/builtins/Array/of/construct-this-with-the-number-of-arguments.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +es6id: 22.1.2.3 +description: Passes the number of arguments to the constructor it calls. +info: | + SendableArray.of ( ...items ) + 1. Let len be the actual number of arguments passed to this function. + 2. Let items be the List of arguments passed to this function. + 3. Let C be the this value. + 4. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + ... +---*/ + +var len; +var hits = 0; +function C(length) { + len = length; + hits++; +} +SendableArray.of.call(C); +assert.sameValue(len, 0, 'The value of len is expected to be 0'); +assert.sameValue(hits, 1, 'The value of hits is expected to be 1'); +SendableArray.of.call(C, 'a', 'b') +assert.sameValue(len, 2, 'The value of len is expected to be 2'); +assert.sameValue(hits, 2, 'The value of hits is expected to be 2'); +SendableArray.of.call(C, false, null, undefined); +assert.sameValue( + len, 3, + 'The value of len is expected to be 3' +); +assert.sameValue(hits, 3, 'The value of hits is expected to be 3'); diff --git a/test/sendable/builtins/Array/of/creates-a-new-array-from-arguments.js b/test/sendable/builtins/Array/of/creates-a-new-array-from-arguments.js new file mode 100644 index 00000000000..488fe9d23c9 --- /dev/null +++ b/test/sendable/builtins/Array/of/creates-a-new-array-from-arguments.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +es6id: 22.1.2.3 +description: > + SendableArray.of method creates a new Array with a variable number of arguments. +info: | + 22.1.2.3 SendableArray.of ( ...items ) + 7. Let k be 0. + 8. Repeat, while k < len + a. Let kValue be items[k]. + b. Let Pk be ToString(k). + c. Let defineStatus be CreateDataPropertyOrThrow(A,Pk, kValue). + d. ReturnIfAbrupt(defineStatus). + e. Increase k by 1. + 9. Let setStatus be Set(A, "length", len, true). + 10. ReturnIfAbrupt(setStatus). + 11. Return A. +---*/ + +var a1 = SendableArray.of('Mike', 'Rick', 'Leo'); +assert.sameValue( + a1.length, 3, + 'The value of a1.length is expected to be 3' +); +assert.sameValue(a1[0], 'Mike', 'The value of a1[0] is expected to be "Mike"'); +assert.sameValue(a1[1], 'Rick', 'The value of a1[1] is expected to be "Rick"'); +assert.sameValue(a1[2], 'Leo', 'The value of a1[2] is expected to be "Leo"'); +var a2 = SendableArray.of(undefined, false, null, undefined); +assert.sameValue( + a2.length, 4, + 'The value of a2.length is expected to be 4' +); +assert.sameValue(a2[0], undefined, 'The value of a2[0] is expected to equal undefined'); +assert.sameValue(a2[1], false, 'The value of a2[1] is expected to be false'); +assert.sameValue(a2[2], null, 'The value of a2[2] is expected to be null'); +assert.sameValue(a2[3], undefined, 'The value of a2[3] is expected to equal undefined'); +var a3 = SendableArray.of(); +assert.sameValue(a3.length, 0, 'The value of a3.length is expected to be 0'); diff --git a/test/sendable/builtins/Array/of/does-not-use-prototype-properties.js b/test/sendable/builtins/Array/of/does-not-use-prototype-properties.js new file mode 100644 index 00000000000..f243c776164 --- /dev/null +++ b/test/sendable/builtins/Array/of/does-not-use-prototype-properties.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +es6id: 22.1.2.3 +description: Array.of does not use prototype properties for arguments. +info: | + It defines elements rather than assigning to them. +---*/ + +Object.defineProperty(SendableArray.prototype, "0", { + set: function(v) { + throw new Test262Error('Should define own properties'); + } +}); +var arr = SendableArray.of(true); +assert.sameValue(arr[0], true, 'The value of arr[0] is expected to be true'); +function Custom() {} +Object.defineProperty(Custom.prototype, "0", { + set: function(v) { + throw new Test262Error('Should define own properties'); + } +}); +var custom = SendableArray.of.call(Custom, true); +assert.sameValue(custom[0], true, 'The value of custom[0] is expected to be true'); diff --git a/test/sendable/builtins/Array/of/does-not-use-set-for-indices.js b/test/sendable/builtins/Array/of/does-not-use-set-for-indices.js new file mode 100644 index 00000000000..8965ef3ee56 --- /dev/null +++ b/test/sendable/builtins/Array/of/does-not-use-set-for-indices.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +description: > + Non-writable properties are overwritten by CreateDataProperty. + (result object's "0" is non-writable) +info: | + SendableArray.of ( ...items ) + 7. Repeat, while k < len + c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue). +includes: [propertyHelper.js] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + value: 1, + writable: false, + enumerable: false, + configurable: true, + }); +}; +var res = SendableArray.of.call(A, 2); +verifyProperty(res, "0", { + value: 2, + writable: true, + enumerable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/of/length.js b/test/sendable/builtins/Array/of/length.js new file mode 100644 index 00000000000..45867c99593 --- /dev/null +++ b/test/sendable/builtins/Array/of/length.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +description: > + SendableArray.of.length value and property descriptor +info: | + SendableArray.of ( ...items ) + The length property of the of function is 0. +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.of, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/of/name.js b/test/sendable/builtins/Array/of/name.js new file mode 100644 index 00000000000..a804310834e --- /dev/null +++ b/test/sendable/builtins/Array/of/name.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +description: > + SendableArray.of.name value and property descriptor +info: | + SendableArray.of ( ...items ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.of, "name", { + value: "of", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/of/not-a-constructor.js b/test/sendable/builtins/Array/of/not-a-constructor.js new file mode 100644 index 00000000000..3944d50616f --- /dev/null +++ b/test/sendable/builtins/Array/of/not-a-constructor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableArray.of 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(SendableArray.of), false, 'isConstructor(SendableArray.of) must return false'); +assert.throws(TypeError, () => { + new SendableArray.of(1); +}, '`new SendableArray.of(1)` throws a TypeError exception'); + diff --git a/test/sendable/builtins/Array/of/of.js b/test/sendable/builtins/Array/of/of.js new file mode 100644 index 00000000000..0f9537967fd --- /dev/null +++ b/test/sendable/builtins/Array/of/of.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +description: > + SendableArray.of property descriptor +info: | + SendableArray.of ( ...items ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray, "of", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/of/proto-from-ctor-realm.js b/test/sendable/builtins/Array/of/proto-from-ctor-realm.js new file mode 100644 index 00000000000..4b6e6fa495e --- /dev/null +++ b/test/sendable/builtins/Array/of/proto-from-ctor-realm.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +description: Default [[Prototype]] value derived from realm of the constructor +info: | + 4. If IsConstructor(C) is true, then + a. Let A be ? Construct(C, « len »). + 9.1.14 GetPrototypeFromConstructor + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. +features: [cross-realm] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; +var a = SendableArray.of.call(C, 1, 2, 3); +assert.sameValue( + Object.getPrototypeOf(a), + other.Object.prototype, + 'Object.getPrototypeOf(SendableArray.of.call(C, 1, 2, 3)) returns other.Object.prototype' +); diff --git a/test/sendable/builtins/Array/of/return-a-custom-instance.js b/test/sendable/builtins/Array/of/return-a-custom-instance.js new file mode 100644 index 00000000000..2857e2494ef --- /dev/null +++ b/test/sendable/builtins/Array/of/return-a-custom-instance.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +description: > + Returns an instance from a custom constructor. +info: | + SendableArray.of ( ...items ) + 4. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 11. Return A. +---*/ + +function Coop() {} +var coop = SendableArray.of.call(Coop, 'Mike', 'Rick', 'Leo'); +assert.sameValue( + coop.length, 3, + 'The value of coop.length is expected to be 3' +); +assert.sameValue( + coop[0], 'Mike', + 'The value of coop[0] is expected to be "Mike"' +); +assert.sameValue( + coop[1], 'Rick', + 'The value of coop[1] is expected to be "Rick"' +); +assert.sameValue( + coop[2], 'Leo', + 'The value of coop[2] is expected to be "Leo"' +); +assert(coop instanceof Coop, 'The result of evaluating (coop instanceof Coop) is expected to be true'); diff --git a/test/sendable/builtins/Array/of/return-a-new-array-object.js b/test/sendable/builtins/Array/of/return-a-new-array-object.js new file mode 100644 index 00000000000..9a4e3cd21b2 --- /dev/null +++ b/test/sendable/builtins/Array/of/return-a-new-array-object.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +description: > + Returns a new SendableArray. +info: | + SendableArray.of ( ...items ) + 1. Let len be the actual number of arguments passed to this function. + 2. Let items be the List of arguments passed to this function. + 3. Let C be the this value. + 4. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 5. Else, + b. Let A be ArrayCreate(len). + 11. Return A. +---*/ + +var result = SendableArray.of(); +assert(result instanceof SendableArray, 'The result of evaluating (result instanceof SendableArray) is expected to be true'); + +result = SendableArray.of.call(undefined); +assert( + result instanceof SendableArray, + 'The result of evaluating (result instanceof SendableArray) is expected to be true' +); +result = SendableArray.of.call(Math.cos); +assert( + result instanceof SendableArray, + 'The result of evaluating (result instanceof SendableArray) is expected to be true' +); +result = SendableArray.of.call(Math.cos.bind(Math)); +assert( + result instanceof SendableArray, + 'The result of evaluating (result instanceof SendableArray) is expected to be true' +); diff --git a/test/sendable/builtins/Array/of/return-abrupt-from-contructor.js b/test/sendable/builtins/Array/of/return-abrupt-from-contructor.js new file mode 100644 index 00000000000..773678f6004 --- /dev/null +++ b/test/sendable/builtins/Array/of/return-abrupt-from-contructor.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +description: > + Return abrupt from this' constructor +info: | + SendableArray.of ( ...items ) + 1. Let len be the actual number of arguments passed to this function. + 2. Let items be the List of arguments passed to this function. + 3. Let C be the this value. + 4. If IsConstructor(C) is true, then + a. Let A be Construct(C, «len»). + 5. Else, + b. Let A be ArrayCreate(len). + 6. ReturnIfAbrupt(A). + ... +---*/ + +function T() { + throw new Test262Error(); +} +assert.throws(Test262Error, function() { + SendableArray.of.call(T); +}, 'SendableArray.of.call(T) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/of/return-abrupt-from-data-property-using-proxy.js b/test/sendable/builtins/Array/of/return-abrupt-from-data-property-using-proxy.js new file mode 100644 index 00000000000..a1e227825f7 --- /dev/null +++ b/test/sendable/builtins/Array/of/return-abrupt-from-data-property-using-proxy.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +description: > + Return abrupt from Data Property creation +info: | + SendableArray.of ( ...items ) + 7. Let k be 0. + 8. Repeat, while k < len + a. Let kValue be items[k]. + b. Let Pk be ToString(k). + c. Let defineStatus be CreateDataPropertyOrThrow(A,Pk, kValue). + d. ReturnIfAbrupt(defineStatus). + 7.3.6 CreateDataPropertyOrThrow (O, P, V) + 3. Let success be CreateDataProperty(O, P, V). + 4. ReturnIfAbrupt(success). +features: [Proxy] +---*/ + +function T() { + return new Proxy({}, { + defineProperty: function() { + throw new Test262Error(); + } + }); +} +assert.throws(Test262Error, function() { + SendableArray.of.call(T, 'Bob'); +}, 'SendableArray.of.call(T, "Bob") throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/of/return-abrupt-from-data-property.js b/test/sendable/builtins/Array/of/return-abrupt-from-data-property.js new file mode 100644 index 00000000000..8d5a8a36ece --- /dev/null +++ b/test/sendable/builtins/Array/of/return-abrupt-from-data-property.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +description: > + Return abrupt from Data Property creation +info: | + SendableArray.of ( ...items ) + 7. Let k be 0. + 8. Repeat, while k < len + a. Let kValue be items[k]. + b. Let Pk be ToString(k). + c. Let defineStatus be CreateDataPropertyOrThrow(A,Pk, kValue). + d. ReturnIfAbrupt(defineStatus). + 7.3.6 CreateDataPropertyOrThrow (O, P, V) + 3. Let success be CreateDataProperty(O, P, V). + 4. ReturnIfAbrupt(success). + 5. If success is false, throw a TypeError exception. +---*/ + +function T1() { + Object.preventExtensions(this); +} +assert.throws(TypeError, function() { + SendableArray.of.call(T1, 'Bob'); +}, 'SendableArray.of.call(T1, "Bob") throws a TypeError exception'); +function T2() { + Object.defineProperty(this, 0, { + configurable: false, + writable: true, + enumerable: true + }); +} +assert.throws(TypeError, function() { + SendableArray.of.call(T2, 'Bob'); +}, 'SendableArray.of.call(T2, "Bob") throws a TypeError exception') diff --git a/test/sendable/builtins/Array/of/return-abrupt-from-setting-length.js b/test/sendable/builtins/Array/of/return-abrupt-from-setting-length.js new file mode 100644 index 00000000000..726733bc943 --- /dev/null +++ b/test/sendable/builtins/Array/of/return-abrupt-from-setting-length.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +description: > + Return abrupt from setting the length property. +info: | + SendableArray.of ( ...items ) + 9. Let setStatus be Set(A, "length", len, true). + 10. ReturnIfAbrupt(setStatus). +---*/ + +function T() { + Object.defineProperty(this, 'length', { + set: function() { + throw new Test262Error(); + } + }); +} +assert.throws(Test262Error, function() { + SendableArray.of.call(T); +}, 'SendableArray.of.call(T) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/of/sets-length.js b/test/sendable/builtins/Array/of/sets-length.js new file mode 100644 index 00000000000..2fdb9553795 --- /dev/null +++ b/test/sendable/builtins/Array/of/sets-length.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.of +description: > + Calls the length setter if available +info: | + SendableArray.of ( ...items ) + 9. Let setStatus be Set(A, "length", len, true). +---*/ + +var hits = 0; +var value; +var _this_; +function Pack() { + Object.defineProperty(this, "length", { + set: function(len) { + hits++; + value = len; + _this_ = this; + } + }); +} +var result = SendableArray.of.call(Pack, 'wolves', 'cards', 'cigarettes', 'lies'); +assert.sameValue(hits, 1, 'The value of hits is expected to be 1'); +assert.sameValue( + value, 4, + 'The value of value is expected to be 4' +); +assert.sameValue(_this_, result, 'The value of _this_ is expected to equal the value of result'); -- Gitee From 1b7c2df4ff0fa8a910b195e473e0a0610e9b2e57 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 17 Dec 2024 16:37:33 +0800 Subject: [PATCH 13/93] add array-prototype-at cases Signed-off-by: zhuzhihui7 --- .../prototype/at/coerced-index-resize.js | 49 +++++++++++++++ .../prototype/at/index-argument-tointeger.js | 38 ++++++++++++ ...-non-numeric-argument-tointeger-invalid.js | 32 ++++++++++ .../index-non-numeric-argument-tointeger.js | 37 ++++++++++++ .../builtins/Array/prototype/at/length.js | 35 +++++++++++ .../builtins/Array/prototype/at/name.js | 38 ++++++++++++ .../builtins/Array/prototype/at/prop-desc.js | 39 ++++++++++++ .../prototype/at/return-abrupt-from-this.js | 34 +++++++++++ .../at/returns-item-relative-index.js | 42 +++++++++++++ .../Array/prototype/at/returns-item.js | 43 ++++++++++++++ ...ns-undefined-for-holes-in-sparse-arrays.js | 51 ++++++++++++++++ ...eturns-undefined-for-out-of-range-index.js | 33 +++++++++++ .../at/typed-array-resizable-buffer.js | 59 +++++++++++++++++++ 13 files changed, 530 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/at/coerced-index-resize.js create mode 100644 test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js create mode 100644 test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js create mode 100644 test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger.js create mode 100644 test/sendable/builtins/Array/prototype/at/length.js create mode 100644 test/sendable/builtins/Array/prototype/at/name.js create mode 100644 test/sendable/builtins/Array/prototype/at/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/at/return-abrupt-from-this.js create mode 100644 test/sendable/builtins/Array/prototype/at/returns-item-relative-index.js create mode 100644 test/sendable/builtins/Array/prototype/at/returns-item.js create mode 100644 test/sendable/builtins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js create mode 100644 test/sendable/builtins/Array/prototype/at/returns-undefined-for-out-of-range-index.js create mode 100644 test/sendable/builtins/Array/prototype/at/typed-array-resizable-buffer.js diff --git a/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js b/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js new file mode 100644 index 00000000000..1191115aa3a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.at +description: > + Array.p.at behaves correctly on TypedArrays backed by resizable buffers when + the TypedArray is resized during parameter conversion +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function SendableArrayAtHelper(ta, index) { + return SendableArray.prototype.at.call(ta, index); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2); + return 0; + } + }; + assert.sameValue(SendableArrayAtHelper(fixedLength, evil), undefined); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + let evil = { + valueOf: () => { + rab.resize(2); + return -1; + } + }; + // The TypedArray is *not* out of bounds since it's length-tracking. + assert.sameValue(SendableArrayAtHelper(lengthTracking, evil), undefined); +} diff --git a/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js b/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js new file mode 100644 index 00000000000..d966d02bef8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.at +description: > + Property type and descriptor. +info: | + Array.prototype.at( index ) + Let relativeIndex be ? ToInteger(index). +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof sendableArray.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); +let valueOfCallCount = 0; +let index = { + valueOf() { + valueOfCallCount++; + return 1; + } +}; +let a = [0,1,2,3]; +assert.sameValue(a.at(index), 1, 'a.at({valueOf() {valueOfCallCount++; return 1;}}) must return 1'); +assert.sameValue(valueOfCallCount, 1, 'The value of valueOfCallCount is expected to be 1'); diff --git a/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js b/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js new file mode 100644 index 00000000000..c7fcccf6d51 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.at +description: > + Property type and descriptor. +info: | + Array.prototype.at( index ) + Let relativeIndex be ? ToInteger(index). +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof sendableArray.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); +let a = [0,1,2,3]; +assert.throws(TypeError, () => { + a.at(Symbol()); +}, 'a.at(Symbol()) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger.js b/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger.js new file mode 100644 index 00000000000..1b3332508bb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.at +description: > + Property type and descriptor. +info: | + Array.prototype.at( index ) + Let relativeIndex be ? ToInteger(index). +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof sendableArray.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); +let a = [0,1,2,3]; +assert.sameValue(a.at(false), 0, 'a.at(false) must return 0'); +assert.sameValue(a.at(null), 0, 'a.at(null) must return 0'); +assert.sameValue(a.at(undefined), 0, 'a.at(undefined) must return 0'); +assert.sameValue(a.at(""), 0, 'a.at("") must return 0'); +assert.sameValue(a.at(function() {}), 0, 'a.at(function() {}) must return 0'); +assert.sameValue(a.at([]), 0, 'a.at([]) must return 0'); +assert.sameValue(a.at(true), 1, 'a.at(true) must return 1'); +assert.sameValue(a.at("1"), 1, 'a.at("1") must return 1'); diff --git a/test/sendable/builtins/Array/prototype/at/length.js b/test/sendable/builtins/Array/prototype/at/length.js new file mode 100644 index 00000000000..5c96c5677a6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/at/length.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.at +description: > + Array.prototype.at.length value and descriptor. +info: | + Array.prototype.at( index ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof sendableArray.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); +verifyProperty(sendableArray.prototype.at, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/at/name.js b/test/sendable/builtins/Array/prototype/at/name.js new file mode 100644 index 00000000000..87973d657fb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/at/name.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.at +description: > + Array.prototype.at.name value and descriptor. +info: | + Array.prototype.at( index ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof sendableArray.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); +assert.sameValue( + sendableArray.prototype.at.name, 'at', + 'The value of Array.prototype.at.name is expected to be "at"' +); +verifyProperty(sendableArray.prototype.at, 'name', { + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/at/prop-desc.js b/test/sendable/builtins/Array/prototype/at/prop-desc.js new file mode 100644 index 00000000000..d7ba95456b2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/at/prop-desc.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.at +description: > + Property type and descriptor. +info: | + Array.prototype.at( index ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof sendableArray.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); +assert.sameValue( + typeof sendableArray.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); +verifyProperty(sendableArray.prototype, 'at', { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/at/return-abrupt-from-this.js b/test/sendable/builtins/Array/prototype/at/return-abrupt-from-this.js new file mode 100644 index 00000000000..e1947b0486d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/at/return-abrupt-from-this.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.at +description: > + Return abrupt from ToObject(this value). +info: | + Array.prototype.at( index ) + Let O be ? ToObject(this value). +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof sendableArray.prototype.at, + 'function', + 'The value of `typeof sendableArray.prototype.at` is expected to be "function"' +); +assert.throws(TypeError, () => { + sendableArray.prototype.at.call(undefined); +}, 'sendableArray.prototype.at.call(undefined) throws a TypeError exception'); +assert.throws(TypeError, () => { + sendableArray.prototype.at.call(null); +}, 'sendableArray.prototype.at.call(null) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/at/returns-item-relative-index.js b/test/sendable/builtins/Array/prototype/at/returns-item-relative-index.js new file mode 100644 index 00000000000..d40ebe5b888 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/at/returns-item-relative-index.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.at +description: > + Returns the item value at the specified relative index +info: | + Array.prototype.at ( ) + Let O be ? ToObject(this value). + Let len be ? LengthOfArrayLike(O). + Let relativeIndex be ? ToInteger(index). + If relativeIndex ≥ 0, then + Let k be relativeIndex. + Else, + Let k be len + relativeIndex. + If k < 0 or k ≥ len, then return undefined. + Return ? Get(O, ! ToString(k)). +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof sendableArray.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); +let a = [1, 2, 3, 4, ,5]; +assert.sameValue(a.at(0), 1, 'a.at(0) must return 1'); +assert.sameValue(a.at(-1), 5, 'a.at(-1) must return 5'); +assert.sameValue(a.at(-2), undefined, 'a.at(-2) returns undefined'); +assert.sameValue(a.at(-3), 4, 'a.at(-3) must return 4'); +assert.sameValue(a.at(-4), 3, 'a.at(-4) must return 3'); diff --git a/test/sendable/builtins/Array/prototype/at/returns-item.js b/test/sendable/builtins/Array/prototype/at/returns-item.js new file mode 100644 index 00000000000..8828a3f760e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/at/returns-item.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.at +description: > + Returns the item value at the specified index +info: | + Array.prototype.at ( ) + Let O be ? ToObject(this value). + Let len be ? LengthOfArrayLike(O). + Let relativeIndex be ? ToInteger(index). + If relativeIndex ≥ 0, then + Let k be relativeIndex. + Else, + Let k be len + relativeIndex. + If k < 0 or k ≥ len, then return undefined. + Return ? Get(O, ! ToString(k)). +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof sendableArray.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); +let a = [1, 2, 3, 4,,5]; +assert.sameValue(a.at(0), 1, 'a.at(0) must return 1'); +assert.sameValue(a.at(1), 2, 'a.at(1) must return 2'); +assert.sameValue(a.at(2), 3, 'a.at(2) must return 3'); +assert.sameValue(a.at(3), 4, 'a.at(3) must return 4'); +assert.sameValue(a.at(4), undefined, 'a.at(4) returns undefined'); +assert.sameValue(a.at(5), 5, 'a.at(5) must return 5'); diff --git a/test/sendable/builtins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js b/test/sendable/builtins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js new file mode 100644 index 00000000000..7459c9523fe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.at +description: > + Returns the item value at the specified index, respecting holes in sparse arrays. +info: | + Array.prototype.at ( ) + Let O be ? ToObject(this value). + Let len be ? LengthOfArrayLike(O). + Let relativeIndex be ? ToInteger(index). + If relativeIndex ≥ 0, then + Let k be relativeIndex. + Else, + Let k be len + relativeIndex. + If k < 0 or k ≥ len, then return undefined. + Return ? Get(O, ! ToString(k)). +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof sendableArray.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); +let a = [0, 1, , 3, 4, , 6]; +assert.sameValue(a.at(0), 0, 'a.at(0) must return 0'); +assert.sameValue(a.at(1), 1, 'a.at(1) must return 1'); +assert.sameValue(a.at(2), undefined, 'a.at(2) returns undefined'); +assert.sameValue(a.at(3), 3, 'a.at(3) must return 3'); +assert.sameValue(a.at(4), 4, 'a.at(4) must return 4'); +assert.sameValue(a.at(5), undefined, 'a.at(5) returns undefined'); +assert.sameValue(a.at(6), 6, 'a.at(6) must return 6'); +assert.sameValue(a.at(-0), 0, 'a.at(-0) must return 0'); +assert.sameValue(a.at(-1), 6, 'a.at(-1) must return 6'); +assert.sameValue(a.at(-2), undefined, 'a.at(-2) returns undefined'); +assert.sameValue(a.at(-3), 4, 'a.at(-3) must return 4'); +assert.sameValue(a.at(-4), 3, 'a.at(-4) must return 3'); +assert.sameValue(a.at(-5), undefined, 'a.at(-5) returns undefined'); +assert.sameValue(a.at(-6), 1, 'a.at(-6) must return 1'); diff --git a/test/sendable/builtins/Array/prototype/at/returns-undefined-for-out-of-range-index.js b/test/sendable/builtins/Array/prototype/at/returns-undefined-for-out-of-range-index.js new file mode 100644 index 00000000000..7f295d280de --- /dev/null +++ b/test/sendable/builtins/Array/prototype/at/returns-undefined-for-out-of-range-index.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.at +description: > + Returns undefined if the specified index less than or greater than the available index range. +info: | + Array.prototype.at( index ) + If k < 0 or k ≥ len, then return undefined. +features: [Array.prototype.at] +---*/ +assert.sameValue( + typeof sendableArray.prototype.at, + 'function', + 'The value of `typeof Array.prototype.at` is expected to be "function"' +); +let a = []; +assert.sameValue(a.at(-2), undefined, 'a.at(-2) returns undefined'); // wrap around the end +assert.sameValue(a.at(0), undefined, 'a.at(0) returns undefined'); +assert.sameValue(a.at(1), undefined, 'a.at(1) returns undefined'); + diff --git a/test/sendable/builtins/Array/prototype/at/typed-array-resizable-buffer.js b/test/sendable/builtins/Array/prototype/at/typed-array-resizable-buffer.js new file mode 100644 index 00000000000..0321205aa81 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/at/typed-array-resizable-buffer.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.at +description: > + Array.p.at behaves correctly on TypedArrays backed by resizable buffers +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function ArrayAtHelper(ta, index) { + const result = sendableArray.prototype.at.call(ta, index); + return Convert(result); +}for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + let ta_write = new ctor(rab); + for (let i = 0; i < 4; ++i) { + ta_write[i] = MayNeedBigInt(ta_write, i); + } + assert.sameValue(ArrayAtHelper(fixedLength, -1), 3); + assert.sameValue(ArrayAtHelper(lengthTracking, -1), 3); + assert.sameValue(ArrayAtHelper(fixedLengthWithOffset, -1), 3); + assert.sameValue(ArrayAtHelper(lengthTrackingWithOffset, -1), 3); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + assert.sameValue(ArrayAtHelper(fixedLength, -1), undefined); + assert.sameValue(ArrayAtHelper(fixedLengthWithOffset, -1), undefined); + assert.sameValue(ArrayAtHelper(lengthTracking, -1), 2); + assert.sameValue(ArrayAtHelper(lengthTrackingWithOffset, -1), 2); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.sameValue(ArrayAtHelper(fixedLength, -1), undefined); + assert.sameValue(ArrayAtHelper(fixedLengthWithOffset, -1), undefined); + assert.sameValue(ArrayAtHelper(lengthTrackingWithOffset, -1), undefined); + assert.sameValue(ArrayAtHelper(lengthTracking, -1), 0); + // Grow so that all TAs are back in-bounds. New memory is zeroed. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + assert.sameValue(ArrayAtHelper(fixedLength, -1), 0); + assert.sameValue(ArrayAtHelper(lengthTracking, -1), 0); + assert.sameValue(ArrayAtHelper(fixedLengthWithOffset, -1), 0); + assert.sameValue(ArrayAtHelper(lengthTrackingWithOffset, -1), 0); +} -- Gitee From 1348377de0c712c7cbd0ebe370d84a0f7717bbf0 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 18 Dec 2024 10:52:46 +0800 Subject: [PATCH 14/93] modify sendable/builtins/Array/prototype/at/coerced-index-resize Signed-off-by: zhuzhihui7 --- .../builtins/Array/prototype/at/coerced-index-resize.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js b/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js index 1191115aa3a..5d9beb79f3b 100644 --- a/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js +++ b/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js @@ -22,7 +22,7 @@ features: [resizable-arraybuffer] ---*/ function SendableArrayAtHelper(ta, index) { - return SendableArray.prototype.at.call(ta, index); + return SendableArray.at.call(ta, index); } for (let ctor of ctors) { const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); -- Gitee From e1d0ee3e4dbde07be15449d60a62b3af854838ab Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 18 Dec 2024 11:05:10 +0800 Subject: [PATCH 15/93] add test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js Signed-off-by: zhuzhihui7 --- .../builtins/Array/prototype/at/index-argument-tointeger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js b/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js index d966d02bef8..2f9ffb8b349 100644 --- a/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js +++ b/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js @@ -22,7 +22,7 @@ info: | features: [Array.prototype.at] ---*/ assert.sameValue( - typeof sendableArray.prototype.at, + typeof sendableArray.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); -- Gitee From 51900f4a043530a555987fadf4560151c1f991f8 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 18 Dec 2024 11:16:47 +0800 Subject: [PATCH 16/93] update prototype/at cases Signed-off-by: zhuzhihui7 --- .../Array/prototype/at/index-argument-tointeger.js | 2 +- .../at/index-non-numeric-argument-tointeger-invalid.js | 2 +- .../at/index-non-numeric-argument-tointeger.js | 2 +- test/sendable/builtins/Array/prototype/at/length.js | 4 ++-- test/sendable/builtins/Array/prototype/at/name.js | 6 +++--- test/sendable/builtins/Array/prototype/at/prop-desc.js | 6 +++--- .../Array/prototype/at/return-abrupt-from-this.js | 10 +++++----- .../Array/prototype/at/returns-item-relative-index.js | 2 +- .../builtins/Array/prototype/at/returns-item.js | 2 +- .../at/returns-undefined-for-holes-in-sparse-arrays.js | 2 +- .../at/returns-undefined-for-out-of-range-index.js | 2 +- .../Array/prototype/at/typed-array-resizable-buffer.js | 2 +- 12 files changed, 21 insertions(+), 21 deletions(-) diff --git a/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js b/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js index 2f9ffb8b349..6d4d41a3035 100644 --- a/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js +++ b/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js @@ -22,7 +22,7 @@ info: | features: [Array.prototype.at] ---*/ assert.sameValue( - typeof sendableArray.at, + typeof SendableArray.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); diff --git a/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js b/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js index c7fcccf6d51..87e0b9db304 100644 --- a/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js +++ b/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js @@ -22,7 +22,7 @@ info: | features: [Array.prototype.at] ---*/ assert.sameValue( - typeof sendableArray.prototype.at, + typeof SendableArray.prototype.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); diff --git a/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger.js b/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger.js index 1b3332508bb..0511767ccdf 100644 --- a/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger.js +++ b/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger.js @@ -22,7 +22,7 @@ info: | features: [Array.prototype.at] ---*/ assert.sameValue( - typeof sendableArray.prototype.at, + typeof SendableArray.prototype.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); diff --git a/test/sendable/builtins/Array/prototype/at/length.js b/test/sendable/builtins/Array/prototype/at/length.js index 5c96c5677a6..7f5bb702b84 100644 --- a/test/sendable/builtins/Array/prototype/at/length.js +++ b/test/sendable/builtins/Array/prototype/at/length.js @@ -23,11 +23,11 @@ includes: [propertyHelper.js] features: [Array.prototype.at] ---*/ assert.sameValue( - typeof sendableArray.prototype.at, + typeof SendableArray.prototype.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); -verifyProperty(sendableArray.prototype.at, "length", { +verifyProperty(SendableArray.prototype.at, "length", { value: 1, writable: false, enumerable: false, diff --git a/test/sendable/builtins/Array/prototype/at/name.js b/test/sendable/builtins/Array/prototype/at/name.js index 87973d657fb..f771119fab0 100644 --- a/test/sendable/builtins/Array/prototype/at/name.js +++ b/test/sendable/builtins/Array/prototype/at/name.js @@ -23,15 +23,15 @@ includes: [propertyHelper.js] features: [Array.prototype.at] ---*/ assert.sameValue( - typeof sendableArray.prototype.at, + typeof SendableArray.prototype.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); assert.sameValue( - sendableArray.prototype.at.name, 'at', + SendableArray.prototype.at.name, 'at', 'The value of Array.prototype.at.name is expected to be "at"' ); -verifyProperty(sendableArray.prototype.at, 'name', { +verifyProperty(SendableArray.prototype.at, 'name', { enumerable: false, writable: false, configurable: true diff --git a/test/sendable/builtins/Array/prototype/at/prop-desc.js b/test/sendable/builtins/Array/prototype/at/prop-desc.js index d7ba95456b2..4738e006586 100644 --- a/test/sendable/builtins/Array/prototype/at/prop-desc.js +++ b/test/sendable/builtins/Array/prototype/at/prop-desc.js @@ -23,16 +23,16 @@ includes: [propertyHelper.js] features: [Array.prototype.at] ---*/ assert.sameValue( - typeof sendableArray.prototype.at, + typeof SendableArray.prototype.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); assert.sameValue( - typeof sendableArray.prototype.at, + typeof SendableArray.prototype.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); -verifyProperty(sendableArray.prototype, 'at', { +verifyProperty(SendableArray.prototype, 'at', { enumerable: false, writable: true, configurable: true diff --git a/test/sendable/builtins/Array/prototype/at/return-abrupt-from-this.js b/test/sendable/builtins/Array/prototype/at/return-abrupt-from-this.js index e1947b0486d..ac927e51c59 100644 --- a/test/sendable/builtins/Array/prototype/at/return-abrupt-from-this.js +++ b/test/sendable/builtins/Array/prototype/at/return-abrupt-from-this.js @@ -22,13 +22,13 @@ info: | features: [Array.prototype.at] ---*/ assert.sameValue( - typeof sendableArray.prototype.at, + typeof SendableArray.prototype.at, 'function', - 'The value of `typeof sendableArray.prototype.at` is expected to be "function"' + 'The value of `typeof SendableArray.prototype.at` is expected to be "function"' ); assert.throws(TypeError, () => { - sendableArray.prototype.at.call(undefined); + SendableArray.prototype.at.call(undefined); }, 'sendableArray.prototype.at.call(undefined) throws a TypeError exception'); assert.throws(TypeError, () => { - sendableArray.prototype.at.call(null); -}, 'sendableArray.prototype.at.call(null) throws a TypeError exception'); + SendableArray.prototype.at.call(null); +}, 'SendableArray.prototype.at.call(null) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/at/returns-item-relative-index.js b/test/sendable/builtins/Array/prototype/at/returns-item-relative-index.js index d40ebe5b888..c45fd47d6e6 100644 --- a/test/sendable/builtins/Array/prototype/at/returns-item-relative-index.js +++ b/test/sendable/builtins/Array/prototype/at/returns-item-relative-index.js @@ -30,7 +30,7 @@ info: | features: [Array.prototype.at] ---*/ assert.sameValue( - typeof sendableArray.prototype.at, + typeof SendableArray.prototype.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); diff --git a/test/sendable/builtins/Array/prototype/at/returns-item.js b/test/sendable/builtins/Array/prototype/at/returns-item.js index 8828a3f760e..374ba1422a1 100644 --- a/test/sendable/builtins/Array/prototype/at/returns-item.js +++ b/test/sendable/builtins/Array/prototype/at/returns-item.js @@ -30,7 +30,7 @@ info: | features: [Array.prototype.at] ---*/ assert.sameValue( - typeof sendableArray.prototype.at, + typeof SendableArray.prototype.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); diff --git a/test/sendable/builtins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js b/test/sendable/builtins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js index 7459c9523fe..f46de3ab4d1 100644 --- a/test/sendable/builtins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js +++ b/test/sendable/builtins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js @@ -30,7 +30,7 @@ info: | features: [Array.prototype.at] ---*/ assert.sameValue( - typeof sendableArray.prototype.at, + typeof SendableArray.prototype.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); diff --git a/test/sendable/builtins/Array/prototype/at/returns-undefined-for-out-of-range-index.js b/test/sendable/builtins/Array/prototype/at/returns-undefined-for-out-of-range-index.js index 7f295d280de..0880883df9c 100644 --- a/test/sendable/builtins/Array/prototype/at/returns-undefined-for-out-of-range-index.js +++ b/test/sendable/builtins/Array/prototype/at/returns-undefined-for-out-of-range-index.js @@ -22,7 +22,7 @@ info: | features: [Array.prototype.at] ---*/ assert.sameValue( - typeof sendableArray.prototype.at, + typeof SendableArray.prototype.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); diff --git a/test/sendable/builtins/Array/prototype/at/typed-array-resizable-buffer.js b/test/sendable/builtins/Array/prototype/at/typed-array-resizable-buffer.js index 0321205aa81..2b7ce642131 100644 --- a/test/sendable/builtins/Array/prototype/at/typed-array-resizable-buffer.js +++ b/test/sendable/builtins/Array/prototype/at/typed-array-resizable-buffer.js @@ -21,7 +21,7 @@ features: [resizable-arraybuffer] ---*/ function ArrayAtHelper(ta, index) { - const result = sendableArray.prototype.at.call(ta, index); + const result = SendableArray.prototype.at.call(ta, index); return Convert(result); }for (let ctor of ctors) { const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); -- Gitee From e3928889bc529ac8e7bf0cfa89b35b61f4e667e0 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 18 Dec 2024 11:25:48 +0800 Subject: [PATCH 17/93] update case Signed-off-by: zhuzhihui7 --- .../builtins/Array/prototype/at/coerced-index-resize.js | 2 +- .../builtins/Array/prototype/at/index-argument-tointeger.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js b/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js index 5d9beb79f3b..1191115aa3a 100644 --- a/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js +++ b/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js @@ -22,7 +22,7 @@ features: [resizable-arraybuffer] ---*/ function SendableArrayAtHelper(ta, index) { - return SendableArray.at.call(ta, index); + return SendableArray.prototype.at.call(ta, index); } for (let ctor of ctors) { const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); diff --git a/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js b/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js index 6d4d41a3035..82f25364d49 100644 --- a/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js +++ b/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js @@ -22,7 +22,7 @@ info: | features: [Array.prototype.at] ---*/ assert.sameValue( - typeof SendableArray.at, + typeof typeof Array.prototype.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); -- Gitee From f214abf45335bf54f19c3c050c5f2bb5790d899c Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 18 Dec 2024 11:30:54 +0800 Subject: [PATCH 18/93] add cas Signed-off-by: zhuzhihui7 --- .../builtins/Array/prototype/at/index-argument-tointeger.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js b/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js index 82f25364d49..5ff59403225 100644 --- a/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js +++ b/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js @@ -22,7 +22,7 @@ info: | features: [Array.prototype.at] ---*/ assert.sameValue( - typeof typeof Array.prototype.at, + typeof Array.prototype.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); -- Gitee From 6364360c8d03c600d6d5fc6a33d77ea0c209a9c9 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 18 Dec 2024 13:42:42 +0800 Subject: [PATCH 19/93] modify case Signed-off-by: zhuzhihui7 --- .../builtins/Array/prototype/at/coerced-index-resize.js | 6 +++--- .../builtins/Array/prototype/at/index-argument-tointeger.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js b/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js index 1191115aa3a..6cac062fe6f 100644 --- a/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js +++ b/test/sendable/builtins/Array/prototype/at/coerced-index-resize.js @@ -21,7 +21,7 @@ includes: [resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -function SendableArrayAtHelper(ta, index) { +function ArrayAtHelper(ta, index) { return SendableArray.prototype.at.call(ta, index); } for (let ctor of ctors) { @@ -33,7 +33,7 @@ for (let ctor of ctors) { return 0; } }; - assert.sameValue(SendableArrayAtHelper(fixedLength, evil), undefined); + assert.sameValue(ArrayAtHelper(fixedLength, evil), undefined); } for (let ctor of ctors) { const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); @@ -45,5 +45,5 @@ for (let ctor of ctors) { } }; // The TypedArray is *not* out of bounds since it's length-tracking. - assert.sameValue(SendableArrayAtHelper(lengthTracking, evil), undefined); + assert.sameValue(ArrayAtHelper(lengthTracking, evil), undefined); } diff --git a/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js b/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js index 5ff59403225..089ca96c7f0 100644 --- a/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js +++ b/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js @@ -22,7 +22,7 @@ info: | features: [Array.prototype.at] ---*/ assert.sameValue( - typeof Array.prototype.at, + typeof SendableArray.prototype.at, 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); -- Gitee From 2c39e4b3cf846bbe3d4555642dafe0a45dcebd08 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 18 Dec 2024 14:24:16 +0800 Subject: [PATCH 20/93] add concat cases Signed-off-by: zhuzhihui7 --- .../concat/15.4.4.4-5-b-iii-3-b-1.js | 35 ++++++++++ .../prototype/concat/15.4.4.4-5-c-i-1.js | 37 ++++++++++ .../Array/prototype/concat/S15.4.4.4_A1_T1.js | 35 ++++++++++ .../Array/prototype/concat/S15.4.4.4_A1_T2.js | 38 ++++++++++ .../Array/prototype/concat/S15.4.4.4_A1_T3.js | 32 +++++++++ .../Array/prototype/concat/S15.4.4.4_A1_T4.js | 32 +++++++++ .../Array/prototype/concat/S15.4.4.4_A2_T1.js | 38 ++++++++++ .../Array/prototype/concat/S15.4.4.4_A2_T2.js | 31 ++++++++ .../Array/prototype/concat/S15.4.4.4_A3_T1.js | 41 +++++++++++ .../Array/prototype/concat/S15.4.4.4_A3_T2.js | 39 +++++++++++ .../Array/prototype/concat/S15.4.4.4_A3_T3.js | 40 +++++++++++ .../arg-length-exceeding-integer-limit.js | 48 +++++++++++++ .../concat/arg-length-near-integer-limit.js | 47 +++++++++++++ .../prototype/concat/call-with-boolean.js | 29 ++++++++ ...ncat_array-like-length-to-string-throws.js | 34 +++++++++ ...oncat_array-like-length-value-of-throws.js | 34 +++++++++ .../concat_array-like-negative-length.js | 32 +++++++++ ..._array-like-primitive-non-number-length.js | 40 +++++++++++ .../concat/concat_array-like-string-length.js | 41 +++++++++++ .../concat_array-like-to-length-throws.js | 39 +++++++++++ .../prototype/concat/concat_array-like.js | 41 +++++++++++ .../concat/concat_holey-sloppy-arguments.js | 28 ++++++++ .../concat/concat_large-typed-array.js | 55 +++++++++++++++ .../prototype/concat/concat_length-throws.js | 33 +++++++++ .../prototype/concat/concat_no-prototype.js | 23 ++++++ .../prototype/concat/concat_non-array.js | 37 ++++++++++ .../concat/concat_sloppy-arguments-throws.js | 31 ++++++++ .../concat_sloppy-arguments-with-dupes.js | 34 +++++++++ .../concat/concat_sloppy-arguments.js | 33 +++++++++ .../concat/concat_small-typed-array.js | 60 ++++++++++++++++ .../concat_spreadable-boolean-wrapper.js | 49 +++++++++++++ .../concat/concat_spreadable-function.js | 42 +++++++++++ .../concat/concat_spreadable-getter-throws.js | 32 +++++++++ .../concat_spreadable-number-wrapper.js | 47 +++++++++++++ .../concat/concat_spreadable-reg-exp.js | 44 ++++++++++++ .../concat/concat_spreadable-sparse-object.js | 31 ++++++++ .../concat_spreadable-string-wrapper.js | 38 ++++++++++ .../concat/concat_strict-arguments.js | 34 +++++++++ .../concat/create-ctor-non-object.js | 49 +++++++++++++ .../prototype/concat/create-ctor-poisoned.js | 34 +++++++++ .../prototype/concat/create-non-array.js | 46 ++++++++++++ .../create-proto-from-ctor-realm-array.js | 53 ++++++++++++++ .../create-proto-from-ctor-realm-non-array.js | 54 ++++++++++++++ .../Array/prototype/concat/create-proxy.js | 48 +++++++++++++ .../prototype/concat/create-revoked-proxy.js | 43 ++++++++++++ .../prototype/concat/create-species-abrupt.js | 41 +++++++++++ .../concat/create-species-non-ctor.js | 42 +++++++++++ ...reate-species-non-extensible-spreadable.js | 42 +++++++++++ .../concat/create-species-non-extensible.js | 42 +++++++++++ .../prototype/concat/create-species-null.js | 43 ++++++++++++ .../concat/create-species-poisoned.js | 37 ++++++++++ .../prototype/concat/create-species-undef.js | 41 +++++++++++ ...th-non-configurable-property-spreadable.js | 44 ++++++++++++ ...-species-with-non-configurable-property.js | 43 ++++++++++++ ...s-with-non-writable-property-spreadable.js | 48 +++++++++++++ ...eate-species-with-non-writable-property.js | 48 +++++++++++++ .../Array/prototype/concat/create-species.js | 51 ++++++++++++++ .../concat/is-concat-spreadable-get-err.js | 46 ++++++++++++ .../concat/is-concat-spreadable-get-order.js | 70 +++++++++++++++++++ ...oncat-spreadable-is-array-proxy-revoked.js | 53 ++++++++++++++ .../is-concat-spreadable-proxy-revoked.js | 42 +++++++++++ .../concat/is-concat-spreadable-proxy.js | 54 ++++++++++++++ .../concat/is-concat-spreadable-val-falsey.js | 59 ++++++++++++++++ .../concat/is-concat-spreadable-val-truthy.js | 57 +++++++++++++++ .../is-concat-spreadable-val-undefined.js | 47 +++++++++++++ .../builtins/Array/prototype/concat/length.js | 40 +++++++++++ .../builtins/Array/prototype/concat/name.js | 36 ++++++++++ .../prototype/concat/not-a-constructor.js | 38 ++++++++++ .../Array/prototype/concat/prop-desc.js | 32 +++++++++ 69 files changed, 2857 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/concat/15.4.4.4-5-b-iii-3-b-1.js create mode 100644 test/sendable/builtins/Array/prototype/concat/15.4.4.4-5-c-i-1.js create mode 100644 test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js create mode 100644 test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T3.js create mode 100644 test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T4.js create mode 100644 test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T1.js create mode 100644 test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T2.js create mode 100644 test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T3.js create mode 100644 test/sendable/builtins/Array/prototype/concat/arg-length-exceeding-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/concat/arg-length-near-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/concat/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_array-like-length-to-string-throws.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_array-like-length-value-of-throws.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_array-like-negative-length.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_array-like-primitive-non-number-length.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_array-like-string-length.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_array-like-to-length-throws.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_array-like.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_holey-sloppy-arguments.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_large-typed-array.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_length-throws.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_no-prototype.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_non-array.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-throws.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-with-dupes.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_small-typed-array.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_spreadable-boolean-wrapper.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_spreadable-function.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_spreadable-getter-throws.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_spreadable-number-wrapper.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_spreadable-reg-exp.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_spreadable-sparse-object.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_spreadable-string-wrapper.js create mode 100644 test/sendable/builtins/Array/prototype/concat/concat_strict-arguments.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-ctor-non-object.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-ctor-poisoned.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-non-array.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-array.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-proxy.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-revoked-proxy.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-species-abrupt.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-species-non-ctor.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-species-non-extensible-spreadable.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-species-non-extensible.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-species-null.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-species-poisoned.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-species-undef.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property.js create mode 100644 test/sendable/builtins/Array/prototype/concat/create-species.js create mode 100644 test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-err.js create mode 100644 test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-order.js create mode 100644 test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js create mode 100644 test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js create mode 100644 test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy.js create mode 100644 test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-falsey.js create mode 100644 test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-truthy.js create mode 100644 test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-undefined.js create mode 100644 test/sendable/builtins/Array/prototype/concat/length.js create mode 100644 test/sendable/builtins/Array/prototype/concat/name.js create mode 100644 test/sendable/builtins/Array/prototype/concat/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/concat/prop-desc.js diff --git a/test/sendable/builtins/Array/prototype/concat/15.4.4.4-5-b-iii-3-b-1.js b/test/sendable/builtins/Array/prototype/concat/15.4.4.4-5-b-iii-3-b-1.js new file mode 100644 index 00000000000..c923d4ba6c9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/15.4.4.4-5-b-iii-3-b-1.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-SendableArray.prototype.concat +description: > + SendableArray.prototype.concat will concat an Array when index property + (read-only) exists in SendableArray.prototype (Step 5.b.iii.3.b) +includes: [propertyHelper.js] +---*/ + +Object.defineProperty(SendableArray.prototype, "0", { + value: 100, + writable: false, + configurable: true +}); +var oldArr = [101]; +var newArr = SendableArray.prototype.concat.call(oldArr); +verifyProperty(newArr, "0", { + value: 101, + writable: true, + enumerable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/concat/15.4.4.4-5-c-i-1.js b/test/sendable/builtins/Array/prototype/concat/15.4.4.4-5-c-i-1.js new file mode 100644 index 00000000000..eeb0f8e474b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/15.4.4.4-5-c-i-1.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + Array.prototype.concat will concat an Array when index property + (read-only) exists in Array.prototype (Step 5.c.i) +includes: [propertyHelper.js] +---*/ + +Object.defineProperty(SendableArray.prototype, "0", { + value: 100, + writable: false, + configurable: true +}); +var newArrayFromConcat = SendableArray.prototype.concat.call(101); +assert( + newArrayFromConcat[0] instanceof Number, + 'The result of evaluating (newArrayFromConcat[0] instanceof Number) is expected to be true' +); +verifyProperty(newArrayFromConcat, "0", { + writable: true, + enumerable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T1.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T1.js new file mode 100644 index 00000000000..62be6677a4d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T1.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +info: | + When the concat method is called with zero or more arguments item1, item2, + etc., it returns an array containing the array elements of the object followed by + the array elements of each argument in order +es5id: 15.4.4.4_A1_T1 +description: Checking this algorithm, items are Array object +---*/ +var x = new SendableArray(); +var y = new SendableArray(0, 1); +var z = new SendableArray(2, 3, 4); +var arr = x.concat(y, z); +arr.getClass = Object.prototype.toString; +assert.sameValue(arr.getClass(), "[object SendableArray]", 'arr.getClass() must return "[object SendableArray]"'); +assert.sameValue(arr[0], 0, 'The value of arr[0] is expected to be 0'); +assert.sameValue(arr[1], 1, 'The value of arr[1] is expected to be 1'); +assert.sameValue(arr[2], 2, 'The value of arr[2] is expected to be 2'); +assert.sameValue(arr[3], 3, 'The value of arr[3] is expected to be 3'); +assert.sameValue(arr[4], 4, 'The value of arr[4] is expected to be 4'); +assert.sameValue(arr.length, 5, 'The value of arr.length is expected to be 5'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js new file mode 100644 index 00000000000..047e023a96f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +info: | + When the concat method is called with zero or more arguments item1, item2, + etc., it returns an array containing the array elements of the object followed by + the array elements of each argument in order +es5id: 15.4.4.4_A1_T2 +description: Checking this algorithm, items are objects and primitives +---*/ + +var x = [0]; +var y = new Object(); +var z = new SendableArray(1, 2); +var arr = x.concat(y, z, -1, true, "NaN"); +arr.getClass = Object.prototype.toString; +assert.sameValue(arr.getClass(), "[object SendableArray]", 'arr.getClass() must return "[object SendableArray]"'); +assert.sameValue(arr[0], 0, 'The value of arr[0] is expected to be 0'); +assert.sameValue(arr[1], y, 'The value of arr[1] is expected to equal the value of y'); +assert.sameValue(arr[2], 1, 'The value of arr[2] is expected to be 1'); +assert.sameValue(arr[3], 2, 'The value of arr[3] is expected to be 2'); +assert.sameValue(arr[4], -1, 'The value of arr[4] is expected to be -1'); +assert.sameValue(arr[5], true, 'The value of arr[5] is expected to be true'); +assert.sameValue(arr[6], "NaN", 'The value of arr[6] is expected to be "NaN"'); +assert.sameValue(arr.length, 7, 'The value of arr.length is expected to be 7'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T3.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T3.js new file mode 100644 index 00000000000..d879bb2e20a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T3.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +info: | + When the concat method is called with zero or more arguments item1, item2, + etc., it returns an array containing the array elements of the object followed by + the array elements of each argument in order +es5id: 15.4.4.4_A1_T3 +description: Checking this algorithm with no items +---*/ + +var x = [0, 1]; +var arr = x.concat(); +arr.getClass = Object.prototype.toString; +assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); +assert.sameValue(arr[0], 0, 'The value of arr[0] is expected to be 0'); +assert.sameValue(arr[1], 1, 'The value of arr[1] is expected to be 1'); +assert.sameValue(arr.length, 2, 'The value of arr.length is expected to be 2'); +assert.notSameValue(arr, x, 'The value of arr is expected to not equal the value of `x`'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T4.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T4.js new file mode 100644 index 00000000000..2c5ceed5543 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T4.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +info: | + When the concat method is called with zero or more arguments item1, item2, + etc., it returns an array containing the array elements of the object followed by + the array elements of each argument in order +es5id: 15.4.4.4_A1_T4 +description: Checking this algorithm, items are [], [,] +---*/ + +var x = [, 1]; +var arr = x.concat([], [, ]); +arr.getClass = Object.prototype.toString; +assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); +assert.sameValue(arr[0], undefined, 'The value of arr[0] is expected to equal undefined'); +assert.sameValue(arr[1], 1, 'The value of arr[1] is expected to be 1'); +assert.sameValue(arr[2], undefined, 'The value of arr[2] is expected to equal undefined'); +assert.sameValue(arr.length, 3, 'The value of arr.length is expected to be 3'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T1.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T1.js new file mode 100644 index 00000000000..5671f7ccefa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T1.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +info: | + The concat function is intentionally generic. + It does not require that its this value be an Array object +es5id: 15.4.4.4_A2_T1 +description: Checking this for Object object, items are objects and primitives +---*/ + +var x = {}; +x.concat = SendableArray.prototype.concat; +var y = new Object(); +var z = new SendableArray(1, 2); +var arr = x.concat(y, z, -1, true, "NaN"); +arr.getClass = Object.prototype.toString; +assert.sameValue(arr.getClass(), "[object SendableArray]", 'arr.getClass() must return "[object SendableArray]"'); +assert.sameValue(arr[0], x, 'The value of arr[0] is expected to equal the value of x'); +assert.sameValue(arr[1], y, 'The value of arr[1] is expected to equal the value of y'); +assert.sameValue(arr[2], 1, 'The value of arr[2] is expected to be 1'); +assert.sameValue(arr[3], 2, 'The value of arr[3] is expected to be 2'); +assert.sameValue(arr[4], -1, 'The value of arr[4] is expected to be -1'); +assert.sameValue(arr[5], true, 'The value of arr[5] is expected to be true'); +assert.sameValue(arr[6], "NaN", 'The value of arr[6] is expected to be "NaN"'); +assert.sameValue(arr.length, 7, 'The value of arr.length is expected to be 7'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T2.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T2.js new file mode 100644 index 00000000000..2eb8ada9fde --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T2.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.concat +info: | + The concat function is intentionally generic. + It does not require that its this value be an Array object +es5id: 15.4.4.4_A2_T2 +description: Checking this for Object object with no items +---*/ + +var x = {}; +x.concat = SendableArray.prototype.concat; +var arr = x.concat(); +arr.getClass = Object.prototype.toString; +assert.sameValue(arr.getClass(), "[object SendableArray]", 'arr.getClass() must return "[object SendableArray]"'); +assert.sameValue(arr[0], x, 'The value of arr[0] is expected to equal the value of x'); +assert.sameValue(arr.length, 1, 'The value of arr.length is expected to be 1'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T1.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T1.js new file mode 100644 index 00000000000..dc5ce76240c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T1.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.concat +info: "[[Get]] from not an inherited property" +es5id: 15.4.4.4_A3_T1 +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +SendableArray.prototype[1] = 1; +var x = [0]; +x.length = 2; +var arr = x.concat(); +assert.sameValue(arr[0], 0, 'The value of arr[0] is expected to be 0'); +assert.sameValue(arr[1], 1, 'The value of arr[1] is expected to be 1'); +assert.sameValue(arr.hasOwnProperty('1'), true, 'arr.hasOwnProperty("1") must return true'); +Object.prototype[1] = 1; +Object.prototype.length = 2; +Object.prototype.concat = SendableArray.prototype.concat; +x = { + 0: 0 +}; +var arr = x.concat(); +assert.sameValue(arr[0], x, 'The value of arr[0] is expected to equal the value of x'); +assert.sameValue(arr[1], 1, 'The value of arr[1] is expected to be 1'); +assert.sameValue(arr.hasOwnProperty('1'), false, 'arr.hasOwnProperty("1") must return false'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T2.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T2.js new file mode 100644 index 00000000000..5edc3e6d66f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T2.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +info: Array.prototype.concat uses [[Get]] on 'length' to determine array length +es5id: 15.4.4.4_A3_T2 +description: > + checking whether non-ownProperties are seen, copied by Array.prototype.concat: Array.prototype[1] +---*/ + +var a = [0]; +assert.sameValue(a.length, 1, 'The value of a.length is expected to be 1'); +a.length = 3; +assert.sameValue(a[1], undefined, 'The value of a[1] is expected to equal undefined'); +assert.sameValue(a[2], undefined, 'The value of a[2] is expected to equal undefined'); +SendableArray.prototype[2] = 2; +assert.sameValue(a[1], undefined, 'The value of a[1] is expected to equal undefined'); +assert.sameValue(a[2], 2, 'The value of a[2] is expected to be 2'); +assert.sameValue(a.hasOwnProperty('1'), false, 'a.hasOwnProperty("1") must return false'); +assert.sameValue(a.hasOwnProperty('2'), false, 'a.hasOwnProperty("2") must return false'); +var b = a.concat(); +assert.sameValue(b.length, 3, 'The value of b.length is expected to be 3'); +assert.sameValue(b[0], 0, 'The value of b[0] is expected to be 0'); +assert.sameValue(b[1], undefined, 'The value of b[1] is expected to equal undefined'); +assert.sameValue(b[2], 2, 'The value of b[2] is expected to be 2'); +assert.sameValue(b.hasOwnProperty('1'), false, 'b.hasOwnProperty("1") must return false'); +assert.sameValue(b.hasOwnProperty('2'), true, 'b.hasOwnProperty("2") must return true'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T3.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T3.js new file mode 100644 index 00000000000..faca42ffbd0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T3.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.concat +info: Array.prototype.concat uses [[Get]] on 'length' to determine array length +es5id: 15.4.4.4_A3_T3 +description: > + checking whether non-ownProperties are seen, copied by Array.prototype.concat: Object.prototype[1] +---*/ + +var a = [0]; +assert.sameValue(a.length, 1, 'The value of a.length is expected to be 1'); +a.length = 3; +assert.sameValue(a[1], undefined, 'The value of a[1] is expected to equal undefined'); +assert.sameValue(a[2], undefined, 'The value of a[2] is expected to equal undefined'); +Object.prototype[2] = 2; +assert.sameValue(a[1], undefined, 'The value of a[1] is expected to equal undefined'); +assert.sameValue(a[2], 2, 'The value of a[2] is expected to be 2'); +assert.sameValue(a.hasOwnProperty('1'), false, 'a.hasOwnProperty("1") must return false'); +assert.sameValue(a.hasOwnProperty('2'), false, 'a.hasOwnProperty("2") must return false'); +var b = a.concat(); +assert.sameValue(b.length, 3, 'The value of b.length is expected to be 3'); +assert.sameValue(b[0], 0, 'The value of b[0] is expected to be 0'); +assert.sameValue(b[1], undefined, 'The value of b[1] is expected to equal undefined'); +assert.sameValue(b[2], 2, 'The value of b[2] is expected to be 2'); +assert.sameValue(b.hasOwnProperty('1'), false, 'b.hasOwnProperty("1") must return false'); +assert.sameValue(b.hasOwnProperty('2'), true, 'b.hasOwnProperty("2") must return true'); diff --git a/test/sendable/builtins/Array/prototype/concat/arg-length-exceeding-integer-limit.js b/test/sendable/builtins/Array/prototype/concat/arg-length-exceeding-integer-limit.js new file mode 100644 index 00000000000..e98d363be71 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/arg-length-exceeding-integer-limit.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + TypeError is thrown if "length" of result array exceeds 2^53 - 1. +info: | + Array.prototype.concat ( ...arguments ) + + [...] + 5. Repeat, while items is not empty + [...] + c. If spreadable is true, then + [...] + ii. Let len be ? LengthOfArrayLike(E). + iii. If n + len > 2^53 - 1, throw a TypeError exception. + [...] +features: [Symbol.isConcatSpreadable, Proxy] +---*/ + +var spreadableLengthOutOfRange = {}; +spreadableLengthOutOfRange.length = Number.MAX_SAFE_INTEGER; +spreadableLengthOutOfRange[Symbol.isConcatSpreadable] = true; +assert.throws(TypeError, function() { + [1].concat(spreadableLengthOutOfRange); +}, '[1].concat(spreadableLengthOutOfRange) throws a TypeError exception'); +var proxyForArrayWithLengthOutOfRange = new Proxy([], { + get: function(_target, key) { + if (key === "length") { + return Number.MAX_SAFE_INTEGER; + } + }, +}); +assert.throws(TypeError, function() { + [].concat(1, proxyForArrayWithLengthOutOfRange); +}, '[].concat(1, proxyForArrayWithLengthOutOfRange) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/arg-length-near-integer-limit.js b/test/sendable/builtins/Array/prototype/concat/arg-length-near-integer-limit.js new file mode 100644 index 00000000000..729b3b779ac --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/arg-length-near-integer-limit.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + Elements are copied from a spreadable array-like object + whose "length" property is near the integer limit. +info: | + Array.prototype.concat ( ...arguments ) + + [...] + 5. Repeat, while items is not empty + [...] + c. If spreadable is true, then + [...] + ii. Let len be ? LengthOfArrayLike(E). + iii. If n + len > 2^53 - 1, throw a TypeError exception. + iv. Repeat, while k < len + [...] + 3. If exists is true, then + a. Let subElement be ? Get(E, P). + [...] +features: [Symbol.isConcatSpreadable] +---*/ + +var spreadableHasPoisonedIndex = { + length: Number.MAX_SAFE_INTEGER, + get 0() { + throw new Test262Error(); + }, +}; +spreadableHasPoisonedIndex[Symbol.isConcatSpreadable] = true; +assert.throws(Test262Error, function() { + [].concat(spreadableHasPoisonedIndex); +}, '[].concat(spreadableHasPoisonedIndex) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/call-with-boolean.js b/test/sendable/builtins/Array/prototype/concat/call-with-boolean.js new file mode 100644 index 00000000000..f89534b805a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/call-with-boolean.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat applied to boolean primitive +---*/ + +assert.sameValue( + SendableArray.prototype.concat.call(true)[0] instanceof Boolean, + true, + 'The result of evaluating (SendableArray.prototype.concat.call(true)[0] instanceof Boolean) is expected to be true' +); +assert.sameValue( + SendableArray.prototype.concat.call(false)[0] instanceof Boolean, + true, + 'The result of evaluating (SendableArray.prototype.concat.call(false)[0] instanceof Boolean) is expected to be true' +); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-to-string-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-to-string-throws.js new file mode 100644 index 00000000000..49a8ac137c6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-to-string-throws.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat array like length to string throws +features: [Symbol.isConcatSpreadable] +---*/ +var objWithPoisonedLengthToString = { + "length": { + toString: function() { + throw new Test262Error(); + }, + valueOf: null + }, + "1": "A", + "3": "B", + "5": "C" +}; +objWithPoisonedLengthToString[Symbol.isConcatSpreadable] = true; +assert.throws(Test262Error, function() { + [].concat(objWithPoisonedLengthToString); +}, '[].concat(objWithPoisonedLengthToString) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-value-of-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-value-of-throws.js new file mode 100644 index 00000000000..20d57091195 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-value-of-throws.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat array like length valueOf throws +features: [Symbol.isConcatSpreadable] +---*/ +var objWithPoisonedLengthValueOf = { + "length": { + valueOf: function() { + throw new Test262Error(); + }, + toString: null + }, + "1": "A", + "3": "B", + "5": "C" +}; +objWithPoisonedLengthValueOf[Symbol.isConcatSpreadable] = true; +assert.throws(Test262Error, function() { + [].concat(objWithPoisonedLengthValueOf); +}, '[].concat(objWithPoisonedLengthValueOf) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-negative-length.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-negative-length.js new file mode 100644 index 00000000000..42cf9fa68e2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-negative-length.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat array like negative length +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var obj = { + "length": -4294967294, + "1": "A", + "3": "B", + "5": "C" +}; +obj[Symbol.isConcatSpreadable] = true; +assert.compareArray([].concat(obj), [], '[].concat({"length": -4294967294, "1": "A", "3": "B", "5": "C"}) must return []'); +obj.length = -4294967294; +assert.compareArray([].concat(obj), [], '[].concat({"length": -4294967294, "1": "A", "3": "B", "5": "C"}) must return []'); +obj.length = "-4294967294"; +assert.compareArray([].concat(obj), [], '[].concat({"length": -4294967294, "1": "A", "3": "B", "5": "C"}) must return []'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-primitive-non-number-length.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-primitive-non-number-length.js new file mode 100644 index 00000000000..96a658d3ae8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-primitive-non-number-length.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat array like primitive non number length +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var obj = { + "1": "A", + "3": "B", + "5": "C" +}; +obj[Symbol.isConcatSpreadable] = true; +obj.length = { + toString: function() { + return "SIX"; + }, + valueOf: null +}; +assert.compareArray([].concat(obj), [], '[].concat({"1": "A", "3": "B", "5": "C"}) must return []'); +obj.length = { + toString: null, + valueOf: function() { + return "SIX"; + } +}; +assert.compareArray([].concat(obj), [], '[].concat({"1": "A", "3": "B", "5": "C"}) must return []'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-string-length.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-string-length.js new file mode 100644 index 00000000000..993ea37d45c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-string-length.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat array like string length +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var obj = { + "length": "6", + "1": "A", + "3": "B", + "5": "C" +}; +obj[Symbol.isConcatSpreadable] = true; +var obj2 = { + length: 3, + "0": "0", + "1": "1", + "2": "2" +}; +var arr = ["X", "Y", "Z"]; +var expected = [ + void 0, "A", void 0, "B", void 0, "C", + obj2, + "X", "Y", "Z" +]; +var actual = SendableArray.prototype.concat.call(obj, obj2, arr); +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-to-length-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-to-length-throws.js new file mode 100644 index 00000000000..9dd87a297db --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-to-length-throws.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat array like to length throws +features: [Symbol.isConcatSpreadable] +---*/ +var spreadableWithBrokenLength = { + "length": { + valueOf: null, + toString: null + }, + "1": "A", + "3": "B", + "5": "C" +}; +spreadableWithBrokenLength[Symbol.isConcatSpreadable] = true; +var obj2 = { + length: 3, + "0": "0", + "1": "1", + "2": "2" +}; +var arr = ["X", "Y", "Z"]; +assert.throws(TypeError, function() { + SendableArray.prototype.concat.call(spreadableWithBrokenLength, obj2, arr); +}, 'SendableArray.prototype.concat.call(spreadableWithBrokenLength, obj2, arr) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like.js new file mode 100644 index 00000000000..4ac8174aceb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat array like +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var obj = { + "length": 6, + "1": "A", + "3": "B", + "5": "C" +}; +obj[Symbol.isConcatSpreadable] = true; +var obj2 = { + length: 3, + "0": "0", + "1": "1", + "2": "2" +}; +var arr = ["X", "Y", "Z"]; +var expected = [ + void 0, "A", void 0, "B", void 0, "C", + obj2, + "X", "Y", "Z" +]; +var actual = SendableArray.prototype.concat.call(obj, obj2, arr); +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_holey-sloppy-arguments.js b/test/sendable/builtins/Array/prototype/concat/concat_holey-sloppy-arguments.js new file mode 100644 index 00000000000..d8066ddcfae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_holey-sloppy-arguments.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat holey sloppy arguments +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var args = (function(a) { + return arguments; +})(1, 2, 3); +delete args[1]; +args[Symbol.isConcatSpreadable] = true; +assert.compareArray([1, void 0, 3, 1, void 0, 3], [].concat(args, args), + '[1, void 0, 3, 1, void 0, 3] must return the same value returned by [].concat(args, args)' +); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_large-typed-array.js b/test/sendable/builtins/Array/prototype/concat/concat_large-typed-array.js new file mode 100644 index 00000000000..d04f0dd7263 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_large-typed-array.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat large typed array +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +function concatTypedArray(type, elems, modulo) { + var items = new SendableArray(elems); + var ta_by_len = new type(elems); + for (var i = 0; i < elems; ++i) { + ta_by_len[i] = items[i] = modulo === false ? i : elems % modulo; + } + var ta = new type(items); + assert.compareArray([].concat(ta, ta), [ta, ta]); + ta[Symbol.isConcatSpreadable] = true; + assert.compareArray([].concat(ta), items); + assert.compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]); + ta_by_len[Symbol.isConcatSpreadable] = true; + assert.compareArray([].concat(ta_by_len), items); + // TypedArray with fake `length`. + ta = new type(1); + var defValue = ta[0]; + var expected = new SendableArray(4000); + expected[0] = defValue; + Object.defineProperty(ta, "length", { + value: 4000 + }); + ta[Symbol.isConcatSpreadable] = true; + assert.compareArray([].concat(ta), expected); +} +// Float16Array cannot be included in this because it cannot precisely represent integers above 2048 +var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false]; +[ + Uint8Array, + Uint16Array, + Uint32Array, + Float32Array, + Float64Array +].forEach(function(ctor, i) { + concatTypedArray(ctor, 4000, max[i]); +}); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_length-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_length-throws.js new file mode 100644 index 00000000000..8508593944c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_length-throws.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat length throws +features: [Symbol.isConcatSpreadable] +---*/ +var spreadablePoisonedLengthGetter = {}; +spreadablePoisonedLengthGetter[Symbol.isConcatSpreadable] = true; +Object.defineProperty(spreadablePoisonedLengthGetter, "length", { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + [].concat(spreadablePoisonedLengthGetter); +}, '[].concat(spreadablePoisonedLengthGetter) throws a Test262Error exception'); + +assert.throws(Test262Error, function() { + SendableArray.prototype.concat.call(spreadablePoisonedLengthGetter, 1, 2, 3); +}, 'SendableArray.prototype.concat.call(spreadablePoisonedLengthGetter, 1, 2, 3) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_no-prototype.js b/test/sendable/builtins/Array/prototype/concat/concat_no-prototype.js new file mode 100644 index 00000000000..a00b77353a4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_no-prototype.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat no prototype +---*/ +assert.sameValue( + SendableArray.prototype.concat.prototype, + void 0, + 'The value of SendableArray.prototype.concat.prototype is expected to be void 0' +); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_non-array.js b/test/sendable/builtins/Array/prototype/concat/concat_non-array.js new file mode 100644 index 00000000000..a4d8260ccf2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_non-array.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: array-concat-non-array +includes: [compareArray.js] +---*/ +// +// test262 --command "v8 --harmony-classes --harmony_object_literals" array-concat-non-array +// +class NonArray { + constructor() { + SendableArray.apply(this, arguments); + } +} + +var obj = new NonArray(1, 2, 3); +var result = SendableArray.prototype.concat.call(obj, 4, 5, 6); +assert.sameValue(SendableArray, result.constructor, 'The value of Array is expected to equal the value of result.constructor'); +assert.sameValue( + result instanceof NonArray, + false, + 'The result of evaluating (result instanceof NonArray) is expected to be false' +); +assert.compareArray(result, [obj, 4, 5, 6], 'The value of result is expected to be [obj, 4, 5, 6]'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-throws.js new file mode 100644 index 00000000000..92664877181 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-throws.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat sloppy arguments throws +features: [Symbol.isConcatSpreadable] +---*/ +var args = (function(a) { + return arguments; +})(1, 2, 3); +Object.defineProperty(args, 0, { + get: function() { + throw new Test262Error(); + } +}); +args[Symbol.isConcatSpreadable] = true; +assert.throws(Test262Error, function() { + return [].concat(args, args); +}, 'return [].concat(args, args) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-with-dupes.js b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-with-dupes.js new file mode 100644 index 00000000000..35dbd1de8a5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-with-dupes.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat sloppy arguments with dupes +flags: [noStrict] +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var args = (function(a, a, a) { + return arguments; +})(1, 2, 3); +args[Symbol.isConcatSpreadable] = true; +assert.compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3], + '[].concat((function(a, a, a) {return arguments;})(1, 2, 3), (function(a, a, a) {return arguments;})(1, 2, 3)) must return [1, 2, 3, 1, 2, 3]' +); +Object.defineProperty(args, "length", { + value: 6 +}); +assert.compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0], + '[].concat((function(a, a, a) {return arguments;})(1, 2, 3)) must return [1, 2, 3, void 0, void 0, void 0]' +); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments.js b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments.js new file mode 100644 index 00000000000..daee5f4c937 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat sloppy arguments +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var args = (function(a, b, c) { + return arguments; +})(1, 2, 3); +args[Symbol.isConcatSpreadable] = true; +assert.compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3], + '[].concat((function(a, b, c) {return arguments;})(1, 2, 3), (function(a, b, c) {return arguments;})(1, 2, 3)) must return [1, 2, 3, 1, 2, 3]' +); +Object.defineProperty(args, "length", { + value: 6 +}); +assert.compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0], + '[].concat((function(a, b, c) {return arguments;})(1, 2, 3)) must return [1, 2, 3, void 0, void 0, void 0]' +); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_small-typed-array.js b/test/sendable/builtins/Array/prototype/concat/concat_small-typed-array.js new file mode 100644 index 00000000000..2c5e648f38c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_small-typed-array.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat small typed array +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +function concatTypedArray(type, elems, modulo) { + var items = new SendableArray(elems); + var ta_by_len = new type(elems); + for (var i = 0; i < elems; ++i) { + ta_by_len[i] = items[i] = modulo === false ? i : elems % modulo; + } + var ta = new type(items); + assert.compareArray([].concat(ta, ta), [ta, ta]); + ta[Symbol.isConcatSpreadable] = true; + assert.compareArray([].concat(ta), items); + assert.compareArray([].concat(ta_by_len, ta_by_len), [ta_by_len, ta_by_len]); + ta_by_len[Symbol.isConcatSpreadable] = true; + assert.compareArray([].concat(ta_by_len), items); + // TypedArray with fake `length`. + ta = new type(1); + var defValue = ta[0]; + var expected = new SendableArray(4000); + expected[0] = defValue; + Object.defineProperty(ta, "length", { + value: 4000 + }); + ta[Symbol.isConcatSpreadable] = true; + assert.compareArray([].concat(ta), expected); +} +var max = [Math.pow(2, 8), Math.pow(2, 16), Math.pow(2, 32), false, false]; +var TAs = [ + Uint8Array, + Uint16Array, + Uint32Array, + Float32Array, + Float64Array +]; +if (typeof Float16Array !== 'undefined') { + max.push(false); + TAs.push(Float16Array); +} + +TAs.forEach(function(ctor, i) { + concatTypedArray(ctor, 1, max[i]); +}); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-boolean-wrapper.js b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-boolean-wrapper.js new file mode 100644 index 00000000000..b66af29d308 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-boolean-wrapper.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable boolean wrapper +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var bool = new Boolean(true) +// Boolean wrapper objects are not concat-spreadable by default +assert.compareArray([bool], [].concat(bool), '[bool] must return the same value returned by [].concat(bool)'); +// Boolean wrapper objects may be individually concat-spreadable +bool[Symbol.isConcatSpreadable] = true; +bool.length = 3; +bool[0] = 1, bool[1] = 2, bool[2] = 3; +assert.compareArray([1, 2, 3], [].concat(bool), + '[1, 2, 3] must return the same value returned by [].concat(bool)' +); +Boolean.prototype[Symbol.isConcatSpreadable] = true; +// Boolean wrapper objects may be concat-spreadable +assert.compareArray([], [].concat(new Boolean(true)), + '[] must return the same value returned by [].concat(new Boolean(true))' +); +Boolean.prototype[0] = 1; +Boolean.prototype[1] = 2; +Boolean.prototype[2] = 3; +Boolean.prototype.length = 3; +assert.compareArray([1, 2, 3], [].concat(new Boolean(true)), + '[1, 2, 3] must return the same value returned by [].concat(new Boolean(true))' +); +// Boolean values are never concat-spreadable +assert.compareArray([true], [].concat(true), '[true] must return the same value returned by [].concat(true)'); +delete Boolean.prototype[Symbol.isConcatSpreadable]; +delete Boolean.prototype[0]; +delete Boolean.prototype[1]; +delete Boolean.prototype[2]; +delete Boolean.prototype.length; diff --git a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-function.js b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-function.js new file mode 100644 index 00000000000..61f382e0879 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-function.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable function +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var fn = function(a, b, c) {} +// Functions are not concat-spreadable by default +assert.compareArray([fn], [].concat(fn), '[fn] must return the same value returned by [].concat(fn)'); +// Functions may be individually concat-spreadable +fn[Symbol.isConcatSpreadable] = true; +fn[0] = 1, fn[1] = 2, fn[2] = 3; +assert.compareArray([1, 2, 3], [].concat(fn), '[1, 2, 3] must return the same value returned by [].concat(fn)'); +Function.prototype[Symbol.isConcatSpreadable] = true; +// Functions may be concat-spreadable +assert.compareArray([void 0, void 0, void 0], [].concat(function(a, b, c) {}), + '[void 0, void 0, void 0] must return the same value returned by [].concat(function(a, b, c) {})' +); +Function.prototype[0] = 1; +Function.prototype[1] = 2; +Function.prototype[2] = 3; +assert.compareArray([1, 2, 3], [].concat(function(a, b, c) {}), + '[1, 2, 3] must return the same value returned by [].concat(function(a, b, c) {})' +); +delete Function.prototype[Symbol.isConcatSpreadable]; +delete Function.prototype[0]; +delete Function.prototype[1]; +delete Function.prototype[2]; diff --git a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-getter-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-getter-throws.js new file mode 100644 index 00000000000..383c711e2cc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-getter-throws.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable getter throws +features: [Symbol.isConcatSpreadable] +---*/ +var spreadablePoisonedGetter = {}; +Object.defineProperty(spreadablePoisonedGetter, Symbol.isConcatSpreadable, { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + [].concat(spreadablePoisonedGetter); +}, '[].concat(spreadablePoisonedGetter) throws a Test262Error exception'); + +assert.throws(Test262Error, function() { + SendableArray.prototype.concat.call(spreadablePoisonedGetter, 1, 2, 3); +}, 'SendableArray.prototype.concat.call(spreadablePoisonedGetter, 1, 2, 3) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-number-wrapper.js b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-number-wrapper.js new file mode 100644 index 00000000000..63db81933a6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-number-wrapper.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable number wrapper +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var num = new Number(true) +// Number wrapper objects are not concat-spreadable by default +assert.compareArray([num], [].concat(num), '[num] must return the same value returned by [].concat(num)'); +// Number wrapper objects may be individually concat-spreadable +num[Symbol.isConcatSpreadable] = true; +num.length = 3; +num[0] = 1, num[1] = 2, num[2] = 3; +assert.compareArray([1, 2, 3], [].concat(num), '[1, 2, 3] must return the same value returned by [].concat(num)'); +Number.prototype[Symbol.isConcatSpreadable] = true; +// Number wrapper objects may be concat-spreadable +assert.compareArray([], [].concat(new Number(123)), + '[] must return the same value returned by [].concat(new Number(123))' +); +Number.prototype[0] = 1; +Number.prototype[1] = 2; +Number.prototype[2] = 3; +Number.prototype.length = 3; +assert.compareArray([1, 2, 3], [].concat(new Number(123)), + '[1, 2, 3] must return the same value returned by [].concat(new Number(123))' +); +// Number values are never concat-spreadable +assert.compareArray([true], [].concat(true), '[true] must return the same value returned by [].concat(true)'); +delete Number.prototype[Symbol.isConcatSpreadable]; +delete Number.prototype[0]; +delete Number.prototype[1]; +delete Number.prototype[2]; +delete Number.prototype.length; diff --git a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-reg-exp.js b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-reg-exp.js new file mode 100644 index 00000000000..fc3ca84d0f4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-reg-exp.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable reg exp +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var re = /abc/; +// RegExps are not concat-spreadable by default +assert.compareArray([].concat(re), [re], '[].concat(/abc/) must return [re]'); +// RegExps may be individually concat-spreadable +re[Symbol.isConcatSpreadable] = true; +re[0] = 1, re[1] = 2, re[2] = 3, re.length = 3; +assert.compareArray([].concat(re), [1, 2, 3], '[].concat(/abc/) must return [1, 2, 3]'); +// RegExps may be concat-spreadable +RegExp.prototype[Symbol.isConcatSpreadable] = true; +RegExp.prototype.length = 3; +assert.compareArray([].concat(/abc/), [void 0, void 0, void 0], + '[].concat(/abc/) must return [void 0, void 0, void 0]' +); +RegExp.prototype[0] = 1; +RegExp.prototype[1] = 2; +RegExp.prototype[2] = 3; +assert.compareArray([].concat(/abc/), [1, 2, 3], + '[].concat(/abc/) must return [1, 2, 3]' +); +delete RegExp.prototype[Symbol.isConcatSpreadable]; +delete RegExp.prototype[0]; +delete RegExp.prototype[1]; +delete RegExp.prototype[2]; +delete RegExp.prototype.length; diff --git a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-sparse-object.js b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-sparse-object.js new file mode 100644 index 00000000000..89b74357213 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-sparse-object.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable sparse object +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var obj = { + length: 5 +}; +obj[Symbol.isConcatSpreadable] = true; +assert.compareArray([void 0, void 0, void 0, void 0, void 0], [].concat(obj), + '[void 0, void 0, void 0, void 0, void 0] must return the same value returned by [].concat(obj)' +); +obj.length = 4000; +assert.compareArray(new SendableArray(4000), [].concat(obj), + 'new SendableArray(4000) must return the same value returned by [].concat(obj)' +); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-string-wrapper.js b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-string-wrapper.js new file mode 100644 index 00000000000..c84fac1b7ba --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-string-wrapper.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat Symbol.isConcatSpreadable string wrapper +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var str1 = new String("yuck\uD83D\uDCA9") +// String wrapper objects are not concat-spreadable by default +assert.compareArray([str1], [].concat(str1), '[str1] must return the same value returned by [].concat(str1)'); +// String wrapper objects may be individually concat-spreadable +str1[Symbol.isConcatSpreadable] = true; +assert.compareArray(["y", "u", "c", "k", "\uD83D", "\uDCA9"], [].concat(str1), + '["y", "u", "c", "k", "uD83D", "uDCA9"] must return the same value returned by [].concat(str1)' +); +String.prototype[Symbol.isConcatSpreadable] = true; +// String wrapper objects may be concat-spreadable +assert.compareArray(["y", "u", "c", "k", "\uD83D", "\uDCA9"], [].concat(new String("yuck\uD83D\uDCA9")), + '["y", "u", "c", "k", "uD83D", "uDCA9"] must return the same value returned by [].concat(new String("yuckuD83DuDCA9"))' +); +// String values are never concat-spreadable +assert.compareArray(["yuck\uD83D\uDCA9"], [].concat("yuck\uD83D\uDCA9"), + '["yuckuD83DuDCA9"] must return the same value returned by [].concat("yuckuD83DuDCA9")' +); +delete String.prototype[Symbol.isConcatSpreadable]; diff --git a/test/sendable/builtins/Array/prototype/concat/concat_strict-arguments.js b/test/sendable/builtins/Array/prototype/concat/concat_strict-arguments.js new file mode 100644 index 00000000000..3017642060e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/concat_strict-arguments.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Array.prototype.concat strict arguments +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ +var args = (function(a, b, c) { + "use strict"; + return arguments; +})(1, 2, 3); +args[Symbol.isConcatSpreadable] = true; +assert.compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3], + '[].concat("(function(a, b, c) {"use strict"; return arguments;})(1, 2, 3)", "(function(a, b, c) {"use strict"; return arguments;})(1, 2, 3)") must return [1, 2, 3, 1, 2, 3]' +); +Object.defineProperty(args, "length", { + value: 6 +}); +assert.compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0], + '[].concat("(function(a, b, c) {"use strict"; return arguments;})(1, 2, 3)") must return [1, 2, 3, void 0, void 0, void 0]' +); diff --git a/test/sendable/builtins/Array/prototype/concat/create-ctor-non-object.js b/test/sendable/builtins/Array/prototype/concat/create-ctor-non-object.js new file mode 100644 index 00000000000..40fd42325ca --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-ctor-non-object.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + Behavior when `constructor` property is neither an Object nor undefined +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 9. If IsConstructor(C) is false, throw a TypeError exception. +---*/ +var a = []; +a.constructor = null; +assert.throws(TypeError, function() { + a.concat(); +}, 'a.concat() throws a TypeError exception'); +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.concat(); +}, 'a.concat() throws a TypeError exception'); +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.concat(); +}, 'a.concat() throws a TypeError exception'); +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.concat(); +}, 'a.concat() throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-ctor-poisoned.js b/test/sendable/builtins/Array/prototype/concat/create-ctor-poisoned.js new file mode 100644 index 00000000000..6b8a080a721 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-ctor-poisoned.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Abrupt completion from `constructor` property access +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + [...] + 5. Let C be ? Get(originalArray, "constructor"). +---*/ + +var a = []; +Object.defineProperty(a, 'constructor', { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + a.concat(); +}, 'a.concat() throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-non-array.js b/test/sendable/builtins/Array/prototype/concat/create-non-array.js new file mode 100644 index 00000000000..e67eff8dd70 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-non-array.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Constructor is ignored for non-Array values +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + [...] + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). +---*/ + +var obj = { + length: 0 +}; +var callCount = 0; +var result; +Object.defineProperty(obj, 'constructor', { + get: function() { + callCount += 1; + } +}); +result = SendableArray.prototype.concat.call(obj); +assert.sameValue(callCount, 0, 'The value of callCount is expected to be 0'); +assert.sameValue( + Object.getPrototypeOf(result), + SendableArray.prototype, + 'Object.getPrototypeOf(SendableArray.prototype.concat.call(obj)) returns SendableArray.prototype' +); +assert(SendableArray.isArray(result), 'SendableArray.isArray(result) must return true'); +assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); +assert.sameValue(result[0], obj, 'The value of result[0] is expected to equal the value of obj'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-array.js b/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-array.js new file mode 100644 index 00000000000..fc46d59a9e2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-array.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Prefer Array constructor of current realm record +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + [...] + 9.4.2.3 ArraySpeciesCreate + [...] + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C + be undefined. + [...] +features: [cross-realm, Symbol.species] +---*/ + +var SendableArray = []; +var callCount = 0; +var OArray = $262.createRealm().global.SendableArray; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +SendableArray.constructor = OArray; +Object.defineProperty(SendableArray, Symbol.species, speciesDesc); +Object.defineProperty(OArray, Symbol.species, speciesDesc); +result = SendableArray.concat(); +assert.sameValue( + Object.getPrototypeOf(result), + SendableArray.prototype, + 'Object.getPrototypeOf(SendableArray.concat()) returns SendableArray.prototype' +); +assert.sameValue(callCount, 0, 'The value of callCount is expected to be 0'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js b/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js new file mode 100644 index 00000000000..f6114e87f7f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Accept non-Array constructors from other realms +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + [...] + 9.4.2.3 ArraySpeciesCreate + [...] + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C + be undefined. + [...] +features: [cross-realm, Symbol.species] +---*/ + +var SendableArray = []; +var callCount = 0; +var CustomCtor = function() {}; +var OObject = $262.createRealm().global.Object; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +SendableArray.constructor = OObject; +OObject[Symbol.species] = CustomCtor; +Object.defineProperty(SendableArray, Symbol.species, speciesDesc); +result = SendableArray.concat(); +assert.sameValue( + Object.getPrototypeOf(result), + CustomCtor.prototype, + 'Object.getPrototypeOf(SendableArray.concat()) returns CustomCtor.prototype' +); +assert.sameValue(callCount, 0, 'The value of callCount is expected to be 0'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-proxy.js b/test/sendable/builtins/Array/prototype/concat/create-proxy.js new file mode 100644 index 00000000000..d93b80b2059 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-proxy.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Species constructor of a Proxy object whose target is an array +info: | + [...] + 2. Let A be ? ArraySpeciesCreate(O, 0). + [...] + 7. Return A. + 9.4.2.3 ArraySpeciesCreate + [...] + 3. Let isArray be ? IsArray(originalArray). + 7.2.2 IsArray + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is + null, throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy, Symbol.species] +---*/ + +var SendableArray = []; +var proxy = new Proxy(new Proxy(array, {}), {}); +var Ctor = function() {}; +var result; +SendableArray.constructor = function() {}; +SendableArray.constructor[Symbol.species] = Ctor; +result = SendableArray.prototype.concat.call(proxy); +assert.sameValue( + Object.getPrototypeOf(result), + Ctor.prototype, + 'Object.getPrototypeOf(SendableArray.prototype.concat.call(proxy)) returns Ctor.prototype' +); diff --git a/test/sendable/builtins/Array/prototype/concat/create-revoked-proxy.js b/test/sendable/builtins/Array/prototype/concat/create-revoked-proxy.js new file mode 100644 index 00000000000..e457cfe7843 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-revoked-proxy.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Abrupt completion from constructor that is a revoked Proxy object +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + [...] + 3. Let isArray be ? IsArray(originalArray). + 7.2.2 IsArray + [...] + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is + null, throw a TypeError exception. +features: [Proxy] +---*/ + +var o = Proxy.revocable([], {}); +var callCount = 0; +Object.defineProperty(o.proxy, 'constructor', { + get: function() { + callCount += 1; + } +}); +o.revoke(); +assert.throws(TypeError, function() { + SendableArray.prototype.concat.call(o.proxy); +}, 'SendableArray.prototype.concat.call(o.proxy) throws a TypeError exception'); +assert.sameValue(callCount, 0, 'The value of callCount is expected to be 0'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-abrupt.js b/test/sendable/builtins/Array/prototype/concat/create-species-abrupt.js new file mode 100644 index 00000000000..ae29a921b02 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-species-abrupt.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Species constructor returns an abrupt completion +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var Ctor = function() { + throw new Test262Error(); +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; +assert.throws(Test262Error, function() { + a.concat(); +}, 'a.concat() throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-non-ctor.js b/test/sendable/builtins/Array/prototype/concat/create-species-non-ctor.js new file mode 100644 index 00000000000..507a2c2607c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-species-non-ctor.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + Behavior when the @@species attribute is a non-constructor object +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + 5. Let C be ? Get(originalArray, "constructor"). + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 9. If IsConstructor(C) is false, throw a TypeError exception. +includes: [isConstructor.js] +features: [Symbol.species, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(parseInt), + false, + 'precondition: isConstructor(parseInt) must return false' +); +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; +assert.throws(TypeError, function() { + a.concat(); +}, 'a.concat() throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible-spreadable.js b/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible-spreadable.js new file mode 100644 index 00000000000..491c46d627e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible-spreadable.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible, argument is spreadable) +info: | + Array.prototype.concat ( ...arguments ) + 5. Repeat, while items is not empty + c. If spreadable is true, then + iv. Repeat, while k < len + 3. If exists is true, then + b. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), subElement). + CreateDataPropertyOrThrow ( O, P, V ) + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; +var arr = []; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.concat([1]); +}, 'arr.concat([1]) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible.js b/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible.js new file mode 100644 index 00000000000..a45e4f1d59b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.concat +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible, argument is not spreadable) +info: | + Array.prototype.concat ( ...arguments ) + 5. Repeat, while items is not empty + c. If spreadable is true, then + d. Else, + iii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), E). + CreateDataPropertyOrThrow ( O, P, V ) + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; +var arr = []; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.concat(1); +}, 'arr.concat(1) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-null.js b/test/sendable/builtins/Array/prototype/concat/create-species-null.js new file mode 100644 index 00000000000..78d0bd32185 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-species-null.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + A null value for the @@species constructor is interpreted as `undefined` +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). +features: [Symbol.species] +---*/ + +var a = []; +var result; +a.constructor = {}; +a.constructor[Symbol.species] = null; +result = a.concat(); +assert.sameValue( + Object.getPrototypeOf(result), + SendableArray.prototype, + 'Object.getPrototypeOf(a.concat()) returns SendableArray.prototype' +); +assert(SendableArray.isArray(result), 'SendableArray.isArray(result) must return true'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-poisoned.js b/test/sendable/builtins/Array/prototype/concat/create-species-poisoned.js new file mode 100644 index 00000000000..1774333caae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-species-poisoned.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Abrupt completion from `@@species` property access +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + 5. Let C be ? Get(originalArray, "constructor"). + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). +features: [Symbol.species] +---*/ + +var a = []; +a.constructor = {}; +Object.defineProperty(a.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + a.concat(); +}, 'a.concat() throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-undef.js b/test/sendable/builtins/Array/prototype/concat/create-species-undef.js new file mode 100644 index 00000000000..e017fac4331 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-species-undef.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + An undefined value for the @@species constructor triggers the creation of + an Array exotic object +info: | + 9. Let A be ? ArraySpeciesCreate(O, actualDeleteCount). + 9.4.2.3 ArraySpeciesCreate + 5. Let C be ? Get(originalArray, "constructor"). + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). +features: [Symbol.species] +---*/ + +var a = []; +var result; +a.constructor = {}; +a.constructor[Symbol.species] = undefined; +result = a.concat(); +assert.sameValue( + Object.getPrototypeOf(result), + SendableArray.prototype, + 'Object.getPrototypeOf(a.concat()) returns SendableArray.prototype' +); +assert(SendableArray.isArray(result), 'SendableArray.isArray(result) must return true'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js new file mode 100644 index 00000000000..6f58108196b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable, argument is spreadable) +info: | + Array.prototype.concat ( ...arguments ) + 5. Repeat, while items is not empty + c. If spreadable is true, then + iv. Repeat, while k < len + 3. If exists is true, then + b. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), subElement). + CreateDataPropertyOrThrow ( O, P, V ) + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + writable: true, + configurable: false, + }); +}; +var arr = []; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.concat([1]); +}, 'arr.concat([1]) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property.js b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property.js new file mode 100644 index 00000000000..79ed2b767de --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable, argument is non-spreadable) +info: | + Array.prototype.concat ( ...arguments ) + 5. Repeat, while items is not empty + c. If spreadable is true, then + d. Else, + iii. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), E). + CreateDataPropertyOrThrow ( O, P, V ) + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + set: function(_value) {}, + configurable: false, + }); +}; +var arr = []; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.concat(1); +}, 'arr.concat(1) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js new file mode 100644 index 00000000000..fdaf8760053 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + Non-writable properties are overwritten by CreateDataProperty. + (result object's "0" is non-writable, argument is spreadable) +info: | + Array.prototype.concat ( ...arguments ) + 5. Repeat, while items is not empty + c. If spreadable is true, then + iv. Repeat, while k < len + 3. If exists is true, then + b. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), subElement). +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + value: 1, + writable: false, + enumerable: false, + configurable: true, + }); +}; +var arr = []; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +var res = arr.concat([2]); +verifyProperty(res, "0", { + value: 2, + writable: true, + enumerable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property.js new file mode 100644 index 00000000000..b9b1e6b74aa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + Non-writable properties are overwritten by CreateDataProperty. + (result object's "0" is non-writable, argument is not spreadable) +info: | + Array.prototype.concat ( ...arguments ) + 5. Repeat, while items is not empty + c. If spreadable is true, then + iv. Repeat, while k < len + 3. If exists is true, then + b. Perform ? CreateDataPropertyOrThrow(A, ! ToString(n), subElement). +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + value: 1, + writable: false, + enumerable: false, + configurable: true, + }); +}; +var arr = []; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +var res = arr.concat(2); +verifyProperty(res, "0", { + value: 2, + writable: true, + enumerable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species.js b/test/sendable/builtins/Array/prototype/concat/create-species.js new file mode 100644 index 00000000000..f1191afbccb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/create-species.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Species constructor is used to create a new instance +info: | + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + 5. Let C be ? Get(originalArray, "constructor"). + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var thisValue, args, result; +var callCount = 0; +var instance = []; +var Ctor = function() { + callCount += 1; + thisValue = this; + args = arguments; + return instance; +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; +result = a.concat(); +assert.sameValue(callCount, 1, 'The value of callCount is expected to be 1'); +assert.sameValue( + Object.getPrototypeOf(thisValue), + Ctor.prototype, + 'Object.getPrototypeOf(this) returns Ctor.prototype' +); +assert.sameValue(args.length, 1, 'The value of args.length is expected to be 1'); +assert.sameValue(args[0], 0, 'The value of args[0] is expected to be 0'); +assert.sameValue(result, instance, 'The value of result is expected to equal the value of instance'); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-err.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-err.js new file mode 100644 index 00000000000..a2d1447246c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-err.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: Error thrown when accessing `Symbol.isConcatSpreadable` property +info: | + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let A be ArraySpeciesCreate(O, 0). + 4. ReturnIfAbrupt(A). + 5. Let n be 0. + 6. Let items be a List whose first element is O and whose subsequent + elements are, in left to right order, the arguments that were passed to + this function invocation. + 7. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the element. + b. Let spreadable be IsConcatSpreadable(E). + c. ReturnIfAbrupt(spreadable). + ES6 22.1.3.1.1: Runtime Semantics: IsConcatSpreadable ( O ) + 1. If Type(O) is not Object, return false. + 2. Let spreadable be Get(O, @@isConcatSpreadable). + 3. ReturnIfAbrupt(spreadable). +features: [Symbol.isConcatSpreadable] +---*/ + +var o = {}; +Object.defineProperty(o, Symbol.isConcatSpreadable, { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.concat.call(o); +}, 'SendableArray.prototype.concat.call(o) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-order.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-order.js new file mode 100644 index 00000000000..4d7ae64937c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-order.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + Symbol.isConcatSpreadable should be looked up once for `this value` and + once for each argument, after ArraySpeciesCreate routine. +info: | + Array.prototype.concat ( ...arguments ) + 1. Let O be ? ToObject(this value). + 2. Let A be ? ArraySpeciesCreate(O, 0). + 5. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the element. + b. Let spreadable be ? IsConcatSpreadable(E). + ArraySpeciesCreate ( originalArray, length ) + 5. Let C be ? Get(originalArray, "constructor"). + Runtime Semantics: IsConcatSpreadable ( O ) + 1. If Type(O) is not Object, return false. + 2. Let spreadable be ? Get(O, @@isConcatSpreadable). +includes: [compareArray.js] +features: [Symbol.isConcatSpreadable] +---*/ + +var calls = []; +var descConstructor = { + get: function() { + calls.push("constructor"); + return Array; + }, + configurable: true, +}; +var descSpreadable = { + get: function() { + calls.push("isConcatSpreadable"); + }, + configurable: true, +}; +var arr1 = []; +Object.defineProperty(arr1, "constructor", descConstructor); +Object.defineProperty(arr1, Symbol.isConcatSpreadable, descSpreadable); + +assert.compareArray(arr1.concat(1), [1], 'arr1.concat(1) must return [1]'); +assert.compareArray( + calls, + ["constructor", "isConcatSpreadable"], + 'The value of calls is expected to be ["constructor", "isConcatSpreadable"]' +); +calls = []; +var arr2 = []; +var arg = {}; +Object.defineProperty(arr2, "constructor", descConstructor); +Object.defineProperty(arg, Symbol.isConcatSpreadable, descSpreadable); +assert.compareArray(arr2.concat(arg), [arg], 'arr2.concat({}) must return [arg]'); +assert.compareArray( + calls, + ["constructor", "isConcatSpreadable"], + 'The value of calls is expected to be ["constructor", "isConcatSpreadable"]' +); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js new file mode 100644 index 00000000000..e0609ac012d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-isconcatspreadable +description: Revoked proxy value produces a TypeError when supplied to IsArray +info: | + 5. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the + element. + b. Let spreadable be ? IsConcatSpreadable(E). + c. If spreadable is true, then + e. Else E is added as a single item rather than spread, + ES6 22.1.3.1.1: Runtime Semantics: IsConcatSpreadable ( O ) + 1. If Type(O) is not Object, return false. + 2. Let spreadable be ? Get(O, @@isConcatSpreadable). + 3. If spreadable is not undefined, return ToBoolean(spreadable). + 4. Return ? IsArray(O). + 7.2.2 IsArray + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is null, + throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy, Symbol.isConcatSpreadable] +---*/ + +var target = []; +var handle = Proxy.revocable(target, { + get: function(_, key) { + // Defer proxy revocation until after property access to ensure that the + // expected TypeError originates from the IsArray operation. + if (key === Symbol.isConcatSpreadable) { + handle.revoke(); + } + return target[key]; + } +}); +assert.throws(TypeError, function() { + [].concat(handle.proxy); +}, '[].concat(handle.proxy) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js new file mode 100644 index 00000000000..d3c4e8b3f96 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-isconcatspreadable +description: > + Revoked proxy value produces a TypeError during access of + `Symbol.isConcatSpreadable` property +info: | + 5. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the + element. + b. Let spreadable be ? IsConcatSpreadable(E). + c. If spreadable is true, then + e. Else E is added as a single item rather than spread, + ES6 22.1.3.1.1: Runtime Semantics: IsConcatSpreadable ( O ) + 1. If Type(O) is not Object, return false. + 2. Let spreadable be ? Get(O, @@isConcatSpreadable). + 7.3.1 Get + 3. Return ? O.[[Get]](P, O). + 9.5.8 [[Get]] + 2. Let handler be O.[[ProxyHandler]]. + 3. If handler is null, throw a TypeError exception. +features: [Proxy] +---*/ + +var handle = Proxy.revocable([], {}); +handle.revoke(); +assert.throws(TypeError, function() { + [].concat(handle.proxy); +}, '[].concat(handle.proxy) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy.js new file mode 100644 index 00000000000..6119460a388 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-isconcatspreadable +description: > + Proxies who final targets are arrays are considered spreadable +info: | + 5. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the + element. + b. Let spreadable be ? IsConcatSpreadable(E). + c. If spreadable is true, then + e. Else E is added as a single item rather than spread, + ES6 22.1.3.1.1: Runtime Semantics: IsConcatSpreadable ( O ) + 1. If Type(O) is not Object, return false. + 2. Let spreadable be ? Get(O, @@isConcatSpreadable). + 3. If spreadable is not undefined, return ToBoolean(spreadable). + 4. Return ? IsArray(O). + 7.2.2 IsArray + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is null, + throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy, Symbol.isConcatSpreadable] +---*/ + +var arrayProxy = new Proxy([], {}); +var arrayProxyProxy = new Proxy(arrayProxy, {}); +var spreadable = {}; +spreadable[Symbol.isConcatSpreadable] = true; +var spreadableProxy = new Proxy(spreadable, {}); +assert.sameValue([].concat(arrayProxy).length, 0, 'The value of [].concat(arrayProxy).length is expected to be 0'); +assert.sameValue( + [].concat(arrayProxyProxy).length, 0, 'The value of [].concat(arrayProxyProxy).length is expected to be 0' +); +assert.sameValue( + [].concat(spreadableProxy).length, + 0, + 'The value of [].concat(spreadableProxy).length is expected to be 0' +); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-falsey.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-falsey.js new file mode 100644 index 00000000000..149be4ce8c6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-falsey.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + The `Symbol.isConcatSpreadable` property is defined and coerces to `false` +info: | + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let A be ArraySpeciesCreate(O, 0). + 4. ReturnIfAbrupt(A). + 5. Let n be 0. + 6. Let items be a List whose first element is O and whose subsequent + elements are, in left to right order, the arguments that were passed to + this function invocation. + 7. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the element. + b. Let spreadable be IsConcatSpreadable(E). + c. ReturnIfAbrupt(spreadable). + d. If spreadable is true, then + e. Else E is added as a single item rather than spread, + ES6 22.1.3.1.1: Runtime Semantics: IsConcatSpreadable ( O ) + 1. If Type(O) is not Object, return false. + 2. Let spreadable be Get(O, @@isConcatSpreadable). + 3. ReturnIfAbrupt(spreadable). + 4. If spreadable is not undefined, return ToBoolean(spreadable). +features: [Symbol.isConcatSpreadable] +---*/ + +var item = [1, 2]; +var result; +item[Symbol.isConcatSpreadable] = null; +result = [].concat(item); +assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); +assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); +item[Symbol.isConcatSpreadable] = false; +result = [].concat(item); +assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); +assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); +item[Symbol.isConcatSpreadable] = 0; +result = [].concat(item); +assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); +assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); +item[Symbol.isConcatSpreadable] = NaN; +result = [].concat(item); +assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); +assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-truthy.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-truthy.js new file mode 100644 index 00000000000..91eed2edd46 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-truthy.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + The `Symbol.isConcatSpreadable` property is defined and coerces to `true` +info: | + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let A be ArraySpeciesCreate(O, 0). + 4. ReturnIfAbrupt(A). + 5. Let n be 0. + 6. Let items be a List whose first element is O and whose subsequent + elements are, in left to right order, the arguments that were passed to + this function invocation. + 7. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the element. + b. Let spreadable be IsConcatSpreadable(E). + c. ReturnIfAbrupt(spreadable). + d. If spreadable is true, then + ES6 22.1.3.1.1: Runtime Semantics: IsConcatSpreadable ( O ) + 1. If Type(O) is not Object, return false. + 2. Let spreadable be Get(O, @@isConcatSpreadable). + 3. ReturnIfAbrupt(spreadable). + 4. If spreadable is not undefined, return ToBoolean(spreadable). +features: [Symbol, Symbol.isConcatSpreadable] +---*/ + +var item = {}; +var result; +item[Symbol.isConcatSpreadable] = true; +result = [].concat(item); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); +item[Symbol.isConcatSpreadable] = 86; +result = [].concat(item); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); +item[Symbol.isConcatSpreadable] = 'string'; +result = [].concat(item); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); +item[Symbol.isConcatSpreadable] = Symbol(); +result = [].concat(item); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); +item[Symbol.isConcatSpreadable] = {}; +result = [].concat(item); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-undefined.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-undefined.js new file mode 100644 index 00000000000..9ff95202f7f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-undefined.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + The `Symbol.isConcatSpreadable` property is defined as the value `undefined` +info: | + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let A be ArraySpeciesCreate(O, 0). + 4. ReturnIfAbrupt(A). + 5. Let n be 0. + 6. Let items be a List whose first element is O and whose subsequent + elements are, in left to right order, the arguments that were passed to + this function invocation. + 7. Repeat, while items is not empty + a. Remove the first element from items and let E be the value of the element. + b. Let spreadable be IsConcatSpreadable(E). + c. ReturnIfAbrupt(spreadable). + d. If spreadable is true, then + e. Else E is added as a single item rather than spread, + ES6 22.1.3.1.1: Runtime Semantics: IsConcatSpreadable ( O ) + 1. If Type(O) is not Object, return false. + 2. Let spreadable be Get(O, @@isConcatSpreadable). + 3. ReturnIfAbrupt(spreadable). + 4. If spreadable is not undefined, return ToBoolean(spreadable). + 5. Return IsArray(O). +features: [Symbol.isConcatSpreadable] +---*/ + +var item = []; +var result; +item[Symbol.isConcatSpreadable] = undefined; +result = [].concat(item); +assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); diff --git a/test/sendable/builtins/Array/prototype/concat/length.js b/test/sendable/builtins/Array/prototype/concat/length.js new file mode 100644 index 00000000000..451db021d76 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/length.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + The "length" property of Array.prototype.concat +info: | + 22.1.3.1 Array.prototype.concat ( ...arguments ) + The length property of the concat method is 1. + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.concat, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/concat/name.js b/test/sendable/builtins/Array/prototype/concat/name.js new file mode 100644 index 00000000000..84fa9722666 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + Array.prototype.concat.name is "concat". +info: | + Array.prototype.concat ( ...arguments ) + 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(SendableArray.prototype.concat, "name", { + value: "concat", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/concat/not-a-constructor.js b/test/sendable/builtins/Array/prototype/concat/not-a-constructor.js new file mode 100644 index 00000000000..cad5cabacda --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/not-a-constructor.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.concat 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(SendableArray.prototype.concat), + false, + 'isConstructor(SendableArray.prototype.concat) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.concat([]); +}, 'new SendableArray.prototype.concat([]) throws a TypeError exception'); + diff --git a/test/sendable/builtins/Array/prototype/concat/prop-desc.js b/test/sendable/builtins/Array/prototype/concat/prop-desc.js new file mode 100644 index 00000000000..79bc394b32e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/concat/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.concat +description: > + "concat" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.concat, 'function', 'The value of `typeof SendableArray.prototype.concat` is expected to be "function"'); +verifyProperty(SendableArray.prototype, "concat", { + writable: true, + enumerable: false, + configurable: true +}); -- Gitee From 17da2796a2edafcb6d6d040745c75cebf5d2f5ab Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 18 Dec 2024 14:42:55 +0800 Subject: [PATCH 21/93] update Signed-off-by: zhuzhihui7 --- .../sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T1.js | 2 +- .../sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js | 2 +- .../sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T1.js | 2 +- .../sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T2.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T1.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T1.js index 62be6677a4d..97d6751d8ed 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T1.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T1.js @@ -26,7 +26,7 @@ var y = new SendableArray(0, 1); var z = new SendableArray(2, 3, 4); var arr = x.concat(y, z); arr.getClass = Object.prototype.toString; -assert.sameValue(arr.getClass(), "[object SendableArray]", 'arr.getClass() must return "[object SendableArray]"'); +assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); assert.sameValue(arr[0], 0, 'The value of arr[0] is expected to be 0'); assert.sameValue(arr[1], 1, 'The value of arr[1] is expected to be 1'); assert.sameValue(arr[2], 2, 'The value of arr[2] is expected to be 2'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js index 047e023a96f..13a80f3ea6c 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js @@ -27,7 +27,7 @@ var y = new Object(); var z = new SendableArray(1, 2); var arr = x.concat(y, z, -1, true, "NaN"); arr.getClass = Object.prototype.toString; -assert.sameValue(arr.getClass(), "[object SendableArray]", 'arr.getClass() must return "[object SendableArray]"'); +assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); assert.sameValue(arr[0], 0, 'The value of arr[0] is expected to be 0'); assert.sameValue(arr[1], y, 'The value of arr[1] is expected to equal the value of y'); assert.sameValue(arr[2], 1, 'The value of arr[2] is expected to be 1'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T1.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T1.js index 5671f7ccefa..966abd6ac3d 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T1.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T1.js @@ -27,7 +27,7 @@ var y = new Object(); var z = new SendableArray(1, 2); var arr = x.concat(y, z, -1, true, "NaN"); arr.getClass = Object.prototype.toString; -assert.sameValue(arr.getClass(), "[object SendableArray]", 'arr.getClass() must return "[object SendableArray]"'); +assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); assert.sameValue(arr[0], x, 'The value of arr[0] is expected to equal the value of x'); assert.sameValue(arr[1], y, 'The value of arr[1] is expected to equal the value of y'); assert.sameValue(arr[2], 1, 'The value of arr[2] is expected to be 1'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T2.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T2.js index 2eb8ada9fde..5113f4bb8c4 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T2.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A2_T2.js @@ -26,6 +26,6 @@ var x = {}; x.concat = SendableArray.prototype.concat; var arr = x.concat(); arr.getClass = Object.prototype.toString; -assert.sameValue(arr.getClass(), "[object SendableArray]", 'arr.getClass() must return "[object SendableArray]"'); +assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); assert.sameValue(arr[0], x, 'The value of arr[0] is expected to equal the value of x'); assert.sameValue(arr.length, 1, 'The value of arr.length is expected to be 1'); -- Gitee From 081434ef453fab4cdb1686db8795dcf6539ccabc Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 18 Dec 2024 16:48:53 +0800 Subject: [PATCH 22/93] add copywithin case Signed-off-by: zhuzhihui7 --- .../prototype/copyWithin/call-with-boolean.js | 29 +++ .../copyWithin/coerced-values-end.js | 49 +++++ .../coerced-values-start-change-start.js | 57 ++++++ .../coerced-values-start-change-target.js | 48 +++++ .../copyWithin/coerced-values-start.js | 56 ++++++ .../copyWithin/coerced-values-target.js | 60 ++++++ .../Array/prototype/copyWithin/fill-holes.js | 28 +++ .../copyWithin/length-near-integer-limit.js | 47 +++++ .../Array/prototype/copyWithin/length.js | 30 +++ .../Array/prototype/copyWithin/name.js | 30 +++ .../prototype/copyWithin/negative-end.js | 60 ++++++ .../copyWithin/negative-out-of-bounds-end.js | 68 +++++++ .../negative-out-of-bounds-start.js | 57 ++++++ .../negative-out-of-bounds-target.js | 41 +++++ .../prototype/copyWithin/negative-start.js | 49 +++++ .../prototype/copyWithin/negative-target.js | 37 ++++ .../non-negative-out-of-bounds-end.js | 56 ++++++ ...negative-out-of-bounds-target-and-start.js | 94 ++++++++++ .../non-negative-target-and-start.js | 53 ++++++ .../non-negative-target-start-and-end.js | 71 ++++++++ .../prototype/copyWithin/not-a-constructor.js | 39 ++++ .../Array/prototype/copyWithin/prop-desc.js | 33 ++++ .../prototype/copyWithin/resizable-buffer.js | 171 ++++++++++++++++++ .../return-abrupt-from-delete-proxy-target.js | 44 +++++ .../return-abrupt-from-delete-target.js | 39 ++++ .../return-abrupt-from-end-as-symbol.js | 30 +++ .../copyWithin/return-abrupt-from-end.js | 33 ++++ .../return-abrupt-from-get-start-value.js | 45 +++++ .../return-abrupt-from-has-start.js | 44 +++++ .../return-abrupt-from-set-target-value.js | 44 +++++ .../return-abrupt-from-start-as-symbol.js | 29 +++ .../copyWithin/return-abrupt-from-start.js | 32 ++++ .../return-abrupt-from-target-as-symbol.js | 29 +++ .../copyWithin/return-abrupt-from-target.js | 32 ++++ ...eturn-abrupt-from-this-length-as-symbol.js | 33 ++++ .../return-abrupt-from-this-length.js | 45 +++++ .../copyWithin/return-abrupt-from-this.js | 30 +++ .../Array/prototype/copyWithin/return-this.js | 31 ++++ .../prototype/copyWithin/undefined-end.js | 33 ++++ 39 files changed, 1836 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/coerced-values-end.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/coerced-values-start-change-start.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/coerced-values-start-change-target.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/coerced-values-start.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/coerced-values-target.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/fill-holes.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/length-near-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/length.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/name.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/negative-end.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/negative-out-of-bounds-end.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/negative-out-of-bounds-start.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/negative-out-of-bounds-target.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/negative-start.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/negative-target.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/non-negative-out-of-bounds-end.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/non-negative-target-and-start.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/non-negative-target-start-and-end.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-delete-proxy-target.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-delete-target.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-end-as-symbol.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-end.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-get-start-value.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-has-start.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-set-target-value.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-start-as-symbol.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-start.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-target-as-symbol.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-target.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-this-length-as-symbol.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-this-length.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-this.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/return-this.js create mode 100644 test/sendable/builtins/Array/prototype/copyWithin/undefined-end.js diff --git a/test/sendable/builtins/Array/prototype/copyWithin/call-with-boolean.js b/test/sendable/builtins/Array/prototype/copyWithin/call-with-boolean.js new file mode 100644 index 00000000000..8bd0d38e2b5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/call-with-boolean.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copyWithin +description: Array.prototype.copyWithin applied to boolean primitive +---*/ + +assert.sameValue( + SendableArray.prototype.copyWithin.call(true) instanceof Boolean, + true, + 'The result of evaluating (SendableArray.prototype.copyWithin.call(true) instanceof Boolean) is expected to be true' +); +assert.sameValue( + SendableArray.prototype.copyWithin.call(false) instanceof Boolean, + true, + 'The result of evaluating (SendableArray.prototype.copyWithin.call(false) instanceof Boolean) is expected to be true' +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-end.js b/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-end.js new file mode 100644 index 00000000000..f0275398a5d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-end.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + end argument is coerced to an integer values. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, 0, null), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(1, 0, null) must return [0, 1, 2, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, 0, NaN), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(1, 0, NaN) must return [0, 1, 2, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, 0, false), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(1, 0, false) must return [0, 1, 2, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, 0, true), [0, 0, 2, 3], + '[0, 1, 2, 3].copyWithin(1, 0, true) must return [0, 0, 2, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, 0, '-2'), [0, 0, 1, 3], + '[0, 1, 2, 3].copyWithin(1, 0, "-2") must return [0, 0, 1, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, 0, -2.5), [0, 0, 1, 3], + '[0, 1, 2, 3].copyWithin(1, 0, -2.5) must return [0, 0, 1, 3]' +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-start-change-start.js b/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-start-change-start.js new file mode 100644 index 00000000000..0549639c96d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-start-change-start.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + SECURITY: start argument is coerced to an integer value + and side effects change the length of the array so that + the start is out of bounds +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 8. Let relativeStart be ToInteger(start). +includes: [compareArray.js] +---*/ + + +// make a long integer Array +function longDenseArray(){ + var a = [0]; + for(var i = 0; i < 1024; i++){ + a[i] = i; + } + return a; +} +function shorten(){ + currArray.length = 20; + return 1000; +} +var array = []; +array.length = 20; +var currArray = longDenseArray(); +assert.compareArray( + currArray.copyWithin(0, {valueOf: shorten}), array, + 'currArray.copyWithin(0, {valueOf: shorten}) returns array' +); +currArray = longDenseArray(); +Object.setPrototypeOf(currArray, longDenseArray()); +var array2 = longDenseArray(); +array2.length = 20; +for(var i = 0; i < 24; i++){ + array2[i] = Object.getPrototypeOf(currArray)[i+1000]; +} +assert.compareArray( + currArray.copyWithin(0, {valueOf: shorten}), array2, + 'currArray.copyWithin(0, {valueOf: shorten}) returns array2' +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-start-change-target.js b/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-start-change-target.js new file mode 100644 index 00000000000..3eac18b6462 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-start-change-target.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + SECURITY: start argument is coerced to an integer value + and side effects change the length of the array so that + the target is out of bounds +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 8. Let relativeStart be ToInteger(start). +includes: [compareArray.js] +---*/ + +// make a long integer Array +function longDenseArray(){ + var a = [0]; + for(var i = 0; i < 1024; i++){ + a[i] = i; + } + return a; +} +function shorten(){ + currArray.length = 20; + return 1; +} +var array = longDenseArray(); +array.length = 20; +for(var i = 0; i < 19; i++){ + array[i+1000] = array[i+1]; +} +var currArray = longDenseArray(); +assert.compareArray( + currArray.copyWithin(1000, {valueOf: shorten}), array, + 'currArray.copyWithin(1000, {valueOf: shorten}) returns array' +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-start.js b/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-start.js new file mode 100644 index 00000000000..e4209ef8022 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-start.js @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + start argument is coerced to an integer value. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 8. Let relativeStart be ToInteger(start). +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, undefined), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin(1, undefined) must return [0, 0, 1, 2]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, false), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin(1, false) must return [0, 0, 1, 2]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, NaN), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin(1, NaN) must return [0, 0, 1, 2]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, null), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin(1, null) must return [0, 0, 1, 2]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, true), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0, true) must return [1, 2, 3, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, '1'), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0, "1") must return [1, 2, 3, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(1, 0.5), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin(1, 0.5) must return [0, 0, 1, 2]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1.5), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0, 1.5) must return [1, 2, 3, 3]' +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-target.js b/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-target.js new file mode 100644 index 00000000000..ef2ccb4a842 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/coerced-values-target.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + target argument is coerced to an integer value. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 5. Let relativeTarget be ToInteger(target). +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(undefined, 1), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(undefined, 1) must return [1, 2, 3, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(false, 1), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(false, 1) must return [1, 2, 3, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(NaN, 1), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(NaN, 1) must return [1, 2, 3, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(null, 1), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(null, 1) must return [1, 2, 3, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(true, 0), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin(true, 0) must return [0, 0, 1, 2]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin('1', 0), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin("1", 0) must return [0, 0, 1, 2]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(0.5, 1), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0.5, 1) must return [1, 2, 3, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(1.5, 0), [0, 0, 1, 2], + '[0, 1, 2, 3].copyWithin(1.5, 0) must return [0, 0, 1, 2]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin({}, 1), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin({}, 1) must return [1, 2, 3, 3]' +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/fill-holes.js b/test/sendable/builtins/Array/prototype/copyWithin/fill-holes.js new file mode 100644 index 00000000000..e40908fbf6b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/fill-holes.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Loop from each property, even empty holes. +---*/ + +var arr = [0, 1, , , 1]; +arr.copyWithin(0, 1, 4); +assert.sameValue(arr.length, 5); +assert.sameValue(arr[0], 1); +assert.sameValue(arr[4], 1); +assert.sameValue(arr.hasOwnProperty(1), false); +assert.sameValue(arr.hasOwnProperty(2), false); +assert.sameValue(arr.hasOwnProperty(3), false); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/length-near-integer-limit.js b/test/sendable/builtins/Array/prototype/copyWithin/length-near-integer-limit.js new file mode 100644 index 00000000000..c0612cb287c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/length-near-integer-limit.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.copywithin +description: > + Elements are copied and deleted in an array-like object + whose "length" property is near the integer limit. +info: | + Array.prototype.copyWithin ( target, start [ , end ] ) + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + 9. Let count be min(final - from, len - to). + 12. Repeat, while count > 0 + d. If fromPresent is true, then + i. Let fromVal be ? Get(O, fromKey). + ii. Perform ? Set(O, toKey, fromVal, true). + e. Else, + i. Assert: fromPresent is false. + ii. Perform ? DeletePropertyOrThrow(O, toKey). +---*/ + +var startIndex = Number.MAX_SAFE_INTEGER - 3; +var arrayLike = { + 0: 0, + 1: 1, + 2: 2, + length: Number.MAX_SAFE_INTEGER, +}; +arrayLike[startIndex] = -3; +arrayLike[startIndex + 2] = -1; +SendableArray.prototype.copyWithin.call(arrayLike, 0, startIndex, startIndex + 3); +assert.sameValue(arrayLike[0], -3); +assert.sameValue(1 in arrayLike, false); +assert.sameValue(arrayLike[2], -1); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/length.js b/test/sendable/builtins/Array/prototype/copyWithin/length.js new file mode 100644 index 00000000000..6cd39a1650c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/length.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: Array.prototype.copyWithin.length value and descriptor. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + The length property of the copyWithin method is 2. +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.prototype.copyWithin, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/name.js b/test/sendable/builtins/Array/prototype/copyWithin/name.js new file mode 100644 index 00000000000..ea5b69be7f3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/name.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Array.prototype.copyWithin.name value and descriptor. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.prototype.copyWithin, "name", { + value: "copyWithin", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/negative-end.js b/test/sendable/builtins/Array/prototype/copyWithin/negative-end.js new file mode 100644 index 00000000000..2a5fd4a2d78 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/negative-end.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Set values with negative end argument. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 12. ReturnIfAbrupt(relativeEnd). + 13. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let + final be min(relativeEnd, len). +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1, -1), [1, 2, 2, 3], + '[0, 1, 2, 3].copyWithin(0, 1, -1) must return [1, 2, 2, 3]' +); +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(2, 0, -1), [0, 1, 0, 1, 2], + '[0, 1, 2, 3, 4].copyWithin(2, 0, -1) must return [0, 1, 0, 1, 2]' +); +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(1, 2, -2), [0, 2, 2, 3, 4], + '[0, 1, 2, 3, 4].copyWithin(1, 2, -2) must return [0, 2, 2, 3, 4]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, -2, -1), [2, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, -2, -1) must return [2, 1, 2, 3]' +); +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(2, -2, -1), [0, 1, 3, 3, 4], + '[0, 1, 2, 3, 4].copyWithin(2, -2, -1) must return [0, 1, 3, 3, 4]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(-3, -2, -1), [0, 2, 2, 3], + '[0, 1, 2, 3].copyWithin(-3, -2, -1) must return [0, 2, 2, 3]' +); +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(-2, -3, -1), [0, 1, 2, 2, 3], + '[0, 1, 2, 3, 4].copyWithin(-2, -3, -1) must return [0, 1, 2, 2, 3]' +); +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(-5, -2, -1), [3, 1, 2, 3, 4], + '[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) must return [3, 1, 2, 3, 4]' +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/negative-out-of-bounds-end.js b/test/sendable/builtins/Array/prototype/copyWithin/negative-out-of-bounds-end.js new file mode 100644 index 00000000000..9c4db4cf193 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/negative-out-of-bounds-end.js @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Set values with negative out of bounds end argument. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 12. ReturnIfAbrupt(relativeEnd). + 13. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let + final be min(relativeEnd, len). +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1, -10), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, 1, -10) must return [0, 1, 2, 3]' +); +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity) must return [1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, -2, -10), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, -2, -10) must return [0, 1, 2, 3]' +); +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity) must return [1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, -9, -10), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, -9, -10) must return [0, 1, 2, 3]' +); +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity) must return [1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(-3, -2, -10), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(-3, -2, -10) must return [0, 1, 2, 3]' +); +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity) must return [1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(-7, -8, -9), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(-7, -8, -9) must return [0, 1, 2, 3]' +); +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) must return [1, 2, 3, 4, 5]' +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/negative-out-of-bounds-start.js b/test/sendable/builtins/Array/prototype/copyWithin/negative-out-of-bounds-start.js new file mode 100644 index 00000000000..b8479b2ba47 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/negative-out-of-bounds-start.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Set values with out of bounds negative start argument. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, -10), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, -10) must return [0, 1, 2, 3]' +); +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(0, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(0, -Infinity) must return [1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(2, -10), [0, 1, 0, 1, 2], + '[0, 1, 2, 3, 4].copyWithin(2, -10) must return [0, 1, 0, 1, 2]' +); +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(2, -Infinity), [1, 2, 1, 2, 3], + '[1, 2, 3, 4, 5].copyWithin(2, -Infinity) must return [1, 2, 1, 2, 3]' +); +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(10, -10), [0, 1, 2, 3, 4], + '[0, 1, 2, 3, 4].copyWithin(10, -10) must return [0, 1, 2, 3, 4]' +); +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(10, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(10, -Infinity) must return [1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(-9, -10), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(-9, -10) must return [0, 1, 2, 3]' +); +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(-9, -Infinity), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) must return [1, 2, 3, 4, 5]' +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/negative-out-of-bounds-target.js b/test/sendable/builtins/Array/prototype/copyWithin/negative-out-of-bounds-target.js new file mode 100644 index 00000000000..48eea8e9fab --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/negative-out-of-bounds-target.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Set values with out of bounds negative target argument. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to + be min(relativeTarget, len). +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(-10, 0), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(-10, 0) must return [0, 1, 2, 3]' +); +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(-Infinity, 0), [1, 2, 3, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(-Infinity, 0) must return [1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(-10, 2), [2, 3, 4, 3, 4], + '[0, 1, 2, 3, 4].copyWithin(-10, 2) must return [2, 3, 4, 3, 4]' +); +assert.compareArray( + [1, 2, 3, 4, 5].copyWithin(-Infinity, 2), [3, 4, 5, 4, 5], + '[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) must return [3, 4, 5, 4, 5]' +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/negative-start.js b/test/sendable/builtins/Array/prototype/copyWithin/negative-start.js new file mode 100644 index 00000000000..ebf4103fe6e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/negative-start.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Set values with negative start argument. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, -1), [3, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, -1) must return [3, 1, 2, 3]' +); +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(2, -2), [0, 1, 3, 4, 4], + '[0, 1, 2, 3, 4].copyWithin(2, -2) must return [0, 1, 3, 4, 4]' +); +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(1, -2), [0, 3, 4, 3, 4], + '[0, 1, 2, 3, 4].copyWithin(1, -2) must return [0, 3, 4, 3, 4]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(-1, -2), [0, 1, 2, 2], + '[0, 1, 2, 3].copyWithin(-1, -2) must return [0, 1, 2, 2]' +); +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(-2, -3), [0, 1, 2, 2, 3], + '[0, 1, 2, 3, 4].copyWithin(-2, -3) must return [0, 1, 2, 2, 3]' +); +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(-5, -2), [3, 4, 2, 3, 4], + '[0, 1, 2, 3, 4].copyWithin(-5, -2) must return [3, 4, 2, 3, 4]' +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/negative-target.js b/test/sendable/builtins/Array/prototype/copyWithin/negative-target.js new file mode 100644 index 00000000000..31cd0a25296 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/negative-target.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Set values with negative target argument. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to + be min(relativeTarget, len). +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(-1, 0), [0, 1, 2, 0], + '[0, 1, 2, 3].copyWithin(-1, 0) must return [0, 1, 2, 0]' +); +assert.compareArray( + [0, 1, 2, 3, 4].copyWithin(-2, 2), [0, 1, 2, 2, 3], + '[0, 1, 2, 3, 4].copyWithin(-2, 2) must return [0, 1, 2, 2, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(-1, 2), [0, 1, 2, 2], + '[0, 1, 2, 3].copyWithin(-1, 2) must return [0, 1, 2, 2]' +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/non-negative-out-of-bounds-end.js b/test/sendable/builtins/Array/prototype/copyWithin/non-negative-out-of-bounds-end.js new file mode 100644 index 00000000000..c754d03447c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/non-negative-out-of-bounds-end.js @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Max value of end position is the this.length. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to + be min(relativeTarget, len). + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 14. Let count be min(final-from, len-to). + 15. If from 0 + a. If fromPresent is true, then + i. Let fromVal be Get(O, fromKey). + iii. Let setStatus be Set(O, toKey, fromVal, true). +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1, 6), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0, 1, 6) must return [1, 2, 3, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1, Infinity), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0, 1, Infinity) must return [1, 2, 3, 3]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6), [0, 3, 4, 5, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6) must return [0, 3, 4, 5, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(1, 3, Infinity), [0, 3, 4, 5, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) must return [0, 3, 4, 5, 4, 5]' +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js b/test/sendable/builtins/Array/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js new file mode 100644 index 00000000000..c2f831b1957 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Max values of target and start positions are this.length. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to + be min(relativeTarget, len). + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 14. Let count be min(final-from, len-to). + 15. If from 0 +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(6, 0), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(6, 0) must return [0, 1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(7, 0), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(7, 0) must return [0, 1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(Infinity, 0), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(Infinity, 0) must return [0, 1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(6, 2), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(6, 2) must return [0, 1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(7, 2), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(7, 2) must return [0, 1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(Infinity, 2), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(Infinity, 2) must return [0, 1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(0, 6), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(0, 6) must return [0, 1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(0, 7), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(0, 7) must return [0, 1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(0, Infinity), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(0, Infinity) must return [0, 1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(2, 6), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(2, 6) must return [0, 1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(1, 7), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(1, 7) must return [0, 1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(3, Infinity), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(3, Infinity) must return [0, 1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(6, 6), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(6, 6) must return [0, 1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(10, 10), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(10, 10) must return [0, 1, 2, 3, 4, 5]' +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(Infinity, Infinity), [0, 1, 2, 3, 4, 5], + '[0, 1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) must return [0, 1, 2, 3, 4, 5]' +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/non-negative-target-and-start.js b/test/sendable/builtins/Array/prototype/copyWithin/non-negative-target-and-start.js new file mode 100644 index 00000000000..cdbb2bf7264 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/non-negative-target-and-start.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Copy values with non-negative target and start positions. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to + be min(relativeTarget, len). + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 14. Let count be min(final-from, len-to). + 15. If from 0 + a. If fromPresent is true, then + i. Let fromVal be Get(O, fromKey). + iii. Let setStatus be Set(O, toKey, fromVal, true). +includes: [compareArray.js] +---*/ + +assert.compareArray( + ['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(0, 0), + ['a', 'b', 'c', 'd', 'e', 'f'] +); +assert.compareArray( + ['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(0, 2), + ['c', 'd', 'e', 'f', 'e', 'f'] +); +assert.compareArray( + ['a', 'b', 'c', 'd', 'e', 'f'].copyWithin(3, 0), + ['a', 'b', 'c', 'a', 'b', 'c'] +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].copyWithin(1, 4), + [0, 4, 5, 3, 4, 5] +); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/non-negative-target-start-and-end.js b/test/sendable/builtins/Array/prototype/copyWithin/non-negative-target-start-and-end.js new file mode 100644 index 00000000000..df2eade4820 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/non-negative-target-start-and-end.js @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Copy values with non-negative target, start and end positions. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to + be min(relativeTarget, len). + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 14. Let count be min(final-from, len-to). + 15. If from 0 + a. If fromPresent is true, then + i. Let fromVal be Get(O, fromKey). + iii. Let setStatus be Set(O, toKey, fromVal, true). +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 0, 0), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, 0, 0) must return [0, 1, 2, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 0, 2), [0, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, 0, 2) must return [0, 1, 2, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1, 2), [1, 1, 2, 3], + '[0, 1, 2, 3].copyWithin(0, 1, 2) must return [1, 1, 2, 3]' +); +/* + * 15. If from + Array.prototype.copyWithin 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(SendableArray.prototype.copyWithin), + false, + 'isConstructor(SendableArray.prototype.copyWithin) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.copyWithin(); +}); + diff --git a/test/sendable/builtins/Array/prototype/copyWithin/prop-desc.js b/test/sendable/builtins/Array/prototype/copyWithin/prop-desc.js new file mode 100644 index 00000000000..e81bb713cfb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/prop-desc.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: Property type and descriptor. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableArray.prototype.copyWithin, + 'function', + '`typeof SendableArray.prototype.copyWithin` is `function`' +); +verifyProperty(SendableArray.prototype, "copyWithin", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/resizable-buffer.js b/test/sendable/builtins/Array/prototype/copyWithin/resizable-buffer.js new file mode 100644 index 00000000000..ef9982c13a1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/resizable-buffer.js @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Array.p.copyWithin behaves correctly when the receiver is backed by + resizable buffer +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +const ArrayCopyWithinHelper = (ta, ...rest) => { + Array.prototype.copyWithin.call(ta, ...rest); +}; +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + // Orig. array: [0, 1, 2, 3] + // [0, 1, 2, 3] << fixedLength + // [2, 3] << fixedLengthWithOffset + // [0, 1, 2, 3, ...] << lengthTracking + // [2, 3, ...] << lengthTrackingWithOffset + ArrayCopyWithinHelper(fixedLength, 0, 2); + assert.compareArray(ToNumbers(fixedLength), [ + 2, + 3, + 2, + 3 + ]); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + ArrayCopyWithinHelper(fixedLengthWithOffset, 0, 1); + assert.compareArray(ToNumbers(fixedLengthWithOffset), [ + 3, + 3 + ]); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + ArrayCopyWithinHelper(lengthTracking, 0, 2); + assert.compareArray(ToNumbers(lengthTracking), [ + 2, + 3, + 2, + 3 + ]); + ArrayCopyWithinHelper(lengthTrackingWithOffset, 0, 1); + assert.compareArray(ToNumbers(lengthTrackingWithOffset), [ + 3, + 3 + ]); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 3; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + // Orig. array: [0, 1, 2] + // [0, 1, 2, ...] << lengthTracking + // [2, ...] << lengthTrackingWithOffset + + assert.compareArray(ToNumbers(fixedLength), []); + assert.compareArray(ToNumbers(fixedLengthWithOffset), []); + + ArrayCopyWithinHelper(fixedLength, 0, 1); + ArrayCopyWithinHelper(fixedLengthWithOffset, 0, 1); + // We'll check below that these were no-op. + assert.compareArray(ToNumbers(fixedLength), []); + assert.compareArray(ToNumbers(fixedLengthWithOffset), []); + assert.compareArray(ToNumbers(lengthTracking), [ + 0, + 1, + 2 + ]); + ArrayCopyWithinHelper(lengthTracking, 0, 1); + assert.compareArray(ToNumbers(lengthTracking), [ + 1, + 2, + 2 + ]); + ArrayCopyWithinHelper(lengthTrackingWithOffset, 0, 1); + assert.compareArray(ToNumbers(lengthTrackingWithOffset), [2]); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + taWrite[0] = MayNeedBigInt(taWrite, 0); + ArrayCopyWithinHelper(fixedLength, 0, 1, 1); + ArrayCopyWithinHelper(fixedLengthWithOffset, 0, 1, 1); + ArrayCopyWithinHelper(lengthTrackingWithOffset, 0, 1, 1); + assert.compareArray(ToNumbers(lengthTracking), [0]); + ArrayCopyWithinHelper(lengthTracking, 0, 0, 1); + assert.compareArray(ToNumbers(lengthTracking), [0]); + // Shrink to zero. + rab.resize(0); + ArrayCopyWithinHelper(fixedLength, 0, 1, 1); + ArrayCopyWithinHelper(fixedLengthWithOffset, 0, 1, 1); + ArrayCopyWithinHelper(lengthTrackingWithOffset, 0, 1, 1); + assert.compareArray(ToNumbers(lengthTracking), []); + ArrayCopyWithinHelper(lengthTracking, 0, 0, 1); + assert.compareArray(ToNumbers(lengthTracking), []); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + // Orig. array: [0, 1, 2, 3, 4, 5] + // [0, 1, 2, 3] << fixedLength + // [2, 3] << fixedLengthWithOffset + // [0, 1, 2, 3, 4, 5, ...] << lengthTracking + // [2, 3, 4, 5, ...] << lengthTrackingWithOffset + ArrayCopyWithinHelper(fixedLength, 0, 2); + assert.compareArray(ToNumbers(fixedLength), [ + 2, + 3, + 2, + 3 + ]); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + ArrayCopyWithinHelper(fixedLengthWithOffset, 0, 1); + assert.compareArray(ToNumbers(fixedLengthWithOffset), [ + 3, + 3 + ]); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + // [0, 1, 2, 3, 4, 5, ...] << lengthTracking + // target ^ ^ start + ArrayCopyWithinHelper(lengthTracking, 0, 2); + assert.compareArray(ToNumbers(lengthTracking), [ + 2, + 3, + 4, + 5, + 4, + 5 + ]); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + // [2, 3, 4, 5, ...] << lengthTrackingWithOffset + // target ^ ^ start + ArrayCopyWithinHelper(lengthTrackingWithOffset, 0, 1); + assert.compareArray(ToNumbers(lengthTrackingWithOffset), [ + 3, + 4, + 5, + 5 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-delete-proxy-target.js b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-delete-proxy-target.js new file mode 100644 index 00000000000..7d4c8d648b7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-delete-proxy-target.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Return abrupt from deleting property value - using Proxy +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 17. Repeat, while count > 0 + a. Let fromKey be ToString(from). + b. Let toKey be ToString(to). + c. Let fromPresent be HasProperty(O, fromKey). + f. Else fromPresent is false, + i. Let deleteStatus be DeletePropertyOrThrow(O, toKey). + ii. ReturnIfAbrupt(deleteStatus). +features: [Proxy] +---*/ + +var o = { + '42': true, + length: 43 +}; +var p = new Proxy(o, { + deleteProperty: function(t, prop) { + if (prop === '42') { + throw new Test262Error(); + } + } +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.copyWithin.call(p, 42, 0); +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-delete-target.js b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-delete-target.js new file mode 100644 index 00000000000..fd9fa51f9de --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-delete-target.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Return abrupt from deleting property value on DeletePropertyOrThrow(O, toKey). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 17. Repeat, while count > 0 + a. Let fromKey be ToString(from). + b. Let toKey be ToString(to). + c. Let fromPresent be HasProperty(O, fromKey). + f. Else fromPresent is false, + i. Let deleteStatus be DeletePropertyOrThrow(O, toKey). + ii. ReturnIfAbrupt(deleteStatus). +---*/ + +var o = { + length: 43 +}; +Object.defineProperty(o, '42', { + configurable: false, + writable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.copyWithin.call(o, 42, 0); +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-end-as-symbol.js b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-end-as-symbol.js new file mode 100644 index 00000000000..37e5cbbb6ee --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-end-as-symbol.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Return abrupt from end as a Symbol. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 12. ReturnIfAbrupt(relativeEnd). +features: [Symbol] +---*/ + +var s = Symbol(1); +assert.throws(TypeError, function() { + [].copyWithin(0, 0, s); +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-end.js b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-end.js new file mode 100644 index 00000000000..69335b1fb83 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-end.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Return abrupt from ToInteger(end). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 12. ReturnIfAbrupt(relativeEnd). +---*/ + +var o1 = { + valueOf: function() { + throw new Test262Error(); + } +}; +assert.throws(Test262Error, function() { + [].copyWithin(0, 0, o1); +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-get-start-value.js b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-get-start-value.js new file mode 100644 index 00000000000..432b3c195d1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-get-start-value.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Return abrupt from getting property value - Get(O, fromKey). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 8. Let relativeStart be ToInteger(start). + 9. ReturnIfAbrupt(relativeStart). + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). + 17. Repeat, while count > 0 + a. Let fromKey be ToString(from). + b. Let toKey be ToString(to). + c. Let fromPresent be HasProperty(O, fromKey). + d. ReturnIfAbrupt(fromPresent). + e. If fromPresent is true, then + i. Let fromVal be Get(O, fromKey). + ii. ReturnIfAbrupt(fromVal). +---*/ + +var o = { + length: 1 +}; +Object.defineProperty(o, '0', { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.copyWithin.call(o, 0, 0); +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-has-start.js b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-has-start.js new file mode 100644 index 00000000000..355e362c7f1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-has-start.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Return abrupt from HasProperty(O, fromKey). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 8. Let relativeStart be ToInteger(start). + 9. ReturnIfAbrupt(relativeStart). + 10. If relativeStart < 0, let from be max((len + relativeStart),0); else let + from be min(relativeStart, len). + 17. Repeat, while count > 0 + a. Let fromKey be ToString(from). + b. Let toKey be ToString(to). + c. Let fromPresent be HasProperty(O, fromKey). + d. ReturnIfAbrupt(fromPresent). +features: [Proxy] +---*/ + +var o = { + '0': 42, + length: 1 +}; +var p = new Proxy(o, { + has: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.copyWithin.call(p, 0, 0); +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-set-target-value.js b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-set-target-value.js new file mode 100644 index 00000000000..60eb0002235 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-set-target-value.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Return abrupt from setting property value - Set(O, toKey, fromVal, true). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 5. Let relativeTarget be ToInteger(target). + 6. ReturnIfAbrupt(relativeTarget). + 7. If relativeTarget < 0, let to be max((len + relativeTarget),0); else let to + be min(relativeTarget, len). + 17. Repeat, while count > 0 + a. Let fromKey be ToString(from). + b. Let toKey be ToString(to). + e. If fromPresent is true, then + iii. Let setStatus be Set(O, toKey, fromVal, true). + iv. ReturnIfAbrupt(setStatus). +---*/ + +var o = { + '0': true, + length: 43 +}; +Object.defineProperty(o, '42', { + set: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.copyWithin.call(o, 42, 0); +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-start-as-symbol.js b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-start-as-symbol.js new file mode 100644 index 00000000000..c4e762b6c03 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-start-as-symbol.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Return abrupt from start as a Symbol. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 8. Let relativeStart be ToInteger(start). + 9. ReturnIfAbrupt(relativeStart). +features: [Symbol] +---*/ + +var s = Symbol(1); +assert.throws(TypeError, function() { + [].copyWithin(0, s); +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-start.js b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-start.js new file mode 100644 index 00000000000..8dde6149dd7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-start.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Return abrupt from ToInteger(start). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 8. Let relativeStart be ToInteger(start). + 9. ReturnIfAbrupt(relativeStart). +---*/ + +var o1 = { + valueOf: function() { + throw new Test262Error(); + } +}; +assert.throws(Test262Error, function() { + [].copyWithin(0, o1); +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-target-as-symbol.js b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-target-as-symbol.js new file mode 100644 index 00000000000..3811276777b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-target-as-symbol.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Return abrupt from target as a Symbol. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 5. Let relativeTarget be ToInteger(target). + 6. ReturnIfAbrupt(relativeTarget). +features: [Symbol] +---*/ + +var s = Symbol(1); +assert.throws(TypeError, function() { + [].copyWithin(s, 0); +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-target.js b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-target.js new file mode 100644 index 00000000000..b7c6938c246 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-target.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Return abrupt from ToInteger(target). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 5. Let relativeTarget be ToInteger(target). + 6. ReturnIfAbrupt(relativeTarget). +---*/ + +var o1 = { + valueOf: function() { + throw new Test262Error(); + } +}; +assert.throws(Test262Error, function() { + [].copyWithin(o1); +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-this-length-as-symbol.js b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-this-length-as-symbol.js new file mode 100644 index 00000000000..00632a63cd9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-this-length-as-symbol.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Return abrupt from ToLength(Get(O, "length")) where length is a Symbol. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let len be ToLength(Get(O, "length")). + 4. ReturnIfAbrupt(len). +features: [Symbol] +---*/ + +var o = {}; +o.length = Symbol(1); +// value argument is given to avoid false positives +assert.throws(TypeError, function() { + [].copyWithin.call(o, 0, 0); +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-this-length.js b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-this-length.js new file mode 100644 index 00000000000..34bf17a0f6e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-this-length.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Return abrupt from ToLength(Get(O, "length")). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let len be ToLength(Get(O, "length")). + 4. ReturnIfAbrupt(len). +---*/ + +var o1 = {}; +Object.defineProperty(o1, 'length', { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + [].copyWithin.call(o1); +}); +var o2 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; +assert.throws(Test262Error, function() { + [].copyWithin.call(o2); +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-this.js b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-this.js new file mode 100644 index 00000000000..80b63dd1632 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-abrupt-from-this.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Return abrupt from ToObject(this value). +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.copyWithin.call(undefined, 0, 0); +}); +assert.throws(TypeError, function() { + SendableArray.prototype.copyWithin.call(null, 0, 0); +}); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/return-this.js b/test/sendable/builtins/Array/prototype/copyWithin/return-this.js new file mode 100644 index 00000000000..24190bdf40a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/return-this.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + Returns `this`. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 18. Return O. +---*/ + +var arr = []; +var result = arr.copyWithin(0, 0); +assert.sameValue(result, arr); +var o = { + length: 0 +}; +result = SendableArray.prototype.copyWithin.call(o, 0, 0); +assert.sameValue(result, o); diff --git a/test/sendable/builtins/Array/prototype/copyWithin/undefined-end.js b/test/sendable/builtins/Array/prototype/copyWithin/undefined-end.js new file mode 100644 index 00000000000..52d8c0329e5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/copyWithin/undefined-end.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.copywithin +description: > + If `end` is undefined, set final position to `this.length`. +info: | + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + 11. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1, undefined), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0, 1, undefined) must return [1, 2, 3, 3]' +); +assert.compareArray( + [0, 1, 2, 3].copyWithin(0, 1), [1, 2, 3, 3], + '[0, 1, 2, 3].copyWithin(0, 1) must return [1, 2, 3, 3]' +); -- Gitee From 756bab51f6649a7fc2d41f0ae2ee84d621e8a25a Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 18 Dec 2024 17:03:07 +0800 Subject: [PATCH 23/93] add new file harness Signed-off-by: zhuzhihui7 --- harness/resizableArrayBufferUtils.js | 152 +++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 harness/resizableArrayBufferUtils.js diff --git a/harness/resizableArrayBufferUtils.js b/harness/resizableArrayBufferUtils.js new file mode 100644 index 00000000000..9dad8ccb83f --- /dev/null +++ b/harness/resizableArrayBufferUtils.js @@ -0,0 +1,152 @@ +// Copyright 2023 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: | + Collection of helper constants and functions for testing resizable array buffers. +defines: + - floatCtors + - ctors + - MyBigInt64Array + - CreateResizableArrayBuffer + - MayNeedBigInt + - Convert + - ToNumbers + - CreateRabForTest + - CollectValuesAndResize + - TestIterationAndResize +features: [BigInt] +---*/ +// Helper to create subclasses without bombing out when `class` isn't supported +function subClass(type) { + try { + return new Function('return class My' + type + ' extends ' + type + ' {}')(); + } catch (e) {} +} + +const MyUint8Array = subClass('Uint8Array'); +const MyFloat32Array = subClass('Float32Array'); +const MyBigInt64Array = subClass('BigInt64Array'); + +const builtinCtors = [ + Uint8Array, + Int8Array, + Uint16Array, + Int16Array, + Uint32Array, + Int32Array, + Float32Array, + Float64Array, + Uint8ClampedArray, +]; + +// Big(U)int64Array and Float16Array are newer features adding them above unconditionally +// would cause implementations lacking it to fail every test which uses it. +if (typeof Float16Array !== 'undefined') { + builtinCtors.push(Float16Array); +} + +if (typeof BigUint64Array !== 'undefined') { + builtinCtors.push(BigUint64Array); +} + +if (typeof BigInt64Array !== 'undefined') { + builtinCtors.push(BigInt64Array); +} + +const floatCtors = [ + Float32Array, + Float64Array, + MyFloat32Array +]; + +if (typeof Float16Array !== 'undefined') { + floatCtors.push(Float16Array); +} + +const ctors = builtinCtors.concat(MyUint8Array, MyFloat32Array); + +if (typeof MyBigInt64Array !== 'undefined') { + ctors.push(MyBigInt64Array); +} + +function CreateResizableArrayBuffer(byteLength, maxByteLength) { + return new ArrayBuffer(byteLength, { maxByteLength: maxByteLength }); +} + +function Convert(item) { + if (typeof item == 'bigint') { + return Number(item); + } + return item; +} + +function ToNumbers(array) { + let result = []; + for (let i = 0; i < array.length; i++) { + let item = array[i]; + result.push(Convert(item)); + } + return result; +} + +function MayNeedBigInt(ta, n) { + assert.sameValue(typeof n, 'number'); + if ((BigInt64Array !== 'undefined' && ta instanceof BigInt64Array) + || (BigUint64Array !== 'undefined' && ta instanceof BigUint64Array)) { + return BigInt(n); + } + return n; +} + +function CreateRabForTest(ctor) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + return rab; +} + +function CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo) { + if (typeof n == 'bigint') { + values.push(Number(n)); + } else { + values.push(n); + } + if (values.length == resizeAfter) { + rab.resize(resizeTo); + } + return true; +} + +function TestIterationAndResize(iterable, expected, rab, resizeAfter, newByteLength) { + let values = []; + let resized = false; + var arrayValues = false; + + for (let value of iterable) { + if (Array.isArray(value)) { + arrayValues = true; + values.push([ + value[0], + Number(value[1]) + ]); + } else { + values.push(Number(value)); + } + if (!resized && values.length == resizeAfter) { + rab.resize(newByteLength); + resized = true; + } + } + if (!arrayValues) { + assert.compareArray([].concat(values), expected, "TestIterationAndResize: list of iterated values"); + } else { + for (let i = 0; i < expected.length; i++) { + assert.compareArray(values[i], expected[i], "TestIterationAndResize: list of iterated lists of values"); + } + } + assert(resized, "TestIterationAndResize: resize condition should have been hit"); +} -- Gitee From e14c782816c687979c0a706946bd831e9d59b637 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 19 Dec 2024 09:19:12 +0800 Subject: [PATCH 24/93] add entries cases Signed-off-by: zhuzhihui7 --- .../prototype/entries/iteration-mutable.js | 41 +++++ .../Array/prototype/entries/iteration.js | 47 +++++ .../Array/prototype/entries/length.js | 30 ++++ .../builtins/Array/prototype/entries/name.js | 30 ++++ .../prototype/entries/not-a-constructor.js | 38 ++++ .../Array/prototype/entries/prop-desc.js | 34 ++++ .../resizable-buffer-grow-mid-iteration.js | 122 +++++++++++++ .../resizable-buffer-shrink-mid-iteration.js | 80 +++++++++ .../prototype/entries/resizable-buffer.js | 164 ++++++++++++++++++ .../entries/return-abrupt-from-this.js | 31 ++++ .../entries/returns-iterator-from-object.js | 36 ++++ .../prototype/entries/returns-iterator.js | 36 ++++ 12 files changed, 689 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/entries/iteration-mutable.js create mode 100644 test/sendable/builtins/Array/prototype/entries/iteration.js create mode 100644 test/sendable/builtins/Array/prototype/entries/length.js create mode 100644 test/sendable/builtins/Array/prototype/entries/name.js create mode 100644 test/sendable/builtins/Array/prototype/entries/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/entries/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/entries/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/entries/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/entries/resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/entries/return-abrupt-from-this.js create mode 100644 test/sendable/builtins/Array/prototype/entries/returns-iterator-from-object.js create mode 100644 test/sendable/builtins/Array/prototype/entries/returns-iterator.js diff --git a/test/sendable/builtins/Array/prototype/entries/iteration-mutable.js b/test/sendable/builtins/Array/prototype/entries/iteration-mutable.js new file mode 100644 index 00000000000..a3c5d1bdf46 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/entries/iteration-mutable.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.entries +description: > + New items in the array are accessible via iteration until iterator is "done". +info: | + The method should return a valid iterator with the context as the + IteratedObject. When an item is added to the array after the iterator is + created but before the iterator is "done" (as defined by 22.1.5.2.1) the + new item should be accessible via iteration. +---*/ + +var SendableArray = []; +var iterator = SendableArray.entries(); +var result; +SendableArray.push('a'); +result = iterator.next(); +assert.sameValue(result.done, false, 'First result `done` flag'); +assert.sameValue(result.value[0], 0, 'First result `value` (array key)'); +assert.sameValue(result.value[1], 'a', 'First result `value (array value)'); +assert.sameValue(result.value.length, 2, 'First result `value` (length)'); +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +SendableArray.push('b'); +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag (after push)'); +assert.sameValue(result.value, undefined, 'Exhausted result `value` (after push)'); diff --git a/test/sendable/builtins/Array/prototype/entries/iteration.js b/test/sendable/builtins/Array/prototype/entries/iteration.js new file mode 100644 index 00000000000..51550e925fb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/entries/iteration.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.entries +description: > + The return is a valid iterator with the array's numeric properties. +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key+value"). +---*/ + +var SendableArray = ['a', 'b', 'c']; +var iterator = array.entries(); +var result; +result = iterator.next(); +assert.sameValue(result.done, false, 'First result `done` flag'); +assert.sameValue(result.value[0], 0, 'First result `value` (array key)'); +assert.sameValue(result.value[1], 'a', 'First result `value` (array value)'); +assert.sameValue(result.value.length, 2, 'First result `value` (length)'); +result = iterator.next(); +assert.sameValue(result.done, false, 'Second result `done` flag'); +assert.sameValue(result.value[0], 1, 'Second result `value` (array key)'); +assert.sameValue(result.value[1], 'b', 'Second result `value` (array value)'); +assert.sameValue(result.value.length, 2, 'Second result `value` (length)'); +result = iterator.next(); +assert.sameValue(result.done, false, 'Third result `done` flag'); +assert.sameValue(result.value[0], 2, 'Third result `value` (array key)'); +assert.sameValue(result.value[1], 'c', 'Third result `value` (array value)'); +assert.sameValue(result.value.length, 2, 'Third result `value` (length)'); +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); diff --git a/test/sendable/builtins/Array/prototype/entries/length.js b/test/sendable/builtins/Array/prototype/entries/length.js new file mode 100644 index 00000000000..b1bbef984ad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/entries/length.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.entries +description: > + Array.prototype.entries.length value and descriptor. +info: | + 22.1.3.4 Array.prototype.entries ( ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.prototype.entries, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/entries/name.js b/test/sendable/builtins/Array/prototype/entries/name.js new file mode 100644 index 00000000000..5974eb0e6d3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/entries/name.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.entries +description: > + Array.prototype.entries.name value and descriptor. +info: | + 22.1.3.4 Array.prototype.entries ( ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.prototype.entries, "name", { + value: "entries", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/entries/not-a-constructor.js b/test/sendable/builtins/Array/prototype/entries/not-a-constructor.js new file mode 100644 index 00000000000..7af70e6e1e5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/entries/not-a-constructor.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.entries 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(SendableArray.prototype.entries), + false, + 'isConstructor(SendableArray.prototype.entries) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.entries(); +}); + diff --git a/test/sendable/builtins/Array/prototype/entries/prop-desc.js b/test/sendable/builtins/Array/prototype/entries/prop-desc.js new file mode 100644 index 00000000000..f2be3e34459 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/entries/prop-desc.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.entries +description: > + Property type and descriptor. +info: | + 22.1.3.4 Array.prototype.entries ( ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableArray.prototype.entries, + 'function', + '`typeof SendableArray.prototype.entries` is `function`' +); +verifyProperty(SendableArray.prototype, "entries", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/entries/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/Array/prototype/entries/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..3910e9821b9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/entries/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.entries +description: > + Array.p.entries behaves correctly when receiver is backed by a resizable + buffer and resized mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function ArrayEntriesHelper(ta) { + return SendableArray.prototype.entries.call(ta); +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +// Iterating with entries() (the 4 loops below). +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + // The fixed length array is not affected by resizing. + TestIterationAndResize(ArrayEntriesHelper(fixedLength), [ + [ + 0, + 0 + ], + [ + 1, + 2 + ], + [ + 2, + 4 + ], + [ + 3, + 6 + ] + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + // The fixed length array is not affected by resizing. + TestIterationAndResize(ArrayEntriesHelper(fixedLengthWithOffset), [ + [ + 0, + 4 + ], + [ + 1, + 6 + ] + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + TestIterationAndResize(ArrayEntriesHelper(lengthTracking), [ + [ + 0, + 0 + ], + [ + 1, + 2 + ], + [ + 2, + 4 + ], + [ + 3, + 6 + ], + [ + 4, + 0 + ], + [ + 5, + 0 + ] + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + TestIterationAndResize(ArrayEntriesHelper(lengthTrackingWithOffset), [ + [ + 0, + 4 + ], + [ + 1, + 6 + ], + [ + 2, + 0 + ], + [ + 3, + 0 + ] + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/Array/prototype/entries/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/Array/prototype/entries/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..0eaefe36c5e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/entries/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.entries +description: > + Array.p.entries behaves correctly when receiver is backed by resizable + buffer that is shrunk mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function ArrayEntriesHelper(ta) { + return SendableArray.prototype.entries.call(ta); +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +// Iterating with entries() (the 4 loops below). +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + // The fixed length array goes out of bounds when the RAB is resized. + assert.throws(TypeError, () => { + TestIterationAndResize(ArrayEntriesHelper(fixedLength), null, rab, 2, 3 * ctor.BYTES_PER_ELEMENT); + }); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + // The fixed length array goes out of bounds when the RAB is resized. + assert.throws(TypeError, () => { + TestIterationAndResize(ArrayEntriesHelper(fixedLengthWithOffset), null, rab, 1, 3 * ctor.BYTES_PER_ELEMENT); + }); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + TestIterationAndResize(ArrayEntriesHelper(lengthTracking), [ + [ + 0, + 0 + ], + [ + 1, + 2 + ], + [ + 2, + 4 + ] + ], rab, 2, 3 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + TestIterationAndResize(ArrayEntriesHelper(lengthTrackingWithOffset), [ + [ + 0, + 4 + ], + [ + 1, + 6 + ] + ], rab, 2, 3 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/Array/prototype/entries/resizable-buffer.js b/test/sendable/builtins/Array/prototype/entries/resizable-buffer.js new file mode 100644 index 00000000000..01fb36fc074 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/entries/resizable-buffer.js @@ -0,0 +1,164 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.entries +description: > + Array.p.entries behaves correctly when receiver is backed by resizable + buffer +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function ArrayEntriesHelper(ta) { + return SendableArray.prototype.entries.call(ta); +} +function ValuesFromArrayEntries(ta) { + let result = []; + let expectedKey = 0; + for (let [key, value] of Array.prototype.entries.call(ta)) { + assert.sameValue(key, expectedKey, 'TypedArray method .entries should return `expectedKey`.'); + ++expectedKey; + result.push(Number(value)); + } + return result; +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + assert.compareArray(ValuesFromArrayEntries(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ValuesFromArrayEntries(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(ValuesFromArrayEntries(lengthTracking), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ValuesFromArrayEntries(lengthTrackingWithOffset), [ + 4, + 6 + ]); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + // TypedArray.prototype.{entries, keys, values} throw right away when + // called. Array.prototype.{entries, keys, values} don't throw, but when + // we try to iterate the returned ArrayIterator, that throws. + ArrayEntriesHelper(fixedLength); + ArrayEntriesHelper(fixedLengthWithOffset); + assert.throws(TypeError, () => { + SendableArray.from(ArrayEntriesHelper(fixedLength)); + }); + assert.throws(TypeError, () => { + SendableArray.from(ArrayEntriesHelper(fixedLengthWithOffset)); + }); + assert.compareArray(ValuesFromArrayEntries(lengthTracking), [ + 0, + 2, + 4 + ]); + assert.compareArray(ValuesFromArrayEntries(lengthTrackingWithOffset), [4]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + ArrayEntriesHelper(fixedLength); + ArrayEntriesHelper(fixedLengthWithOffset); + ArrayEntriesHelper(lengthTrackingWithOffset); + assert.throws(TypeError, () => { + SendableArray.from(ArrayEntriesHelper(fixedLength)); + }); + assert.throws(TypeError, () => { + SendableArray.from(ArrayEntriesHelper(fixedLengthWithOffset)); + }); + assert.throws(TypeError, () => { + SendableArray.from(ArrayEntriesHelper(lengthTrackingWithOffset)); + }); + assert.compareArray(ValuesFromArrayEntries(lengthTracking), [0]); + + // Shrink to zero. + rab.resize(0); + ArrayEntriesHelper(fixedLength); + ArrayEntriesHelper(fixedLengthWithOffset); + ArrayEntriesHelper(lengthTrackingWithOffset); + assert.throws(TypeError, () => { + SendableArray.from(ArrayEntriesHelper(fixedLength)); + }); + assert.throws(TypeError, () => { + SendableArray.from(ArrayEntriesHelper(fixedLengthWithOffset)); + }); + assert.throws(TypeError, () => { + SendableArray.from(ArrayEntriesHelper(lengthTrackingWithOffset)); + }); + assert.compareArray(ValuesFromArrayEntries(lengthTracking), []); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert.compareArray(ValuesFromArrayEntries(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ValuesFromArrayEntries(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(ValuesFromArrayEntries(lengthTracking), [ + 0, + 2, + 4, + 6, + 8, + 10 + ]); + assert.compareArray(ValuesFromArrayEntries(lengthTrackingWithOffset), [ + 4, + 6, + 8, + 10 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/entries/return-abrupt-from-this.js b/test/sendable/builtins/Array/prototype/entries/return-abrupt-from-this.js new file mode 100644 index 00000000000..600d36eff73 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/entries/return-abrupt-from-this.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.entries +description: > + Return abrupt from ToObject(this value). +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.entries.call(undefined); +}); +assert.throws(TypeError, function() { + SendableArray.prototype.entries.call(null); +}); diff --git a/test/sendable/builtins/Array/prototype/entries/returns-iterator-from-object.js b/test/sendable/builtins/Array/prototype/entries/returns-iterator-from-object.js new file mode 100644 index 00000000000..267ea9709f8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/entries/returns-iterator-from-object.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.entries +description: > + Creates an iterator from a custom object. +info: | + 22.1.3.4 Array.prototype.entries ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key+value"). +features: [Symbol.iterator] +---*/ + +var obj = { + length: 2 +}; +var iter = SendableArray.prototype.entries.call(obj); +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].entries() is %ArrayIteratorPrototype%' +); diff --git a/test/sendable/builtins/Array/prototype/entries/returns-iterator.js b/test/sendable/builtins/Array/prototype/entries/returns-iterator.js new file mode 100644 index 00000000000..3c846c3e76f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/entries/returns-iterator.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.entries +description: > + The method should return an Iterator instance. +info: | + 22.1.3.4 Array.prototype.entries ( ) + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key+value"). + 22.1.5.1 CreateArrayIterator Abstract Operation + 2. Let iterator be ObjectCreate(%ArrayIteratorPrototype%, «‍[[IteratedObject]], + [[ArrayIteratorNextIndex]], [[ArrayIterationKind]]»). + 6. Return iterator. +features: [Symbol.iterator] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); +var iter = [].entries(); +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].entries() is %ArrayIteratorPrototype%' +); -- Gitee From 1261a5903a01e0403cc630bf3f57c53d49d5ef65 Mon Sep 17 00:00:00 2001 From: chaocw Date: Thu, 19 Dec 2024 14:38:39 +0800 Subject: [PATCH 25/93] ArraryBuffer name Signed-off-by: chaocw --- test/sendable/builtins/ArrayBuffer/name.js | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 test/sendable/builtins/ArrayBuffer/name.js diff --git a/test/sendable/builtins/ArrayBuffer/name.js b/test/sendable/builtins/ArrayBuffer/name.js new file mode 100644 index 00000000000..0bca8a2795c --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/name.js @@ -0,0 +1,28 @@ +// Copyright (C) 2017 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-constructor +description: > + SendableArrayBuffer.name is "SendableArrayBuffer". +info: | + 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(SendableArrayBuffer.name, "SendableArrayBuffer"); + +verifyProperty(SendableArrayBuffer, "name", { + writable: false, + enumerable: false, + configurable: true, +}); -- Gitee From 3ab0108d5d2545a14f5fbf654fe8a3a644967fa7 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 19 Dec 2024 19:30:31 +0800 Subject: [PATCH 26/93] add new cases-every Signed-off-by: zhuzhihui7 --- .../Array/prototype/every/15.4.4.16-0-1.js | 21 ++++ .../Array/prototype/every/15.4.4.16-1-1.js | 22 ++++ .../Array/prototype/every/15.4.4.16-1-10.js | 25 +++++ .../Array/prototype/every/15.4.4.16-1-11.js | 26 +++++ .../Array/prototype/every/15.4.4.16-1-12.js | 26 +++++ .../Array/prototype/every/15.4.4.16-1-13.js | 25 +++++ .../Array/prototype/every/15.4.4.16-1-14.js | 26 +++++ .../Array/prototype/every/15.4.4.16-1-15.js | 26 +++++ .../Array/prototype/every/15.4.4.16-1-2.js | 22 ++++ .../Array/prototype/every/15.4.4.16-1-3.js | 28 +++++ .../Array/prototype/every/15.4.4.16-1-4.js | 30 +++++ .../Array/prototype/every/15.4.4.16-1-5.js | 28 +++++ .../Array/prototype/every/15.4.4.16-1-6.js | 30 +++++ .../Array/prototype/every/15.4.4.16-1-7.js | 23 ++++ .../Array/prototype/every/15.4.4.16-1-8.js | 24 ++++ .../Array/prototype/every/15.4.4.16-1-9.js | 28 +++++ .../Array/prototype/every/15.4.4.16-2-1.js | 35 ++++++ .../Array/prototype/every/15.4.4.16-2-10.js | 42 +++++++ .../Array/prototype/every/15.4.4.16-2-11.js | 36 ++++++ .../Array/prototype/every/15.4.4.16-2-12.js | 42 +++++++ .../Array/prototype/every/15.4.4.16-2-13.js | 38 +++++++ .../Array/prototype/every/15.4.4.16-2-14.js | 32 ++++++ .../Array/prototype/every/15.4.4.16-2-17.js | 33 ++++++ .../Array/prototype/every/15.4.4.16-2-18.js | 31 ++++++ .../Array/prototype/every/15.4.4.16-2-19.js | 35 ++++++ .../Array/prototype/every/15.4.4.16-2-2.js | 28 +++++ .../Array/prototype/every/15.4.4.16-2-3.js | 39 +++++++ .../Array/prototype/every/15.4.4.16-2-4.js | 33 ++++++ .../Array/prototype/every/15.4.4.16-2-5.js | 46 ++++++++ .../Array/prototype/every/15.4.4.16-2-6.js | 38 +++++++ .../Array/prototype/every/15.4.4.16-2-7.js | 39 +++++++ .../Array/prototype/every/15.4.4.16-2-8.js | 44 ++++++++ .../Array/prototype/every/15.4.4.16-2-9.js | 48 ++++++++ .../Array/prototype/every/15.4.4.16-3-1.js | 30 +++++ .../Array/prototype/every/15.4.4.16-3-10.js | 32 ++++++ .../Array/prototype/every/15.4.4.16-3-11.js | 35 ++++++ .../Array/prototype/every/15.4.4.16-3-12.js | 35 ++++++ .../Array/prototype/every/15.4.4.16-3-13.js | 35 ++++++ .../Array/prototype/every/15.4.4.16-3-14.js | 40 +++++++ .../Array/prototype/every/15.4.4.16-3-15.js | 35 ++++++ .../Array/prototype/every/15.4.4.16-3-16.js | 35 ++++++ .../Array/prototype/every/15.4.4.16-3-17.js | 35 ++++++ .../Array/prototype/every/15.4.4.16-3-18.js | 33 ++++++ .../Array/prototype/every/15.4.4.16-3-19.js | 47 ++++++++ .../Array/prototype/every/15.4.4.16-3-2.js | 34 ++++++ .../Array/prototype/every/15.4.4.16-3-20.js | 42 +++++++ .../Array/prototype/every/15.4.4.16-3-21.js | 49 +++++++++ .../Array/prototype/every/15.4.4.16-3-22.js | 50 +++++++++ .../Array/prototype/every/15.4.4.16-3-23.js | 55 +++++++++ .../Array/prototype/every/15.4.4.16-3-24.js | 35 ++++++ .../Array/prototype/every/15.4.4.16-3-25.js | 33 ++++++ .../Array/prototype/every/15.4.4.16-3-29.js | 34 ++++++ .../Array/prototype/every/15.4.4.16-3-3.js | 30 +++++ .../Array/prototype/every/15.4.4.16-3-4.js | 30 +++++ .../Array/prototype/every/15.4.4.16-3-5.js | 30 +++++ .../Array/prototype/every/15.4.4.16-3-6.js | 35 ++++++ .../Array/prototype/every/15.4.4.16-3-7.js | 35 ++++++ .../Array/prototype/every/15.4.4.16-3-8.js | 33 ++++++ .../Array/prototype/every/15.4.4.16-3-9.js | 33 ++++++ .../Array/prototype/every/15.4.4.16-4-1.js | 24 ++++ .../Array/prototype/every/15.4.4.16-4-10.js | 35 ++++++ .../Array/prototype/every/15.4.4.16-4-11.js | 39 +++++++ .../Array/prototype/every/15.4.4.16-4-12.js | 24 ++++ .../Array/prototype/every/15.4.4.16-4-15.js | 46 ++++++++ .../Array/prototype/every/15.4.4.16-4-3.js | 24 ++++ .../Array/prototype/every/15.4.4.16-4-4.js | 25 +++++ .../Array/prototype/every/15.4.4.16-4-5.js | 25 +++++ .../Array/prototype/every/15.4.4.16-4-6.js | 25 +++++ .../Array/prototype/every/15.4.4.16-4-7.js | 27 +++++ .../Array/prototype/every/15.4.4.16-4-8.js | 38 +++++++ .../Array/prototype/every/15.4.4.16-4-9.js | 42 +++++++ .../Array/prototype/every/15.4.4.16-5-1-s.js | 29 +++++ .../Array/prototype/every/15.4.4.16-5-1.js | 28 +++++ .../Array/prototype/every/15.4.4.16-5-10.js | 28 +++++ .../Array/prototype/every/15.4.4.16-5-11.js | 28 +++++ .../Array/prototype/every/15.4.4.16-5-12.js | 28 +++++ .../Array/prototype/every/15.4.4.16-5-13.js | 28 +++++ .../Array/prototype/every/15.4.4.16-5-14.js | 27 +++++ .../Array/prototype/every/15.4.4.16-5-15.js | 28 +++++ .../Array/prototype/every/15.4.4.16-5-16.js | 28 +++++ .../Array/prototype/every/15.4.4.16-5-17.js | 27 +++++ .../Array/prototype/every/15.4.4.16-5-18.js | 28 +++++ .../Array/prototype/every/15.4.4.16-5-19.js | 31 ++++++ .../Array/prototype/every/15.4.4.16-5-2.js | 29 +++++ .../Array/prototype/every/15.4.4.16-5-21.js | 28 +++++ .../Array/prototype/every/15.4.4.16-5-22.js | 27 +++++ .../Array/prototype/every/15.4.4.16-5-23.js | 27 +++++ .../Array/prototype/every/15.4.4.16-5-24.js | 27 +++++ .../Array/prototype/every/15.4.4.16-5-3.js | 29 +++++ .../Array/prototype/every/15.4.4.16-5-4.js | 31 ++++++ .../Array/prototype/every/15.4.4.16-5-5.js | 29 +++++ .../Array/prototype/every/15.4.4.16-5-6.js | 29 +++++ .../Array/prototype/every/15.4.4.16-5-7.js | 26 +++++ .../Array/prototype/every/15.4.4.16-5-9.js | 27 +++++ .../Array/prototype/every/15.4.4.16-7-1.js | 32 ++++++ .../Array/prototype/every/15.4.4.16-7-2.js | 31 ++++++ .../Array/prototype/every/15.4.4.16-7-3.js | 31 ++++++ .../Array/prototype/every/15.4.4.16-7-4.js | 31 ++++++ .../Array/prototype/every/15.4.4.16-7-5.js | 33 ++++++ .../Array/prototype/every/15.4.4.16-7-6.js | 34 ++++++ .../Array/prototype/every/15.4.4.16-7-7.js | 33 ++++++ .../Array/prototype/every/15.4.4.16-7-8.js | 31 ++++++ .../Array/prototype/every/15.4.4.16-7-9.js | 40 +++++++ .../Array/prototype/every/15.4.4.16-7-b-1.js | 31 ++++++ .../Array/prototype/every/15.4.4.16-7-b-10.js | 40 +++++++ .../Array/prototype/every/15.4.4.16-7-b-11.js | 37 +++++++ .../Array/prototype/every/15.4.4.16-7-b-12.js | 44 ++++++++ .../Array/prototype/every/15.4.4.16-7-b-13.js | 39 +++++++ .../Array/prototype/every/15.4.4.16-7-b-14.js | 36 ++++++ .../Array/prototype/every/15.4.4.16-7-b-15.js | 43 ++++++++ .../Array/prototype/every/15.4.4.16-7-b-16.js | 44 ++++++++ .../Array/prototype/every/15.4.4.16-7-b-2.js | 35 ++++++ .../Array/prototype/every/15.4.4.16-7-b-3.js | 39 +++++++ .../Array/prototype/every/15.4.4.16-7-b-4.js | 44 ++++++++ .../Array/prototype/every/15.4.4.16-7-b-5.js | 42 +++++++ .../Array/prototype/every/15.4.4.16-7-b-6.js | 44 ++++++++ .../Array/prototype/every/15.4.4.16-7-b-7.js | 42 +++++++ .../Array/prototype/every/15.4.4.16-7-b-8.js | 44 ++++++++ .../Array/prototype/every/15.4.4.16-7-b-9.js | 42 +++++++ .../prototype/every/15.4.4.16-7-c-i-1.js | 34 ++++++ .../prototype/every/15.4.4.16-7-c-i-10.js | 36 ++++++ .../prototype/every/15.4.4.16-7-c-i-11.js | 44 ++++++++ .../prototype/every/15.4.4.16-7-c-i-12.js | 37 +++++++ .../prototype/every/15.4.4.16-7-c-i-13.js | 47 ++++++++ .../prototype/every/15.4.4.16-7-c-i-14.js | 42 +++++++ .../prototype/every/15.4.4.16-7-c-i-15.js | 40 +++++++ .../prototype/every/15.4.4.16-7-c-i-16.js | 35 ++++++ .../prototype/every/15.4.4.16-7-c-i-17.js | 35 ++++++ .../prototype/every/15.4.4.16-7-c-i-18.js | 33 ++++++ .../prototype/every/15.4.4.16-7-c-i-19.js | 37 +++++++ .../prototype/every/15.4.4.16-7-c-i-2.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-i-20.js | 35 ++++++ .../prototype/every/15.4.4.16-7-c-i-21.js | 37 +++++++ .../prototype/every/15.4.4.16-7-c-i-22.js | 32 ++++++ .../prototype/every/15.4.4.16-7-c-i-25.js | 32 ++++++ .../prototype/every/15.4.4.16-7-c-i-26.js | 38 +++++++ .../prototype/every/15.4.4.16-7-c-i-27.js | 38 +++++++ .../prototype/every/15.4.4.16-7-c-i-28.js | 44 ++++++++ .../prototype/every/15.4.4.16-7-c-i-29.js | 46 ++++++++ .../prototype/every/15.4.4.16-7-c-i-3.js | 38 +++++++ .../prototype/every/15.4.4.16-7-c-i-30.js | 44 ++++++++ .../prototype/every/15.4.4.16-7-c-i-31.js | 41 +++++++ .../prototype/every/15.4.4.16-7-c-i-4.js | 30 +++++ .../prototype/every/15.4.4.16-7-c-i-5.js | 46 ++++++++ .../prototype/every/15.4.4.16-7-c-i-6.js | 34 ++++++ .../prototype/every/15.4.4.16-7-c-i-7.js | 37 +++++++ .../prototype/every/15.4.4.16-7-c-i-8.js | 30 +++++ .../prototype/every/15.4.4.16-7-c-i-9.js | 39 +++++++ .../prototype/every/15.4.4.16-7-c-ii-1.js | 26 +++++ .../prototype/every/15.4.4.16-7-c-ii-10.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-ii-11.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-ii-12.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-ii-13.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-ii-16.js | 32 ++++++ .../prototype/every/15.4.4.16-7-c-ii-17.js | 32 ++++++ .../prototype/every/15.4.4.16-7-c-ii-18.js | 32 ++++++ .../prototype/every/15.4.4.16-7-c-ii-19.js | 32 ++++++ .../prototype/every/15.4.4.16-7-c-ii-2.js | 27 +++++ .../prototype/every/15.4.4.16-7-c-ii-20.js | 34 ++++++ .../prototype/every/15.4.4.16-7-c-ii-21.js | 40 +++++++ .../prototype/every/15.4.4.16-7-c-ii-22.js | 40 +++++++ .../prototype/every/15.4.4.16-7-c-ii-23.js | 33 ++++++ .../prototype/every/15.4.4.16-7-c-ii-3.js | 33 ++++++ .../prototype/every/15.4.4.16-7-c-ii-4.js | 35 ++++++ .../prototype/every/15.4.4.16-7-c-ii-5.js | 40 +++++++ .../prototype/every/15.4.4.16-7-c-ii-6.js | 34 ++++++ .../prototype/every/15.4.4.16-7-c-ii-7.js | 39 +++++++ .../prototype/every/15.4.4.16-7-c-ii-8.js | 33 ++++++ .../prototype/every/15.4.4.16-7-c-ii-9.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-1.js | 30 +++++ .../prototype/every/15.4.4.16-7-c-iii-10.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-11.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-12.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-13.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-14.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-15.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-16.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-17.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-18.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-19.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-2.js | 30 +++++ .../prototype/every/15.4.4.16-7-c-iii-20.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-21.js | 26 +++++ .../prototype/every/15.4.4.16-7-c-iii-22.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-23.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-24.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-25.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-27.js | 29 +++++ .../prototype/every/15.4.4.16-7-c-iii-28.js | 50 +++++++++ .../prototype/every/15.4.4.16-7-c-iii-29.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-3.js | 32 ++++++ .../prototype/every/15.4.4.16-7-c-iii-4.js | 32 ++++++ .../prototype/every/15.4.4.16-7-c-iii-5.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-6.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-7.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-8.js | 28 +++++ .../prototype/every/15.4.4.16-7-c-iii-9.js | 28 +++++ .../Array/prototype/every/15.4.4.16-8-1.js | 22 ++++ .../Array/prototype/every/15.4.4.16-8-10.js | 32 ++++++ .../Array/prototype/every/15.4.4.16-8-11.js | 30 +++++ .../Array/prototype/every/15.4.4.16-8-12.js | 32 ++++++ .../Array/prototype/every/15.4.4.16-8-13.js | 30 +++++ .../Array/prototype/every/15.4.4.16-8-2.js | 28 +++++ .../Array/prototype/every/15.4.4.16-8-3.js | 28 +++++ .../Array/prototype/every/15.4.4.16-8-4.js | 28 +++++ .../Array/prototype/every/15.4.4.16-8-5.js | 28 +++++ .../Array/prototype/every/15.4.4.16-8-6.js | 33 ++++++ .../Array/prototype/every/15.4.4.16-8-7.js | 38 +++++++ .../Array/prototype/every/15.4.4.16-8-8.js | 41 +++++++ .../prototype/every/call-with-boolean.js | 29 +++++ .../every/callbackfn-resize-arraybuffer.js | 76 +++++++++++++ .../builtins/Array/prototype/every/length.js | 30 +++++ .../builtins/Array/prototype/every/name.js | 36 ++++++ .../prototype/every/not-a-constructor.js | 39 +++++++ .../Array/prototype/every/prop-desc.js | 32 ++++++ .../resizable-buffer-grow-mid-iteration.js | 93 ++++++++++++++++ .../resizable-buffer-shrink-mid-iteration.js | 84 ++++++++++++++ .../Array/prototype/every/resizable-buffer.js | 104 ++++++++++++++++++ 218 files changed, 7443 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-0-1.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-1.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-10.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-11.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-12.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-13.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-14.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-15.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-2.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-3.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-4.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-5.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-6.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-7.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-8.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-1-9.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-1.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-10.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-11.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-12.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-13.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-14.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-17.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-18.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-19.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-2.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-3.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-4.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-5.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-6.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-7.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-8.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-2-9.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-1.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-10.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-11.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-12.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-13.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-14.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-15.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-16.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-17.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-18.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-19.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-2.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-20.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-21.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-22.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-23.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-24.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-25.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-29.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-3.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-4.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-5.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-6.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-7.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-8.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-3-9.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-4-1.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-4-10.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-4-11.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-4-12.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-4-15.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-4-3.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-4-4.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-4-5.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-4-6.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-4-7.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-4-8.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-4-9.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-1-s.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-1.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-10.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-11.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-12.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-13.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-14.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-15.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-16.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-17.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-18.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-19.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-2.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-21.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-22.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-23.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-24.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-3.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-4.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-5.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-6.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-7.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-5-9.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-1.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-2.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-3.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-4.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-5.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-6.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-7.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-8.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-9.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-1.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-10.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-11.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-12.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-13.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-14.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-15.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-16.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-2.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-3.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-4.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-5.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-6.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-7.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-8.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-9.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-1.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-10.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-11.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-12.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-13.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-14.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-15.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-16.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-17.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-18.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-19.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-2.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-20.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-21.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-22.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-25.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-26.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-27.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-28.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-29.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-3.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-30.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-31.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-4.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-5.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-6.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-7.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-8.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-9.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-1.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-10.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-11.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-12.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-13.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-16.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-17.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-18.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-19.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-2.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-20.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-21.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-22.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-23.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-3.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-4.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-5.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-6.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-7.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-8.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-9.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-1.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-10.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-11.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-12.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-13.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-14.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-15.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-16.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-17.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-18.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-19.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-2.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-20.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-21.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-22.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-23.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-24.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-25.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-27.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-28.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-29.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-3.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-4.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-5.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-6.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-7.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-8.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-9.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-8-1.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-8-10.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-8-11.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-8-12.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-8-13.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-8-2.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-8-3.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-8-4.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-8-5.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-8-6.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-8-7.js create mode 100644 test/sendable/builtins/Array/prototype/every/15.4.4.16-8-8.js create mode 100644 test/sendable/builtins/Array/prototype/every/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/every/callbackfn-resize-arraybuffer.js create mode 100644 test/sendable/builtins/Array/prototype/every/length.js create mode 100644 test/sendable/builtins/Array/prototype/every/name.js create mode 100644 test/sendable/builtins/Array/prototype/every/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/every/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/every/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/every/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/every/resizable-buffer.js diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-0-1.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-0-1.js new file mode 100644 index 00000000000..c46aaacba40 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-0-1.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every must exist as a function +---*/ + +var f = SendableArray.prototype.every; +assert.sameValue(typeof(f), "function", 'typeof(f)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-1.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-1.js new file mode 100644 index 00000000000..ba60ef99953 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to undefined throws a TypeError +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.every.call(undefined); // TypeError is thrown if value is undefined +}); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-10.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-10.js new file mode 100644 index 00000000000..3d0ba9ed0c5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-10.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to the Math object +---*/ + +function callbackfn(val, idx, obj) { + return ('[object Math]' !== Object.prototype.toString.call(obj)); +} +Math.length = 1; +Math[0] = 1; +assert.sameValue(SendableArray.prototype.every.call(Math, callbackfn), false, 'SendableArray.prototype.every.call(Math, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-11.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-11.js new file mode 100644 index 00000000000..a5c44af33d4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-11.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to Date object +---*/ + +function callbackfn(val, idx, obj) { + return !(obj instanceof Date); +} +var obj = new Date(0); +obj.length = 1; +obj[0] = 1; +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-12.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-12.js new file mode 100644 index 00000000000..82743960cd8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-12.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to RegExp object +---*/ + +function callbackfn(val, idx, obj) { + return !(obj instanceof RegExp); +} +var obj = new RegExp(); +obj.length = 1; +obj[0] = 1; +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-13.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-13.js new file mode 100644 index 00000000000..3e034e084c5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-13.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to the JSON object +---*/ + +function callbackfn(val, idx, obj) { + return ('[object JSON]' !== Object.prototype.toString.call(obj)); +} +JSON.length = 1; +JSON[0] = 1; +assert.sameValue(SendableArray.prototype.every.call(JSON, callbackfn), false, 'SendableArray.prototype.every.call(JSON, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-14.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-14.js new file mode 100644 index 00000000000..f311195cf90 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-14.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to Error object +---*/ + +function callbackfn(val, idx, obj) { + return !(obj instanceof Error); +} +var obj = new Error(); +obj.length = 1; +obj[0] = 1; +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-15.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-15.js new file mode 100644 index 00000000000..534c0d3785d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-15.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to the Arguments object +---*/ + +function callbackfn(val, idx, obj) { + return ('[object Arguments]' !== Object.prototype.toString.call(obj)); +} +var obj = (function fun() { + return arguments; +}("a", "b")); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-2.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-2.js new file mode 100644 index 00000000000..cd035218d29 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-2.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to null throws a TypeError +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.every.call(null); // TypeError is thrown if value is null +}); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-3.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-3.js new file mode 100644 index 00000000000..887d05ba8bf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-3.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to boolean primitive +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return obj instanceof Boolean; +} +Boolean.prototype[0] = 1; +Boolean.prototype.length = 1; +assert(SendableArray.prototype.every.call(false, callbackfn), 'SendableArray.prototype.every.call(false, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-4.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-4.js new file mode 100644 index 00000000000..54d0bc0cd41 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to Boolean object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return obj instanceof Boolean; +} +var obj = new Boolean(true); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-5.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-5.js new file mode 100644 index 00000000000..f1bfdbf5c32 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-5.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to number primitive +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return obj instanceof Number; +} +Number.prototype[0] = 1; +Number.prototype.length = 1; +assert(SendableArray.prototype.every.call(2.5, callbackfn), 'SendableArray.prototype.every.call(2.5, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-6.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-6.js new file mode 100644 index 00000000000..8778d458961 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-6.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to Number object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return obj instanceof Number; +} +var obj = new Number(-128); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-7.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-7.js new file mode 100644 index 00000000000..58d772af737 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-7.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to string primitive +---*/ + +function callbackfn(val, idx, obj) { + return !(obj instanceof String); +} +assert.sameValue(SendableArray.prototype.every.call("hello\nworld\\!", callbackfn), false, 'SendableArray.prototype.every.call("hello\nworld\\!", callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-8.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-8.js new file mode 100644 index 00000000000..973b3cb7749 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-8.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to String object +---*/ + +function callbackfn(val, idx, obj) { + return !(obj instanceof String); +} +var obj = new String("hello\nworld\\!"); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-9.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-9.js new file mode 100644 index 00000000000..a8c5b306042 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-1-9.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to Function object +---*/ + +function callbackfn(val, idx, obj) { + return !(obj instanceof Function); +} +var obj = function(a, b) { + return a + b; +}; +obj[0] = 11; +obj[1] = 9; +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-1.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-1.js new file mode 100644 index 00000000000..1abf1b0b352 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-1.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + own data property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-10.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-10.js new file mode 100644 index 00000000000..ba25d501848 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-10.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + inherited accessor property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert(SendableArray.prototype.every.call(child, callbackfn1), 'SendableArray.prototype.every.call(child, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(child, callbackfn2), false, 'SendableArray.prototype.every.call(child, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-11.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-11.js new file mode 100644 index 00000000000..e9bf86c7d8c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-11.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + own accessor property without a get function +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 9, + 1: 8 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-12.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-12.js new file mode 100644 index 00000000000..5b0d898f01c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-12.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is own accessor property without + a get function that overrides an inherited accessor property +---*/ +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var obj = { + 0: 9, + 1: 8 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-13.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-13.js new file mode 100644 index 00000000000..5207799f311 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-13.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to the Array-like object that + 'length' is inherited accessor property without a get function +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 9; +child[1] = 8; +assert(SendableArray.prototype.every.call(child, callbackfn), 'SendableArray.prototype.every.call(child, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-14.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-14.js new file mode 100644 index 00000000000..237e480e232 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-14.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to the Array-like object that + 'length' property doesn't exist +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + 1: 12 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-17.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-17.js new file mode 100644 index 00000000000..bc9ff5fead8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-17.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to the Arguments object, which + implements its own property get method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var func = function(a, b) { + arguments[2] = 9; + return SendableArray.prototype.every.call(arguments, callbackfn1) && + !SendableArray.prototype.every.call(arguments, callbackfn2); +}; +assert(func(12, 11), 'func(12, 11) !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-18.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-18.js new file mode 100644 index 00000000000..d30dfb474da --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-18.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to String object, which implements + its own property get method +---*/ + +function callbackfn1(val, idx, obj) { + return parseInt(val, 10) > 1; +} +function callbackfn2(val, idx, obj) { + return parseInt(val, 10) > 2; +} +var str = new String("432"); +String.prototype[3] = "1"; +assert(SendableArray.prototype.every.call(str, callbackfn1), 'SendableArray.prototype.every.call(str, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(str, callbackfn2), false, 'SendableArray.prototype.every.call(str, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-19.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-19.js new file mode 100644 index 00000000000..5cf0571999c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-19.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Function object, which implements + its own property get method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var fun = function(a, b) { + return a + b; +}; +fun[0] = 12; +fun[1] = 11; +fun[2] = 9; +assert(SendableArray.prototype.every.call(fun, callbackfn1), 'SendableArray.prototype.every.call(fun, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(fun, callbackfn2), false, 'SendableArray.prototype.every.call(fun, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-2.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-2.js new file mode 100644 index 00000000000..8de1cec4d08 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - 'length' is own data property on an Array +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +SendableArray.prototype[2] = 9; +assert([12, 11].every(callbackfn1), '[12, 11].every(callbackfn1) !== true'); +assert.sameValue([12, 11].every(callbackfn2), false, '[12, 11].every(callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-3.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-3.js new file mode 100644 index 00000000000..cecbbc3747d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-3.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + own data property that overrides an inherited data property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var proto = { + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert(SendableArray.prototype.every.call(child, callbackfn1), 'SendableArray.prototype.every.call(child, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(child, callbackfn2), false, 'SendableArray.prototype.every.call(child, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-4.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-4.js new file mode 100644 index 00000000000..77ced97130d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-4.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is own data property that + overrides an inherited data property on an Array +---*/ + +var arrProtoLen = 0; +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +arrProtoLen = Array.prototype.length; +SendableArray.prototype.length = 0; +SendableArray.prototype[2] = 9; +assert([12, 11].every(callbackfn1), '[12, 11].every(callbackfn1) !== true'); +assert.sameValue([12, 11].every(callbackfn2), false, '[12, 11].every(callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-5.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-5.js new file mode 100644 index 00000000000..5655481d3d6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-5.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + own data property that overrides an inherited accessor property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +assert(SendableArray.prototype.every.call(child, callbackfn1), 'SendableArray.prototype.every.call(child, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(child, callbackfn2), false, 'SendableArray.prototype.every.call(child, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-6.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-6.js new file mode 100644 index 00000000000..7fd9ea554c0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-6.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + inherited data property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var proto = { + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert(SendableArray.prototype.every.call(child, callbackfn1), 'SendableArray.prototype.every.call(child, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(child, callbackfn2), false, 'SendableArray.prototype.every.call(child, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-7.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-7.js new file mode 100644 index 00000000000..146ef2a5920 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-7.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + own accessor property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); +obj[0] = 12; +obj[1] = 11; +obj[2] = 9; +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-8.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-8.js new file mode 100644 index 00000000000..2060a80b559 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-8.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + own accessor property that overrides an inherited data property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var proto = { + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert(SendableArray.prototype.every.call(child, callbackfn1), 'SendableArray.prototype.every.call(child, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(child, callbackfn2), false, 'SendableArray.prototype.every.call(child, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-9.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-9.js new file mode 100644 index 00000000000..a9444f754c7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-2-9.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every applied to Array-like object, 'length' is an + own accessor property that overrides an inherited accessor property +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert(SendableArray.prototype.every.call(child, callbackfn1), 'SendableArray.prototype.every.call(child, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(child, callbackfn2), false, 'SendableArray.prototype.every.call(child, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-1.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-1.js new file mode 100644 index 00000000000..5eec5b797c3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - value of 'length' is undefined +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 9, + length: undefined +}; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-10.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-10.js new file mode 100644 index 00000000000..b913be3a20c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-10.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is a number (value is + NaN) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 9, + length: NaN +}; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-11.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-11.js new file mode 100644 index 00000000000..a570bd79f0b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-11.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is a string containing a positive + number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "2" +}; +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-12.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-12.js new file mode 100644 index 00000000000..8b1bbcfbfec --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-12.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is a string containing a negative + number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 11, + 1: 12, + 2: 9, + length: "-4294967294" +}; +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert(SendableArray.prototype.every.call(obj, callbackfn2), 'SendableArray.prototype.every.call(obj, callbackfn2) !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-13.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-13.js new file mode 100644 index 00000000000..10ce67576f3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-13.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is a string containing a decimal + number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "2.5" +}; +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-14.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-14.js new file mode 100644 index 00000000000..1ece97444af --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-14.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - 'length' is a string containing +/-Infinity +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var objOne = { + 0: 9, + length: "Infinity" +}; +var objTwo = { + 0: 9, + length: "+Infinity" +}; +var objThree = { + 0: 9, + length: "-Infinity" +}; +assert.sameValue(SendableArray.prototype.every.call(objOne, callbackfn), false, 'SendableArray.prototype.every.call(objOne, callbackfn)'); +assert.sameValue(SendableArray.prototype.every.call(objTwo, callbackfn), false, 'SendableArray.prototype.every.call(objTwo, callbackfn)'); +assert(SendableArray.prototype.every.call(objThree, callbackfn), 'SendableArray.prototype.every.call(objThree, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-15.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-15.js new file mode 100644 index 00000000000..d58408398c6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-15.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is a string containing an + exponential number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "2E0" +}; +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-16.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-16.js new file mode 100644 index 00000000000..251bf527660 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-16.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is a string containing a hex + number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "0x0002" +}; +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-17.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-17.js new file mode 100644 index 00000000000..2f3b8d73462 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-17.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is a string containing a number + with leading zeros +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "0002.00" +}; +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-18.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-18.js new file mode 100644 index 00000000000..8130416582e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-18.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is a string that can't + convert to a number +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 9, + 1: 8, + length: "two" +}; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-19.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-19.js new file mode 100644 index 00000000000..d8ae9b91c9d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-19.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is an Object which has + an own toString method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var toStringAccessed = false; +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: { + toString: function() { + toStringAccessed = true; + return '2'; + } + } +}; +// objects inherit the default valueOf() method from Object +// that simply returns itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); +assert(toStringAccessed, 'toStringAccessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-2.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-2.js new file mode 100644 index 00000000000..d1e3f257838 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-2.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every on an Array-like object if 'length' is 1 + (length overridden to true(type conversion)) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 11, + 1: 9, + length: true +}; +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-20.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-20.js new file mode 100644 index 00000000000..74e4d6e908b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-20.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is an Object which has + an own valueOf method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var valueOfAccessed = false; +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: { + valueOf: function() { + valueOfAccessed = true; + return 2; + } + } +}; +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-21.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-21.js new file mode 100644 index 00000000000..f248a9af35b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-21.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'length' is an object that has an own + valueOf method that returns an object and toString method that + returns a string +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var toStringAccessed = false; +var valueOfAccessed = false; +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: { + valueOf: function() { + valueOfAccessed = true; + return {}; + }, + toString: function() { + toStringAccessed = true; + return '2'; + } + } +}; +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert(toStringAccessed, 'toStringAccessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-22.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-22.js new file mode 100644 index 00000000000..41b48f75d95 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-22.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every throws TypeError exception when 'length' is + an object with toString and valueOf methods that don�t return + primitive values +---*/ + +var callbackfnAccessed = false; +var toStringAccessed = false; +var valueOfAccessed = false; +function callbackfn(val, idx, obj) { + callbackfnAccessed = true; + return val > 10; +} +var obj = { + 0: 11, + 1: 12, + + length: { + valueOf: function() { + valueOfAccessed = true; + return {}; + }, + toString: function() { + toStringAccessed = true; + return {}; + } + } +}; +assert.throws(TypeError, function() { + SendableArray.prototype.every.call(obj, callbackfn); +}); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(callbackfnAccessed, false, 'callbackfnAccessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-23.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-23.js new file mode 100644 index 00000000000..2002231d343 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-23.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every uses inherited valueOf method when 'length' + is an object with an own toString and inherited valueOf methods +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var valueOfAccessed = false; +var toStringAccessed = false; +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "toString", { + value: function() { + toStringAccessed = true; + return '1'; + } +}); +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: child +}; + +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-24.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-24.js new file mode 100644 index 00000000000..0cdd168ba7d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-24.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2.685 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-25.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-25.js new file mode 100644 index 00000000000..c1860668eef --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-25.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - value of 'length' is a negative non-integer +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: -4294967294.5 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert(SendableArray.prototype.every.call(obj, callbackfn2), 'SendableArray.prototype.every.call(obj, callbackfn2) !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-29.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-29.js new file mode 100644 index 00000000000..33dc9e7a7e6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-29.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is boundary value (2^32 + + 1) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 11, + 1: 9, + length: 4294967297 +}; +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn1), false, 'SendableArray.prototype.every.call(obj, callbackfn1)'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-3.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-3.js new file mode 100644 index 00000000000..81372e82e32 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-3.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - value of 'length' is a number (value is 0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 9, + length: 0 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-4.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-4.js new file mode 100644 index 00000000000..fb8f5160463 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - value of 'length' is a number (value is +0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 9, + length: +0 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-5.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-5.js new file mode 100644 index 00000000000..8436f04dead --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-5.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - value of 'length' is a number (value is -0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 9, + length: -0 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-6.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-6.js new file mode 100644 index 00000000000..178fd93fc26 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is a number (value is + positive) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn2), false, 'SendableArray.prototype.every.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-7.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-7.js new file mode 100644 index 00000000000..4c90d2d3649 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-7.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - value of 'length' is a number (value is + negative) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: -4294967294 +}; //length used to exec while loop is 0 +assert(SendableArray.prototype.every.call(obj, callbackfn1), 'SendableArray.prototype.every.call(obj, callbackfn1) !== true'); +assert(SendableArray.prototype.every.call(obj, callbackfn2), 'SendableArray.prototype.every.call(obj, callbackfn2) !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-8.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-8.js new file mode 100644 index 00000000000..166009d930a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-8.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-3-8 +description: > + Array.prototype.every - value of 'length' is a number (value is + Infinity) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 9, + length: Infinity +}; +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-9.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-9.js new file mode 100644 index 00000000000..9ba6ffea922 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-3-9.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-3-9 +description: > + Array.prototype.every - value of 'length' is a number (value is + -Infinity) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 9, + length: -Infinity +}; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-1.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-1.js new file mode 100644 index 00000000000..888e824d3f3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-1.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-1 +description: Array.prototype.every throws TypeError if callbackfn is undefined +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.every(); +}); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-10.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-10.js new file mode 100644 index 00000000000..5594665fd81 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-10.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-10 +description: > + Array.prototype.every - the exception is not thrown if exception + was thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.every.call(obj, undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-11.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-11.js new file mode 100644 index 00000000000..f2890e13f79 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-11.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-11 +description: > + Array.prototype.every - the exception is not thrown if exception + was thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.every.call(obj, undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-12.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-12.js new file mode 100644 index 00000000000..2622b95fe1d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-12.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-12 +description: Array.prototype.every - 'callbackfn' is a function +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +assert.sameValue([11, 9].every(callbackfn), false, '[11, 9].every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-15.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-15.js new file mode 100644 index 00000000000..5ff333ffc6f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-15.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-15 +description: > + Array.prototype.every - calling with no callbackfn is the same as + passing undefined for callbackfn +---*/ + +var obj = { + 10: 10 +}; +var lengthAccessed = false; +var loopAccessed = false; +Object.defineProperty(obj, "length", { + get: function() { + lengthAccessed = true; + return 20; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + loopAccessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.every.call(obj); +}); +assert(lengthAccessed, 'lengthAccessed !== true'); +assert.sameValue(loopAccessed, false, 'loopAccessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-3.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-3.js new file mode 100644 index 00000000000..901357ecd2f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-3.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-3 +description: Array.prototype.every throws TypeError if callbackfn is null +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.every(null); +}); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-4.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-4.js new file mode 100644 index 00000000000..3c927147c70 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-4.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-4 +description: Array.prototype.every throws TypeError if callbackfn is boolean +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.every(true); +}); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-5.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-5.js new file mode 100644 index 00000000000..b473c5dd656 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-5.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-5 +description: Array.prototype.every throws TypeError if callbackfn is number +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.every(5); +}); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-6.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-6.js new file mode 100644 index 00000000000..1366b99bf62 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-6.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-6 +description: Array.prototype.every throws TypeError if callbackfn is string +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.every("abc"); +}); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-7.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-7.js new file mode 100644 index 00000000000..f8460cec1f9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-7.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-7 +description: > + Array.prototype.every throws TypeError if callbackfn is Object + without a Call internal method +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.every({}); +}); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-8.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-8.js new file mode 100644 index 00000000000..81e25997740 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-8.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-8 +description: > + Array.prototype.every - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.every.call(obj, null); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-9.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-9.js new file mode 100644 index 00000000000..8c93a50df24 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-4-9.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-4-9 +description: > + Array.prototype.every - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.every.call(obj, null); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-1-s.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-1-s.js new file mode 100644 index 00000000000..5da287c9959 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-1-s.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-1-s +description: Array.prototype.every - thisArg not passed to strict callbackfn +flags: [noStrict] +---*/ + +var innerThisCorrect = false; +function callbackfn(val, idx, obj) { + "use strict"; + innerThisCorrect = this === undefined; + return true; +} +[1].every(callbackfn); +assert(innerThisCorrect, 'innerThisCorrect !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-1.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-1.js new file mode 100644 index 00000000000..a1ec4b91841 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-1.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-1 +description: Array.prototype.every - thisArg not passed +flags: [noStrict] +---*/ + +var global = this; +function callbackfn(val, idx, obj) +{ + return this === global; +} +var arr = [1]; +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-10.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-10.js new file mode 100644 index 00000000000..38da0b5e9b3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-10.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-10 +description: Array.prototype.every - Array Object can be used as thisArg +---*/ + +var accessed = false; +var objArray = []; +function callbackfn(val, idx, obj) { + accessed = true; + return this === objArray; +} +assert([11].every(callbackfn, objArray), '[11].every(callbackfn, objArray) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-11.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-11.js new file mode 100644 index 00000000000..8aabe58a928 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-11.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-11 +description: Array.prototype.every - String Object can be used as thisArg +---*/ + +var accessed = false; +var objString = new String(); +function callbackfn(val, idx, obj) { + accessed = true; + return this === objString; +} +assert([11].every(callbackfn, objString), '[11].every(callbackfn, objString) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-12.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-12.js new file mode 100644 index 00000000000..31dd7a4843f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-12.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-12 +description: Array.prototype.every - Boolean Object can be used as thisArg +---*/ + +var accessed = false; +var objBoolean = new Boolean(); +function callbackfn(val, idx, obj) { + accessed = true; + return this === objBoolean; +} +assert([11].every(callbackfn, objBoolean), '[11].every(callbackfn, objBoolean) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-13.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-13.js new file mode 100644 index 00000000000..63962fa1877 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-13.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-13 +description: Array.prototype.every - Number Object can be used as thisArg +---*/ + +var accessed = false; +var objNumber = new Number(); +function callbackfn(val, idx, obj) { + accessed = true; + return this === objNumber; +} +assert([11].every(callbackfn, objNumber), '[11].every(callbackfn, objNumber) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-14.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-14.js new file mode 100644 index 00000000000..6ef23469d00 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-14.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-14 +description: Array.prototype.every - the Math object can be used as thisArg +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this === Math; +} +assert([11].every(callbackfn, Math), '[11].every(callbackfn, Math) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-15.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-15.js new file mode 100644 index 00000000000..42ed2f75c71 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-15.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-15 +description: Array.prototype.every - Date Object can be used as thisArg +---*/ + +var accessed = false; +var objDate = new Date(0); +function callbackfn(val, idx, obj) { + accessed = true; + return this === objDate; +} +assert([11].every(callbackfn, objDate), '[11].every(callbackfn, objDate) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-16.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-16.js new file mode 100644 index 00000000000..5c56dc047ce --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-16.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-16 +description: Array.prototype.every - RegExp Object can be used as thisArg +---*/ + +var accessed = false; +var objRegExp = new RegExp(); +function callbackfn(val, idx, obj) { + accessed = true; + return this === objRegExp; +} +assert([11].every(callbackfn, objRegExp), '[11].every(callbackfn, objRegExp) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-17.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-17.js new file mode 100644 index 00000000000..15ec234416d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-17.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-17 +description: Array.prototype.every - the JSON object can be used as thisArg +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this === JSON; +} +assert([11].every(callbackfn, JSON), '[11].every(callbackfn, JSON) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-18.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-18.js new file mode 100644 index 00000000000..428bc99670a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-18.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-18 +description: Array.prototype.every - Error Object can be used as thisArg +---*/ + +var accessed = false; +var objError = new RangeError(); +function callbackfn(val, idx, obj) { + accessed = true; + return this === objError; +} +assert([11].every(callbackfn, objError), '[11].every(callbackfn, objError) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-19.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-19.js new file mode 100644 index 00000000000..e1e33cb527b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-19.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-19 +description: Array.prototype.every - the Arguments object can be used as thisArg +---*/ + +var accessed = false; +var arg; +function callbackfn(val, idx, obj) { + accessed = true; + return this === arg; +} +(function fun() { + arg = arguments; +}(1, 2, 3)); +assert([11].every(callbackfn, arg), '[11].every(callbackfn, arg) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-2.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-2.js new file mode 100644 index 00000000000..fe61fcc15cd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-2.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-2 +description: Array.prototype.every - thisArg is Object +---*/ + +var res = false; +var o = new Object(); +o.res = true; +function callbackfn(val, idx, obj) +{ + return this.res; +} +var arr = [1]; +assert.sameValue(arr.every(callbackfn, o), true, 'arr.every(callbackfn, o)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-21.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-21.js new file mode 100644 index 00000000000..d445022e64a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-21.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-21 +description: Array.prototype.every - the global object can be used as thisArg +---*/ + +var global = this; +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this === global; +} +assert([11].every(callbackfn, global), '[11].every(callbackfn, global) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-22.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-22.js new file mode 100644 index 00000000000..fea3054f7e1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-22.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-22 +description: Array.prototype.every - boolean primitive can be used as thisArg +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this.valueOf() === false; +} +assert([11].every(callbackfn, false), '[11].every(callbackfn, false) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-23.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-23.js new file mode 100644 index 00000000000..290cf08ad43 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-23.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-23 +description: Array.prototype.every - number primitive can be used as thisArg +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this.valueOf() === 101; +} +assert([11].every(callbackfn, 101), '[11].every(callbackfn, 101) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-24.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-24.js new file mode 100644 index 00000000000..87c9c942cd4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-24.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-24 +description: Array.prototype.every - string primitive can be used as thisArg +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this.valueOf() === "abc"; +} +assert([11].every(callbackfn, "abc"), '[11].every(callbackfn, "abc") !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-3.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-3.js new file mode 100644 index 00000000000..75f0b9d3ad1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-3.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +es5id: 15.4.4.16-5-3 +description: Array.prototype.every - thisArg is Array +---*/ + +var res = false; +var a = new Array(); +a.res = true; +function callbackfn(val, idx, obj) +{ + return this.res; +} +var arr = [1]; +assert.sameValue(arr.every(callbackfn, a), true, 'arr.every(callbackfn, a)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-4.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-4.js new file mode 100644 index 00000000000..442862faa89 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-4.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - thisArg is object from object + template(prototype) +---*/ + +var res = false; +function callbackfn(val, idx, obj) +{ + return this.res; +} +function foo() {} +foo.prototype.res = true; +var f = new foo(); +var arr = [1]; +assert.sameValue(arr.every(callbackfn, f), true, 'arr.every(callbackfn,f)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-5.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-5.js new file mode 100644 index 00000000000..d809a83fbea --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-5.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - thisArg is object from object template +---*/ + +var res = false; +function callbackfn(val, idx, obj) +{ + return this.res; +} +function foo() {} +var f = new foo(); +f.res = true; +var arr = [1]; +assert.sameValue(arr.every(callbackfn, f), true, 'arr.every(callbackfn,f)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-6.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-6.js new file mode 100644 index 00000000000..61e9a38d6fb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-6.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - thisArg is function +---*/ + +var res = false; +function callbackfn(val, idx, obj) +{ + return this.res; +} +function foo() {} +foo.res = true; +var arr = [1]; +assert.sameValue(arr.every(callbackfn, foo), true, 'arr.every(callbackfn,foo)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-7.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-7.js new file mode 100644 index 00000000000..7d9f06db897 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-7.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - built-in functions can be used as thisArg +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this === eval; +} +assert([11].every(callbackfn, eval), '[11].every(callbackfn, eval) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-9.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-9.js new file mode 100644 index 00000000000..9c3be55d9fe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-5-9.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - Function Object can be used as thisArg +---*/ + +var accessed = false; +var objFunction = function() {}; +function callbackfn(val, idx, obj) { + accessed = true; + return this === objFunction; +} +assert([11].every(callbackfn, objFunction), '[11].every(callbackfn, objFunction) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-1.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-1.js new file mode 100644 index 00000000000..bcc861daec5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-1.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every considers new elements added to array after + the call +---*/ + +var calledForThree = false; +function callbackfn(val, Idx, obj) +{ + arr[2] = 3; + if (val == 3) + calledForThree = true; + return true; +} +var arr = [1, 2, , 4, 5]; +var res = arr.every(callbackfn); +assert(calledForThree, 'calledForThree !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-2.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-2.js new file mode 100644 index 00000000000..e709ff7f6e7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-2.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every considers new value of elements in array + after the call +---*/ + +function callbackfn(val, Idx, obj) +{ + arr[4] = 6; + if (val < 6) + return true; + else + return false; +} +var arr = [1, 2, 3, 4, 5]; +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-3.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-3.js new file mode 100644 index 00000000000..ae4bf4e0ff5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-3.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every doesn't visit deleted elements in array + after the call +---*/ + +function callbackfn(val, Idx, obj) +{ + delete arr[2]; + if (val == 3) + return false; + else + return true; +} +var arr = [1, 2, 3, 4, 5]; +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-4.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-4.js new file mode 100644 index 00000000000..0bfff155eca --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-4.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every doesn't visit deleted elements when + Array.length is decreased +---*/ + +function callbackfn(val, Idx, obj) +{ + arr.length = 3; + if (val < 4) + return true; + else + return false; +} +var arr = [1, 2, 3, 4, 6]; +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-5.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-5.js new file mode 100644 index 00000000000..bf320ffd53f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-5.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every doesn't consider newly added elements in + sparse array +---*/ + +function callbackfn(val, Idx, obj) +{ + arr[1000] = 3; + if (val < 3) + return true; + else + return false; +} +var arr = new SendableArray(10); +arr[1] = 1; +arr[2] = 2; +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-6.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-6.js new file mode 100644 index 00000000000..36fe6298738 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-6.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every visits deleted element in array after the + call when same index is also present in prototype +---*/ + +function callbackfn(val, Idx, obj) +{ + delete arr[2]; + if (val == 3) + return false; + else + return true; +} +SendableArray.prototype[2] = 3; +var arr = [1, 2, 3, 4, 5]; +var res = arr.every(callbackfn); +delete SendableArray.prototype[2]; +assert.sameValue(res, false, 'res'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-7.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-7.js new file mode 100644 index 00000000000..8030d563fc5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-7.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - Deleting the array itself within the + callbackfn of Array.prototype.every is successful once + Array.prototype.every is called for all elements +---*/ + +var o = new Object(); +o.arr = [1, 2, 3, 4, 5]; +function callbackfn(val, Idx, obj) { + delete o.arr; + if (val === Idx + 1) + return true; + else + return false; +} +assert(o.arr.every(callbackfn), 'o.arr.every(callbackfn) !== true'); +assert.sameValue(o.hasOwnProperty("arr"), false, 'o.hasOwnProperty("arr")'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-8.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-8.js new file mode 100644 index 00000000000..d169054880b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-8.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - no observable effects occur if len is 0 +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + 1: 12, + length: 0 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-9.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-9.js new file mode 100644 index 00000000000..6219d33b1af --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-9.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - modifications to length don't change + number of iterations +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + return val > 10; +} +var obj = { + 1: 12, + 2: 9, + length: 2 +}; +Object.defineProperty(obj, "0", { + get: function() { + obj.length = 3; + return 11; + }, + configurable: true +}); +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-1.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-1.js new file mode 100644 index 00000000000..65d6d9ed258 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn not called for indexes never + been assigned values +---*/ + +var callCnt = 0.; +function callbackfn(val, Idx, obj) +{ + callCnt++; + return true; +} +var arr = new SendableArray(10); +arr[1] = undefined; +arr.every(callbackfn); +assert.sameValue(callCnt, 1, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-10.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-10.js new file mode 100644 index 00000000000..197f335693e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-10.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - deleting property of prototype causes + prototype index property not to be visited on an Array-like Object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return idx !== 1; +} +var arr = { + 2: 2, + length: 20 +}; +Object.defineProperty(arr, "0", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +assert(SendableArray.prototype.every.call(arr, callbackfn), 'SendableArray.prototype.every.call(arr, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-11.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-11.js new file mode 100644 index 00000000000..6a2faff2d46 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-11.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - deleting property of prototype causes + prototype index property not to be visited on an Array +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return idx !== 1; +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + delete Array.prototype[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +assert(arr.every(callbackfn), 'arr.every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-12.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-12.js new file mode 100644 index 00000000000..df5b10b4681 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-12.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return false; + } else { + return true; + } +} +var arr = { + 0: 0, + 1: 111, + 2: 2, + length: 10 +}; +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +assert.sameValue(SendableArray.prototype.every.call(arr, callbackfn), false, 'SendableArray.prototype.every.call(arr, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-13.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-13.js new file mode 100644 index 00000000000..31bc700e9f8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-13.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return false; + } else { + return true; + } +} +var arr = [0, 111, 2]; + +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-14.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-14.js new file mode 100644 index 00000000000..1bda458c197 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-14.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - decreasing length of array causes index + property not to be visited +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return idx !== 3; +} +var arr = [0, 1, 2, "last"]; +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); +assert(arr.every(callbackfn), 'arr.every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-15.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-15.js new file mode 100644 index 00000000000..892c99c2c55 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-15.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - decreasing length of array with prototype + property causes prototype index property to be visited +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "prototype") { + return false; + } else { + return true; + } +} +var arr = [0, 1, 2]; +Object.defineProperty(Array.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-16.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-16.js new file mode 100644 index 00000000000..d2ae124cb86 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-16.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - decreasing length of array does not delete + non-configurable properties +flags: [noStrict] +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "unconfigurable") { + return false; + } else { + return true; + } +} +var arr = [0, 1, 2]; +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-2.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-2.js new file mode 100644 index 00000000000..256c24912a9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-2.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - added properties in step 2 are visible here +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "length") { + return false; + } else { + return true; + } +} +var arr = {}; +Object.defineProperty(arr, "length", { + get: function() { + arr[2] = "length"; + return 3; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.every.call(arr, callbackfn), false, 'SendableArray.prototype.every.call(arr, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-3.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-3.js new file mode 100644 index 00000000000..66eae653b64 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-3.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - deleted properties in step 2 are visible + here +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return idx !== 2; +} +var arr = { + 2: 6.99, + 8: 19 +}; +Object.defineProperty(arr, "length", { + get: function() { + delete arr[2]; + return 10; + }, + configurable: true +}); +assert(SendableArray.prototype.every.call(arr, callbackfn), 'SendableArray.prototype.every.call(arr, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-4.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-4.js new file mode 100644 index 00000000000..9ef30bc9ac1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-4.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - properties added into own object after + current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return false; + } else { + return true; + } +} +var arr = { + length: 2 +}; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.every.call(arr, callbackfn), false, 'SendableArray.prototype.every.call(arr, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-5.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-5.js new file mode 100644 index 00000000000..cf9b24c5e24 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-5.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - properties added into own object after + current position are visited on an Array +---*/ +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return false; + } else { + return true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-6.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-6.js new file mode 100644 index 00000000000..a7bfded0f79 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-6.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - properties can be added to prototype after + current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + return false; + } else { + return true; + } +} +var arr = { + length: 2 +}; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.every.call(arr, callbackfn), false, 'SendableArray.prototype.every.call(arr, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-7.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-7.js new file mode 100644 index 00000000000..fc6b368cd06 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-7.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - properties can be added to prototype after + current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + return false; + } else { + return true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-8.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-8.js new file mode 100644 index 00000000000..ca00b666f09 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-8.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - deleting own property causes index + property not to be visited on an Array-like object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return idx !== 1; +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-9.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-9.js new file mode 100644 index 00000000000..f85470478f3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-b-9.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - deleting own property causes index + property not to be visited on an Array +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return idx !== 1; +} +var arr = [1, 2]; +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +assert(arr.every(callbackfn), 'arr.every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-1.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-1.js new file mode 100644 index 00000000000..5bd647c7742 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-1.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own data + property on an Array-like object +---*/ + +var kValue = {}; +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val !== kValue; + } else { + return true; + } +} +var obj = { + 5: kValue, + length: 100 +}; +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-10.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-10.js new file mode 100644 index 00000000000..fe3d88da61c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-10.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2) { + return val !== 12; + } else { + return true; + } +} +var arr = []; +Object.defineProperty(arr, "2", { + get: function() { + return 12; + }, + configurable: true +}); +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-11.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-11.js new file mode 100644 index 00000000000..0bb3b44ef44 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-11.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 5; + } else { + return true; + } +} +var proto = { + 0: 5, + 1: 6 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 10; +Object.defineProperty(child, "0", { + get: function() { + return 11; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.every.call(child, callbackfn), false, 'SendableArray.prototype.every.call(child, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-12.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-12.js new file mode 100644 index 00000000000..97db543d9b0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-12.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 10; + } else { + return true; + } +} +var arr = []; +SendableArray.prototype[0] = 10; +Object.defineProperty(arr, "0", { + get: function() { + return 111; + }, + configurable: true +}); +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-13.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-13.js new file mode 100644 index 00000000000..5c1a50fc99e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-13.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === 6; + } else { + return true; + } +} +var proto = {}; +Object.defineProperty(proto, "1", { + get: function() { + return 6; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 10; +Object.defineProperty(child, "1", { + get: function() { + return 12; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.every.call(child, callbackfn), false, 'SendableArray.prototype.every.call(child, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-14.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-14.js new file mode 100644 index 00000000000..58e21ad67c4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-14.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 5; + } else { + return true; + } +} +var arr = []; +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 5; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + return 11; + }, + configurable: true +}); +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-15.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-15.js new file mode 100644 index 00000000000..6f96b7080b8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-15.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val !== 11; + } else { + return true; + } +} +var proto = {}; +Object.defineProperty(proto, "1", { + get: function() { + return 11; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 20; +assert.sameValue(SendableArray.prototype.every.call(child, callbackfn), false, 'SendableArray.prototype.every.call(child, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-16.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-16.js new file mode 100644 index 00000000000..75c84edcca1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-16.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is inherited + accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val !== 11; + } else { + return true; + } +} +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 11; + }, + configurable: true +}); +assert.sameValue([, , , ].every(callbackfn), false, '[, , , ].every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-17.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-17.js new file mode 100644 index 00000000000..adfe68419fe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-17.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return typeof val === "undefined"; +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-18.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-18.js new file mode 100644 index 00000000000..71d83854c0a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-18.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return typeof val === "undefined"; +} +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +assert(arr.every(callbackfn), 'arr.every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-19.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-19.js new file mode 100644 index 00000000000..bcb8d30cb1d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-19.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return typeof val === "undefined"; +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); +Object.prototype[1] = 10; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-2.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-2.js new file mode 100644 index 00000000000..f3d2d2d6faf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own data + property on an Array +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + return val === 11; +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert.sameValue(called, 1, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-20.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-20.js new file mode 100644 index 00000000000..2fd8e1483f8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-20.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return typeof val === "undefined"; +} +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +SendableArray.prototype[0] = 100; +assert(arr.every(callbackfn), 'arr.every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-21.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-21.js new file mode 100644 index 00000000000..6670a239027 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-21.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return typeof val === "undefined"; +} +var proto = {}; +Object.defineProperty(proto, "1", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +assert(SendableArray.prototype.every.call(child, callbackfn), 'SendableArray.prototype.every.call(child, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-22.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-22.js new file mode 100644 index 00000000000..cab59cad96a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-22.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return typeof val === "undefined"; +} +Object.defineProperty(SendableArray.prototype, "0", { + set: function() {}, + configurable: true +}); +assert([, ].every(callbackfn), '[, ].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-25.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-25.js new file mode 100644 index 00000000000..355c129f47f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-25.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - This object is the Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + return val === 11; +} +var func = function(a, b) { + return SendableArray.prototype.every.call(arguments, callbackfn); +}; +assert(func(11), 'func(11) !== true'); +assert.sameValue(called, 1, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-26.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-26.js new file mode 100644 index 00000000000..7ca8c28a42a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-26.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - This object is the Arguments object which + implements its own property get method (number of arguments equals + number of parameters) +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + if (idx === 0) { + return val === 11; + } else if (idx === 1) { + return val === 9; + } else { + return false; + } +} +var func = function(a, b) { + return SendableArray.prototype.every.call(arguments, callbackfn); +}; +assert(func(11, 9), 'func(11, 9) !== true'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-27.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-27.js new file mode 100644 index 00000000000..d21dbb5d231 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-27.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - This object is the Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + if (idx < 2) { + return val > 10; + } else if (idx === 2) { + return val < 10; + } else { + return false; + } +} +var func = function(a, b) { + return SendableArray.prototype.every.call(arguments, callbackfn); +}; +assert(func(11, 12, 9), 'func(11, 12, 9) !== true'); +assert.sameValue(called, 3, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-28.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-28.js new file mode 100644 index 00000000000..d3d62c07bf6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-28.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element changed by getter on previous + iterations is observed on an Array +---*/ + +var preIterVisible = false; +var arr = []; +function callbackfn(val, idx, obj) { + return val > 10; +} +Object.defineProperty(arr, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 11; + } + }, + configurable: true +}); +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-29.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-29.js new file mode 100644 index 00000000000..c1b101a37a2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-29.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element changed by getter on previous + iterations is observed on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var preIterVisible = false; +var obj = { + length: 2 +}; +Object.defineProperty(obj, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 13; + } + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-3.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-3.js new file mode 100644 index 00000000000..23fb5adb751 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-3.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val === 100; + } else { + return true; + } +} +var proto = { + 0: 11, + 5: 100 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[5] = "abc"; +child.length = 10; +assert.sameValue(SendableArray.prototype.every.call(child, callbackfn), false, 'SendableArray.prototype.every.call(child, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-30.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-30.js new file mode 100644 index 00000000000..65e71989fd4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-30.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - unnhandled exceptions happened in getter + terminate iteration on an Array-like object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } + return true; +} +var obj = { + 0: 11, + 5: 10, + 10: 8, + length: 20 +}; +Object.defineProperty(obj, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + SendableArray.prototype.every.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-31.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-31.js new file mode 100644 index 00000000000..ea06edfb2b7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-31.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - unhandled exceptions happened in getter + terminate iteration on an Array +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } + return true; +} +var arr = []; +arr[5] = 10; +arr[10] = 100; +Object.defineProperty(arr, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.every(callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-4.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-4.js new file mode 100644 index 00000000000..3efec07535d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + return val === 12; +} +SendableArray.prototype[0] = 11; +SendableArray.prototype[1] = 11; +assert([12, 12].every(callbackfn), '[12, 12].every(callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-5.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-5.js new file mode 100644 index 00000000000..1cbe342439a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-5.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 5; + } else { + return true; + } +} +var proto = {}; +Object.defineProperty(proto, "0", { + get: function() { + return 5; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +Object.defineProperty(child, "0", { + value: 11, + configurable: true +}); +child[1] = 12; +assert.sameValue(SendableArray.prototype.every.call(child, callbackfn), false, 'SendableArray.prototype.every.call(child, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-6.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-6.js new file mode 100644 index 00000000000..82f67eeec95 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-6.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val === 11; +} +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 9; + }, + configurable: true +}); +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-7.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-7.js new file mode 100644 index 00000000000..8691e989e96 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-7.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is inherited data + property on an Array-like object +---*/ + +var kValue = 'abc'; +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val !== kValue; + } else { + return true; + } +} +var proto = { + 5: kValue +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 10; +assert.sameValue(SendableArray.prototype.every.call(child, callbackfn), false, 'SendableArray.prototype.every.call(child, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-8.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-8.js new file mode 100644 index 00000000000..fd37043f850 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-8.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is inherited data + property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val !== 13; + } else { + return true; + } +} +SendableArray.prototype[1] = 13; +assert.sameValue([, , , ].every(callbackfn), false, '[, , , ].every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-9.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-9.js new file mode 100644 index 00000000000..5e0b14b04ca --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-i-9.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element to be retrieved is own accessor + property on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val !== 11; + } else { + return true; + } +} +var obj = { + 10: 10, + length: 20 +}; +Object.defineProperty(obj, "0", { + get: function() { + return 11; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-1.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-1.js new file mode 100644 index 00000000000..5eace82d008 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-1.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - callbackfn called with correct parameters +---*/ + +function callbackfn(val, Idx, obj) +{ + if (obj[Idx] === val) + return true; +} +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-10.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-10.js new file mode 100644 index 00000000000..1feb4cc4605 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-10.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn is called with 1 formal + parameter +---*/ + +var called = 0; +function callbackfn(val) { + called++; + return val > 10; +} +assert([11, 12].every(callbackfn), '[11, 12].every(callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-11.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-11.js new file mode 100644 index 00000000000..17d1fd6034b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-11.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn is called with 2 formal + parameter +---*/ + +var called = 0; +function callbackfn(val, idx) { + called++; + return val > 10 && arguments[2][idx] === val; +} +assert([11, 12].every(callbackfn), '[11, 12].every(callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-12.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-12.js new file mode 100644 index 00000000000..f77a2a3293a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-12.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn is called with 3 formal + parameter +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + return val > 10 && obj[idx] === val; +} +assert([11, 12, 13].every(callbackfn), '[11, 12, 13].every(callbackfn) !== true'); +assert.sameValue(called, 3, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-13.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-13.js new file mode 100644 index 00000000000..1ae7d87a49b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-13.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn that uses arguments object to + get parameter value +---*/ + +var called = 0; +function callbackfn() { + called++; + return arguments[2][arguments[1]] === arguments[0]; +} +assert([11, 12].every(callbackfn), '[11, 12].every(callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-16.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-16.js new file mode 100644 index 00000000000..6f4942b52b4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-16.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'this' of 'callbackfn' is a Boolean object + when T is not an object (T is a boolean primitive) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this.valueOf() !== false; +} +var obj = { + 0: 11, + length: 2 +}; +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn, false), false, 'SendableArray.prototype.every.call(obj, callbackfn, false)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-17.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-17.js new file mode 100644 index 00000000000..5698cf20764 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-17.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every -'this' of 'callbackfn' is a Number object + when T is not an object (T is a number primitive) +---*/ + +var accessed = false; +function callbackfn(val, idx, o) { + accessed = true; + return 5 === this.valueOf(); +} +var obj = { + 0: 11, + length: 2 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn, 5), 'SendableArray.prototype.every.call(obj, callbackfn, 5) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-18.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-18.js new file mode 100644 index 00000000000..f35d1ad44d9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-18.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - 'this' of 'callbackfn' is an String object + when T is not an object (T is a string primitive) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return 'hello' === this.valueOf(); +} +var obj = { + 0: 11, + length: 2 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn, "hello"), 'SendableArray.prototype.every.call(obj, callbackfn, "hello") !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-19.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-19.js new file mode 100644 index 00000000000..d0733969731 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-19.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - non-indexed properties are not called +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + return val !== 8; +} +var obj = { + 0: 11, + 10: 12, + non_index_property: 8, + length: 20 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-2.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-2.js new file mode 100644 index 00000000000..8a3c72d1be6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-2.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - callbackfn takes 3 arguments +---*/ + +function callbackfn(val, Idx, obj) +{ + if (arguments.length === 3) //verify if callbackfn was called with 3 parameters + return true; +} +var arr = [0, 1, true, null, new Object(), "five"]; +arr[999999] = -6.6; +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-20.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-20.js new file mode 100644 index 00000000000..bd312b72dff --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-20.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn called with correct parameters + (thisArg is correct) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return 10 === this.threshold; +} +var thisArg = { + threshold: 10 +}; +var obj = { + 0: 11, + length: 1 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn, thisArg), 'SendableArray.prototype.every.call(obj, callbackfn, thisArg) !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-21.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-21.js new file mode 100644 index 00000000000..74415599517 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-21.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn called with correct parameters + (kValue is correct) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + if (idx === 0) { + return val === 11; + } + + if (idx === 1) { + return val === 12; + } + +} +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-22.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-22.js new file mode 100644 index 00000000000..ae16199330d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-22.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn called with correct parameters + (the index k is correct) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + if (val === 11) { + return idx === 0; + } + + if (val === 12) { + return idx === 1; + } + +} +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-23.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-23.js new file mode 100644 index 00000000000..f5e1bbcab08 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-23.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn called with correct parameters + (this object O is correct) +---*/ + +var called = 0; +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +function callbackfn(val, idx, o) { + called++; + return obj === o; +} +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-3.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-3.js new file mode 100644 index 00000000000..f1770d84355 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-3.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every immediately returns false if callbackfn + returns false +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + callCnt++; + if (idx > 5) + return false; + else + return true; +} +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +assert.sameValue(arr.every(callbackfn), false, 'arr.every(callbackfn)'); +assert.sameValue(callCnt, 7, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-4.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-4.js new file mode 100644 index 00000000000..42e19095dc0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-4.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - k values are passed in ascending numeric + order +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +var lastIdx = 0; +var called = 0; +function callbackfn(val, idx, o) { + called++; + if (lastIdx !== idx) { + return false; + } else { + lastIdx++; + return true; + } +} +assert(arr.every(callbackfn), 'arr.every(callbackfn) !== true'); +assert.sameValue(arr.length, called, 'arr.length'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-5.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-5.js new file mode 100644 index 00000000000..520584fbe36 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-5.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - k values are accessed during each + iteration and not prior to starting the loop on an Array +---*/ + +var called = 0; +var kIndex = []; +//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(val, idx, obj) { + called++; + //Each position should be visited one time, which means k is accessed one time during iterations. + if (typeof kIndex[idx] === "undefined") { + //when current position is visited, its previous index should has been visited. + if (idx !== 0 && typeof kIndex[idx - 1] === "undefined") { + return false; + } + kIndex[idx] = 1; + return true; + } else { + return false; + } +} +assert([11, 12, 13, 14].every(callbackfn, undefined), '[11, 12, 13, 14].every(callbackfn, undefined) !== true'); +assert.sameValue(called, 4, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-6.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-6.js new file mode 100644 index 00000000000..57c4782d128 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-6.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - arguments to callbackfn are self consistent +---*/ + +var accessed = false; +var thisArg = {}; +var obj = { + 0: 11, + length: 1 +}; +function callbackfn() { + accessed = true; + return this === thisArg && + arguments[0] === 11 && + arguments[1] === 0 && + arguments[2] === obj; +} +assert(SendableArray.prototype.every.call(obj, callbackfn, thisArg), 'SendableArray.prototype.every.call(obj, callbackfn, thisArg) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-7.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-7.js new file mode 100644 index 00000000000..62a7a74f9d6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-7.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - unhandled exceptions happened in + callbackfn terminate iteration +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + if (called === 1) { + throw new Test262Error("Exception occurred in callbackfn"); + } + return true; +} +var obj = { + 0: 11, + 4: 10, + 10: 8, + length: 20 +}; +assert.throws(Test262Error, function() { + SendableArray.prototype.every.call(obj, callbackfn); +}); +assert.sameValue(called, 1, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-8.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-8.js new file mode 100644 index 00000000000..727c7ecd58d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-8.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - element changed by callbackfn on previous + iterations is observed +---*/ + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +function callbackfn(val, idx, o) { + if (idx === 0) { + obj[idx + 1] = 8; + } + return val > 10; +} +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-9.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-9.js new file mode 100644 index 00000000000..0749d083591 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-ii-9.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - callbackfn is called with 0 formal + parameter +---*/ + +var called = 0; +function callbackfn() { + called++; + return true; +} +assert([11, 12].every(callbackfn), '[11, 12].every(callbackfn) !== true'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-1.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-1.js new file mode 100644 index 00000000000..25fe5b613ff --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - return value of callbackfn is undefined +---*/ + +var accessed = false; +var obj = { + 0: 11, + length: 1 +}; +function callbackfn(val, idx, o) { + accessed = true; + return undefined; +} +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-10.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-10.js new file mode 100644 index 00000000000..8acc61f79e7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-10.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a number + (value is Infinity) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return Infinity; +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-11.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-11.js new file mode 100644 index 00000000000..4f9c82afba4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-11.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a number + (value is -Infinity) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return -Infinity; +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-12.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-12.js new file mode 100644 index 00000000000..2b250c1ba1e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-12.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a number + (value is NaN) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return NaN; +} +assert.sameValue([11].every(callbackfn), false, '[11].every(callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-13.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-13.js new file mode 100644 index 00000000000..1eaa419819c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-13.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is an empty + string +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return ""; +} +assert.sameValue([11].every(callbackfn), false, '[11].every(callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-14.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-14.js new file mode 100644 index 00000000000..0de62153ffe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-14.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a non-empty + string +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return "non-empty string"; +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-15.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-15.js new file mode 100644 index 00000000000..27de673dd70 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-15.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a Function + object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return function() {}; +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-16.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-16.js new file mode 100644 index 00000000000..eee23a4da7b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-16.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is an Array + object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return []; +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-17.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-17.js new file mode 100644 index 00000000000..cfba6f59803 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-17.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a String + object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return new String(); +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-18.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-18.js new file mode 100644 index 00000000000..6196bced8cd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-18.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a Boolean + object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return new Boolean(); +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-19.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-19.js new file mode 100644 index 00000000000..2adc8eb49a4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-19.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a Number + object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return new Number(); +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-2.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-2.js new file mode 100644 index 00000000000..2453981ea15 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-2.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - return value of callbackfn is null +---*/ + +var accessed = false; +var obj = { + 0: 11, + length: 1 +}; +function callbackfn(val, idx, obj) { + accessed = true; + return null; +} +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-20.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-20.js new file mode 100644 index 00000000000..d5e1a532dae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-20.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is the Math + object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return Math; +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-21.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-21.js new file mode 100644 index 00000000000..08c4e30fcd6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-21.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - return value of callbackfn is a Date object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return new Date(0); +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-22.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-22.js new file mode 100644 index 00000000000..e9a533b266d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-22.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a RegExp + object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return new RegExp(); +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-23.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-23.js new file mode 100644 index 00000000000..1a4bfc56473 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-23.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is the JSON + object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return JSON; +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-24.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-24.js new file mode 100644 index 00000000000..bcd84e22880 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-24.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is an Error + object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return new EvalError(); +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-25.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-25.js new file mode 100644 index 00000000000..6b73fa423ae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-25.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is the + Arguments object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return arguments; +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-27.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-27.js new file mode 100644 index 00000000000..127aecab8ee --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-27.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is the global + object +---*/ + +var global = this; +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return global; +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-28.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-28.js new file mode 100644 index 00000000000..3bb13b761fe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-28.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - false prevents further side effects +---*/ + +var result = false; +var obj = { + length: 20 +}; +function callbackfn(val, idx, obj) { + if (idx > 1) { + result = true; + } + return val > 10; +} +Object.defineProperty(obj, "0", { + get: function() { + return 11; + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + return 8; + }, + configurable: true +}); +Object.defineProperty(obj, "2", { + get: function() { + result = true; + return 8; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); +assert.sameValue(result, false, 'result'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-29.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-29.js new file mode 100644 index 00000000000..a1fc50ba8cf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-29.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value (new Boolean(false)) of + callbackfn is treated as true value +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return new Boolean(false); +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-3.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-3.js new file mode 100644 index 00000000000..24a11887363 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-3.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a boolean + (value is false) +---*/ + +var accessed = false; +var obj = { + 0: 11, + length: 1 +}; +function callbackfn(val, idx, obj) { + accessed = true; + return false; +} +assert.sameValue(SendableArray.prototype.every.call(obj, callbackfn), false, 'SendableArray.prototype.every.call(obj, callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-4.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-4.js new file mode 100644 index 00000000000..deda81e6e19 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-4.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a boolean + (value is true) +---*/ + +var accessed = false; +var obj = { + 0: 11, + length: 1 +}; +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} +assert(SendableArray.prototype.every.call(obj, callbackfn), 'SendableArray.prototype.every.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-5.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-5.js new file mode 100644 index 00000000000..ba3ad76aeb7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-5.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a number + (value is 0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return 0; +} +assert.sameValue([11].every(callbackfn), false, '[11].every(callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-6.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-6.js new file mode 100644 index 00000000000..306f9b44000 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-6.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a number + (value is +0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return +0; +} +assert.sameValue([11].every(callbackfn), false, '[11].every(callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-7.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-7.js new file mode 100644 index 00000000000..74163ff732f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-7.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a nunmber + (value is -0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return -0; +} +assert.sameValue([11].every(callbackfn), false, '[11].every(callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-8.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-8.js new file mode 100644 index 00000000000..d30fa7a924e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-8.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a number + (value is positive number) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return 5; +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-9.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-9.js new file mode 100644 index 00000000000..aa0ab248204 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-7-c-iii-9.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every - return value of callbackfn is a number + (value is negative number) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return -5; +} +assert([11].every(callbackfn), '[11].every(callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-1.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-1.js new file mode 100644 index 00000000000..c2d0891229d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every returns true if 'length' is 0 (empty array) +---*/ + +function cb() {} +var i = [].every(cb); +assert.sameValue(i, true, 'i'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-10.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-10.js new file mode 100644 index 00000000000..29794292320 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-10.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every - subclassed array when length is reduced +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = 2; +function cb(val) +{ + if (val > 2) + return false; + else + return true; +} +var i = f.every(cb); +assert.sameValue(i, true, 'i'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-11.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-11.js new file mode 100644 index 00000000000..0d429ecc1dd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-11.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true when all calls to callbackfn + return true +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + callCnt++; + return true; +} +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); +assert.sameValue(callCnt, 10, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-12.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-12.js new file mode 100644 index 00000000000..ceb0a285439 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-12.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every doesn't mutate the array on which it is + called on +---*/ + +function callbackfn(val, idx, obj) +{ + return true; +} +var arr = [1, 2, 3, 4, 5]; +arr.every(callbackfn); +assert.sameValue(arr[0], 1, 'arr[0]'); +assert.sameValue(arr[1], 2, 'arr[1]'); +assert.sameValue(arr[2], 3, 'arr[2]'); +assert.sameValue(arr[3], 4, 'arr[3]'); +assert.sameValue(arr[4], 5, 'arr[4]'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-13.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-13.js new file mode 100644 index 00000000000..cad0a5a5fe4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-13.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every doesn't visit expandos +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + callCnt++; + return true; +} +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +arr["i"] = 10; +arr[true] = 11; +assert.sameValue(arr.every(callbackfn), true, 'arr.every(callbackfn)'); +assert.sameValue(callCnt, 10, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-2.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-2.js new file mode 100644 index 00000000000..f4df250fda7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true if 'length' is 0 (subclassed + Array, length overridden to null (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = null; +function cb() {} +var i = f.every(cb); +assert.sameValue(i, true, 'i'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-3.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-3.js new file mode 100644 index 00000000000..7a948d8fde0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-3.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true if 'length' is 0 (subclassed + Array, length overridden to false (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = false; +function cb() {} +var i = f.every(cb); +assert.sameValue(i, true, 'i'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-4.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-4.js new file mode 100644 index 00000000000..beaf4be5ae1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true if 'length' is 0 (subclassed + Array, length overridden to 0 (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = 0; +function cb() {} +var i = f.every(cb); +assert.sameValue(i, true, 'i'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-5.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-5.js new file mode 100644 index 00000000000..0fcbe639fa3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-5.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true if 'length' is 0 (subclassed + Array, length overridden to '0' (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = '0'; +function cb() {} +var i = f.every(cb); +assert.sameValue(i, true, 'i'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-6.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-6.js new file mode 100644 index 00000000000..a5ab8b25758 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-6.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true if 'length' is 0 (subclassed + Array, length overridden with obj with valueOf) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; +function cb() {} +var i = f.every(cb); +assert.sameValue(i, true, 'i'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-7.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-7.js new file mode 100644 index 00000000000..83962972827 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-7.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true if 'length' is 0 (subclassed + Array, length overridden with obj w/o valueOf (toString)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +function cb() {} +var i = f.every(cb); +assert.sameValue(i, true, 'i'); diff --git a/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-8.js b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-8.js new file mode 100644 index 00000000000..18302434c89 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/15.4.4.16-8-8.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every returns true if 'length' is 0 (subclassed + Array, length overridden with [] +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = []; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +function cb() {} +var i = f.every(cb); +assert.sameValue(i, true, 'i'); diff --git a/test/sendable/builtins/Array/prototype/every/call-with-boolean.js b/test/sendable/builtins/Array/prototype/every/call-with-boolean.js new file mode 100644 index 00000000000..1a1db10090f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/call-with-boolean.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: Array.prototype.every applied to boolean primitive +---*/ + +assert.sameValue( + SendableArray.prototype.every.call(true, () => {}), + true, + 'SendableArray.prototype.every.call(true, () => {}) must return true' +); +assert.sameValue( + SendableArray.prototype.every.call(false, () => {}), + true, + 'SendableArray.prototype.every.call(false, () => {}) must return true' +); diff --git a/test/sendable/builtins/Array/prototype/every/callbackfn-resize-arraybuffer.js b/test/sendable/builtins/Array/prototype/every/callbackfn-resize-arraybuffer.js new file mode 100644 index 00000000000..b18129bf2dc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/callbackfn-resize-arraybuffer.js @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + elements = []; + indices = []; + arrays = []; + result = SendableArray.prototype.every.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + elements.push(element); + indices.push(index); + arrays.push(array); + return true; + }); + assert.compareArray(elements, expectedElements, 'elements (shrink)'); + assert.compareArray(indices, expectedIndices, 'indices (shrink)'); + assert.compareArray(arrays, expectedArrays, 'arrays (shrink)'); + assert.sameValue(result, true, 'result (shrink)'); + elements = []; + indices = []; + arrays = []; + result = SendableArray.prototype.every.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + elements.push(element); + indices.push(index); + arrays.push(array); + return true; + }); + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, true, 'result (grow)'); +}); diff --git a/test/sendable/builtins/Array/prototype/every/length.js b/test/sendable/builtins/Array/prototype/every/length.js new file mode 100644 index 00000000000..06dea31d019 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/length.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every.length value and property descriptor +info: | + Array.prototype.every ( callbackfn [ , thisArg] ) + The length property of the of function is 1. +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.prototype.every, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/every/name.js b/test/sendable/builtins/Array/prototype/every/name.js new file mode 100644 index 00000000000..2c263624f7a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.prototype.every.name is "every". +info: | + Array.prototype.every ( callbackfn [ , thisArg] ) + 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(SendableArray.prototype.every, "name", { + value: "every", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/every/not-a-constructor.js b/test/sendable/builtins/Array/prototype/every/not-a-constructor.js new file mode 100644 index 00000000000..8783fca3a6d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/not-a-constructor.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.every 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(SendableArray.prototype.every), + false, + 'isConstructor(SendableArray.prototype.every) must return false' +); + +assert.throws(TypeError, () => { + new SendableArray.prototype.every(() => {}); +}); + diff --git a/test/sendable/builtins/Array/prototype/every/prop-desc.js b/test/sendable/builtins/Array/prototype/every/prop-desc.js new file mode 100644 index 00000000000..3bff7121876 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + "every" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.every, 'function', 'typeof'); +verifyPrimordialProperty(SendableArray.prototype, "every", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/every/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/Array/prototype/every/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..966a3ff6dbc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.p.every behaves correctly when receiver is backed by resizable + buffer that is grown mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(n) { + // Returns true by default. + return CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(SendableArray.prototype.every.call(fixedLength, ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(SendableArray.prototype.every.call(fixedLengthWithOffset, ResizeMidIteration)); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(SendableArray.prototype.every.call(lengthTracking, ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(SendableArray.prototype.every.call(lengthTrackingWithOffset, ResizeMidIteration)); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/every/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/Array/prototype/every/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..52ebc890af5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.p.every behaves correctly when receiver is backed by resizable + buffer that is shrunk mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(n) { + // Returns true by default. + return CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(SendableArray.prototype.every.call(fixedLength, ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(SendableArray.prototype.every.call(fixedLengthWithOffset, ResizeMidIteration)); + assert.compareArray(values, [4]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(SendableArray.prototype.every.call(lengthTracking, ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2, + 4 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(SendableArray.prototype.every.call(lengthTrackingWithOffset, ResizeMidIteration)); + assert.compareArray(values, [4]); +} diff --git a/test/sendable/builtins/Array/prototype/every/resizable-buffer.js b/test/sendable/builtins/Array/prototype/every/resizable-buffer.js new file mode 100644 index 00000000000..a56db539af8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/every/resizable-buffer.js @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.every +description: > + Array.p.every behaves correctly when the receiver is backed by + resizable buffer +includes: [resizableArrayBufferUtils.js ] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + function div3(n) { + return Number(n) % 3 == 0; + } + function even(n) { + return Number(n) % 2 == 0; + } + function over10(n) { + return Number(n) > 10; + } + assert(!Array.prototype.every.call(fixedLength, div3)); + assert(Array.prototype.every.call(fixedLength, even)); + assert(!Array.prototype.every.call(fixedLengthWithOffset, div3)); + assert(Array.prototype.every.call(fixedLengthWithOffset, even)); + assert(!Array.prototype.every.call(lengthTracking, div3)); + assert(Array.prototype.every.call(lengthTracking, even)); + assert(!Array.prototype.every.call(lengthTrackingWithOffset, div3)); + assert(Array.prototype.every.call(lengthTrackingWithOffset, even)); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + // Calling .every on an out of bounds TA doesn't throw. + assert(Array.prototype.every.call(fixedLength, div3)); + assert(Array.prototype.every.call(fixedLengthWithOffset, div3)); + assert(!Array.prototype.every.call(lengthTracking, div3)); + assert(Array.prototype.every.call(lengthTracking, even)); + assert(!Array.prototype.every.call(lengthTrackingWithOffset, div3)); + assert(Array.prototype.every.call(lengthTrackingWithOffset, even)); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + // Calling .every on an out of bounds TA doesn't throw. + assert(Array.prototype.every.call(fixedLength, div3)); + assert(Array.prototype.every.call(fixedLengthWithOffset, div3)); + assert(Array.prototype.every.call(lengthTrackingWithOffset, div3)); + assert(Array.prototype.every.call(lengthTracking, div3)); + assert(Array.prototype.every.call(lengthTracking, even)); + // Shrink to zero. + rab.resize(0); + // Calling .every on an out of bounds TA doesn't throw. + assert(Array.prototype.every.call(fixedLength, div3)); + assert(Array.prototype.every.call(fixedLengthWithOffset, div3)); + assert(Array.prototype.every.call(lengthTrackingWithOffset, div3)); + assert(Array.prototype.every.call(lengthTracking, div3)); + assert(Array.prototype.every.call(lengthTracking, even)); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + assert(!Array.prototype.every.call(fixedLength, div3)); + assert(Array.prototype.every.call(fixedLength, even)); + assert(!Array.prototype.every.call(fixedLengthWithOffset, div3)); + assert(Array.prototype.every.call(fixedLengthWithOffset, even)); + assert(!Array.prototype.every.call(lengthTracking, div3)); + assert(Array.prototype.every.call(lengthTracking, even)); + assert(!Array.prototype.every.call(lengthTrackingWithOffset, div3)); + assert(Array.prototype.every.call(lengthTrackingWithOffset, even)); +} -- Gitee From cc4d0d0c42aae31d375cf7b0bccb3bab3397ca4a Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 23 Dec 2024 09:17:03 +0800 Subject: [PATCH 27/93] add new case array-fill Signed-off-by: zhuzhihui7 --- .../Array/prototype/fill/call-with-boolean.js | 29 +++ .../Array/prototype/fill/coerced-indexes.js | 71 +++++++ .../fill/fill-values-custom-start-and-end.js | 47 +++++ .../fill/fill-values-relative-end.js | 37 ++++ .../fill/fill-values-relative-start.js | 34 ++++ .../Array/prototype/fill/fill-values.js | 41 ++++ .../fill/length-near-integer-limit.js | 38 ++++ .../builtins/Array/prototype/fill/length.js | 28 +++ .../builtins/Array/prototype/fill/name.js | 30 +++ .../Array/prototype/fill/not-a-constructor.js | 34 ++++ .../Array/prototype/fill/prop-desc.js | 32 +++ .../Array/prototype/fill/resizable-buffer.js | 185 ++++++++++++++++++ .../fill/return-abrupt-from-end-as-symbol.js | 30 +++ .../prototype/fill/return-abrupt-from-end.js | 33 ++++ ...turn-abrupt-from-setting-property-value.js | 41 ++++ .../return-abrupt-from-start-as-symbol.js | 29 +++ .../fill/return-abrupt-from-start.js | 32 +++ ...eturn-abrupt-from-this-length-as-symbol.js | 33 ++++ .../fill/return-abrupt-from-this-length.js | 46 +++++ .../prototype/fill/return-abrupt-from-this.js | 30 +++ .../Array/prototype/fill/return-this.js | 30 +++ .../prototype/fill/typed-array-resize.js | 83 ++++++++ 22 files changed, 993 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/fill/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/fill/coerced-indexes.js create mode 100644 test/sendable/builtins/Array/prototype/fill/fill-values-custom-start-and-end.js create mode 100644 test/sendable/builtins/Array/prototype/fill/fill-values-relative-end.js create mode 100644 test/sendable/builtins/Array/prototype/fill/fill-values-relative-start.js create mode 100644 test/sendable/builtins/Array/prototype/fill/fill-values.js create mode 100644 test/sendable/builtins/Array/prototype/fill/length-near-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/fill/length.js create mode 100644 test/sendable/builtins/Array/prototype/fill/name.js create mode 100644 test/sendable/builtins/Array/prototype/fill/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/fill/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/fill/resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/fill/return-abrupt-from-end-as-symbol.js create mode 100644 test/sendable/builtins/Array/prototype/fill/return-abrupt-from-end.js create mode 100644 test/sendable/builtins/Array/prototype/fill/return-abrupt-from-setting-property-value.js create mode 100644 test/sendable/builtins/Array/prototype/fill/return-abrupt-from-start-as-symbol.js create mode 100644 test/sendable/builtins/Array/prototype/fill/return-abrupt-from-start.js create mode 100644 test/sendable/builtins/Array/prototype/fill/return-abrupt-from-this-length-as-symbol.js create mode 100644 test/sendable/builtins/Array/prototype/fill/return-abrupt-from-this-length.js create mode 100644 test/sendable/builtins/Array/prototype/fill/return-abrupt-from-this.js create mode 100644 test/sendable/builtins/Array/prototype/fill/return-this.js create mode 100644 test/sendable/builtins/Array/prototype/fill/typed-array-resize.js diff --git a/test/sendable/builtins/Array/prototype/fill/call-with-boolean.js b/test/sendable/builtins/Array/prototype/fill/call-with-boolean.js new file mode 100644 index 00000000000..1b8ff7ce353 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/call-with-boolean.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: Array.prototype.fill applied to boolean primitive +---*/ + +assert.sameValue( + SendableArray.prototype.fill.call(true) instanceof Boolean, + true, + 'The result of `(SendableArray.prototype.fill.call(true) instanceof Boolean)` is true' +); +assert.sameValue( + SendableArray.prototype.fill.call(false) instanceof Boolean, + true, + 'The result of `(SendableArray.prototype.fill.call(false) instanceof Boolean)` is true' +); diff --git a/test/sendable/builtins/Array/prototype/fill/coerced-indexes.js b/test/sendable/builtins/Array/prototype/fill/coerced-indexes.js new file mode 100644 index 00000000000..0a0f78fbbd8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/coerced-indexes.js @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Fills elements from coerced to Integer `start` and `end` values +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + 7. Let relativeStart be ToInteger(start). + 8. ReturnIfAbrupt(relativeStart). + 9. If relativeStart < 0, let k be max((len + relativeStart),0); else let k be + min(relativeStart, len). + 10. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). +includes: [compareArray.js] +---*/ + +assert.compareArray([0, 0].fill(1, undefined), [1, 1], + '[0, 0].fill(1, undefined) must return [1, 1]' +); +assert.compareArray([0, 0].fill(1, 0, undefined), [1, 1], + '[0, 0].fill(1, 0, undefined) must return [1, 1]' +); +assert.compareArray([0, 0].fill(1, null), [1, 1], + '[0, 0].fill(1, null) must return [1, 1]' +); +assert.compareArray([0, 0].fill(1, 0, null), [0, 0], + '[0, 0].fill(1, 0, null) must return [0, 0]' +); +assert.compareArray([0, 0].fill(1, true), [0, 1], + '[0, 0].fill(1, true) must return [0, 1]' +); +assert.compareArray([0, 0].fill(1, 0, true), [1, 0], + '[0, 0].fill(1, 0, true) must return [1, 0]' +); +assert.compareArray([0, 0].fill(1, false), [1, 1], + '[0, 0].fill(1, false) must return [1, 1]' +); +assert.compareArray([0, 0].fill(1, 0, false), [0, 0], + '[0, 0].fill(1, 0, false) must return [0, 0]' +); +assert.compareArray([0, 0].fill(1, NaN), [1, 1], + '[0, 0].fill(1, NaN) must return [1, 1]' +); +assert.compareArray([0, 0].fill(1, 0, NaN), [0, 0], + '[0, 0].fill(1, 0, NaN) must return [0, 0]' +); +assert.compareArray([0, 0].fill(1, '1'), [0, 1], + '[0, 0].fill(1, "1") must return [0, 1]' +); +assert.compareArray([0, 0].fill(1, 0, '1'), [1, 0], + '[0, 0].fill(1, 0, "1") must return [1, 0]' +); +assert.compareArray([0, 0].fill(1, 1.5), [0, 1], + '[0, 0].fill(1, 1.5) must return [0, 1]' +); +assert.compareArray([0, 0].fill(1, 0, 1.5), [1, 0], + '[0, 0].fill(1, 0, 1.5) must return [1, 0]' +); diff --git a/test/sendable/builtins/Array/prototype/fill/fill-values-custom-start-and-end.js b/test/sendable/builtins/Array/prototype/fill/fill-values-custom-start-and-end.js new file mode 100644 index 00000000000..94b445df171 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/fill-values-custom-start-and-end.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Fills all the elements from a with a custom start and end indexes. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + 7. If relativeStart < 0, let k be max((len + relativeStart),0); else let k be + min(relativeStart, len). + 8. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 9. ReturnIfAbrupt(relativeEnd). + 10. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let + final be min(relativeEnd, len). +includes: [compareArray.js] +---*/ + +assert.compareArray([0, 0, 0].fill(8, 1, 2), [0, 8, 0], '[0, 0, 0].fill(8, 1, 2) must return [0, 8, 0]'); +assert.compareArray( + [0, 0, 0, 0, 0].fill(8, -3, 4), + [0, 0, 8, 8, 0], + '[0, 0, 0, 0, 0].fill(8, -3, 4) must return [0, 0, 8, 8, 0]' +); +assert.compareArray( + [0, 0, 0, 0, 0].fill(8, -2, -1), + [0, 0, 0, 8, 0], + '[0, 0, 0, 0, 0].fill(8, -2, -1) must return [0, 0, 0, 8, 0]' +); +assert.compareArray( + [0, 0, 0, 0, 0].fill(8, -1, -3), + [0, 0, 0, 0, 0], + '[0, 0, 0, 0, 0].fill(8, -1, -3) must return [0, 0, 0, 0, 0]' +); +assert.compareArray([, , , , 0].fill(8, 1, 3), [, 8, 8, , 0], '[, , , , 0].fill(8, 1, 3) must return [, 8, 8, , 0]'); diff --git a/test/sendable/builtins/Array/prototype/fill/fill-values-relative-end.js b/test/sendable/builtins/Array/prototype/fill/fill-values-relative-end.js new file mode 100644 index 00000000000..7945d7b6208 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/fill-values-relative-end.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Fills all the elements from a with a custom start index. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + 8. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 9. ReturnIfAbrupt(relativeEnd). + 10. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let + final be min(relativeEnd, len). +includes: [compareArray.js] +---*/ + +assert.compareArray([0, 0, 0].fill(8, 0, 1), [8, 0, 0], + '[0, 0, 0].fill(8, 0, 1) must return [8, 0, 0]' +); +assert.compareArray([0, 0, 0].fill(8, 0, -1), [8, 8, 0], + '[0, 0, 0].fill(8, 0, -1) must return [8, 8, 0]' +); +assert.compareArray([0, 0, 0].fill(8, 0, 5), [8, 8, 8], + '[0, 0, 0].fill(8, 0, 5) must return [8, 8, 8]' +); diff --git a/test/sendable/builtins/Array/prototype/fill/fill-values-relative-start.js b/test/sendable/builtins/Array/prototype/fill/fill-values-relative-start.js new file mode 100644 index 00000000000..5d292d03753 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/fill-values-relative-start.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Fills all the elements from a with a custom start index. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + 7. If relativeStart < 0, let k be max((len + relativeStart),0); else let k be + min(relativeStart, len). +includes: [compareArray.js] +---*/ + +assert.compareArray([0, 0, 0].fill(8, 1), [0, 8, 8], + '[0, 0, 0].fill(8, 1) must return [0, 8, 8]' +); +assert.compareArray([0, 0, 0].fill(8, 4), [0, 0, 0], + '[0, 0, 0].fill(8, 4) must return [0, 0, 0]' +); +assert.compareArray([0, 0, 0].fill(8, -1), [0, 0, 8], + '[0, 0, 0].fill(8, -1) must return [0, 0, 8]' +); diff --git a/test/sendable/builtins/Array/prototype/fill/fill-values.js b/test/sendable/builtins/Array/prototype/fill/fill-values.js new file mode 100644 index 00000000000..4ce84e6b982 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/fill-values.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Fills all the elements with `value` from a defaul start and index. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + 7. If relativeStart < 0, let k be max((len + relativeStart),0); else let k be + min(relativeStart, len). + 8. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 9. ReturnIfAbrupt(relativeEnd). + 10. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let + final be min(relativeEnd, len). + 11. Repeat, while k < final + a. Let Pk be ToString(k). + b. Let setStatus be Set(O, Pk, value, true). + c. ReturnIfAbrupt(setStatus). + d. Increase k by 1. + 12. Return O. +includes: [compareArray.js] +---*/ + +assert.compareArray([].fill(8), [], '[].fill(8) must return []'); +assert.compareArray([0, 0].fill(), [undefined, undefined], '[0, 0].fill() must return [undefined, undefined]'); +assert.compareArray([0, 0, 0].fill(8), [8, 8, 8], + '[0, 0, 0].fill(8) must return [8, 8, 8]' +); diff --git a/test/sendable/builtins/Array/prototype/fill/length-near-integer-limit.js b/test/sendable/builtins/Array/prototype/fill/length-near-integer-limit.js new file mode 100644 index 00000000000..39114158cbe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/length-near-integer-limit.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.fill +description: > + Elements are filled in an array-like object + whose "length" property is near the integer limit. +info: | + Array.prototype.fill ( value [ , start [ , end ] ] ) + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + 7. Repeat, while k < final + a. Let Pk be ! ToString(k). + b. Perform ? Set(O, Pk, value, true). +---*/ + +var value = {}; +var startIndex = Number.MAX_SAFE_INTEGER - 3; +var arrayLike = { + length: Number.MAX_SAFE_INTEGER, +}; +SendableArray.prototype.fill.call(arrayLike, value, startIndex, startIndex + 3); +assert.sameValue(arrayLike[startIndex], value); +assert.sameValue(arrayLike[startIndex + 1], value); +assert.sameValue(arrayLike[startIndex + 2], value); diff --git a/test/sendable/builtins/Array/prototype/fill/length.js b/test/sendable/builtins/Array/prototype/fill/length.js new file mode 100644 index 00000000000..41804705e28 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/length.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: Array.prototype.fill.length value and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.prototype.fill, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/fill/name.js b/test/sendable/builtins/Array/prototype/fill/name.js new file mode 100644 index 00000000000..4a949321103 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/name.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Array.prototype.fill.name value and descriptor. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.prototype.fill, "name", { + value: "fill", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/fill/not-a-constructor.js b/test/sendable/builtins/Array/prototype/fill/not-a-constructor.js new file mode 100644 index 00000000000..ec9cba43055 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/not-a-constructor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.fill 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(SendableArray.prototype.fill), false, 'isConstructor(SendableArray.prototype.fill) must return false'); +assert.throws(TypeError, () => { + new SendableArray.prototype.fill(); +}); + diff --git a/test/sendable/builtins/Array/prototype/fill/prop-desc.js b/test/sendable/builtins/Array/prototype/fill/prop-desc.js new file mode 100644 index 00000000000..da501932b36 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: Property type and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableArray.prototype.fill, + 'function', + '`typeof SendableArray.prototype.fill` is `function`' +); +verifyProperty(SendableArray.prototype, "fill", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/fill/resizable-buffer.js b/test/sendable/builtins/Array/prototype/fill/resizable-buffer.js new file mode 100644 index 00000000000..980e1553935 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/resizable-buffer.js @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Array.p.fill behaves correctly when the receiver is backed by + resizable buffer +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function ReadDataFromBuffer(ab, ctor) { + let result = []; + const ta = new ctor(ab, 0, ab.byteLength / ctor.BYTES_PER_ELEMENT); + for (let item of ta) { + result.push(Number(item)); + } + return result; +} +function ArrayFillHelper(ta, n, start, end) { + if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) { + SendableArray.prototype.fill.call(ta, BigInt(n), start, end); + } else { + SendableArray.prototype.fill.call(ta, n, start, end); + } +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 0, + 0, + 0, + 0 + ]); + ArrayFillHelper(fixedLength, 1); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 1, + 1, + 1, + 1 + ]); + ArrayFillHelper(fixedLengthWithOffset, 2); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 1, + 1, + 2, + 2 + ]); + ArrayFillHelper(lengthTracking, 3); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 3, + 3, + 3, + 3 + ]); + ArrayFillHelper(lengthTrackingWithOffset, 4); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 3, + 3, + 4, + 4 + ]); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + ArrayFillHelper(fixedLength, 5); + ArrayFillHelper(fixedLengthWithOffset, 6); + // We'll check below that these were no-op. + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 3, + 3, + 4 + ]); + ArrayFillHelper(lengthTracking, 7); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 7, + 7, + 7 + ]); + ArrayFillHelper(lengthTrackingWithOffset, 8); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 7, + 7, + 8 + ]); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + // We'll check below that these were no-op. + ArrayFillHelper(fixedLength, 9); + ArrayFillHelper(fixedLengthWithOffset, 10); + ArrayFillHelper(lengthTrackingWithOffset, 11); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [7]); + ArrayFillHelper(lengthTracking, 12); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [12]); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + ArrayFillHelper(fixedLength, 13); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 13, + 13, + 13, + 13, + 0, + 0 + ]); + ArrayFillHelper(fixedLengthWithOffset, 14); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 13, + 13, + 14, + 14, + 0, + 0 + ]); + ArrayFillHelper(lengthTracking, 15); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 15, + 15, + 15, + 15, + 15, + 15 + ]); + ArrayFillHelper(lengthTrackingWithOffset, 16); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 15, + 15, + 16, + 16, + 16, + 16 + ]); + // Filling with non-undefined start & end. + ArrayFillHelper(fixedLength, 17, 1, 3); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 15, + 17, + 17, + 16, + 16, + 16 + ]); + ArrayFillHelper(fixedLengthWithOffset, 18, 1, 2); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 15, + 17, + 17, + 18, + 16, + 16 + ]); + ArrayFillHelper(lengthTracking, 19, 1, 3); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 15, + 19, + 19, + 18, + 16, + 16 + ]); + ArrayFillHelper(lengthTrackingWithOffset, 20, 1, 2); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 15, + 19, + 19, + 20, + 16, + 16 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-end-as-symbol.js b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-end-as-symbol.js new file mode 100644 index 00000000000..aaf70cbf48d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-end-as-symbol.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Return abrupt from ToInteger(end) as a Symbol. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + 8. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 9. ReturnIfAbrupt(relativeEnd). +features: [Symbol] +---*/ + +var end = Symbol(1); +assert.throws(TypeError, function() { + [].fill(1, 0, end); +}); diff --git a/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-end.js b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-end.js new file mode 100644 index 00000000000..78a2faf59ac --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-end.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Return abrupt from ToInteger(end). +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + 8. If end is undefined, let relativeEnd be len; else let relativeEnd be + ToInteger(end). + 9. ReturnIfAbrupt(relativeEnd). +---*/ + +var end = { + valueOf: function() { + throw new Test262Error(); + } +}; +assert.throws(Test262Error, function() { + [].fill(1, 0, end); +}); diff --git a/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-setting-property-value.js b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-setting-property-value.js new file mode 100644 index 00000000000..0263e0880ce --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-setting-property-value.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Return abrupt from setting a property value. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + 11. Repeat, while k < final + a. Let Pk be ToString(k). + b. Let setStatus be Set(O, Pk, value, true). + c. ReturnIfAbrupt(setStatus). +---*/ + +var a1 = []; +Object.freeze(a1); +// won't break on an empty array. +a1.fill(1); +var a2 = { + length: 1 +}; +Object.defineProperty(a2, '0', { + set: function() { + throw new Test262Error(); + } +}) +assert.throws(Test262Error, function() { + SendableArray.prototype.fill.call(a2); +}); diff --git a/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-start-as-symbol.js b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-start-as-symbol.js new file mode 100644 index 00000000000..a4aeda89e9a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-start-as-symbol.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Return abrupt from ToInteger(start) as a Symbol. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + 5. Let relativeStart be ToInteger(start). + 6. ReturnIfAbrupt(relativeStart). +features: [Symbol] +---*/ + +var start = Symbol(1); +assert.throws(TypeError, function() { + [].fill(1, start); +}); diff --git a/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-start.js b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-start.js new file mode 100644 index 00000000000..cda4a75596b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-start.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Return abrupt from ToInteger(start). +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + 5. Let relativeStart be ToInteger(start). + 6. ReturnIfAbrupt(relativeStart). +---*/ + +var start = { + valueOf: function() { + throw new Test262Error(); + } +}; +assert.throws(Test262Error, function() { + [].fill(1, start); +}); diff --git a/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-this-length-as-symbol.js b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-this-length-as-symbol.js new file mode 100644 index 00000000000..f7f03cfb8fd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-this-length-as-symbol.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Return abrupt from ToLength(Get(O, "length")) where length is a Symbol. +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let len be ToLength(Get(O, "length")). + 4. ReturnIfAbrupt(len). +features: [Symbol] +---*/ + +var o = {}; +o.length = Symbol(1); +// value argument is given to avoid false positives +assert.throws(TypeError, function() { + [].fill.call(o, 1); +}); diff --git a/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-this-length.js b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-this-length.js new file mode 100644 index 00000000000..02c6f2b2a45 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-this-length.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Return abrupt from ToLength(Get(O, "length")). +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let len be ToLength(Get(O, "length")). + 4. ReturnIfAbrupt(len). +---*/ + +var o1 = {}; +Object.defineProperty(o1, 'length', { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + [].fill.call(o1, 1); +}); +var o2 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; +assert.throws(Test262Error, function() { + [].fill.call(o2, 1); +}); diff --git a/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-this.js b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-this.js new file mode 100644 index 00000000000..1ac2e3d806e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/return-abrupt-from-this.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Return abrupt from ToObject(this value). +info: | + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.fill.call(undefined, 1); +}); +assert.throws(TypeError, function() { + SendableArray.prototype.fill.call(null, 1); +}); diff --git a/test/sendable/builtins/Array/prototype/fill/return-this.js b/test/sendable/builtins/Array/prototype/fill/return-this.js new file mode 100644 index 00000000000..e228540f6e6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/return-this.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Returns `this`. +info: | + 12. Return O. +---*/ + +var arr = []; +var result = arr.fill(1); +assert.sameValue(result, arr); +var o = { + length: 0 +}; +result = SendableArray.prototype.fill.call(o); +assert.sameValue(result, o); diff --git a/test/sendable/builtins/Array/prototype/fill/typed-array-resize.js b/test/sendable/builtins/Array/prototype/fill/typed-array-resize.js new file mode 100644 index 00000000000..28b0cc79831 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/fill/typed-array-resize.js @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.fill +description: > + Array.p.fill called on a TypedArray backed by a resizable buffer + that goes out of bounds during evaluation of the arguments +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function ReadDataFromBuffer(ab, ctor) { + let result = []; + const ta = new ctor(ab, 0, ab.byteLength / ctor.BYTES_PER_ELEMENT); + for (let item of ta) { + result.push(Number(item)); + } + return result; +} +function ArrayFillHelper(ta, n, start, end) { + if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) { + SendableArray.prototype.fill.call(ta, BigInt(n), start, end); + } else { + SendableArray.prototype.fill.call(ta, n, start, end); + } +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 3; + } + }; + ArrayFillHelper(fixedLength, evil, 1, 2); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 0, + 0 + ]); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 1; + } + }; + ArrayFillHelper(fixedLength, 3, evil, 2); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 0, + 0 + ]); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 2; + } + }; + ArrayFillHelper(fixedLength, 3, 1, evil); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 0, + 0 + ]); +} -- Gitee From 8f303fe356da80c47a081542e8a264db9f129340 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 23 Dec 2024 14:16:11 +0800 Subject: [PATCH 28/93] SendableArrayBuffer base test Signed-off-by: zhuzhihui7 --- .../builtins/ArrayBuffer/allocation-limit.js | 31 +++++++ .../data-allocation-after-object-creation.js | 38 ++++++++ .../builtins/ArrayBuffer/init-zero.js | 34 ++++++++ .../builtins/ArrayBuffer/is-a-constructor.js | 24 +++++ .../builtins/ArrayBuffer/length-is-absent.js | 18 ++++ .../ArrayBuffer/length-is-too-large-throws.js | 31 +++++++ test/sendable/builtins/ArrayBuffer/length.js | 33 +++++++ test/sendable/builtins/ArrayBuffer/name.js | 8 +- .../ArrayBuffer/negative-length-throws.js | 34 ++++++++ .../newtarget-prototype-is-not-object.js | 48 ++++++++++ .../options-maxbytelength-allocation-limit.js | 40 +++++++++ ...elength-compared-before-object-creation.js | 40 +++++++++ ...h-data-allocation-after-object-creation.js | 41 +++++++++ .../options-maxbytelength-diminuitive.js | 22 +++++ .../options-maxbytelength-excessive.js | 28 ++++++ .../options-maxbytelength-negative.js | 25 ++++++ .../options-maxbytelength-object.js | 45 ++++++++++ .../options-maxbytelength-poisoned.js | 29 +++++++ .../options-maxbytelength-undefined.js | 24 +++++ .../ArrayBuffer/options-non-object.js | 27 ++++++ .../builtins/ArrayBuffer/prop-desc.js | 23 +++++ .../ArrayBuffer/proto-from-ctor-realm.js | 27 ++++++ .../ArrayBuffer/prototype-from-newtarget.js | 34 ++++++++ .../return-abrupt-from-length-symbol.js | 21 +++++ .../ArrayBuffer/return-abrupt-from-length.js | 24 +++++ .../builtins/ArrayBuffer/toindex-length.js | 87 +++++++++++++++++++ .../ArrayBuffer/undefined-newtarget-throws.js | 23 +++++ .../builtins/ArrayBuffer/zero-length.js | 23 +++++ 28 files changed, 878 insertions(+), 4 deletions(-) create mode 100644 test/sendable/builtins/ArrayBuffer/allocation-limit.js create mode 100644 test/sendable/builtins/ArrayBuffer/data-allocation-after-object-creation.js create mode 100644 test/sendable/builtins/ArrayBuffer/init-zero.js create mode 100644 test/sendable/builtins/ArrayBuffer/is-a-constructor.js create mode 100644 test/sendable/builtins/ArrayBuffer/length-is-absent.js create mode 100644 test/sendable/builtins/ArrayBuffer/length-is-too-large-throws.js create mode 100644 test/sendable/builtins/ArrayBuffer/length.js create mode 100644 test/sendable/builtins/ArrayBuffer/negative-length-throws.js create mode 100644 test/sendable/builtins/ArrayBuffer/newtarget-prototype-is-not-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-allocation-limit.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-diminuitive.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-excessive.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-negative.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-poisoned.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-undefined.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-non-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prop-desc.js create mode 100644 test/sendable/builtins/ArrayBuffer/proto-from-ctor-realm.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype-from-newtarget.js create mode 100644 test/sendable/builtins/ArrayBuffer/return-abrupt-from-length-symbol.js create mode 100644 test/sendable/builtins/ArrayBuffer/return-abrupt-from-length.js create mode 100644 test/sendable/builtins/ArrayBuffer/toindex-length.js create mode 100644 test/sendable/builtins/ArrayBuffer/undefined-newtarget-throws.js create mode 100644 test/sendable/builtins/ArrayBuffer/zero-length.js diff --git a/test/sendable/builtins/ArrayBuffer/allocation-limit.js b/test/sendable/builtins/ArrayBuffer/allocation-limit.js new file mode 100644 index 00000000000..83d5962f3ac --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/allocation-limit.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + Throws a RangeError if requested Data Block is too large. +info: | + SendableArrayBuffer( length ) + + ... + 6. Return AllocateSendableArrayBuffer(NewTarget, byteLength). + + 6.2.6.1 CreateByteDataBlock(size) + ... + 2. Let db be a new Data Block value consisting of size bytes. If it is + impossible to create such a Data Block, throw a RangeError exception. + ... +---*/ + +assert.throws(RangeError, function() { + // Allocating 7 PiB should fail with a RangeError. + // Math.pow(1024, 5) = 1125899906842624 + new SendableArrayBuffer(7 * 1125899906842624); +}, "`length` parameter is 7 PiB"); + +assert.throws(RangeError, function() { + // Allocating almost 8 PiB should fail with a RangeError. + // Math.pow(2, 53) = 9007199254740992 + new SendableArrayBuffer(9007199254740992 - 1); +}, "`length` parameter is Math.pow(2, 53) - 1"); diff --git a/test/sendable/builtins/ArrayBuffer/data-allocation-after-object-creation.js b/test/sendable/builtins/ArrayBuffer/data-allocation-after-object-creation.js new file mode 100644 index 00000000000..96c8076a01c --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/data-allocation-after-object-creation.js @@ -0,0 +1,38 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + The new SendableArrayBuffer instance is created prior to allocating the Data Block. +info: | + SendableArrayBuffer( length ) + + ... + 6. Return AllocateSendableArrayBuffer(NewTarget, byteLength). + + AllocateSendableArrayBuffer( constructor, byteLength ) + 1. Let obj be OrdinaryCreateFromConstructor(constructor, "%SendableArrayBufferPrototype%", + «[[SendableArrayBufferData]], [[SendableArrayBufferByteLength]]» ). + 2. ReturnIfAbrupt(obj). + ... + 4. Let block be CreateByteDataBlock(byteLength). + 5. ReturnIfAbrupt(block). + ... +features: [Reflect.construct] +---*/ + +function DummyError() {} + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get: function() { + throw new DummyError(); + } +}); + +assert.throws(DummyError, function() { + // Allocating 7 PiB should fail with a RangeError. + // Math.pow(1024, 5) = 1125899906842624 + Reflect.construct(SendableArrayBuffer, [7 * 1125899906842624], newTarget); +}); diff --git a/test/sendable/builtins/ArrayBuffer/init-zero.js b/test/sendable/builtins/ArrayBuffer/init-zero.js new file mode 100644 index 00000000000..9c5a4431ce5 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/init-zero.js @@ -0,0 +1,34 @@ +// 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-sendableArrayBuffer-length +description: All bytes are initialized to zero +info: | + [...] + 5. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength). + + 24.1.1.1 AllocateSendableArrayBuffer + + 3. Let block be ? CreateByteDataBlock(byteLength). + + 6.2.6.1 CreateByteDataBlock + + 1. Assert: size≥0. + 2. Let db be a new Data Block value consisting of size bytes. If it is + impossible to create such a Data Block, throw a RangeError exception. + 3. Set all of the bytes of db to 0. + 4. Return db. +features: [DataView] +---*/ + +var view = new DataView(new SendableArrayBuffer(9)); + +assert.sameValue(view.getUint8(0), 0, 'index 0'); +assert.sameValue(view.getUint8(1), 0, 'index 1'); +assert.sameValue(view.getUint8(2), 0, 'index 2'); +assert.sameValue(view.getUint8(3), 0, 'index 3'); +assert.sameValue(view.getUint8(4), 0, 'index 4'); +assert.sameValue(view.getUint8(5), 0, 'index 5'); +assert.sameValue(view.getUint8(6), 0, 'index 6'); +assert.sameValue(view.getUint8(7), 0, 'index 7'); +assert.sameValue(view.getUint8(8), 0, 'index 8'); diff --git a/test/sendable/builtins/ArrayBuffer/is-a-constructor.js b/test/sendable/builtins/ArrayBuffer/is-a-constructor.js new file mode 100644 index 00000000000..bec4c463ac5 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/is-a-constructor.js @@ -0,0 +1,24 @@ +// 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: > + The SendableArrayBuffer constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct, SendableArrayBuffer] +---*/ + +assert.sameValue(isConstructor(SendableArrayBuffer), true, 'isConstructor(SendableArrayBuffer) must return true'); +new SendableArrayBuffer(); + diff --git a/test/sendable/builtins/ArrayBuffer/length-is-absent.js b/test/sendable/builtins/ArrayBuffer/length-is-absent.js new file mode 100644 index 00000000000..c34dff3e66e --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/length-is-absent.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-sendableArrayBuffer-length +description: > + Returns an empty instance if length is absent +info: | + SendableArrayBuffer( length ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength). +---*/ + +var buffer = new SendableArrayBuffer(); + +assert.sameValue(buffer.byteLength, 0); diff --git a/test/sendable/builtins/ArrayBuffer/length-is-too-large-throws.js b/test/sendable/builtins/ArrayBuffer/length-is-too-large-throws.js new file mode 100644 index 00000000000..9fba5d505ff --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/length-is-too-large-throws.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + Throws a RangeError if length >= 2 ** 53 +info: | + SendableArrayBuffer( length ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + + ToIndex( value ) + + 1. If value is undefined, then + a. Let index be 0. + 2. Else, + a. Let integerIndex be ? ToInteger(value). + b. If integerIndex < 0, throw a RangeError exception. + ... +---*/ + +assert.throws(RangeError, function() { + // Math.pow(2, 53) = 9007199254740992 + new SendableArrayBuffer(9007199254740992); +}, "`length` parameter is too large"); + +assert.throws(RangeError, function() { + new SendableArrayBuffer(Infinity); +}, "`length` parameter is positive Infinity"); diff --git a/test/sendable/builtins/ArrayBuffer/length.js b/test/sendable/builtins/ArrayBuffer/length.js new file mode 100644 index 00000000000..a53ff2323a4 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/length.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-constructor +description: > + SendableArrayBuffer.length is 1. +info: | + SendableArrayBuffer ( length ) + + 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. Optional parameters + (which are indicated with brackets: [ ]) or rest parameters (which + are 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] +features: [SendableArrayBuffer] +---*/ + +verifyProperty(SendableArrayBuffer, "length", { + value: 1, + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/ArrayBuffer/name.js b/test/sendable/builtins/ArrayBuffer/name.js index 0bca8a2795c..6552d7a52b5 100644 --- a/test/sendable/builtins/ArrayBuffer/name.js +++ b/test/sendable/builtins/ArrayBuffer/name.js @@ -2,9 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-sendableArrayBuffer-constructor +esid: sec-sendableSendableArrayBuffer-constructor description: > - SendableArrayBuffer.name is "SendableArrayBuffer". + SendableSendableArrayBuffer.name is "SendableSendableArrayBuffer". info: | 17 ECMAScript Standard Built-in Objects: @@ -19,9 +19,9 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(SendableArrayBuffer.name, "SendableArrayBuffer"); +assert.sameValue(SendableSendableArrayBuffer.name, "SendableSendableArrayBuffer"); -verifyProperty(SendableArrayBuffer, "name", { +verifyProperty(SendableSendableArrayBuffer, "name", { writable: false, enumerable: false, configurable: true, diff --git a/test/sendable/builtins/ArrayBuffer/negative-length-throws.js b/test/sendable/builtins/ArrayBuffer/negative-length-throws.js new file mode 100644 index 00000000000..a59493a801f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/negative-length-throws.js @@ -0,0 +1,34 @@ +// 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-sendableArrayBuffer-length +description: > + Throws a Range Error if length represents an integer < 0 +info: | + SendableArrayBuffer( length ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + + ToIndex( value ) + + 1. If value is undefined, then + a. Let index be 0. + 2. Else, + a. Let integerIndex be ? ToInteger(value). + b. If integerIndex < 0, throw a RangeError exception. + ... +---*/ + +assert.throws(RangeError, function() { + new SendableArrayBuffer(-1); +}); + +assert.throws(RangeError, function() { + new SendableArrayBuffer(-1.1); +}); + +assert.throws(RangeError, function() { + new SendableArrayBuffer(-Infinity); +}); diff --git a/test/sendable/builtins/ArrayBuffer/newtarget-prototype-is-not-object.js b/test/sendable/builtins/ArrayBuffer/newtarget-prototype-is-not-object.js new file mode 100644 index 00000000000..77ab90d0f73 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/newtarget-prototype-is-not-object.js @@ -0,0 +1,48 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + [[Prototype]] defaults to %SendableArrayBufferPrototype% if NewTarget.prototype is not an object. +info: | + SendableArrayBuffer( length ) + + SendableArrayBuffer called with argument length performs the following steps: + + ... + 6. Return AllocateSendableArrayBuffer(NewTarget, byteLength). + + AllocateSendableArrayBuffer( constructor, byteLength ) + 1. Let obj be OrdinaryCreateFromConstructor(constructor, "%SendableArrayBufferPrototype%", + «[[SendableArrayBufferData]], [[SendableArrayBufferByteLength]]» ). + 2. ReturnIfAbrupt(obj). + ... +features: [Reflect.construct, Symbol] +---*/ + +function newTarget() {} + +newTarget.prototype = undefined; +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), SendableArrayBuffer.prototype, "newTarget.prototype is undefined"); + +newTarget.prototype = null; +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [2], newTarget); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), SendableArrayBuffer.prototype, "newTarget.prototype is null"); + +newTarget.prototype = true; +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [3], newTarget); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), SendableArrayBuffer.prototype, "newTarget.prototype is a Boolean"); + +newTarget.prototype = ""; +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [4], newTarget); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), SendableArrayBuffer.prototype, "newTarget.prototype is a String"); + +newTarget.prototype = Symbol(); +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [5], newTarget); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), SendableArrayBuffer.prototype, "newTarget.prototype is a Symbol"); + +newTarget.prototype = 1; +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [6], newTarget); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), SendableArrayBuffer.prototype, "newTarget.prototype is a Number"); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-allocation-limit.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-allocation-limit.js new file mode 100644 index 00000000000..22cee7db010 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-allocation-limit.js @@ -0,0 +1,40 @@ +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + Throws a RangeError if the requested Data Block is too large. +info: | + SendableArrayBuffer ( length [ , options ] ) + + ... + 4. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength, requestedMaxByteLength). + + AllocateSendableArrayBuffer ( constructor, byteLength [ , maxByteLength ] ) + + ... + 5. Let block be ? CreateByteDataBlock(byteLength). + ... + + CreateByteDataBlock ( size ) + + ... + 2. Let db be a new Data Block value consisting of size bytes. If it is + impossible to create such a Data Block, throw a RangeError exception. + ... + +features: [resizable-SendableArrayBuffer] +---*/ + +assert.throws(RangeError, function() { + // Allocating 7 PiB should fail with a RangeError. + // Math.pow(1024, 5) = 1125899906842624 + new SendableArrayBuffer(0, {maxByteLength: 7 * 1125899906842624}); +}, "`maxByteLength` option is 7 PiB"); + +assert.throws(RangeError, function() { + // Allocating almost 8 PiB should fail with a RangeError. + // Math.pow(2, 53) = 9007199254740992 + new SendableArrayBuffer(0, {maxByteLength: 9007199254740992 - 1}); +}, "`maxByteLength` option is Math.pow(2, 53) - 1"); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js new file mode 100644 index 00000000000..614641bd233 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js @@ -0,0 +1,40 @@ +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + The byteLength argument is validated before OrdinaryCreateFromConstructor. +info: | + SendableArrayBuffer ( length [ , options ] ) + + ... + 4. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength, requestedMaxByteLength). + + AllocateSendableArrayBuffer ( constructor, byteLength [ , maxByteLength ] ) + + ... + 3. If allocatingResizableBuffer is true, then + a. If byteLength > maxByteLength, throw a RangeError exception. + ... + 4. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%SendableArrayBuffer.prototype%", slots). + ... + +features: [resizable-SendableArrayBuffer, Reflect.construct] +---*/ + +let newTarget = Object.defineProperty(function(){}.bind(null), "prototype", { + get() { + throw new Test262Error(); + } +}); + +assert.throws(RangeError, function() { + let byteLength = 10; + let options = { + maxByteLength: 0, + }; + + // Throws a RangeError, because `byteLength` is larger than `options.maxByteLength`. + Reflect.construct(SendableArrayBuffer, [byteLength, options], newTarget); +}); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js new file mode 100644 index 00000000000..38672b7cf4f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js @@ -0,0 +1,41 @@ +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + The new SendableArrayBuffer instance is created prior to allocating the Data Block. +info: | + SendableArrayBuffer ( length [ , options ] ) + + ... + 4. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength, requestedMaxByteLength). + + AllocateSendableArrayBuffer ( constructor, byteLength [ , maxByteLength ] ) + + ... + 4. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%SendableArrayBuffer.prototype%", slots). + 5. Let block be ? CreateByteDataBlock(byteLength). + ... + +features: [resizable-SendableArrayBuffer, Reflect.construct] +---*/ + +function DummyError() {} + +let newTarget = Object.defineProperty(function(){}.bind(null), "prototype", { + get() { + throw new DummyError(); + } +}); + +assert.throws(DummyError, function() { + let byteLength = 0; + let options = { + maxByteLength: 7 * 1125899906842624 + }; + + // Allocating 7 PiB should fail with a RangeError. + // Math.pow(1024, 5) = 1125899906842624 + Reflect.construct(SendableArrayBuffer, [], newTarget); +}); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-diminuitive.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-diminuitive.js new file mode 100644 index 00000000000..d1108351632 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-diminuitive.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sendableArrayBuffer-constructor +description: | + Invoked with an options object whose `maxByteLength` property is less than + the length. +info: | + SendableArrayBuffer( length [ , options ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Let requestedMaxByteLength be ? GetSendableArrayBufferMaxByteLengthOption(options). + 4. If requestedMaxByteLength is empty, then + a. [...] + 5. If byteLength > requestedMaxByteLength, throw a RangeError exception. +features: [resizable-SendableArrayBuffer] +---*/ + +assert.throws(RangeError, function() { + new SendableArrayBuffer(1, {maxByteLength: 0}); +}); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-excessive.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-excessive.js new file mode 100644 index 00000000000..e988acc74e4 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-excessive.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sendableArrayBuffer-constructor +description: | + Invoked with an options object whose `maxByteLength` property exceeds the + maximum length value +info: | + SendableArrayBuffer( length [ , options ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Let requestedMaxByteLength be ? GetSendableArrayBufferMaxByteLengthOption(options). + [...] + + 1.1.5 GetSendableArrayBufferMaxByteLengthOption ( options ) + + 1. If Type(options) is not Object, return empty. + 2. Let maxByteLength be ? Get(options, "maxByteLength"). + 3. If maxByteLength is undefined, return empty. + 4. Return ? ToIndex(maxByteLength). +features: [resizable-SendableArrayBuffer] +---*/ + +assert.throws(RangeError, function() { + // Math.pow(2, 53) = 9007199254740992 + new SendableArrayBuffer(0, { maxByteLength: 9007199254740992 }); +}); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-negative.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-negative.js new file mode 100644 index 00000000000..55907105b22 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-negative.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sendableArrayBuffer-constructor +description: Invoked with an options object whose `maxByteLength` property is negative +info: | + SendableArrayBuffer( length [ , options ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Let requestedMaxByteLength be ? GetSendableArrayBufferMaxByteLengthOption(options). + [...] + + 1.1.5 GetSendableArrayBufferMaxByteLengthOption ( options ) + + 1. If Type(options) is not Object, return empty. + 2. Let maxByteLength be ? Get(options, "maxByteLength"). + 3. If maxByteLength is undefined, return empty. + 4. Return ? ToIndex(maxByteLength). +features: [resizable-SendableArrayBuffer] +---*/ + +assert.throws(RangeError, function() { + new SendableArrayBuffer(0, { maxByteLength: -1 }); +}); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-object.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-object.js new file mode 100644 index 00000000000..fe4969cf993 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-object.js @@ -0,0 +1,45 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sendableArrayBuffer-constructor +description: | + Invoked with an options object whose `maxByteLength` property cannot be + coerced to a primitive value +info: | + SendableArrayBuffer( length [ , options ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Let requestedMaxByteLength be ? GetSendableArrayBufferMaxByteLengthOption(options). + [...] + + 1.1.5 GetSendableArrayBufferMaxByteLengthOption ( options ) + + 1. If Type(options) is not Object, return empty. + 2. Let maxByteLength be ? Get(options, "maxByteLength"). + 3. If maxByteLength is undefined, return empty. + 4. Return ? ToIndex(maxByteLength). +features: [resizable-SendableArrayBuffer] +---*/ + +var log = []; +var options = { + maxByteLength: { + toString: function() { + log.push('toString'); + return {}; + }, + valueOf: function() { + log.push('valueOf'); + return {}; + } + } +}; + +assert.throws(TypeError, function() { + new SendableArrayBuffer(0, options); +}); + +assert.sameValue(log.length, 2); +assert.sameValue(log[0], 'valueOf'); +assert.sameValue(log[1], 'toString'); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-poisoned.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-poisoned.js new file mode 100644 index 00000000000..b0337e7e5b1 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-poisoned.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sendableArrayBuffer-constructor +description: Invoked with an options object whose `maxByteLength` property throws +info: | + SendableArrayBuffer( length [ , options ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Let requestedMaxByteLength be ? GetSendableArrayBufferMaxByteLengthOption(options). + [...] + + 1.1.5 GetSendableArrayBufferMaxByteLengthOption ( options ) + + 1. If Type(options) is not Object, return empty. + 2. Let maxByteLength be ? Get(options, "maxByteLength"). +features: [resizable-SendableArrayBuffer] +---*/ + +var options = { + get maxByteLength() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + new SendableArrayBuffer(0, options); +}); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-undefined.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-undefined.js new file mode 100644 index 00000000000..fb1b8c82e49 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-undefined.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sendableArrayBuffer-constructor +description: Invoked with an options object whose `maxByteLength` property is undefined +info: | + SendableArrayBuffer( length [ , options ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Let requestedMaxByteLength be ? GetSendableArrayBufferMaxByteLengthOption(options). + 4. If requestedMaxByteLength is empty, then + a. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength). + + 1.1.5 GetSendableArrayBufferMaxByteLengthOption ( options ) + + 1. If Type(options) is not Object, return empty. + 2. Let maxByteLength be ? Get(options, "maxByteLength"). + 3. If maxByteLength is undefined, return empty. +features: [resizable-SendableArrayBuffer] +---*/ + +assert.sameValue(new SendableArrayBuffer(0, {}).resizable, false); +assert.sameValue(new SendableArrayBuffer(0, {maxByteLength: undefined}).resizable, false); diff --git a/test/sendable/builtins/ArrayBuffer/options-non-object.js b/test/sendable/builtins/ArrayBuffer/options-non-object.js new file mode 100644 index 00000000000..975dee7e68a --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-non-object.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sendableArrayBuffer-constructor +description: Invoked with a non-object value for options +info: | + SendableArrayBuffer( length [ , options ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Let requestedMaxByteLength be ? GetSendableArrayBufferMaxByteLengthOption(options). + 4. If requestedMaxByteLength is empty, then + a. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength). + + 1.1.5 GetSendableArrayBufferMaxByteLengthOption ( options ) + + 1. If Type(options) is not Object, return empty. +features: [resizable-SendableArrayBuffer] +---*/ + +assert.sameValue(new SendableArrayBuffer(0, null).resizable, false, 'null'); +assert.sameValue(new SendableArrayBuffer(0, true).resizable, false, 'boolean'); +assert.sameValue(new SendableArrayBuffer(0, Symbol(3)).resizable, false, 'symbol'); +assert.sameValue(new SendableArrayBuffer(0, 1n).resizable, false, 'bigint'); +assert.sameValue(new SendableArrayBuffer(0, 'string').resizable, false, 'string'); +assert.sameValue(new SendableArrayBuffer(0, 9).resizable, false, 'number'); +assert.sameValue(new SendableArrayBuffer(0, undefined).resizable, false, 'undefined'); diff --git a/test/sendable/builtins/ArrayBuffer/prop-desc.js b/test/sendable/builtins/ArrayBuffer/prop-desc.js new file mode 100644 index 00000000000..0623ce3fc03 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-constructor +description: > + Property descriptor of SendableArrayBuffer +info: | + 17 ECMAScript Standard Built-in Objects: + + 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] +---*/ + +assert.sameValue(typeof SendableArrayBuffer, "function", "`typeof SendableArrayBuffer` is `'function'`"); + +verifyProperty(this, "SendableArrayBuffer", { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/ArrayBuffer/proto-from-ctor-realm.js b/test/sendable/builtins/ArrayBuffer/proto-from-ctor-realm.js new file mode 100644 index 00000000000..f7acb5190c3 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/proto-from-ctor-realm.js @@ -0,0 +1,27 @@ +// 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-sendableArrayBuffer-length +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 5. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength). + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var o = Reflect.construct(SendableArrayBuffer, [], C); + +assert.sameValue(Object.getPrototypeOf(o), other.SendableArrayBuffer.prototype); diff --git a/test/sendable/builtins/ArrayBuffer/prototype-from-newtarget.js b/test/sendable/builtins/ArrayBuffer/prototype-from-newtarget.js new file mode 100644 index 00000000000..bcbaa43c18f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype-from-newtarget.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + The [[Prototype]] internal slot is computed from NewTarget. +info: | + SendableArrayBuffer( length ) + + SendableArrayBuffer called with argument length performs the following steps: + + ... + 6. Return AllocateSendableArrayBuffer(NewTarget, byteLength). + + AllocateSendableArrayBuffer( constructor, byteLength ) + 1. Let obj be OrdinaryCreateFromConstructor(constructor, "%SendableArrayBufferPrototype%", + «[[SendableArrayBufferData]], [[SendableArrayBufferByteLength]]» ). + 2. ReturnIfAbrupt(obj). + ... +features: [Reflect.construct] +---*/ + +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [8], Object); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), Object.prototype, "NewTarget is built-in Object constructor"); + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get: function() { + return Array.prototype; + } +}); +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [16], newTarget); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), Array.prototype, "NewTarget is BoundFunction with accessor"); diff --git a/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length-symbol.js b/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length-symbol.js new file mode 100644 index 00000000000..11be1d4bcf9 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length-symbol.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-sendableArrayBuffer-length +description: > + Throws a TypeError if length is a symbol +info: | + SendableArrayBuffer( length ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + ... +features: [Symbol] +---*/ + +var s = Symbol(); + +assert.throws(TypeError, function() { + new SendableArrayBuffer(s); +}, "`length` parameter is a Symbol"); diff --git a/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length.js b/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length.js new file mode 100644 index 00000000000..55a6f68daf2 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length.js @@ -0,0 +1,24 @@ +// 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-sendableArrayBuffer-length +description: > + Return abrupt from ToIndex(length) +info: | + SendableArrayBuffer( length ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + ... +---*/ + +var len = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + new SendableArrayBuffer(len); +}); diff --git a/test/sendable/builtins/ArrayBuffer/toindex-length.js b/test/sendable/builtins/ArrayBuffer/toindex-length.js new file mode 100644 index 00000000000..1794e8da943 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/toindex-length.js @@ -0,0 +1,87 @@ +// 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-sendableArrayBuffer-length +description: > + The `length` parameter is converted to a value numeric index value. +info: | + SendableArrayBuffer( length ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength). + + ToIndex( value ) + + 1. If value is undefined, then + a. Let index be 0. + 2. Else, + a. Let integerIndex be ? ToInteger(value). + b. If integerIndex < 0, throw a RangeError exception. + c. Let index be ! ToLength(integerIndex). + d. If SameValueZero(integerIndex, index) is false, throw a RangeError exception. + 3. Return index. +---*/ + +var obj1 = { + valueOf: function() { + return 42; + } +}; + +var obj2 = { + toString: function() { + return 42; + } +}; + +var buffer; + +buffer = new SendableArrayBuffer(obj1); +assert.sameValue(buffer.byteLength, 42, "object's valueOf"); + +buffer = new SendableArrayBuffer(obj2); +assert.sameValue(buffer.byteLength, 42, "object's toString"); + +buffer = new SendableArrayBuffer(""); +assert.sameValue(buffer.byteLength, 0, "the Empty string"); + +buffer = new SendableArrayBuffer("0"); +assert.sameValue(buffer.byteLength, 0, "string '0'"); + +buffer = new SendableArrayBuffer("1"); +assert.sameValue(buffer.byteLength, 1, "string '1'"); + +buffer = new SendableArrayBuffer(true); +assert.sameValue(buffer.byteLength, 1, "true"); + +buffer = new SendableArrayBuffer(false); +assert.sameValue(buffer.byteLength, 0, "false"); + +buffer = new SendableArrayBuffer(NaN); +assert.sameValue(buffer.byteLength, 0, "NaN"); + +buffer = new SendableArrayBuffer(null); +assert.sameValue(buffer.byteLength, 0, "null"); + +buffer = new SendableArrayBuffer(undefined); +assert.sameValue(buffer.byteLength, 0, "undefined"); + +buffer = new SendableArrayBuffer(0.1); +assert.sameValue(buffer.byteLength, 0, "0.1"); + +buffer = new SendableArrayBuffer(0.9); +assert.sameValue(buffer.byteLength, 0, "0.9"); + +buffer = new SendableArrayBuffer(1.1); +assert.sameValue(buffer.byteLength, 1, "1.1"); + +buffer = new SendableArrayBuffer(1.9); +assert.sameValue(buffer.byteLength, 1, "1.9"); + +buffer = new SendableArrayBuffer(-0.1); +assert.sameValue(buffer.byteLength, 0, "-0.1"); + +buffer = new SendableArrayBuffer(-0.99999); +assert.sameValue(buffer.byteLength, 0, "-0.99999"); diff --git a/test/sendable/builtins/ArrayBuffer/undefined-newtarget-throws.js b/test/sendable/builtins/ArrayBuffer/undefined-newtarget-throws.js new file mode 100644 index 00000000000..e2738376e75 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/undefined-newtarget-throws.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + Throws a TypeError if SendableArrayBuffer is called as a function. +info: | + SendableArrayBuffer( length ) + + SendableArrayBuffer called with argument length performs the following steps: + + 1. If NewTarget is undefined, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableArrayBuffer(); +}); + +assert.throws(TypeError, function() { + SendableArrayBuffer(10); +}); diff --git a/test/sendable/builtins/ArrayBuffer/zero-length.js b/test/sendable/builtins/ArrayBuffer/zero-length.js new file mode 100644 index 00000000000..ccd71e026e4 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/zero-length.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + The `length` parameter can be zero. +info: | + SendableArrayBuffer( length ) + + ... + 2. Let numberLength be ToNumber(length). + 3. Let byteLength be ToLength(numberLength). + 4. ReturnIfAbrupt(byteLength). + 5. If SameValueZero(numberLength, byteLength) is false, throw a RangeError exception. + ... +---*/ + +var positiveZero = new SendableArrayBuffer(+0); +assert.sameValue(positiveZero.byteLength, 0); + +var negativeZero = new SendableArrayBuffer(-0); +assert.sameValue(negativeZero.byteLength, 0); -- Gitee From 5b8fc328c0ebdaa60b07a5643e364b07aa162125 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 23 Dec 2024 14:57:56 +0800 Subject: [PATCH 29/93] Merge branch 'wuchaochao' SendableArrayBuffer base test Signed-off-by: zhuzhihui7 --- .../builtins/ArrayBuffer/allocation-limit.js | 31 +++++++ .../data-allocation-after-object-creation.js | 38 ++++++++ .../builtins/ArrayBuffer/init-zero.js | 34 ++++++++ .../builtins/ArrayBuffer/is-a-constructor.js | 24 +++++ .../builtins/ArrayBuffer/length-is-absent.js | 18 ++++ .../ArrayBuffer/length-is-too-large-throws.js | 31 +++++++ test/sendable/builtins/ArrayBuffer/length.js | 33 +++++++ test/sendable/builtins/ArrayBuffer/name.js | 8 +- .../ArrayBuffer/negative-length-throws.js | 34 ++++++++ .../newtarget-prototype-is-not-object.js | 48 ++++++++++ .../options-maxbytelength-allocation-limit.js | 40 +++++++++ ...elength-compared-before-object-creation.js | 40 +++++++++ ...h-data-allocation-after-object-creation.js | 41 +++++++++ .../options-maxbytelength-diminuitive.js | 22 +++++ .../options-maxbytelength-excessive.js | 28 ++++++ .../options-maxbytelength-negative.js | 25 ++++++ .../options-maxbytelength-object.js | 45 ++++++++++ .../options-maxbytelength-poisoned.js | 29 +++++++ .../options-maxbytelength-undefined.js | 24 +++++ .../ArrayBuffer/options-non-object.js | 27 ++++++ .../builtins/ArrayBuffer/prop-desc.js | 23 +++++ .../ArrayBuffer/proto-from-ctor-realm.js | 27 ++++++ .../ArrayBuffer/prototype-from-newtarget.js | 34 ++++++++ .../return-abrupt-from-length-symbol.js | 21 +++++ .../ArrayBuffer/return-abrupt-from-length.js | 24 +++++ .../builtins/ArrayBuffer/toindex-length.js | 87 +++++++++++++++++++ .../ArrayBuffer/undefined-newtarget-throws.js | 23 +++++ .../builtins/ArrayBuffer/zero-length.js | 23 +++++ 28 files changed, 878 insertions(+), 4 deletions(-) create mode 100644 test/sendable/builtins/ArrayBuffer/allocation-limit.js create mode 100644 test/sendable/builtins/ArrayBuffer/data-allocation-after-object-creation.js create mode 100644 test/sendable/builtins/ArrayBuffer/init-zero.js create mode 100644 test/sendable/builtins/ArrayBuffer/is-a-constructor.js create mode 100644 test/sendable/builtins/ArrayBuffer/length-is-absent.js create mode 100644 test/sendable/builtins/ArrayBuffer/length-is-too-large-throws.js create mode 100644 test/sendable/builtins/ArrayBuffer/length.js create mode 100644 test/sendable/builtins/ArrayBuffer/negative-length-throws.js create mode 100644 test/sendable/builtins/ArrayBuffer/newtarget-prototype-is-not-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-allocation-limit.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-diminuitive.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-excessive.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-negative.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-poisoned.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-maxbytelength-undefined.js create mode 100644 test/sendable/builtins/ArrayBuffer/options-non-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prop-desc.js create mode 100644 test/sendable/builtins/ArrayBuffer/proto-from-ctor-realm.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype-from-newtarget.js create mode 100644 test/sendable/builtins/ArrayBuffer/return-abrupt-from-length-symbol.js create mode 100644 test/sendable/builtins/ArrayBuffer/return-abrupt-from-length.js create mode 100644 test/sendable/builtins/ArrayBuffer/toindex-length.js create mode 100644 test/sendable/builtins/ArrayBuffer/undefined-newtarget-throws.js create mode 100644 test/sendable/builtins/ArrayBuffer/zero-length.js diff --git a/test/sendable/builtins/ArrayBuffer/allocation-limit.js b/test/sendable/builtins/ArrayBuffer/allocation-limit.js new file mode 100644 index 00000000000..83d5962f3ac --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/allocation-limit.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + Throws a RangeError if requested Data Block is too large. +info: | + SendableArrayBuffer( length ) + + ... + 6. Return AllocateSendableArrayBuffer(NewTarget, byteLength). + + 6.2.6.1 CreateByteDataBlock(size) + ... + 2. Let db be a new Data Block value consisting of size bytes. If it is + impossible to create such a Data Block, throw a RangeError exception. + ... +---*/ + +assert.throws(RangeError, function() { + // Allocating 7 PiB should fail with a RangeError. + // Math.pow(1024, 5) = 1125899906842624 + new SendableArrayBuffer(7 * 1125899906842624); +}, "`length` parameter is 7 PiB"); + +assert.throws(RangeError, function() { + // Allocating almost 8 PiB should fail with a RangeError. + // Math.pow(2, 53) = 9007199254740992 + new SendableArrayBuffer(9007199254740992 - 1); +}, "`length` parameter is Math.pow(2, 53) - 1"); diff --git a/test/sendable/builtins/ArrayBuffer/data-allocation-after-object-creation.js b/test/sendable/builtins/ArrayBuffer/data-allocation-after-object-creation.js new file mode 100644 index 00000000000..96c8076a01c --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/data-allocation-after-object-creation.js @@ -0,0 +1,38 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + The new SendableArrayBuffer instance is created prior to allocating the Data Block. +info: | + SendableArrayBuffer( length ) + + ... + 6. Return AllocateSendableArrayBuffer(NewTarget, byteLength). + + AllocateSendableArrayBuffer( constructor, byteLength ) + 1. Let obj be OrdinaryCreateFromConstructor(constructor, "%SendableArrayBufferPrototype%", + «[[SendableArrayBufferData]], [[SendableArrayBufferByteLength]]» ). + 2. ReturnIfAbrupt(obj). + ... + 4. Let block be CreateByteDataBlock(byteLength). + 5. ReturnIfAbrupt(block). + ... +features: [Reflect.construct] +---*/ + +function DummyError() {} + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get: function() { + throw new DummyError(); + } +}); + +assert.throws(DummyError, function() { + // Allocating 7 PiB should fail with a RangeError. + // Math.pow(1024, 5) = 1125899906842624 + Reflect.construct(SendableArrayBuffer, [7 * 1125899906842624], newTarget); +}); diff --git a/test/sendable/builtins/ArrayBuffer/init-zero.js b/test/sendable/builtins/ArrayBuffer/init-zero.js new file mode 100644 index 00000000000..9c5a4431ce5 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/init-zero.js @@ -0,0 +1,34 @@ +// 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-sendableArrayBuffer-length +description: All bytes are initialized to zero +info: | + [...] + 5. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength). + + 24.1.1.1 AllocateSendableArrayBuffer + + 3. Let block be ? CreateByteDataBlock(byteLength). + + 6.2.6.1 CreateByteDataBlock + + 1. Assert: size≥0. + 2. Let db be a new Data Block value consisting of size bytes. If it is + impossible to create such a Data Block, throw a RangeError exception. + 3. Set all of the bytes of db to 0. + 4. Return db. +features: [DataView] +---*/ + +var view = new DataView(new SendableArrayBuffer(9)); + +assert.sameValue(view.getUint8(0), 0, 'index 0'); +assert.sameValue(view.getUint8(1), 0, 'index 1'); +assert.sameValue(view.getUint8(2), 0, 'index 2'); +assert.sameValue(view.getUint8(3), 0, 'index 3'); +assert.sameValue(view.getUint8(4), 0, 'index 4'); +assert.sameValue(view.getUint8(5), 0, 'index 5'); +assert.sameValue(view.getUint8(6), 0, 'index 6'); +assert.sameValue(view.getUint8(7), 0, 'index 7'); +assert.sameValue(view.getUint8(8), 0, 'index 8'); diff --git a/test/sendable/builtins/ArrayBuffer/is-a-constructor.js b/test/sendable/builtins/ArrayBuffer/is-a-constructor.js new file mode 100644 index 00000000000..bec4c463ac5 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/is-a-constructor.js @@ -0,0 +1,24 @@ +// 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: > + The SendableArrayBuffer constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct, SendableArrayBuffer] +---*/ + +assert.sameValue(isConstructor(SendableArrayBuffer), true, 'isConstructor(SendableArrayBuffer) must return true'); +new SendableArrayBuffer(); + diff --git a/test/sendable/builtins/ArrayBuffer/length-is-absent.js b/test/sendable/builtins/ArrayBuffer/length-is-absent.js new file mode 100644 index 00000000000..c34dff3e66e --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/length-is-absent.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-sendableArrayBuffer-length +description: > + Returns an empty instance if length is absent +info: | + SendableArrayBuffer( length ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength). +---*/ + +var buffer = new SendableArrayBuffer(); + +assert.sameValue(buffer.byteLength, 0); diff --git a/test/sendable/builtins/ArrayBuffer/length-is-too-large-throws.js b/test/sendable/builtins/ArrayBuffer/length-is-too-large-throws.js new file mode 100644 index 00000000000..9fba5d505ff --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/length-is-too-large-throws.js @@ -0,0 +1,31 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + Throws a RangeError if length >= 2 ** 53 +info: | + SendableArrayBuffer( length ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + + ToIndex( value ) + + 1. If value is undefined, then + a. Let index be 0. + 2. Else, + a. Let integerIndex be ? ToInteger(value). + b. If integerIndex < 0, throw a RangeError exception. + ... +---*/ + +assert.throws(RangeError, function() { + // Math.pow(2, 53) = 9007199254740992 + new SendableArrayBuffer(9007199254740992); +}, "`length` parameter is too large"); + +assert.throws(RangeError, function() { + new SendableArrayBuffer(Infinity); +}, "`length` parameter is positive Infinity"); diff --git a/test/sendable/builtins/ArrayBuffer/length.js b/test/sendable/builtins/ArrayBuffer/length.js new file mode 100644 index 00000000000..a53ff2323a4 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/length.js @@ -0,0 +1,33 @@ +// Copyright (C) 2017 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-constructor +description: > + SendableArrayBuffer.length is 1. +info: | + SendableArrayBuffer ( length ) + + 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. Optional parameters + (which are indicated with brackets: [ ]) or rest parameters (which + are 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] +features: [SendableArrayBuffer] +---*/ + +verifyProperty(SendableArrayBuffer, "length", { + value: 1, + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/ArrayBuffer/name.js b/test/sendable/builtins/ArrayBuffer/name.js index 0bca8a2795c..6552d7a52b5 100644 --- a/test/sendable/builtins/ArrayBuffer/name.js +++ b/test/sendable/builtins/ArrayBuffer/name.js @@ -2,9 +2,9 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-sendableArrayBuffer-constructor +esid: sec-sendableSendableArrayBuffer-constructor description: > - SendableArrayBuffer.name is "SendableArrayBuffer". + SendableSendableArrayBuffer.name is "SendableSendableArrayBuffer". info: | 17 ECMAScript Standard Built-in Objects: @@ -19,9 +19,9 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(SendableArrayBuffer.name, "SendableArrayBuffer"); +assert.sameValue(SendableSendableArrayBuffer.name, "SendableSendableArrayBuffer"); -verifyProperty(SendableArrayBuffer, "name", { +verifyProperty(SendableSendableArrayBuffer, "name", { writable: false, enumerable: false, configurable: true, diff --git a/test/sendable/builtins/ArrayBuffer/negative-length-throws.js b/test/sendable/builtins/ArrayBuffer/negative-length-throws.js new file mode 100644 index 00000000000..a59493a801f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/negative-length-throws.js @@ -0,0 +1,34 @@ +// 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-sendableArrayBuffer-length +description: > + Throws a Range Error if length represents an integer < 0 +info: | + SendableArrayBuffer( length ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + + ToIndex( value ) + + 1. If value is undefined, then + a. Let index be 0. + 2. Else, + a. Let integerIndex be ? ToInteger(value). + b. If integerIndex < 0, throw a RangeError exception. + ... +---*/ + +assert.throws(RangeError, function() { + new SendableArrayBuffer(-1); +}); + +assert.throws(RangeError, function() { + new SendableArrayBuffer(-1.1); +}); + +assert.throws(RangeError, function() { + new SendableArrayBuffer(-Infinity); +}); diff --git a/test/sendable/builtins/ArrayBuffer/newtarget-prototype-is-not-object.js b/test/sendable/builtins/ArrayBuffer/newtarget-prototype-is-not-object.js new file mode 100644 index 00000000000..77ab90d0f73 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/newtarget-prototype-is-not-object.js @@ -0,0 +1,48 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + [[Prototype]] defaults to %SendableArrayBufferPrototype% if NewTarget.prototype is not an object. +info: | + SendableArrayBuffer( length ) + + SendableArrayBuffer called with argument length performs the following steps: + + ... + 6. Return AllocateSendableArrayBuffer(NewTarget, byteLength). + + AllocateSendableArrayBuffer( constructor, byteLength ) + 1. Let obj be OrdinaryCreateFromConstructor(constructor, "%SendableArrayBufferPrototype%", + «[[SendableArrayBufferData]], [[SendableArrayBufferByteLength]]» ). + 2. ReturnIfAbrupt(obj). + ... +features: [Reflect.construct, Symbol] +---*/ + +function newTarget() {} + +newTarget.prototype = undefined; +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), SendableArrayBuffer.prototype, "newTarget.prototype is undefined"); + +newTarget.prototype = null; +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [2], newTarget); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), SendableArrayBuffer.prototype, "newTarget.prototype is null"); + +newTarget.prototype = true; +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [3], newTarget); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), SendableArrayBuffer.prototype, "newTarget.prototype is a Boolean"); + +newTarget.prototype = ""; +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [4], newTarget); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), SendableArrayBuffer.prototype, "newTarget.prototype is a String"); + +newTarget.prototype = Symbol(); +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [5], newTarget); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), SendableArrayBuffer.prototype, "newTarget.prototype is a Symbol"); + +newTarget.prototype = 1; +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [6], newTarget); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), SendableArrayBuffer.prototype, "newTarget.prototype is a Number"); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-allocation-limit.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-allocation-limit.js new file mode 100644 index 00000000000..22cee7db010 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-allocation-limit.js @@ -0,0 +1,40 @@ +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + Throws a RangeError if the requested Data Block is too large. +info: | + SendableArrayBuffer ( length [ , options ] ) + + ... + 4. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength, requestedMaxByteLength). + + AllocateSendableArrayBuffer ( constructor, byteLength [ , maxByteLength ] ) + + ... + 5. Let block be ? CreateByteDataBlock(byteLength). + ... + + CreateByteDataBlock ( size ) + + ... + 2. Let db be a new Data Block value consisting of size bytes. If it is + impossible to create such a Data Block, throw a RangeError exception. + ... + +features: [resizable-SendableArrayBuffer] +---*/ + +assert.throws(RangeError, function() { + // Allocating 7 PiB should fail with a RangeError. + // Math.pow(1024, 5) = 1125899906842624 + new SendableArrayBuffer(0, {maxByteLength: 7 * 1125899906842624}); +}, "`maxByteLength` option is 7 PiB"); + +assert.throws(RangeError, function() { + // Allocating almost 8 PiB should fail with a RangeError. + // Math.pow(2, 53) = 9007199254740992 + new SendableArrayBuffer(0, {maxByteLength: 9007199254740992 - 1}); +}, "`maxByteLength` option is Math.pow(2, 53) - 1"); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js new file mode 100644 index 00000000000..614641bd233 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js @@ -0,0 +1,40 @@ +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + The byteLength argument is validated before OrdinaryCreateFromConstructor. +info: | + SendableArrayBuffer ( length [ , options ] ) + + ... + 4. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength, requestedMaxByteLength). + + AllocateSendableArrayBuffer ( constructor, byteLength [ , maxByteLength ] ) + + ... + 3. If allocatingResizableBuffer is true, then + a. If byteLength > maxByteLength, throw a RangeError exception. + ... + 4. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%SendableArrayBuffer.prototype%", slots). + ... + +features: [resizable-SendableArrayBuffer, Reflect.construct] +---*/ + +let newTarget = Object.defineProperty(function(){}.bind(null), "prototype", { + get() { + throw new Test262Error(); + } +}); + +assert.throws(RangeError, function() { + let byteLength = 10; + let options = { + maxByteLength: 0, + }; + + // Throws a RangeError, because `byteLength` is larger than `options.maxByteLength`. + Reflect.construct(SendableArrayBuffer, [byteLength, options], newTarget); +}); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js new file mode 100644 index 00000000000..38672b7cf4f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js @@ -0,0 +1,41 @@ +// Copyright (C) 2024 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + The new SendableArrayBuffer instance is created prior to allocating the Data Block. +info: | + SendableArrayBuffer ( length [ , options ] ) + + ... + 4. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength, requestedMaxByteLength). + + AllocateSendableArrayBuffer ( constructor, byteLength [ , maxByteLength ] ) + + ... + 4. Let obj be ? OrdinaryCreateFromConstructor(constructor, "%SendableArrayBuffer.prototype%", slots). + 5. Let block be ? CreateByteDataBlock(byteLength). + ... + +features: [resizable-SendableArrayBuffer, Reflect.construct] +---*/ + +function DummyError() {} + +let newTarget = Object.defineProperty(function(){}.bind(null), "prototype", { + get() { + throw new DummyError(); + } +}); + +assert.throws(DummyError, function() { + let byteLength = 0; + let options = { + maxByteLength: 7 * 1125899906842624 + }; + + // Allocating 7 PiB should fail with a RangeError. + // Math.pow(1024, 5) = 1125899906842624 + Reflect.construct(SendableArrayBuffer, [], newTarget); +}); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-diminuitive.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-diminuitive.js new file mode 100644 index 00000000000..d1108351632 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-diminuitive.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sendableArrayBuffer-constructor +description: | + Invoked with an options object whose `maxByteLength` property is less than + the length. +info: | + SendableArrayBuffer( length [ , options ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Let requestedMaxByteLength be ? GetSendableArrayBufferMaxByteLengthOption(options). + 4. If requestedMaxByteLength is empty, then + a. [...] + 5. If byteLength > requestedMaxByteLength, throw a RangeError exception. +features: [resizable-SendableArrayBuffer] +---*/ + +assert.throws(RangeError, function() { + new SendableArrayBuffer(1, {maxByteLength: 0}); +}); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-excessive.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-excessive.js new file mode 100644 index 00000000000..e988acc74e4 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-excessive.js @@ -0,0 +1,28 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sendableArrayBuffer-constructor +description: | + Invoked with an options object whose `maxByteLength` property exceeds the + maximum length value +info: | + SendableArrayBuffer( length [ , options ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Let requestedMaxByteLength be ? GetSendableArrayBufferMaxByteLengthOption(options). + [...] + + 1.1.5 GetSendableArrayBufferMaxByteLengthOption ( options ) + + 1. If Type(options) is not Object, return empty. + 2. Let maxByteLength be ? Get(options, "maxByteLength"). + 3. If maxByteLength is undefined, return empty. + 4. Return ? ToIndex(maxByteLength). +features: [resizable-SendableArrayBuffer] +---*/ + +assert.throws(RangeError, function() { + // Math.pow(2, 53) = 9007199254740992 + new SendableArrayBuffer(0, { maxByteLength: 9007199254740992 }); +}); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-negative.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-negative.js new file mode 100644 index 00000000000..55907105b22 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-negative.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sendableArrayBuffer-constructor +description: Invoked with an options object whose `maxByteLength` property is negative +info: | + SendableArrayBuffer( length [ , options ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Let requestedMaxByteLength be ? GetSendableArrayBufferMaxByteLengthOption(options). + [...] + + 1.1.5 GetSendableArrayBufferMaxByteLengthOption ( options ) + + 1. If Type(options) is not Object, return empty. + 2. Let maxByteLength be ? Get(options, "maxByteLength"). + 3. If maxByteLength is undefined, return empty. + 4. Return ? ToIndex(maxByteLength). +features: [resizable-SendableArrayBuffer] +---*/ + +assert.throws(RangeError, function() { + new SendableArrayBuffer(0, { maxByteLength: -1 }); +}); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-object.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-object.js new file mode 100644 index 00000000000..fe4969cf993 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-object.js @@ -0,0 +1,45 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sendableArrayBuffer-constructor +description: | + Invoked with an options object whose `maxByteLength` property cannot be + coerced to a primitive value +info: | + SendableArrayBuffer( length [ , options ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Let requestedMaxByteLength be ? GetSendableArrayBufferMaxByteLengthOption(options). + [...] + + 1.1.5 GetSendableArrayBufferMaxByteLengthOption ( options ) + + 1. If Type(options) is not Object, return empty. + 2. Let maxByteLength be ? Get(options, "maxByteLength"). + 3. If maxByteLength is undefined, return empty. + 4. Return ? ToIndex(maxByteLength). +features: [resizable-SendableArrayBuffer] +---*/ + +var log = []; +var options = { + maxByteLength: { + toString: function() { + log.push('toString'); + return {}; + }, + valueOf: function() { + log.push('valueOf'); + return {}; + } + } +}; + +assert.throws(TypeError, function() { + new SendableArrayBuffer(0, options); +}); + +assert.sameValue(log.length, 2); +assert.sameValue(log[0], 'valueOf'); +assert.sameValue(log[1], 'toString'); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-poisoned.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-poisoned.js new file mode 100644 index 00000000000..b0337e7e5b1 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-poisoned.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sendableArrayBuffer-constructor +description: Invoked with an options object whose `maxByteLength` property throws +info: | + SendableArrayBuffer( length [ , options ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Let requestedMaxByteLength be ? GetSendableArrayBufferMaxByteLengthOption(options). + [...] + + 1.1.5 GetSendableArrayBufferMaxByteLengthOption ( options ) + + 1. If Type(options) is not Object, return empty. + 2. Let maxByteLength be ? Get(options, "maxByteLength"). +features: [resizable-SendableArrayBuffer] +---*/ + +var options = { + get maxByteLength() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + new SendableArrayBuffer(0, options); +}); diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-undefined.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-undefined.js new file mode 100644 index 00000000000..fb1b8c82e49 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-undefined.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sendableArrayBuffer-constructor +description: Invoked with an options object whose `maxByteLength` property is undefined +info: | + SendableArrayBuffer( length [ , options ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Let requestedMaxByteLength be ? GetSendableArrayBufferMaxByteLengthOption(options). + 4. If requestedMaxByteLength is empty, then + a. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength). + + 1.1.5 GetSendableArrayBufferMaxByteLengthOption ( options ) + + 1. If Type(options) is not Object, return empty. + 2. Let maxByteLength be ? Get(options, "maxByteLength"). + 3. If maxByteLength is undefined, return empty. +features: [resizable-SendableArrayBuffer] +---*/ + +assert.sameValue(new SendableArrayBuffer(0, {}).resizable, false); +assert.sameValue(new SendableArrayBuffer(0, {maxByteLength: undefined}).resizable, false); diff --git a/test/sendable/builtins/ArrayBuffer/options-non-object.js b/test/sendable/builtins/ArrayBuffer/options-non-object.js new file mode 100644 index 00000000000..975dee7e68a --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/options-non-object.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-sendableArrayBuffer-constructor +description: Invoked with a non-object value for options +info: | + SendableArrayBuffer( length [ , options ] ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Let requestedMaxByteLength be ? GetSendableArrayBufferMaxByteLengthOption(options). + 4. If requestedMaxByteLength is empty, then + a. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength). + + 1.1.5 GetSendableArrayBufferMaxByteLengthOption ( options ) + + 1. If Type(options) is not Object, return empty. +features: [resizable-SendableArrayBuffer] +---*/ + +assert.sameValue(new SendableArrayBuffer(0, null).resizable, false, 'null'); +assert.sameValue(new SendableArrayBuffer(0, true).resizable, false, 'boolean'); +assert.sameValue(new SendableArrayBuffer(0, Symbol(3)).resizable, false, 'symbol'); +assert.sameValue(new SendableArrayBuffer(0, 1n).resizable, false, 'bigint'); +assert.sameValue(new SendableArrayBuffer(0, 'string').resizable, false, 'string'); +assert.sameValue(new SendableArrayBuffer(0, 9).resizable, false, 'number'); +assert.sameValue(new SendableArrayBuffer(0, undefined).resizable, false, 'undefined'); diff --git a/test/sendable/builtins/ArrayBuffer/prop-desc.js b/test/sendable/builtins/ArrayBuffer/prop-desc.js new file mode 100644 index 00000000000..0623ce3fc03 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prop-desc.js @@ -0,0 +1,23 @@ +// Copyright (C) 2017 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-constructor +description: > + Property descriptor of SendableArrayBuffer +info: | + 17 ECMAScript Standard Built-in Objects: + + 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] +---*/ + +assert.sameValue(typeof SendableArrayBuffer, "function", "`typeof SendableArrayBuffer` is `'function'`"); + +verifyProperty(this, "SendableArrayBuffer", { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/ArrayBuffer/proto-from-ctor-realm.js b/test/sendable/builtins/ArrayBuffer/proto-from-ctor-realm.js new file mode 100644 index 00000000000..f7acb5190c3 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/proto-from-ctor-realm.js @@ -0,0 +1,27 @@ +// 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-sendableArrayBuffer-length +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 5. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength). + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var o = Reflect.construct(SendableArrayBuffer, [], C); + +assert.sameValue(Object.getPrototypeOf(o), other.SendableArrayBuffer.prototype); diff --git a/test/sendable/builtins/ArrayBuffer/prototype-from-newtarget.js b/test/sendable/builtins/ArrayBuffer/prototype-from-newtarget.js new file mode 100644 index 00000000000..bcbaa43c18f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype-from-newtarget.js @@ -0,0 +1,34 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + The [[Prototype]] internal slot is computed from NewTarget. +info: | + SendableArrayBuffer( length ) + + SendableArrayBuffer called with argument length performs the following steps: + + ... + 6. Return AllocateSendableArrayBuffer(NewTarget, byteLength). + + AllocateSendableArrayBuffer( constructor, byteLength ) + 1. Let obj be OrdinaryCreateFromConstructor(constructor, "%SendableArrayBufferPrototype%", + «[[SendableArrayBufferData]], [[SendableArrayBufferByteLength]]» ). + 2. ReturnIfAbrupt(obj). + ... +features: [Reflect.construct] +---*/ + +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [8], Object); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), Object.prototype, "NewTarget is built-in Object constructor"); + +var newTarget = function() {}.bind(null); +Object.defineProperty(newTarget, "prototype", { + get: function() { + return Array.prototype; + } +}); +var SendableArrayBuffer = Reflect.construct(SendableArrayBuffer, [16], newTarget); +assert.sameValue(Object.getPrototypeOf(SendableArrayBuffer), Array.prototype, "NewTarget is BoundFunction with accessor"); diff --git a/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length-symbol.js b/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length-symbol.js new file mode 100644 index 00000000000..11be1d4bcf9 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length-symbol.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-sendableArrayBuffer-length +description: > + Throws a TypeError if length is a symbol +info: | + SendableArrayBuffer( length ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + ... +features: [Symbol] +---*/ + +var s = Symbol(); + +assert.throws(TypeError, function() { + new SendableArrayBuffer(s); +}, "`length` parameter is a Symbol"); diff --git a/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length.js b/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length.js new file mode 100644 index 00000000000..55a6f68daf2 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length.js @@ -0,0 +1,24 @@ +// 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-sendableArrayBuffer-length +description: > + Return abrupt from ToIndex(length) +info: | + SendableArrayBuffer( length ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + ... +---*/ + +var len = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + new SendableArrayBuffer(len); +}); diff --git a/test/sendable/builtins/ArrayBuffer/toindex-length.js b/test/sendable/builtins/ArrayBuffer/toindex-length.js new file mode 100644 index 00000000000..1794e8da943 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/toindex-length.js @@ -0,0 +1,87 @@ +// 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-sendableArrayBuffer-length +description: > + The `length` parameter is converted to a value numeric index value. +info: | + SendableArrayBuffer( length ) + + 1. If NewTarget is undefined, throw a TypeError exception. + 2. Let byteLength be ? ToIndex(length). + 3. Return ? AllocateSendableArrayBuffer(NewTarget, byteLength). + + ToIndex( value ) + + 1. If value is undefined, then + a. Let index be 0. + 2. Else, + a. Let integerIndex be ? ToInteger(value). + b. If integerIndex < 0, throw a RangeError exception. + c. Let index be ! ToLength(integerIndex). + d. If SameValueZero(integerIndex, index) is false, throw a RangeError exception. + 3. Return index. +---*/ + +var obj1 = { + valueOf: function() { + return 42; + } +}; + +var obj2 = { + toString: function() { + return 42; + } +}; + +var buffer; + +buffer = new SendableArrayBuffer(obj1); +assert.sameValue(buffer.byteLength, 42, "object's valueOf"); + +buffer = new SendableArrayBuffer(obj2); +assert.sameValue(buffer.byteLength, 42, "object's toString"); + +buffer = new SendableArrayBuffer(""); +assert.sameValue(buffer.byteLength, 0, "the Empty string"); + +buffer = new SendableArrayBuffer("0"); +assert.sameValue(buffer.byteLength, 0, "string '0'"); + +buffer = new SendableArrayBuffer("1"); +assert.sameValue(buffer.byteLength, 1, "string '1'"); + +buffer = new SendableArrayBuffer(true); +assert.sameValue(buffer.byteLength, 1, "true"); + +buffer = new SendableArrayBuffer(false); +assert.sameValue(buffer.byteLength, 0, "false"); + +buffer = new SendableArrayBuffer(NaN); +assert.sameValue(buffer.byteLength, 0, "NaN"); + +buffer = new SendableArrayBuffer(null); +assert.sameValue(buffer.byteLength, 0, "null"); + +buffer = new SendableArrayBuffer(undefined); +assert.sameValue(buffer.byteLength, 0, "undefined"); + +buffer = new SendableArrayBuffer(0.1); +assert.sameValue(buffer.byteLength, 0, "0.1"); + +buffer = new SendableArrayBuffer(0.9); +assert.sameValue(buffer.byteLength, 0, "0.9"); + +buffer = new SendableArrayBuffer(1.1); +assert.sameValue(buffer.byteLength, 1, "1.1"); + +buffer = new SendableArrayBuffer(1.9); +assert.sameValue(buffer.byteLength, 1, "1.9"); + +buffer = new SendableArrayBuffer(-0.1); +assert.sameValue(buffer.byteLength, 0, "-0.1"); + +buffer = new SendableArrayBuffer(-0.99999); +assert.sameValue(buffer.byteLength, 0, "-0.99999"); diff --git a/test/sendable/builtins/ArrayBuffer/undefined-newtarget-throws.js b/test/sendable/builtins/ArrayBuffer/undefined-newtarget-throws.js new file mode 100644 index 00000000000..e2738376e75 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/undefined-newtarget-throws.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + Throws a TypeError if SendableArrayBuffer is called as a function. +info: | + SendableArrayBuffer( length ) + + SendableArrayBuffer called with argument length performs the following steps: + + 1. If NewTarget is undefined, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableArrayBuffer(); +}); + +assert.throws(TypeError, function() { + SendableArrayBuffer(10); +}); diff --git a/test/sendable/builtins/ArrayBuffer/zero-length.js b/test/sendable/builtins/ArrayBuffer/zero-length.js new file mode 100644 index 00000000000..ccd71e026e4 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/zero-length.js @@ -0,0 +1,23 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer-length +description: > + The `length` parameter can be zero. +info: | + SendableArrayBuffer( length ) + + ... + 2. Let numberLength be ToNumber(length). + 3. Let byteLength be ToLength(numberLength). + 4. ReturnIfAbrupt(byteLength). + 5. If SameValueZero(numberLength, byteLength) is false, throw a RangeError exception. + ... +---*/ + +var positiveZero = new SendableArrayBuffer(+0); +assert.sameValue(positiveZero.byteLength, 0); + +var negativeZero = new SendableArrayBuffer(-0); +assert.sameValue(negativeZero.byteLength, 0); -- Gitee From effaa87896e3b014f0636ce7748135b8d75e7881 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 23 Dec 2024 15:05:13 +0800 Subject: [PATCH 30/93] arrarybuffer isview test Signed-off-by: zhuzhihui7 --- .../isView/arg-has-no-viewedarraybuffer.js | 17 +++++++++++ .../ArrayBuffer/isView/arg-is-arraybuffer.js | 18 +++++++++++ .../isView/arg-is-dataview-buffer.js | 19 ++++++++++++ .../isView/arg-is-dataview-constructor.js | 17 +++++++++++ .../arg-is-dataview-subclass-instance.js | 21 +++++++++++++ .../ArrayBuffer/isView/arg-is-dataview.js | 19 ++++++++++++ .../ArrayBuffer/isView/arg-is-not-object.js | 18 +++++++++++ .../isView/arg-is-typedarray-buffer.js | 22 ++++++++++++++ .../isView/arg-is-typedarray-constructor.js | 20 +++++++++++++ .../arg-is-typedarray-subclass-instance.js | 24 +++++++++++++++ .../ArrayBuffer/isView/arg-is-typedarray.js | 22 ++++++++++++++ .../ArrayBuffer/isView/invoked-as-a-fn.js | 29 ++++++++++++++++++ .../builtins/ArrayBuffer/isView/length.js | 30 +++++++++++++++++++ .../builtins/ArrayBuffer/isView/name.js | 27 +++++++++++++++++ .../builtins/ArrayBuffer/isView/no-arg.js | 15 ++++++++++ .../ArrayBuffer/isView/not-a-constructor.js | 29 ++++++++++++++++++ .../builtins/ArrayBuffer/isView/prop-desc.js | 19 ++++++++++++ 17 files changed, 366 insertions(+) create mode 100644 test/sendable/builtins/ArrayBuffer/isView/arg-has-no-viewedarraybuffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/arg-is-arraybuffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-buffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-constructor.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-subclass-instance.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/arg-is-not-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-buffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-constructor.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/invoked-as-a-fn.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/length.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/name.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/no-arg.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/not-a-constructor.js create mode 100644 test/sendable/builtins/ArrayBuffer/isView/prop-desc.js diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-has-no-viewedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/isView/arg-has-no-viewedarraybuffer.js new file mode 100644 index 00000000000..5208a7764fa --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-has-no-viewedarraybuffer.js @@ -0,0 +1,17 @@ +// 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-sendableArrayBuffer.isview +description: > + Return false if arg has no [[ViewedSendableArrayBuffer]] internal slot. +info: | + 24.1.3.1 SendableArrayBuffer.isView ( arg ) + + 1. If Type(arg) is not Object, return false. + 2. If arg has a [[ViewedSendableArrayBuffer]] internal slot, return true. + 3. Return false. +---*/ + +assert.sameValue(SendableArrayBuffer.isView({}), false, "ordinary object"); +assert.sameValue(SendableArrayBuffer.isView([]), false, "Array"); diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-arraybuffer.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-arraybuffer.js new file mode 100644 index 00000000000..05888fbf129 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-arraybuffer.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-sendableArrayBuffer.isview +description: > + Return false from an instance of SendableArrayBuffer +info: | + 24.1.3.1 SendableArrayBuffer.isView ( arg ) + + 1. If Type(arg) is not Object, return false. + 2. If arg has a [[ViewedSendableArrayBuffer]] internal slot, return true. + 3. Return false. +---*/ + +var sample = new SendableArrayBuffer(1); + +assert.sameValue(SendableArrayBuffer.isView(sample), false); diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-buffer.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-buffer.js new file mode 100644 index 00000000000..7e44d26d7ef --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-buffer.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-sendableArrayBuffer.isview +description: > + Return false from DataView's instance `.buffer` +info: | + 24.1.3.1 SendableArrayBuffer.isView ( arg ) + + 1. If Type(arg) is not Object, return false. + 2. If arg has a [[ViewedSendableArrayBuffer]] internal slot, return true. + 3. Return false. +features: [DataView] +---*/ + +var sample = new DataView(new SendableArrayBuffer(1), 0, 0).buffer; + +assert.sameValue(SendableArrayBuffer.isView(sample), false); diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-constructor.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-constructor.js new file mode 100644 index 00000000000..ff85fc8e9d9 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-constructor.js @@ -0,0 +1,17 @@ +// 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-sendableArrayBuffer.isview +description: > + Return false if arg is the DataView constructor +info: | + 24.1.3.1 SendableArrayBuffer.isView ( arg ) + + 1. If Type(arg) is not Object, return false. + 2. If arg has a [[ViewedSendableArrayBuffer]] internal slot, return true. + 3. Return false. +features: [DataView] +---*/ + +assert.sameValue(SendableArrayBuffer.isView(DataView), false, "DataView"); diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-subclass-instance.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-subclass-instance.js new file mode 100644 index 00000000000..a475ee80928 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-subclass-instance.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-sendableArrayBuffer.isview +description: > + Return true if arg is an instance from a subclass of DataView +info: | + 24.1.3.1 SendableArrayBuffer.isView ( arg ) + + 1. If Type(arg) is not Object, return false. + 2. If arg has a [[ViewedSendableArrayBuffer]] internal slot, return true. + 3. Return false. +features: [class, DataView] +---*/ + +class DV extends DataView {} + +var sample = new DV(new SendableArrayBuffer(1), 0, 0); + +assert(SendableArrayBuffer.isView(sample)); diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview.js new file mode 100644 index 00000000000..afb37c37272 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview.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-sendableArrayBuffer.isview +description: > + Return true if is an instance of DataView +info: | + 24.1.3.1 SendableArrayBuffer.isView ( arg ) + + 1. If Type(arg) is not Object, return false. + 2. If arg has a [[ViewedSendableArrayBuffer]] internal slot, return true. + 3. Return false. +features: [DataView] +---*/ + +var sample = new DataView(new SendableArrayBuffer(1), 0, 0); + +assert.sameValue(SendableArrayBuffer.isView(sample), true); diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-not-object.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-not-object.js new file mode 100644 index 00000000000..2b4fca19311 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-not-object.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-sendableArrayBuffer.isview +description: > + Return false if arg is not Object +info: | + 24.1.3.1 SendableArrayBuffer.isView ( arg ) + + 1. If Type(arg) is not Object, return false. + ... +---*/ + +assert.sameValue(SendableArrayBuffer.isView(null), false, "null"); +assert.sameValue(SendableArrayBuffer.isView(undefined), false, "undefined"); +assert.sameValue(SendableArrayBuffer.isView(1), false, "number"); +assert.sameValue(SendableArrayBuffer.isView(""), false, "string"); diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-buffer.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-buffer.js new file mode 100644 index 00000000000..9986303e512 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-buffer.js @@ -0,0 +1,22 @@ +// 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-sendableArrayBuffer.isview +description: > + Return false from TypedArray's instance `.buffer` +info: | + 24.1.3.1 SendableArrayBuffer.isView ( arg ) + + 1. If Type(arg) is not Object, return false. + 2. If arg has a [[ViewedSendableArrayBuffer]] internal slot, return true. + 3. Return false. +features: [TypedArray] +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(ctor) { + var sample = new ctor().buffer; + + assert.sameValue(SendableArrayBuffer.isView(sample), false); +}); diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-constructor.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-constructor.js new file mode 100644 index 00000000000..eaa7a27d06f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-constructor.js @@ -0,0 +1,20 @@ +// 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-sendableArrayBuffer.isview +description: > + Return false if arg is a TypedArray constructor +info: | + 24.1.3.1 SendableArrayBuffer.isView ( arg ) + + 1. If Type(arg) is not Object, return false. + 2. If arg has a [[ViewedSendableArrayBuffer]] internal slot, return true. + 3. Return false. +features: [TypedArray] +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(ctor) { + assert.sameValue(SendableArrayBuffer.isView(ctor), false); +}); diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js new file mode 100644 index 00000000000..2b710a8ce23 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js @@ -0,0 +1,24 @@ +// 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-sendableArrayBuffer.isview +description: > + Return true if arg is an instance from a subclass of TypedArray +info: | + 24.1.3.1 SendableArrayBuffer.isView ( arg ) + + 1. If Type(arg) is not Object, return false. + 2. If arg has a [[ViewedSendableArrayBuffer]] internal slot, return true. + 3. Return false. +features: [class, TypedArray] +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(ctor) { + class TA extends ctor {} + + var sample = new TA(); + + assert(SendableArrayBuffer.isView(sample)); +}); diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray.js new file mode 100644 index 00000000000..b7871704ab2 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray.js @@ -0,0 +1,22 @@ +// 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-sendableArrayBuffer.isview +description: > + Return true if arg is an instance of TypedArray +info: | + 24.1.3.1 SendableArrayBuffer.isView ( arg ) + + 1. If Type(arg) is not Object, return false. + 2. If arg has a [[ViewedSendableArrayBuffer]] internal slot, return true. + 3. Return false. +features: [TypedArray] +includes: [testTypedArray.js] +---*/ + +testWithTypedArrayConstructors(function(ctor) { + var sample = new ctor(); + + assert.sameValue(SendableArrayBuffer.isView(sample), true); +}); diff --git a/test/sendable/builtins/ArrayBuffer/isView/invoked-as-a-fn.js b/test/sendable/builtins/ArrayBuffer/isView/invoked-as-a-fn.js new file mode 100644 index 00000000000..aa4b20b90cf --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/invoked-as-a-fn.js @@ -0,0 +1,29 @@ +// 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-sendableArrayBuffer.isview +description: > + `isView` can be invoked as a function +info: | + 24.1.3.1 SendableArrayBuffer.isView ( arg ) + + 1. If Type(arg) is not Object, return false. + 2. If arg has a [[ViewedSendableArrayBuffer]] internal slot, return true. + 3. Return false. +features: [TypedArray, DataView] +includes: [testTypedArray.js] +---*/ + +var isView = SendableArrayBuffer.isView; + +testWithTypedArrayConstructors(function(ctor) { + var sample = new ctor(); + assert.sameValue(isView(sample), true, "instance of TypedArray"); +}); + +var dv = new DataView(new SendableArrayBuffer(1), 0, 0); +assert.sameValue(isView(dv), true, "instance of DataView"); + +assert.sameValue(isView(), false, "undefined arg"); +assert.sameValue(isView({}), false, "ordinary object"); diff --git a/test/sendable/builtins/ArrayBuffer/isView/length.js b/test/sendable/builtins/ArrayBuffer/isView/length.js new file mode 100644 index 00000000000..29798203aa9 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/length.js @@ -0,0 +1,30 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer.isview +description: > + SendableArrayBuffer.isView.length is 1. +info: | + SendableArrayBuffer.isView ( arg ) + + 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(SendableArrayBuffer.isView, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/isView/name.js b/test/sendable/builtins/ArrayBuffer/isView/name.js new file mode 100644 index 00000000000..435e7b3ecdc --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/name.js @@ -0,0 +1,27 @@ +// Copyright (C) 2015 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-sendableArrayBuffer.isview +description: > + SendableArrayBuffer.isView.name is "isView". +info: | + SendableArrayBuffer.isView ( arg ) + + 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(SendableArrayBuffer.isView, "name", { + value: "isView", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/isView/no-arg.js b/test/sendable/builtins/ArrayBuffer/isView/no-arg.js new file mode 100644 index 00000000000..e5ad217fa33 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/no-arg.js @@ -0,0 +1,15 @@ +// 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-sendableArrayBuffer.isview +description: > + Return false if isView is called with no arg +info: | + 24.1.3.1 SendableArrayBuffer.isView ( arg ) + + 1. If Type(arg) is not Object, return false. + ... +---*/ + +assert.sameValue(SendableArrayBuffer.isView(), false); diff --git a/test/sendable/builtins/ArrayBuffer/isView/not-a-constructor.js b/test/sendable/builtins/ArrayBuffer/isView/not-a-constructor.js new file mode 100644 index 00000000000..479578f4bba --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/not-a-constructor.js @@ -0,0 +1,29 @@ +// 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: > + SendableArrayBuffer.isView 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, SendableArrayBuffer, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableArrayBuffer.isView), false, 'isConstructor(SendableArrayBuffer.isView) must return false'); + +assert.throws(TypeError, () => { + new SendableArrayBuffer.isView(); +}); + diff --git a/test/sendable/builtins/ArrayBuffer/isView/prop-desc.js b/test/sendable/builtins/ArrayBuffer/isView/prop-desc.js new file mode 100644 index 00000000000..888330dc902 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/isView/prop-desc.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-sendableArrayBuffer.isview +description: > + "isView" property of SendableArrayBuffer +info: | + ES6 section 17: 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] +---*/ + +verifyProperty(SendableArrayBuffer, "isView", { + writable: true, + enumerable: false, + configurable: true +}); -- Gitee From f5f591729915566393ea8a8387e422a9c29375c0 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 23 Dec 2024 15:19:49 +0800 Subject: [PATCH 31/93] add new case array-filter Signed-off-by: zhuzhihui7 --- .../Array/prototype/filter/15.4.4.20-1-1.js | 22 ++++ .../Array/prototype/filter/15.4.4.20-1-10.js | 26 +++++ .../Array/prototype/filter/15.4.4.20-1-11.js | 27 +++++ .../Array/prototype/filter/15.4.4.20-1-12.js | 27 +++++ .../Array/prototype/filter/15.4.4.20-1-13.js | 26 +++++ .../Array/prototype/filter/15.4.4.20-1-14.js | 27 +++++ .../Array/prototype/filter/15.4.4.20-1-15.js | 28 +++++ .../Array/prototype/filter/15.4.4.20-1-2.js | 22 ++++ .../Array/prototype/filter/15.4.4.20-1-3.js | 26 +++++ .../Array/prototype/filter/15.4.4.20-1-4.js | 29 +++++ .../Array/prototype/filter/15.4.4.20-1-5.js | 26 +++++ .../Array/prototype/filter/15.4.4.20-1-6.js | 29 +++++ .../Array/prototype/filter/15.4.4.20-1-7.js | 24 ++++ .../Array/prototype/filter/15.4.4.20-1-8.js | 25 +++++ .../Array/prototype/filter/15.4.4.20-1-9.js | 30 +++++ .../Array/prototype/filter/15.4.4.20-10-1.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-10-2.js | 34 ++++++ .../Array/prototype/filter/15.4.4.20-10-3.js | 29 +++++ .../Array/prototype/filter/15.4.4.20-10-4.js | 29 +++++ .../Array/prototype/filter/15.4.4.20-2-1.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-2-10.js | 39 +++++++ .../Array/prototype/filter/15.4.4.20-2-11.js | 37 ++++++ .../Array/prototype/filter/15.4.4.20-2-12.js | 43 +++++++ .../Array/prototype/filter/15.4.4.20-2-13.js | 39 +++++++ .../Array/prototype/filter/15.4.4.20-2-14.js | 33 ++++++ .../Array/prototype/filter/15.4.4.20-2-17.js | 29 +++++ .../Array/prototype/filter/15.4.4.20-2-18.js | 27 +++++ .../Array/prototype/filter/15.4.4.20-2-19.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-2-2.js | 24 ++++ .../Array/prototype/filter/15.4.4.20-2-3.js | 36 ++++++ .../Array/prototype/filter/15.4.4.20-2-4.js | 29 +++++ .../Array/prototype/filter/15.4.4.20-2-5.js | 43 +++++++ .../Array/prototype/filter/15.4.4.20-2-6.js | 35 ++++++ .../Array/prototype/filter/15.4.4.20-2-7.js | 36 ++++++ .../Array/prototype/filter/15.4.4.20-2-8.js | 41 +++++++ .../Array/prototype/filter/15.4.4.20-2-9.js | 46 ++++++++ .../Array/prototype/filter/15.4.4.20-3-1.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-3-10.js | 33 ++++++ .../Array/prototype/filter/15.4.4.20-3-11.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-3-12.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-3-13.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-3-14.js | 31 ++++++ .../Array/prototype/filter/15.4.4.20-3-15.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-3-16.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-3-17.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-3-18.js | 33 ++++++ .../Array/prototype/filter/15.4.4.20-3-19.js | 36 ++++++ .../Array/prototype/filter/15.4.4.20-3-2.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-3-20.js | 36 ++++++ .../Array/prototype/filter/15.4.4.20-3-21.js | 46 ++++++++ .../Array/prototype/filter/15.4.4.20-3-22.js | 50 +++++++++ .../Array/prototype/filter/15.4.4.20-3-23.js | 49 ++++++++ .../Array/prototype/filter/15.4.4.20-3-24.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-3-25.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-3-3.js | 31 ++++++ .../Array/prototype/filter/15.4.4.20-3-4.js | 33 ++++++ .../Array/prototype/filter/15.4.4.20-3-5.js | 33 ++++++ .../Array/prototype/filter/15.4.4.20-3-6.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-3-7.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-3-9.js | 33 ++++++ .../Array/prototype/filter/15.4.4.20-4-1.js | 23 ++++ .../Array/prototype/filter/15.4.4.20-4-10.js | 34 ++++++ .../Array/prototype/filter/15.4.4.20-4-11.js | 38 +++++++ .../Array/prototype/filter/15.4.4.20-4-12.js | 28 +++++ .../Array/prototype/filter/15.4.4.20-4-15.js | 45 ++++++++ .../Array/prototype/filter/15.4.4.20-4-2.js | 25 +++++ .../Array/prototype/filter/15.4.4.20-4-3.js | 23 ++++ .../Array/prototype/filter/15.4.4.20-4-4.js | 23 ++++ .../Array/prototype/filter/15.4.4.20-4-5.js | 23 ++++ .../Array/prototype/filter/15.4.4.20-4-6.js | 23 ++++ .../Array/prototype/filter/15.4.4.20-4-7.js | 25 +++++ .../Array/prototype/filter/15.4.4.20-4-8.js | 37 ++++++ .../Array/prototype/filter/15.4.4.20-4-9.js | 41 +++++++ .../Array/prototype/filter/15.4.4.20-5-1-s.js | 28 +++++ .../Array/prototype/filter/15.4.4.20-5-1.js | 30 +++++ .../Array/prototype/filter/15.4.4.20-5-10.js | 28 +++++ .../Array/prototype/filter/15.4.4.20-5-11.js | 28 +++++ .../Array/prototype/filter/15.4.4.20-5-12.js | 28 +++++ .../Array/prototype/filter/15.4.4.20-5-13.js | 28 +++++ .../Array/prototype/filter/15.4.4.20-5-14.js | 27 +++++ .../Array/prototype/filter/15.4.4.20-5-15.js | 28 +++++ .../Array/prototype/filter/15.4.4.20-5-16.js | 28 +++++ .../Array/prototype/filter/15.4.4.20-5-17.js | 27 +++++ .../Array/prototype/filter/15.4.4.20-5-18.js | 28 +++++ .../Array/prototype/filter/15.4.4.20-5-19.js | 33 ++++++ .../Array/prototype/filter/15.4.4.20-5-2.js | 29 +++++ .../Array/prototype/filter/15.4.4.20-5-21.js | 28 +++++ .../Array/prototype/filter/15.4.4.20-5-22.js | 27 +++++ .../Array/prototype/filter/15.4.4.20-5-23.js | 27 +++++ .../Array/prototype/filter/15.4.4.20-5-24.js | 27 +++++ .../Array/prototype/filter/15.4.4.20-5-27.js | 23 ++++ .../Array/prototype/filter/15.4.4.20-5-28.js | 21 ++++ .../Array/prototype/filter/15.4.4.20-5-29.js | 21 ++++ .../Array/prototype/filter/15.4.4.20-5-3.js | 29 +++++ .../Array/prototype/filter/15.4.4.20-5-30.js | 31 ++++++ .../Array/prototype/filter/15.4.4.20-5-4.js | 33 ++++++ .../Array/prototype/filter/15.4.4.20-5-5.js | 31 ++++++ .../Array/prototype/filter/15.4.4.20-5-6.js | 30 +++++ .../Array/prototype/filter/15.4.4.20-5-7.js | 28 +++++ .../Array/prototype/filter/15.4.4.20-5-9.js | 29 +++++ .../Array/prototype/filter/15.4.4.20-6-1.js | 26 +++++ .../Array/prototype/filter/15.4.4.20-6-2.js | 30 +++++ .../Array/prototype/filter/15.4.4.20-6-3.js | 30 +++++ .../Array/prototype/filter/15.4.4.20-6-4.js | 30 +++++ .../Array/prototype/filter/15.4.4.20-6-5.js | 30 +++++ .../Array/prototype/filter/15.4.4.20-6-6.js | 35 ++++++ .../Array/prototype/filter/15.4.4.20-6-7.js | 41 +++++++ .../Array/prototype/filter/15.4.4.20-6-8.js | 43 +++++++ .../Array/prototype/filter/15.4.4.20-9-1.js | 30 +++++ .../Array/prototype/filter/15.4.4.20-9-2.js | 36 ++++++ .../Array/prototype/filter/15.4.4.20-9-3.js | 37 ++++++ .../Array/prototype/filter/15.4.4.20-9-4.js | 30 +++++ .../Array/prototype/filter/15.4.4.20-9-5.js | 32 ++++++ .../Array/prototype/filter/15.4.4.20-9-6.js | 39 +++++++ .../Array/prototype/filter/15.4.4.20-9-7.js | 34 ++++++ .../Array/prototype/filter/15.4.4.20-9-8.js | 34 ++++++ .../Array/prototype/filter/15.4.4.20-9-9.js | 42 +++++++ .../Array/prototype/filter/15.4.4.20-9-b-1.js | 33 ++++++ .../prototype/filter/15.4.4.20-9-b-10.js | 40 +++++++ .../prototype/filter/15.4.4.20-9-b-11.js | 37 ++++++ .../prototype/filter/15.4.4.20-9-b-12.js | 43 +++++++ .../prototype/filter/15.4.4.20-9-b-13.js | 37 ++++++ .../prototype/filter/15.4.4.20-9-b-14.js | 36 ++++++ .../prototype/filter/15.4.4.20-9-b-15.js | 42 +++++++ .../prototype/filter/15.4.4.20-9-b-16.js | 43 +++++++ .../Array/prototype/filter/15.4.4.20-9-b-2.js | 36 ++++++ .../Array/prototype/filter/15.4.4.20-9-b-3.js | 39 +++++++ .../Array/prototype/filter/15.4.4.20-9-b-4.js | 43 +++++++ .../Array/prototype/filter/15.4.4.20-9-b-5.js | 41 +++++++ .../Array/prototype/filter/15.4.4.20-9-b-6.js | 43 +++++++ .../Array/prototype/filter/15.4.4.20-9-b-7.js | 41 +++++++ .../Array/prototype/filter/15.4.4.20-9-b-8.js | 46 ++++++++ .../Array/prototype/filter/15.4.4.20-9-b-9.js | 42 +++++++ .../prototype/filter/15.4.4.20-9-c-i-1.js | 33 ++++++ .../prototype/filter/15.4.4.20-9-c-i-10.js | 35 ++++++ .../prototype/filter/15.4.4.20-9-c-i-11.js | 43 +++++++ .../prototype/filter/15.4.4.20-9-c-i-12.js | 36 ++++++ .../prototype/filter/15.4.4.20-9-c-i-13.js | 46 ++++++++ .../prototype/filter/15.4.4.20-9-c-i-14.js | 41 +++++++ .../prototype/filter/15.4.4.20-9-c-i-15.js | 38 +++++++ .../prototype/filter/15.4.4.20-9-c-i-16.js | 33 ++++++ .../prototype/filter/15.4.4.20-9-c-i-17.js | 34 ++++++ .../prototype/filter/15.4.4.20-9-c-i-18.js | 32 ++++++ .../prototype/filter/15.4.4.20-9-c-i-19.js | 36 ++++++ .../prototype/filter/15.4.4.20-9-c-i-2.js | 29 +++++ .../prototype/filter/15.4.4.20-9-c-i-20.js | 34 ++++++ .../prototype/filter/15.4.4.20-9-c-i-21.js | 36 ++++++ .../prototype/filter/15.4.4.20-9-c-i-22.js | 31 ++++++ .../prototype/filter/15.4.4.20-9-c-i-25.js | 31 ++++++ .../prototype/filter/15.4.4.20-9-c-i-26.js | 38 +++++++ .../prototype/filter/15.4.4.20-9-c-i-27.js | 41 +++++++ .../prototype/filter/15.4.4.20-9-c-i-28.js | 46 ++++++++ .../prototype/filter/15.4.4.20-9-c-i-29.js | 48 ++++++++ .../prototype/filter/15.4.4.20-9-c-i-3.js | 37 ++++++ .../prototype/filter/15.4.4.20-9-c-i-30.js | 44 ++++++++ .../prototype/filter/15.4.4.20-9-c-i-31.js | 41 +++++++ .../prototype/filter/15.4.4.20-9-c-i-4.js | 28 +++++ .../prototype/filter/15.4.4.20-9-c-i-5.js | 44 ++++++++ .../prototype/filter/15.4.4.20-9-c-i-6.js | 33 ++++++ .../prototype/filter/15.4.4.20-9-c-i-7.js | 35 ++++++ .../prototype/filter/15.4.4.20-9-c-i-8.js | 28 +++++ .../prototype/filter/15.4.4.20-9-c-i-9.js | 37 ++++++ .../prototype/filter/15.4.4.20-9-c-ii-1.js | 32 ++++++ .../prototype/filter/15.4.4.20-9-c-ii-10.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-ii-11.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-ii-12.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-ii-13.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-ii-16.js | 31 ++++++ .../prototype/filter/15.4.4.20-9-c-ii-17.js | 31 ++++++ .../prototype/filter/15.4.4.20-9-c-ii-18.js | 31 ++++++ .../prototype/filter/15.4.4.20-9-c-ii-19.js | 33 ++++++ .../prototype/filter/15.4.4.20-9-c-ii-2.js | 31 ++++++ .../prototype/filter/15.4.4.20-9-c-ii-20.js | 34 ++++++ .../prototype/filter/15.4.4.20-9-c-ii-21.js | 39 +++++++ .../prototype/filter/15.4.4.20-9-c-ii-22.js | 39 +++++++ .../prototype/filter/15.4.4.20-9-c-ii-23.js | 31 ++++++ .../prototype/filter/15.4.4.20-9-c-ii-4.js | 35 ++++++ .../prototype/filter/15.4.4.20-9-c-ii-5.js | 41 +++++++ .../prototype/filter/15.4.4.20-9-c-ii-6.js | 35 ++++++ .../prototype/filter/15.4.4.20-9-c-ii-7.js | 39 +++++++ .../prototype/filter/15.4.4.20-9-c-ii-8.js | 35 ++++++ .../prototype/filter/15.4.4.20-9-c-ii-9.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-1-1.js | 32 ++++++ .../prototype/filter/15.4.4.20-9-c-iii-1-2.js | 33 ++++++ .../prototype/filter/15.4.4.20-9-c-iii-1-3.js | 39 +++++++ .../prototype/filter/15.4.4.20-9-c-iii-1-4.js | 34 ++++++ .../prototype/filter/15.4.4.20-9-c-iii-1-5.js | 36 ++++++ .../prototype/filter/15.4.4.20-9-c-iii-1-6.js | 42 +++++++ .../prototype/filter/15.4.4.20-9-c-iii-1.js | 35 ++++++ .../prototype/filter/15.4.4.20-9-c-iii-10.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-11.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-12.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-13.js | 29 +++++ .../prototype/filter/15.4.4.20-9-c-iii-14.js | 29 +++++ .../prototype/filter/15.4.4.20-9-c-iii-15.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-16.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-17.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-18.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-19.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-2.js | 32 ++++++ .../prototype/filter/15.4.4.20-9-c-iii-20.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-21.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-22.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-23.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-24.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-25.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-26.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-28.js | 29 +++++ .../prototype/filter/15.4.4.20-9-c-iii-29.js | 35 ++++++ .../prototype/filter/15.4.4.20-9-c-iii-3.js | 31 ++++++ .../prototype/filter/15.4.4.20-9-c-iii-30.js | 27 +++++ .../prototype/filter/15.4.4.20-9-c-iii-4.js | 33 ++++++ .../prototype/filter/15.4.4.20-9-c-iii-5.js | 31 ++++++ .../prototype/filter/15.4.4.20-9-c-iii-6.js | 29 +++++ .../prototype/filter/15.4.4.20-9-c-iii-7.js | 29 +++++ .../prototype/filter/15.4.4.20-9-c-iii-8.js | 29 +++++ .../prototype/filter/15.4.4.20-9-c-iii-9.js | 27 +++++ .../prototype/filter/call-with-boolean.js | 30 +++++ .../filter/callbackfn-resize-arraybuffer.js | 77 +++++++++++++ .../filter/create-ctor-non-object.js | 59 ++++++++++ .../prototype/filter/create-ctor-poisoned.js | 40 +++++++ .../prototype/filter/create-non-array.js | 39 +++++++ .../create-proto-from-ctor-realm-array.js | 46 ++++++++ .../create-proto-from-ctor-realm-non-array.js | 48 ++++++++ .../Array/prototype/filter/create-proxy.js | 40 +++++++ .../prototype/filter/create-revoked-proxy.js | 45 ++++++++ .../prototype/filter/create-species-abrupt.js | 42 +++++++ .../filter/create-species-non-ctor.js | 46 ++++++++ .../prototype/filter/create-species-null.js | 36 ++++++ .../filter/create-species-poisoned.js | 49 ++++++++ .../prototype/filter/create-species-undef.js | 46 ++++++++ .../Array/prototype/filter/create-species.js | 55 +++++++++ .../builtins/Array/prototype/filter/length.js | 40 +++++++ .../builtins/Array/prototype/filter/name.js | 36 ++++++ .../prototype/filter/not-a-constructor.js | 38 +++++++ .../Array/prototype/filter/prop-desc.js | 32 ++++++ .../resizable-buffer-grow-mid-iteration.js | 93 ++++++++++++++++ .../resizable-buffer-shrink-mid-iteration.js | 88 +++++++++++++++ .../prototype/filter/resizable-buffer.js | 105 ++++++++++++++++++ .../filter/target-array-non-extensible.js | 43 +++++++ ...et-array-with-non-configurable-property.js | 45 ++++++++ ...target-array-with-non-writable-property.js | 41 +++++++ 242 files changed, 8336 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-1.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-10.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-11.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-12.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-13.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-14.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-15.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-2.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-3.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-4.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-5.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-6.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-7.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-8.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-9.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-1.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-2.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-3.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-4.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-1.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-10.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-11.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-12.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-13.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-14.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-17.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-18.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-19.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-2.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-3.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-4.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-5.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-6.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-7.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-8.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-9.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-1.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-10.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-11.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-12.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-13.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-14.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-15.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-16.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-17.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-18.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-19.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-2.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-20.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-21.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-22.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-23.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-24.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-25.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-3.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-4.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-5.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-6.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-7.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-9.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-1.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-10.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-11.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-12.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-15.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-2.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-3.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-4.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-5.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-6.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-7.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-8.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-9.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-1-s.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-1.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-10.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-11.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-12.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-13.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-14.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-15.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-16.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-17.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-18.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-19.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-2.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-21.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-22.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-23.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-24.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-27.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-28.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-29.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-3.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-30.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-4.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-5.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-6.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-7.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-9.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-1.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-2.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-3.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-4.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-5.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-6.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-7.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-8.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-1.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-2.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-3.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-4.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-5.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-6.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-7.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-8.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-9.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-1.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-10.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-11.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-12.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-13.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-14.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-15.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-16.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-2.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-3.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-4.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-5.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-6.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-7.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-8.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-9.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-1.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-10.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-11.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-12.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-13.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-14.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-15.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-16.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-17.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-18.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-19.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-2.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-20.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-21.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-22.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-25.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-26.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-27.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-28.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-29.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-3.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-30.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-31.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-4.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-5.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-6.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-7.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-8.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-9.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-1.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-10.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-11.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-12.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-13.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-16.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-17.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-18.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-19.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-2.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-20.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-21.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-22.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-23.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-4.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-5.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-6.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-7.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-8.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-9.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-1.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-2.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-3.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-4.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-5.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-6.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-10.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-11.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-12.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-13.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-14.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-15.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-16.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-17.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-18.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-19.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-2.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-20.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-21.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-22.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-23.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-24.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-25.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-26.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-28.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-29.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-3.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-30.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-4.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-5.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-6.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-7.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-8.js create mode 100644 test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-9.js create mode 100644 test/sendable/builtins/Array/prototype/filter/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/filter/callbackfn-resize-arraybuffer.js create mode 100644 test/sendable/builtins/Array/prototype/filter/create-ctor-non-object.js create mode 100644 test/sendable/builtins/Array/prototype/filter/create-ctor-poisoned.js create mode 100644 test/sendable/builtins/Array/prototype/filter/create-non-array.js create mode 100644 test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-array.js create mode 100644 test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-non-array.js create mode 100644 test/sendable/builtins/Array/prototype/filter/create-proxy.js create mode 100644 test/sendable/builtins/Array/prototype/filter/create-revoked-proxy.js create mode 100644 test/sendable/builtins/Array/prototype/filter/create-species-abrupt.js create mode 100644 test/sendable/builtins/Array/prototype/filter/create-species-non-ctor.js create mode 100644 test/sendable/builtins/Array/prototype/filter/create-species-null.js create mode 100644 test/sendable/builtins/Array/prototype/filter/create-species-poisoned.js create mode 100644 test/sendable/builtins/Array/prototype/filter/create-species-undef.js create mode 100644 test/sendable/builtins/Array/prototype/filter/create-species.js create mode 100644 test/sendable/builtins/Array/prototype/filter/length.js create mode 100644 test/sendable/builtins/Array/prototype/filter/name.js create mode 100644 test/sendable/builtins/Array/prototype/filter/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/filter/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/filter/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/filter/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/filter/resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/filter/target-array-non-extensible.js create mode 100644 test/sendable/builtins/Array/prototype/filter/target-array-with-non-configurable-property.js create mode 100644 test/sendable/builtins/Array/prototype/filter/target-array-with-non-writable-property.js diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-1.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-1.js new file mode 100644 index 00000000000..fb50996a146 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to undefined throws a TypeError +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.filter.call(undefined); // TypeError is thrown if value is undefined +}); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-10.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-10.js new file mode 100644 index 00000000000..bdc533dafb6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-10.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to the Math object +---*/ + +function callbackfn(val, idx, obj) { + return '[object Math]' === Object.prototype.toString.call(obj); +} +Math.length = 1; +Math[0] = 1; +var newArr = SendableArray.prototype.filter.call(Math, callbackfn); +assert.sameValue(newArr[0], 1, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-11.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-11.js new file mode 100644 index 00000000000..eab3c61683e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-11.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to Date object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Date; +} +var obj = new Date(0); +obj.length = 1; +obj[0] = 1; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr[0], 1, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-12.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-12.js new file mode 100644 index 00000000000..19c40c45c99 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-12.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to RegExp object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof RegExp; +} +var obj = new RegExp(); +obj.length = 2; +obj[1] = true; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr[0], true, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-13.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-13.js new file mode 100644 index 00000000000..b1cd285cfa9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-13.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to the JSON object +---*/ + +function callbackfn(val, idx, obj) { + return '[object JSON]' === Object.prototype.toString.call(JSON); +} +JSON.length = 1; +JSON[0] = 1; +var newArr = SendableArray.prototype.filter.call(JSON, callbackfn); +assert.sameValue(newArr[0], 1, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-14.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-14.js new file mode 100644 index 00000000000..be7ffb9e116 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-14.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to Error object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Error; +} +var obj = new Error(); +obj.length = 1; +obj[0] = 1; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr[0], 1, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-15.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-15.js new file mode 100644 index 00000000000..2c466dfd77a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-15.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to the Arguments object +---*/ + +function callbackfn(val, idx, obj) { + return '[object Arguments]' === Object.prototype.toString.call(obj); +} +var obj = (function() { + return arguments; +}("a", "b")); +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr[0], "a", 'newArr[0]'); +assert.sameValue(newArr[1], "b", 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-2.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-2.js new file mode 100644 index 00000000000..bd38b042c74 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-2.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to null throws a TypeError +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.filter.call(null); +}); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-3.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-3.js new file mode 100644 index 00000000000..9ce975bb620 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-3.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to boolean primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Boolean; +} +Boolean.prototype[0] = true; +Boolean.prototype.length = 1; +var newArr = SendableArray.prototype.filter.call(false, callbackfn); +assert.sameValue(newArr[0], true, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-4.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-4.js new file mode 100644 index 00000000000..bb2eb80bd44 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-4.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to Boolean Object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Boolean; +} +var obj = new Boolean(true); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert.sameValue(newArr[1], 12, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-5.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-5.js new file mode 100644 index 00000000000..4a45a6eb5f7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-5.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to number primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Number; +} +Number.prototype[0] = 1; +Number.prototype.length = 1; +var newArr = SendableArray.prototype.filter.call(2.5, callbackfn); +assert.sameValue(newArr[0], 1, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-6.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-6.js new file mode 100644 index 00000000000..2eb53fe9d49 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-6.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to Number object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Number; +} +var obj = new Number(-128); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert.sameValue(newArr[1], 12, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-7.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-7.js new file mode 100644 index 00000000000..8e61bc6d4bf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-7.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to string primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof String; +} +var newArr = SendableArray.prototype.filter.call("abc", callbackfn); +assert.sameValue(newArr[0], "a", 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-8.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-8.js new file mode 100644 index 00000000000..c0002227c34 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-8.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to String object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof String; +} +var obj = new String("abc"); +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr[0], "a", 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-9.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-9.js new file mode 100644 index 00000000000..0cf847efa76 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-1-9.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to Function object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Function; +} +var obj = function(a, b) { + return a + b; +}; +obj[0] = 11; +obj[1] = 9; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert.sameValue(newArr[1], 9, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-1.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-1.js new file mode 100644 index 00000000000..04bf4582722 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-1.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter doesn't mutate the Array on which it is + called on +---*/ + +function callbackfn(val, idx, obj) +{ + return true; +} +var srcArr = [1, 2, 3, 4, 5]; +srcArr.filter(callbackfn); +assert.sameValue(srcArr[0], 1, 'srcArr[0]'); +assert.sameValue(srcArr[1], 2, 'srcArr[1]'); +assert.sameValue(srcArr[2], 3, 'srcArr[2]'); +assert.sameValue(srcArr[3], 4, 'srcArr[3]'); +assert.sameValue(srcArr[4], 5, 'srcArr[4]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-2.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-2.js new file mode 100644 index 00000000000..509e2156123 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-2.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter returns new Array with length equal to + number of true returned by callbackfn +---*/ + +function callbackfn(val, idx, obj) +{ + if (val % 2) + return true; + else + return false; +} +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.filter(callbackfn); +assert.sameValue(resArr.length, 3, 'resArr.length'); +assert.sameValue(resArr[0], 1, 'resArr[0]'); +assert.sameValue(resArr[1], 3, 'resArr[1]'); +assert.sameValue(resArr[2], 5, 'resArr[2]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-3.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-3.js new file mode 100644 index 00000000000..f249899088a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-3.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - subclassed array when length is reduced +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = 1; +function cb() { + return true; +} +var a = f.filter(cb); +assert(SendableArray.isArray(a), 'SendableArray.isArray(a) !== true'); +assert.sameValue(a.length, 1, 'a.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-4.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-4.js new file mode 100644 index 00000000000..b9b9bd25148 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-10-4.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter doesn't visit expandos +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + callCnt++; +} +var srcArr = [1, 2, 3, 4, 5]; +srcArr["i"] = 10; +srcArr[true] = 11; +var resArr = srcArr.filter(callbackfn); +assert.sameValue(callCnt, 5, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-1.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-1.js new file mode 100644 index 00000000000..cd62a13c01f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-1.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + own data property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-10.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-10.js new file mode 100644 index 00000000000..665b41d8fb6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-10.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + inherited accessor property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; +var newArr = SendableArray.prototype.filter.call(child, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-11.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-11.js new file mode 100644 index 00000000000..fa5895a0d28 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-11.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + own accessor property without a get function +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-12.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-12.js new file mode 100644 index 00000000000..360fb8cf550 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-12.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is own accessor property without + a get function that overrides an inherited accessor property +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var obj = { + 0: 12, + 1: 11 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-13.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-13.js new file mode 100644 index 00000000000..10950470e56 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-13.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to the Array-like object that + 'length' is inherited accessor property without a get function +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 11; +child[1] = 12; +var newArr = SendableArray.prototype.filter.call(child, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-14.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-14.js new file mode 100644 index 00000000000..42e2a551fe2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-14.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to the Array-like object that + 'length property doesn't exist +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} +var obj = { + 0: 11, + 1: 12 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-17.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-17.js new file mode 100644 index 00000000000..df98cae944a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-17.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to the Arguments object, which + implements its own property get method +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} +var func = function(a, b) { + var newArr = SendableArray.prototype.filter.call(arguments, callbackfn); + return newArr.length === 2; +}; +assert(func(12, 11), 'func(12, 11) !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-18.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-18.js new file mode 100644 index 00000000000..57a4aca97c6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-18.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to String object, which implements + its own property get method +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 3; +} +var str = new String("012"); +var newArr = SendableArray.prototype.filter.call(str, callbackfn); +assert.sameValue(newArr.length, 3, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-19.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-19.js new file mode 100644 index 00000000000..09ee29ae0d6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-19.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Function object, which + implements its own property get method +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} +var fun = function(a, b) { + return a + b; +}; +fun[0] = 12; +fun[1] = 11; +fun[2] = 9; +var newArr = SendableArray.prototype.filter.call(fun, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-2.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-2.js new file mode 100644 index 00000000000..1c4d23720ac --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-2.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - 'length' is own data property on an Array +---*/ +function callbackfn(val, idx, obj) { + return obj.length === 2; +} +var newArr = [12, 11].filter(callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-3.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-3.js new file mode 100644 index 00000000000..3e0853a7e38 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-3.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + an own data property that overrides an inherited data property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} +var proto = { + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +child[0] = 12; +child[1] = 11; +child[2] = 9; +var newArr = SendableArray.prototype.filter.call(child, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-4.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-4.js new file mode 100644 index 00000000000..3c8d5dfec3e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-4.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is own data property that + overrides an inherited data property on an Array +---*/ + +var arrProtoLen; +function callbackfn(val, idx, obj) { + return obj.length === 2; +} +arrProtoLen = SendableArray.prototype.length; +SendableArray.prototype.length = 0; +var newArr = [12, 11].filter(callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-5.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-5.js new file mode 100644 index 00000000000..79995d767f9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-5.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter to Array-like object, 'length' is an own + data property that overrides an inherited accessor property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +var newArr = SendableArray.prototype.filter.call(child, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-6.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-6.js new file mode 100644 index 00000000000..29c0ec3c594 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + an inherited data property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} +var proto = { + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; +var newArr = SendableArray.prototype.filter.call(child, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-7.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-7.js new file mode 100644 index 00000000000..fbb529c91ae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-7.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + an own accessor property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); +obj[0] = 12; +obj[1] = 11; +obj[2] = 9; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-8.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-8.js new file mode 100644 index 00000000000..8e669ff5718 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-8.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + own accessor property that overrides an inherited data property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} +var proto = { + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +var newArr = SendableArray.prototype.filter.call(child, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-9.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-9.js new file mode 100644 index 00000000000..c1127354e9a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-2-9.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied to Array-like object, 'length' is + an own accessor property that overrides an inherited accessor + property +---*/ + +function callbackfn(val, idx, obj) { + return obj.length === 2; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +var newArr = SendableArray.prototype.filter.call(child, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-1.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-1.js new file mode 100644 index 00000000000..7dd05a513d8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-1.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - value of 'length' is undefined +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} +var obj = { + 0: 0, + 1: 1, + length: undefined +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-10.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-10.js new file mode 100644 index 00000000000..f5881ae85c7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-10.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a number (value is + NaN) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} +var obj = { + 0: 9, + length: NaN +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-11.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-11.js new file mode 100644 index 00000000000..b7baf3ad827 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-11.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is a string containing a + positive number +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 1: 11, + 2: 9, + length: "2" +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-12.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-12.js new file mode 100644 index 00000000000..89680608af0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-12.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is a string containing a + negative number +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 1: 11, + 2: 9, + length: "-4294967294" +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-13.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-13.js new file mode 100644 index 00000000000..01b1533aac9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-13.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is a string containing a decimal + number +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 1: 11, + 2: 9, + length: "2.5" +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-14.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-14.js new file mode 100644 index 00000000000..75e5724120c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-14.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - 'length' is a string containing -Infinity +---*/ + +var accessed2 = false; +function callbackfn2(val, idx, obj) { + accessed2 = true; + return true; +} +var obj2 = { + 0: 9, + length: "-Infinity" +}; +var newArr2 = SendableArray.prototype.filter.call(obj2, callbackfn2); +assert.sameValue(accessed2, false, 'accessed2'); +assert.sameValue(newArr2.length, 0, 'newArr2.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-15.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-15.js new file mode 100644 index 00000000000..281b511263b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-15.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is a string containing an + exponential number +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 1: 11, + 2: 9, + length: "2E0" +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-16.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-16.js new file mode 100644 index 00000000000..e147cdd3531 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-16.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is a string containing a hex + number +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 1: 11, + 2: 9, + length: "0x0002" +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-17.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-17.js new file mode 100644 index 00000000000..588d3cdee13 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-17.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is a string containing a number + with leading zeros +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 1: 11, + 2: 9, + length: "0002.00" +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-18.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-18.js new file mode 100644 index 00000000000..77d706360dd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-18.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a string that can't + convert to a number +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} +var obj = { + 0: 9, + length: "asdf!_" +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(newArr.length, 0, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-19.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-19.js new file mode 100644 index 00000000000..55da68a8325 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-19.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is an Object which has + an own toString method. +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 1: 11, + 2: 9, + length: { + toString: function() { + return '2'; + } + } +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-2.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-2.js new file mode 100644 index 00000000000..1d279f9c4bf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-2.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter applied on an Array-like object if 'length' + is 1 (length overridden to true(type conversion)) +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 0: 11, + 1: 9, + length: true +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-20.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-20.js new file mode 100644 index 00000000000..0e214059dee --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-20.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is an Object which has + an own valueOf method. +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 1: 11, + 2: 9, + length: { + valueOf: function() { + return 2; + } + } +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-21.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-21.js new file mode 100644 index 00000000000..c8257022708 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-21.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'length' is an object that has an own + valueOf method that returns an object and toString method that + returns a string +---*/ + +var firstStepOccured = false; +var secondStepOccured = false; +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 1: 11, + 2: 9, + length: { + valueOf: function() { + firstStepOccured = true; + return {}; + }, + toString: function() { + secondStepOccured = true; + return '2'; + } + } +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(firstStepOccured, 'firstStepOccured !== true'); +assert(secondStepOccured, 'secondStepOccured !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-22.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-22.js new file mode 100644 index 00000000000..ab1bb622ef4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-22.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter throws TypeError exception when 'length' is + an object with toString and valueOf methods that don�t return + primitive values +---*/ + +var accessed = false; +var firstStepOccured = false; +var secondStepOccured = false; +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} +var obj = { + 1: 11, + 2: 12, + + length: { + valueOf: function() { + firstStepOccured = true; + return {}; + }, + toString: function() { + secondStepOccured = true; + return {}; + } + } +}; +assert.throws(TypeError, function() { + SendableArray.prototype.filter.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); +assert(firstStepOccured, 'firstStepOccured !== true'); +assert(secondStepOccured, 'secondStepOccured !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-23.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-23.js new file mode 100644 index 00000000000..e8dfd3a0b02 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-23.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter uses inherited valueOf method when 'length' + is an object with an own toString and inherited valueOf methods +---*/ + +var valueOfAccessed = false; +var toStringAccessed = false; +function callbackfn(val, idx, obj) { + return true; +} +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return '1'; +}; +var obj = { + 1: 11, + 2: 9, + length: child +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-24.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-24.js new file mode 100644 index 00000000000..60a78a7d5f0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-24.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 1: 11, + 2: 9, + length: 2.685 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-25.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-25.js new file mode 100644 index 00000000000..4bda6a0ef9e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-25.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a negative + non-integer +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 1: 11, + 2: 9, + length: -4294967294.5 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-3.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-3.js new file mode 100644 index 00000000000..b7cbddc7de9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-3.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - value of 'length' is a number (value is 0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} +var obj = { + 0: 11, + length: 0 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-4.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-4.js new file mode 100644 index 00000000000..53dbbaa1e52 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-4.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a number (value is + +0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} +var obj = { + 0: 11, + length: +0 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-5.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-5.js new file mode 100644 index 00000000000..c69c8f5714a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-5.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a number (value is + -0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} +var obj = { + 0: 11, + length: -0 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-6.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-6.js new file mode 100644 index 00000000000..5678cdd80cc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-6.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a number (value is + positive) +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 1: 11, + 2: 9, + length: 2 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-7.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-7.js new file mode 100644 index 00000000000..97d83a508f7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-7.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a number (value is + negative) +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 1: 11, + 2: 9, + length: -4294967294 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-9.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-9.js new file mode 100644 index 00000000000..bbac55190eb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-3-9.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of 'length' is a number (value is + -Infinity) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return true; +} +var obj = { + 0: 9, + length: -Infinity +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-1.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-1.js new file mode 100644 index 00000000000..e505e0daa46 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter throws TypeError if callbackfn is undefined +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.filter(); +}); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-10.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-10.js new file mode 100644 index 00000000000..286cecd0c02 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-10.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - the exception is not thrown if exception + was thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.filter.call(obj, undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-11.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-11.js new file mode 100644 index 00000000000..0f71ff8c796 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-11.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - the exception is not thrown if exception + was thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.filter.call(obj, undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-12.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-12.js new file mode 100644 index 00000000000..97251811fdc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-12.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - 'callbackfn' is a function +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === 9; + } + return false; +} +var newArr = [11, 9].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 9, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-15.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-15.js new file mode 100644 index 00000000000..12a6acfff6e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-15.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - calling with no callbackfn is the same as + passing undefined for callbackfn +---*/ + +var obj = { + 10: 10 +}; +var lengthAccessed = false; +var loopAccessed = false; +Object.defineProperty(obj, "length", { + get: function() { + lengthAccessed = true; + return 20; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + loopAccessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.filter.call(obj); +}); +assert(lengthAccessed, 'lengthAccessed !== true'); +assert.sameValue(loopAccessed, false, 'loopAccessed'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-2.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-2.js new file mode 100644 index 00000000000..b2eae252193 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter throws ReferenceError if callbackfn is + unreferenced +---*/ + +var arr = new SendableArray(10); +assert.throws(ReferenceError, function() { + arr.filter(foo); +}); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-3.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-3.js new file mode 100644 index 00000000000..b55ea90649f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter throws TypeError if callbackfn is null +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.filter(null); +}); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-4.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-4.js new file mode 100644 index 00000000000..268064847cb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-4.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter throws TypeError if callbackfn is boolean +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.filter(true); +}); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-5.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-5.js new file mode 100644 index 00000000000..69079bfd984 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-5.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter throws TypeError if callbackfn is number +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.filter(5); +}); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-6.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-6.js new file mode 100644 index 00000000000..b52445d43e4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-6.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter throws TypeError if callbackfn is string +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.filter("abc"); +}); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-7.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-7.js new file mode 100644 index 00000000000..271e76b6ef7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-7.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter throws TypeError if callbackfn is Object + without [[Call]] internal method +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.filter(new Object()); +}); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-8.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-8.js new file mode 100644 index 00000000000..654437ead58 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-8.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.filter.call(obj, null); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-9.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-9.js new file mode 100644 index 00000000000..d017ec0b36d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-4-9.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.filter.call(obj, null); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-1-s.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-1-s.js new file mode 100644 index 00000000000..b1364628e87 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-1-s.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - thisArg not passed to strict callbackfn +flags: [noStrict] +---*/ + +var innerThisCorrect = false; +function callbackfn(val, idx, obj) { + "use strict"; + innerThisCorrect = this === undefined; + return true; +} +[1].filter(callbackfn); +assert(innerThisCorrect, 'innerThisCorrect !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-1.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-1.js new file mode 100644 index 00000000000..51149389898 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - thisArg is passed +flags: [noStrict] +---*/ + +(function() { + this._15_4_4_20_5_1 = false; + var _15_4_4_20_5_1 = true; + function callbackfn(val, idx, obj) { + return this._15_4_4_20_5_1; + } + var srcArr = [1]; + var resArr = srcArr.filter(callbackfn); + assert.sameValue(resArr.length, 0, 'resArr.length'); +})(); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-10.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-10.js new file mode 100644 index 00000000000..f9aa9c60596 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-10.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - Array Object can be used as thisArg +---*/ + +var accessed = false; +var objArray = new SendableArray(10); +function callbackfn(val, idx, obj) { + accessed = true; + return this === objArray; +} +var newArr = [11].filter(callbackfn, objArray); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-11.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-11.js new file mode 100644 index 00000000000..ca73b00aa18 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-11.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - String Object can be used as thisArg +---*/ + +var accessed = false; +var objString = new String(); +function callbackfn(val, idx, obj) { + accessed = true; + return this === objString; +} +var newArr = [11].filter(callbackfn, objString); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-12.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-12.js new file mode 100644 index 00000000000..43fb5f857ae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-12.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - Boolean Object can be used as thisArg +---*/ + +var accessed = false; +var objBoolean = new Boolean(); +function callbackfn(val, idx, obj) { + accessed = true; + return this === objBoolean; +} +var newArr = [11].filter(callbackfn, objBoolean); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-13.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-13.js new file mode 100644 index 00000000000..257df599fbd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-13.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - Number Object can be used as thisArg +---*/ + +var accessed = false; +var objNumber = new Number(); +function callbackfn(val, idx, obj) { + accessed = true; + return this === objNumber; +} +var newArr = [11].filter(callbackfn, objNumber); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-14.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-14.js new file mode 100644 index 00000000000..272a2046632 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-14.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - the Math object can be used as thisArg +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this === Math; +} +var newArr = [11].filter(callbackfn, Math); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-15.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-15.js new file mode 100644 index 00000000000..e107b363f42 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-15.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - Date Object can be used as thisArg +---*/ + +var accessed = false; +var objDate = new Date(0); +function callbackfn(val, idx, obj) { + accessed = true; + return this === objDate; +} +var newArr = [11].filter(callbackfn, objDate); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-16.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-16.js new file mode 100644 index 00000000000..898d6c215f1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-16.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - RegExp Object can be used as thisArg +---*/ + +var accessed = false; +var objRegExp = new RegExp(); +function callbackfn(val, idx, obj) { + accessed = true; + return this === objRegExp; +} +var newArr = [11].filter(callbackfn, objRegExp); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-17.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-17.js new file mode 100644 index 00000000000..d13320316c3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-17.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - the JSON object can be used as thisArg +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this === JSON; +} +var newArr = [11].filter(callbackfn, JSON); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-18.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-18.js new file mode 100644 index 00000000000..9637dc6f180 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-18.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - Error Object can be used as thisArg +---*/ + +var accessed = false; +var objError = new RangeError(); +function callbackfn(val, idx, obj) { + accessed = true; + return this === objError; +} +var newArr = [11].filter(callbackfn, objError); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-19.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-19.js new file mode 100644 index 00000000000..5483ed46574 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-19.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - the Arguments object can be used as + thisArg +---*/ + +var accessed = false; +var arg; +function callbackfn(val, idx, obj) { + accessed = true; + return this === arg; +} +(function fun() { + arg = arguments; +}(1, 2, 3)); +var newArr = [11].filter(callbackfn, arg); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-2.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-2.js new file mode 100644 index 00000000000..8058025cf8a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-2.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - thisArg is Object +---*/ + +var res = false; +var o = new Object(); +o.res = true; +function callbackfn(val, idx, obj) +{ + return this.res; +} +var srcArr = [1]; +var resArr = srcArr.filter(callbackfn, o); +assert.sameValue(resArr.length, 1, 'resArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-21.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-21.js new file mode 100644 index 00000000000..7aa47c2a2b9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-21.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - the global object can be used as thisArg +---*/ + +var global = this; +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this === global; +} +var newArr = [11].filter(callbackfn, global); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-22.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-22.js new file mode 100644 index 00000000000..604ad3ebd9c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-22.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - boolean primitive can be used as thisArg +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this.valueOf() === false; +} +var newArr = [11].filter(callbackfn, false); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-23.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-23.js new file mode 100644 index 00000000000..fd034ab7821 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-23.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - number primitive can be used as thisArg +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this.valueOf() === 101; +} +var newArr = [11].filter(callbackfn, 101); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-24.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-24.js new file mode 100644 index 00000000000..56c5b180faf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-24.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - string primitive can be used as thisArg +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this.valueOf() === "abc"; +} +var newArr = [11].filter(callbackfn, "abc"); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-27.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-27.js new file mode 100644 index 00000000000..9e5043af775 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-27.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - Array.isArray(arg) returns true when arg + is the returned array +---*/ + +var newArr = [11].filter(function() {}); +assert(SendableArray.isArray(newArr), 'SendableArray.isArray(newArr) !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-28.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-28.js new file mode 100644 index 00000000000..0c648c54449 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-28.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - the returned array is instanceof Array +---*/ + +var newArr = [11].filter(function() {}); +assert(newArr instanceof SendableArray, 'newArr instanceof SendableArray !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-29.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-29.js new file mode 100644 index 00000000000..bf37ff3a48e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-29.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - returns an array whose length is 0 +---*/ + +var newArr = [11].filter(function() {}); +assert.sameValue(newArr.length, 0, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-3.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-3.js new file mode 100644 index 00000000000..9fe58a74786 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-3.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - thisArg is Array +---*/ + +var res = false; +var a = new Array(); +a.res = true; +function callbackfn(val, idx, obj) +{ + return this.res; +} +var srcArr = [1]; +var resArr = srcArr.filter(callbackfn, a); +assert.sameValue(resArr.length, 1, 'resArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-30.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-30.js new file mode 100644 index 00000000000..1bf4c45d498 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-30.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - thisArg not passed +flags: [noStrict] +---*/ + +function innerObj() { + this._15_4_4_20_5_30 = true; + var _15_4_4_20_5_30 = false; + function callbackfn(val, idx, obj) { + return this._15_4_4_20_5_30; + } + var srcArr = [1]; + var resArr = srcArr.filter(callbackfn); + this.retVal = resArr.length === 0; +} +assert(new innerObj().retVal, 'new innerObj().retVal !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-4.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-4.js new file mode 100644 index 00000000000..bd6c371e06e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-4.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-5-4 +description: > + Array.prototype.filter - thisArg is object from object + template(prototype) +---*/ + +var res = false; +function callbackfn(val, idx, obj) +{ + return this.res; +} +function foo() {} +foo.prototype.res = true; +var f = new foo(); +var srcArr = [1]; +var resArr = srcArr.filter(callbackfn, f); +assert.sameValue(resArr.length, 1, 'resArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-5.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-5.js new file mode 100644 index 00000000000..77f9cdb2564 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-5.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-5-5 +description: Array.prototype.filter - thisArg is object from object template +---*/ + +var res = false; +function callbackfn(val, idx, obj) +{ + return this.res; +} +function foo() {} +var f = new foo(); +f.res = true; +var srcArr = [1]; +var resArr = srcArr.filter(callbackfn, f); +assert.sameValue(resArr.length, 1, 'resArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-6.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-6.js new file mode 100644 index 00000000000..8be09ba84a8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-6.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-5-6 +description: Array.prototype.filter - thisArg is function +---*/ + +var res = false; +function callbackfn(val, idx, obj) +{ + return this.res; +} +function foo() {} +foo.res = true; +var srcArr = [1]; +var resArr = srcArr.filter(callbackfn, foo); +assert.sameValue(resArr.length, 1, 'resArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-7.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-7.js new file mode 100644 index 00000000000..68cb455cbb6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-7.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-5-7 +description: Array.prototype.filter - built-in functions can be used as thisArg +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return this === eval; +} +var newArr = [11].filter(callbackfn, eval); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-9.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-9.js new file mode 100644 index 00000000000..725689b0c27 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-5-9.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-5-9 +description: Array.prototype.filter - Function Object can be used as thisArg +---*/ + +var accessed = false; +var objFunction = function() {}; +function callbackfn(val, idx, obj) { + accessed = true; + return this === objFunction; +} +var newArr = [11].filter(callbackfn, objFunction); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-1.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-1.js new file mode 100644 index 00000000000..9b49983a252 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-1.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-1 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (empty array) +---*/ + +function cb() {} +var a = [].filter(cb); +assert(SendableArray.isArray(a), 'SendableArray.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-2.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-2.js new file mode 100644 index 00000000000..5f1fb081d5d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-2.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-2 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (subclassed Array, length overridden to null (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = null; +function cb() {} +var a = f.filter(cb); +assert(SendableArray.isArray(a), 'SendableArray.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-3.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-3.js new file mode 100644 index 00000000000..53d778236ff --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-3.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-3 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (subclassed Array, length overridden to false (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = false; +function cb() {} +var a = f.filter(cb); +assert(SendableArray.isArray(a), 'SendableArray.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-4.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-4.js new file mode 100644 index 00000000000..ea3926ca0e9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-4 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (subclassed Array, length overridden to 0 (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = 0; +function cb() {} +var a = f.filter(cb); +assert(SendableArray.isArray(a), 'SendableArray.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-5.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-5.js new file mode 100644 index 00000000000..bc700459c6b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-5.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-5 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (subclassed Array, length overridden to '0' (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = '0'; +function cb() {} +var a = f.filter(cb); +assert(SendableArray.isArray(a), 'SendableArray.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-6.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-6.js new file mode 100644 index 00000000000..09ec0af3c09 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-6 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (subclassed Array, length overridden with obj with valueOf) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; +function cb() {} +var a = f.filter(cb); +assert(SendableArray.isArray(a), 'SendableArray.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-7.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-7.js new file mode 100644 index 00000000000..e579846e800 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-7.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-7 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (subclassed Array, length overridden with obj w/o valueOf + (toString)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +function cb() {} +var a = f.filter(cb); +assert(SendableArray.isArray(a), 'SendableArray.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-8.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-8.js new file mode 100644 index 00000000000..0c431a654eb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-6-8.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-6-8 +description: > + Array.prototype.filter returns an empty array if 'length' is 0 + (subclassed Array, length overridden with [] +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = []; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +function cb() {} +var a = f.filter(cb); +assert(SendableArray.isArray(a), 'SendableArray.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-1.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-1.js new file mode 100644 index 00000000000..c1c5c93ecc8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-1 +description: > + Array.prototype.filter doesn't consider new elements added to + array after it is called +---*/ + +function callbackfn(val, idx, obj) { + srcArr[2] = 3; + srcArr[5] = 6; + return true; +} +var srcArr = [1, 2, , 4, 5]; +var resArr = srcArr.filter(callbackfn); +assert.sameValue(resArr.length, 5, 'resArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-2.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-2.js new file mode 100644 index 00000000000..5fae0f6080f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-2.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-2 +description: > + Array.prototype.filter considers new value of elements in array + after it is called +---*/ + +function callbackfn(val, idx, obj) +{ + srcArr[2] = -1; + srcArr[4] = -1; + if (val > 0) + return true; + else + return false; +} +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.filter(callbackfn); +assert.sameValue(resArr.length, 3, 'resArr.length'); +assert.sameValue(resArr[0], 1, 'resArr[0]'); +assert.sameValue(resArr[2], 4, 'resArr[2]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-3.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-3.js new file mode 100644 index 00000000000..184f623e226 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-3.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-3 +description: > + Array.prototype.filter doesn't visit deleted elements in array + after the call +---*/ + +function callbackfn(val, idx, obj) +{ + delete srcArr[2]; + delete srcArr[4]; + if (val > 0) + return true; + else + return false; +} +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.filter(callbackfn); +// two elements deleted +assert.sameValue(resArr.length, 3, 'resArr.length'); +assert.sameValue(resArr[0], 1, 'resArr[0]'); +assert.sameValue(resArr[2], 4, 'resArr[2]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-4.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-4.js new file mode 100644 index 00000000000..b5ba735997b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-4 +description: > + Array.prototype.filter doesn't visit deleted elements when + Array.length is decreased +---*/ + +function callbackfn(val, idx, obj) +{ + srcArr.length = 2; + return true; +} +var srcArr = [1, 2, 3, 4, 6]; +var resArr = srcArr.filter(callbackfn); +assert.sameValue(resArr.length, 2, 'resArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-5.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-5.js new file mode 100644 index 00000000000..36ed5f0f540 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-5.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-5 +description: > + Array.prototype.filter doesn't consider newly added elements in + sparse array +---*/ + +function callbackfn(val, idx, obj) +{ + srcArr[1000] = 3; + return true; +} +var srcArr = new SendableArray(10); +srcArr[1] = 1; +srcArr[2] = 2; +var resArr = srcArr.filter(callbackfn); +assert.sameValue(resArr.length, 2, 'resArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-6.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-6.js new file mode 100644 index 00000000000..cac2c91376e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-6.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-6 +description: > + Array.prototype.filter visits deleted element in array after the + call when same index is also present in prototype +---*/ + +function callbackfn(val, idx, obj) +{ + delete srcArr[2]; + delete srcArr[4]; + if (val > 0) + return true; + else + return false; +} +SendableArray.prototype[4] = 5; +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.filter(callbackfn); +delete SendableArray.prototype[4]; +// only one element deleted +assert.sameValue(resArr.length, 4, 'resArr.length'); +assert.sameValue(resArr[0], 1, 'resArr[0]'); +assert.sameValue(resArr[3], 5, 'resArr[3]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-7.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-7.js new file mode 100644 index 00000000000..9a1050e7675 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-7.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-7 +description: > + Array.prototype.filter stops calling callbackfn once the array is + deleted during the call +---*/ + +var o = new Object(); +o.srcArr = [1, 2, 3, 4, 5]; +function callbackfn(val, idx, obj) { + delete o.srcArr; + if (val > 0) + return true; + else + return false; +} +var resArr = o.srcArr.filter(callbackfn); +assert.sameValue(resArr.length, 5, 'resArr.length'); +assert.sameValue(typeof o.srcArr, "undefined", 'typeof o.srcArr'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-8.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-8.js new file mode 100644 index 00000000000..05b856affbb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-8.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-8 +description: Array.prototype.filter - no observable effects occur if len is 0 +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + 1: 12, + length: 0 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(obj.length, 0, 'obj.length'); +assert.sameValue(newArr.length, 0, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-9.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-9.js new file mode 100644 index 00000000000..7e1fd49d83e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-9.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-9 +description: > + Array.prototype.filter - modifications to length don't change + number of iterations +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + return true; +} +var obj = { + 1: 12, + 2: 9, + length: 2 +}; +Object.defineProperty(obj, "0", { + get: function() { + obj.length = 3; + return 11; + }, + configurable: true +}); +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-1.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-1.js new file mode 100644 index 00000000000..468a516df51 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-1.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-1 +description: > + Array.prototype.filter - callbackfn not called for indexes never + been assigned values +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + callCnt++; + return false; +} +var srcArr = new SendableArray(10); +srcArr[1] = undefined; //explicitly assigning a value +var resArr = srcArr.filter(callbackfn); +assert.sameValue(resArr.length, 0, 'resArr.length'); +assert.sameValue(callCnt, 1, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-10.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-10.js new file mode 100644 index 00000000000..f4c32c1ef9a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-10.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-10 +description: > + Array.prototype.filter - deleting property of prototype causes + prototype index property not to be visited on an Array-like Object +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 2: 2, + length: 20 +}; +Object.defineProperty(obj, "0", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.notSameValue(newArr[1], 1, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-11.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-11.js new file mode 100644 index 00000000000..2bb7c85c91b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-11.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-11 +description: > + Array.prototype.filter - deleting property of prototype causes + prototype index property not to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + delete SendableArray.prototype[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.notSameValue(newArr[1], 1, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-12.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-12.js new file mode 100644 index 00000000000..7b1c5db8d2d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-12.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-12 +description: > + Array.prototype.filter - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 0: 0, + 1: 111, + 2: 2, + length: 10 +}; +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[1], 1, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-13.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-13.js new file mode 100644 index 00000000000..a1bc50aba9f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-13.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-13 +description: > + Array.prototype.filter - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + return val < 3 ? true : false; +} +var arr = [0, 111, 2]; +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[1], 1, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-14.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-14.js new file mode 100644 index 00000000000..7d586d07cc5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-14.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-14 +description: > + Array.prototype.filter - decreasing length of array causes index + property not to be visited +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var arr = [0, 1, 2, "last"]; +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[2], 2, 'newArr[2]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-15.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-15.js new file mode 100644 index 00000000000..caa81fd156c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-15.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-15 +description: > + Array.prototype.filter - decreasing length of array with prototype + property causes prototype index property to be visited +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var arr = [0, 1, 2]; +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[2], "prototype", 'newArr[2]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-16.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-16.js new file mode 100644 index 00000000000..b6660fd2954 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-16.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-16 +description: > + Array.prototype.filter - decreasing length of array does not + delete non-configurable properties +flags: [noStrict] +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var arr = [0, 1, 2]; +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[2], "unconfigurable", 'newArr[2]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-2.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-2.js new file mode 100644 index 00000000000..8a1390f3c95 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-2.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-2 +description: > + Array.prototype.filter - added properties in step 2 are visible + here +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + obj[2] = "length"; + return 3; + }, + configurable: true +}); +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], "length", 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-3.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-3.js new file mode 100644 index 00000000000..69f01f10331 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-3.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-3 +description: > + Array.prototype.filter - deleted properties in step 2 are visible + here +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 2: 6.99, + 8: 19 +}; +Object.defineProperty(obj, "length", { + get: function() { + delete obj[2]; + return 10; + }, + configurable: true +}); +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.notSameValue(newArr[0], 6.99, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-4.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-4.js new file mode 100644 index 00000000000..e0d446ce45d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-4.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-4 +description: > + Array.prototype.filter - properties added into own object after + current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.sameValue(newArr[1], 6.99, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-5.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-5.js new file mode 100644 index 00000000000..3545628a78b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-5.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-5 +description: > + Array.prototype.filter - properties added into own object after + current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[1], 6.99, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-6.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-6.js new file mode 100644 index 00000000000..fc31d392ad0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-6.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-6 +description: > + Array.prototype.filter - properties can be added to prototype + after current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.sameValue(SendableArray[1], 6.99, 'SendableArray[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-7.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-7.js new file mode 100644 index 00000000000..c05229be551 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-7.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-7 +description: > + Array.prototype.filter - properties can be added to prototype + after current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[1], 6.99, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-8.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-8.js new file mode 100644 index 00000000000..dae2774efe0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-8.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-8 +description: > + Array.prototype.filter - deleting own property causes index + property not to be visited on an Array-like object +---*/ + +var accessed = false; +var obj = { + length: 2 +}; +function callbackfn(val, idx, o) { + accessed = true; + return true; +} +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 0, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-9.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-9.js new file mode 100644 index 00000000000..49c522fc606 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-b-9.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-b-9 +description: > + Array.prototype.filter - deleting own property causes index + property not to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var arr = [1, 2]; +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 0, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-1.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-1.js new file mode 100644 index 00000000000..5d04e1e45e7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-1.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-c-i-1 +description: > + Array.prototype.filter - element to be retrieved is own data + property on an Array-like object +---*/ + +var kValue = {}; +function callbackfn(val, idx, obj) { + return (idx === 5) && (val === kValue); +} +var obj = { + 5: kValue, + length: 100 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], kValue, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-10.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-10.js new file mode 100644 index 00000000000..becd3b16482 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-10.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-c-i-10 +description: > + Array.prototype.filter - element to be retrieved is own accessor + property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return idx === 2 && val === 12; +} +var arr = []; +Object.defineProperty(arr, "2", { + get: function() { + return 12; + }, + configurable: true +}); +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 12, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-11.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-11.js new file mode 100644 index 00000000000..b661d713d6d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-11.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-c-i-11 +description: > + Array.prototype.filter - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return idx === 0 && val === 11; +} +var proto = { + 0: 5, + 1: 6 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 10; +Object.defineProperty(child, "0", { + get: function() { + return 11; + }, + configurable: true +}); +var newArr = SendableArray.prototype.filter.call(child, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-12.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-12.js new file mode 100644 index 00000000000..35d1a398ff2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-12.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-c-i-12 +description: > + Array.prototype.filter - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return val === 111 && idx === 0; +} +var arr = []; +SendableArray.prototype[0] = 10; +Object.defineProperty(arr, "0", { + get: function() { + return 111; + }, + configurable: true +}); +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 111, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-13.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-13.js new file mode 100644 index 00000000000..d4f9733eaaf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-13.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-c-i-13 +description: > + Array.prototype.filter - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return idx === 1 && val === 12; +} +var proto = {}; +Object.defineProperty(proto, "1", { + get: function() { + return 6; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 10; +Object.defineProperty(child, "1", { + get: function() { + return 12; + }, + configurable: true +}); +var newArr = SendableArray.prototype.filter.call(child, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 12, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-14.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-14.js new file mode 100644 index 00000000000..866271d5d2a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-14.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +es5id: 15.4.4.20-9-c-i-14 +description: > + Array.prototype.filter - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return idx === 0 && val === 11; +} +var arr = []; +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 5; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + return 11; + }, + configurable: true +}); +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-15.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-15.js new file mode 100644 index 00000000000..161178c6809 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-15.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return val === 11 && idx === 1; +} +var proto = {}; +Object.defineProperty(proto, "1", { + get: function() { + return 11; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 20; +var newArr = SendableArray.prototype.filter.call(child, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-16.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-16.js new file mode 100644 index 00000000000..51dd0638c8e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-16.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is inherited + accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return idx === 0 && val === 11; +} +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 11; + }, + configurable: true +}); +var newArr = [, , , ].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-17.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-17.js new file mode 100644 index 00000000000..ab2ca4eb8a9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-17.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return undefined === val && idx === 1; +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-18.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-18.js new file mode 100644 index 00000000000..0967977ac77 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-18.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +function callbackfn(val, idx, obj) { + return undefined === val && idx === 0; +} +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-19.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-19.js new file mode 100644 index 00000000000..c56717572eb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-19.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return undefined === val && idx === 1; +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); +Object.prototype[1] = 10; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-2.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-2.js new file mode 100644 index 00000000000..49db2ca0cb1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-2.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own data + property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-20.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-20.js new file mode 100644 index 00000000000..1c2abd9f736 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-20.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return undefined === val && idx === 0; +} +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +SendableArray.prototype[0] = 100; +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-21.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-21.js new file mode 100644 index 00000000000..8687a4570e8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-21.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return val === undefined && idx === 1; +} +var proto = {}; +Object.defineProperty(proto, "1", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +var newArr = SendableArray.prototype.filter.call(child, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-22.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-22.js new file mode 100644 index 00000000000..e08050b33e1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-22.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +function callbackfn(val, idx, obj) { + return undefined === val && idx === 0; +} +Object.defineProperty(SendableArray.prototype, "0", { + set: function() {}, + configurable: true +}); +var newArr = [, ].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], undefined, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-25.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-25.js new file mode 100644 index 00000000000..8e3f551d786 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-25.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - This object is the Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +function callbackfn(val, idx, obj) { + return val === 11 && idx === 0; +} +var func = function(a, b) { + return SendableArray.prototype.filter.call(arguments, callbackfn); +}; +var newArr = func(11); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-26.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-26.js new file mode 100644 index 00000000000..9b71d72c29e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-26.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - This object is the Arguments object which + implements its own property get method (number of arguments equals + number of parameters) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } else if (idx === 1) { + return val === 9; + } else { + return false; + } +} +var func = function(a, b) { + return SendableArray.prototype.filter.call(arguments, callbackfn); +}; +var newArr = func(11, 9); +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert.sameValue(newArr[1], 9, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-27.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-27.js new file mode 100644 index 00000000000..967c64de7e0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-27.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - This object is the Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } else if (idx === 1) { + return val === 12; + } else if (idx === 2) { + return val === 9; + } else { + return false; + } +} +var func = function(a, b) { + return SendableArray.prototype.filter.call(arguments, callbackfn); +}; +var newArr = func(11, 12, 9); +assert.sameValue(newArr.length, 3, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert.sameValue(newArr[1], 12, 'newArr[1]'); +assert.sameValue(newArr[2], 9, 'newArr[2]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-28.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-28.js new file mode 100644 index 00000000000..289704031dd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-28.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element changed by getter on previous + iterations is observed on an Array +---*/ + +var preIterVisible = false; +var arr = []; +function callbackfn(val, idx, obj) { + return idx === 1 && val === 9; +} +Object.defineProperty(arr, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 11; + } + }, + configurable: true +}); +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 9, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-29.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-29.js new file mode 100644 index 00000000000..c29c0c68fa0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-29.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element changed by getter on previous + iterations is observed on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return val === 9 && idx === 1; +} +var preIterVisible = false; +var obj = { + length: 2 +}; +Object.defineProperty(obj, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 13; + } + }, + configurable: true +}); +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 9, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-3.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-3.js new file mode 100644 index 00000000000..d2822bc6fb7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-3.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return (idx === 5) && (val === "abc"); +} +var proto = { + 0: 11, + 5: 100 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[5] = "abc"; +child.length = 10; +var newArr = SendableArray.prototype.filter.call(child, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], "abc", 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-30.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-30.js new file mode 100644 index 00000000000..3b752636158 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-30.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - unnhandled exceptions happened in getter + terminate iteration on an Array-like object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } + return true; +} +var obj = { + 0: 11, + 5: 10, + 10: 8, + length: 20 +}; +Object.defineProperty(obj, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + SendableArray.prototype.filter.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-31.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-31.js new file mode 100644 index 00000000000..0c7719ffae0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-31.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - unnhandled exceptions happened in getter + terminate iteration on an Array +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } + return true; +} +var arr = []; +arr[5] = 10; +arr[10] = 100; +Object.defineProperty(arr, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.filter(callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-4.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-4.js new file mode 100644 index 00000000000..39cade273e4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return (idx === 0) && (val === 12); +} +SendableArray.prototype[0] = 11; +var newArr = [12].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 12, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-5.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-5.js new file mode 100644 index 00000000000..a73215ce05f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-5.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return idx === 0 && val === 11; +} +var proto = {}; +Object.defineProperty(proto, "0", { + get: function() { + return 5; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +Object.defineProperty(child, "0", { + value: 11, + configurable: true +}); +child[1] = 12; +var newArr = SendableArray.prototype.filter.call(child, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-6.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-6.js new file mode 100644 index 00000000000..5fdc342657d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-6.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return val === 11; +} +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 9; + }, + configurable: true +}); +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-7.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-7.js new file mode 100644 index 00000000000..40be865701a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-7.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is inherited data + property on an Array-like object +---*/ + +var kValue = 'abc'; +function callbackfn(val, idx, obj) { + return (idx === 5) && (val === kValue); +} +var proto = { + 5: kValue +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 10; +var newArr = SendableArray.prototype.filter.call(child, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], kValue, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-8.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-8.js new file mode 100644 index 00000000000..6134bb6481f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-8.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is inherited data + property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return (idx === 1) && (val === 13); +} +SendableArray.prototype[1] = 13; +var newArr = [, , , ].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 13, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-9.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-9.js new file mode 100644 index 00000000000..3dd1ef80a87 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-i-9.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element to be retrieved is own accessor + property on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + return (idx === 0) && (val === 11); +} +var obj = { + 10: 10, + length: 20 +}; +Object.defineProperty(obj, "0", { + get: function() { + return 11; + }, + configurable: true +}); +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-1.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-1.js new file mode 100644 index 00000000000..e1c47754ae6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-1.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - callbackfn called with correct parameters +---*/ + +var bPar = true; +var bCalled = false; +function callbackfn(val, idx, obj) +{ + bCalled = true; + if (obj[idx] !== val) + bPar = false; +} +var srcArr = [0, 1, true, null, new Object(), "five"]; +srcArr[999999] = -6.6; +var resArr = srcArr.filter(callbackfn); +assert.sameValue(bCalled, true, 'bCalled'); +assert.sameValue(bPar, true, 'bPar'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-10.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-10.js new file mode 100644 index 00000000000..b316c52ccd3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-10.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn is called with 1 formal + parameter +---*/ + +function callbackfn(val) { + return val > 10; +} +var newArr = [12].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 12, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-11.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-11.js new file mode 100644 index 00000000000..fede2a41576 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-11.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn is called with 2 formal + parameter +---*/ + +function callbackfn(val, idx) { + return val > 10 && arguments[2][idx] === val; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-12.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-12.js new file mode 100644 index 00000000000..5b64600126a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-12.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn is called with 3 formal + parameter +---*/ + +function callbackfn(val, idx, obj) { + return val > 10 && obj[idx] === val; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-13.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-13.js new file mode 100644 index 00000000000..a5849e8c4e9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-13.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn that uses arguments object to + get parameter value +---*/ + +function callbackfn() { + return arguments[2][arguments[1]] === arguments[0]; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-16.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-16.js new file mode 100644 index 00000000000..71b3d0763fd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-16.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'this' of 'callbackfn' is a Boolean + object when T is not an object (T is a boolean) +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === false; +} +var obj = { + 0: 11, + length: 2 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn, false); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-17.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-17.js new file mode 100644 index 00000000000..e13ea2c476a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-17.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter -'this' of 'callbackfn' is a Number object + when T is not an object (T is a number) +---*/ + +function callbackfn(val, idx, o) { + return 5 === this.valueOf(); +} +var obj = { + 0: 11, + length: 2 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn, 5); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-18.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-18.js new file mode 100644 index 00000000000..22dba59637d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-18.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - 'this' of 'callbackfn' is an String + object when T is not an object (T is a string) +---*/ + +function callbackfn(val, idx, obj) { + return 'hello' === this.valueOf(); +} +var obj = { + 0: 11, + length: 2 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn, "hello"); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-19.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-19.js new file mode 100644 index 00000000000..126251432e1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-19.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - non-indexed properties are not called +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val === 8; +} +var obj = { + 0: 11, + non_index_property: 8, + 2: 5, + length: 20 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-2.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-2.js new file mode 100644 index 00000000000..1c33d6ec569 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-2.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - callbackfn takes 3 arguments +---*/ + +var parCnt = 3; +var bCalled = false +function callbackfn(val, idx, obj) +{ + bCalled = true; + if (arguments.length !== 3) + parCnt = arguments.length; //verify if callbackfn was called with 3 parameters +} +var srcArr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +var resArr = srcArr.filter(callbackfn); +assert.sameValue(bCalled, true, 'bCalled'); +assert.sameValue(parCnt, 3, 'parCnt'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-20.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-20.js new file mode 100644 index 00000000000..3984512ccad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-20.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn called with correct parameters + (thisArg is correct) +---*/ + +var thisArg = { + threshold: 10 +}; +function callbackfn(val, idx, obj) { + return this === thisArg; +} +var obj = { + 0: 11, + length: 1 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn, thisArg); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-21.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-21.js new file mode 100644 index 00000000000..619a36e9a1a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-21.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn called with correct parameters + (kValue is correct) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } + if (idx === 1) { + return val === 12; + } + return false; +} +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert.sameValue(newArr[1], 12, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-22.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-22.js new file mode 100644 index 00000000000..e97d8bbd7b2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-22.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn called with correct parameters + (the index k is correct) +---*/ + +function callbackfn(val, idx, obj) { + if (val === 11) { + return idx === 0; + } + if (val === 12) { + return idx === 1; + } + return false; +} +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); +assert.sameValue(newArr[1], 12, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-23.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-23.js new file mode 100644 index 00000000000..758971d5f5b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-23.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn called with correct parameters + (this object O is correct) +---*/ + +var obj = { + 0: 11, + length: 2 +}; +function callbackfn(val, idx, o) { + return obj === o; +} +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-4.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-4.js new file mode 100644 index 00000000000..68068d2ab77 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-4.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - k values are passed in ascending numeric + order +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +var lastIdx = 0; +var called = 0; +function callbackfn(val, idx, o) { + called++; + if (lastIdx !== idx) { + return false; + } else { + lastIdx++; + return true; + } +} +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, called, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-5.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-5.js new file mode 100644 index 00000000000..df97f3e3110 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-5.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - k values are accessed during each + iteration and not prior to starting the loop on an Array +---*/ + +var kIndex = []; +var called = 0; +//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(val, idx, obj) { + called++; + //Each position should be visited one time, which means k is accessed one time during iterations. + if (kIndex[idx] === undefined) { + //when current position is visited, its previous index should has been visited. + if (idx !== 0 && kIndex[idx - 1] === undefined) { + return true; + } + kIndex[idx] = 1; + return false; + } else { + return true; + } +} +var newArr = [11, 12, 13, 14].filter(callbackfn, undefined); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert.sameValue(called, 4, 'called'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-6.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-6.js new file mode 100644 index 00000000000..82487ed6079 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - arguments to callbackfn are self + consistent +---*/ + +var obj = { + 0: 11, + length: 1 +}; +var thisArg = {}; +function callbackfn() { + return this === thisArg && + arguments[0] === 11 && + arguments[1] === 0 && + arguments[2] === obj; +} +var newArr = SendableArray.prototype.filter.call(obj, callbackfn, thisArg); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-7.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-7.js new file mode 100644 index 00000000000..44599443633 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-7.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - unhandled exceptions happened in + callbackfn terminate iteration +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + if (called === 1) { + throw new Error("Exception occurred in callbackfn"); + } + return true; +} +var obj = { + 0: 11, + 4: 10, + 10: 8, + length: 20 +}; +assert.throws(Error, function() { + SendableArray.prototype.filter.call(obj, callbackfn); +}); +assert.sameValue(called, 1, 'called'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-8.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-8.js new file mode 100644 index 00000000000..d0b58ee1d97 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-8.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - element changed by callbackfn on previous + iterations is observed +---*/ + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +function callbackfn(val, idx, o) { + if (idx === 0) { + obj[idx + 1] = 8; + } + return val > 10; +} +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-9.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-9.js new file mode 100644 index 00000000000..7ae9704fa99 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-ii-9.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - callbackfn is called with 0 formal + parameter +---*/ + +function callbackfn() { + return true; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-1.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-1.js new file mode 100644 index 00000000000..052c6b8a766 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-1.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of returned array element equals to + 'kValue' +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr[0], obj[0], 'newArr[0]'); +assert.sameValue(newArr[1], obj[1], 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-2.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-2.js new file mode 100644 index 00000000000..92da69325d0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-2.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of returned array element can be + overwritten +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +var tempVal = newArr[1]; +newArr[1] += 1; +assert.notSameValue(newArr[1], tempVal, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-3.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-3.js new file mode 100644 index 00000000000..60188bdc803 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-3.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of returned array element can be + enumerated +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 0: 11, + length: 2 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +var prop; +var enumerable = false; +for (prop in newArr) { + if (newArr.hasOwnProperty(prop)) { + if (prop === "0") { + enumerable = true; + } + } +} +assert(enumerable, 'enumerable !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-4.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-4.js new file mode 100644 index 00000000000..f6e96181c7b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-4.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - value of returned array element can be + changed or deleted +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +var tempVal = newArr[1]; +delete newArr[1]; +assert.notSameValue(tempVal, undefined, 'tempVal'); +assert.sameValue(newArr[1], undefined, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-5.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-5.js new file mode 100644 index 00000000000..75eff04fde5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-5.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - values of 'to' are passed in acending + numeric order +---*/ + +var arr = [0, 1, 2, 3, 4]; +var lastToIdx = 0; +var called = 0; +function callbackfn(val, idx, obj) { + called++; + if (lastToIdx !== idx) { + return false; + } else { + lastToIdx++; + return true; + } +} +var newArr = arr.filter(callbackfn); +assert.sameValue(newArr.length, 5, 'newArr.length'); +assert.sameValue(called, 5, 'called'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-6.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-6.js new file mode 100644 index 00000000000..d53a0c85070 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1-6.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - values of 'to' are accessed during each + iteration when 'selected' is converted to true and not prior to + starting the loop +---*/ + +var toIndex = []; +var called = 0; +//By below way, we could verify that 'to' would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(val, idx, obj) { + called++; + //Each position should be visited one time, which means 'to' is accessed one time during iterations. + if (toIndex[idx] === undefined) { + //when current position is visited, its previous index should has been visited. + if (idx !== 0 && toIndex[idx - 1] === undefined) { + return false; + } + toIndex[idx] = 1; + return true; + } else { + return false; + } +} +var newArr = [11, 12, 13, 14].filter(callbackfn, undefined); +assert.sameValue(newArr.length, 4, 'newArr.length'); +assert.sameValue(called, 4, 'called'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1.js new file mode 100644 index 00000000000..8086bc71410 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-1.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - getOwnPropertyDescriptor(all true) of + returned array element +---*/ + +function callbackfn(val, idx, obj) { + if (val % 2) + return true; + else + return false; +} +var srcArr = [0, 1, 2, 3, 4]; +var resArr = srcArr.filter(callbackfn); +assert(resArr.length > 0, 'resArr.length > 0'); +var desc = Object.getOwnPropertyDescriptor(resArr, 1); +assert.sameValue(desc.value, 3, 'desc.value'); //srcArr[1] = true +assert.sameValue(desc.writable, true, 'desc.writable'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-10.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-10.js new file mode 100644 index 00000000000..d904830b83a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-10.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a number + (value is negative number) +---*/ + +function callbackfn(val, idx, obj) { + return -5; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-11.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-11.js new file mode 100644 index 00000000000..90204e24139 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-11.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a number + (value is Infinity) +---*/ + +function callbackfn(val, idx, obj) { + return Infinity; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-12.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-12.js new file mode 100644 index 00000000000..940e02bbfd3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-12.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a number + (value is -Infinity) +---*/ + +function callbackfn(val, idx, obj) { + return -Infinity; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-13.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-13.js new file mode 100644 index 00000000000..552f21c2fbc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-13.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a number + (value is NaN) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return NaN; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-14.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-14.js new file mode 100644 index 00000000000..4c9daeb0178 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-14.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is an empty + string +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return ""; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-15.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-15.js new file mode 100644 index 00000000000..a781b2d2cf4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-15.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a non-empty + string +---*/ + +function callbackfn(val, idx, obj) { + return "non-empty string"; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-16.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-16.js new file mode 100644 index 00000000000..acc89ca0b14 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-16.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a Function + object +---*/ + +function callbackfn(val, idx, obj) { + return function() {}; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-17.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-17.js new file mode 100644 index 00000000000..aa650e9fb08 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-17.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is an Array + object +---*/ + +function callbackfn(val, idx, obj) { + return new Array(10); +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-18.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-18.js new file mode 100644 index 00000000000..6f44e5d1aa7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-18.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a String + object +---*/ + +function callbackfn(val, idx, obj) { + return new String(); +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-19.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-19.js new file mode 100644 index 00000000000..95fb2e0b161 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-19.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter return value of callbackfn is a Boolean + object +---*/ + +function callbackfn(val, idx, obj) { + return new Boolean(); +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-2.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-2.js new file mode 100644 index 00000000000..53c448f73de --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-2.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - return value of callbackfn is undefined +---*/ + +var accessed = false; +function callbackfn(val, idx, o) { + accessed = true; + return undefined; +} + +var obj = { + 0: 11, + length: 1 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-20.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-20.js new file mode 100644 index 00000000000..8133789f13a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-20.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a Number + object +---*/ + +function callbackfn(val, idx, obj) { + return new Number(); +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-21.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-21.js new file mode 100644 index 00000000000..5f1b6e8dc2f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-21.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is the Math + object +---*/ + +function callbackfn(val, idx, obj) { + return Math; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-22.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-22.js new file mode 100644 index 00000000000..bd4aa235078 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-22.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a Date + object +---*/ + +function callbackfn(val, idx, obj) { + return new Date(0); +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-23.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-23.js new file mode 100644 index 00000000000..e770273dce8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-23.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a RegExp + object +---*/ + +function callbackfn(val, idx, obj) { + return new RegExp(); +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-24.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-24.js new file mode 100644 index 00000000000..23985e9a487 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-24.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is the JSON + object +---*/ + +function callbackfn(val, idx, obj) { + return JSON; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-25.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-25.js new file mode 100644 index 00000000000..5cf04f4998c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-25.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is an Error + object +---*/ + +function callbackfn(val, idx, obj) { + return new EvalError(); +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-26.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-26.js new file mode 100644 index 00000000000..b446b9905f9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-26.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is the + Arguments object +---*/ + +function callbackfn(val, idx, obj) { + return arguments; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-28.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-28.js new file mode 100644 index 00000000000..836bb182d63 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-28.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is the global + object +---*/ + +var global = this; + +function callbackfn(val, idx, obj) { + return global; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-29.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-29.js new file mode 100644 index 00000000000..dbbdee45cac --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-29.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - false prevents element added to output + Array +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + return val > 10; +} +var obj = { + 0: 11, + 1: 8, + length: 20 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.notSameValue(newArr[0], 8, 'newArr[0]'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-3.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-3.js new file mode 100644 index 00000000000..c113735982d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-3.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter - return value of callbackfn is null +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return null; +} +var obj = { + 0: 11, + length: 1 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-30.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-30.js new file mode 100644 index 00000000000..f36952566fc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-30.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value (new Boolean(false)) of + callbackfn is treated as true value +---*/ + +function callbackfn(val, idx, obj) { + return new Boolean(false); +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-4.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-4.js new file mode 100644 index 00000000000..82c7ddfe10d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-4.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a boolean + (value is false) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return false; +} +var obj = { + 0: 11, + length: 1 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-5.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-5.js new file mode 100644 index 00000000000..719c3f7a935 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-5.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a boolean + (value is true) +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 0: 11, + length: 1 +}; +var newArr = SendableArray.prototype.filter.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-6.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-6.js new file mode 100644 index 00000000000..d71d0d46ff2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-6.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a number + (value is 0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return 0; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-7.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-7.js new file mode 100644 index 00000000000..fef3580b1e4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-7.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a number + (value is +0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return +0; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-8.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-8.js new file mode 100644 index 00000000000..a7bf9c37026 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-8.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a nunmber + (value is -0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return -0; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-9.js b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-9.js new file mode 100644 index 00000000000..baae8633b3c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/15.4.4.20-9-c-iii-9.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter - return value of callbackfn is a number + (value is positive number) +---*/ + +function callbackfn(val, idx, obj) { + return 5; +} +var newArr = [11].filter(callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); +assert.sameValue(newArr[0], 11, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/filter/call-with-boolean.js b/test/sendable/builtins/Array/prototype/filter/call-with-boolean.js new file mode 100644 index 00000000000..8b0172fdc38 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/call-with-boolean.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Array.prototype.filter applied to boolean primitive +includes: [compareArray.js] +---*/ + +assert.compareArray( + SendableArray.prototype.filter.call(true, () => {}), + [], + 'SendableArray.prototype.filter.call(true, () => {}) must return []' +); +assert.compareArray( + SendableArray.prototype.filter.call(false, () => {}), + [], + 'SendableArray.prototype.filter.call(false, () => {}) must return []' +); diff --git a/test/sendable/builtins/Array/prototype/filter/callbackfn-resize-arraybuffer.js b/test/sendable/builtins/Array/prototype/filter/callbackfn-resize-arraybuffer.js new file mode 100644 index 00000000000..70ae9741a75 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/callbackfn-resize-arraybuffer.js @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + elements = []; + indices = []; + arrays = []; + result = SendableArray.prototype.filter.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + elements.push(element); + indices.push(index); + arrays.push(array); + return true; + }); + assert.compareArray(elements, expectedElements, 'elements (shrink)'); + assert.compareArray(indices, expectedIndices, 'indices (shrink)'); + assert.compareArray(arrays, expectedArrays, 'arrays (shrink)'); + assert.compareArray(result, expectedElements, 'result (shrink)'); + elements = []; + indices = []; + arrays = []; + result = SendableArray.prototype.filter.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return true; + }); + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.compareArray(result, expectedElements, 'result (grow)'); +}); diff --git a/test/sendable/builtins/Array/prototype/filter/create-ctor-non-object.js b/test/sendable/builtins/Array/prototype/filter/create-ctor-non-object.js new file mode 100644 index 00000000000..124bfcb7f8e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/create-ctor-non-object.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Behavior when `constructor` property is neither an Object nor undefined +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 9. If IsConstructor(C) is false, throw a TypeError exception. +---*/ + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 0; +}; +a.constructor = null; +assert.throws(TypeError, function() { + a.filter(cb); +}, 'null value'); +assert.sameValue(callCount, 0, 'callback not invoked (null value)'); +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.filter(cb); +}, 'number value'); +assert.sameValue(callCount, 0, 'callback not invoked (number value)'); +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.filter(cb); +}, 'string value'); +assert.sameValue(callCount, 0, 'callback not invoked (string value)'); +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.filter(cb); +}, 'boolean value'); +assert.sameValue(callCount, 0, 'callback not invoked (boolean value)'); diff --git a/test/sendable/builtins/Array/prototype/filter/create-ctor-poisoned.js b/test/sendable/builtins/Array/prototype/filter/create-ctor-poisoned.js new file mode 100644 index 00000000000..4e8a3fa815f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/create-ctor-poisoned.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Abrupt completion from `constructor` property access +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + 9.4.2.3 ArraySpeciesCreate + [...] + 5. Let C be ? Get(originalArray, "constructor"). +---*/ + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 1; +}; +Object.defineProperty(a, 'constructor', { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + a.filter(cb); +}); +assert.sameValue(callCount, 0); diff --git a/test/sendable/builtins/Array/prototype/filter/create-non-array.js b/test/sendable/builtins/Array/prototype/filter/create-non-array.js new file mode 100644 index 00000000000..9d16919cea6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/create-non-array.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Constructor is ignored for non-Array values +info: | + 5. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + 3. Let isArray be ? IsArray(originalArray). + 4. If isArray is false, return ? ArrayCreate(length). +---*/ + +var obj = { + length: 0 +}; +var callCount = 0; +var result; +Object.defineProperty(obj, 'constructor', { + get: function() { + callCount += 1; + } +}); +result = SendableArray.prototype.filter.call(obj, function() {}); +assert.sameValue(callCount, 0, '`constructor` property not accessed'); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert(SendableArray.isArray(result), 'result is an Array exotic object'); +assert.sameValue(result.length, 0, 'array created with appropriate length'); diff --git a/test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-array.js b/test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-array.js new file mode 100644 index 00000000000..1f90ae55ebd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-array.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Prefer Array constructor of current realm record +info: | + 1. Let O be ? ToObject(this value). + 5. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C + be undefined. +features: [cross-realm, Symbol.species] +---*/ + +var SendableArray = []; +var callCount = 0; +var OArray = $262.createRealm().global.SendableArray; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +SendableArray.constructor = OArray; +Object.defineProperty(SendableArray, Symbol.species, speciesDesc); +Object.defineProperty(OArray, Symbol.species, speciesDesc); +result = SendableArray.filter(function() {}); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert.sameValue(callCount, 0, 'Species constructor is not referenced'); diff --git a/test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-non-array.js b/test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-non-array.js new file mode 100644 index 00000000000..693dd476ed8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-non-array.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Accept non-Array constructors from other realms +info: | + 1. Let O be ? ToObject(this value). + 5. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + 5. Let C be ? Get(originalArray, "constructor"). + 6. If IsConstructor(C) is true, then + a. Let thisRealm be the current Realm Record. + b. Let realmC be ? GetFunctionRealm(C). + c. If thisRealm and realmC are not the same Realm Record, then + i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C + be undefined. +features: [cross-realm, Symbol.species] +---*/ + +var SendableArray = []; +var callCount = 0; +var CustomCtor = function() {}; +var OObject = $262.createRealm().global.Object; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +SendableArray.constructor = OObject; +OObject[Symbol.species] = CustomCtor; + +Object.defineProperty(SendableArray, Symbol.species, speciesDesc); +result = SendableArray.filter(function() {}); +assert.sameValue(Object.getPrototypeOf(result), CustomCtor.prototype); +assert.sameValue(callCount, 0, 'SendableArray species constructor is not referenced'); diff --git a/test/sendable/builtins/Array/prototype/filter/create-proxy.js b/test/sendable/builtins/Array/prototype/filter/create-proxy.js new file mode 100644 index 00000000000..56bd062e43b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/create-proxy.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Species constructor of a Proxy object whose target is an array +info: | + 5. Let A be ? ArraySpeciesCreate(O, 0). + 9. Return A. + 9.4.2.3 ArraySpeciesCreate + 3. Let isArray be ? IsArray(originalArray). + 7.2.2 IsArray + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is + null, throw a TypeError exception. + b. Let target be the value of the [[ProxyTarget]] internal slot of + argument. + c. Return ? IsArray(target). +features: [Proxy, Symbol.species] +---*/ + +var SendableArray = []; +var proxy = new Proxy(new Proxy(SendableArray, {}), {}); +var Ctor = function() {}; +var result; +SendableArray.constructor = function() {}; +SendableArray.constructor[Symbol.species] = Ctor; +result = SendableArray.prototype.filter.call(proxy, function() {}); +assert.sameValue(Object.getPrototypeOf(result), Ctor.prototype); diff --git a/test/sendable/builtins/Array/prototype/filter/create-revoked-proxy.js b/test/sendable/builtins/Array/prototype/filter/create-revoked-proxy.js new file mode 100644 index 00000000000..6f0c7fc2e67 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/create-revoked-proxy.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Abrupt completion from constructor that is a revoked Proxy object +info: | + 5. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + 3. Let isArray be ? IsArray(originalArray). + 7.2.2 IsArray + 3. If argument is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of argument is + null, throw a TypeError exception. +features: [Proxy] +---*/ + +var o = Proxy.revocable([], {}); +var ctorCount = 0; +var cbCount = 0; +var cb = function() { + cbCount += 1; +}; +Object.defineProperty(o.proxy, 'constructor', { + get: function() { + ctorCount += 1; + } +}); +o.revoke(); +assert.throws(TypeError, function() { + SendableArray.prototype.filter.call(o.proxy, cb); +}); +assert.sameValue(ctorCount, 0, '`constructor` property not accessed'); +assert.sameValue(cbCount, 0, 'callback not invoked'); diff --git a/test/sendable/builtins/Array/prototype/filter/create-species-abrupt.js b/test/sendable/builtins/Array/prototype/filter/create-species-abrupt.js new file mode 100644 index 00000000000..13a6af07fcf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/create-species-abrupt.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Species constructor returns an abrupt completion +info: | + 5. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + 5. Let C be ? Get(originalArray, "constructor"). + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var Ctor = function() { + throw new Test262Error(); +}; +var callCount = 0; +var cb = function() { + callCount += 1; +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; +assert.throws(Test262Error, function() { + a.filter(cb); +}); +assert.sameValue(callCount, 0); diff --git a/test/sendable/builtins/Array/prototype/filter/create-species-non-ctor.js b/test/sendable/builtins/Array/prototype/filter/create-species-non-ctor.js new file mode 100644 index 00000000000..5462c0ade79 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/create-species-non-ctor.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Behavior when the @@species attribute is a non-constructor object +info: | + 5. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + 5. Let C be ? Get(originalArray, "constructor"). + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 9. If IsConstructor(C) is false, throw a TypeError exception. +includes: [isConstructor.js] +features: [Symbol.species, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(parseInt), + false, + 'precondition: isConstructor(parseInt) must return false' +); +var a = []; +var callCount = 0; +var cb = function() { + callCount += 1; +}; +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; +assert.throws(TypeError, function() { + a.filter(cb); +}, 'a.filter(cb) throws a TypeError exception'); +assert.sameValue(callCount, 0); diff --git a/test/sendable/builtins/Array/prototype/filter/create-species-null.js b/test/sendable/builtins/Array/prototype/filter/create-species-null.js new file mode 100644 index 00000000000..2d338440bb4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/create-species-null.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + A null value for the @@species constructor is interpreted as `undefined` +info: | + 5. Let A be ? ArraySpeciesCreate(O, 0). + 9.4.2.3 ArraySpeciesCreate + 5. Let C be ? Get(originalArray, "constructor"). + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). +features: [Symbol.species] +---*/ + +var a = []; +var result; +a.constructor = {}; +a.constructor[Symbol.species] = null; +result = a.filter(function() {}); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert(SendableArray.isArray(result), 'result is an Array exotic object'); diff --git a/test/sendable/builtins/Array/prototype/filter/create-species-poisoned.js b/test/sendable/builtins/Array/prototype/filter/create-species-poisoned.js new file mode 100644 index 00000000000..c57dea8002a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/create-species-poisoned.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Abrupt completion from `@@species` property access +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). +features: [Symbol.species] +---*/ + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 1; +}; +a.constructor = {}; + +Object.defineProperty(a.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + a.filter(cb); +}); +assert.sameValue(callCount, 0); diff --git a/test/sendable/builtins/Array/prototype/filter/create-species-undef.js b/test/sendable/builtins/Array/prototype/filter/create-species-undef.js new file mode 100644 index 00000000000..e2e4793ebaa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/create-species-undef.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + An undefined value for the @@species constructor triggers the creation of + an Array exotic object +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + 8. If C is undefined, return ? ArrayCreate(length). +features: [Symbol.species] +---*/ + +var a = []; +var result; + +a.constructor = {}; +a.constructor[Symbol.species] = undefined; + +result = a.filter(function() {}); + +assert.sameValue(Object.getPrototypeOf(result), Array.prototype); +assert(Array.isArray(result), 'result is an Array exotic object'); diff --git a/test/sendable/builtins/Array/prototype/filter/create-species.js b/test/sendable/builtins/Array/prototype/filter/create-species.js new file mode 100644 index 00000000000..09f4afd2fa0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/create-species.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: Species constructor is used to create a new instance +info: | + [...] + 5. Let A be ? ArraySpeciesCreate(O, 0). + [...] + + 9.4.2.3 ArraySpeciesCreate + + [...] + 5. Let C be ? Get(originalArray, "constructor"). + [...] + 7. If Type(C) is Object, then + a. Let C be ? Get(C, @@species). + b. If C is null, let C be undefined. + [...] + 10. Return ? Construct(C, « length »). +features: [Symbol.species] +---*/ + +var thisValue, args, result; +var callCount = 0; +var instance = []; +var Ctor = function() { + callCount += 1; + thisValue = this; + args = arguments; + return instance; +}; +var a = [1, 2, 3, 4, 5, 6, 7]; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; + +result = a.filter(function() {}); + +assert.sameValue(callCount, 1, 'Constructor invoked exactly once'); +assert.sameValue(Object.getPrototypeOf(thisValue), Ctor.prototype); +assert.sameValue(args.length, 1, 'Constructor invoked with a single argument'); +assert.sameValue(args[0], 0); +assert.sameValue(result, instance); diff --git a/test/sendable/builtins/Array/prototype/filter/length.js b/test/sendable/builtins/Array/prototype/filter/length.js new file mode 100644 index 00000000000..8d0e174d39d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/length.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.filter +description: > + The "length" property of Array.prototype.filter +info: | + 22.1.3.7 Array.prototype.filter ( callbackfn [ , thisArg ] ) + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.filter, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/filter/name.js b/test/sendable/builtins/Array/prototype/filter/name.js new file mode 100644 index 00000000000..6009f8f92b4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.prototype.filter.name is "filter". +info: | + Array.prototype.filter ( callbackfn [ , thisArg ] ) + 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(SendableArray.prototype.filter, "name", { + value: "filter", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/filter/not-a-constructor.js b/test/sendable/builtins/Array/prototype/filter/not-a-constructor.js new file mode 100644 index 00000000000..70051077fab --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/not-a-constructor.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.filter 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(SendableArray.prototype.filter), + false, + 'isConstructor(SendableArray.prototype.filter) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.filter(() => {}); +}); + diff --git a/test/sendable/builtins/Array/prototype/filter/prop-desc.js b/test/sendable/builtins/Array/prototype/filter/prop-desc.js new file mode 100644 index 00000000000..5be5d11e8ff --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + "filter" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.filter, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "filter", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/filter/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/Array/prototype/filter/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..4ea14c04b21 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.p.filter behaves correctly on TypedArrays backed by resizable buffers + that grow mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(fixedLength, ResizeMidIteration)), []); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(fixedLengthWithOffset, ResizeMidIteration)), []); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(lengthTracking, ResizeMidIteration)), []); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(lengthTrackingWithOffset, ResizeMidIteration)), []); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/filter/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/Array/prototype/filter/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..cf7c000d6ee --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-%array%.prototype.filter +description: > + Array.p.filter behaves correctly on TypedArrays backed by resizable buffers + that shrink mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(fixedLength, ResizeMidIteration)),[]); + assert.compareArray(values, [ + 0, + 2 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(fixedLengthWithOffset, ResizeMidIteration)),[]); + assert.compareArray(values, [ + 4 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(lengthTracking, ResizeMidIteration)),[]); + assert.compareArray(values, [ + 0, + 2, + 4 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(lengthTrackingWithOffset, ResizeMidIteration)),[]); + assert.compareArray(values, [ + 4 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/filter/resizable-buffer.js b/test/sendable/builtins/Array/prototype/filter/resizable-buffer.js new file mode 100644 index 00000000000..50fbe050348 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/resizable-buffer.js @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Array.p.filter behaves correctly on TypedArrays backed by resizable buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + // Orig. array: [0, 1, 2, 3] + // [0, 1, 2, 3] << fixedLength + // [2, 3] << fixedLengthWithOffset + // [0, 1, 2, 3, ...] << lengthTracking + // [2, 3, ...] << lengthTrackingWithOffset + function isEven(n) { + return n != undefined && Number(n) % 2 == 0; + } + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(fixedLength, isEven)), [ + 0, + 2 + ]); + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(fixedLengthWithOffset, isEven)), [2]); + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(lengthTracking, isEven)), [ + 0, + 2 + ]); + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(lengthTrackingWithOffset, isEven)), [2]); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 1, 2] + // [0, 1, 2, ...] << lengthTracking + // [2, ...] << lengthTrackingWithOffset + + assert.compareArray(SendableArray.prototype.filter.call(fixedLength, isEven), []); + assert.compareArray(SendableArray.prototype.filter.call(fixedLengthWithOffset, isEven), []); + + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(lengthTracking, isEven)), [ + 0, + 2 + ]); + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(lengthTrackingWithOffset, isEven)), [2]); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.compareArray(SendableArray.prototype.filter.call(fixedLength, isEven), []); + assert.compareArray(SendableArray.prototype.filter.call(fixedLengthWithOffset, isEven), []); + assert.compareArray(SendableArray.prototype.filter.call(lengthTrackingWithOffset, isEven), []); + + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(lengthTracking, isEven)), [0]); + + // Shrink to zero. + rab.resize(0); + assert.compareArray(SendableArray.prototype.filter.call(fixedLength, isEven), []); + assert.compareArray(SendableArray.prototype.filter.call(fixedLengthWithOffset, isEven), []); + assert.compareArray(SendableArray.prototype.filter.call(lengthTrackingWithOffset, isEven), []); + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(lengthTracking, isEven)), []); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + // Orig. array: [0, 1, 2, 3, 4, 5] + // [0, 1, 2, 3] << fixedLength + // [2, 3] << fixedLengthWithOffset + // [0, 1, 2, 3, 4, 5, ...] << lengthTracking + // [2, 3, 4, 5, ...] << lengthTrackingWithOffset + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(fixedLength, isEven)), [ + 0, + 2 + ]); + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(fixedLengthWithOffset, isEven)), [2]); + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(lengthTracking, isEven)), [ + 0, + 2, + 4 + ]); + assert.compareArray(ToNumbers(SendableArray.prototype.filter.call(lengthTrackingWithOffset, isEven)), [ + 2, + 4 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/filter/target-array-non-extensible.js b/test/sendable/builtins/Array/prototype/filter/target-array-non-extensible.js new file mode 100644 index 00000000000..ad278b77399 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/target-array-non-extensible.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible) +info: | + Array.prototype.filter ( callbackfn [ , thisArg ] ) + 7. Repeat, while k < len + c. If kPresent is true, then + iii. If selected is true, then + 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue). + CreateDataPropertyOrThrow ( O, P, V ) + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.filter(function() { + return true; + }); +}); diff --git a/test/sendable/builtins/Array/prototype/filter/target-array-with-non-configurable-property.js b/test/sendable/builtins/Array/prototype/filter/target-array-with-non-configurable-property.js new file mode 100644 index 00000000000..df904499c83 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/target-array-with-non-configurable-property.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable) +info: | + Array.prototype.filter ( callbackfn [ , thisArg ] ) + 7. Repeat, while k < len + c. If kPresent is true, then + iii. If selected is true, then + 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue). + CreateDataPropertyOrThrow ( O, P, V ) + 3. Let success be ? CreateDataProperty(O, P, V). + 4. If success is false, throw a TypeError exception. +features: [Symbol.species] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + writable: true, + configurable: false, + }); +}; +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.filter(function() { + return true; + }); +}); diff --git a/test/sendable/builtins/Array/prototype/filter/target-array-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/filter/target-array-with-non-writable-property.js new file mode 100644 index 00000000000..b4e268a2bcf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/filter/target-array-with-non-writable-property.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.filter +description: > + Non-writable properties are overwritten by CreateDataPropertyOrThrow. +info: | + 22.1.3.7 Array.prototype.filter ( callbackfn [ , thisArg ] ) + 8. Repeat, while k < len + c. If kPresent is true, then + iii. If selected is true, then + 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue). +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var a = [1]; +a.constructor = {}; +a.constructor[Symbol.species] = function(len) { + var q = new SendableArray(0); + Object.defineProperty(q, 0, { + value: 0, writable: false, configurable: true, enumerable: false, + }); + return q; +}; +var r = a.filter(function(){ return true; }); +verifyProperty(r, 0, { + value: 1, writable: true, configurable: true, enumerable: true, +}); -- Gitee From 97a3815ccbf9bb4e90fe9f0e2561a4288f805e91 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 23 Dec 2024 15:48:08 +0800 Subject: [PATCH 32/93] modify array-filter cases Signed-off-by: zhuzhihui7 --- .../prototype/filter/create-ctor-non-object.js | 11 ----------- .../prototype/filter/create-ctor-poisoned.js | 7 ------- .../Array/prototype/filter/create-non-array.js | 5 ----- .../filter/create-proto-from-ctor-realm-array.js | 11 ----------- .../create-proto-from-ctor-realm-non-array.js | 11 ----------- .../Array/prototype/filter/create-proxy.js | 12 ------------ .../prototype/filter/create-revoked-proxy.js | 8 -------- .../prototype/filter/create-species-abrupt.js | 8 -------- .../prototype/filter/create-species-non-ctor.js | 8 -------- .../Array/prototype/filter/create-species-null.js | 8 -------- .../prototype/filter/create-species-poisoned.js | 12 ------------ .../prototype/filter/create-species-undef.js | 14 -------------- .../Array/prototype/filter/create-species.js | 15 --------------- .../filter/target-array-non-extensible.js | 9 --------- ...target-array-with-non-configurable-property.js | 9 --------- .../target-array-with-non-writable-property.js | 6 ------ 16 files changed, 154 deletions(-) diff --git a/test/sendable/builtins/Array/prototype/filter/create-ctor-non-object.js b/test/sendable/builtins/Array/prototype/filter/create-ctor-non-object.js index 124bfcb7f8e..88cd95b4b27 100644 --- a/test/sendable/builtins/Array/prototype/filter/create-ctor-non-object.js +++ b/test/sendable/builtins/Array/prototype/filter/create-ctor-non-object.js @@ -16,17 +16,6 @@ esid: sec-array.prototype.filter description: > Behavior when `constructor` property is neither an Object nor undefined -info: | - [...] - 5. Let A be ? ArraySpeciesCreate(O, 0). - [...] - - 9.4.2.3 ArraySpeciesCreate - - [...] - 5. Let C be ? Get(originalArray, "constructor"). - [...] - 9. If IsConstructor(C) is false, throw a TypeError exception. ---*/ var a = []; diff --git a/test/sendable/builtins/Array/prototype/filter/create-ctor-poisoned.js b/test/sendable/builtins/Array/prototype/filter/create-ctor-poisoned.js index 4e8a3fa815f..abb5f502c14 100644 --- a/test/sendable/builtins/Array/prototype/filter/create-ctor-poisoned.js +++ b/test/sendable/builtins/Array/prototype/filter/create-ctor-poisoned.js @@ -15,13 +15,6 @@ /*--- esid: sec-array.prototype.filter description: Abrupt completion from `constructor` property access -info: | - [...] - 5. Let A be ? ArraySpeciesCreate(O, 0). - [...] - 9.4.2.3 ArraySpeciesCreate - [...] - 5. Let C be ? Get(originalArray, "constructor"). ---*/ var a = []; diff --git a/test/sendable/builtins/Array/prototype/filter/create-non-array.js b/test/sendable/builtins/Array/prototype/filter/create-non-array.js index 9d16919cea6..7128ab3e54b 100644 --- a/test/sendable/builtins/Array/prototype/filter/create-non-array.js +++ b/test/sendable/builtins/Array/prototype/filter/create-non-array.js @@ -15,11 +15,6 @@ /*--- esid: sec-array.prototype.filter description: Constructor is ignored for non-Array values -info: | - 5. Let A be ? ArraySpeciesCreate(O, 0). - 9.4.2.3 ArraySpeciesCreate - 3. Let isArray be ? IsArray(originalArray). - 4. If isArray is false, return ? ArrayCreate(length). ---*/ var obj = { diff --git a/test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-array.js b/test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-array.js index 1f90ae55ebd..c2f57ebc402 100644 --- a/test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-array.js +++ b/test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-array.js @@ -15,17 +15,6 @@ /*--- esid: sec-array.prototype.filter description: Prefer Array constructor of current realm record -info: | - 1. Let O be ? ToObject(this value). - 5. Let A be ? ArraySpeciesCreate(O, 0). - 9.4.2.3 ArraySpeciesCreate - 5. Let C be ? Get(originalArray, "constructor"). - 6. If IsConstructor(C) is true, then - a. Let thisRealm be the current Realm Record. - b. Let realmC be ? GetFunctionRealm(C). - c. If thisRealm and realmC are not the same Realm Record, then - i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C - be undefined. features: [cross-realm, Symbol.species] ---*/ diff --git a/test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-non-array.js b/test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-non-array.js index 693dd476ed8..696bee824db 100644 --- a/test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-non-array.js +++ b/test/sendable/builtins/Array/prototype/filter/create-proto-from-ctor-realm-non-array.js @@ -15,17 +15,6 @@ /*--- esid: sec-array.prototype.filter description: Accept non-Array constructors from other realms -info: | - 1. Let O be ? ToObject(this value). - 5. Let A be ? ArraySpeciesCreate(O, 0). - 9.4.2.3 ArraySpeciesCreate - 5. Let C be ? Get(originalArray, "constructor"). - 6. If IsConstructor(C) is true, then - a. Let thisRealm be the current Realm Record. - b. Let realmC be ? GetFunctionRealm(C). - c. If thisRealm and realmC are not the same Realm Record, then - i. If SameValue(C, realmC.[[Intrinsics]].[[%Array%]]) is true, let C - be undefined. features: [cross-realm, Symbol.species] ---*/ diff --git a/test/sendable/builtins/Array/prototype/filter/create-proxy.js b/test/sendable/builtins/Array/prototype/filter/create-proxy.js index 56bd062e43b..dbaf65e99cd 100644 --- a/test/sendable/builtins/Array/prototype/filter/create-proxy.js +++ b/test/sendable/builtins/Array/prototype/filter/create-proxy.js @@ -15,18 +15,6 @@ /*--- esid: sec-array.prototype.filter description: Species constructor of a Proxy object whose target is an array -info: | - 5. Let A be ? ArraySpeciesCreate(O, 0). - 9. Return A. - 9.4.2.3 ArraySpeciesCreate - 3. Let isArray be ? IsArray(originalArray). - 7.2.2 IsArray - 3. If argument is a Proxy exotic object, then - a. If the value of the [[ProxyHandler]] internal slot of argument is - null, throw a TypeError exception. - b. Let target be the value of the [[ProxyTarget]] internal slot of - argument. - c. Return ? IsArray(target). features: [Proxy, Symbol.species] ---*/ diff --git a/test/sendable/builtins/Array/prototype/filter/create-revoked-proxy.js b/test/sendable/builtins/Array/prototype/filter/create-revoked-proxy.js index 6f0c7fc2e67..0c60b5ed38a 100644 --- a/test/sendable/builtins/Array/prototype/filter/create-revoked-proxy.js +++ b/test/sendable/builtins/Array/prototype/filter/create-revoked-proxy.js @@ -15,14 +15,6 @@ /*--- esid: sec-array.prototype.filter description: Abrupt completion from constructor that is a revoked Proxy object -info: | - 5. Let A be ? ArraySpeciesCreate(O, 0). - 9.4.2.3 ArraySpeciesCreate - 3. Let isArray be ? IsArray(originalArray). - 7.2.2 IsArray - 3. If argument is a Proxy exotic object, then - a. If the value of the [[ProxyHandler]] internal slot of argument is - null, throw a TypeError exception. features: [Proxy] ---*/ diff --git a/test/sendable/builtins/Array/prototype/filter/create-species-abrupt.js b/test/sendable/builtins/Array/prototype/filter/create-species-abrupt.js index 13a6af07fcf..155b6fcc314 100644 --- a/test/sendable/builtins/Array/prototype/filter/create-species-abrupt.js +++ b/test/sendable/builtins/Array/prototype/filter/create-species-abrupt.js @@ -15,14 +15,6 @@ /*--- esid: sec-array.prototype.filter description: Species constructor returns an abrupt completion -info: | - 5. Let A be ? ArraySpeciesCreate(O, 0). - 9.4.2.3 ArraySpeciesCreate - 5. Let C be ? Get(originalArray, "constructor"). - 7. If Type(C) is Object, then - a. Let C be ? Get(C, @@species). - b. If C is null, let C be undefined. - 10. Return ? Construct(C, « length »). features: [Symbol.species] ---*/ diff --git a/test/sendable/builtins/Array/prototype/filter/create-species-non-ctor.js b/test/sendable/builtins/Array/prototype/filter/create-species-non-ctor.js index 5462c0ade79..47886fb3e91 100644 --- a/test/sendable/builtins/Array/prototype/filter/create-species-non-ctor.js +++ b/test/sendable/builtins/Array/prototype/filter/create-species-non-ctor.js @@ -16,14 +16,6 @@ esid: sec-array.prototype.filter description: > Behavior when the @@species attribute is a non-constructor object -info: | - 5. Let A be ? ArraySpeciesCreate(O, 0). - 9.4.2.3 ArraySpeciesCreate - 5. Let C be ? Get(originalArray, "constructor"). - 7. If Type(C) is Object, then - a. Let C be ? Get(C, @@species). - b. If C is null, let C be undefined. - 9. If IsConstructor(C) is false, throw a TypeError exception. includes: [isConstructor.js] features: [Symbol.species, Reflect.construct] ---*/ diff --git a/test/sendable/builtins/Array/prototype/filter/create-species-null.js b/test/sendable/builtins/Array/prototype/filter/create-species-null.js index 2d338440bb4..6abdc347ef4 100644 --- a/test/sendable/builtins/Array/prototype/filter/create-species-null.js +++ b/test/sendable/builtins/Array/prototype/filter/create-species-null.js @@ -16,14 +16,6 @@ esid: sec-array.prototype.filter description: > A null value for the @@species constructor is interpreted as `undefined` -info: | - 5. Let A be ? ArraySpeciesCreate(O, 0). - 9.4.2.3 ArraySpeciesCreate - 5. Let C be ? Get(originalArray, "constructor"). - 7. If Type(C) is Object, then - a. Let C be ? Get(C, @@species). - b. If C is null, let C be undefined. - 8. If C is undefined, return ? ArrayCreate(length). features: [Symbol.species] ---*/ diff --git a/test/sendable/builtins/Array/prototype/filter/create-species-poisoned.js b/test/sendable/builtins/Array/prototype/filter/create-species-poisoned.js index c57dea8002a..23ef097558c 100644 --- a/test/sendable/builtins/Array/prototype/filter/create-species-poisoned.js +++ b/test/sendable/builtins/Array/prototype/filter/create-species-poisoned.js @@ -15,18 +15,6 @@ /*--- esid: sec-array.prototype.filter description: Abrupt completion from `@@species` property access -info: | - [...] - 5. Let A be ? ArraySpeciesCreate(O, 0). - [...] - - 9.4.2.3 ArraySpeciesCreate - - [...] - 5. Let C be ? Get(originalArray, "constructor"). - [...] - 7. If Type(C) is Object, then - a. Let C be ? Get(C, @@species). features: [Symbol.species] ---*/ diff --git a/test/sendable/builtins/Array/prototype/filter/create-species-undef.js b/test/sendable/builtins/Array/prototype/filter/create-species-undef.js index e2e4793ebaa..0f10c846d7d 100644 --- a/test/sendable/builtins/Array/prototype/filter/create-species-undef.js +++ b/test/sendable/builtins/Array/prototype/filter/create-species-undef.js @@ -17,20 +17,6 @@ esid: sec-array.prototype.filter description: > An undefined value for the @@species constructor triggers the creation of an Array exotic object -info: | - [...] - 5. Let A be ? ArraySpeciesCreate(O, 0). - [...] - - 9.4.2.3 ArraySpeciesCreate - - [...] - 5. Let C be ? Get(originalArray, "constructor"). - [...] - 7. If Type(C) is Object, then - a. Let C be ? Get(C, @@species). - b. If C is null, let C be undefined. - 8. If C is undefined, return ? ArrayCreate(length). features: [Symbol.species] ---*/ diff --git a/test/sendable/builtins/Array/prototype/filter/create-species.js b/test/sendable/builtins/Array/prototype/filter/create-species.js index 09f4afd2fa0..da4e1ba51a6 100644 --- a/test/sendable/builtins/Array/prototype/filter/create-species.js +++ b/test/sendable/builtins/Array/prototype/filter/create-species.js @@ -15,21 +15,6 @@ /*--- esid: sec-array.prototype.filter description: Species constructor is used to create a new instance -info: | - [...] - 5. Let A be ? ArraySpeciesCreate(O, 0). - [...] - - 9.4.2.3 ArraySpeciesCreate - - [...] - 5. Let C be ? Get(originalArray, "constructor"). - [...] - 7. If Type(C) is Object, then - a. Let C be ? Get(C, @@species). - b. If C is null, let C be undefined. - [...] - 10. Return ? Construct(C, « length »). features: [Symbol.species] ---*/ diff --git a/test/sendable/builtins/Array/prototype/filter/target-array-non-extensible.js b/test/sendable/builtins/Array/prototype/filter/target-array-non-extensible.js index ad278b77399..9afd9853851 100644 --- a/test/sendable/builtins/Array/prototype/filter/target-array-non-extensible.js +++ b/test/sendable/builtins/Array/prototype/filter/target-array-non-extensible.js @@ -17,15 +17,6 @@ esid: sec-array.prototype.filter description: > TypeError is thrown if CreateDataProperty fails. (result object is non-extensible) -info: | - Array.prototype.filter ( callbackfn [ , thisArg ] ) - 7. Repeat, while k < len - c. If kPresent is true, then - iii. If selected is true, then - 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue). - CreateDataPropertyOrThrow ( O, P, V ) - 3. Let success be ? CreateDataProperty(O, P, V). - 4. If success is false, throw a TypeError exception. features: [Symbol.species] ---*/ diff --git a/test/sendable/builtins/Array/prototype/filter/target-array-with-non-configurable-property.js b/test/sendable/builtins/Array/prototype/filter/target-array-with-non-configurable-property.js index df904499c83..599ec4a0381 100644 --- a/test/sendable/builtins/Array/prototype/filter/target-array-with-non-configurable-property.js +++ b/test/sendable/builtins/Array/prototype/filter/target-array-with-non-configurable-property.js @@ -17,15 +17,6 @@ esid: sec-array.prototype.filter description: > TypeError is thrown if CreateDataProperty fails. (result object's "0" is non-configurable) -info: | - Array.prototype.filter ( callbackfn [ , thisArg ] ) - 7. Repeat, while k < len - c. If kPresent is true, then - iii. If selected is true, then - 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue). - CreateDataPropertyOrThrow ( O, P, V ) - 3. Let success be ? CreateDataProperty(O, P, V). - 4. If success is false, throw a TypeError exception. features: [Symbol.species] ---*/ diff --git a/test/sendable/builtins/Array/prototype/filter/target-array-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/filter/target-array-with-non-writable-property.js index b4e268a2bcf..6b00e245431 100644 --- a/test/sendable/builtins/Array/prototype/filter/target-array-with-non-writable-property.js +++ b/test/sendable/builtins/Array/prototype/filter/target-array-with-non-writable-property.js @@ -16,12 +16,6 @@ esid: sec-array.prototype.filter description: > Non-writable properties are overwritten by CreateDataPropertyOrThrow. -info: | - 22.1.3.7 Array.prototype.filter ( callbackfn [ , thisArg ] ) - 8. Repeat, while k < len - c. If kPresent is true, then - iii. If selected is true, then - 1. Perform ? CreateDataPropertyOrThrow(A, ! ToString(to), kValue). features: [Symbol.species] includes: [propertyHelper.js] ---*/ -- Gitee From d1164e789ac774f0efa857bfce0c085ba57cfd1b Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 23 Dec 2024 16:05:19 +0800 Subject: [PATCH 33/93] add license Signed-off-by: zhuzhihui7 --- .../ArrayBuffer/Symbol.species/length.js | 45 +++++++++++++++++++ .../Symbol.species/return-value.js | 27 +++++++++++ .../Symbol.species/symbol-species-name.js | 36 +++++++++++++++ .../Symbol.species/symbol-species.js | 33 ++++++++++++++ .../builtins/ArrayBuffer/allocation-limit.js | 16 ++++++- .../data-allocation-after-object-creation.js | 16 ++++++- .../builtins/ArrayBuffer/init-zero.js | 17 ++++++- .../builtins/ArrayBuffer/is-a-constructor.js | 16 ++++++- .../isView/arg-has-no-viewedarraybuffer.js | 16 ++++++- .../ArrayBuffer/isView/arg-is-arraybuffer.js | 16 ++++++- .../isView/arg-is-dataview-buffer.js | 16 ++++++- .../isView/arg-is-dataview-constructor.js | 16 ++++++- .../arg-is-dataview-subclass-instance.js | 16 ++++++- .../ArrayBuffer/isView/arg-is-dataview.js | 16 ++++++- .../ArrayBuffer/isView/arg-is-not-object.js | 16 ++++++- .../isView/arg-is-typedarray-buffer.js | 16 ++++++- .../isView/arg-is-typedarray-constructor.js | 16 ++++++- .../arg-is-typedarray-subclass-instance.js | 16 ++++++- .../ArrayBuffer/isView/arg-is-typedarray.js | 16 ++++++- .../ArrayBuffer/isView/invoked-as-a-fn.js | 16 ++++++- .../builtins/ArrayBuffer/isView/length.js | 16 ++++++- .../builtins/ArrayBuffer/isView/name.js | 16 ++++++- .../builtins/ArrayBuffer/isView/no-arg.js | 16 ++++++- .../ArrayBuffer/isView/not-a-constructor.js | 16 ++++++- .../builtins/ArrayBuffer/isView/prop-desc.js | 17 ++++++- .../builtins/ArrayBuffer/length-is-absent.js | 16 ++++++- .../ArrayBuffer/length-is-too-large-throws.js | 16 ++++++- test/sendable/builtins/ArrayBuffer/length.js | 16 ++++++- test/sendable/builtins/ArrayBuffer/name.js | 24 +++++++--- .../ArrayBuffer/negative-length-throws.js | 16 ++++++- .../newtarget-prototype-is-not-object.js | 16 ++++++- .../options-maxbytelength-allocation-limit.js | 16 ++++++- ...elength-compared-before-object-creation.js | 16 ++++++- ...h-data-allocation-after-object-creation.js | 16 ++++++- .../options-maxbytelength-diminuitive.js | 17 ++++++- .../options-maxbytelength-excessive.js | 17 ++++++- .../options-maxbytelength-negative.js | 17 ++++++- .../options-maxbytelength-object.js | 17 ++++++- .../options-maxbytelength-poisoned.js | 17 ++++++- .../options-maxbytelength-undefined.js | 17 ++++++- .../ArrayBuffer/options-non-object.js | 17 ++++++- .../builtins/ArrayBuffer/prop-desc.js | 16 ++++++- .../ArrayBuffer/proto-from-ctor-realm.js | 17 ++++++- .../ArrayBuffer/prototype-from-newtarget.js | 16 ++++++- .../return-abrupt-from-length-symbol.js | 16 ++++++- .../ArrayBuffer/return-abrupt-from-length.js | 16 ++++++- .../builtins/ArrayBuffer/toindex-length.js | 16 ++++++- .../ArrayBuffer/undefined-newtarget-throws.js | 16 ++++++- .../builtins/ArrayBuffer/zero-length.js | 16 ++++++- 49 files changed, 785 insertions(+), 94 deletions(-) create mode 100644 test/sendable/builtins/ArrayBuffer/Symbol.species/length.js create mode 100644 test/sendable/builtins/ArrayBuffer/Symbol.species/return-value.js create mode 100644 test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species-name.js create mode 100644 test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species.js diff --git a/test/sendable/builtins/ArrayBuffer/Symbol.species/length.js b/test/sendable/builtins/ArrayBuffer/Symbol.species/length.js new file mode 100644 index 00000000000..eea042a45ff --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/Symbol.species/length.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-get-sendableSendableArrayBuffer-@@species +description: > + get SendableArrayBuffer [ @@species ].length is 0. +info: | + get SendableArrayBuffer [ @@species ] + + 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] +features: [Symbol.species] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArrayBuffer, Symbol.species); + +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/Symbol.species/return-value.js b/test/sendable/builtins/ArrayBuffer/Symbol.species/return-value.js new file mode 100644 index 00000000000..37fc32e7f34 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/Symbol.species/return-value.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-get-sendableSendableArrayBuffer-@@species +description: Return value of @@species accessor method +info: | + 1. Return the this value. +features: [Symbol.species] +---*/ + +var thisVal = {}; +var accessor = Object.getOwnPropertyDescriptor(SendableArrayBuffer, Symbol.species).get; + +assert.sameValue(accessor.call(thisVal), thisVal); diff --git a/test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species-name.js b/test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species-name.js new file mode 100644 index 00000000000..87786437641 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species-name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-get-sendableSendableArrayBuffer-@@species +description: > + SendableArrayBuffer[Symbol.species] accessor property get name +info: | + 24.1.3.3 get SendableArrayBuffer [ @@species ] + + ... + The value of the name property of this function is "get [Symbol.species]". +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(SendableArrayBuffer, Symbol.species); + +verifyProperty(descriptor.get, "name", { + value: "get [Symbol.species]", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species.js b/test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species.js new file mode 100644 index 00000000000..98abbcdb310 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +info: | + SendableArrayBuffer has a property at `Symbol.species` +esid: sec-get-sendableSendableArrayBuffer-@@species +author: Sam Mikes +description: SendableArrayBuffer[Symbol.species] exists per spec +features: [SendableArrayBuffer, Symbol.species] +includes: [propertyHelper.js] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArrayBuffer, Symbol.species); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, 'function'); + +verifyNotWritable(SendableArrayBuffer, Symbol.species, Symbol.species); +verifyNotEnumerable(SendableArrayBuffer, Symbol.species); +verifyConfigurable(SendableArrayBuffer, Symbol.species); diff --git a/test/sendable/builtins/ArrayBuffer/allocation-limit.js b/test/sendable/builtins/ArrayBuffer/allocation-limit.js index 83d5962f3ac..cc37c2c63d4 100644 --- a/test/sendable/builtins/ArrayBuffer/allocation-limit.js +++ b/test/sendable/builtins/ArrayBuffer/allocation-limit.js @@ -1,5 +1,17 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length diff --git a/test/sendable/builtins/ArrayBuffer/data-allocation-after-object-creation.js b/test/sendable/builtins/ArrayBuffer/data-allocation-after-object-creation.js index 96c8076a01c..750689dd768 100644 --- a/test/sendable/builtins/ArrayBuffer/data-allocation-after-object-creation.js +++ b/test/sendable/builtins/ArrayBuffer/data-allocation-after-object-creation.js @@ -1,5 +1,17 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length diff --git a/test/sendable/builtins/ArrayBuffer/init-zero.js b/test/sendable/builtins/ArrayBuffer/init-zero.js index 9c5a4431ce5..b438ee281b4 100644 --- a/test/sendable/builtins/ArrayBuffer/init-zero.js +++ b/test/sendable/builtins/ArrayBuffer/init-zero.js @@ -1,5 +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. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*--- esid: sec-sendableArrayBuffer-length description: All bytes are initialized to zero diff --git a/test/sendable/builtins/ArrayBuffer/is-a-constructor.js b/test/sendable/builtins/ArrayBuffer/is-a-constructor.js index bec4c463ac5..54e58168178 100644 --- a/test/sendable/builtins/ArrayBuffer/is-a-constructor.js +++ b/test/sendable/builtins/ArrayBuffer/is-a-constructor.js @@ -1,5 +1,17 @@ -// Copyright (C) 2020 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-ecmascript-standard-built-in-objects diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-has-no-viewedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/isView/arg-has-no-viewedarraybuffer.js index 5208a7764fa..e8c9701fde8 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/arg-has-no-viewedarraybuffer.js +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-has-no-viewedarraybuffer.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-arraybuffer.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-arraybuffer.js index 05888fbf129..50364c13232 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/arg-is-arraybuffer.js +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-arraybuffer.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-buffer.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-buffer.js index 7e44d26d7ef..67c2dfc3f18 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-buffer.js +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-buffer.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-constructor.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-constructor.js index ff85fc8e9d9..5da2f888205 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-constructor.js +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-constructor.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-subclass-instance.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-subclass-instance.js index a475ee80928..a53fa6340f2 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-subclass-instance.js +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview-subclass-instance.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview.js index afb37c37272..8973f949cdd 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview.js +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-dataview.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-not-object.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-not-object.js index 2b4fca19311..bfd59a06791 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/arg-is-not-object.js +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-not-object.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-buffer.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-buffer.js index 9986303e512..10cb5633daf 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-buffer.js +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-buffer.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-constructor.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-constructor.js index eaa7a27d06f..4bdcc737abf 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-constructor.js +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-constructor.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js index 2b710a8ce23..67e9b19bae2 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray-subclass-instance.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray.js b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray.js index b7871704ab2..16818663e81 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray.js +++ b/test/sendable/builtins/ArrayBuffer/isView/arg-is-typedarray.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/invoked-as-a-fn.js b/test/sendable/builtins/ArrayBuffer/isView/invoked-as-a-fn.js index aa4b20b90cf..110bad9f2c2 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/invoked-as-a-fn.js +++ b/test/sendable/builtins/ArrayBuffer/isView/invoked-as-a-fn.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/length.js b/test/sendable/builtins/ArrayBuffer/isView/length.js index 29798203aa9..84efc9d7891 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/length.js +++ b/test/sendable/builtins/ArrayBuffer/isView/length.js @@ -1,5 +1,17 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/name.js b/test/sendable/builtins/ArrayBuffer/isView/name.js index 435e7b3ecdc..32076c55815 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/name.js +++ b/test/sendable/builtins/ArrayBuffer/isView/name.js @@ -1,5 +1,17 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/no-arg.js b/test/sendable/builtins/ArrayBuffer/isView/no-arg.js index e5ad217fa33..71f6604cca4 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/no-arg.js +++ b/test/sendable/builtins/ArrayBuffer/isView/no-arg.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/isView/not-a-constructor.js b/test/sendable/builtins/ArrayBuffer/isView/not-a-constructor.js index 479578f4bba..fbec420fedf 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/not-a-constructor.js +++ b/test/sendable/builtins/ArrayBuffer/isView/not-a-constructor.js @@ -1,5 +1,17 @@ -// Copyright (C) 2020 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-ecmascript-standard-built-in-objects diff --git a/test/sendable/builtins/ArrayBuffer/isView/prop-desc.js b/test/sendable/builtins/ArrayBuffer/isView/prop-desc.js index 888330dc902..04732697884 100644 --- a/test/sendable/builtins/ArrayBuffer/isView/prop-desc.js +++ b/test/sendable/builtins/ArrayBuffer/isView/prop-desc.js @@ -1,5 +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. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*--- esid: sec-sendableArrayBuffer.isview diff --git a/test/sendable/builtins/ArrayBuffer/length-is-absent.js b/test/sendable/builtins/ArrayBuffer/length-is-absent.js index c34dff3e66e..0ea1c6250dd 100644 --- a/test/sendable/builtins/ArrayBuffer/length-is-absent.js +++ b/test/sendable/builtins/ArrayBuffer/length-is-absent.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 Project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length diff --git a/test/sendable/builtins/ArrayBuffer/length-is-too-large-throws.js b/test/sendable/builtins/ArrayBuffer/length-is-too-large-throws.js index 9fba5d505ff..06015f94846 100644 --- a/test/sendable/builtins/ArrayBuffer/length-is-too-large-throws.js +++ b/test/sendable/builtins/ArrayBuffer/length-is-too-large-throws.js @@ -1,5 +1,17 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length diff --git a/test/sendable/builtins/ArrayBuffer/length.js b/test/sendable/builtins/ArrayBuffer/length.js index a53ff2323a4..14013edd06d 100644 --- a/test/sendable/builtins/ArrayBuffer/length.js +++ b/test/sendable/builtins/ArrayBuffer/length.js @@ -1,5 +1,17 @@ -// Copyright (C) 2017 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-constructor diff --git a/test/sendable/builtins/ArrayBuffer/name.js b/test/sendable/builtins/ArrayBuffer/name.js index 6552d7a52b5..ec0aa54d5fa 100644 --- a/test/sendable/builtins/ArrayBuffer/name.js +++ b/test/sendable/builtins/ArrayBuffer/name.js @@ -1,10 +1,22 @@ -// Copyright (C) 2017 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- -esid: sec-sendableSendableArrayBuffer-constructor +esid: sec-sendableArrayBuffer-constructor description: > - SendableSendableArrayBuffer.name is "SendableSendableArrayBuffer". + SendableArrayBuffer.name is "SendableArrayBuffer". info: | 17 ECMAScript Standard Built-in Objects: @@ -19,9 +31,9 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(SendableSendableArrayBuffer.name, "SendableSendableArrayBuffer"); +assert.sameValue(SendableArrayBuffer.name, "SendableArrayBuffer"); -verifyProperty(SendableSendableArrayBuffer, "name", { +verifyProperty(SendableArrayBuffer, "name", { writable: false, enumerable: false, configurable: true, diff --git a/test/sendable/builtins/ArrayBuffer/negative-length-throws.js b/test/sendable/builtins/ArrayBuffer/negative-length-throws.js index a59493a801f..f95674c1a84 100644 --- a/test/sendable/builtins/ArrayBuffer/negative-length-throws.js +++ b/test/sendable/builtins/ArrayBuffer/negative-length-throws.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 Project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length diff --git a/test/sendable/builtins/ArrayBuffer/newtarget-prototype-is-not-object.js b/test/sendable/builtins/ArrayBuffer/newtarget-prototype-is-not-object.js index 77ab90d0f73..d9e99b3c692 100644 --- a/test/sendable/builtins/ArrayBuffer/newtarget-prototype-is-not-object.js +++ b/test/sendable/builtins/ArrayBuffer/newtarget-prototype-is-not-object.js @@ -1,5 +1,17 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-allocation-limit.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-allocation-limit.js index 22cee7db010..4e7460ab00f 100644 --- a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-allocation-limit.js +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-allocation-limit.js @@ -1,5 +1,17 @@ -// Copyright (C) 2024 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js index 614641bd233..84889969cd9 100644 --- a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-compared-before-object-creation.js @@ -1,5 +1,17 @@ -// Copyright (C) 2024 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js index 38672b7cf4f..07f9079a926 100644 --- a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-data-allocation-after-object-creation.js @@ -1,5 +1,17 @@ -// Copyright (C) 2024 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-diminuitive.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-diminuitive.js index d1108351632..f6bbc7b1643 100644 --- a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-diminuitive.js +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-diminuitive.js @@ -1,5 +1,18 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*--- esid: sec-sendableArrayBuffer-constructor description: | diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-excessive.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-excessive.js index e988acc74e4..5f1a78c3610 100644 --- a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-excessive.js +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-excessive.js @@ -1,5 +1,18 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*--- esid: sec-sendableArrayBuffer-constructor description: | diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-negative.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-negative.js index 55907105b22..df8ced5c944 100644 --- a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-negative.js +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-negative.js @@ -1,5 +1,18 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*--- esid: sec-sendableArrayBuffer-constructor description: Invoked with an options object whose `maxByteLength` property is negative diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-object.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-object.js index fe4969cf993..3ea4da2f813 100644 --- a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-object.js +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-object.js @@ -1,5 +1,18 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*--- esid: sec-sendableArrayBuffer-constructor description: | diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-poisoned.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-poisoned.js index b0337e7e5b1..89a553bbbf5 100644 --- a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-poisoned.js +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-poisoned.js @@ -1,5 +1,18 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*--- esid: sec-sendableArrayBuffer-constructor description: Invoked with an options object whose `maxByteLength` property throws diff --git a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-undefined.js b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-undefined.js index fb1b8c82e49..4168ec66891 100644 --- a/test/sendable/builtins/ArrayBuffer/options-maxbytelength-undefined.js +++ b/test/sendable/builtins/ArrayBuffer/options-maxbytelength-undefined.js @@ -1,5 +1,18 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*--- esid: sec-sendableArrayBuffer-constructor description: Invoked with an options object whose `maxByteLength` property is undefined diff --git a/test/sendable/builtins/ArrayBuffer/options-non-object.js b/test/sendable/builtins/ArrayBuffer/options-non-object.js index 975dee7e68a..d7fb596bf9f 100644 --- a/test/sendable/builtins/ArrayBuffer/options-non-object.js +++ b/test/sendable/builtins/ArrayBuffer/options-non-object.js @@ -1,5 +1,18 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*--- esid: sec-sendableArrayBuffer-constructor description: Invoked with a non-object value for options diff --git a/test/sendable/builtins/ArrayBuffer/prop-desc.js b/test/sendable/builtins/ArrayBuffer/prop-desc.js index 0623ce3fc03..732d929ee3d 100644 --- a/test/sendable/builtins/ArrayBuffer/prop-desc.js +++ b/test/sendable/builtins/ArrayBuffer/prop-desc.js @@ -1,5 +1,17 @@ -// Copyright (C) 2017 Rick Waldron. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-constructor diff --git a/test/sendable/builtins/ArrayBuffer/proto-from-ctor-realm.js b/test/sendable/builtins/ArrayBuffer/proto-from-ctor-realm.js index f7acb5190c3..3e6bc798e80 100644 --- a/test/sendable/builtins/ArrayBuffer/proto-from-ctor-realm.js +++ b/test/sendable/builtins/ArrayBuffer/proto-from-ctor-realm.js @@ -1,5 +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. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + /*--- esid: sec-sendableArrayBuffer-length description: Default [[Prototype]] value derived from realm of the newTarget diff --git a/test/sendable/builtins/ArrayBuffer/prototype-from-newtarget.js b/test/sendable/builtins/ArrayBuffer/prototype-from-newtarget.js index bcbaa43c18f..8aea514f186 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype-from-newtarget.js +++ b/test/sendable/builtins/ArrayBuffer/prototype-from-newtarget.js @@ -1,5 +1,17 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length diff --git a/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length-symbol.js b/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length-symbol.js index 11be1d4bcf9..8bdf5a44a06 100644 --- a/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length-symbol.js +++ b/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length-symbol.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 Project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length diff --git a/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length.js b/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length.js index 55a6f68daf2..90a215c0268 100644 --- a/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length.js +++ b/test/sendable/builtins/ArrayBuffer/return-abrupt-from-length.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 Project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length diff --git a/test/sendable/builtins/ArrayBuffer/toindex-length.js b/test/sendable/builtins/ArrayBuffer/toindex-length.js index 1794e8da943..49d8e5a705b 100644 --- a/test/sendable/builtins/ArrayBuffer/toindex-length.js +++ b/test/sendable/builtins/ArrayBuffer/toindex-length.js @@ -1,5 +1,17 @@ -// Copyright (C) 2016 The V8 Project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length diff --git a/test/sendable/builtins/ArrayBuffer/undefined-newtarget-throws.js b/test/sendable/builtins/ArrayBuffer/undefined-newtarget-throws.js index e2738376e75..9a05e998901 100644 --- a/test/sendable/builtins/ArrayBuffer/undefined-newtarget-throws.js +++ b/test/sendable/builtins/ArrayBuffer/undefined-newtarget-throws.js @@ -1,5 +1,17 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length diff --git a/test/sendable/builtins/ArrayBuffer/zero-length.js b/test/sendable/builtins/ArrayBuffer/zero-length.js index ccd71e026e4..093bdc9d2bc 100644 --- a/test/sendable/builtins/ArrayBuffer/zero-length.js +++ b/test/sendable/builtins/ArrayBuffer/zero-length.js @@ -1,5 +1,17 @@ -// Copyright (C) 2015 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ /*--- esid: sec-sendableArrayBuffer-length -- Gitee From 14a18f4baf1356f5beb5046ad9bfd6d8d033a9df Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 23 Dec 2024 17:13:17 +0800 Subject: [PATCH 34/93] add new case array-find Signed-off-by: zhuzhihui7 --- .../find/array-altered-during-loop.js | 44 ++++++++ .../Array/prototype/find/call-with-boolean.js | 29 +++++ .../find/callbackfn-resize-arraybuffer.js | 74 +++++++++++++ .../builtins/Array/prototype/find/length.js | 28 +++++ .../builtins/Array/prototype/find/name.js | 30 ++++++ .../Array/prototype/find/not-a-constructor.js | 35 ++++++ .../find/predicate-call-parameters.js | 41 +++++++ .../find/predicate-call-this-non-strict.js | 30 ++++++ .../find/predicate-call-this-strict.js | 30 ++++++ ...redicate-called-for-each-array-property.js | 26 +++++ .../find/predicate-is-not-callable-throws.js | 47 ++++++++ .../predicate-not-called-on-empty-array.js | 28 +++++ .../Array/prototype/find/prop-desc.js | 32 ++++++ .../resizable-buffer-grow-mid-iteration.js | 94 ++++++++++++++++ .../resizable-buffer-shrink-mid-iteration.js | 100 ++++++++++++++++++ .../Array/prototype/find/resizable-buffer.js | 88 +++++++++++++++ .../find/return-abrupt-from-predicate-call.js | 26 +++++ .../find/return-abrupt-from-property.js | 31 ++++++ ...eturn-abrupt-from-this-length-as-symbol.js | 27 +++++ .../find/return-abrupt-from-this-length.js | 40 +++++++ .../prototype/find/return-abrupt-from-this.js | 31 ++++++ ...rn-found-value-predicate-result-is-true.js | 56 ++++++++++ ...efined-if-predicate-returns-false-value.js | 49 +++++++++ 23 files changed, 1016 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/find/array-altered-during-loop.js create mode 100644 test/sendable/builtins/Array/prototype/find/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/find/callbackfn-resize-arraybuffer.js create mode 100644 test/sendable/builtins/Array/prototype/find/length.js create mode 100644 test/sendable/builtins/Array/prototype/find/name.js create mode 100644 test/sendable/builtins/Array/prototype/find/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/find/predicate-call-parameters.js create mode 100644 test/sendable/builtins/Array/prototype/find/predicate-call-this-non-strict.js create mode 100644 test/sendable/builtins/Array/prototype/find/predicate-call-this-strict.js create mode 100644 test/sendable/builtins/Array/prototype/find/predicate-called-for-each-array-property.js create mode 100644 test/sendable/builtins/Array/prototype/find/predicate-is-not-callable-throws.js create mode 100644 test/sendable/builtins/Array/prototype/find/predicate-not-called-on-empty-array.js create mode 100644 test/sendable/builtins/Array/prototype/find/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/find/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/find/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/find/resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/find/return-abrupt-from-predicate-call.js create mode 100644 test/sendable/builtins/Array/prototype/find/return-abrupt-from-property.js create mode 100644 test/sendable/builtins/Array/prototype/find/return-abrupt-from-this-length-as-symbol.js create mode 100644 test/sendable/builtins/Array/prototype/find/return-abrupt-from-this-length.js create mode 100644 test/sendable/builtins/Array/prototype/find/return-abrupt-from-this.js create mode 100644 test/sendable/builtins/Array/prototype/find/return-found-value-predicate-result-is-true.js create mode 100644 test/sendable/builtins/Array/prototype/find/return-undefined-if-predicate-returns-false-value.js diff --git a/test/sendable/builtins/Array/prototype/find/array-altered-during-loop.js b/test/sendable/builtins/Array/prototype/find/array-altered-during-loop.js new file mode 100644 index 00000000000..50f3a1c090a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/array-altered-during-loop.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + The range of elements processed is set before the first call to `predicate`. +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var results = []; +arr.find(function(kValue) { + if (results.length === 0) { + arr.splice(1, 1); + } + results.push(kValue); +}); +assert.sameValue(results.length, 3, 'predicate called three times'); +assert.sameValue(results[0], 'Shoes'); +assert.sameValue(results[1], 'Bike'); +assert.sameValue(results[2], undefined); +results = []; +arr = ['Skateboard', 'Barefoot']; +arr.find(function(kValue) { + if (results.length === 0) { + arr.push('Motorcycle'); + arr[1] = 'Magic Carpet'; + } + results.push(kValue); +}); +assert.sameValue(results.length, 2, 'predicate called twice'); +assert.sameValue(results[0], 'Skateboard'); +assert.sameValue(results[1], 'Magic Carpet'); diff --git a/test/sendable/builtins/Array/prototype/find/call-with-boolean.js b/test/sendable/builtins/Array/prototype/find/call-with-boolean.js new file mode 100644 index 00000000000..79d61ec3da4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/call-with-boolean.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: Array.prototype.find applied to boolean primitive +---*/ + +assert.sameValue( + SendableArray.prototype.find.call(true, () => {}), + undefined, + 'SendableArray.prototype.find.call(true, () => {}) must return undefined' +); +assert.sameValue( + SendableArray.prototype.find.call(false, () => {}), + undefined, + 'SendableArray.prototype.find.call(false, () => {}) must return undefined' +); diff --git a/test/sendable/builtins/Array/prototype/find/callbackfn-resize-arraybuffer.js b/test/sendable/builtins/Array/prototype/find/callbackfn-resize-arraybuffer.js new file mode 100644 index 00000000000..23810c950e4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/callbackfn-resize-arraybuffer.js @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var finalElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + elements = []; + indices = []; + arrays = []; + result = Array.prototype.find.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + finalElement = undefined; + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + finalElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)'); + assert.compareArray(indices, [0, 1, 2], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, undefined, 'result (shrink)'); + elements = []; + indices = []; + arrays = []; + result = Array.prototype.find.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, undefined, 'result (grow)'); +}); diff --git a/test/sendable/builtins/Array/prototype/find/length.js b/test/sendable/builtins/Array/prototype/find/length.js new file mode 100644 index 00000000000..8128b9adfe8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/length.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: Array.prototype.find.length value and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.prototype.find, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/find/name.js b/test/sendable/builtins/Array/prototype/find/name.js new file mode 100644 index 00000000000..95c75c34af1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/name.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + Array.prototype.find.name value and descriptor. +info: | + 22.1.3.8 Array.prototype.find ( predicate [ , thisArg ] ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.prototype.find, "name", { + value: "find", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/find/not-a-constructor.js b/test/sendable/builtins/Array/prototype/find/not-a-constructor.js new file mode 100644 index 00000000000..dc6a8486755 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/not-a-constructor.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.find 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(SendableArray.prototype.find), false, 'isConstructor(SendableArray.prototype.find) must return false'); +assert.throws(TypeError, () => { + new SendableArray.prototype.find(() => {}); +}); + diff --git a/test/sendable/builtins/Array/prototype/find/predicate-call-parameters.js b/test/sendable/builtins/Array/prototype/find/predicate-call-parameters.js new file mode 100644 index 00000000000..9ee90e11d9c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/predicate-call-parameters.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +---*/ + +var arr = ['Mike', 'Rick', 'Leo']; +var results = []; +arr.find(function(kValue, k, O) { + results.push(arguments); +}); +assert.sameValue(results.length, 3); +var result = results[0]; +assert.sameValue(result[0], 'Mike'); +assert.sameValue(result[1], 0); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); +result = results[1]; +assert.sameValue(result[0], 'Rick'); +assert.sameValue(result[1], 1); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); +result = results[2]; +assert.sameValue(result[0], 'Leo'); +assert.sameValue(result[1], 2); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); diff --git a/test/sendable/builtins/Array/prototype/find/predicate-call-this-non-strict.js b/test/sendable/builtins/Array/prototype/find/predicate-call-this-non-strict.js new file mode 100644 index 00000000000..0de5019cc89 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/predicate-call-this-non-strict.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +---*/ + +var result; +[1].find(function(kValue, k, O) { + result = this; +}); +assert.sameValue(result, this); +var o = {}; +[1].find(function() { + result = this; +}, o); +assert.sameValue(result, o); diff --git a/test/sendable/builtins/Array/prototype/find/predicate-call-this-strict.js b/test/sendable/builtins/Array/prototype/find/predicate-call-this-strict.js new file mode 100644 index 00000000000..a6465dede9a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/predicate-call-this-strict.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +---*/ + +var result; +[1].find(function(kValue, k, O) { + result = this; +}); +assert.sameValue(result, undefined); +var o = {}; +[1].find(function() { + result = this; +}, o); +assert.sameValue(result, o); diff --git a/test/sendable/builtins/Array/prototype/find/predicate-called-for-each-array-property.js b/test/sendable/builtins/Array/prototype/find/predicate-called-for-each-array-property.js new file mode 100644 index 00000000000..f847b926f6b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/predicate-called-for-each-array-property.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + Predicate is called for each array property. +---*/ + +var arr = [undefined, , , 'foo']; +var called = 0; +arr.find(function() { + called++; +}); +assert.sameValue(called, 4); diff --git a/test/sendable/builtins/Array/prototype/find/predicate-is-not-callable-throws.js b/test/sendable/builtins/Array/prototype/find/predicate-is-not-callable-throws.js new file mode 100644 index 00000000000..605e7075a4f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/predicate-is-not-callable-throws.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + Throws a TypeError exception if predicate is not callable. +---*/ + +assert.throws(TypeError, function() { + [].find({}); +}); +assert.throws(TypeError, function() { + [].find(null); +}); +assert.throws(TypeError, function() { + [].find(undefined); +}); +assert.throws(TypeError, function() { + [].find(true); +}); +assert.throws(TypeError, function() { + [].find(1); +}); +assert.throws(TypeError, function() { + [].find(''); +}); +assert.throws(TypeError, function() { + [].find(1); +}); +assert.throws(TypeError, function() { + [].find([]); +}); +assert.throws(TypeError, function() { + [].find(/./); +}); diff --git a/test/sendable/builtins/Array/prototype/find/predicate-not-called-on-empty-array.js b/test/sendable/builtins/Array/prototype/find/predicate-not-called-on-empty-array.js new file mode 100644 index 00000000000..88bd9a356d7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/predicate-not-called-on-empty-array.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + Predicate is only called if this.length is > 0. +---*/ + +var called = false; +var predicate = function() { + called = true; + return true; +}; +var result = [].find(predicate); +assert.sameValue(called, false, '[].find(predicate) does not call predicate'); +assert.sameValue(result, undefined, '[].find(predicate) returned undefined'); diff --git a/test/sendable/builtins/Array/prototype/find/prop-desc.js b/test/sendable/builtins/Array/prototype/find/prop-desc.js new file mode 100644 index 00000000000..de33068e738 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: Property type and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableArray.prototype.find, + 'function', + '`typeof SendableArray.prototype.find` is `function`' +); +verifyProperty(SendableArray.prototype, "find", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/find/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/Array/prototype/find/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..873acec4fdf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.find +description: > + Array.p.find behaves correctly when receiver is backed by resizable + buffer that is grown mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.find.call(fixedLength, ResizeMidIteration), undefined); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.find.call(fixedLengthWithOffset, ResizeMidIteration), undefined); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.find.call(lengthTracking, ResizeMidIteration), undefined); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.find.call(lengthTrackingWithOffset, ResizeMidIteration), undefined); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/find/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/Array/prototype/find/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..38b891c3671 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.find +description: > + Array.p.find behaves correctly when receiver is backed by resizable + buffer that is shrunk mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function ArrayFindHelper(ta, p) { + return SendableArray.prototype.find.call(ta, p); +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + const values = []; + const resizeAfter = 2; + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + function CollectResize(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; + } + assert.sameValue(ArrayFindHelper(fixedLength, CollectResize), undefined); + assert.compareArray(values, [ + 0, + 2, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const values = []; + const resizeAfter = 1; + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + function CollectResize(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; + } + assert.sameValue(ArrayFindHelper(fixedLengthWithOffset, CollectResize), undefined); + assert.compareArray(values, [ + 4, + undefined + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + const values = []; + const resizeAfter = 2; + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + function CollectResize(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; + } + assert.sameValue(ArrayFindHelper(lengthTracking, CollectResize), undefined); + assert.compareArray(values, [ + 0, + 2, + 4, + undefined + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const values = []; + const resizeAfter = 1; + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + function CollectResize(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; + } + assert.sameValue(ArrayFindHelper(lengthTrackingWithOffset, CollectResize), undefined); + assert.compareArray(values, [ + 4, + undefined + ]); +} diff --git a/test/sendable/builtins/Array/prototype/find/resizable-buffer.js b/test/sendable/builtins/Array/prototype/find/resizable-buffer.js new file mode 100644 index 00000000000..6e42560ecb7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/resizable-buffer.js @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.find +description: > + Array.p.find behaves correctly when receiver is backed by resizable + buffer +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + function isTwoOrFour(n) { + return n == 2 || n == 4; + } + assert.sameValue(Number(SendableArray.prototype.find.call(fixedLength, isTwoOrFour)), 2); + assert.sameValue(Number(SendableArray.prototype.find.call(fixedLengthWithOffset, isTwoOrFour)), 4); + assert.sameValue(Number(SendableArray.prototype.find.call(lengthTracking, isTwoOrFour)), 2); + assert.sameValue(Number(SendableArray.prototype.find.call(lengthTrackingWithOffset, isTwoOrFour)), 4); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.sameValue(SendableArray.prototype.find.call(fixedLength, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.find.call(fixedLengthWithOffset, isTwoOrFour), undefined); + assert.sameValue(Number(SendableArray.prototype.find.call(lengthTracking, isTwoOrFour)), 2); + assert.sameValue(Number(SendableArray.prototype.find.call(lengthTrackingWithOffset, isTwoOrFour)), 4); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.sameValue(SendableArray.prototype.find.call(fixedLength, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.find.call(fixedLengthWithOffset, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.find.call(lengthTrackingWithOffset, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.find.call(lengthTracking, isTwoOrFour), undefined); + // Shrink to zero. + rab.resize(0); + assert.sameValue(SendableArray.prototype.find.call(fixedLength, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.find.call(fixedLengthWithOffset, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.find.call(lengthTrackingWithOffset, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.find.call(lengthTracking, isTwoOrFour), undefined); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 0); + } + taWrite[4] = MayNeedBigInt(taWrite, 2); + taWrite[5] = MayNeedBigInt(taWrite, 4); + // Orig. array: [0, 0, 0, 0, 2, 4] + // [0, 0, 0, 0] << fixedLength + // [0, 0] << fixedLengthWithOffset + // [0, 0, 0, 0, 2, 4, ...] << lengthTracking + // [0, 0, 2, 4, ...] << lengthTrackingWithOffset + assert.sameValue(SendableArray.prototype.find.call(fixedLength, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.find.call(fixedLengthWithOffset, isTwoOrFour), undefined); + assert.sameValue(Number(SendableArray.prototype.find.call(lengthTracking, isTwoOrFour)), 2); + assert.sameValue(Number(SendableArray.prototype.find.call(lengthTrackingWithOffset, isTwoOrFour)), 2); +} diff --git a/test/sendable/builtins/Array/prototype/find/return-abrupt-from-predicate-call.js b/test/sendable/builtins/Array/prototype/find/return-abrupt-from-predicate-call.js new file mode 100644 index 00000000000..44051819e7b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/return-abrupt-from-predicate-call.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + Return abrupt from predicate call. +---*/ + +var predicate = function() { + throw new Test262Error(); +}; +assert.throws(Test262Error, function() { + [1].find(predicate); +}); diff --git a/test/sendable/builtins/Array/prototype/find/return-abrupt-from-property.js b/test/sendable/builtins/Array/prototype/find/return-abrupt-from-property.js new file mode 100644 index 00000000000..f5964bcb25f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/return-abrupt-from-property.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + Returns abrupt from getting property value from `this`. +---*/ + +var o = { + length: 1 +}; +Object.defineProperty(o, 0, { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + [].find.call(o, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/find/return-abrupt-from-this-length-as-symbol.js b/test/sendable/builtins/Array/prototype/find/return-abrupt-from-this-length-as-symbol.js new file mode 100644 index 00000000000..5cd7938a13a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/return-abrupt-from-this-length-as-symbol.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + Return abrupt from ToLength(Get(O, "length")) where length is a Symbol. +---*/ + +var o = {}; + +o.length = Symbol(1); +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + [].find.call(o, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/find/return-abrupt-from-this-length.js b/test/sendable/builtins/Array/prototype/find/return-abrupt-from-this-length.js new file mode 100644 index 00000000000..f0600a57f87 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/return-abrupt-from-this-length.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + Return abrupt from ToLength(Get(O, "length")). +---*/ + +var o1 = {}; +Object.defineProperty(o1, 'length', { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + [].find.call(o1); +}); +var o2 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; +assert.throws(Test262Error, function() { + [].find.call(o2); +}); diff --git a/test/sendable/builtins/Array/prototype/find/return-abrupt-from-this.js b/test/sendable/builtins/Array/prototype/find/return-abrupt-from-this.js new file mode 100644 index 00000000000..fed39282784 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/return-abrupt-from-this.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + Return abrupt from ToObject(this value). +info: | + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + SendableArray.prototype.find.call(undefined, function() {}); +}); +assert.throws(TypeError, function() { + SendableArray.prototype.find.call(null, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/find/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/Array/prototype/find/return-found-value-predicate-result-is-true.js new file mode 100644 index 00000000000..17c0495594a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/return-found-value-predicate-result-is-true.js @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + Return found value if predicate return a boolean true value. +features: [Symbol] +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; +var result = arr.find(function(val) { + called++; + return true; +}); +assert.sameValue(result, 'Shoes'); +assert.sameValue(called, 1, 'predicate was called once'); +called = 0; +result = arr.find(function(val) { + called++; + return val === 'Bike'; +}); +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, 'Bike'); +result = arr.find(function(val) { + return 'string'; +}); +assert.sameValue(result, 'Shoes', 'coerced string'); +result = arr.find(function(val) { + return {}; +}); +assert.sameValue(result, 'Shoes', 'coerced object'); +result = arr.find(function(val) { + return Symbol(''); +}); +assert.sameValue(result, 'Shoes', 'coerced Symbol'); +result = arr.find(function(val) { + return 1; +}); +assert.sameValue(result, 'Shoes', 'coerced number'); +result = arr.find(function(val) { + return -1; +}); +assert.sameValue(result, 'Shoes', 'coerced negative number'); diff --git a/test/sendable/builtins/Array/prototype/find/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/Array/prototype/find/return-undefined-if-predicate-returns-false-value.js new file mode 100644 index 00000000000..d35d512c6d9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/find/return-undefined-if-predicate-returns-false-value.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.find +description: > + Return undefined if predicate always returns a boolean false value. +features: [Symbol] +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; +var result = arr.find(function(val) { + called++; + return false; +}); +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, undefined); +result = arr.find(function(val) { + return ''; +}); +assert.sameValue(result, undefined, 'coerced string'); +result = arr.find(function(val) { + return undefined; +}); +assert.sameValue(result, undefined, 'coerced undefined'); +result = arr.find(function(val) { + return null; +}); +assert.sameValue(result, undefined, 'coerced null'); +result = arr.find(function(val) { + return 0; +}); +assert.sameValue(result, undefined, 'coerced 0'); +result = arr.find(function(val) { + return NaN; +}); +assert.sameValue(result, undefined, 'coerced NaN'); -- Gitee From 80d2b319d9dc84dd83672943caacff032f25498d Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 24 Dec 2024 15:04:33 +0800 Subject: [PATCH 35/93] arrarybuffer prptotype test Signed-off-by: zhuzhihui7 --- .../prototype/Symbol.toStringTag.js | 36 ++++++++ .../prototype/byteLength/detached-buffer.js | 32 +++++++ .../byteLength/invoked-as-accessor.js | 31 +++++++ .../prototype/byteLength/invoked-as-func.js | 35 +++++++ .../prototype/byteLength/length.js | 44 +++++++++ .../ArrayBuffer/prototype/byteLength/name.js | 38 ++++++++ .../prototype/byteLength/prop-desc.js | 35 +++++++ .../prototype/byteLength/return-bytelength.js | 31 +++++++ .../this-has-no-typedarrayname-internal.js | 52 +++++++++++ .../byteLength/this-is-not-object.js | 59 ++++++++++++ .../byteLength/this-is-sharedarraybuffer.js | 36 ++++++++ .../ArrayBuffer/prototype/constructor.js | 37 ++++++++ .../detached/detached-buffer-resizable.js | 49 ++++++++++ .../prototype/detached/detached-buffer.js | 37 ++++++++ .../prototype/detached/invoked-as-accessor.js | 32 +++++++ .../prototype/detached/invoked-as-func.js | 37 ++++++++ .../ArrayBuffer/prototype/detached/length.js | 46 ++++++++++ .../ArrayBuffer/prototype/detached/name.js | 37 ++++++++ .../prototype/detached/prop-desc.js | 38 ++++++++ .../this-has-no-arraybufferdata-internal.js | 52 +++++++++++ .../prototype/detached/this-is-not-object.js | 61 +++++++++++++ .../this-is-sharedarraybuffer-resizable.js | 40 ++++++++ .../detached/this-is-sharedarraybuffer.js | 40 ++++++++ .../maxByteLength/detached-buffer.js | 35 +++++++ .../maxByteLength/invoked-as-accessor.js | 30 ++++++ .../maxByteLength/invoked-as-func.js | 36 ++++++++ .../prototype/maxByteLength/length.js | 45 +++++++++ .../prototype/maxByteLength/name.js | 37 ++++++++ .../prototype/maxByteLength/prop-desc.js | 38 ++++++++ .../return-maxbytelength-non-resizable.js | 38 ++++++++ .../return-maxbytelength-resizable.js | 41 +++++++++ .../this-has-no-arraybufferdata-internal.js | 52 +++++++++++ .../maxByteLength/this-is-not-object.js | 61 +++++++++++++ .../this-is-sharedarraybuffer.js | 46 ++++++++++ .../prototype/resizable/detached-buffer.js | 47 ++++++++++ .../resizable/invoked-as-accessor.js | 30 ++++++ .../prototype/resizable/invoked-as-func.js | 36 ++++++++ .../ArrayBuffer/prototype/resizable/length.js | 45 +++++++++ .../ArrayBuffer/prototype/resizable/name.js | 37 ++++++++ .../prototype/resizable/prop-desc.js | 38 ++++++++ .../prototype/resizable/return-resizable.js | 42 +++++++++ .../this-has-no-arraybufferdata-internal.js | 52 +++++++++++ .../prototype/resizable/this-is-not-object.js | 61 +++++++++++++ .../resizable/this-is-sharedarraybuffer.js | 46 ++++++++++ .../resize/coerced-new-length-detach.js | 42 +++++++++ .../prototype/resize/descriptor.js | 35 +++++++ .../prototype/resize/extensible.js | 28 ++++++ .../ArrayBuffer/prototype/resize/length.js | 43 +++++++++ .../ArrayBuffer/prototype/resize/name.js | 40 ++++++++ .../prototype/resize/new-length-excessive.js | 38 ++++++++ .../prototype/resize/new-length-negative.js | 38 ++++++++ .../prototype/resize/new-length-non-number.js | 50 ++++++++++ .../prototype/resize/nonconstructor.js | 36 ++++++++ .../prototype/resize/resize-grow.js | 90 ++++++++++++++++++ .../resize/resize-same-size-zero-explicit.js | 91 +++++++++++++++++++ .../resize/resize-same-size-zero-implicit.js | 91 +++++++++++++++++++ .../prototype/resize/resize-same-size.js | 91 +++++++++++++++++++ .../resize/resize-shrink-zero-explicit.js | 90 ++++++++++++++++++ .../resize/resize-shrink-zero-implicit.js | 90 ++++++++++++++++++ .../prototype/resize/resize-shrink.js | 90 ++++++++++++++++++ .../prototype/resize/this-is-detached.js | 40 ++++++++ .../resize/this-is-not-arraybuffer-object.js | 41 +++++++++ .../prototype/resize/this-is-not-object.js | 57 ++++++++++++ ...his-is-not-resizable-arraybuffer-object.js | 51 +++++++++++ .../resize/this-is-sharedarraybuffer.js | 33 +++++++ .../context-is-not-arraybuffer-object.js | 35 +++++++ .../prototype/slice/context-is-not-object.js | 51 +++++++++++ .../ArrayBuffer/prototype/slice/descriptor.js | 34 +++++++ .../prototype/slice/end-default-if-absent.js | 33 +++++++ .../slice/end-default-if-undefined.js | 34 +++++++ .../prototype/slice/end-exceeds-length.js | 43 +++++++++ .../ArrayBuffer/prototype/slice/extensible.js | 28 ++++++ .../ArrayBuffer/prototype/slice/length.js | 42 +++++++++ .../ArrayBuffer/prototype/slice/name.js | 39 ++++++++ .../prototype/slice/negative-end.js | 43 +++++++++ .../prototype/slice/negative-start.js | 43 +++++++++ .../prototype/slice/nonconstructor.js | 36 ++++++++ .../prototype/slice/not-a-constructor.js | 45 +++++++++ .../prototype/slice/number-conversion.js | 49 ++++++++++ .../species-constructor-is-not-object.js | 57 ++++++++++++ .../slice/species-constructor-is-undefined.js | 40 ++++++++ .../slice/species-is-not-constructor.js | 51 +++++++++++ .../prototype/slice/species-is-not-object.js | 57 ++++++++++++ .../prototype/slice/species-is-null.js | 44 +++++++++ .../prototype/slice/species-is-undefined.js | 44 +++++++++ .../species-returns-larger-arraybuffer.js | 43 +++++++++ .../slice/species-returns-not-arraybuffer.js | 43 +++++++++ .../slice/species-returns-same-arraybuffer.js | 45 +++++++++ .../species-returns-smaller-arraybuffer.js | 44 +++++++++ .../ArrayBuffer/prototype/slice/species.js | 44 +++++++++ .../slice/start-default-if-absent.js | 32 +++++++ .../slice/start-default-if-undefined.js | 34 +++++++ .../prototype/slice/start-exceeds-end.js | 33 +++++++ .../prototype/slice/start-exceeds-length.js | 43 +++++++++ .../slice/this-is-sharedarraybuffer.js | 26 ++++++ .../slice/tointeger-conversion-end.js | 39 ++++++++ .../slice/tointeger-conversion-start.js | 39 ++++++++ .../prototype/transfer/descriptor.js | 35 +++++++ .../prototype/transfer/extensible.js | 28 ++++++ .../from-fixed-to-larger-no-resizable.js | 70 ++++++++++++++ .../transfer/from-fixed-to-larger.js | 68 ++++++++++++++ .../from-fixed-to-same-no-resizable.js | 71 +++++++++++++++ .../prototype/transfer/from-fixed-to-same.js | 69 ++++++++++++++ .../from-fixed-to-smaller-no-resizable.js | 68 ++++++++++++++ .../transfer/from-fixed-to-smaller.js | 66 ++++++++++++++ .../from-fixed-to-zero-no-resizable.js | 62 +++++++++++++ .../prototype/transfer/from-fixed-to-zero.js | 60 ++++++++++++ .../transfer/from-resizable-to-larger.js | 68 ++++++++++++++ .../transfer/from-resizable-to-same.js | 69 ++++++++++++++ .../transfer/from-resizable-to-smaller.js | 66 ++++++++++++++ .../transfer/from-resizable-to-zero.js | 60 ++++++++++++ .../ArrayBuffer/prototype/transfer/length.js | 43 +++++++++ .../ArrayBuffer/prototype/transfer/name.js | 40 ++++++++ .../transfer/new-length-excessive.js | 29 ++++++ .../transfer/new-length-non-number.js | 52 +++++++++++ .../prototype/transfer/nonconstructor.js | 36 ++++++++ .../prototype/transfer/this-is-detached.js | 40 ++++++++ .../this-is-not-arraybuffer-object.js | 41 +++++++++ .../prototype/transfer/this-is-not-object.js | 57 ++++++++++++ .../transfer/this-is-sharedarraybuffer.js | 33 +++++++ .../transferToFixedLength/descriptor.js | 36 ++++++++ .../transferToFixedLength/extensible.js | 28 ++++++ .../from-fixed-to-larger-no-resizable.js | 49 ++++++++++ .../from-fixed-to-larger.js | 47 ++++++++++ .../from-fixed-to-same-no-resizable.js | 50 ++++++++++ .../from-fixed-to-same.js | 48 ++++++++++ .../from-fixed-to-smaller-no-resizable.js | 47 ++++++++++ .../from-fixed-to-smaller.js | 45 +++++++++ .../from-fixed-to-zero-no-resizable.js | 41 +++++++++ .../from-fixed-to-zero.js | 39 ++++++++ .../from-resizable-to-larger.js | 47 ++++++++++ .../from-resizable-to-same.js | 48 ++++++++++ .../from-resizable-to-smaller.js | 45 +++++++++ .../from-resizable-to-zero.js | 39 ++++++++ .../prototype/transferToFixedLength/length.js | 43 +++++++++ .../prototype/transferToFixedLength/name.js | 40 ++++++++ .../new-length-excessive.js | 29 ++++++ .../new-length-non-number.js | 52 +++++++++++ .../transferToFixedLength/nonconstructor.js | 36 ++++++++ .../transferToFixedLength/this-is-detached.js | 40 ++++++++ .../this-is-not-arraybuffer-object.js | 41 +++++++++ .../this-is-not-object.js | 57 ++++++++++++ .../this-is-sharedarraybuffer.js | 33 +++++++ 143 files changed, 6557 insertions(+) create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/Symbol.toStringTag.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/byteLength/detached-buffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/byteLength/invoked-as-accessor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/byteLength/invoked-as-func.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/byteLength/length.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/byteLength/name.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/byteLength/prop-desc.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/byteLength/return-bytelength.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-has-no-typedarrayname-internal.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-is-not-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/constructor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer-resizable.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/detached/invoked-as-accessor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/detached/invoked-as-func.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/detached/length.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/detached/name.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/detached/prop-desc.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/detached/this-has-no-arraybufferdata-internal.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-not-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer-resizable.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/detached-buffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/invoked-as-accessor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/invoked-as-func.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/length.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/name.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/prop-desc.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-non-resizable.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-resizable.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-has-no-arraybufferdata-internal.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-is-not-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-is-sharedarraybuffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resizable/detached-buffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resizable/invoked-as-accessor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resizable/invoked-as-func.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resizable/length.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resizable/name.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resizable/prop-desc.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resizable/return-resizable.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resizable/this-has-no-arraybufferdata-internal.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resizable/this-is-not-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resizable/this-is-sharedarraybuffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/coerced-new-length-detach.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/descriptor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/extensible.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/length.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/name.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-excessive.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-negative.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-non-number.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/nonconstructor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/resize-grow.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-explicit.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-implicit.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-explicit.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-implicit.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-detached.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-not-arraybuffer-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-not-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-not-resizable-arraybuffer-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-sharedarraybuffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/context-is-not-arraybuffer-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/context-is-not-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/descriptor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/end-default-if-absent.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/end-default-if-undefined.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/end-exceeds-length.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/extensible.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/length.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/name.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/negative-end.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/negative-start.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/nonconstructor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/not-a-constructor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/number-conversion.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/species-constructor-is-not-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/species-constructor-is-undefined.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-not-constructor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-not-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-null.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-undefined.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-larger-arraybuffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-not-arraybuffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-same-arraybuffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-smaller-arraybuffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/species.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/start-default-if-absent.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/start-default-if-undefined.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/start-exceeds-end.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/start-exceeds-length.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/tointeger-conversion-end.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/slice/tointeger-conversion-start.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/descriptor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/extensible.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger-no-resizable.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same-no-resizable.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller-no-resizable.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero-no-resizable.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-larger.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-same.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-smaller.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-zero.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/length.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/name.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/new-length-excessive.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/new-length-non-number.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/nonconstructor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-detached.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-not-arraybuffer-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-not-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-sharedarraybuffer.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/descriptor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/extensible.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-larger-no-resizable.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-larger.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-same-no-resizable.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-same.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-smaller-no-resizable.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-smaller.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-zero-no-resizable.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-zero.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-larger.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-same.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-smaller.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-zero.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/length.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/name.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/new-length-excessive.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/new-length-non-number.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/nonconstructor.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-detached.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-not-arraybuffer-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-not-object.js create mode 100644 test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-sharedarraybuffer.js diff --git a/test/sendable/builtins/ArrayBuffer/prototype/Symbol.toStringTag.js b/test/sendable/builtins/ArrayBuffer/prototype/Symbol.toStringTag.js new file mode 100644 index 00000000000..0bd961069d9 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/Symbol.toStringTag.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype-@@tostringtag +description: > + `Symbol.toStringTag` property descriptor +info: | + The initial value of the @@toStringTag property is the String value + "SendableArrayBuffer". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.toStringTag] +---*/ + +assert.sameValue(SendableArrayBuffer.prototype[Symbol.toStringTag], 'SendableArrayBuffer'); + +verifyProperty(SendableArrayBuffer.prototype, Symbol.toStringTag, { + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/byteLength/detached-buffer.js b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/detached-buffer.js new file mode 100644 index 00000000000..535e262aeff --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/detached-buffer.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.bytelength +description: Returns 0 if the buffer is detached +info: | + get SendableArrayBuffer.prototype.byteLength + ... + If IsDetachedBuffer(buffer) is true, return 0. + ... +includes: [detachSendableArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality] +---*/ + +var ab = new SendableArrayBuffer(1); + +$DETACHBUFFER(ab); + +assert.sameValue(ab.byteLength, 0, 'The value of ab.byteLength is 0'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/byteLength/invoked-as-accessor.js b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/invoked-as-accessor.js new file mode 100644 index 00000000000..242b4d1fb23 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/invoked-as-accessor.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.bytelength +description: Requires this value to have a [[SendableArrayBufferData]] internal slot +info: | + 24.1.4.1 get SendableArrayBuffer.prototype.byteLength + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have an [[SendableArrayBufferData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.byteLength; +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/byteLength/invoked-as-func.js b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/invoked-as-func.js new file mode 100644 index 00000000000..d5d725c765e --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/invoked-as-func.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.bytelength +description: Throws a TypeError exception when invoked as a function +info: | + 24.1.4.1 get SendableArrayBuffer.prototype.byteLength + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have an [[SendableArrayBufferData]] internal slot, throw a TypeError + exception. + ... +---*/ + +var getter = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, "byteLength" +).get; + +assert.throws(TypeError, function() { + getter(); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/byteLength/length.js b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/length.js new file mode 100644 index 00000000000..7171ba3b550 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/length.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.bytelength +description: > + get SendableArrayBuffer.prototype.byteLength.length is 0. +info: | + get SendableArrayBuffer.prototype.byteLength + + 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] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArrayBuffer.prototype, "byteLength"); + +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/byteLength/name.js b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/name.js new file mode 100644 index 00000000000..78ca53f19c9 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/name.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.bytelength +description: > + get SendableArrayBuffer.prototype.byteLength + + 17 ECMAScript Standard Built-in Objects + + Functions that are specified as get or set accessor functions of built-in + properties have "get " or "set " prepended to the property name string. + +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, 'byteLength' +); + +verifyProperty(descriptor.get, "name", { + value: "get byteLength", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/byteLength/prop-desc.js b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/prop-desc.js new file mode 100644 index 00000000000..9f46f11a904 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/prop-desc.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.bytelength +description: > + "byteLength" property of SendableArrayBuffer.prototype +info: | + SendableArrayBuffer.prototype.byteLength is an accessor property whose set accessor + function is undefined. + + Section 17: Every accessor property described in clauses 18 through 26 and in + Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } +includes: [propertyHelper.js] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArrayBuffer.prototype, "byteLength"); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, "function"); + +verifyNotEnumerable(SendableArrayBuffer.prototype, "byteLength"); +verifyConfigurable(SendableArrayBuffer.prototype, "byteLength"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/byteLength/return-bytelength.js b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/return-bytelength.js new file mode 100644 index 00000000000..9b89bd13e14 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/return-bytelength.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.bytelength +description: Return value from [[ByteLength]] internal slot +info: | + 24.1.4.1 get SendableArrayBuffer.prototype.byteLength + + ... + 5. Let length be the value of O's [[SendableArrayBufferByteLength]] internal slot. + 6. Return length. +---*/ + +var ab1 = new SendableArrayBuffer(0); +assert.sameValue(ab1.byteLength, 0); + +var ab2 = new SendableArrayBuffer(42); +assert.sameValue(ab2.byteLength, 42); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-has-no-typedarrayname-internal.js new file mode 100644 index 00000000000..a8569b0fc67 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-has-no-typedarrayname-internal.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.bytelength +description: > + Throws a TypeError exception when `this` does not have a [[SendableArrayBufferData]] + internal slot +info: | + 24.1.4.1 get SendableArrayBuffer.prototype.byteLength + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have an [[SendableArrayBufferData]] internal slot, throw a TypeError + exception. + ... +features: [DataView, Int8Array] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, "byteLength" +).get; + +assert.throws(TypeError, function() { + getter.call({}); +}); + +assert.throws(TypeError, function() { + getter.call([]); +}); + +var ta = new Int8Array(8); +assert.throws(TypeError, function() { + getter.call(ta); +}); + +var dv = new DataView(new SendableArrayBuffer(8), 0); +assert.throws(TypeError, function() { + getter.call(dv); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-is-not-object.js b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-is-not-object.js new file mode 100644 index 00000000000..c5f85b04ba8 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-is-not-object.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.bytelength +description: Throws a TypeError exception when `this` is not Object +info: | + 24.1.4.1 get SendableArrayBuffer.prototype.byteLength + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, "byteLength" +).get; + +assert.throws(TypeError, function() { + getter.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + getter.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + getter.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + getter.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + getter.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + getter.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + getter.call(s); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js new file mode 100644 index 00000000000..52908e1d623 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.bytelength +description: Throws a TypeError exception when `this` is a SharedSendableArrayBuffer +features: [align-detached-buffer-semantics-with-web-reality, SharedSendableArrayBuffer] +---*/ + +var byteLength = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, "byteLength" +); + +var getter = byteLength.get; +var sab = new SharedSendableArrayBuffer(4); + +assert.throws(TypeError, function() { + getter.call(sab); +}, "`this` cannot be a SharedSendableArrayBuffer"); + +assert.throws(TypeError, function() { + Object.defineProperties(sab, { byteLength }); + sab.byteLength; +}, "`this` cannot be a SharedSendableArrayBuffer"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/constructor.js b/test/sendable/builtins/ArrayBuffer/prototype/constructor.js new file mode 100644 index 00000000000..8509330a7d5 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/constructor.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.constructor +description: > + The `SendableArrayBuffer.prototype.constructor` property descriptor. +info: | + The initial value of SendableArrayBuffer.prototype.constructor is the intrinsic + object %SendableArrayBuffer%. + + 17 ECMAScript Standard Built-in Objects: + 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] +---*/ + +assert.sameValue(SendableArrayBuffer.prototype.constructor, SendableArrayBuffer); + +verifyProperty(SendableArrayBuffer.prototype, "constructor", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer-resizable.js new file mode 100644 index 00000000000..128217f1721 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer-resizable.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.detached +description: Return a boolean indicating if the SendableArrayBuffer is detached +info: | + get SendableArrayBuffer.prototype.detached + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. Return IsDetachedBuffer(O). +includes: [detachSendableArrayBuffer.js] +features: [SendableArrayBuffer, arraybuffer-transfer, resizable-arraybuffer] +---*/ + +var ab1 = new SendableArrayBuffer(0, { maxByteLength: 0 }); +assert.sameValue(ab1.detached, false, 'Resizable SendableArrayBuffer with maxByteLength of 0 is not detached'); + +$DETACHBUFFER(ab1); + +assert.sameValue(ab1.detached, true, 'Resizable SendableArrayBuffer with maxByteLength of 0 is now detached'); + +var ab2 = new SendableArrayBuffer(0, { maxByteLength: 23 }); +assert.sameValue(ab2.detached, false, 'Resizable SendableArrayBuffer with maxByteLength of 23 is not detached'); + +$DETACHBUFFER(ab2); + +assert.sameValue(ab2.detached, true, 'Resizable SendableArrayBuffer with maxByteLength of 23 is now detached'); + +var ab3 = new SendableArrayBuffer(42, { maxByteLength: 42 }); +assert.sameValue(ab3.detached, false, 'Resizable SendableArrayBuffer with maxByteLength of 42 is not detached'); + +$DETACHBUFFER(ab3); + +assert.sameValue(ab3.detached, true, 'Resizable SendableArrayBuffer with maxByteLength of 42 is now detached'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer.js new file mode 100644 index 00000000000..e4c3cd48bae --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.detached +description: Returns true if the buffer is detached, else false +info: | + get SendableArrayBuffer.prototype.detached + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. Return IsDetachedBuffer(O). + +includes: [detachSendableArrayBuffer.js] +features: [SendableArrayBuffer, arraybuffer-transfer] +---*/ + +var ab = new SendableArrayBuffer(1); + +assert.sameValue(ab.detached, false); + +$DETACHBUFFER(ab); + +assert.sameValue(ab.detached, true); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/invoked-as-accessor.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/invoked-as-accessor.js new file mode 100644 index 00000000000..88cfd0cd309 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/invoked-as-accessor.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.detached +description: Returns true if the buffer is detached, else false +info: | + get SendableArrayBuffer.prototype.detached + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. Return IsDetachedBuffer(O). + +features: [SendableArrayBuffer, arraybuffer-transfer] +---*/ + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.detached; +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/invoked-as-func.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/invoked-as-func.js new file mode 100644 index 00000000000..58be7ffcfc9 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/invoked-as-func.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.detached +description: Returns true if the buffer is detached, else false +info: | + get SendableArrayBuffer.prototype.detached + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] + +features: [SendableArrayBuffer, arraybuffer-transfer] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, 'detached' +).get; + +assert.sameValue(typeof getter, 'function'); + +assert.throws(TypeError, function() { + getter(); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/length.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/length.js new file mode 100644 index 00000000000..a506c5680a2 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/length.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.detached +description: > + get SendableArrayBuffer.prototype.detached.length is 0. +info: | + get SendableArrayBuffer.prototype.detached + + 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] +features: [SendableArrayBuffer, arraybuffer-transfer] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArrayBuffer.prototype, 'detached'); + +verifyProperty(desc.get, 'length', { + value: 0, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/name.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/name.js new file mode 100644 index 00000000000..a9f7718e222 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/name.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.detached +description: > + get SendableArrayBuffer.prototype.detached + + 17 ECMAScript Standard Built-in Objects + + Functions that are specified as get or set accessor functions of built-in + properties have "get " or "set " prepended to the property name string. + +includes: [propertyHelper.js] +features: [SendableArrayBuffer, arraybuffer-transfer] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArrayBuffer.prototype, 'detached'); + +verifyProperty(desc.get, 'name', { + value: 'get detached', + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/prop-desc.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/prop-desc.js new file mode 100644 index 00000000000..41e63462f3a --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/prop-desc.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.detached +description: > + "detached" property of SendableArrayBuffer.prototype +info: | + SendableArrayBuffer.prototype.detached is an accessor property whose set + accessor function is undefined. + + Section 17: Every accessor property described in clauses 18 through 26 and in + Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } +includes: [propertyHelper.js] +features: [SendableArrayBuffer, arraybuffer-transfer] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArrayBuffer.prototype, 'detached'); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, 'function'); + +verifyProperty(SendableArrayBuffer.prototype, 'detached', { + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/this-has-no-arraybufferdata-internal.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/this-has-no-arraybufferdata-internal.js new file mode 100644 index 00000000000..6dc067f22c9 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/this-has-no-arraybufferdata-internal.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.detached +description: > + Throws a TypeError exception when `this` does not have a [[SendableArrayBufferData]] + internal slot +info: | + get SendableArrayBuffer.prototype.detached + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] +features: [DataView, Int8Array, SendableArrayBuffer, arraybuffer-transfer] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, "detached" +).get; + +assert.sameValue(typeof getter, "function"); + +assert.throws(TypeError, function() { + getter.call({}); +}); + +assert.throws(TypeError, function() { + getter.call([]); +}); + +var ta = new Int8Array(8); +assert.throws(TypeError, function() { + getter.call(ta); +}); + +var dv = new DataView(new SendableArrayBuffer(8), 0); +assert.throws(TypeError, function() { + getter.call(dv); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-not-object.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-not-object.js new file mode 100644 index 00000000000..a2383a08aa9 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-not-object.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.detached +description: Throws a TypeError exception when `this` is not Object +info: | + get SendableArrayBuffer.prototype.detached + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] +features: [Symbol, SendableArrayBuffer, arraybuffer-transfer] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, "detached" +).get; + +assert.sameValue(typeof getter, "function"); + +assert.throws(TypeError, function() { + getter.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + getter.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + getter.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + getter.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + getter.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + getter.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + getter.call(s); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer-resizable.js new file mode 100644 index 00000000000..80ae69657d1 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer-resizable.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.detached +description: Throws a TypeError exception when `this` is a resizable SharedSendableArrayBuffer +info: | + get SendableArrayBuffer.prototype.detached + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + [...] +features: [SharedSendableArrayBuffer, SendableArrayBuffer, arraybuffer-transfer] +---*/ + +var detached = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, "detached" +); + +var getter = detached.get; +var sab = new SharedSendableArrayBuffer(4); + +assert.sameValue(typeof getter, "function"); + +assert.throws(TypeError, function() { + getter.call(sab); +}, "`this` cannot be a SharedSendableArrayBuffer"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer.js new file mode 100644 index 00000000000..cd515712a45 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.detached +description: Throws a TypeError exception when `this` is a SharedSendableArrayBuffer +info: | + get SendableArrayBuffer.prototype.detached + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + [...] +features: [SharedSendableArrayBuffer, SendableArrayBuffer, arraybuffer-transfer] +---*/ + +var detached = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, "detached" +); + +var getter = detached.get; +var sab = new SharedSendableArrayBuffer(4); + +assert.sameValue(typeof getter, "function"); + +assert.throws(TypeError, function() { + getter.call(sab); +}, "`this` cannot be a SharedSendableArrayBuffer"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/detached-buffer.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/detached-buffer.js new file mode 100644 index 00000000000..abe267f3e24 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/detached-buffer.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.maxbytelength +description: Returns 0 if the buffer is detached +info: | + get SendableArrayBuffer.prototype.maxByteLength + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, return +0𝔽. + [...] +includes: [detachSendableArrayBuffer.js] +features: [resizable-arraybuffer] +---*/ + +var ab = new SendableArrayBuffer(1); + +$DETACHBUFFER(ab); + +assert.sameValue(ab.maxByteLength, 0); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/invoked-as-accessor.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/invoked-as-accessor.js new file mode 100644 index 00000000000..260f603d2b9 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/invoked-as-accessor.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.maxbytelength +description: Requires this value to have a [[SendableArrayBufferData]] internal slot +info: | + get SendableArrayBuffer.prototype.maxByteLength + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] +features: [resizable-arraybuffer] +---*/ + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.maxByteLength; +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/invoked-as-func.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/invoked-as-func.js new file mode 100644 index 00000000000..629b4231b36 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/invoked-as-func.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.maxbytelength +description: Throws a TypeError exception when invoked as a function +info: | + get SendableArrayBuffer.prototype.maxByteLength + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] +features: [resizable-arraybuffer] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, 'maxByteLength' +).get; + +assert.sameValue(typeof getter, 'function'); + +assert.throws(TypeError, function() { + getter(); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/length.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/length.js new file mode 100644 index 00000000000..ade931bf570 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/length.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.maxbytelength +description: > + get SendableArrayBuffer.prototype.maxByteLength.length is 0. +info: | + get SendableArrayBuffer.prototype.maxByteLength + + 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] +features: [resizable-arraybuffer] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArrayBuffer.prototype, 'maxByteLength'); + +verifyProperty(desc.get, 'length', { + value: 0, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/name.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/name.js new file mode 100644 index 00000000000..3b4439b5f0f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/name.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.maxbytelength +description: > + get SendableArrayBuffer.prototype.maxByteLength + + 17 ECMAScript Standard Built-in Objects + + Functions that are specified as get or set accessor functions of built-in + properties have "get " or "set " prepended to the property name string. + +includes: [propertyHelper.js] +features: [resizable-arraybuffer] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArrayBuffer.prototype, 'maxByteLength'); + +verifyProperty(desc.get, 'name', { + value: 'get maxByteLength', + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/prop-desc.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/prop-desc.js new file mode 100644 index 00000000000..fd8f03bab08 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/prop-desc.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.maxbytelength +description: > + "maxByteLength" property of SendableArrayBuffer.prototype +info: | + SendableArrayBuffer.prototype.maxByteLength is an accessor property whose set + accessor function is undefined. + + Section 17: Every accessor property described in clauses 18 through 26 and in + Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } +includes: [propertyHelper.js] +features: [resizable-arraybuffer] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArrayBuffer.prototype, 'maxByteLength'); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, 'function'); + +verifyProperty(SendableArrayBuffer.prototype, 'maxByteLength', { + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-non-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-non-resizable.js new file mode 100644 index 00000000000..80f798f1a3c --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-non-resizable.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.maxbytelength +description: Return value from [[SendableArrayBufferByteLength]] internal slot +info: | + 24.1.4.1 get SendableArrayBuffer.prototype.maxByteLength + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, return +0𝔽. + 5. If IsResizableSendableArrayBuffer(O) is true, then + [...] + 6. Else, + a. Let length be O.[[SendableArrayBufferByteLength]]. + 7. Return 𝔽(length). +features: [resizable-arraybuffer] +---*/ + +var ab1 = new SendableArrayBuffer(0); +assert.sameValue(ab1.maxByteLength, 0); + +var ab2 = new SendableArrayBuffer(42); +assert.sameValue(ab2.maxByteLength, 42); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-resizable.js new file mode 100644 index 00000000000..10c64eff211 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-resizable.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.maxbytelength +description: Return value from [[SendableArrayBufferMaxByteLength]] internal slot +info: | + 24.1.4.1 get SendableArrayBuffer.prototype.maxByteLength + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, return +0𝔽. + 5. If IsResizableSendableArrayBuffer(O) is true, then + a. Let length be O.[[SendableArrayBufferMaxByteLength]]. + 6. Else, + [...] + 7. Return 𝔽(length). +features: [resizable-arraybuffer] +---*/ + +var ab1 = new SendableArrayBuffer(0, { maxByteLength: 0 }); +assert.sameValue(ab1.maxByteLength, 0); + +var ab2 = new SendableArrayBuffer(0, { maxByteLength: 23 }); +assert.sameValue(ab2.maxByteLength, 23); + +var ab3 = new SendableArrayBuffer(42, { maxByteLength: 42 }); +assert.sameValue(ab3.maxByteLength, 42); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-has-no-arraybufferdata-internal.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-has-no-arraybufferdata-internal.js new file mode 100644 index 00000000000..2c649fc6a56 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-has-no-arraybufferdata-internal.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.maxbytelength +description: > + Throws a TypeError exception when `this` does not have a [[SendableArrayBufferData]] + internal slot +info: | + get SendableArrayBuffer.prototype.maxByteLength + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] +features: [DataView, Int8Array, resizable-arraybuffer] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, "maxByteLength" +).get; + +assert.sameValue(typeof getter, "function"); + +assert.throws(TypeError, function() { + getter.call({}); +}); + +assert.throws(TypeError, function() { + getter.call([]); +}); + +var ta = new Int8Array(8); +assert.throws(TypeError, function() { + getter.call(ta); +}); + +var dv = new DataView(new SendableArrayBuffer(8), 0); +assert.throws(TypeError, function() { + getter.call(dv); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-is-not-object.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-is-not-object.js new file mode 100644 index 00000000000..d74989e49e2 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-is-not-object.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.maxbytelength +description: Throws a TypeError exception when `this` is not Object +info: | + get SendableArrayBuffer.prototype.maxByteLength + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] +features: [Symbol, resizable-arraybuffer] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, "maxByteLength" +).get; + +assert.sameValue(typeof getter, "function"); + +assert.throws(TypeError, function() { + getter.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + getter.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + getter.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + getter.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + getter.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + getter.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + getter.call(s); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-is-sharedarraybuffer.js new file mode 100644 index 00000000000..c49c8b66475 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-is-sharedarraybuffer.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.maxbytelength +description: Throws a TypeError exception when `this` is a SharedSendableArrayBuffer +info: | + get SendableArrayBuffer.prototype.maxByteLength + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + [...] +features: [SharedSendableArrayBuffer, resizable-arraybuffer] +---*/ + +var maxByteLength = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, "maxByteLength" +); + +var getter = maxByteLength.get; +var sab = new SharedSendableArrayBuffer(4); + +assert.sameValue(typeof getter, "function"); + +assert.throws(TypeError, function() { + getter.call(sab); +}, "`this` cannot be a SharedSendableArrayBuffer"); + +Object.defineProperties(sab, { maxByteLength: maxByteLength }); + +assert.throws(TypeError, function() { + sab.maxByteLength; +}, "`this` cannot be a SharedSendableArrayBuffer"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resizable/detached-buffer.js b/test/sendable/builtins/ArrayBuffer/prototype/resizable/detached-buffer.js new file mode 100644 index 00000000000..81e359cf074 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resizable/detached-buffer.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.resizable +description: Unaffected by buffer's attachedness +info: | + get SendableArrayBuffer.prototype.resizable + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. Return IsResizableSendableArrayBuffer(O). + + IsResizableSendableArrayBuffer ( arrayBuffer ) + + 1. Assert: Type(arrayBuffer) is Object and arrayBuffer has an + [[SendableArrayBufferData]] internal slot. + 2. If buffer has an [[SendableArrayBufferMaxByteLength]] internal slot, return true. + 3. Return false. +includes: [detachSendableArrayBuffer.js] +features: [resizable-arraybuffer] +---*/ + +var ab1 = new SendableArrayBuffer(1); + +$DETACHBUFFER(ab1); + +assert.sameValue(ab1.resizable, false); + +var ab2 = new SendableArrayBuffer(1, {maxByteLength: 1}); + +$DETACHBUFFER(ab2); + +assert.sameValue(ab2.resizable, true); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resizable/invoked-as-accessor.js b/test/sendable/builtins/ArrayBuffer/prototype/resizable/invoked-as-accessor.js new file mode 100644 index 00000000000..6c5e04d71fe --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resizable/invoked-as-accessor.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.resizable +description: Requires this value to have a [[SendableArrayBufferData]] internal slot +info: | + get SendableArrayBuffer.prototype.resizable + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] +features: [resizable-arraybuffer] +---*/ + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.resizable; +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resizable/invoked-as-func.js b/test/sendable/builtins/ArrayBuffer/prototype/resizable/invoked-as-func.js new file mode 100644 index 00000000000..593565b5959 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resizable/invoked-as-func.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.resizable +description: Throws a TypeError exception when invoked as a function +info: | + get SendableArrayBuffer.prototype.resizable + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] +features: [resizable-arraybuffer] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, 'resizable' +).get; + +assert.sameValue(typeof getter, 'function'); + +assert.throws(TypeError, function() { + getter(); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resizable/length.js b/test/sendable/builtins/ArrayBuffer/prototype/resizable/length.js new file mode 100644 index 00000000000..e830502082c --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resizable/length.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.resizable +description: > + get SendableArrayBuffer.prototype.resizable.length is 0. +info: | + get SendableArrayBuffer.prototype.resizeable + + 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] +features: [resizable-arraybuffer] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArrayBuffer.prototype, 'resizable'); + +verifyProperty(desc.get, 'length', { + value: 0, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resizable/name.js b/test/sendable/builtins/ArrayBuffer/prototype/resizable/name.js new file mode 100644 index 00000000000..87dc79d2573 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resizable/name.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.resizable +description: > + get SendableArrayBuffer.prototype.resizable + + 17 ECMAScript Standard Built-in Objects + + Functions that are specified as get or set accessor functions of built-in + properties have "get " or "set " prepended to the property name string. + +includes: [propertyHelper.js] +features: [resizable-arraybuffer] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArrayBuffer.prototype, 'resizable'); + +verifyProperty(desc.get, 'name', { + value: 'get resizable', + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resizable/prop-desc.js b/test/sendable/builtins/ArrayBuffer/prototype/resizable/prop-desc.js new file mode 100644 index 00000000000..6880d704e29 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resizable/prop-desc.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.resizable +description: > + "resizable" property of SendableArrayBuffer.prototype +info: | + SendableArrayBuffer.prototype.resizable is an accessor property whose set accessor + function is undefined. + + Section 17: Every accessor property described in clauses 18 through 26 and in + Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } +includes: [propertyHelper.js] +features: [resizable-arraybuffer] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArrayBuffer.prototype, 'resizable'); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, 'function'); + +verifyProperty(SendableArrayBuffer.prototype, 'resizable', { + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resizable/return-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/resizable/return-resizable.js new file mode 100644 index 00000000000..797a50ee389 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resizable/return-resizable.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.resizable +description: Return value according to [[SendableArrayBufferMaxByteLength]] internal slot +info: | + get SendableArrayBuffer.prototype.resizable + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. Return IsResizableSendableArrayBuffer(O). + + IsResizableSendableArrayBuffer ( arrayBuffer ) + + 1. Assert: Type(arrayBuffer) is Object and arrayBuffer has an + [[SendableArrayBufferData]] internal slot. + 2. If buffer has an [[SendableArrayBufferMaxByteLength]] internal slot, return true. + 3. Return false. +features: [resizable-arraybuffer] +---*/ + +var ab1 = new SendableArrayBuffer(1); + +assert.sameValue(ab1.resizable, false); + +var ab2 = new SendableArrayBuffer(1, {maxByteLength: 1}); + +assert.sameValue(ab2.resizable, true); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resizable/this-has-no-arraybufferdata-internal.js b/test/sendable/builtins/ArrayBuffer/prototype/resizable/this-has-no-arraybufferdata-internal.js new file mode 100644 index 00000000000..826aed1ce89 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resizable/this-has-no-arraybufferdata-internal.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.resizable +description: > + Throws a TypeError exception when `this` does not have a [[SendableArrayBufferData]] + internal slot +info: | + get SendableArrayBuffer.prototype.resizable + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] +features: [DataView, Int8Array, resizable-arraybuffer] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, "resizable" +).get; + +assert.sameValue(typeof getter, "function"); + +assert.throws(TypeError, function() { + getter.call({}); +}); + +assert.throws(TypeError, function() { + getter.call([]); +}); + +var ta = new Int8Array(8); +assert.throws(TypeError, function() { + getter.call(ta); +}); + +var dv = new DataView(new SendableArrayBuffer(8), 0); +assert.throws(TypeError, function() { + getter.call(dv); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resizable/this-is-not-object.js b/test/sendable/builtins/ArrayBuffer/prototype/resizable/this-is-not-object.js new file mode 100644 index 00000000000..4d91334441c --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resizable/this-is-not-object.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.resizable +description: Throws a TypeError exception when `this` is not Object +info: | + get SendableArrayBuffer.prototype.resizable + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] +features: [Symbol, resizable-arraybuffer] +---*/ + +var getter = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, "resizable" +).get; + +assert.sameValue(typeof getter, "function"); + +assert.throws(TypeError, function() { + getter.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + getter.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + getter.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + getter.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + getter.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + getter.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + getter.call(s); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resizable/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/resizable/this-is-sharedarraybuffer.js new file mode 100644 index 00000000000..babf9b5759d --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resizable/this-is-sharedarraybuffer.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-sendableArraybuffer.prototype.resizable +description: Throws a TypeError exception when `this` is a SharedSendableArrayBuffer +info: | + get SendableArrayBuffer.prototype.resizable + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + [...] +features: [SharedSendableArrayBuffer, resizable-arraybuffer] +---*/ + +var resizable = Object.getOwnPropertyDescriptor( + SendableArrayBuffer.prototype, "resizable" +); + +var getter = resizable.get; +var sab = new SharedSendableArrayBuffer(4); + +assert.sameValue(typeof getter, "function"); + +assert.throws(TypeError, function() { + getter.call(sab); +}, "`this` cannot be a SharedSendableArrayBuffer"); + +Object.defineProperties(sab, { resizable: resizable }); + +assert.throws(TypeError, function() { + sab.resizable; +}, "`this` cannot be a SharedSendableArrayBuffer"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/coerced-new-length-detach.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/coerced-new-length-detach.js new file mode 100644 index 00000000000..17d0f8825b1 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/coerced-new-length-detach.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: > + SendableArrayBuffer.p.resize has one detach check after argument coercion +includes: [detachSendableArrayBuffer.js] +features: [resizable-arraybuffer] +---*/ + +{ + const rab = new SendableArrayBuffer(64, { maxByteLength: 1024 }); + let called = false; + assert.throws(TypeError, () => rab.resize({ valueOf() { + $DETACHBUFFER(rab); + called = true; + }})); + assert(called); +} + +{ + const rab = new SendableArrayBuffer(64, { maxByteLength: 1024 }); + $DETACHBUFFER(rab); + let called = false; + assert.throws(TypeError, () => rab.resize({ valueOf() { + called = true; + }})); + assert(called); +} diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/descriptor.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/descriptor.js new file mode 100644 index 00000000000..d2bce47a717 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/descriptor.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: > + SendableArrayBuffer.prototype.resize has default data property attributes. +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 17 ECMAScript Standard Built-in Objects: + 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] +features: [resizable-arraybuffer] +---*/ + +verifyProperty(SendableArrayBuffer.prototype, 'resize', { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/extensible.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/extensible.js new file mode 100644 index 00000000000..c1457716f9d --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/extensible.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: SendableArrayBuffer.prototype.resize is extensible. +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 17 ECMAScript Standard Built-in Objects: + Unless specified otherwise, the [[Extensible]] internal slot + of a built-in object initially has the value true. +features: [resizable-arraybuffer] +---*/ + +assert(Object.isExtensible(SendableArrayBuffer.prototype.resize)); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/length.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/length.js new file mode 100644 index 00000000000..4cee0f096da --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: > + SendableArrayBuffer.prototype.resize.length is 1. +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 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] +features: [resizable-arraybuffer] +---*/ + +verifyProperty(SendableArrayBuffer.prototype.resize, 'length', { + value: 1, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/name.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/name.js new file mode 100644 index 00000000000..370aa2f2976 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: > + SendableArrayBuffer.prototype.resize.name is "resize". +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 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 }. +features: [resizable-arraybuffer] +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArrayBuffer.prototype.resize, 'name', { + value: 'resize', + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-excessive.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-excessive.js new file mode 100644 index 00000000000..a2ab576da2d --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-excessive.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: > + Throws a RangeError the newLength value is larger than the max byte length +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). + 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], + throw a RangeError exception. + [...] +features: [resizable-arraybuffer] +---*/ + +var ab = new SendableArrayBuffer(4, {maxByteLength: 4}); + +assert.throws(RangeError, function() { + ab.resize(5); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-negative.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-negative.js new file mode 100644 index 00000000000..6d04b0c7057 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-negative.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: > + Throws a RangeError the newLength value is less than zero +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). + 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], + throw a RangeError exception. + [...] +features: [resizable-arraybuffer] +---*/ + +var ab = new SendableArrayBuffer(4, {maxByteLength: 4}); + +assert.throws(RangeError, function() { + ab.resize(-1); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-non-number.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-non-number.js new file mode 100644 index 00000000000..7ece174e3b9 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-non-number.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: Throws a TypeError if provided length cannot be coerced to a number +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). + [...] +features: [resizable-arraybuffer] +---*/ + +var log = []; +var newLength = { + toString: function() { + log.push('toString'); + return {}; + }, + valueOf: function() { + log.push('valueOf'); + return {}; + } +}; +var ab = new SendableArrayBuffer(0, {maxByteLength: 4}); + +assert.throws(TypeError, function() { + ab.resize(newLength); +}); + +assert.sameValue(log.length, 2); +assert.sameValue(log[0], 'valueOf'); +assert.sameValue(log[1], 'toString'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/nonconstructor.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/nonconstructor.js new file mode 100644 index 00000000000..f841179db23 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/nonconstructor.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: > + SendableArrayBuffer.prototype.resize is not a constructor function. +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 17 ECMAScript Standard Built-in 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. +includes: [isConstructor.js] +features: [resizable-arraybuffer, Reflect.construct] +---*/ + +assert(!isConstructor(SendableArrayBuffer.prototype.resize), "SendableArrayBuffer.prototype.resize is not a constructor"); + +var arrayBuffer = new SendableArrayBuffer(8); +assert.throws(TypeError, function() { + new arrayBuffer.resize(); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-grow.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-grow.js new file mode 100644 index 00000000000..125a32846d3 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-grow.js @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: Behavior when attempting to grow a resizable array buffer +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). + 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], + throw a RangeError exception. + 7. Let hostHandled be ? HostResizeSendableArrayBuffer(O, newByteLength). + [...] + + HostResizeSendableArrayBuffer ( buffer, newByteLength ) + + The implementation of HostResizeSendableArrayBuffer must conform to the following + requirements: + + - The abstract operation does not detach buffer. + - The abstract operation may complete normally or abruptly. + - If the abstract operation completes normally with handled, + buffer.[[SendableArrayBufferByteLength]] is newByteLength. + - The return value is either handled or unhandled. +features: [resizable-arraybuffer] +---*/ + +var ab = new SendableArrayBuffer(4, {maxByteLength: 5}); +var caught = false; +var result; + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ab.resize, 'function'); + +try { + result = ab.resize(5); +} catch (_) { + caught = true; +} + +try { + ab.slice(); +} catch (_) { + throw new Test262Error('The SendableArrayBuffer under test was detached'); +} + +// One of the following three conditions must be met: +// +// - HostResizeSendableArrayBuffer returns an abrupt completion +// - HostResizeSendableArrayBuffer handles the resize operation and conforms to the +// invarient regarding [[SendableArrayBufferByteLength]] +// - HostResizeSendableArrayBuffer does not handle the resize operation, and the +// `resize` method updates [[SendableArrayBufferByteLength]] +// +// The final two conditions are indistinguishable. +assert(caught || ab.byteLength === 5, 'byteLength'); + +// One of the following three conditions must be met: +// +// - HostResizeSendableArrayBuffer returns an abrupt completion +// - HostResizeSendableArrayBuffer handles the resize operation, and the `resize` +// method returns early +// - HostResizeSendableArrayBuffer does not handle the resize operation, and the +// `resize` method executes its final steps +// +// All three conditions have the same effect on the value of `result`. +assert.sameValue(result, undefined, 'normal completion value'); + +// The contents of the SendableArrayBuffer are not guaranteed by the host-defined +// abstract operation, so they are not asserted in this test. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-explicit.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-explicit.js new file mode 100644 index 00000000000..103c6620eb1 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-explicit.js @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: > + Behavior when attempting to reset the size of a resizable array buffer to zero explicitly +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). + 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], + throw a RangeError exception. + 7. Let hostHandled be ? HostResizeSendableArrayBuffer(O, newByteLength). + [...] + + HostResizeSendableArrayBuffer ( buffer, newByteLength ) + + The implementation of HostResizeSendableArrayBuffer must conform to the following + requirements: + + - The abstract operation does not detach buffer. + - The abstract operation may complete normally or abruptly. + - If the abstract operation completes normally with handled, + buffer.[[SendableArrayBufferByteLength]] is newByteLength. + - The return value is either handled or unhandled. +features: [resizable-arraybuffer] +---*/ + +var ab = new SendableArrayBuffer(0, {maxByteLength: 0}); +var caught = false; +var result; + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ab.resize, 'function'); + +try { + result = ab.resize(0); +} catch (_) { + caught = true; +} + +try { + ab.slice(); +} catch (_) { + throw new Test262Error('The SendableArrayBuffer under test was detached'); +} + +// One of the following three conditions must be met: +// +// - HostResizeSendableArrayBuffer returns an abrupt completion +// - HostResizeSendableArrayBuffer handles the resize operation and conforms to the +// invarient regarding [[SendableArrayBufferByteLength]] +// - HostResizeSendableArrayBuffer does not handle the resize operation, and the +// `resize` method updates [[SendableArrayBufferByteLength]] +// +// The final two conditions are indistinguishable. +assert(caught || ab.byteLength === 0, 'byteLength'); + +// One of the following three conditions must be met: +// +// - HostResizeSendableArrayBuffer returns an abrupt completion +// - HostResizeSendableArrayBuffer handles the resize operation, and the `resize` +// method returns early +// - HostResizeSendableArrayBuffer does not handle the resize operation, and the +// `resize` method executes its final steps +// +// All three conditions have the same effect on the value of `result`. +assert.sameValue(result, undefined, 'normal completion value'); + +// The contents of the SendableArrayBuffer are not guaranteed by the host-defined +// abstract operation, so they are not asserted in this test. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-implicit.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-implicit.js new file mode 100644 index 00000000000..c540065630c --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-implicit.js @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: > + Behavior when attempting to reset the size of a resizable array buffer to zero explicitly +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). + 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], + throw a RangeError exception. + 7. Let hostHandled be ? HostResizeSendableArrayBuffer(O, newByteLength). + [...] + + HostResizeSendableArrayBuffer ( buffer, newByteLength ) + + The implementation of HostResizeSendableArrayBuffer must conform to the following + requirements: + + - The abstract operation does not detach buffer. + - The abstract operation may complete normally or abruptly. + - If the abstract operation completes normally with handled, + buffer.[[SendableArrayBufferByteLength]] is newByteLength. + - The return value is either handled or unhandled. +features: [resizable-arraybuffer] +---*/ + +var ab = new SendableArrayBuffer(0, {maxByteLength: 0}); +var caught = false; +var result; + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ab.resize, 'function'); + +try { + result = ab.resize(); +} catch (_) { + caught = true; +} + +try { + ab.slice(); +} catch (_) { + throw new Test262Error('The SendableArrayBuffer under test was detached'); +} + +// One of the following three conditions must be met: +// +// - HostResizeSendableArrayBuffer returns an abrupt completion +// - HostResizeSendableArrayBuffer handles the resize operation and conforms to the +// invarient regarding [[SendableArrayBufferByteLength]] +// - HostResizeSendableArrayBuffer does not handle the resize operation, and the +// `resize` method updates [[SendableArrayBufferByteLength]] +// +// The final two conditions are indistinguishable. +assert(caught || ab.byteLength === 0, 'byteLength'); + +// One of the following three conditions must be met: +// +// - HostResizeSendableArrayBuffer returns an abrupt completion +// - HostResizeSendableArrayBuffer handles the resize operation, and the `resize` +// method returns early +// - HostResizeSendableArrayBuffer does not handle the resize operation, and the +// `resize` method executes its final steps +// +// All three conditions have the same effect on the value of `result`. +assert.sameValue(result, undefined, 'normal completion value'); + +// The contents of the SendableArrayBuffer are not guaranteed by the host-defined +// abstract operation, so they are not asserted in this test. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size.js new file mode 100644 index 00000000000..6eb5a3f8563 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size.js @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: > + Behavior when attempting to reset the size of a resizable array buffer +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). + 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], + throw a RangeError exception. + 7. Let hostHandled be ? HostResizeSendableArrayBuffer(O, newByteLength). + [...] + + HostResizeSendableArrayBuffer ( buffer, newByteLength ) + + The implementation of HostResizeSendableArrayBuffer must conform to the following + requirements: + + - The abstract operation does not detach buffer. + - The abstract operation may complete normally or abruptly. + - If the abstract operation completes normally with handled, + buffer.[[SendableArrayBufferByteLength]] is newByteLength. + - The return value is either handled or unhandled. +features: [resizable-arraybuffer] +---*/ + +var ab = new SendableArrayBuffer(4, {maxByteLength: 4}); +var caught = false; +var result; + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ab.resize, 'function'); + +try { + result = ab.resize(4); +} catch (_) { + caught = true; +} + +try { + ab.slice(); +} catch (_) { + throw new Test262Error('The SendableArrayBuffer under test was detached'); +} + +// One of the following three conditions must be met: +// +// - HostResizeSendableArrayBuffer returns an abrupt completion +// - HostResizeSendableArrayBuffer handles the resize operation and conforms to the +// invarient regarding [[SendableArrayBufferByteLength]] +// - HostResizeSendableArrayBuffer does not handle the resize operation, and the +// `resize` method updates [[SendableArrayBufferByteLength]] +// +// The final two conditions are indistinguishable. +assert(caught || ab.byteLength === 4, 'byteLength'); + +// One of the following three conditions must be met: +// +// - HostResizeSendableArrayBuffer returns an abrupt completion +// - HostResizeSendableArrayBuffer handles the resize operation, and the `resize` +// method returns early +// - HostResizeSendableArrayBuffer does not handle the resize operation, and the +// `resize` method executes its final steps +// +// All three conditions have the same effect on the value of `result`. +assert.sameValue(result, undefined, 'normal completion value'); + +// The contents of the SendableArrayBuffer are not guaranteed by the host-defined +// abstract operation, so they are not asserted in this test. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-explicit.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-explicit.js new file mode 100644 index 00000000000..ae7881bd274 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-explicit.js @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: Behavior when attempting to shrink a resizable array buffer to zero explicitly +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). + 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], + throw a RangeError exception. + 7. Let hostHandled be ? HostResizeSendableArrayBuffer(O, newByteLength). + [...] + + HostResizeSendableArrayBuffer ( buffer, newByteLength ) + + The implementation of HostResizeSendableArrayBuffer must conform to the following + requirements: + + - The abstract operation does not detach buffer. + - The abstract operation may complete normally or abruptly. + - If the abstract operation completes normally with handled, + buffer.[[SendableArrayBufferByteLength]] is newByteLength. + - The return value is either handled or unhandled. +features: [resizable-arraybuffer] +---*/ + +var ab = new SendableArrayBuffer(4, {maxByteLength: 4}); +var caught = false; +var result; + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ab.resize, 'function'); + +try { + result = ab.resize(0); +} catch (_) { + caught = true; +} + +try { + ab.slice(); +} catch (_) { + throw new Test262Error('The SendableArrayBuffer under test was detached'); +} + +// One of the following three conditions must be met: +// +// - HostResizeSendableArrayBuffer returns an abrupt completion +// - HostResizeSendableArrayBuffer handles the resize operation and conforms to the +// invarient regarding [[SendableArrayBufferByteLength]] +// - HostResizeSendableArrayBuffer does not handle the resize operation, and the +// `resize` method updates [[SendableArrayBufferByteLength]] +// +// The final two conditions are indistinguishable. +assert(caught || ab.byteLength === 0, 'byteLength'); + +// One of the following three conditions must be met: +// +// - HostResizeSendableArrayBuffer returns an abrupt completion +// - HostResizeSendableArrayBuffer handles the resize operation, and the `resize` +// method returns early +// - HostResizeSendableArrayBuffer does not handle the resize operation, and the +// `resize` method executes its final steps +// +// All three conditions have the same effect on the value of `result`. +assert.sameValue(result, undefined, 'normal completion value'); + +// The contents of the SendableArrayBuffer are not guaranteed by the host-defined +// abstract operation, so they are not asserted in this test. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-implicit.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-implicit.js new file mode 100644 index 00000000000..6c301054f8f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-implicit.js @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: Behavior when attempting to shrink a resizable array buffer to zero implicitly +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). + 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], + throw a RangeError exception. + 7. Let hostHandled be ? HostResizeSendableArrayBuffer(O, newByteLength). + [...] + + HostResizeSendableArrayBuffer ( buffer, newByteLength ) + + The implementation of HostResizeSendableArrayBuffer must conform to the following + requirements: + + - The abstract operation does not detach buffer. + - The abstract operation may complete normally or abruptly. + - If the abstract operation completes normally with handled, + buffer.[[SendableArrayBufferByteLength]] is newByteLength. + - The return value is either handled or unhandled. +features: [resizable-arraybuffer] +---*/ + +var ab = new SendableArrayBuffer(4, {maxByteLength: 4}); +var caught = false; +var result; + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ab.resize, 'function'); + +try { + result = ab.resize(); +} catch (_) { + caught = true; +} + +try { + ab.slice(); +} catch (_) { + throw new Test262Error('The SendableArrayBuffer under test was detached'); +} + +// One of the following three conditions must be met: +// +// - HostResizeSendableArrayBuffer returns an abrupt completion +// - HostResizeSendableArrayBuffer handles the resize operation and conforms to the +// invarient regarding [[SendableArrayBufferByteLength]] +// - HostResizeSendableArrayBuffer does not handle the resize operation, and the +// `resize` method updates [[SendableArrayBufferByteLength]] +// +// The final two conditions are indistinguishable. +assert(caught || ab.byteLength === 0, 'byteLength'); + +// One of the following three conditions must be met: +// +// - HostResizeSendableArrayBuffer returns an abrupt completion +// - HostResizeSendableArrayBuffer handles the resize operation, and the `resize` +// method returns early +// - HostResizeSendableArrayBuffer does not handle the resize operation, and the +// `resize` method executes its final steps +// +// All three conditions have the same effect on the value of `result`. +assert.sameValue(result, undefined, 'normal completion value'); + +// The contents of the SendableArrayBuffer are not guaranteed by the host-defined +// abstract operation, so they are not asserted in this test. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink.js new file mode 100644 index 00000000000..ddd13e6ca72 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink.js @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: Behavior when attempting to shrink a resizable array buffer +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). + 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], + throw a RangeError exception. + 7. Let hostHandled be ? HostResizeSendableArrayBuffer(O, newByteLength). + [...] + + HostResizeSendableArrayBuffer ( buffer, newByteLength ) + + The implementation of HostResizeSendableArrayBuffer must conform to the following + requirements: + + - The abstract operation does not detach buffer. + - The abstract operation may complete normally or abruptly. + - If the abstract operation completes normally with handled, + buffer.[[SendableArrayBufferByteLength]] is newByteLength. + - The return value is either handled or unhandled. +features: [resizable-arraybuffer] +---*/ + +var ab = new SendableArrayBuffer(4, {maxByteLength: 4}); +var caught = false; +var result; + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ab.resize, 'function'); + +try { + result = ab.resize(3); +} catch (_) { + caught = true; +} + +try { + ab.slice(); +} catch (_) { + throw new Test262Error('The SendableArrayBuffer under test was detached'); +} + +// One of the following three conditions must be met: +// +// - HostResizeSendableArrayBuffer returns an abrupt completion +// - HostResizeSendableArrayBuffer handles the resize operation and conforms to the +// invarient regarding [[SendableArrayBufferByteLength]] +// - HostResizeSendableArrayBuffer does not handle the resize operation, and the +// `resize` method updates [[SendableArrayBufferByteLength]] +// +// The final two conditions are indistinguishable. +assert(caught || ab.byteLength === 3, 'byteLength'); + +// One of the following three conditions must be met: +// +// - HostResizeSendableArrayBuffer returns an abrupt completion +// - HostResizeSendableArrayBuffer handles the resize operation, and the `resize` +// method returns early +// - HostResizeSendableArrayBuffer does not handle the resize operation, and the +// `resize` method executes its final steps +// +// All three conditions have the same effect on the value of `result`. +assert.sameValue(result, undefined, 'normal completion value'); + +// The contents of the SendableArrayBuffer are not guaranteed by the host-defined +// abstract operation, so they are not asserted in this test. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-detached.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-detached.js new file mode 100644 index 00000000000..0e53c3b1bfa --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-detached.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: > + Throws a TypeError if `this` does not have an [[SendableArrayBufferData]] internal slot. +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + [...] +includes: [detachSendableArrayBuffer.js] +features: [resizable-arraybuffer] +---*/ + +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); + +var ab = new SendableArrayBuffer(1); + +$DETACHBUFFER(ab); + +assert.throws(TypeError, function() { + ab.resize(); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-not-arraybuffer-object.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-not-arraybuffer-object.js new file mode 100644 index 00000000000..8de2c17c555 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-not-arraybuffer-object.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: > + Throws a TypeError if `this` does not have an [[SendableArrayBufferData]] internal slot. +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + [...] +features: [resizable-arraybuffer] +---*/ + +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.resize(); +}, '`this` value is the SendableArrayBuffer prototype'); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.resize.call({}); +}, '`this` value is an object'); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.resize.call([]); +}, '`this` value is an array'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-not-object.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-not-object.js new file mode 100644 index 00000000000..3f8db1d1878 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-not-object.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: Throws a TypeError if `this` valueis not an object. +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + [...] +features: [resizable-arraybuffer, Symbol, BigInt] +---*/ + +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.resize.call(undefined); +}, "`this` value is undefined"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.resize.call(null); +}, "`this` value is null"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.resize.call(true); +}, "`this` value is Boolean"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.resize.call(""); +}, "`this` value is String"); + +var symbol = Symbol(); +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.resize.call(symbol); +}, "`this` value is Symbol"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.resize.call(1); +}, "`this` value is Number"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.resize.call(1n); +}, "`this` value is bigint"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-not-resizable-arraybuffer-object.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-not-resizable-arraybuffer-object.js new file mode 100644 index 00000000000..971bc3ddd83 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-not-resizable-arraybuffer-object.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: > + Throws a TypeError if `this` does not have an [[SendableArrayBufferMaxByteLength]] internal slot. +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + [...] +features: [resizable-arraybuffer] +---*/ + +var ab; + +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); + +ab = new SendableArrayBuffer(4); +assert.throws(TypeError, function() { + ab.resize(0); +}, 'zero byte length'); + +ab = new SendableArrayBuffer(4); +assert.throws(TypeError, function() { + ab.resize(3); +}, 'smaller byte length'); + +ab = new SendableArrayBuffer(4); +assert.throws(TypeError, function() { + ab.resize(4); +}, 'same byte length'); + +ab = new SendableArrayBuffer(4); +assert.throws(TypeError, function() { + ab.resize(5); +}, 'larger byte length'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-sharedarraybuffer.js new file mode 100644 index 00000000000..bb3ceabb484 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-sharedarraybuffer.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.resize +description: Throws a TypeError if `this` value is a SharedSendableArrayBuffer +info: | + SendableArrayBuffer.prototype.resize ( newLength ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + [...] +features: [SharedSendableArrayBuffer, resizable-arraybuffer] +---*/ + +var sab = new SharedSendableArrayBuffer(0); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.resize.call(sab); +}, '`this` value cannot be a SharedSendableArrayBuffer'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/context-is-not-arraybuffer-object.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/context-is-not-arraybuffer-object.js new file mode 100644 index 00000000000..8388897d53d --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/context-is-not-arraybuffer-object.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Throws a TypeError if `this` does not have an [[SendableArrayBufferData]] internal slot. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have an [[SendableArrayBufferData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.slice.call({}); +}, "`this` value is Object"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.slice.call([]); +}, "`this` value is Array"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/context-is-not-object.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/context-is-not-object.js new file mode 100644 index 00000000000..785152d0479 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/context-is-not-object.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Throws a TypeError if `this` is not an Object. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.slice.call(undefined); +}, "`this` value is undefined"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.slice.call(null); +}, "`this` value is null"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.slice.call(true); +}, "`this` value is Boolean"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.slice.call(""); +}, "`this` value is String"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.slice.call(Symbol()); +}, "`this` value is Symbol"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.slice.call(1); +}, "`this` value is Number"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/descriptor.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/descriptor.js new file mode 100644 index 00000000000..756ab71310b --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/descriptor.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + SendableArrayBuffer.prototype.slice has default data property attributes. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + 17 ECMAScript Standard Built-in Objects: + 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] +---*/ + +verifyProperty(SendableArrayBuffer.prototype, "slice", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/end-default-if-absent.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/end-default-if-absent.js new file mode 100644 index 00000000000..ad5e4f73a8a --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/end-default-if-absent.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + The `end` index defaults to [[SendableArrayBufferByteLength]] if absent. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 9. If end is undefined, let relativeEnd be len; else let relativeEnd be ToInteger(end). + 10. ReturnIfAbrupt(relativeEnd). + ... +---*/ + +var arrayBuffer = new SendableArrayBuffer(8); + +var start = 6; +var result = arrayBuffer.slice(start); +assert.sameValue(result.byteLength, 2); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/end-default-if-undefined.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/end-default-if-undefined.js new file mode 100644 index 00000000000..8d011d7400e --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/end-default-if-undefined.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + The `end` index defaults to [[SendableArrayBufferByteLength]] if undefined. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 9. If end is undefined, let relativeEnd be len; else let relativeEnd be ToInteger(end). + 10. ReturnIfAbrupt(relativeEnd). + ... +---*/ + +var arrayBuffer = new SendableArrayBuffer(8); + +var start = 6, + end = undefined; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 2); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/end-exceeds-length.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/end-exceeds-length.js new file mode 100644 index 00000000000..eb230e8c572 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/end-exceeds-length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Large `end` index is clamped to [[SendableArrayBufferByteLength]]. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 8. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let final be min(relativeEnd, len). + ... +---*/ + +var arrayBuffer = new SendableArrayBuffer(8); + +var start = 1, + end = 12; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 7, "slice(1, 12)"); + +var start = 2, + end = 0x100000000; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 6, "slice(2, 0x100000000)"); + +var start = 3, + end = +Infinity; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 5, "slice(3, Infinity)"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/extensible.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/extensible.js new file mode 100644 index 00000000000..2b878ab3cce --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/extensible.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + SendableArrayBuffer.prototype.slice is extensible. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + 17 ECMAScript Standard Built-in Objects: + Unless specified otherwise, the [[Extensible]] internal slot + of a built-in object initially has the value true. +---*/ + +assert(Object.isExtensible(SendableArrayBuffer.prototype.slice)); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/length.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/length.js new file mode 100644 index 00000000000..d506009c9a6 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/length.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + SendableArrayBuffer.prototype.slice.length is 2. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + 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(SendableArrayBuffer.prototype.slice, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/name.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/name.js new file mode 100644 index 00000000000..8f9e6dd1246 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/name.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + SendableArrayBuffer.prototype.slice.name is "slice". +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + 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(SendableArrayBuffer.prototype.slice, "name", { + value: "slice", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/negative-end.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/negative-end.js new file mode 100644 index 00000000000..d15f68af65f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/negative-end.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Negative `end` index is relative to [[SendableArrayBufferByteLength]]. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 8. If relativeEnd < 0, let final be max((len + relativeEnd),0); else let final be min(relativeEnd, len). + ... +---*/ + +var arrayBuffer = new SendableArrayBuffer(8); + +var start = 2, + end = -4; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 2, "slice(2, -4)"); + +var start = 2, + end = -10; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 0, "slice(2, -10)"); + +var start = 2, + end = -Infinity; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 0, "slice(2, -Infinity)"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/negative-start.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/negative-start.js new file mode 100644 index 00000000000..dfa8b4881c7 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/negative-start.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Negative `start` index is relative to [[SendableArrayBufferByteLength]]. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 8. If relativeStart < 0, let first be max((len + relativeStart),0); else let first be min(relativeStart, len). + ... +---*/ + +var arrayBuffer = new SendableArrayBuffer(8); + +var start = -5, + end = 6; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 3, "slice(-5, 6)"); + +var start = -12, + end = 6; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 6, "slice(-12, 6)"); + +var start = -Infinity, + end = 6; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 6, "slice(-Infinity, 6)"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/nonconstructor.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/nonconstructor.js new file mode 100644 index 00000000000..867e41e8b26 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/nonconstructor.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + SendableArrayBuffer.prototype.slice is not a constructor function. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + 17 ECMAScript Standard Built-in 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. +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ + +assert(!isConstructor(SendableArrayBuffer.prototype.slice), "SendableArrayBuffer.prototype.slice is not a constructor"); + +var arrayBuffer = new SendableArrayBuffer(8); +assert.throws(TypeError, function() { + new arrayBuffer.slice(); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/not-a-constructor.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/not-a-constructor.js new file mode 100644 index 00000000000..4773d4a2899 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableArrayBuffer.prototype.slice 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, SendableArrayBuffer, arrow-function] +---*/ + +assert.sameValue( + isConstructor(SendableArrayBuffer.prototype.slice), + false, + 'isConstructor(SendableArrayBuffer.prototype.slice) must return false' +); + +assert.throws(TypeError, () => { + let ab = new SendableArrayBuffer(); new ab.slice(); +}); + diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/number-conversion.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/number-conversion.js new file mode 100644 index 00000000000..c9c3acfc529 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/number-conversion.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + ToInteger(start) is called before ToInteger(end). +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 6. Let relativeStart be ToInteger(start). + 7. ReturnIfAbrupt(relativeStart). + ... + 9. If end is undefined, let relativeEnd be len; else let relativeEnd be ToInteger(end). + 10. ReturnIfAbrupt(relativeEnd). + ... +---*/ + +var arrayBuffer = new SendableArrayBuffer(8); + +var log = ""; +var start = { + valueOf: function() { + log += "start-"; + return 0; + } +}; +var end = { + valueOf: function() { + log += "end"; + return 8; + } +}; + +arrayBuffer.slice(start, end); +assert.sameValue(log, "start-end"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/species-constructor-is-not-object.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-constructor-is-not-object.js new file mode 100644 index 00000000000..8e0d475d0e8 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-constructor-is-not-object.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Throws TypeError if `constructor` property is not an object. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 13. Let ctor be SpeciesConstructor(O, %SendableArrayBuffer%). + 14. ReturnIfAbrupt(ctor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + ... + 2. Let C be Get(O, "constructor"). + 3. ReturnIfAbrupt(C). + 4. If C is undefined, return defaultConstructor. + 5. If Type(C) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +var arrayBuffer = new SendableArrayBuffer(8); + +function callSlice() { + arrayBuffer.slice(); +} + +arrayBuffer.constructor = null; +assert.throws(TypeError, callSlice, "`constructor` value is null"); + +arrayBuffer.constructor = true; +assert.throws(TypeError, callSlice, "`constructor` value is Boolean"); + +arrayBuffer.constructor = ""; +assert.throws(TypeError, callSlice, "`constructor` value is String"); + +arrayBuffer.constructor = Symbol(); +assert.throws(TypeError, callSlice, "`constructor` value is Symbol"); + +arrayBuffer.constructor = 1; +assert.throws(TypeError, callSlice, "`constructor` value is Number"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/species-constructor-is-undefined.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-constructor-is-undefined.js new file mode 100644 index 00000000000..ade4cbed528 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-constructor-is-undefined.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Uses default constructor is `constructor` property is undefined. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 13. Let ctor be SpeciesConstructor(O, %SendableArrayBuffer%). + 14. ReturnIfAbrupt(ctor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + ... + 2. Let C be Get(O, "constructor"). + 3. ReturnIfAbrupt(C). + 4. If C is undefined, return defaultConstructor. + ... +---*/ + +var arrayBuffer = new SendableArrayBuffer(8); +arrayBuffer.constructor = undefined; + +var result = arrayBuffer.slice(); +assert.sameValue(Object.getPrototypeOf(result), SendableArrayBuffer.prototype); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-not-constructor.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-not-constructor.js new file mode 100644 index 00000000000..78868af1966 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-not-constructor.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Throws a TypeError if species constructor is not a constructor function. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 13. Let ctor be SpeciesConstructor(O, %SendableArrayBuffer%). + 14. ReturnIfAbrupt(ctor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + ... + 6. Let S be Get(C, @@species). + 7. ReturnIfAbrupt(S). + ... + 9. If IsConstructor(S) is true, return S. + 10. Throw a TypeError exception. +features: [Symbol.species] +---*/ + +var speciesConstructor = {}; + +var arrayBuffer = new SendableArrayBuffer(8); +arrayBuffer.constructor = speciesConstructor; + +function callSlice() { + arrayBuffer.slice(); +} + +speciesConstructor[Symbol.species] = {}; +assert.throws(TypeError, callSlice, "`constructor[Symbol.species]` value is Object"); + +speciesConstructor[Symbol.species] = Function.prototype; +assert.throws(TypeError, callSlice, "`constructor[Symbol.species]` value is Function.prototype"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-not-object.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-not-object.js new file mode 100644 index 00000000000..61049abdb6b --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-not-object.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Throws a TypeError if species constructor is not an object. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 13. Let ctor be SpeciesConstructor(O, %SendableArrayBuffer%). + 14. ReturnIfAbrupt(ctor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + ... + 6. Let S be Get(C, @@species). + 7. ReturnIfAbrupt(S). + 8. If S is either undefined or null, return defaultConstructor. + 9. If IsConstructor(S) is true, return S. + 10. Throw a TypeError exception. +features: [Symbol.species] +---*/ + +var speciesConstructor = {}; + +var arrayBuffer = new SendableArrayBuffer(8); +arrayBuffer.constructor = speciesConstructor; + +function callSlice() { + arrayBuffer.slice(); +} + +speciesConstructor[Symbol.species] = true; +assert.throws(TypeError, callSlice, "`constructor[Symbol.species]` value is Boolean"); + +speciesConstructor[Symbol.species] = ""; +assert.throws(TypeError, callSlice, "`constructor[Symbol.species]` value is String"); + +speciesConstructor[Symbol.species] = Symbol(); +assert.throws(TypeError, callSlice, "`constructor[Symbol.species]` value is Symbol"); + +speciesConstructor[Symbol.species] = 1; +assert.throws(TypeError, callSlice, "`constructor[Symbol.species]` value is Number"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-null.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-null.js new file mode 100644 index 00000000000..01dc5b04bb7 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-null.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Uses default constructor is species constructor is null. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 13. Let ctor be SpeciesConstructor(O, %SendableArrayBuffer%). + 14. ReturnIfAbrupt(ctor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + ... + 6. Let S be Get(C, @@species). + 7. ReturnIfAbrupt(S). + 8. If S is either undefined or null, return defaultConstructor. + ... +features: [Symbol.species] +---*/ + +var speciesConstructor = {}; +speciesConstructor[Symbol.species] = null; + +var arrayBuffer = new SendableArrayBuffer(8); +arrayBuffer.constructor = speciesConstructor; + +var result = arrayBuffer.slice(); +assert.sameValue(Object.getPrototypeOf(result), SendableArrayBuffer.prototype); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-undefined.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-undefined.js new file mode 100644 index 00000000000..8aced784316 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-is-undefined.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Uses default constructor is species constructor is undefined. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 13. Let ctor be SpeciesConstructor(O, %SendableArrayBuffer%). + 14. ReturnIfAbrupt(ctor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + ... + 6. Let S be Get(C, @@species). + 7. ReturnIfAbrupt(S). + 8. If S is either undefined or null, return defaultConstructor. + ... +features: [Symbol.species] +---*/ + +var speciesConstructor = {}; +speciesConstructor[Symbol.species] = undefined; + +var arrayBuffer = new SendableArrayBuffer(8); +arrayBuffer.constructor = speciesConstructor; + +var result = arrayBuffer.slice(); +assert.sameValue(Object.getPrototypeOf(result), SendableArrayBuffer.prototype); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-larger-arraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-larger-arraybuffer.js new file mode 100644 index 00000000000..4d047e1f307 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-larger-arraybuffer.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Does not throw TypeError if new SendableArrayBuffer is too large. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 13. Let ctor be SpeciesConstructor(O, %SendableArrayBuffer%). + 14. ReturnIfAbrupt(ctor). + 15. Let new be Construct(ctor, «newLen»). + 16. ReturnIfAbrupt(new). + ... + 20. If the value of new’s [[SendableArrayBufferByteLength]] internal slot < newLen, throw a TypeError exception. + ... +features: [Symbol.species] +---*/ + +var speciesConstructor = {}; +speciesConstructor[Symbol.species] = function(length) { + return new SendableArrayBuffer(10); +}; + +var arrayBuffer = new SendableArrayBuffer(8); +arrayBuffer.constructor = speciesConstructor; + +var result = arrayBuffer.slice(); +assert.sameValue(result.byteLength, 10); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-not-arraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-not-arraybuffer.js new file mode 100644 index 00000000000..9ef26803eba --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-not-arraybuffer.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Throws a TypeError if new object is not an SendableArrayBuffer instance. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 13. Let ctor be SpeciesConstructor(O, %SendableArrayBuffer%). + 14. ReturnIfAbrupt(ctor). + 15. Let new be Construct(ctor, «newLen»). + 16. ReturnIfAbrupt(new). + 17. If new does not have an [[SendableArrayBufferData]] internal slot, throw a TypeError exception. + ... +features: [Symbol.species] +---*/ + +var speciesConstructor = {}; +speciesConstructor[Symbol.species] = function(length) { + return {}; +}; + +var arrayBuffer = new SendableArrayBuffer(8); +arrayBuffer.constructor = speciesConstructor; + +assert.throws(TypeError, function() { + arrayBuffer.slice(); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-same-arraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-same-arraybuffer.js new file mode 100644 index 00000000000..6a2ce72115b --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-same-arraybuffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Throws a TypeError if species constructor returns `this` value. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + 1. Let O be the this value. + ... + 13. Let ctor be SpeciesConstructor(O, %SendableArrayBuffer%). + 14. ReturnIfAbrupt(ctor). + 15. Let new be Construct(ctor, «newLen»). + 16. ReturnIfAbrupt(new). + ... + 19. If SameValue(new, O) is true, throw a TypeError exception. + ... +features: [Symbol.species] +---*/ + +var speciesConstructor = {}; +speciesConstructor[Symbol.species] = function(length) { + return arrayBuffer; +}; + +var arrayBuffer = new SendableArrayBuffer(8); +arrayBuffer.constructor = speciesConstructor; + +assert.throws(TypeError, function() { + arrayBuffer.slice(); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-smaller-arraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-smaller-arraybuffer.js new file mode 100644 index 00000000000..83c944260bf --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/species-returns-smaller-arraybuffer.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Throws a TypeError if new SendableArrayBuffer is too small. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 13. Let ctor be SpeciesConstructor(O, %SendableArrayBuffer%). + 14. ReturnIfAbrupt(ctor). + 15. Let new be Construct(ctor, «newLen»). + 16. ReturnIfAbrupt(new). + ... + 20. If the value of new’s [[SendableArrayBufferByteLength]] internal slot < newLen, throw a TypeError exception. + ... +features: [Symbol.species] +---*/ + +var speciesConstructor = {}; +speciesConstructor[Symbol.species] = function(length) { + return new SendableArrayBuffer(4); +}; + +var arrayBuffer = new SendableArrayBuffer(8); +arrayBuffer.constructor = speciesConstructor; + +assert.throws(TypeError, function() { + arrayBuffer.slice(); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/species.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/species.js new file mode 100644 index 00000000000..e7c06f12417 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/species.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + New SendableArrayBuffer instance is created from SpeciesConstructor. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 13. Let ctor be SpeciesConstructor(O, %SendableArrayBuffer%). + 14. ReturnIfAbrupt(ctor). + 15. Let new be Construct(ctor, «newLen»). + 16. ReturnIfAbrupt(new). + ... + 26. Return new. +features: [Symbol.species] +---*/ + +var resultBuffer; + +var speciesConstructor = {}; +speciesConstructor[Symbol.species] = function(length) { + return resultBuffer = new SendableArrayBuffer(length); +}; + +var arrayBuffer = new SendableArrayBuffer(8); +arrayBuffer.constructor = speciesConstructor; + +var result = arrayBuffer.slice(); +assert.sameValue(result, resultBuffer); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/start-default-if-absent.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/start-default-if-absent.js new file mode 100644 index 00000000000..d5d359fde62 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/start-default-if-absent.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + The `start` index defaults to 0 if absent. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 6. Let relativeStart be ToInteger(start). + 7. ReturnIfAbrupt(relativeStart). + ... +---*/ + +var arrayBuffer = new SendableArrayBuffer(8); + +var result = arrayBuffer.slice(); +assert.sameValue(result.byteLength, 8); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/start-default-if-undefined.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/start-default-if-undefined.js new file mode 100644 index 00000000000..45ce01746f9 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/start-default-if-undefined.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + The `start` index defaults to 0 if undefined. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 6. Let relativeStart be ToInteger(start). + 7. ReturnIfAbrupt(relativeStart). + ... +---*/ + +var arrayBuffer = new SendableArrayBuffer(8); + +var start = undefined, + end = 6; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 6); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/start-exceeds-end.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/start-exceeds-end.js new file mode 100644 index 00000000000..3e5ec86011f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/start-exceeds-end.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Returns zero-length buffer if `start` index exceeds `end` index. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 12. Let newLen be max(final-first,0). + ... +---*/ + +var arrayBuffer = new SendableArrayBuffer(8); + +var start = 5, + end = 4; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 0); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/start-exceeds-length.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/start-exceeds-length.js new file mode 100644 index 00000000000..42ca6c7544f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/start-exceeds-length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Large `start` index is clamped to [[SendableArrayBufferByteLength]]. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 8. If relativeStart < 0, let first be max((len + relativeStart),0); else let first be min(relativeStart, len). + ... +---*/ + +var arrayBuffer = new SendableArrayBuffer(8); + +var start = 10, + end = 8; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 0, "slice(10, 8)"); + +var start = 0x100000000, + end = 7; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 0, "slice(0x100000000, 7)"); + +var start = +Infinity, + end = 6; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 0, "slice(+Infinity, 6)"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer.js new file mode 100644 index 00000000000..13e97ade6b8 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + Throws a TypeError if `this` is a SharedSendableArrayBuffer +features: [SharedSendableArrayBuffer] +---*/ + +assert.throws(TypeError, function() { + var sab = new SharedSendableArrayBuffer(0); + SendableArrayBuffer.prototype.slice.call(sab); +}, "`this` value cannot be a SharedSendableArrayBuffer"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/tointeger-conversion-end.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/tointeger-conversion-end.js new file mode 100644 index 00000000000..832d6eba7d3 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/tointeger-conversion-end.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + The `end` index parameter is converted to an integral numeric value. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 9. If end is undefined, let relativeEnd be len; else let relativeEnd be ToInteger(end). + 10. ReturnIfAbrupt(relativeEnd). + ... +---*/ + +var arrayBuffer = new SendableArrayBuffer(8); + +var start = 0, + end = 4.5; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 4, "slice(0, 4.5)"); + +var start = 0, + end = NaN; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 0, "slice(0, NaN)"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/tointeger-conversion-start.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/tointeger-conversion-start.js new file mode 100644 index 00000000000..526febd541e --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/tointeger-conversion-start.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.slice +description: > + The `start` index parameter is converted to an integral numeric value. +info: | + SendableArrayBuffer.prototype.slice ( start, end ) + + ... + 6. Let relativeStart be ToInteger(start). + 7. ReturnIfAbrupt(relativeStart). + ... +---*/ + +var arrayBuffer = new SendableArrayBuffer(8); + +var start = 4.5, + end = 8; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 4, "slice(4.5, 8)"); + +var start = NaN, + end = 8; +var result = arrayBuffer.slice(start, end); +assert.sameValue(result.byteLength, 8, "slice(NaN, 8)"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/descriptor.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/descriptor.js new file mode 100644 index 00000000000..c859fabd06c --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/descriptor.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: > + SendableArrayBuffer.prototype.transfer has default data property attributes. +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 17 ECMAScript Standard Built-in Objects: + 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] +features: [arraybuffer-transfer] +---*/ + +verifyProperty(SendableArrayBuffer.prototype, 'transfer', { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/extensible.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/extensible.js new file mode 100644 index 00000000000..414fd4924f0 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/extensible.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: SendableArrayBuffer.prototype.transfer is extensible. +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 17 ECMAScript Standard Built-in Objects: + Unless specified otherwise, the [[Extensible]] internal slot + of a built-in object initially has the value true. +features: [arraybuffer-transfer] +---*/ + +assert(Object.isExtensible(SendableArrayBuffer.prototype.transfer)); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger-no-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger-no-resizable.js new file mode 100644 index 00000000000..26a3c514be7 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger-no-resizable.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: Transfering from a fixed-size SendableArrayBuffer into a larger SendableArrayBuffer +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. If newLength is undefined, let newByteLength be + O.[[SendableArrayBufferByteLength]]. + 6. Else, let newByteLength be ? ToIntegerOrInfinity(newLength). + 7. Let new be ? Construct(%SendableArrayBuffer%, « 𝔽(newByteLength) »). + 8. NOTE: This method returns a fixed-length SendableArrayBuffer. + 9. Let copyLength be min(newByteLength, O.[[SendableArrayBufferByteLength]]). + 10. Let fromBlock be O.[[SendableArrayBufferData]]. + 11. Let toBlock be new.[[SendableArrayBufferData]]. + 12. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength). + 13. NOTE: Neither creation of the new Data Block nor copying from the old + Data Block are observable. Implementations reserve the right to implement + this method as a zero-copy move or a realloc. + 14. Perform ! DetachSendableArrayBuffer(O). + 15. Return new. +features: [arraybuffer-transfer] +---*/ + +// NOTE: This file is a copy of "from-fixed-to-larger.js" with the resizable +// SendableArrayBuffer parts removed, so it can run in implementations which don't yet +// support the "resizable-arraybuffer" feature. + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transfer(5); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.byteLength, 5, 'dest.byteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); +assert.sameValue(destArray[3], 4, 'destArray[3]'); +assert.sameValue(destArray[4], 0, 'destArray[4]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger.js new file mode 100644 index 00000000000..71b6876214b --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: Transfering from a fixed-size SendableArrayBuffer into a larger SendableArrayBuffer +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. If newLength is undefined, let newByteLength be + O.[[SendableArrayBufferByteLength]]. + 6. Else, let newByteLength be ? ToIntegerOrInfinity(newLength). + 7. Let new be ? Construct(%SendableArrayBuffer%, « 𝔽(newByteLength) »). + 8. NOTE: This method returns a fixed-length SendableArrayBuffer. + 9. Let copyLength be min(newByteLength, O.[[SendableArrayBufferByteLength]]). + 10. Let fromBlock be O.[[SendableArrayBufferData]]. + 11. Let toBlock be new.[[SendableArrayBufferData]]. + 12. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength). + 13. NOTE: Neither creation of the new Data Block nor copying from the old + Data Block are observable. Implementations reserve the right to implement + this method as a zero-copy move or a realloc. + 14. Perform ! DetachSendableArrayBuffer(O). + 15. Return new. +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transfer(5); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, false, 'dest.resizable'); +assert.sameValue(dest.byteLength, 5, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 5, 'dest.maxByteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); +assert.sameValue(destArray[3], 4, 'destArray[3]'); +assert.sameValue(destArray[4], 0, 'destArray[4]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same-no-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same-no-resizable.js new file mode 100644 index 00000000000..17d679da5b6 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same-no-resizable.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: | + Transfering from a fixed-size SendableArrayBuffer into an SendableArrayBuffer with the same + byte length +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. If newLength is undefined, let newByteLength be + O.[[SendableArrayBufferByteLength]]. + 6. Else, let newByteLength be ? ToIntegerOrInfinity(newLength). + 7. Let new be ? Construct(%SendableArrayBuffer%, « 𝔽(newByteLength) »). + 8. NOTE: This method returns a fixed-length SendableArrayBuffer. + 9. Let copyLength be min(newByteLength, O.[[SendableArrayBufferByteLength]]). + 10. Let fromBlock be O.[[SendableArrayBufferData]]. + 11. Let toBlock be new.[[SendableArrayBufferData]]. + 12. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength). + 13. NOTE: Neither creation of the new Data Block nor copying from the old + Data Block are observable. Implementations reserve the right to implement + this method as a zero-copy move or a realloc. + 14. Perform ! DetachSendableArrayBuffer(O). + 15. Return new. +features: [arraybuffer-transfer] +---*/ + +// NOTE: This file is a copy of "from-fixed-to-same.js" with the resizable +// SendableArrayBuffer parts removed, so it can run in implementations which don't yet +// support the "resizable-arraybuffer" feature. + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transfer(); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.byteLength, 4, 'dest.byteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); +assert.sameValue(destArray[3], 4, 'destArray[3]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same.js new file mode 100644 index 00000000000..e8760a79688 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: | + Transfering from a fixed-size SendableArrayBuffer into an SendableArrayBuffer with the same + byte length +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. If newLength is undefined, let newByteLength be + O.[[SendableArrayBufferByteLength]]. + 6. Else, let newByteLength be ? ToIntegerOrInfinity(newLength). + 7. Let new be ? Construct(%SendableArrayBuffer%, « 𝔽(newByteLength) »). + 8. NOTE: This method returns a fixed-length SendableArrayBuffer. + 9. Let copyLength be min(newByteLength, O.[[SendableArrayBufferByteLength]]). + 10. Let fromBlock be O.[[SendableArrayBufferData]]. + 11. Let toBlock be new.[[SendableArrayBufferData]]. + 12. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength). + 13. NOTE: Neither creation of the new Data Block nor copying from the old + Data Block are observable. Implementations reserve the right to implement + this method as a zero-copy move or a realloc. + 14. Perform ! DetachSendableArrayBuffer(O). + 15. Return new. +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transfer(); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, false, 'dest.resizable'); +assert.sameValue(dest.byteLength, 4, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 4, 'dest.maxByteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); +assert.sameValue(destArray[3], 4, 'destArray[3]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller-no-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller-no-resizable.js new file mode 100644 index 00000000000..1ebdb28ce93 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller-no-resizable.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: Transfering from a fixed-size SendableArrayBuffer into a smaller SendableArrayBuffer +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. If newLength is undefined, let newByteLength be + O.[[SendableArrayBufferByteLength]]. + 6. Else, let newByteLength be ? ToIntegerOrInfinity(newLength). + 7. Let new be ? Construct(%SendableArrayBuffer%, « 𝔽(newByteLength) »). + 8. NOTE: This method returns a fixed-length SendableArrayBuffer. + 9. Let copyLength be min(newByteLength, O.[[SendableArrayBufferByteLength]]). + 10. Let fromBlock be O.[[SendableArrayBufferData]]. + 11. Let toBlock be new.[[SendableArrayBufferData]]. + 12. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength). + 13. NOTE: Neither creation of the new Data Block nor copying from the old + Data Block are observable. Implementations reserve the right to implement + this method as a zero-copy move or a realloc. + 14. Perform ! DetachSendableArrayBuffer(O). + 15. Return new. +features: [arraybuffer-transfer] +---*/ + +// NOTE: This file is a copy of "from-fixed-to-smaller.js" with the resizable +// SendableArrayBuffer parts removed, so it can run in implementations which don't yet +// support the "resizable-arraybuffer" feature. + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transfer(3); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.byteLength, 3, 'dest.byteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller.js new file mode 100644 index 00000000000..87197b259a6 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: Transfering from a fixed-size SendableArrayBuffer into a smaller SendableArrayBuffer +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. If newLength is undefined, let newByteLength be + O.[[SendableArrayBufferByteLength]]. + 6. Else, let newByteLength be ? ToIntegerOrInfinity(newLength). + 7. Let new be ? Construct(%SendableArrayBuffer%, « 𝔽(newByteLength) »). + 8. NOTE: This method returns a fixed-length SendableArrayBuffer. + 9. Let copyLength be min(newByteLength, O.[[SendableArrayBufferByteLength]]). + 10. Let fromBlock be O.[[SendableArrayBufferData]]. + 11. Let toBlock be new.[[SendableArrayBufferData]]. + 12. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength). + 13. NOTE: Neither creation of the new Data Block nor copying from the old + Data Block are observable. Implementations reserve the right to implement + this method as a zero-copy move or a realloc. + 14. Perform ! DetachSendableArrayBuffer(O). + 15. Return new. +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transfer(3); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, false, 'dest.resizable'); +assert.sameValue(dest.byteLength, 3, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 3, 'dest.maxByteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero-no-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero-no-resizable.js new file mode 100644 index 00000000000..2a600e96ee8 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero-no-resizable.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: Transfering from a fixed-size SendableArrayBuffer into a zero-length SendableArrayBuffer +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. If newLength is undefined, let newByteLength be + O.[[SendableArrayBufferByteLength]]. + 6. Else, let newByteLength be ? ToIntegerOrInfinity(newLength). + 7. Let new be ? Construct(%SendableArrayBuffer%, « 𝔽(newByteLength) »). + 8. NOTE: This method returns a fixed-length SendableArrayBuffer. + 9. Let copyLength be min(newByteLength, O.[[SendableArrayBufferByteLength]]). + 10. Let fromBlock be O.[[SendableArrayBufferData]]. + 11. Let toBlock be new.[[SendableArrayBufferData]]. + 12. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength). + 13. NOTE: Neither creation of the new Data Block nor copying from the old + Data Block are observable. Implementations reserve the right to implement + this method as a zero-copy move or a realloc. + 14. Perform ! DetachSendableArrayBuffer(O). + 15. Return new. +features: [arraybuffer-transfer] +---*/ + +// NOTE: This file is a copy of "from-fixed-to-zero.js" with the resizable +// SendableArrayBuffer parts removed, so it can run in implementations which don't yet +// support the "resizable-arraybuffer" feature. + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transfer(0); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.byteLength, 0, 'dest.byteLength'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero.js new file mode 100644 index 00000000000..a4e43e40fdb --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: Transfering from a fixed-size SendableArrayBuffer into a zero-length SendableArrayBuffer +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. If newLength is undefined, let newByteLength be + O.[[SendableArrayBufferByteLength]]. + 6. Else, let newByteLength be ? ToIntegerOrInfinity(newLength). + 7. Let new be ? Construct(%SendableArrayBuffer%, « 𝔽(newByteLength) »). + 8. NOTE: This method returns a fixed-length SendableArrayBuffer. + 9. Let copyLength be min(newByteLength, O.[[SendableArrayBufferByteLength]]). + 10. Let fromBlock be O.[[SendableArrayBufferData]]. + 11. Let toBlock be new.[[SendableArrayBufferData]]. + 12. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength). + 13. NOTE: Neither creation of the new Data Block nor copying from the old + Data Block are observable. Implementations reserve the right to implement + this method as a zero-copy move or a realloc. + 14. Perform ! DetachSendableArrayBuffer(O). + 15. Return new. +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transfer(0); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, false, 'dest.resizable'); +assert.sameValue(dest.byteLength, 0, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 0, 'dest.maxByteLength'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-larger.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-larger.js new file mode 100644 index 00000000000..516389f9b09 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-larger.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: Transfering from a resizable SendableArrayBuffer into a larger SendableArrayBuffer +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. If newLength is undefined, let newByteLength be + O.[[SendableArrayBufferByteLength]]. + 6. Else, let newByteLength be ? ToIntegerOrInfinity(newLength). + 7. Let new be ? Construct(%SendableArrayBuffer%, « 𝔽(newByteLength) »). + 8. NOTE: This method returns a fixed-length SendableArrayBuffer. + 9. Let copyLength be min(newByteLength, O.[[SendableArrayBufferByteLength]]). + 10. Let fromBlock be O.[[SendableArrayBufferData]]. + 11. Let toBlock be new.[[SendableArrayBufferData]]. + 12. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength). + 13. NOTE: Neither creation of the new Data Block nor copying from the old + Data Block are observable. Implementations reserve the right to implement + this method as a zero-copy move or a realloc. + 14. Perform ! DetachSendableArrayBuffer(O). + 15. Return new. +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4, { maxByteLength: 8 }); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transfer(5); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, true, 'dest.resizable'); +assert.sameValue(dest.byteLength, 5, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 8, 'dest.maxByteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); +assert.sameValue(destArray[3], 4, 'destArray[3]'); +assert.sameValue(destArray[4], 0, 'destArray[4]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-same.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-same.js new file mode 100644 index 00000000000..854eacefa29 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-same.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: | + Transfering from a resizable SendableArrayBuffer into an SendableArrayBuffer with the same + byte length +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. If newLength is undefined, let newByteLength be + O.[[SendableArrayBufferByteLength]]. + 6. Else, let newByteLength be ? ToIntegerOrInfinity(newLength). + 7. Let new be ? Construct(%SendableArrayBuffer%, « 𝔽(newByteLength) »). + 8. NOTE: This method returns a fixed-length SendableArrayBuffer. + 9. Let copyLength be min(newByteLength, O.[[SendableArrayBufferByteLength]]). + 10. Let fromBlock be O.[[SendableArrayBufferData]]. + 11. Let toBlock be new.[[SendableArrayBufferData]]. + 12. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength). + 13. NOTE: Neither creation of the new Data Block nor copying from the old + Data Block are observable. Implementations reserve the right to implement + this method as a zero-copy move or a realloc. + 14. Perform ! DetachSendableArrayBuffer(O). + 15. Return new. +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4, { maxByteLength: 8 }); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transfer(); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, true, 'dest.resizable'); +assert.sameValue(dest.byteLength, 4, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 8, 'dest.maxByteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); +assert.sameValue(destArray[3], 4, 'destArray[3]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-smaller.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-smaller.js new file mode 100644 index 00000000000..c83e80485e7 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-smaller.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: Transfering from a resizable SendableArrayBuffer into a smaller SendableArrayBuffer +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. If newLength is undefined, let newByteLength be + O.[[SendableArrayBufferByteLength]]. + 6. Else, let newByteLength be ? ToIntegerOrInfinity(newLength). + 7. Let new be ? Construct(%SendableArrayBuffer%, « 𝔽(newByteLength) »). + 8. NOTE: This method returns a fixed-length SendableArrayBuffer. + 9. Let copyLength be min(newByteLength, O.[[SendableArrayBufferByteLength]]). + 10. Let fromBlock be O.[[SendableArrayBufferData]]. + 11. Let toBlock be new.[[SendableArrayBufferData]]. + 12. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength). + 13. NOTE: Neither creation of the new Data Block nor copying from the old + Data Block are observable. Implementations reserve the right to implement + this method as a zero-copy move or a realloc. + 14. Perform ! DetachSendableArrayBuffer(O). + 15. Return new. +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4, { maxByteLength: 8 }); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transfer(3); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, true, 'dest.resizable'); +assert.sameValue(dest.byteLength, 3, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 8, 'dest.maxByteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-zero.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-zero.js new file mode 100644 index 00000000000..6a164837cd2 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-zero.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: Transfering from a resizable SendableArrayBuffer into a zero-length SendableArrayBuffer +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. If newLength is undefined, let newByteLength be + O.[[SendableArrayBufferByteLength]]. + 6. Else, let newByteLength be ? ToIntegerOrInfinity(newLength). + 7. Let new be ? Construct(%SendableArrayBuffer%, « 𝔽(newByteLength) »). + 8. NOTE: This method returns a fixed-length SendableArrayBuffer. + 9. Let copyLength be min(newByteLength, O.[[SendableArrayBufferByteLength]]). + 10. Let fromBlock be O.[[SendableArrayBufferData]]. + 11. Let toBlock be new.[[SendableArrayBufferData]]. + 12. Perform CopyDataBlockBytes(toBlock, 0, fromBlock, 0, copyLength). + 13. NOTE: Neither creation of the new Data Block nor copying from the old + Data Block are observable. Implementations reserve the right to implement + this method as a zero-copy move or a realloc. + 14. Perform ! DetachSendableArrayBuffer(O). + 15. Return new. +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4, { maxByteLength: 8 }); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transfer(0); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, true, 'dest.resizable'); +assert.sameValue(dest.byteLength, 0, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 8, 'dest.maxByteLength'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/length.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/length.js new file mode 100644 index 00000000000..206aa0f3791 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: > + SendableArrayBuffer.prototype.transfer.length is 0. +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 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] +features: [arraybuffer-transfer] +---*/ + +verifyProperty(SendableArrayBuffer.prototype.transfer, 'length', { + value: 0, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/name.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/name.js new file mode 100644 index 00000000000..0f866e09cef --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: > + SendableArrayBuffer.prototype.transfer.name is "transfer". +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 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 }. +features: [arraybuffer-transfer] +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArrayBuffer.prototype.transfer, 'name', { + value: 'transfer', + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/new-length-excessive.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/new-length-excessive.js new file mode 100644 index 00000000000..5cc279b3291 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/new-length-excessive.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: > + Throws a RangeError if the newLength is larger than 2^53 - 1 due to clamping + in ToIndex. +features: [arraybuffer-transfer] +---*/ + +var ab = new SendableArrayBuffer(0); + +assert.throws(RangeError, function() { + // Math.pow(2, 53) = 9007199254740992 + ab.transfer(9007199254740992); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/new-length-non-number.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/new-length-non-number.js new file mode 100644 index 00000000000..31e73eaf021 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/new-length-non-number.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: Throws a TypeError if provided length cannot be coerced to a number +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. If newLength is undefined, let newByteLength be + O.[[SendableArrayBufferByteLength]]. + 6. Else, let newByteLength be ? ToIntegerOrInfinity(newLength). + [...] +features: [arraybuffer-transfer] +---*/ + +var log = []; +var newLength = { + toString: function() { + log.push('toString'); + return {}; + }, + valueOf: function() { + log.push('valueOf'); + return {}; + } +}; +var ab = new SendableArrayBuffer(0); + +assert.throws(TypeError, function() { + ab.transfer(newLength); +}); + +assert.sameValue(log.length, 2); +assert.sameValue(log[0], 'valueOf'); +assert.sameValue(log[1], 'toString'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/nonconstructor.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/nonconstructor.js new file mode 100644 index 00000000000..2a364cf9b43 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/nonconstructor.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: > + SendableArrayBuffer.prototype.transfer is not a constructor function. +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 17 ECMAScript Standard Built-in 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. +includes: [isConstructor.js] +features: [arraybuffer-transfer, Reflect.construct] +---*/ + +assert(!isConstructor(SendableArrayBuffer.prototype.transfer), "SendableArrayBuffer.prototype.transfer is not a constructor"); + +var arrayBuffer = new SendableArrayBuffer(8); +assert.throws(TypeError, function() { + new arrayBuffer.transfer(); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-detached.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-detached.js new file mode 100644 index 00000000000..0d72ab175f3 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-detached.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: > + Throws a TypeError if `this` does not have an [[SendableArrayBufferData]] internal slot. +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + [...] +includes: [detachSendableArrayBuffer.js] +features: [arraybuffer-transfer] +---*/ + +assert.sameValue(typeof SendableArrayBuffer.prototype.transfer, 'function'); + +var ab = new SendableArrayBuffer(1); + +$DETACHBUFFER(ab); + +assert.throws(TypeError, function() { + ab.transfer(); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-not-arraybuffer-object.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-not-arraybuffer-object.js new file mode 100644 index 00000000000..d6931265133 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-not-arraybuffer-object.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: > + Throws a TypeError if `this` does not have an [[SendableArrayBufferData]] internal slot. +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] +features: [arraybuffer-transfer] +---*/ + +assert.sameValue(typeof SendableArrayBuffer.prototype.transfer, 'function'); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transfer(); +}, '`this` value is the SendableArrayBuffer prototype'); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transfer.call({}); +}, '`this` value is an object'); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transfer.call([]); +}, '`this` value is an array'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-not-object.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-not-object.js new file mode 100644 index 00000000000..79ccb4951c9 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-not-object.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: Throws a TypeError if `this` valueis not an object. +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] +features: [arraybuffer-transfer, Symbol, BigInt] +---*/ + +assert.sameValue(typeof SendableArrayBuffer.prototype.transfer, "function"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transfer.call(undefined); +}, "`this` value is undefined"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transfer.call(null); +}, "`this` value is null"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transfer.call(true); +}, "`this` value is Boolean"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transfer.call(""); +}, "`this` value is String"); + +var symbol = Symbol(); +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transfer.call(symbol); +}, "`this` value is Symbol"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transfer.call(1); +}, "`this` value is Number"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transfer.call(1n); +}, "`this` value is bigint"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-sharedarraybuffer.js new file mode 100644 index 00000000000..97ff67dfd6e --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-sharedarraybuffer.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfer +description: Throws a TypeError if `this` value is a SharedSendableArrayBuffer +info: | + SendableArrayBuffer.prototype.transfer ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + [...] +features: [SharedSendableArrayBuffer, arraybuffer-transfer] +---*/ + +var sab = new SharedSendableArrayBuffer(0); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transfer.call(sab); +}, '`this` value cannot be a SharedSendableArrayBuffer'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/descriptor.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/descriptor.js new file mode 100644 index 00000000000..c1d94bd3bce --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/descriptor.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: > + SendableArrayBuffer.prototype.transferToFixedLength has default data property + attributes. +info: | + SendableArrayBuffer.prototype.transferToFixedLength ( [ newLength ] ) + + 17 ECMAScript Standard Built-in Objects: + 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] +features: [arraybuffer-transfer] +---*/ + +verifyProperty(SendableArrayBuffer.prototype, 'transferToFixedLength', { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/extensible.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/extensible.js new file mode 100644 index 00000000000..286635ea02b --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/extensible.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: SendableArrayBuffer.prototype.transferToFixedLength is extensible. +info: | + SendableArrayBuffer.prototype.transferToFixedLength ( [ newLength ] ) + + 17 ECMAScript Standard Built-in Objects: + Unless specified otherwise, the [[Extensible]] internal slot + of a built-in object initially has the value true. +features: [arraybuffer-transfer] +---*/ + +assert(Object.isExtensible(SendableArrayBuffer.prototype.transferToFixedLength)); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-larger-no-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-larger-no-resizable.js new file mode 100644 index 00000000000..683b1ed52b1 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-larger-no-resizable.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: Transfering from a fixed-size SendableArrayBuffer into a larger SendableArrayBuffer +features: [arraybuffer-transfer] +---*/ + +// NOTE: This file is a copy of "from-fixed-to-larger.js" with the resizable +// SendableArrayBuffer parts removed, so it can run in implementations which don't yet +// support the "resizable-arraybuffer" feature. + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transferToFixedLength(5); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.byteLength, 5, 'dest.byteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); +assert.sameValue(destArray[3], 4, 'destArray[3]'); +assert.sameValue(destArray[4], 0, 'destArray[4]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-larger.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-larger.js new file mode 100644 index 00000000000..6f1ecc80bd8 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-larger.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: Transfering from a fixed-size SendableArrayBuffer into a larger SendableArrayBuffer +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transferToFixedLength(5); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, false, 'dest.resizable'); +assert.sameValue(dest.byteLength, 5, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 5, 'dest.maxByteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); +assert.sameValue(destArray[3], 4, 'destArray[3]'); +assert.sameValue(destArray[4], 0, 'destArray[4]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-same-no-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-same-no-resizable.js new file mode 100644 index 00000000000..46059bb568d --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-same-no-resizable.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: | + Transfering from a fixed-size SendableArrayBuffer into an SendableArrayBuffer with the same + byte length +features: [arraybuffer-transfer] +---*/ + +// NOTE: This file is a copy of "from-fixed-to-same.js" with the resizable +// SendableArrayBuffer parts removed, so it can run in implementations which don't yet +// support the "resizable-arraybuffer" feature. + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transferToFixedLength(); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.byteLength, 4, 'dest.byteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); +assert.sameValue(destArray[3], 4, 'destArray[3]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-same.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-same.js new file mode 100644 index 00000000000..e354a800d9f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-same.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: | + Transfering from a fixed-size SendableArrayBuffer into an SendableArrayBuffer with the same + byte length +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transferToFixedLength(); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, false, 'dest.resizable'); +assert.sameValue(dest.byteLength, 4, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 4, 'dest.maxByteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); +assert.sameValue(destArray[3], 4, 'destArray[3]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-smaller-no-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-smaller-no-resizable.js new file mode 100644 index 00000000000..15d1babc796 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-smaller-no-resizable.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: Transfering from a fixed-size SendableArrayBuffer into a smaller SendableArrayBuffer +features: [arraybuffer-transfer] +---*/ + +// NOTE: This file is a copy of "from-fixed-to-samller.js" with the resizable +// SendableArrayBuffer parts removed, so it can run in implementations which don't yet +// support the "resizable-arraybuffer" feature. + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transferToFixedLength(3); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.byteLength, 3, 'dest.byteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-smaller.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-smaller.js new file mode 100644 index 00000000000..079ecc0eb70 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-smaller.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: Transfering from a fixed-size SendableArrayBuffer into a smaller SendableArrayBuffer +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transferToFixedLength(3); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, false, 'dest.resizable'); +assert.sameValue(dest.byteLength, 3, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 3, 'dest.maxByteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-zero-no-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-zero-no-resizable.js new file mode 100644 index 00000000000..422445cc86e --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-zero-no-resizable.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: Transfering from a fixed-size SendableArrayBuffer into a zero-length SendableArrayBuffer +features: [arraybuffer-transfer] +---*/ + +// NOTE: This file is a copy of "from-fixed-to-zero.js" with the resizable +// SendableArrayBuffer parts removed, so it can run in implementations which don't yet +// support the "resizable-arraybuffer" feature. + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transferToFixedLength(0); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.byteLength, 0, 'dest.byteLength'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-zero.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-zero.js new file mode 100644 index 00000000000..6b6974d42d2 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-fixed-to-zero.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: Transfering from a fixed-size SendableArrayBuffer into a zero-length SendableArrayBuffer +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transferToFixedLength(0); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, false, 'dest.resizable'); +assert.sameValue(dest.byteLength, 0, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 0, 'dest.maxByteLength'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-larger.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-larger.js new file mode 100644 index 00000000000..e9cd06fee94 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-larger.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: Transfering from a resizable SendableArrayBuffer into a larger SendableArrayBuffer +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4, { maxByteLength: 8 }); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transferToFixedLength(5); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, false, 'dest.resizable'); +assert.sameValue(dest.byteLength, 5, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 5, 'dest.maxByteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); +assert.sameValue(destArray[3], 4, 'destArray[3]'); +assert.sameValue(destArray[4], 0, 'destArray[4]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-same.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-same.js new file mode 100644 index 00000000000..5efeb5d5e0a --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-same.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: | + Transfering from a resizable SendableArrayBuffer into an SendableArrayBuffer with the same + byte length +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4, { maxByteLength: 8 }); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transferToFixedLength(); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, false, 'dest.resizable'); +assert.sameValue(dest.byteLength, 4, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 4, 'dest.maxByteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); +assert.sameValue(destArray[3], 4, 'destArray[3]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-smaller.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-smaller.js new file mode 100644 index 00000000000..5192f7ea097 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-smaller.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: Transfering from a resizable SendableArrayBuffer into a smaller SendableArrayBuffer +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4, { maxByteLength: 8 }); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transferToFixedLength(3); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, false, 'dest.resizable'); +assert.sameValue(dest.byteLength, 3, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 3, 'dest.maxByteLength'); + +var destArray = new Uint8Array(dest); + +assert.sameValue(destArray[0], 1, 'destArray[0]'); +assert.sameValue(destArray[1], 2, 'destArray[1]'); +assert.sameValue(destArray[2], 3, 'destArray[2]'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-zero.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-zero.js new file mode 100644 index 00000000000..43f4c96bd40 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/from-resizable-to-zero.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: Transfering from a resizable SendableArrayBuffer into a zero-length SendableArrayBuffer +features: [resizable-arraybuffer, arraybuffer-transfer] +---*/ + +var source = new SendableArrayBuffer(4, { maxByteLength: 8 }); + +var sourceArray = new Uint8Array(source); +sourceArray[0] = 1; +sourceArray[1] = 2; +sourceArray[2] = 3; +sourceArray[3] = 4; + +var dest = source.transferToFixedLength(0); + +assert.sameValue(source.byteLength, 0, 'source.byteLength'); +assert.throws(TypeError, function() { + source.slice(); +}); + +assert.sameValue(dest.resizable, false, 'dest.resizable'); +assert.sameValue(dest.byteLength, 0, 'dest.byteLength'); +assert.sameValue(dest.maxByteLength, 0, 'dest.maxByteLength'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/length.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/length.js new file mode 100644 index 00000000000..21ac516269d --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: > + SendableArrayBuffer.prototype.transferToFixedLength.length is 0. +info: | + SendableArrayBuffer.prototype.transferToFixedLength ( [ newLength ] ) + + 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] +features: [arraybuffer-transfer] +---*/ + +verifyProperty(SendableArrayBuffer.prototype.transferToFixedLength, 'length', { + value: 0, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/name.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/name.js new file mode 100644 index 00000000000..ec77e4d22ca --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: > + SendableArrayBuffer.prototype.transferToFixedLength.name is "transfer". +info: | + SendableArrayBuffer.prototype.transferToFixedLength ( [ newLength ] ) + + 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 }. +features: [arraybuffer-transfer] +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArrayBuffer.prototype.transferToFixedLength, 'name', { + value: 'transferToFixedLength', + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/new-length-excessive.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/new-length-excessive.js new file mode 100644 index 00000000000..15365851783 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/new-length-excessive.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: > + Throws a RangeError if the newLength is larger than 2^53 - 1 due to clamping + in ToIndex. +features: [arraybuffer-transfer] +---*/ + +var ab = new SendableArrayBuffer(0); + +assert.throws(RangeError, function() { + // Math.pow(2, 53) = 9007199254740992 + ab.transferToFixedLength(9007199254740992); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/new-length-non-number.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/new-length-non-number.js new file mode 100644 index 00000000000..96668ed1b57 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/new-length-non-number.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: Throws a TypeError if provided length cannot be coerced to a number +info: | + SendableArrayBuffer.prototype.transferToFixedLength ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + 5. If newLength is undefined, let newByteLength be + O.[[SendableArrayBufferByteLength]]. + 6. Else, let newByteLength be ? ToIntegerOrInfinity(newLength). + [...] +features: [arraybuffer-transfer] +---*/ + +var log = []; +var newLength = { + toString: function() { + log.push('toString'); + return {}; + }, + valueOf: function() { + log.push('valueOf'); + return {}; + } +}; +var ab = new SendableArrayBuffer(0); + +assert.throws(TypeError, function() { + ab.transferToFixedLength(newLength); +}); + +assert.sameValue(log.length, 2); +assert.sameValue(log[0], 'valueOf'); +assert.sameValue(log[1], 'toString'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/nonconstructor.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/nonconstructor.js new file mode 100644 index 00000000000..97bb42a0ed5 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/nonconstructor.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: > + SendableArrayBuffer.prototype.transferToFixedLength is not a constructor function. +info: | + SendableArrayBuffer.prototype.transferToFixedLength ( [ newLength ] ) + + 17 ECMAScript Standard Built-in 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. +includes: [isConstructor.js] +features: [arraybuffer-transfer, Reflect.construct] +---*/ + +assert(!isConstructor(SendableArrayBuffer.prototype.transferToFixedLength), "SendableArrayBuffer.prototype.transferToFixedLength is not a constructor"); + +var arrayBuffer = new SendableArrayBuffer(8); +assert.throws(TypeError, function() { + new arrayBuffer.transfer(); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-detached.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-detached.js new file mode 100644 index 00000000000..13e6333fce8 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-detached.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: > + Throws a TypeError if `this` does not have an [[SendableArrayBufferData]] internal slot. +info: | + SendableArrayBuffer.prototype.transferToFixedLength ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. + [...] +includes: [detachSendableArrayBuffer.js] +features: [arraybuffer-transfer] +---*/ + +assert.sameValue(typeof SendableArrayBuffer.prototype.transferToFixedLength, 'function'); + +var ab = new SendableArrayBuffer(1); + +$DETACHBUFFER(ab); + +assert.throws(TypeError, function() { + ab.transferToFixedLength(); +}); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-not-arraybuffer-object.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-not-arraybuffer-object.js new file mode 100644 index 00000000000..c8ca0a6345f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-not-arraybuffer-object.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: > + Throws a TypeError if `this` does not have an [[SendableArrayBufferData]] internal slot. +info: | + SendableArrayBuffer.prototype.transferToFixedLength ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] +features: [arraybuffer-transfer] +---*/ + +assert.sameValue(typeof SendableArrayBuffer.prototype.transferToFixedLength, 'function'); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transferToFixedLength(); +}, '`this` value is the SendableArrayBuffer prototype'); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transferToFixedLength.call({}); +}, '`this` value is an object'); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transferToFixedLength.call([]); +}, '`this` value is an array'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-not-object.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-not-object.js new file mode 100644 index 00000000000..06d57cffc3f --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-not-object.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: Throws a TypeError if `this` valueis not an object. +info: | + SendableArrayBuffer.prototype.transferToFixedLength ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + [...] +features: [arraybuffer-transfer, Symbol, BigInt] +---*/ + +assert.sameValue(typeof SendableArrayBuffer.prototype.transferToFixedLength, "function"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transferToFixedLength.call(undefined); +}, "`this` value is undefined"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transferToFixedLength.call(null); +}, "`this` value is null"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transferToFixedLength.call(true); +}, "`this` value is Boolean"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transferToFixedLength.call(""); +}, "`this` value is String"); + +var symbol = Symbol(); +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transferToFixedLength.call(symbol); +}, "`this` value is Symbol"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transferToFixedLength.call(1); +}, "`this` value is Number"); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transferToFixedLength.call(1n); +}, "`this` value is bigint"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-sharedarraybuffer.js new file mode 100644 index 00000000000..36afb320409 --- /dev/null +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-sharedarraybuffer.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-sendableArraybuffer.prototype.transfertofixedlength +description: Throws a TypeError if `this` value is a SharedSendableArrayBuffer +info: | + SendableArrayBuffer.prototype.transferToFixedLength ( [ newLength ] ) + + 1. Let O be the this value. + 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). + 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + [...] +features: [SharedSendableArrayBuffer, arraybuffer-transfer] +---*/ + +var sab = new SharedSendableArrayBuffer(0); + +assert.throws(TypeError, function() { + SendableArrayBuffer.prototype.transferToFixedLength.call(sab); +}, '`this` value cannot be a SharedSendableArrayBuffer'); -- Gitee From 2224ef36901838923de9103adbeaee4d2733367f Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 24 Dec 2024 15:29:32 +0800 Subject: [PATCH 36/93] add array-findindex Signed-off-by: zhuzhihui7 --- .../findIndex/array-altered-during-loop.js | 44 +++++++++ .../prototype/findIndex/call-with-boolean.js | 29 ++++++ .../callbackfn-resize-arraybuffer.js | 78 +++++++++++++++ .../Array/prototype/findIndex/length.js | 28 ++++++ .../Array/prototype/findIndex/name.js | 30 ++++++ .../prototype/findIndex/not-a-constructor.js | 29 ++++++ .../findIndex/predicate-call-parameters.js | 41 ++++++++ .../predicate-call-this-non-strict.js | 30 ++++++ .../findIndex/predicate-call-this-strict.js | 30 ++++++ ...redicate-called-for-each-array-property.js | 26 +++++ .../predicate-is-not-callable-throws.js | 47 +++++++++ .../predicate-not-called-on-empty-array.js | 34 +++++++ .../Array/prototype/findIndex/prop-desc.js | 32 +++++++ .../resizable-buffer-grow-mid-iteration.js | 95 +++++++++++++++++++ .../resizable-buffer-shrink-mid-iteration.js | 93 ++++++++++++++++++ .../prototype/findIndex/resizable-buffer.js | 86 +++++++++++++++++ .../return-abrupt-from-predicate-call.js | 26 +++++ .../findIndex/return-abrupt-from-property.js | 31 ++++++ ...eturn-abrupt-from-this-length-as-symbol.js | 26 +++++ .../return-abrupt-from-this-length.js | 47 +++++++++ .../findIndex/return-abrupt-from-this.js | 31 ++++++ .../return-index-predicate-result-is-true.js | 55 +++++++++++ ...ve-one-if-predicate-returns-false-value.js | 48 ++++++++++ 23 files changed, 1016 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/findIndex/array-altered-during-loop.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/callbackfn-resize-arraybuffer.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/length.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/name.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/predicate-call-parameters.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/predicate-call-this-non-strict.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/predicate-call-this-strict.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/predicate-called-for-each-array-property.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/predicate-is-not-callable-throws.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/predicate-not-called-on-empty-array.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-predicate-call.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-property.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-this-length-as-symbol.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-this-length.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-this.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/return-index-predicate-result-is-true.js create mode 100644 test/sendable/builtins/Array/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js diff --git a/test/sendable/builtins/Array/prototype/findIndex/array-altered-during-loop.js b/test/sendable/builtins/Array/prototype/findIndex/array-altered-during-loop.js new file mode 100644 index 00000000000..f8f23bb90ef --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/array-altered-during-loop.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + The range of elements processed is set before the first call to `predicate`. +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var results = []; +arr.findIndex(function(kValue) { + if (results.length === 0) { + arr.splice(1, 1); + } + results.push(kValue); +}); +assert.sameValue(results.length, 3, 'predicate called three times'); +assert.sameValue(results[0], 'Shoes'); +assert.sameValue(results[1], 'Bike'); +assert.sameValue(results[2], undefined); +results = []; +arr = ['Skateboard', 'Barefoot']; +arr.findIndex(function(kValue) { + if (results.length === 0) { + arr.push('Motorcycle'); + arr[1] = 'Magic Carpet'; + } + results.push(kValue); +}); +assert.sameValue(results.length, 2, 'predicate called twice'); +assert.sameValue(results[0], 'Skateboard'); +assert.sameValue(results[1], 'Magic Carpet'); diff --git a/test/sendable/builtins/Array/prototype/findIndex/call-with-boolean.js b/test/sendable/builtins/Array/prototype/findIndex/call-with-boolean.js new file mode 100644 index 00000000000..bd1266a7b15 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/call-with-boolean.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findIndex +description: Array.prototype.findIndex applied to boolean primitive +---*/ + +assert.sameValue( + SendableArray.prototype.findIndex.call(true, () => {}), + -1, + 'SendableArray.prototype.findIndex.call(true, () => {}) must return -1' +); +assert.sameValue( + SendableArray.prototype.findIndex.call(false, () => {}), + -1, + 'SendableArray.prototype.findIndex.call(false, () => {}) must return -1' +); diff --git a/test/sendable/builtins/Array/prototype/findIndex/callbackfn-resize-arraybuffer.js b/test/sendable/builtins/Array/prototype/findIndex/callbackfn-resize-arraybuffer.js new file mode 100644 index 00000000000..9d7d2ada667 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/callbackfn-resize-arraybuffer.js @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var finalElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + elements = []; + indices = []; + arrays = []; + result = SendableArray.prototype.findIndex.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + finalElement = undefined; + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + finalElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)'); + assert.compareArray(indices, [0, 1, 2], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, -1, 'result (shrink)'); + elements = []; + indices = []; + arrays = []; + result = SendableArray.prototype.findIndex.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, -1, 'result (grow)'); +}); diff --git a/test/sendable/builtins/Array/prototype/findIndex/length.js b/test/sendable/builtins/Array/prototype/findIndex/length.js new file mode 100644 index 00000000000..d3d9fa8c286 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/length.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: Array.prototype.findIndex.length value and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.prototype.findIndex, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/findIndex/name.js b/test/sendable/builtins/Array/prototype/findIndex/name.js new file mode 100644 index 00000000000..83b18d6e984 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/name.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Array.prototype.findIndex.name value and descriptor. +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate [ , thisArg ] ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.prototype.findIndex, "name", { + value: "findIndex", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/findIndex/not-a-constructor.js b/test/sendable/builtins/Array/prototype/findIndex/not-a-constructor.js new file mode 100644 index 00000000000..a57e9f53a11 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/not-a-constructor.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.findIndex does not implement [[Construct]], is not new-able +---*/ + +assert.sameValue( + isConstructor(SendableArray.prototype.findIndex), + false, + 'isConstructor(SendableArray.prototype.findIndex) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.findIndex(() => {}); +}); + diff --git a/test/sendable/builtins/Array/prototype/findIndex/predicate-call-parameters.js b/test/sendable/builtins/Array/prototype/findIndex/predicate-call-parameters.js new file mode 100644 index 00000000000..014dfd8ba91 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/predicate-call-parameters.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +---*/ + +var arr = ['Mike', 'Rick', 'Leo']; +var results = []; +arr.findIndex(function(kValue, k, O) { + results.push(arguments); +}); +assert.sameValue(results.length, 3); +var result = results[0]; +assert.sameValue(result[0], 'Mike'); +assert.sameValue(result[1], 0); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); +result = results[1]; +assert.sameValue(result[0], 'Rick'); +assert.sameValue(result[1], 1); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); +result = results[2]; +assert.sameValue(result[0], 'Leo'); +assert.sameValue(result[1], 2); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); diff --git a/test/sendable/builtins/Array/prototype/findIndex/predicate-call-this-non-strict.js b/test/sendable/builtins/Array/prototype/findIndex/predicate-call-this-non-strict.js new file mode 100644 index 00000000000..b70aec2789f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/predicate-call-this-non-strict.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +---*/ + +var result; +[1].find(function(kValue, k, O) { + result = this; +}); +assert.sameValue(result, this); +var o = {}; +[1].find(function() { + result = this; +}, o); +assert.sameValue(result, o); diff --git a/test/sendable/builtins/Array/prototype/findIndex/predicate-call-this-strict.js b/test/sendable/builtins/Array/prototype/findIndex/predicate-call-this-strict.js new file mode 100644 index 00000000000..16076b46c96 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/predicate-call-this-strict.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +---*/ + +var result; +[1].find(function(kValue, k, O) { + result = this; +}); +assert.sameValue(result, undefined); +var o = {}; +[1].find(function() { + result = this; +}, o); +assert.sameValue(result, o); diff --git a/test/sendable/builtins/Array/prototype/findIndex/predicate-called-for-each-array-property.js b/test/sendable/builtins/Array/prototype/findIndex/predicate-called-for-each-array-property.js new file mode 100644 index 00000000000..50e602e080e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/predicate-called-for-each-array-property.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Predicate is called for each array property. +---*/ + +var arr = [undefined, , , 'foo']; +var called = 0; +arr.findIndex(function() { + called++; +}); +assert.sameValue(called, 4); diff --git a/test/sendable/builtins/Array/prototype/findIndex/predicate-is-not-callable-throws.js b/test/sendable/builtins/Array/prototype/findIndex/predicate-is-not-callable-throws.js new file mode 100644 index 00000000000..c14d3ec8e1a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/predicate-is-not-callable-throws.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Throws a TypeError exception if predicate is not callable. +---*/ + +assert.throws(TypeError, function() { + [].findIndex({}); +}); +assert.throws(TypeError, function() { + [].findIndex(null); +}); +assert.throws(TypeError, function() { + [].findIndex(undefined); +}); +assert.throws(TypeError, function() { + [].findIndex(true); +}); +assert.throws(TypeError, function() { + [].findIndex(1); +}); +assert.throws(TypeError, function() { + [].findIndex(''); +}); +assert.throws(TypeError, function() { + [].findIndex(1); +}); +assert.throws(TypeError, function() { + [].findIndex([]); +}); +assert.throws(TypeError, function() { + [].findIndex(/./); +}); diff --git a/test/sendable/builtins/Array/prototype/findIndex/predicate-not-called-on-empty-array.js b/test/sendable/builtins/Array/prototype/findIndex/predicate-not-called-on-empty-array.js new file mode 100644 index 00000000000..e79f8380b9d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/predicate-not-called-on-empty-array.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Predicate is only called if this.length is > 0. +---*/ + +var called = false; +var predicate = function() { + called = true; + return true; +}; +var result = [].findIndex(predicate); +assert.sameValue( + called, false, + '[].findIndex(predicate) does not call predicate' +); +assert.sameValue( + result, -1, + '[].findIndex(predicate) returned undefined' +); diff --git a/test/sendable/builtins/Array/prototype/findIndex/prop-desc.js b/test/sendable/builtins/Array/prototype/findIndex/prop-desc.js new file mode 100644 index 00000000000..a55703890cf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: Property type and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableArray.prototype.findIndex, + 'function', + '`typeof SendableArray.prototype.findIndex` is `function`' +); +verifyProperty(SendableArray.prototype, "findIndex", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/findIndex/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/Array/prototype/findIndex/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..16a35f167bb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.findindex +description: > + Array.p.findIndex behaves correctly when receiver is backed by resizable + buffer that is grown mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findIndex.call(fixedLength, ResizeMidIteration), -1); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findIndex.call(fixedLengthWithOffset, ResizeMidIteration), -1); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findIndex.call(lengthTracking, ResizeMidIteration), -1); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findIndex.call(lengthTrackingWithOffset, ResizeMidIteration), -1); + assert.compareArray(values, [ + 4, + 6 + ]); +} + diff --git a/test/sendable/builtins/Array/prototype/findIndex/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/Array/prototype/findIndex/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..1a6c9e5f899 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Array.p.findIndex behaves correctly when receiver is backed by resizable + buffer that is shrunk mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findIndex.call(fixedLength, ResizeMidIteration), -1); + assert.compareArray(values, [ + 0, + 2, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findIndex.call(fixedLengthWithOffset, ResizeMidIteration), -1); + assert.compareArray(values, [ + 4, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findIndex.call(lengthTracking, ResizeMidIteration), -1); + assert.compareArray(values, [ + 0, + 2, + 4, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findIndex.call(lengthTrackingWithOffset, ResizeMidIteration), -1); + assert.compareArray(values, [ + 4, + undefined + ]); +} diff --git a/test/sendable/builtins/Array/prototype/findIndex/resizable-buffer.js b/test/sendable/builtins/Array/prototype/findIndex/resizable-buffer.js new file mode 100644 index 00000000000..9c3c075be5b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/resizable-buffer.js @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Array.p.findIndex behaves correctly when receiver is backed by resizable + buffer +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + function isTwoOrFour(n) { + return n == 2 || n == 4; + } + assert.sameValue(SendableArray.prototype.findIndex.call(fixedLength, isTwoOrFour), 1); + assert.sameValue(SendableArray.prototype.findIndex.call(fixedLengthWithOffset, isTwoOrFour), 0); + assert.sameValue(SendableArray.prototype.findIndex.call(lengthTracking, isTwoOrFour), 1); + assert.sameValue(SendableArray.prototype.findIndex.call(lengthTrackingWithOffset, isTwoOrFour), 0); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + assert.sameValue(SendableArray.prototype.findIndex.call(fixedLength, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findIndex.call(fixedLengthWithOffset, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findIndex.call(lengthTracking, isTwoOrFour), 1); + assert.sameValue(SendableArray.prototype.findIndex.call(lengthTrackingWithOffset, isTwoOrFour), 0); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.sameValue(SendableArray.prototype.findIndex.call(fixedLength, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findIndex.call(fixedLengthWithOffset, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findIndex.call(lengthTrackingWithOffset, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findIndex.call(lengthTracking, isTwoOrFour), -1); + // Shrink to zero. + rab.resize(0); + assert.sameValue(SendableArray.prototype.findIndex.call(fixedLength, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findIndex.call(fixedLengthWithOffset, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findIndex.call(lengthTrackingWithOffset, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findIndex.call(lengthTracking, isTwoOrFour), -1); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 0); + } + taWrite[4] = MayNeedBigInt(taWrite, 2); + taWrite[5] = MayNeedBigInt(taWrite, 4); + // Orig. array: [0, 0, 0, 0, 2, 4] + // [0, 0, 0, 0] << fixedLength + // [0, 0] << fixedLengthWithOffset + // [0, 0, 0, 0, 2, 4, ...] << lengthTracking + // [0, 0, 2, 4, ...] << lengthTrackingWithOffset + + assert.sameValue(SendableArray.prototype.findIndex.call(fixedLength, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findIndex.call(fixedLengthWithOffset, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findIndex.call(lengthTracking, isTwoOrFour), 4); + assert.sameValue(SendableArray.prototype.findIndex.call(lengthTrackingWithOffset, isTwoOrFour), 2); +} diff --git a/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-predicate-call.js b/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-predicate-call.js new file mode 100644 index 00000000000..13b5464dbf6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-predicate-call.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Return abrupt from predicate call. +---*/ + +var predicate = function() { + throw new Test262Error(); +}; +assert.throws(Test262Error, function() { + [1].findIndex(predicate); +}); diff --git a/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-property.js b/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-property.js new file mode 100644 index 00000000000..ef315feb159 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-property.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Returns abrupt from getting property value from `this`. +---*/ + +var o = { + length: 1 +}; +Object.defineProperty(o, 0, { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + [].findIndex.call(o, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-this-length-as-symbol.js b/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-this-length-as-symbol.js new file mode 100644 index 00000000000..af109491f5e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-this-length-as-symbol.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Return abrupt from ToLength(Get(O, "length")) where length is a Symbol. +---*/ + +var o = {}; +o.length = Symbol(1); +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + [].findIndex.call(o, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-this-length.js b/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-this-length.js new file mode 100644 index 00000000000..24b10e78ca5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-this-length.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Return abrupt from ToLength(Get(O, "length")). +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Let len be ToLength(Get(O, "length")). + 4. ReturnIfAbrupt(len). +---*/ + +var o1 = {}; +Object.defineProperty(o1, 'length', { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +// predicate fn is given to avoid false positives +assert.throws(Test262Error, function() { + [].findIndex.call(o1, function() {}); +}); +var o2 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; +assert.throws(Test262Error, function() { + [].findIndex.call(o2, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-this.js b/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-this.js new file mode 100644 index 00000000000..d86318274d0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/return-abrupt-from-this.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Return abrupt from ToObject(this value). +info: | + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + SendableArray.prototype.findIndex.call(undefined, function() {}); +}); +assert.throws(TypeError, function() { + SendableArray.prototype.findIndex.call(null, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/findIndex/return-index-predicate-result-is-true.js b/test/sendable/builtins/Array/prototype/findIndex/return-index-predicate-result-is-true.js new file mode 100644 index 00000000000..60e89111ddc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/return-index-predicate-result-is-true.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Return index if predicate return a boolean true value. +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; +var result = arr.findIndex(function(val) { + called++; + return true; +}); +assert.sameValue(result, 0); +assert.sameValue(called, 1, 'predicate was called once'); +called = 0; +result = arr.findIndex(function(val) { + called++; + return val === 'Bike'; +}); +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, 2); +result = arr.findIndex(function(val) { + return 'string'; +}); +assert.sameValue(result, 0, 'coerced string'); +result = arr.findIndex(function(val) { + return {}; +}); +assert.sameValue(result, 0, 'coerced object'); +result = arr.findIndex(function(val) { + return Symbol(''); +}); +assert.sameValue(result, 0, 'coerced Symbol'); +result = arr.findIndex(function(val) { + return 1; +}); +assert.sameValue(result, 0, 'coerced number'); +result = arr.findIndex(function(val) { + return -1; +}); +assert.sameValue(result, 0, 'coerced negative number'); diff --git a/test/sendable/builtins/Array/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/Array/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js new file mode 100644 index 00000000000..e1fe2b7ad65 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findindex +description: > + Return -1 if predicate always returns a boolean false value. +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; +var result = arr.findIndex(function(val) { + called++; + return false; +}); +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, -1); +result = arr.findIndex(function(val) { + return ''; +}); +assert.sameValue(result, -1, 'coerced string'); +result = arr.findIndex(function(val) { + return undefined; +}); +assert.sameValue(result, -1, 'coerced undefined'); +result = arr.findIndex(function(val) { + return null; +}); +assert.sameValue(result, -1, 'coerced null'); +result = arr.findIndex(function(val) { + return 0; +}); +assert.sameValue(result, -1, 'coerced 0'); +result = arr.findIndex(function(val) { + return NaN; +}); +assert.sameValue(result, -1, 'coerced NaN'); -- Gitee From fcf6f672db021125e57dbfe2c8b0a69b3623775f Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 24 Dec 2024 16:18:15 +0800 Subject: [PATCH 37/93] add array-findlast Signed-off-by: zhuzhihui7 --- .../findLast/array-altered-during-loop.js | 44 +++++++++ .../prototype/findLast/call-with-boolean.js | 30 ++++++ .../findLast/callbackfn-resize-arraybuffer.js | 78 ++++++++++++++++ .../Array/prototype/findLast/length.js | 32 +++++++ .../Array/prototype/findLast/maximum-index.js | 30 ++++++ .../builtins/Array/prototype/findLast/name.js | 29 ++++++ .../prototype/findLast/not-a-constructor.js | 25 +++++ .../findLast/predicate-call-parameters.js | 41 ++++++++ .../predicate-call-this-non-strict.js | 30 ++++++ .../findLast/predicate-call-this-strict.js | 30 ++++++ ...redicate-called-for-each-array-property.js | 26 ++++++ .../predicate-is-not-callable-throws.js | 47 ++++++++++ .../predicate-not-called-on-empty-array.js | 28 ++++++ .../Array/prototype/findLast/prop-desc.js | 33 +++++++ .../resizable-buffer-grow-mid-iteration.js | 93 +++++++++++++++++++ .../resizable-buffer-shrink-mid-iteration.js | 93 +++++++++++++++++++ .../prototype/findLast/resizable-buffer.js | 88 ++++++++++++++++++ .../return-abrupt-from-predicate-call.js | 26 ++++++ .../findLast/return-abrupt-from-property.js | 31 +++++++ ...eturn-abrupt-from-this-length-as-symbol.js | 26 ++++++ .../return-abrupt-from-this-length.js | 40 ++++++++ .../findLast/return-abrupt-from-this.js | 27 ++++++ ...rn-found-value-predicate-result-is-true.js | 55 +++++++++++ ...efined-if-predicate-returns-false-value.js | 48 ++++++++++ 24 files changed, 1030 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/findLast/array-altered-during-loop.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/callbackfn-resize-arraybuffer.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/length.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/maximum-index.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/name.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/predicate-call-parameters.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/predicate-call-this-non-strict.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/predicate-call-this-strict.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/predicate-called-for-each-array-property.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/predicate-is-not-callable-throws.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/predicate-not-called-on-empty-array.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-predicate-call.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-property.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-this-length-as-symbol.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-this-length.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-this.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/return-found-value-predicate-result-is-true.js create mode 100644 test/sendable/builtins/Array/prototype/findLast/return-undefined-if-predicate-returns-false-value.js diff --git a/test/sendable/builtins/Array/prototype/findLast/array-altered-during-loop.js b/test/sendable/builtins/Array/prototype/findLast/array-altered-during-loop.js new file mode 100644 index 00000000000..c46602e2a1d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/array-altered-during-loop.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + The range of elements processed is set before the first call to `predicate`. +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var results = []; +arr.findLast(function(kValue) { + if (results.length === 0) { + arr.splice(1, 1); + } + results.push(kValue); +}); +assert.sameValue(results.length, 3, 'predicate called three times'); +assert.sameValue(results[0], 'Bike'); +assert.sameValue(results[1], 'Bike'); +assert.sameValue(results[2], 'Shoes'); +results = []; +arr = ['Skateboard', 'Barefoot']; +arr.findLast(function(kValue) { + if (results.length === 0) { + arr.push('Motorcycle'); + arr[0] = 'Magic Carpet'; + } + results.push(kValue); +}); +assert.sameValue(results.length, 2, 'predicate called twice'); +assert.sameValue(results[0], 'Barefoot'); +assert.sameValue(results[1], 'Magic Carpet'); diff --git a/test/sendable/builtins/Array/prototype/findLast/call-with-boolean.js b/test/sendable/builtins/Array/prototype/findLast/call-with-boolean.js new file mode 100644 index 00000000000..85d7278cfb2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/call-with-boolean.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: Array.prototype.findLast applied to boolean primitive. +features: [array-find-from-last] +---*/ + +assert.sameValue( + SendableArray.prototype.findLast.call(true, () => {}), + undefined, + 'SendableArray.prototype.findLast.call(true, () => {}) must return undefined' +); +assert.sameValue( + SendableArray.prototype.findLast.call(false, () => {}), + undefined, + 'SendableArray.prototype.findLast.call(false, () => {}) must return undefined' +); diff --git a/test/sendable/builtins/Array/prototype/findLast/callbackfn-resize-arraybuffer.js b/test/sendable/builtins/Array/prototype/findLast/callbackfn-resize-arraybuffer.js new file mode 100644 index 00000000000..7955e548fca --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/callbackfn-resize-arraybuffer.js @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var secondElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + elements = []; + indices = []; + arrays = []; + result = SendableArray.prototype.findLast.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(BPE); + secondElement = undefined; + expectedElements = [0]; + expectedIndices = [0]; + expectedArrays = [sample]; + } catch (_) { + secondElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [2, 1, 0]; + expectedArrays = [sample, sample, sample]; + } + } + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + assert.compareArray(elements, [0, secondElement, 0], 'elements (shrink)'); + assert.compareArray(indices, [2, 1, 0], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, undefined, 'result (shrink)'); + elements = []; + indices = []; + arrays = []; + result = SendableArray.prototype.findLast.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, undefined, 'result (grow)'); +}); diff --git a/test/sendable/builtins/Array/prototype/findLast/length.js b/test/sendable/builtins/Array/prototype/findLast/length.js new file mode 100644 index 00000000000..40b7d968efe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/length.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: Array.prototype.findLast.length value and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [array-find-from-last] +---*/ + +assert.sameValue( + SendableArray.prototype.findLast.length, 1, + 'The value of `SendableArray.prototype.findLast.length` is `1`' +); +verifyProperty(SendableArray.prototype.findLast, "length", { + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/findLast/maximum-index.js b/test/sendable/builtins/Array/prototype/findLast/maximum-index.js new file mode 100644 index 00000000000..a55cbfaac79 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/maximum-index.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Support the maximum valid integer index. +---*/ + +var tooBigLength = Number.MAX_VALUE; +var maxExpectedIndex = 9007199254740990; +var arrayLike = { length: tooBigLength }; +var calledWithIndex = []; +SendableArray.prototype.findLast.call(arrayLike, function(_value, index) { + calledWithIndex.push(index); + return true; +}); +assert.sameValue(calledWithIndex.length, 1, 'predicate invoked once'); +assert.sameValue(calledWithIndex[0], maxExpectedIndex); diff --git a/test/sendable/builtins/Array/prototype/findLast/name.js b/test/sendable/builtins/Array/prototype/findLast/name.js new file mode 100644 index 00000000000..a47cc8c1f86 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/name.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Array.prototype.findLast.name value and descriptor. +---*/ + +assert.sameValue( + SendableArray.prototype.findLast.name, 'findLast', + 'The value of `SendableArray.prototype.findLast.name` is `"findLast"`' +); +verifyProperty(SendableArray.prototype.findLast, "name", { + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/findLast/not-a-constructor.js b/test/sendable/builtins/Array/prototype/findLast/not-a-constructor.js new file mode 100644 index 00000000000..0b90f09026d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/not-a-constructor.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.findLast does not implement [[Construct]], is not new-able. +---*/ + +assert.sameValue(isConstructor(SendableArray.prototype.findLast), false, 'isConstructor(SendableArray.prototype.findLast) must return false'); +assert.throws(TypeError, () => { + new SendableArray.prototype.findLast(() => {}); +}); + diff --git a/test/sendable/builtins/Array/prototype/findLast/predicate-call-parameters.js b/test/sendable/builtins/Array/prototype/findLast/predicate-call-parameters.js new file mode 100644 index 00000000000..5b03a289946 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/predicate-call-parameters.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +---*/ + +var arr = ['Mike', 'Rick', 'Leo']; +var results = []; +arr.findLast(function() { + results.push(arguments); +}); +assert.sameValue(results.length, 3); +var result = results[0]; +assert.sameValue(result[0], 'Leo'); +assert.sameValue(result[1], 2); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); +result = results[1]; +assert.sameValue(result[0], 'Rick'); +assert.sameValue(result[1], 1); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); +result = results[2]; +assert.sameValue(result[0], 'Mike'); +assert.sameValue(result[1], 0); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); diff --git a/test/sendable/builtins/Array/prototype/findLast/predicate-call-this-non-strict.js b/test/sendable/builtins/Array/prototype/findLast/predicate-call-this-non-strict.js new file mode 100644 index 00000000000..e4d7a765200 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/predicate-call-this-non-strict.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +---*/ + +var result; +[1].findLast(function() { + result = this; +}); +assert.sameValue(result, this); +var o = {}; +[1].findLast(function() { + result = this; +}, o); +assert.sameValue(result, o); diff --git a/test/sendable/builtins/Array/prototype/findLast/predicate-call-this-strict.js b/test/sendable/builtins/Array/prototype/findLast/predicate-call-this-strict.js new file mode 100644 index 00000000000..ab75a815e5d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/predicate-call-this-strict.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +---*/ + +var result; +[1].findLast(function() { + result = this; +}); +assert.sameValue(result, undefined); +var o = {}; +[1].findLast(function() { + result = this; +}, o); +assert.sameValue(result, o); diff --git a/test/sendable/builtins/Array/prototype/findLast/predicate-called-for-each-array-property.js b/test/sendable/builtins/Array/prototype/findLast/predicate-called-for-each-array-property.js new file mode 100644 index 00000000000..b857318f1e2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/predicate-called-for-each-array-property.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Predicate is called for each array property. +---*/ + +var arr = [undefined, , , 'foo']; +var called = 0; +arr.findLast(function() { + called++; +}); +assert.sameValue(called, 4); diff --git a/test/sendable/builtins/Array/prototype/findLast/predicate-is-not-callable-throws.js b/test/sendable/builtins/Array/prototype/findLast/predicate-is-not-callable-throws.js new file mode 100644 index 00000000000..10160bdc3f9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/predicate-is-not-callable-throws.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Throws a TypeError exception if predicate is not callable. +---*/ + +assert.throws(TypeError, function() { + [].findLast({}); +}); +assert.throws(TypeError, function() { + [].findLast(null); +}); +assert.throws(TypeError, function() { + [].findLast(undefined); +}); +assert.throws(TypeError, function() { + [].findLast(true); +}); +assert.throws(TypeError, function() { + [].findLast(1); +}); +assert.throws(TypeError, function() { + [].findLast(''); +}); +assert.throws(TypeError, function() { + [].findLast(1); +}); +assert.throws(TypeError, function() { + [].findLast([]); +}); +assert.throws(TypeError, function() { + [].findLast(/./); +}); diff --git a/test/sendable/builtins/Array/prototype/findLast/predicate-not-called-on-empty-array.js b/test/sendable/builtins/Array/prototype/findLast/predicate-not-called-on-empty-array.js new file mode 100644 index 00000000000..d46a83a23ca --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/predicate-not-called-on-empty-array.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Predicate is only called if this.length is > 0. +---*/ + +var called = false; +var predicate = function() { + called = true; + return true; +}; +var result = [].findLast(predicate); +assert.sameValue(called, false, '[].findLast(predicate) does not call predicate'); +assert.sameValue(result, undefined, '[].findLast(predicate) returned undefined'); diff --git a/test/sendable/builtins/Array/prototype/findLast/prop-desc.js b/test/sendable/builtins/Array/prototype/findLast/prop-desc.js new file mode 100644 index 00000000000..7c249855ca6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/prop-desc.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: Property type and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [array-find-from-last] +---*/ + +assert.sameValue( + typeof SendableArray.prototype.findLast, + 'function', + '`typeof SendableArray.prototype.findLast` is `function`' +); +verifyProperty(SendableArray.prototype, "findLast", { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/findLast/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/Array/prototype/findLast/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..35180743bce --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Array.p.findLast behaves correctly when receiver is backed by resizable + buffer that is grown mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLast.call(fixedLength, ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLast.call(fixedLengthWithOffset, ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + 4 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLast.call(lengthTracking, ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLast.call(lengthTrackingWithOffset, ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + 4 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/findLast/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/Array/prototype/findLast/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..fd142e0a9b2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Array.p.findLast behaves correctly when receiver is backed by resizable + buffer that is shrunk mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLast.call(fixedLength, ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + 4, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLast.call(fixedLengthWithOffset, ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLast.call(lengthTracking, ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLast.call(lengthTrackingWithOffset, ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + 4 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/findLast/resizable-buffer.js b/test/sendable/builtins/Array/prototype/findLast/resizable-buffer.js new file mode 100644 index 00000000000..df080f6fe2e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/resizable-buffer.js @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.findLast +description: > + Array.p.findLast behaves correctly when receiver is backed by resizable + buffer +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + function isTwoOrFour(n) { + return n == 2 || n == 4; + } + assert.sameValue(Number(SendableArray.prototype.findLast.call(fixedLength, isTwoOrFour)), 4); + assert.sameValue(Number(SendableArray.prototype.findLast.call(fixedLengthWithOffset, isTwoOrFour)), 4); + assert.sameValue(Number(SendableArray.prototype.findLast.call(lengthTracking, isTwoOrFour)), 4); + assert.sameValue(Number(SendableArray.prototype.findLast.call(lengthTrackingWithOffset, isTwoOrFour)), 4); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.sameValue(SendableArray.prototype.findLast.call(fixedLength, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.findLast.call(fixedLengthWithOffset, isTwoOrFour), undefined); + assert.sameValue(Number(SendableArray.prototype.findLast.call(lengthTracking, isTwoOrFour)), 4); + assert.sameValue(Number(SendableArray.prototype.findLast.call(lengthTrackingWithOffset, isTwoOrFour)), 4); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.sameValue(SendableArray.prototype.findLast.call(fixedLength, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.findLast.call(fixedLengthWithOffset, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.findLast.call(lengthTrackingWithOffset, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.findLast.call(lengthTracking, isTwoOrFour), undefined); + // Shrink to zero. + rab.resize(0); + assert.sameValue(SendableArray.prototype.findLast.call(fixedLength, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.findLast.call(fixedLengthWithOffset, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.findLast.call(lengthTrackingWithOffset, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.findLast.call(lengthTracking, isTwoOrFour), undefined); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 0); + } + taWrite[4] = MayNeedBigInt(taWrite, 2); + taWrite[5] = MayNeedBigInt(taWrite, 4); + // Orig. array: [0, 0, 0, 0, 2, 4] + // [0, 0, 0, 0] << fixedLength + // [0, 0] << fixedLengthWithOffset + // [0, 0, 0, 0, 2, 4, ...] << lengthTracking + // [0, 0, 2, 4, ...] << lengthTrackingWithOffset + assert.sameValue(SendableArray.prototype.findLast.call(fixedLength, isTwoOrFour), undefined); + assert.sameValue(SendableArray.prototype.findLast.call(fixedLengthWithOffset, isTwoOrFour), undefined); + assert.sameValue(Number(SendableArray.prototype.findLast.call(lengthTracking, isTwoOrFour)), 4); + assert.sameValue(Number(SendableArray.prototype.findLast.call(lengthTrackingWithOffset, isTwoOrFour)), 4); +} diff --git a/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-predicate-call.js b/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-predicate-call.js new file mode 100644 index 00000000000..e0361196fd4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-predicate-call.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Return abrupt from predicate call. +---*/ + +var predicate = function() { + throw new Test262Error(); +}; +assert.throws(Test262Error, function() { + [1].findLast(predicate); +}); diff --git a/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-property.js b/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-property.js new file mode 100644 index 00000000000..28dd94e0235 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-property.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Returns abrupt from getting property value from `this`. +---*/ + +var o = { + length: 1 +}; +Object.defineProperty(o, 0, { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + [].findLast.call(o, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-this-length-as-symbol.js b/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-this-length-as-symbol.js new file mode 100644 index 00000000000..d12da64393e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-this-length-as-symbol.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Return abrupt from ToLength(Get(O, "length")) where length is a Symbol. +---*/ + +var o = {}; +o.length = Symbol(1); +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + [].findLast.call(o, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-this-length.js b/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-this-length.js new file mode 100644 index 00000000000..86581010884 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-this-length.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Return abrupt from ToLength(Get(O, "length")). +---*/ + +var o1 = {}; +Object.defineProperty(o1, 'length', { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + [].findLast.call(o1); +}); +var o2 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; +assert.throws(Test262Error, function() { + [].findLast.call(o2); +}); diff --git a/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-this.js b/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-this.js new file mode 100644 index 00000000000..cfb0bc50708 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/return-abrupt-from-this.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Return abrupt from ToObject(this value). +---*/ + +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + SendableArray.prototype.findLast.call(undefined, function() {}); +}); +assert.throws(TypeError, function() { + SendableArray.prototype.findLast.call(null, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/findLast/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/Array/prototype/findLast/return-found-value-predicate-result-is-true.js new file mode 100644 index 00000000000..b48170a5a42 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/return-found-value-predicate-result-is-true.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Return found value if predicate return a boolean true value. +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; +var result = arr.findLast(function() { + called++; + return true; +}); +assert.sameValue(result, 'Bike'); +assert.sameValue(called, 1, 'predicate was called once'); +called = 0; +result = arr.findLast(function(val) { + called++; + return val === 'Shoes'; +}); +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, 'Shoes'); +result = arr.findLast(function() { + return 'string'; +}); +assert.sameValue(result, 'Bike', 'coerced string'); +result = arr.findLast(function() { + return {}; +}); +assert.sameValue(result, 'Bike', 'coerced object'); +result = arr.findLast(function() { + return Symbol(''); +}); +assert.sameValue(result, 'Bike', 'coerced Symbol'); +result = arr.findLast(function() { + return 1; +}); +assert.sameValue(result, 'Bike', 'coerced number'); +result = arr.findLast(function() { + return -1; +}); +assert.sameValue(result, 'Bike', 'coerced negative number'); diff --git a/test/sendable/builtins/Array/prototype/findLast/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/Array/prototype/findLast/return-undefined-if-predicate-returns-false-value.js new file mode 100644 index 00000000000..e4b43ea2d2a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLast/return-undefined-if-predicate-returns-false-value.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlast +description: > + Return undefined if predicate always returns a boolean false value. +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; +var result = arr.findLast(function() { + called++; + return false; +}); +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, undefined); +result = arr.findLast(function() { + return ''; +}); +assert.sameValue(result, undefined, 'coerced string'); +result = arr.findLast(function() { + return undefined; +}); +assert.sameValue(result, undefined, 'coerced undefined'); +result = arr.findLast(function() { + return null; +}); +assert.sameValue(result, undefined, 'coerced null'); +result = arr.findLast(function() { + return 0; +}); +assert.sameValue(result, undefined, 'coerced 0'); +result = arr.findLast(function() { + return NaN; +}); +assert.sameValue(result, undefined, 'coerced NaN'); -- Gitee From 0a68618852111abdc9d21c3056dc9885c36f3f31 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 25 Dec 2024 09:41:04 +0800 Subject: [PATCH 38/93] add array-findlastindex Signed-off-by: zhuzhihui7 --- .../array-altered-during-loop.js | 44 +++++++ .../findLastIndex/call-with-boolean.js | 30 +++++ .../callbackfn-resize-arraybuffer.js | 78 +++++++++++++ .../Array/prototype/findLastIndex/length.js | 32 ++++++ .../prototype/findLastIndex/maximum-index.js | 30 +++++ .../Array/prototype/findLastIndex/name.js | 29 +++++ .../findLastIndex/not-a-constructor.js | 30 +++++ .../predicate-call-parameters.js | 41 +++++++ .../predicate-call-this-non-strict.js | 30 +++++ .../predicate-call-this-strict.js | 30 +++++ ...redicate-called-for-each-array-property.js | 26 +++++ .../predicate-is-not-callable-throws.js | 47 ++++++++ .../predicate-not-called-on-empty-array.js | 34 ++++++ .../prototype/findLastIndex/prop-desc.js | 33 ++++++ .../resizable-buffer-grow-mid-iteration.js | 93 +++++++++++++++ .../resizable-buffer-shrink-mid-iteration.js | 107 ++++++++++++++++++ .../findLastIndex/resizable-buffer.js | 88 ++++++++++++++ .../return-abrupt-from-predicate-call.js | 26 +++++ .../return-abrupt-from-property.js | 31 +++++ ...eturn-abrupt-from-this-length-as-symbol.js | 26 +++++ .../return-abrupt-from-this-length.js | 41 +++++++ .../findLastIndex/return-abrupt-from-this.js | 27 +++++ .../return-index-predicate-result-is-true.js | 55 +++++++++ ...ve-one-if-predicate-returns-false-value.js | 48 ++++++++ 24 files changed, 1056 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/array-altered-during-loop.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/callbackfn-resize-arraybuffer.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/length.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/maximum-index.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/name.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/predicate-call-parameters.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/predicate-call-this-non-strict.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/predicate-call-this-strict.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/predicate-called-for-each-array-property.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/predicate-is-not-callable-throws.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/predicate-not-called-on-empty-array.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-predicate-call.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-property.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-this-length-as-symbol.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-this-length.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-this.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/return-index-predicate-result-is-true.js create mode 100644 test/sendable/builtins/Array/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/array-altered-during-loop.js b/test/sendable/builtins/Array/prototype/findLastIndex/array-altered-during-loop.js new file mode 100644 index 00000000000..b3bc630f8a2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/array-altered-during-loop.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + The range of elements processed is set before the first call to `predicate`. +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var results = []; +arr.findLastIndex(function(kValue) { + if (results.length === 0) { + arr.splice(1, 1); + } + results.push(kValue); +}); +assert.sameValue(results.length, 3, 'predicate called three times'); +assert.sameValue(results[0], 'Bike'); +assert.sameValue(results[1], 'Bike'); +assert.sameValue(results[2], 'Shoes'); +results = []; +arr = ['Skateboard', 'Barefoot']; +arr.findLastIndex(function(kValue) { + if (results.length === 0) { + arr.push('Motorcycle'); + arr[0] = 'Magic Carpet'; + } + results.push(kValue); +}); +assert.sameValue(results.length, 2, 'predicate called twice'); +assert.sameValue(results[0], 'Barefoot'); +assert.sameValue(results[1], 'Magic Carpet'); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/call-with-boolean.js b/test/sendable/builtins/Array/prototype/findLastIndex/call-with-boolean.js new file mode 100644 index 00000000000..b53d7cfa6c7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/call-with-boolean.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: Array.prototype.findLastIndex applied to boolean primitive. +features: [array-find-from-last] +---*/ + +assert.sameValue( + SendableArray.prototype.findLastIndex.call(true, () => {}), + -1, + 'SendableArray.prototype.findLastIndex.call(true, () => {}) must return -1' +); +assert.sameValue( + SendableArray.prototype.findLastIndex.call(false, () => {}), + -1, + 'SendableArray.prototype.findLastIndex.call(false, () => {}) must return -1' +); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/callbackfn-resize-arraybuffer.js b/test/sendable/builtins/Array/prototype/findLastIndex/callbackfn-resize-arraybuffer.js new file mode 100644 index 00000000000..900a3c4c9a9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/callbackfn-resize-arraybuffer.js @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var secondElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + elements = []; + indices = []; + arrays = []; + result = SendableArray.prototype.findLastIndex.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(BPE); + secondElement = undefined; + expectedElements = [0]; + expectedIndices = [0]; + expectedArrays = [sample]; + } catch (_) { + secondElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [2, 1, 0]; + expectedArrays = [sample, sample, sample]; + } + } + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + assert.compareArray(elements, [0, secondElement, 0], 'elements (shrink)'); + assert.compareArray(indices, [2, 1, 0], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, -1, 'result (shrink)'); + elements = []; + indices = []; + arrays = []; + result = SendableArray.prototype.findLastIndex.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, -1, 'result (grow)'); +}); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/length.js b/test/sendable/builtins/Array/prototype/findLastIndex/length.js new file mode 100644 index 00000000000..875b9287a65 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/length.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: Array.prototype.findLastIndex.length value and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [array-find-from-last] +---*/ + +assert.sameValue( + SendableArray.prototype.findLastIndex.length, 1, + 'The value of `SendableArray.prototype.findLastIndex.length` is `1`' +); +verifyProperty(SendableArray.prototype.findLastIndex, "length", { + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/maximum-index.js b/test/sendable/builtins/Array/prototype/findLastIndex/maximum-index.js new file mode 100644 index 00000000000..1fa3f744296 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/maximum-index.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Support the maximum valid integer index. +---*/ + +var tooBigLength = Number.MAX_VALUE; +var maxExpectedIndex = 9007199254740990; +var arrayLike = { length: tooBigLength }; +var calledWithIndex = []; +SendableArray.prototype.findLastIndex.call(arrayLike, function(_value, index) { + calledWithIndex.push(index); + return true; +}); +assert.sameValue(calledWithIndex.length, 1, 'predicate invoked once'); +assert.sameValue(calledWithIndex[0], maxExpectedIndex); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/name.js b/test/sendable/builtins/Array/prototype/findLastIndex/name.js new file mode 100644 index 00000000000..18172faac92 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/name.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Array.prototype.findLastIndex.name value and descriptor. +---*/ + +assert.sameValue( + SendableArray.prototype.findLastIndex.name, 'findLastIndex', + 'The value of `SendableArray.prototype.findLastIndex.name` is `"findLastIndex"`' +); +verifyProperty(SendableArray.prototype.findLastIndex, "name", { + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/not-a-constructor.js b/test/sendable/builtins/Array/prototype/findLastIndex/not-a-constructor.js new file mode 100644 index 00000000000..3dbff08651b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/not-a-constructor.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.findLastIndex does not implement [[Construct]], is not new-able. +---*/ + +assert.sameValue( + isConstructor(SendableArray.prototype.findLastIndex), + false, + 'isConstructor(SendableArray.prototype.findLastIndex) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.findLastIndex(() => {}); +}); + diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/predicate-call-parameters.js b/test/sendable/builtins/Array/prototype/findLastIndex/predicate-call-parameters.js new file mode 100644 index 00000000000..5c4d363c008 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/predicate-call-parameters.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +---*/ + +var arr = ['Mike', 'Rick', 'Leo']; +var results = []; +arr.findLastIndex(function() { + results.push(arguments); +}); +assert.sameValue(results.length, 3); +var result = results[0]; +assert.sameValue(result[0], 'Leo'); +assert.sameValue(result[1], 2); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); +result = results[1]; +assert.sameValue(result[0], 'Rick'); +assert.sameValue(result[1], 1); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); +result = results[2]; +assert.sameValue(result[0], 'Mike'); +assert.sameValue(result[1], 0); +assert.sameValue(result[2], arr); +assert.sameValue(result.length, 3); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/predicate-call-this-non-strict.js b/test/sendable/builtins/Array/prototype/findLastIndex/predicate-call-this-non-strict.js new file mode 100644 index 00000000000..4dc54eee0a1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/predicate-call-this-non-strict.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +---*/ + +var result; +[1].findLastIndex(function() { + result = this; +}); +assert.sameValue(result, this); +var o = {}; +[1].findLastIndex(function() { + result = this; +}, o); +assert.sameValue(result, o); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/predicate-call-this-strict.js b/test/sendable/builtins/Array/prototype/findLastIndex/predicate-call-this-strict.js new file mode 100644 index 00000000000..15bb11056b4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/predicate-call-this-strict.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +---*/ + +var result; +[1].findLastIndex(function() { + result = this; +}); +assert.sameValue(result, undefined); +var o = {}; +[1].findLastIndex(function() { + result = this; +}, o); +assert.sameValue(result, o); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/predicate-called-for-each-array-property.js b/test/sendable/builtins/Array/prototype/findLastIndex/predicate-called-for-each-array-property.js new file mode 100644 index 00000000000..47c0e1a3897 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/predicate-called-for-each-array-property.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Predicate is called for each array property. +---*/ + +var arr = [undefined, , , 'foo']; +var called = 0; +arr.findLastIndex(function() { + called++; +}); +assert.sameValue(called, 4); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/predicate-is-not-callable-throws.js b/test/sendable/builtins/Array/prototype/findLastIndex/predicate-is-not-callable-throws.js new file mode 100644 index 00000000000..9acca53ea8f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/predicate-is-not-callable-throws.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Throws a TypeError exception if predicate is not callable. +---*/ + +assert.throws(TypeError, function() { + [].findLastIndex({}); +}); +assert.throws(TypeError, function() { + [].findLastIndex(null); +}); +assert.throws(TypeError, function() { + [].findLastIndex(undefined); +}); +assert.throws(TypeError, function() { + [].findLastIndex(true); +}); +assert.throws(TypeError, function() { + [].findLastIndex(1); +}); +assert.throws(TypeError, function() { + [].findLastIndex(''); +}); +assert.throws(TypeError, function() { + [].findLastIndex(1); +}); +assert.throws(TypeError, function() { + [].findLastIndex([]); +}); +assert.throws(TypeError, function() { + [].findLastIndex(/./); +}); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/predicate-not-called-on-empty-array.js b/test/sendable/builtins/Array/prototype/findLastIndex/predicate-not-called-on-empty-array.js new file mode 100644 index 00000000000..079253fe201 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/predicate-not-called-on-empty-array.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Predicate is only called if this.length is > 0. +---*/ + +var called = false; +var predicate = function() { + called = true; + return true; +}; +var result = [].findLastIndex(predicate); +assert.sameValue( + called, false, + '[].findLastIndex(predicate) does not call predicate' +); +assert.sameValue( + result, -1, + '[].findLastIndex(predicate) returned undefined' +); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/prop-desc.js b/test/sendable/builtins/Array/prototype/findLastIndex/prop-desc.js new file mode 100644 index 00000000000..4bbe20fdda2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/prop-desc.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: Property type and descriptor. +info: | + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [array-find-from-last] +---*/ + +assert.sameValue( + typeof SendableArray.prototype.findLastIndex, + 'function', + '`typeof SendableArray.prototype.findLastIndex` is `function`' +); +verifyProperty(SendableArray.prototype, "findLastIndex", { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/Array/prototype/findLastIndex/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..83f60270f58 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Array.p.findLastIndex behaves correctly when receiver is backed by resizable + buffer that is grown mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLastIndex.call(fixedLength, ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLastIndex.call(fixedLengthWithOffset, ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + 4 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTracking, ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTrackingWithOffset, ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + 4 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/Array/prototype/findLastIndex/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..94535d1df83 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Array.p.findLastIndex behaves correctly when receiver is backed by resizable + buffer that is shrunk mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLastIndex.call(fixedLength, ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + 4, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLastIndex.call(fixedLengthWithOffset, ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTracking, ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 1; + resizeTo = 2 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTracking, ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + undefined, + 2, + 0 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTrackingWithOffset, ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + 4 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/resizable-buffer.js b/test/sendable/builtins/Array/prototype/findLastIndex/resizable-buffer.js new file mode 100644 index 00000000000..74d14d77ac1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/resizable-buffer.js @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Array.p.findLastIndex behaves correctly when receiver is backed by resizable + buffer +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + function isTwoOrFour(n) { + return n == 2 || n == 4; + } + assert.sameValue(SendableArray.prototype.findLastIndex.call(fixedLength, isTwoOrFour), 2); + assert.sameValue(SendableArray.prototype.findLastIndex.call(fixedLengthWithOffset, isTwoOrFour), 0); + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTracking, isTwoOrFour), 2); + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTrackingWithOffset, isTwoOrFour), 0); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.sameValue(SendableArray.prototype.findLastIndex.call(fixedLength, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findLastIndex.call(fixedLengthWithOffset, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTracking, isTwoOrFour), 2); + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTrackingWithOffset, isTwoOrFour), 0); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.sameValue(SendableArray.prototype.findLastIndex.call(fixedLength, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findLastIndex.call(fixedLengthWithOffset, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTrackingWithOffset, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTracking, isTwoOrFour), -1); + // Shrink to zero. + rab.resize(0); + assert.sameValue(SendableArray.prototype.findLastIndex.call(fixedLength, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findLastIndex.call(fixedLengthWithOffset, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTrackingWithOffset, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTracking, isTwoOrFour), -1); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 0); + } + taWrite[4] = MayNeedBigInt(taWrite, 2); + taWrite[5] = MayNeedBigInt(taWrite, 4); + // Orig. array: [0, 0, 0, 0, 2, 4] + // [0, 0, 0, 0] << fixedLength + // [0, 0] << fixedLengthWithOffset + // [0, 0, 0, 0, 2, 4, ...] << lengthTracking + // [0, 0, 2, 4, ...] << lengthTrackingWithOffset + + assert.sameValue(SendableArray.prototype.findLastIndex.call(fixedLength, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findLastIndex.call(fixedLengthWithOffset, isTwoOrFour), -1); + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTracking, isTwoOrFour), 5); + assert.sameValue(SendableArray.prototype.findLastIndex.call(lengthTrackingWithOffset, isTwoOrFour), 3); +} + diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-predicate-call.js b/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-predicate-call.js new file mode 100644 index 00000000000..20731759593 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-predicate-call.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Return abrupt from predicate call. +---*/ + +var predicate = function() { + throw new Test262Error(); +}; +assert.throws(Test262Error, function() { + [1].findLastIndex(predicate); +}); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-property.js b/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-property.js new file mode 100644 index 00000000000..8edfe39f2cf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-property.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Returns abrupt from getting property value from `this`. +---*/ + +var o = { + length: 1 +}; +Object.defineProperty(o, 0, { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + [].findLastIndex.call(o, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-this-length-as-symbol.js b/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-this-length-as-symbol.js new file mode 100644 index 00000000000..8462a7a603c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-this-length-as-symbol.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Return abrupt from ToLength(Get(O, "length")) where length is a Symbol. +---*/ + +var o = {}; +o.length = Symbol(1); +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + [].findLastIndex.call(o, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-this-length.js b/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-this-length.js new file mode 100644 index 00000000000..0f078afdcff --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-this-length.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Return abrupt from ToLength(Get(O, "length")). +---*/ + +var o1 = {}; +Object.defineProperty(o1, 'length', { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +// predicate fn is given to avoid false positives +assert.throws(Test262Error, function() { + [].findLastIndex.call(o1, function() {}); +}); +var o2 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; +assert.throws(Test262Error, function() { + [].findLastIndex.call(o2, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-this.js b/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-this.js new file mode 100644 index 00000000000..60d96dedc2d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/return-abrupt-from-this.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Return abrupt from ToObject(this value). +---*/ + +// predicate fn is given to avoid false positives +assert.throws(TypeError, function() { + SendableArray.prototype.findLastIndex.call(undefined, function() {}); +}); +assert.throws(TypeError, function() { + SendableArray.prototype.findLastIndex.call(null, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/return-index-predicate-result-is-true.js b/test/sendable/builtins/Array/prototype/findLastIndex/return-index-predicate-result-is-true.js new file mode 100644 index 00000000000..3b89ac4305c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/return-index-predicate-result-is-true.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Return index if predicate return a boolean true value. +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; +var result = arr.findLastIndex(function() { + called++; + return true; +}); +assert.sameValue(result, 2); +assert.sameValue(called, 1, 'predicate was called once'); +called = 0; +result = arr.findLastIndex(function(val) { + called++; + return val === 'Shoes'; +}); +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, 0); +result = arr.findLastIndex(function() { + return 'string'; +}); +assert.sameValue(result, 2, 'coerced string'); +result = arr.findLastIndex(function() { + return {}; +}); +assert.sameValue(result, 2, 'coerced object'); +result = arr.findLastIndex(function() { + return Symbol(''); +}); +assert.sameValue(result, 2, 'coerced Symbol'); +result = arr.findLastIndex(function() { + return 1; +}); +assert.sameValue(result, 2, 'coerced number'); +result = arr.findLastIndex(function() { + return -1; +}); +assert.sameValue(result, 2, 'coerced negative number'); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/Array/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js new file mode 100644 index 00000000000..82adaee8dd4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.findlastindex +description: > + Return -1 if predicate always returns a boolean false value. +---*/ + +var arr = ['Shoes', 'Car', 'Bike']; +var called = 0; +var result = arr.findLastIndex(function() { + called++; + return false; +}); +assert.sameValue(called, 3, 'predicate was called three times'); +assert.sameValue(result, -1); +result = arr.findLastIndex(function() { + return ''; +}); +assert.sameValue(result, -1, 'coerced string'); +result = arr.findLastIndex(function() { + return undefined; +}); +assert.sameValue(result, -1, 'coerced undefined'); +result = arr.findLastIndex(function() { + return null; +}); +assert.sameValue(result, -1, 'coerced null'); +result = arr.findLastIndex(function() { + return 0; +}); +assert.sameValue(result, -1, 'coerced 0'); +result = arr.findLastIndex(function() { + return NaN; +}); +assert.sameValue(result, -1, 'coerced NaN'); -- Gitee From 029ea0ae8960bbcd2b27259235f4a62ec9b368f6 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 25 Dec 2024 09:58:42 +0800 Subject: [PATCH 39/93] add array-flat Signed-off-by: zhuzhihui7 --- .../prototype/flat/array-like-objects.js | 40 +++++++++++++++ .../prototype/flat/bound-function-call.js | 28 +++++++++++ .../Array/prototype/flat/call-with-boolean.js | 22 +++++++++ .../prototype/flat/empty-array-elements.js | 36 ++++++++++++++ .../prototype/flat/empty-object-elements.js | 33 +++++++++++++ .../builtins/Array/prototype/flat/length.js | 32 ++++++++++++ .../builtins/Array/prototype/flat/name.js | 33 +++++++++++++ .../non-numeric-depth-should-not-throw.js | 49 +++++++++++++++++++ .../prototype/flat/non-object-ctor-throws.js | 43 ++++++++++++++++ .../Array/prototype/flat/not-a-constructor.js | 34 +++++++++++++ .../prototype/flat/null-undefined-elements.js | 43 ++++++++++++++++ .../flat/null-undefined-input-throws.js | 31 ++++++++++++ .../Array/prototype/flat/positive-infinity.js | 24 +++++++++ .../Array/prototype/flat/prop-desc.js | 33 +++++++++++++ .../prototype/flat/proxy-access-count.js | 30 ++++++++++++ .../symbol-object-create-null-depth-throws.js | 28 +++++++++++ .../flat/target-array-non-extensible.js | 32 ++++++++++++ ...et-array-with-non-configurable-property.js | 34 +++++++++++++ ...target-array-with-non-writable-property.js | 39 +++++++++++++++ 19 files changed, 644 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/flat/array-like-objects.js create mode 100644 test/sendable/builtins/Array/prototype/flat/bound-function-call.js create mode 100644 test/sendable/builtins/Array/prototype/flat/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/flat/empty-array-elements.js create mode 100644 test/sendable/builtins/Array/prototype/flat/empty-object-elements.js create mode 100644 test/sendable/builtins/Array/prototype/flat/length.js create mode 100644 test/sendable/builtins/Array/prototype/flat/name.js create mode 100644 test/sendable/builtins/Array/prototype/flat/non-numeric-depth-should-not-throw.js create mode 100644 test/sendable/builtins/Array/prototype/flat/non-object-ctor-throws.js create mode 100644 test/sendable/builtins/Array/prototype/flat/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/flat/null-undefined-elements.js create mode 100644 test/sendable/builtins/Array/prototype/flat/null-undefined-input-throws.js create mode 100644 test/sendable/builtins/Array/prototype/flat/positive-infinity.js create mode 100644 test/sendable/builtins/Array/prototype/flat/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/flat/proxy-access-count.js create mode 100644 test/sendable/builtins/Array/prototype/flat/symbol-object-create-null-depth-throws.js create mode 100644 test/sendable/builtins/Array/prototype/flat/target-array-non-extensible.js create mode 100644 test/sendable/builtins/Array/prototype/flat/target-array-with-non-configurable-property.js create mode 100644 test/sendable/builtins/Array/prototype/flat/target-array-with-non-writable-property.js diff --git a/test/sendable/builtins/Array/prototype/flat/array-like-objects.js b/test/sendable/builtins/Array/prototype/flat/array-like-objects.js new file mode 100644 index 00000000000..e9ddc643e62 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/array-like-objects.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: > + array-like objects can be flattened +includes: [compareArray.js] +features: [Array.prototype.flat] +---*/ + +function getArgumentsObject() { + return arguments; +} +var a = getArgumentsObject([1], [2]); +var actual = [].flat.call(a); +assert.compareArray(actual, [1, 2], 'The value of actual is expected to be [1, 2]'); +a = { + length: 1, + 0: [1], +}; +actual = [].flat.call(a); +assert.compareArray(actual, [1], 'The value of actual is expected to be [1]'); +a = { + length: undefined, + 0: [1], +}; +actual = [].flat.call(a); +assert.compareArray(actual, [], 'The value of actual is expected to be []'); diff --git a/test/sendable/builtins/Array/prototype/flat/bound-function-call.js b/test/sendable/builtins/Array/prototype/flat/bound-function-call.js new file mode 100644 index 00000000000..197eea675c1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/bound-function-call.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: > + using bound functions +includes: [compareArray.js] +features: [Array.prototype.flat] +---*/ + +var a = [ + [0], + [1] +]; +var actual = [].flat.bind(a)(); +assert.compareArray(actual, [0, 1], 'The value of actual is expected to be [0, 1]'); diff --git a/test/sendable/builtins/Array/prototype/flat/call-with-boolean.js b/test/sendable/builtins/Array/prototype/flat/call-with-boolean.js new file mode 100644 index 00000000000..d409cc4bcf1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/call-with-boolean.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.flat +description: Array.prototype.flat applied to boolean primitive +includes: [compareArray.js] +---*/ +assert.compareArray(SendableArray.prototype.flat.call(true), [], 'SendableArray.prototype.flat.call(true) must return []'); +assert.compareArray(SendableArray.prototype.flat.call(false), [], 'SendableArray.prototype.flat.call(false) must return []'); diff --git a/test/sendable/builtins/Array/prototype/flat/empty-array-elements.js b/test/sendable/builtins/Array/prototype/flat/empty-array-elements.js new file mode 100644 index 00000000000..e6b7be57f39 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/empty-array-elements.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: > + arrays with empty arrays elements +includes: [compareArray.js] +features: [Array.prototype.flat] +---*/ + +var a = {}; +assert.compareArray([].flat(), [], '[].flat() must return []'); +assert.compareArray([ + [], + [] +].flat(), [], '[ [], [] ].flat() must return []'); +assert.compareArray([ + [], + [1] +].flat(), [1], '[ [], [1] ].flat() must return [1]'); +assert.compareArray([ + [], + [1, a] +].flat(), [1, a], '[ [], [1, a] ].flat() must return [1, a]'); diff --git a/test/sendable/builtins/Array/prototype/flat/empty-object-elements.js b/test/sendable/builtins/Array/prototype/flat/empty-object-elements.js new file mode 100644 index 00000000000..6b999e3981c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/empty-object-elements.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: > + arrays with empty object elements +includes: [compareArray.js] +features: [Array.prototype.flat] +---*/ + +var a = {}, + b = {}; +assert.compareArray([a].flat(), [a], '[a].flat() must return [a]'); +assert.compareArray([a, [b]].flat(), [a, b], '[a, [b]].flat() must return [a, b]'); +assert.compareArray([ + [a], b +].flat(), [a, b], '[ [a], b ].flat() must return [a, b]'); +assert.compareArray([ + [a], + [b] +].flat(), [a, b], '[ [a], [b] ].flat() must return [a, b]'); diff --git a/test/sendable/builtins/Array/prototype/flat/length.js b/test/sendable/builtins/Array/prototype/flat/length.js new file mode 100644 index 00000000000..8ad3aae5bbc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/length.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: Array.prototype.flat.length value and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [Array.prototype.flat] +---*/ + +assert.sameValue( + SendableArray.prototype.flat.length, 0, + 'The value of `SendableArray.prototype.flat.length` is `0`' +); +verifyProperty(SendableArray.prototype.flat, 'length', { + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/flat/name.js b/test/sendable/builtins/Array/prototype/flat/name.js new file mode 100644 index 00000000000..784af39f54e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/name.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: > + Array.prototype.flat.name value and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [Array.prototype.flat] +---*/ + +assert.sameValue( + SendableArray.prototype.flat.name, 'flat', + 'The value of `SendableArray.prototype.flat.name` is `"flat"`' +); +verifyProperty(SendableArray.prototype.flat, 'name', { + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/flat/non-numeric-depth-should-not-throw.js b/test/sendable/builtins/Array/prototype/flat/non-numeric-depth-should-not-throw.js new file mode 100644 index 00000000000..f8d54d78788 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/non-numeric-depth-should-not-throw.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: > + if the argument is a string or object, the depthNum is 0 +includes: [compareArray.js] +features: [Array.prototype.flat] +---*/ + +var a = [1, [2]]; +var expected = a; +// non integral string depthNum is converted to 0 +var depthNum = 'TestString'; +var actual = a.flat(depthNum); +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); +// object type depthNum is converted to 0 +depthNum = {}; +actual = a.flat(depthNum); +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); +// negative infinity depthNum is converted to 0 +depthNum = Number.NEGATIVE_INFINITY; +actual = a.flat(depthNum); +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); +// positive zero depthNum is converted to 0 +depthNum = +0; +actual = a.flat(depthNum); +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); +// negative zero depthNum is converted to 0 +depthNum = -0; +actual = a.flat(depthNum); +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); +// integral string depthNum is converted to an integer +depthNum = '1'; +actual = a.flat(depthNum); +expected = [1, 2] +assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); diff --git a/test/sendable/builtins/Array/prototype/flat/non-object-ctor-throws.js b/test/sendable/builtins/Array/prototype/flat/non-object-ctor-throws.js new file mode 100644 index 00000000000..e45103baf0f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/non-object-ctor-throws.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: > + Behavior when `constructor` property is neither an Object nor undefined + - if IsConstructor(C) is false, throw a TypeError exception. +features: [Array.prototype.flat] +---*/ + +assert.sameValue(typeof Array.prototype.flat, 'function'); +var a = []; +a.constructor = null; +assert.throws(TypeError, function() { + a.flat(); +}, 'null value'); +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.flat(); +}, 'number value'); +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.flat(); +}, 'string value'); +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.flat(); +}, 'boolean value'); diff --git a/test/sendable/builtins/Array/prototype/flat/not-a-constructor.js b/test/sendable/builtins/Array/prototype/flat/not-a-constructor.js new file mode 100644 index 00000000000..7b74befd17b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/not-a-constructor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.flat 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(SendableArray.prototype.flat), false, 'isConstructor(SendableArray.prototype.flat) must return false'); +assert.throws(TypeError, () => { + new SendableArray.prototype.flat(); +}); + diff --git a/test/sendable/builtins/Array/prototype/flat/null-undefined-elements.js b/test/sendable/builtins/Array/prototype/flat/null-undefined-elements.js new file mode 100644 index 00000000000..cc0a4f59e3d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/null-undefined-elements.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: > + arrays with null, and undefined +includes: [compareArray.js] +features: [Array.prototype.flat] +---*/ + +var a = [void 0]; +assert.compareArray( + [1, null, void 0].flat(), + [1, null, undefined], + '[1, null, void 0].flat() must return [1, null, undefined]' +); +assert.compareArray( + [1, [null, void 0]].flat(), + [1, null, undefined], + '[1, [null, void 0]].flat() must return [1, null, undefined]' +); +assert.compareArray([ + [null, void 0], + [null, void 0] +].flat(), [null, undefined, null, undefined], '[ [null, void 0], [null, void 0] ].flat() must return [null, undefined, null, undefined]'); +assert.compareArray([1, [null, a]].flat(1), [1, null, a], '[1, [null, a]].flat(1) must return [1, null, a]'); +assert.compareArray( + [1, [null, a]].flat(2), + [1, null, undefined], + '[1, [null, a]].flat(2) must return [1, null, undefined]' +); diff --git a/test/sendable/builtins/Array/prototype/flat/null-undefined-input-throws.js b/test/sendable/builtins/Array/prototype/flat/null-undefined-input-throws.js new file mode 100644 index 00000000000..252811b1103 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/null-undefined-input-throws.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: > + null or undefined should throw TypeError Exception +features: [Array.prototype.flat] +---*/ + +assert.sameValue(typeof SendableArray.prototype.flat, 'function'); +assert.throws(TypeError, function() { + [].flat.call(null); +}, 'null value'); +assert.throws(TypeError, function() { + [].flat.call(); +}, 'missing'); +assert.throws(TypeError, function() { + [].flat.call(void 0); +}, 'undefined'); diff --git a/test/sendable/builtins/Array/prototype/flat/positive-infinity.js b/test/sendable/builtins/Array/prototype/flat/positive-infinity.js new file mode 100644 index 00000000000..8ae46aeeaa9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/positive-infinity.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: > + if the argument is a positive infinity, the depthNum is max depth of the array +includes: [compareArray.js] +features: [Array.prototype.flat] +---*/ + +var a = [1, [2, [3, [4]]]] +assert.compareArray(a.flat(Number.POSITIVE_INFINITY), [1, 2, 3, 4], 'a.flat(Number.POSITIVE_INFINITY) must return [1, 2, 3, 4]'); diff --git a/test/sendable/builtins/Array/prototype/flat/prop-desc.js b/test/sendable/builtins/Array/prototype/flat/prop-desc.js new file mode 100644 index 00000000000..da34914d27d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/prop-desc.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: Property type and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [Array.prototype.flat] +---*/ + +assert.sameValue( + typeof SendableArray.prototype.flat, + 'function', + '`typeof SendableArray.prototype.flat` is `function`' +); +verifyProperty(SendableArray.prototype, 'flat', { + enumerable: false, + writable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/flat/proxy-access-count.js b/test/sendable/builtins/Array/prototype/flat/proxy-access-count.js new file mode 100644 index 00000000000..228e9e25778 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/proxy-access-count.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: > + properties are accessed correct number of times by .flat +---*/ + +const getCalls = [], hasCalls = []; +const handler = { + get : function (t, p, r) { getCalls.push(p); return Reflect.get(t, p, r); }, + has : function (t, p, r) { hasCalls.push(p); return Reflect.has(t, p, r); } +} +const tier2 = new Proxy([4, 3], handler); +const tier1 = new Proxy([2, [3, [4, 2], 2], 5, tier2, 6], handler); +SendableArray.prototype.flat.call(tier1, 3); +assert.compareArray(getCalls, ["length", "constructor", "0", "1", "2", "3", "length", "0", "1", "4"], 'The value of getCalls is expected to be ["length", "constructor", "0", "1", "2", "3", "length", "0", "1", "4"]'); +assert.compareArray(hasCalls, ["0", "1", "2", "3", "0", "1", "4"], 'The value of hasCalls is expected to be ["0", "1", "2", "3", "0", "1", "4"]'); diff --git a/test/sendable/builtins/Array/prototype/flat/symbol-object-create-null-depth-throws.js b/test/sendable/builtins/Array/prototype/flat/symbol-object-create-null-depth-throws.js new file mode 100644 index 00000000000..7cc30864a39 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/symbol-object-create-null-depth-throws.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: > + if the argument is a Symbol or Object null, it throws exception +features: [Array.prototype.flat] +---*/ + +assert.sameValue(typeof SendableArray.prototype.flat, 'function'); +assert.throws(TypeError, function() { + [].flat(Symbol()); +}, 'symbol value'); +assert.throws(TypeError, function() { + [].flat(Object.create(null)); +}, 'object create null'); diff --git a/test/sendable/builtins/Array/prototype/flat/target-array-non-extensible.js b/test/sendable/builtins/Array/prototype/flat/target-array-non-extensible.js new file mode 100644 index 00000000000..f52627ab2bf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/target-array-non-extensible.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.flat +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible, source array is not flattened) +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.flat(1); +}); diff --git a/test/sendable/builtins/Array/prototype/flat/target-array-with-non-configurable-property.js b/test/sendable/builtins/Array/prototype/flat/target-array-with-non-configurable-property.js new file mode 100644 index 00000000000..46459485fad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/target-array-with-non-configurable-property.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.flat +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable, source array gets flattened) +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + set: function(_value) {}, + configurable: false, + }); +}; +var arr = [[1]]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.flat(1); +}); diff --git a/test/sendable/builtins/Array/prototype/flat/target-array-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/flat/target-array-with-non-writable-property.js new file mode 100644 index 00000000000..18ca4af7cc8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flat/target-array-with-non-writable-property.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flat +description: > + Non-writable properties are overwritten by CreateDataProperty. + (result object's "0" is non-writable, source array gets flattened) +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + value: 1, + writable: false, + enumerable: false, + configurable: true, + }); +}; +var arr = [[2]]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +var res = arr.flat(1); +verifyProperty(res, "0", { + value: 2, + writable: true, + enumerable: true, + configurable: true, +}); -- Gitee From 197b5cc0b6cc55103e20bb7dd0b1a42e67ebf3e9 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 25 Dec 2024 10:47:29 +0800 Subject: [PATCH 40/93] add array-flatmap Signed-off-by: zhuzhihui7 --- .../flatMap/array-like-objects-nested.js | 55 +++++++ .../array-like-objects-poisoned-length.js | 65 +++++++++ .../flatMap/array-like-objects-typedarrays.js | 43 ++++++ .../prototype/flatMap/array-like-objects.js | 68 +++++++++ .../flatMap/bound-function-argument.js | 26 ++++ .../prototype/flatMap/call-with-boolean.js | 30 ++++ .../prototype/flatMap/depth-always-one.js | 34 +++++ .../Array/prototype/flatMap/length.js | 32 +++++ .../builtins/Array/prototype/flatMap/name.js | 32 +++++ .../flatMap/non-callable-argument-throws.js | 48 +++++++ .../prototype/flatMap/not-a-constructor.js | 32 +++++ .../Array/prototype/flatMap/prop-desc.js | 37 +++++ .../prototype/flatMap/proxy-access-count.js | 46 ++++++ .../flatMap/target-array-non-extensible.js | 35 +++++ ...et-array-with-non-configurable-property.js | 38 +++++ ...target-array-with-non-writable-property.js | 44 ++++++ .../flatMap/this-value-ctor-non-object.js | 64 +++++++++ ...is-value-ctor-object-species-bad-throws.js | 114 +++++++++++++++ ...ect-species-custom-ctor-poisoned-throws.js | 45 ++++++ ...s-value-ctor-object-species-custom-ctor.js | 68 +++++++++ .../flatMap/this-value-ctor-object-species.js | 134 ++++++++++++++++++ .../this-value-null-undefined-throws.js | 32 +++++ .../prototype/flatMap/thisArg-argument.js | 51 +++++++ 23 files changed, 1173 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/flatMap/array-like-objects-nested.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/array-like-objects-poisoned-length.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/array-like-objects-typedarrays.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/array-like-objects.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/bound-function-argument.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/depth-always-one.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/length.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/name.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/non-callable-argument-throws.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/proxy-access-count.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/target-array-non-extensible.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/target-array-with-non-configurable-property.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/target-array-with-non-writable-property.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-non-object.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor-poisoned-throws.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/this-value-null-undefined-throws.js create mode 100644 test/sendable/builtins/Array/prototype/flatMap/thisArg-argument.js diff --git a/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-nested.js b/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-nested.js new file mode 100644 index 00000000000..2ab99edaf3a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-nested.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: > + Does not flatten array-like objects nested into the main array +info: | + FlattenIntoArray(target, source, sourceLen, start, depth [ , mapperFunction, thisArg ]) +---*/ + +function fn(e) { + return e; +} +var obj1 = { + length: 1, + 0: 'a', + toString() { return 'obj1'; } +}; +var obj2 = new Int32Array(2); +var obj3 = { + get length() { throw "should not even consider the length property" }, + toString() { return 'obj3'; } +}; +var arr = [obj1, obj2, obj3]; +var actual = arr.flatMap(fn); +assert.compareArray(actual, arr, 'The value of actual is expected to equal the value of arr'); +assert.notSameValue(actual, arr, 'The value of actual is expected to not equal the value of `arr`'); +var arrLike = { + length: 4, + 0: obj1, + 1: obj2, + 2: obj3, + get 3() { return arrLike }, + toString() { return 'obj4'; } +}; +actual = [].flatMap.call(arrLike, fn); +assert.compareArray(actual, [obj1, obj2, obj3, arrLike], 'The value of actual is expected to be [obj1, obj2, obj3, arrLike]'); +assert.notSameValue(actual, arrLike, 'The value of actual is expected to not equal the value of `arrLike`'); +assert.sameValue( + Object.getPrototypeOf(actual), + SendableArray.prototype, + 'Object.getPrototypeOf([].flatMap.call(arrLike, fn)") returns SendableArray.prototype' +); diff --git a/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-poisoned-length.js b/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-poisoned-length.js new file mode 100644 index 00000000000..dbd3e0818b0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-poisoned-length.js @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: > + Observe abrupt completion in poisoned lengths of array-like objects +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + 1. Let O be ? ToObject(this value). + 2. Let sourceLen be ? ToLength(? Get(O, "length")). +features: [Array.prototype.flatMap, Symbol.toPrimitive] +---*/ + +assert.sameValue(typeof SendableArray.prototype.flatMap, 'function'); +function fn(e) { + return e; +} +var arr = { + length: Symbol(), +}; +assert.throws(TypeError, function() { + [].flatMap.call(arr, fn); +}, 'length is a symbol'); +arr = { + get length() { throw new Test262Error() } +}; +assert.throws(Test262Error, function() { + [].flatMap.call(arr, fn); +}, 'custom get error'); +arr = { + length: { + valueOf() { throw new Test262Error() } + } +}; +assert.throws(Test262Error, function() { + [].flatMap.call(arr, fn); +}, 'custom valueOf error'); +arr = { + length: { + toString() { throw new Test262Error() } + } +}; +assert.throws(Test262Error, function() { + [].flatMap.call(arr, fn); +}, 'custom toString error'); +arr = { + length: { + [Symbol.toPrimitive]() { throw new Test262Error() } + } +}; +assert.throws(Test262Error, function() { + [].flatMap.call(arr, fn); +}, 'custom Symbol.toPrimitive error'); diff --git a/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-typedarrays.js b/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-typedarrays.js new file mode 100644 index 00000000000..63de504b11f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-typedarrays.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: > + array-like objects can be flattened (typedArrays) +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +---*/ + +function same(e) { + return e; +} +var ta; +var actual; +ta = new Int32Array([1, 0, 42]); +Object.defineProperty(ta, 'constructor', { + get() { throw "it should not object the typedarray ctor"; } +}); +actual = [].flatMap.call(ta, same); +assert.compareArray(actual, [1, 0, 42], 'The value of actual is expected to be [1, 0, 42]'); +assert.sameValue(Object.getPrototypeOf(actual), SendableArray.prototype, 'Object.getPrototypeOf([].flatMap.call(ta, same)") returns SendableArray.prototype'); +assert.sameValue(actual instanceof Int32Array, false, 'The result of evaluating (actual instanceof Int32Array) is expected to be false'); +ta = new Int32Array(0); +Object.defineProperty(ta, 'constructor', { + get() { throw "it should not object the typedarray ctor"; } +}); +actual = [].flatMap.call(ta, same); +assert.compareArray(actual, [], 'The value of actual is expected to be []'); +assert.sameValue(Object.getPrototypeOf(actual), SendableArray.prototype, 'Object.getPrototypeOf([].flatMap.call(ta, same)") returns SendableArray.prototype'); +assert.sameValue(actual instanceof Int32Array, false, 'The result of evaluating (actual instanceof Int32Array) is expected to be false'); diff --git a/test/sendable/builtins/Array/prototype/flatMap/array-like-objects.js b/test/sendable/builtins/Array/prototype/flatMap/array-like-objects.js new file mode 100644 index 00000000000..d93c3daa03f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/array-like-objects.js @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: > + array-like objects can be flattened +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +---*/ + +function fn(e) { + return [39, e * 2]; // returns an array to observe it being flattened after +} +var a; +var actual; +a = { + length: 3, + 0: 1, + // property 1 will be fully skipped + 2: 21, + get 3() { throw 'it should not get this property'; } +}; +actual = [].flatMap.call(a, fn); +assert.compareArray(actual, [39, 2, 39, 42], 'The value of actual is expected to be [39, 2, 39, 42]'); +assert.sameValue(Object.getPrototypeOf(actual), SendableArray.prototype, 'Object.getPrototypeOf([].flatMap.call(a, fn)") returns SendableArray.prototype'); +a = { + length: undefined, + get 0() { throw 'it should not get this property'; }, +}; +actual = [].flatMap.call(a, fn); +assert.compareArray(actual, [], 'The value of actual is expected to be []'); +assert.sameValue(Object.getPrototypeOf(actual), SendableArray.prototype, 'Object.getPrototypeOf([].flatMap.call(a, fn)") returns SendableArray.prototype'); +var called = false; +a = { + get length() { + if (!called) { + called = true; + return 2; + } else { + throw 'is should get the length only once'; + } + }, + 0: 21, + 1: 19.5, + get 2() { throw 'it should not get this property'; }, +}; +actual = [].flatMap.call(a, fn); +assert.compareArray(actual, [39, 42, 39, 39], 'The value of actual is expected to be [39, 42, 39, 39]'); +assert.sameValue(Object.getPrototypeOf(actual), SendableArray.prototype, 'Object.getPrototypeOf([].flatMap.call(a, fn)") returns SendableArray.prototype'); +a = { + length: 10001, + [10000]: 7, +}; +actual = [].flatMap.call(a, fn); +assert.compareArray(actual, [39, 14], 'The value of actual is expected to be [39, 14]'); +assert.sameValue(Object.getPrototypeOf(actual), SendableArray.prototype, 'Object.getPrototypeOf([].flatMap.call(a, fn)") returns SendableArray.prototype'); diff --git a/test/sendable/builtins/Array/prototype/flatMap/bound-function-argument.js b/test/sendable/builtins/Array/prototype/flatMap/bound-function-argument.js new file mode 100644 index 00000000000..371ac5778f6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/bound-function-argument.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: > + Behavior when given a bound function +includes: [compareArray.js] +features: [Array.prototype.flatMap] +---*/ + +var a = [0, 0]; +assert.compareArray(a.flatMap(function() { + return this; +}.bind([1, 2])), [1, 2, 1, 2], 'a.flatMap(function() {return this;}.bind([1, 2])) must return [1, 2, 1, 2]'); diff --git a/test/sendable/builtins/Array/prototype/flatMap/call-with-boolean.js b/test/sendable/builtins/Array/prototype/flatMap/call-with-boolean.js new file mode 100644 index 00000000000..b81636074b4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/call-with-boolean.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: Array.prototype.flatMap applied to boolean primitive +includes: [compareArray.js] +---*/ + +assert.compareArray( + SendableArray.prototype.flatMap.call(true, () => {}), + [], + 'SendableArray.prototype.flatMap.call(true, () => {}) must return []' +); +assert.compareArray( + SendableArray.prototype.flatMap.call(false, () => {}), + [], + 'Array.prototype.flatMap.call(false, () => {}) must return []' +); diff --git a/test/sendable/builtins/Array/prototype/flatMap/depth-always-one.js b/test/sendable/builtins/Array/prototype/flatMap/depth-always-one.js new file mode 100644 index 00000000000..b88d0ba80a2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/depth-always-one.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: > + Behavior when array is depth more than 1 +includes: [compareArray.js] +features: [Array.prototype.flatMap] +---*/ + +assert.compareArray([1, 2].flatMap(function(e) { + return [e, e * 2]; +}), [1, 2, 2, 4], '[1, 2].flatMap(function(e) {return [e, e * 2];}) must return [1, 2, 2, 4]'); +var result = [1, 2, 3].flatMap(function(ele) { + return [ + [ele * 2] + ]; +}); +assert.sameValue(result.length, 3, 'The value of result.length is expected to be 3'); +assert.compareArray(result[0], [2], 'The value of result[0] is expected to be [2]'); +assert.compareArray(result[1], [4], 'The value of result[1] is expected to be [4]'); +assert.compareArray(result[2], [6], 'The value of result[2] is expected to be [6]'); diff --git a/test/sendable/builtins/Array/prototype/flatMap/length.js b/test/sendable/builtins/Array/prototype/flatMap/length.js new file mode 100644 index 00000000000..84c3521c821 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/length.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: Array.prototype.flatMap.length value and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [Array.prototype.flatMap] +---*/ + +assert.sameValue( + SendableArray.prototype.flatMap.length, 1, + 'The value of `SendableArray.prototype.flatmap.length` is `1`' +); +verifyProperty(SendableArray.prototype.flatMap, 'length', { + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/flatMap/name.js b/test/sendable/builtins/Array/prototype/flatMap/name.js new file mode 100644 index 00000000000..d97f6510098 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/name.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatmap +description: Array.prototype.flatmap name value and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [Array.prototype.flatMap] +---*/ + +assert.sameValue( + SendableArray.prototype.flatMap.name, 'flatMap', + 'The value of `SendableArray.prototype.flatMap.name` is `"flatMap"`' +); +verifyProperty(SendableArray.prototype.flatMap, 'name', { + enumerable: false, + writable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/flatMap/non-callable-argument-throws.js b/test/sendable/builtins/Array/prototype/flatMap/non-callable-argument-throws.js new file mode 100644 index 00000000000..2fe0ae5ced1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/non-callable-argument-throws.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: > + non callable argument should throw TypeError Exception +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +---*/ + +assert.sameValue(typeof SendableArray.prototype.flatMap, "function"); +assert.throws(TypeError, function() { + [].flatMap({}); +}, 'non callable argument, object'); +assert.throws(TypeError, function() { + [].flatMap(0); +}, 'non callable argument, number'); +assert.throws(TypeError, function() { + [].flatMap(); +}, 'non callable argument, implict undefined'); +assert.throws(TypeError, function() { + [].flatMap(undefined); +}, 'non callable argument, undefined'); +assert.throws(TypeError, function() { + [].flatMap(null); +}, 'non callable argument, null'); +assert.throws(TypeError, function() { + [].flatMap(false); +}, 'non callable argument, boolean'); +assert.throws(TypeError, function() { + [].flatMap(''); +}, 'non callable argument, string'); +var s = Symbol(); +assert.throws(TypeError, function() { + [].flatMap(s); +}, 'non callable argument, symbol'); diff --git a/test/sendable/builtins/Array/prototype/flatMap/not-a-constructor.js b/test/sendable/builtins/Array/prototype/flatMap/not-a-constructor.js new file mode 100644 index 00000000000..f3689c78634 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/not-a-constructor.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.flatMap does not implement [[Construct]], is not new-able +info: | + ECMAScript Function Objects +---*/ + +assert.sameValue( + isConstructor(SendableArray.prototype.flatMap), + false, + 'isConstructor(SendableArray.prototype.flatMap) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.flatMap(() => {}); +}); + diff --git a/test/sendable/builtins/Array/prototype/flatMap/prop-desc.js b/test/sendable/builtins/Array/prototype/flatMap/prop-desc.js new file mode 100644 index 00000000000..72e65fd0bc8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/prop-desc.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.flatMap +description: Property type and descriptor. +info: > + 17 ECMAScript Standard Built-in Objects + 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] +features: [Array.prototype.flatMap] +---*/ + +assert.sameValue( + typeof SendableArray.prototype.flatMap, + 'function', + '`typeof SendableArray.prototype.flatMap` is `function`' +); +verifyProperty(SendableArray.prototype, 'flatMap', { + enumerable: false, + writable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/flatMap/proxy-access-count.js b/test/sendable/builtins/Array/prototype/flatMap/proxy-access-count.js new file mode 100644 index 00000000000..01695a6afc5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/proxy-access-count.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: > + properties are accessed correct number of times by .flatMap +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + 6. Perform ? FlattenIntoArray(A, O, sourceLen, 0, 1, mapperFunction, T). + FlattenIntoArray (target, source, sourceLen, start, depth [ , mapperFunction, thisArg ]) + 3. Repeat, while sourceIndex < sourceLen + a. Let P be ! ToString(sourceIndex). + b. Let exists be ? HasProperty(source, P). + c. If exists is true, then + i. Let element be ? Get(source, P). +features: [Array.prototype.flatMap] +includes: [compareArray.js] +---*/ + +assert.sameValue( + typeof SendableArray.prototype.flatMap, + 'function', + 'The value of `typeof SendableArray.prototype.flatMap` is expected to be "function"' +); +const getCalls = [], hasCalls = []; +const handler = { + get : function (t, p, r) { getCalls.push(p); return Reflect.get(t, p, r); }, + has : function (t, p, r) { hasCalls.push(p); return Reflect.has(t, p, r); } +} +const tier2 = new Proxy([4, 3], handler); +const tier1 = new Proxy([2, [3, 4, 2, 2], 5, tier2, 6], handler); +SendableArray.prototype.flatMap.call(tier1, function(a){ return a; }); +assert.compareArray(getCalls, ["length", "constructor", "0", "1", "2", "3", "length", "0", "1", "4"], 'The value of getCalls is expected to be ["length", "constructor", "0", "1", "2", "3", "length", "0", "1", "4"]'); +assert.compareArray(hasCalls, ["0", "1", "2", "3", "0", "1", "4"], 'The value of hasCalls is expected to be ["0", "1", "2", "3", "0", "1", "4"]'); diff --git a/test/sendable/builtins/Array/prototype/flatMap/target-array-non-extensible.js b/test/sendable/builtins/Array/prototype/flatMap/target-array-non-extensible.js new file mode 100644 index 00000000000..920dbcf094b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/target-array-non-extensible.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatmap +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible, source array gets flattened) +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; +var arr = [[1]]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.flatMap(function(item) { + return item; + }); +}); diff --git a/test/sendable/builtins/Array/prototype/flatMap/target-array-with-non-configurable-property.js b/test/sendable/builtins/Array/prototype/flatMap/target-array-with-non-configurable-property.js new file mode 100644 index 00000000000..bc9d0ab028e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/target-array-with-non-configurable-property.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatmap +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable, source array is not flattened) +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +features: [Symbol.species] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + writable: true, + configurable: false, + }); +}; +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.flatMap(function(item) { + return item; + }); +}); diff --git a/test/sendable/builtins/Array/prototype/flatMap/target-array-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/flatMap/target-array-with-non-writable-property.js new file mode 100644 index 00000000000..877b7d3939a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/target-array-with-non-writable-property.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.flatmap +description: > + Non-writable properties are overwritten by CreateDataProperty. + (result object's "0" is non-writable, source array is not flattened) +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + value: 1, + writable: false, + enumerable: false, + configurable: true, + }); +}; +var arr = [2]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +var res = arr.flatMap(function(item) { + return item; +}); +verifyProperty(res, "0", { + value: 2, + writable: true, + enumerable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-non-object.js b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-non-object.js new file mode 100644 index 00000000000..ddb55188230 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-non-object.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: > + Assert behavior if this value has a custom non-object constructor property +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +includes: [compareArray.js] +---*/ + +assert.sameValue( + typeof SendableArray.prototype.flatMap, + 'function', + 'The value of `typeof SendableArray.prototype.flatMap` is expected to be "function"' +); +var a = []; +var mapperFn = function() {}; +a.constructor = null; +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'a.flatMap(mapperFn) throws a TypeError exception'); +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'a.flatMap(mapperFn) throws a TypeError exception'); +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'a.flatMap(mapperFn) throws a TypeError exception'); +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'a.flatMap(mapperFn) throws a TypeError exception'); +a = []; +a.constructor = Symbol(); +assert.throws(TypeError, function() { + a.flatMap(mapperFn); +}, 'a.flatMap(mapperFn) throws a TypeError exception'); +a = []; +a.constructor = undefined; +var actual = a.flatMap(mapperFn); +assert.compareArray(actual, [], 'The value of actual is expected to be []'); +assert.sameValue( + Object.getPrototypeOf(actual), + SendableArray.prototype, + 'Object.getPrototypeOf(a.flatMap(mapperFn)) returns SendableArray.prototype' +); +assert.notSameValue(actual, a, 'The value of actual is expected to not equal the value of `a`'); diff --git a/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js new file mode 100644 index 00000000000..7b7247bff64 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: > + Assert behavior if this value has a custom object constructor property species +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +---*/ + +assert.sameValue( + typeof SendableArray.prototype.flatMap, + 'function', + 'The value of `typeof Array.prototype.flatMap` is expected to be "function"' +); +var arr = [[42, 1], [42, 2]]; +var mapperFn = function(e) { return e; }; +arr.constructor = {}; +var actual = arr.flatMap(mapperFn); +assert.compareArray(actual, [42, 1, 42, 2], 'The value of actual is expected to be [42, 1, 42, 2]'); +assert.sameValue( + Object.getPrototypeOf(actual), + SendableArray.prototype, + 'Object.getPrototypeOf(arr.flatMap(mapperFn)) returns SendableArray.prototype' +); +var called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return 0; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return ''; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return false; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return {}; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return []; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return Symbol(); + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + throw new Test262Error + } +}; +assert.throws(Test262Error, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a Test262Error exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); diff --git a/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor-poisoned-throws.js b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor-poisoned-throws.js new file mode 100644 index 00000000000..63576dd4c8e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor-poisoned-throws.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: > + Assert behavior if this value has a poisoned custom species constructor +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +features: [Array.prototype.flatMap, Symbol, Symbol.species] +---*/ + +assert.sameValue(typeof SendableArray.prototype.flatMap, 'function'); +var arr = []; +var mapperFn = function(e) { return e; }; +var called = 0; +var ctorCalled = 0; +function ctor(len) { + assert.sameValue(new.target, ctor, 'new target is defined'); + assert.sameValue(len, 0, 'first argument is always 0'); + ctorCalled++; + throw new Test262Error(); +} +arr.constructor = { + get [Symbol.species]() { + called++; + return ctor; + } +}; +assert.throws(Test262Error, function() { + arr.flatMap(mapperFn); +}, 'Return abrupt completion from species custom ctor'); +assert.sameValue(called, 1, 'got species once'); +assert.sameValue(ctorCalled, 1, 'called custom ctor once'); diff --git a/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor.js b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor.js new file mode 100644 index 00000000000..b30769cc1ad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor.js @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: > + Assert behavior if this value has a custom species constructor +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof SendableArray.prototype.flatMap, 'function'); +var arr = [[42, 1], [42, 2]]; +var mapperFn = function(e) { return e; }; +var called = 0; +var ctorCalled = 0; +function ctor(len) { + assert.sameValue(new.target, ctor, 'new target is defined'); + assert.sameValue(len, 0, 'first argument is always 0'); + ctorCalled++; +} +arr.constructor = { + get [Symbol.species]() { + called++; + return ctor; + } +}; +var actual = arr.flatMap(mapperFn); +assert(actual instanceof ctor, 'returned value is an instance of custom ctor'); +assert.sameValue(called, 1, 'got species once'); +assert.sameValue(ctorCalled, 1, 'called custom ctor once'); +assert.sameValue(Object.prototype.hasOwnProperty.call(actual, 'length'), false, 'it does not define an own length property'); +verifyProperty(actual, '0', { + configurable: true, + writable: true, + enumerable: true, + value: 42 +}); +verifyProperty(actual, '1', { + configurable: true, + writable: true, + enumerable: true, + value: 1 +}); +verifyProperty(actual, '2', { + configurable: true, + writable: true, + enumerable: true, + value: 42 +}); +verifyProperty(actual, '3', { + configurable: true, + writable: true, + enumerable: true, + value: 2 +}); diff --git a/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species.js b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species.js new file mode 100644 index 00000000000..fb38a2dd10c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species.js @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.flatMap +description: > + Assert behavior if this value has a custom object constructor property +info: | + SendableArray.prototype.flatMap ( mapperFunction [ , thisArg ] ) +---*/ + +assert.sameValue( + typeof SendableArray.prototype.flatMap, + 'function', + 'The value of `typeof SendableArray.prototype.flatMap` is expected to be "function"' +); +var arr = [[42, 1], [42, 2]]; +var mapperFn = function(e) { return e; }; +arr.constructor = {}; +var actual = arr.flatMap(mapperFn); +assert.compareArray(actual, [42, 1, 42, 2], 'The value of actual is expected to be [42, 1, 42, 2]'); +assert.sameValue( + Object.getPrototypeOf(actual), + SendableArray.prototype, + 'Object.getPrototypeOf(arr.flatMap(mapperFn)) returns SendableArray.prototype' +); +var called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return null; + } +}; +actual = arr.flatMap(mapperFn); +assert.compareArray(actual, [42, 1, 42, 2], 'The value of actual is expected to be [42, 1, 42, 2]'); +assert.sameValue( + Object.getPrototypeOf(actual), + SendableArray.prototype, + 'Object.getPrototypeOf(arr.flatMap(mapperFn)) returns SendableArray.prototype' +); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return undefined; + } +}; +actual = arr.flatMap(mapperFn); +assert.compareArray(actual, [42, 1, 42, 2], 'The value of actual is expected to be [42, 1, 42, 2]'); +assert.sameValue( + Object.getPrototypeOf(actual), + SendableArray.prototype, + 'Object.getPrototypeOf(arr.flatMap(mapperFn)) returns SendableArray.prototype' +); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return 0; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return ''; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return false; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return {}; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return []; + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); +called = 0; +arr.constructor = { + get [Symbol.species]() { + called++; + return Symbol(); + } +}; +assert.throws(TypeError, function() { + arr.flatMap(mapperFn); +}, 'arr.flatMap(mapperFn) throws a TypeError exception'); +assert.sameValue(called, 1, 'The value of called is expected to be 1'); diff --git a/test/sendable/builtins/Array/prototype/flatMap/this-value-null-undefined-throws.js b/test/sendable/builtins/Array/prototype/flatMap/this-value-null-undefined-throws.js new file mode 100644 index 00000000000..8967485fbaa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/this-value-null-undefined-throws.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: > + Throw a TypeError if this value is null or undefined +info: | + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) + 1. Let O be ? ToObject(this value). +features: [Array.prototype.flatMap] +---*/ + +assert.sameValue(typeof SendableArray.prototype.flatMap, 'function'); +var mapperFn = function() {}; +assert.throws(TypeError, function() { + [].flatMap.call(null, mapperFn); +}, 'null value'); +assert.throws(TypeError, function() { + [].flatMap.call(undefined, mapperFn); +}, 'undefined'); diff --git a/test/sendable/builtins/Array/prototype/flatMap/thisArg-argument.js b/test/sendable/builtins/Array/prototype/flatMap/thisArg-argument.js new file mode 100644 index 00000000000..8f39ad21bf8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/flatMap/thisArg-argument.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.flatMap +description: > + Behavior when thisArg is provided + Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +flags: [onlyStrict] +includes: [compareArray.js] +features: [Array.prototype.flatMap] +---*/ + +var a = {}; +var actual; +actual = [1].flatMap(function() { + return [this]; +}, "TestString"); +assert.compareArray(actual, ["TestString"], 'The value of actual is expected to be ["TestString"]'); +actual = [1].flatMap(function() { + return [this]; +}, 1); +assert.compareArray(actual, [1], 'The value of actual is expected to be [1]'); +actual = [1].flatMap(function() { + return [this]; +}, null); +assert.compareArray(actual, [null], 'The value of actual is expected to be [null]'); +actual = [1].flatMap(function() { + return [this]; +}, true); +assert.compareArray(actual, [true], 'The value of actual is expected to be [true]'); +actual = [1].flatMap(function() { + return [this]; +}, a); +assert.compareArray(actual, [a], 'The value of actual is expected to be [a]'); +actual = [1].flatMap(function() { + return [this]; +}, void 0); +assert.compareArray(actual, [undefined], 'The value of actual is expected to be [undefined]'); + -- Gitee From 4e9d6726d431c9f55c9232dbb88a00fd9e8b6fc6 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 25 Dec 2024 17:03:41 +0800 Subject: [PATCH 41/93] add array-foreach Signed-off-by: zhuzhihui7 --- .../Array/prototype/forEach/15.4.4.18-1-1.js | 22 +++ .../Array/prototype/forEach/15.4.4.18-1-10.js | 27 ++++ .../Array/prototype/forEach/15.4.4.18-1-11.js | 28 ++++ .../Array/prototype/forEach/15.4.4.18-1-12.js | 28 ++++ .../Array/prototype/forEach/15.4.4.18-1-13.js | 27 ++++ .../Array/prototype/forEach/15.4.4.18-1-14.js | 28 ++++ .../Array/prototype/forEach/15.4.4.18-1-15.js | 28 ++++ .../Array/prototype/forEach/15.4.4.18-1-2.js | 22 +++ .../Array/prototype/forEach/15.4.4.18-1-3.js | 27 ++++ .../Array/prototype/forEach/15.4.4.18-1-4.js | 29 ++++ .../Array/prototype/forEach/15.4.4.18-1-5.js | 27 ++++ .../Array/prototype/forEach/15.4.4.18-1-6.js | 29 ++++ .../Array/prototype/forEach/15.4.4.18-1-7.js | 25 ++++ .../Array/prototype/forEach/15.4.4.18-1-8.js | 26 ++++ .../Array/prototype/forEach/15.4.4.18-1-9.js | 30 +++++ .../Array/prototype/forEach/15.4.4.18-2-1.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-2-10.js | 40 ++++++ .../Array/prototype/forEach/15.4.4.18-2-11.js | 35 +++++ .../Array/prototype/forEach/15.4.4.18-2-12.js | 42 ++++++ .../Array/prototype/forEach/15.4.4.18-2-13.js | 37 +++++ .../Array/prototype/forEach/15.4.4.18-2-14.js | 31 +++++ .../Array/prototype/forEach/15.4.4.18-2-17.js | 31 +++++ .../Array/prototype/forEach/15.4.4.18-2-18.js | 28 ++++ .../Array/prototype/forEach/15.4.4.18-2-19.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-2-2.js | 25 ++++ .../Array/prototype/forEach/15.4.4.18-2-3.js | 37 +++++ .../Array/prototype/forEach/15.4.4.18-2-4.js | 30 +++++ .../Array/prototype/forEach/15.4.4.18-2-5.js | 44 ++++++ .../Array/prototype/forEach/15.4.4.18-2-6.js | 36 +++++ .../Array/prototype/forEach/15.4.4.18-2-7.js | 37 +++++ .../Array/prototype/forEach/15.4.4.18-2-8.js | 42 ++++++ .../Array/prototype/forEach/15.4.4.18-2-9.js | 47 +++++++ .../Array/prototype/forEach/15.4.4.18-3-1.js | 30 +++++ .../Array/prototype/forEach/15.4.4.18-3-10.js | 31 +++++ .../Array/prototype/forEach/15.4.4.18-3-11.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-3-12.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-3-13.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-3-14.js | 30 +++++ .../Array/prototype/forEach/15.4.4.18-3-15.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-3-16.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-3-17.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-3-18.js | 32 +++++ .../Array/prototype/forEach/15.4.4.18-3-19.js | 37 +++++ .../Array/prototype/forEach/15.4.4.18-3-2.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-3-20.js | 37 +++++ .../Array/prototype/forEach/15.4.4.18-3-21.js | 47 +++++++ .../Array/prototype/forEach/15.4.4.18-3-22.js | 47 +++++++ .../Array/prototype/forEach/15.4.4.18-3-23.js | 51 +++++++ .../Array/prototype/forEach/15.4.4.18-3-24.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-3-25.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-3-3.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-3-4.js | 32 +++++ .../Array/prototype/forEach/15.4.4.18-3-5.js | 32 +++++ .../Array/prototype/forEach/15.4.4.18-3-6.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-3-7.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-3-9.js | 32 +++++ .../Array/prototype/forEach/15.4.4.18-4-1.js | 24 ++++ .../Array/prototype/forEach/15.4.4.18-4-10.js | 35 +++++ .../Array/prototype/forEach/15.4.4.18-4-11.js | 39 ++++++ .../Array/prototype/forEach/15.4.4.18-4-12.js | 26 ++++ .../Array/prototype/forEach/15.4.4.18-4-15.js | 46 +++++++ .../Array/prototype/forEach/15.4.4.18-4-2.js | 26 ++++ .../Array/prototype/forEach/15.4.4.18-4-3.js | 24 ++++ .../Array/prototype/forEach/15.4.4.18-4-4.js | 24 ++++ .../Array/prototype/forEach/15.4.4.18-4-5.js | 24 ++++ .../Array/prototype/forEach/15.4.4.18-4-6.js | 24 ++++ .../Array/prototype/forEach/15.4.4.18-4-7.js | 25 ++++ .../Array/prototype/forEach/15.4.4.18-4-8.js | 37 +++++ .../Array/prototype/forEach/15.4.4.18-4-9.js | 41 ++++++ .../prototype/forEach/15.4.4.18-5-1-s.js | 28 ++++ .../Array/prototype/forEach/15.4.4.18-5-1.js | 31 +++++ .../Array/prototype/forEach/15.4.4.18-5-10.js | 26 ++++ .../Array/prototype/forEach/15.4.4.18-5-11.js | 26 ++++ .../Array/prototype/forEach/15.4.4.18-5-12.js | 26 ++++ .../Array/prototype/forEach/15.4.4.18-5-13.js | 26 ++++ .../Array/prototype/forEach/15.4.4.18-5-14.js | 25 ++++ .../Array/prototype/forEach/15.4.4.18-5-15.js | 26 ++++ .../Array/prototype/forEach/15.4.4.18-5-16.js | 26 ++++ .../Array/prototype/forEach/15.4.4.18-5-17.js | 25 ++++ .../Array/prototype/forEach/15.4.4.18-5-18.js | 26 ++++ .../Array/prototype/forEach/15.4.4.18-5-19.js | 31 +++++ .../Array/prototype/forEach/15.4.4.18-5-2.js | 30 +++++ .../Array/prototype/forEach/15.4.4.18-5-21.js | 26 ++++ .../Array/prototype/forEach/15.4.4.18-5-22.js | 25 ++++ .../Array/prototype/forEach/15.4.4.18-5-23.js | 25 ++++ .../Array/prototype/forEach/15.4.4.18-5-24.js | 25 ++++ .../Array/prototype/forEach/15.4.4.18-5-25.js | 32 +++++ .../Array/prototype/forEach/15.4.4.18-5-3.js | 30 +++++ .../Array/prototype/forEach/15.4.4.18-5-4.js | 33 +++++ .../Array/prototype/forEach/15.4.4.18-5-5.js | 31 +++++ .../Array/prototype/forEach/15.4.4.18-5-6.js | 30 +++++ .../Array/prototype/forEach/15.4.4.18-5-7.js | 25 ++++ .../Array/prototype/forEach/15.4.4.18-5-9.js | 26 ++++ .../Array/prototype/forEach/15.4.4.18-7-1.js | 31 +++++ .../Array/prototype/forEach/15.4.4.18-7-2.js | 31 +++++ .../Array/prototype/forEach/15.4.4.18-7-3.js | 30 +++++ .../Array/prototype/forEach/15.4.4.18-7-4.js | 32 +++++ .../Array/prototype/forEach/15.4.4.18-7-5.js | 32 +++++ .../Array/prototype/forEach/15.4.4.18-7-7.js | 31 +++++ .../Array/prototype/forEach/15.4.4.18-7-8.js | 30 +++++ .../Array/prototype/forEach/15.4.4.18-7-9.js | 39 ++++++ .../prototype/forEach/15.4.4.18-7-b-1.js | 30 +++++ .../prototype/forEach/15.4.4.18-7-b-10.js | 44 ++++++ .../prototype/forEach/15.4.4.18-7-b-11.js | 41 ++++++ .../prototype/forEach/15.4.4.18-7-b-12.js | 43 ++++++ .../prototype/forEach/15.4.4.18-7-b-13.js | 38 ++++++ .../prototype/forEach/15.4.4.18-7-b-14.js | 40 ++++++ .../prototype/forEach/15.4.4.18-7-b-15.js | 43 ++++++ .../prototype/forEach/15.4.4.18-7-b-16.js | 44 ++++++ .../prototype/forEach/15.4.4.18-7-b-2.js | 37 +++++ .../prototype/forEach/15.4.4.18-7-b-3.js | 43 ++++++ .../prototype/forEach/15.4.4.18-7-b-4.js | 44 ++++++ .../prototype/forEach/15.4.4.18-7-b-5.js | 42 ++++++ .../prototype/forEach/15.4.4.18-7-b-6.js | 44 ++++++ .../prototype/forEach/15.4.4.18-7-b-7.js | 42 ++++++ .../prototype/forEach/15.4.4.18-7-b-8.js | 48 +++++++ .../prototype/forEach/15.4.4.18-7-b-9.js | 46 +++++++ .../prototype/forEach/15.4.4.18-7-c-i-1.js | 34 +++++ .../prototype/forEach/15.4.4.18-7-c-i-10.js | 36 +++++ .../prototype/forEach/15.4.4.18-7-c-i-11.js | 43 ++++++ .../prototype/forEach/15.4.4.18-7-c-i-12.js | 37 +++++ .../prototype/forEach/15.4.4.18-7-c-i-13.js | 47 +++++++ .../prototype/forEach/15.4.4.18-7-c-i-14.js | 42 ++++++ .../prototype/forEach/15.4.4.18-7-c-i-15.js | 40 ++++++ .../prototype/forEach/15.4.4.18-7-c-i-16.js | 35 +++++ .../prototype/forEach/15.4.4.18-7-c-i-17.js | 36 +++++ .../prototype/forEach/15.4.4.18-7-c-i-18.js | 34 +++++ .../prototype/forEach/15.4.4.18-7-c-i-19.js | 43 ++++++ .../prototype/forEach/15.4.4.18-7-c-i-2.js | 29 ++++ .../prototype/forEach/15.4.4.18-7-c-i-20.js | 41 ++++++ .../prototype/forEach/15.4.4.18-7-c-i-21.js | 38 ++++++ .../prototype/forEach/15.4.4.18-7-c-i-22.js | 33 +++++ .../prototype/forEach/15.4.4.18-7-c-i-25.js | 33 +++++ .../prototype/forEach/15.4.4.18-7-c-i-26.js | 42 ++++++ .../prototype/forEach/15.4.4.18-7-c-i-27.js | 44 ++++++ .../prototype/forEach/15.4.4.18-7-c-i-28.js | 48 +++++++ .../prototype/forEach/15.4.4.18-7-c-i-29.js | 50 +++++++ .../prototype/forEach/15.4.4.18-7-c-i-3.js | 38 ++++++ .../prototype/forEach/15.4.4.18-7-c-i-30.js | 50 +++++++ .../prototype/forEach/15.4.4.18-7-c-i-31.js | 47 +++++++ .../prototype/forEach/15.4.4.18-7-c-i-4.js | 30 +++++ .../prototype/forEach/15.4.4.18-7-c-i-5.js | 45 +++++++ .../prototype/forEach/15.4.4.18-7-c-i-6.js | 35 +++++ .../prototype/forEach/15.4.4.18-7-c-i-7.js | 37 +++++ .../prototype/forEach/15.4.4.18-7-c-i-8.js | 30 +++++ .../prototype/forEach/15.4.4.18-7-c-i-9.js | 39 ++++++ .../prototype/forEach/15.4.4.18-7-c-ii-1.js | 32 +++++ .../prototype/forEach/15.4.4.18-7-c-ii-10.js | 27 ++++ .../prototype/forEach/15.4.4.18-7-c-ii-11.js | 27 ++++ .../prototype/forEach/15.4.4.18-7-c-ii-12.js | 27 ++++ .../prototype/forEach/15.4.4.18-7-c-ii-13.js | 25 ++++ .../prototype/forEach/15.4.4.18-7-c-ii-16.js | 31 +++++ .../prototype/forEach/15.4.4.18-7-c-ii-17.js | 31 +++++ .../prototype/forEach/15.4.4.18-7-c-ii-18.js | 31 +++++ .../prototype/forEach/15.4.4.18-7-c-ii-19.js | 36 +++++ .../prototype/forEach/15.4.4.18-7-c-ii-2.js | 31 +++++ .../prototype/forEach/15.4.4.18-7-c-ii-20.js | 34 +++++ .../prototype/forEach/15.4.4.18-7-c-ii-21.js | 39 ++++++ .../prototype/forEach/15.4.4.18-7-c-ii-22.js | 39 ++++++ .../prototype/forEach/15.4.4.18-7-c-ii-23.js | 31 +++++ .../prototype/forEach/15.4.4.18-7-c-ii-4.js | 36 +++++ .../prototype/forEach/15.4.4.18-7-c-ii-5.js | 38 ++++++ .../prototype/forEach/15.4.4.18-7-c-ii-6.js | 35 +++++ .../prototype/forEach/15.4.4.18-7-c-ii-7.js | 40 ++++++ .../prototype/forEach/15.4.4.18-7-c-ii-8.js | 37 +++++ .../prototype/forEach/15.4.4.18-7-c-ii-9.js | 27 ++++ .../Array/prototype/forEach/15.4.4.18-8-1.js | 27 ++++ .../Array/prototype/forEach/15.4.4.18-8-10.js | 29 ++++ .../Array/prototype/forEach/15.4.4.18-8-11.js | 32 +++++ .../Array/prototype/forEach/15.4.4.18-8-12.js | 29 ++++ .../Array/prototype/forEach/15.4.4.18-8-13.js | 28 ++++ .../Array/prototype/forEach/15.4.4.18-8-2.js | 31 +++++ .../Array/prototype/forEach/15.4.4.18-8-3.js | 31 +++++ .../Array/prototype/forEach/15.4.4.18-8-4.js | 31 +++++ .../Array/prototype/forEach/15.4.4.18-8-5.js | 31 +++++ .../Array/prototype/forEach/15.4.4.18-8-6.js | 36 +++++ .../Array/prototype/forEach/15.4.4.18-8-7.js | 42 ++++++ .../Array/prototype/forEach/15.4.4.18-8-8.js | 44 ++++++ .../Array/prototype/forEach/15.4.4.18-8-9.js | 44 ++++++ .../Array/prototype/forEach/S15.4.4.18_A1.js | 23 ++++ .../Array/prototype/forEach/S15.4.4.18_A2.js | 26 ++++ .../prototype/forEach/call-with-boolean.js | 29 ++++ .../forEach/callbackfn-resize-arraybuffer.js | 75 +++++++++++ .../Array/prototype/forEach/length.js | 26 ++++ .../builtins/Array/prototype/forEach/name.js | 26 ++++ .../prototype/forEach/not-a-constructor.js | 30 +++++ .../Array/prototype/forEach/prop-desc.js | 28 ++++ .../resizable-buffer-grow-mid-iteration.js | 95 +++++++++++++ .../resizable-buffer-shrink-mid-iteration.js | 89 +++++++++++++ .../prototype/forEach/resizable-buffer.js | 126 ++++++++++++++++++ 190 files changed, 6623 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-1.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-10.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-11.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-12.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-13.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-14.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-15.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-2.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-3.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-4.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-5.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-6.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-7.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-8.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-9.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-1.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-10.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-11.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-12.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-13.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-14.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-17.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-18.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-19.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-2.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-3.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-4.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-5.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-6.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-7.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-8.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-9.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-1.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-10.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-11.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-12.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-13.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-14.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-15.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-16.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-17.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-18.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-19.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-2.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-20.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-21.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-22.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-23.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-24.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-25.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-3.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-4.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-5.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-6.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-7.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-9.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-1.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-10.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-11.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-12.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-15.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-2.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-3.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-4.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-5.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-6.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-7.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-8.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-9.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-1-s.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-1.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-10.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-11.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-12.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-13.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-14.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-15.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-16.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-17.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-18.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-19.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-2.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-21.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-22.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-23.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-24.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-25.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-3.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-4.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-5.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-6.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-7.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-9.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-1.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-2.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-3.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-4.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-5.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-7.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-8.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-9.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-1.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-10.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-11.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-12.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-13.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-14.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-15.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-16.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-2.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-3.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-4.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-5.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-6.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-7.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-8.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-9.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-1.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-10.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-11.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-12.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-13.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-14.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-15.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-16.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-17.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-18.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-19.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-2.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-20.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-21.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-22.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-25.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-26.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-27.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-28.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-29.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-3.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-30.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-31.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-4.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-5.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-6.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-7.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-8.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-9.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-1.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-10.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-11.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-12.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-13.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-16.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-17.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-18.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-19.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-2.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-20.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-21.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-22.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-23.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-4.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-5.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-6.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-7.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-8.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-9.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-1.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-10.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-11.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-12.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-13.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-2.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-3.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-4.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-5.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-6.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-7.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-8.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-9.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/S15.4.4.18_A1.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/S15.4.4.18_A2.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/length.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/name.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/forEach/resizable-buffer.js diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-1.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-1.js new file mode 100644 index 00000000000..b34efe06da9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to undefined +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.forEach.call(undefined); // TypeError is thrown if value is undefined +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-10.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-10.js new file mode 100644 index 00000000000..c0459ab7bf7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-10.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to the Math object +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = ('[object Math]' === Object.prototype.toString.call(obj)); +} +Math.length = 1; +Math[0] = 1; +SendableArray.prototype.forEach.call(Math, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-11.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-11.js new file mode 100644 index 00000000000..c0580d00de4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-11.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to Date object +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = obj instanceof Date; +} +var obj = new Date(0); +obj.length = 1; +obj[0] = 1; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-12.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-12.js new file mode 100644 index 00000000000..7dc1d9c12bf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-12.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to RegExp object +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = obj instanceof RegExp; +} +var obj = new RegExp(); +obj.length = 1; +obj[0] = 1; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-13.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-13.js new file mode 100644 index 00000000000..be4d7b167fa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-13.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to the JSON object +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = ('[object JSON]' === Object.prototype.toString.call(obj)); +} +JSON.length = 1; +JSON[0] = 1; +SendableArray.prototype.forEach.call(JSON, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-14.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-14.js new file mode 100644 index 00000000000..add67548d6e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-14.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to Error object +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = obj instanceof Error; +} +var obj = new Error(); +obj.length = 1; +obj[0] = 1; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-15.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-15.js new file mode 100644 index 00000000000..33f01faf316 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-15.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to the Arguments object +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = ('[object Arguments]' === Object.prototype.toString.call(obj)); +} +var obj = (function() { + return arguments; +}("a", "b")); +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-2.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-2.js new file mode 100644 index 00000000000..4949006f434 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-2.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to null +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.forEach.call(null); // TypeError is thrown if value is null +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-3.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-3.js new file mode 100644 index 00000000000..de9cdce2b3c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-3.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to boolean primitive +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = obj instanceof Boolean; +} +Boolean.prototype[0] = true; +Boolean.prototype.length = 1; +SendableArray.prototype.forEach.call(false, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-4.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-4.js new file mode 100644 index 00000000000..320f7e02d56 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-4.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to Boolean object +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = obj instanceof Boolean; +} +var obj = new Boolean(true); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-5.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-5.js new file mode 100644 index 00000000000..23ddd587635 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-5.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to number primitive +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = obj instanceof Number; +} +Number.prototype[0] = 1; +Number.prototype.length = 1; +SendableArray.prototype.forEach.call(2.5, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-6.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-6.js new file mode 100644 index 00000000000..768ac950acb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-6.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to Number object +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = obj instanceof Number; +} +var obj = new Number(-128); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-7.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-7.js new file mode 100644 index 00000000000..a9ebcfa75b1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-7.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to string primitive +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = obj instanceof String; +} +SendableArray.prototype.forEach.call("abc", callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-8.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-8.js new file mode 100644 index 00000000000..09e0e452822 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-8.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to String object +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = obj instanceof String; +} +var obj = new String("abc"); +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-9.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-9.js new file mode 100644 index 00000000000..df7b28990e2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-1-9.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach applied to Function object +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = obj instanceof Function; +} +var obj = function(a, b) { + return a + b; +}; +obj[0] = 11; +obj[1] = 9; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-1.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-1.js new file mode 100644 index 00000000000..69adec3c82e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-1.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - 'length' is own data property on an + Array-like object +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2 +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-10.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-10.js new file mode 100644 index 00000000000..ce6055d4c90 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-10.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Array-like object, 'length' is + an inherited accessor property +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; +SendableArray.prototype.forEach.call(child, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-11.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-11.js new file mode 100644 index 00000000000..205d4d1d649 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-11.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Array-like object, 'length' is + an own accessor property without a get function +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-12.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-12.js new file mode 100644 index 00000000000..10400a1b779 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-12.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - 'length' is own accessor property + without a get function that overrides an inherited accessor + property on an Array +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var obj = { + 0: 12, + 1: 11 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-13.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-13.js new file mode 100644 index 00000000000..dcfc2f9479e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-13.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to the Array-like object that + 'length' is inherited accessor property without a get function +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 11; +child[1] = 12; +SendableArray.prototype.forEach.call(child, callbackfn); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-14.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-14.js new file mode 100644 index 00000000000..2fafe4c74b2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-14.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to the Array-like object that + 'length' property doesn't exist +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +var obj = { + 0: 11, + 1: 12 +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-17.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-17.js new file mode 100644 index 00000000000..7a72b8e5527 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-17.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to the Arguments object, which + implements its own property get method +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} +var func = function(a, b) { + arguments[2] = 9; + SendableArray.prototype.forEach.call(arguments, callbackfn); + return result; +}; +assert(func(12, 11), 'func(12, 11) !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-18.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-18.js new file mode 100644 index 00000000000..3d89269b052 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-18.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to String object, which implements + its own property get method +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (obj.length === 3); +} +var str = new String("012"); +SendableArray.prototype.forEach.call(str, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-19.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-19.js new file mode 100644 index 00000000000..d6a7742121e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-19.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Function object, which + implements its own property get method +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} +var fun = function(a, b) { + return a + b; +}; +fun[0] = 12; +fun[1] = 11; +fun[2] = 9; +SendableArray.prototype.forEach.call(fun, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-2.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-2.js new file mode 100644 index 00000000000..636da12f19b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - 'length' is own data property on an Array +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} +[12, 11].forEach(callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-3.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-3.js new file mode 100644 index 00000000000..0be91c242e7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-3.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - 'length' is an own data property that + overrides an inherited data property on an Array-like object +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} +var proto = { + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +child[0] = 12; +child[1] = 11; +child[2] = 9; +SendableArray.prototype.forEach.call(child, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-4.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-4.js new file mode 100644 index 00000000000..5ba26230579 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - 'length' is own data property that + overrides an inherited data property on an Array +---*/ + +var result = false; +var arrProtoLen; +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} +arrProtoLen = SendableArray.prototype.length; +SendableArray.prototype.length = 0; +[12, 11].forEach(callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-5.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-5.js new file mode 100644 index 00000000000..dd669fa9d85 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-5.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Array-like object, 'length' is + an own data property that overrides an inherited accessor property +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +SendableArray.prototype.forEach.call(child, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-6.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-6.js new file mode 100644 index 00000000000..ce5430b1095 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-6.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Array-like object, 'length' is + an inherited data property +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} +var proto = { + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; +SendableArray.prototype.forEach.call(child, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-7.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-7.js new file mode 100644 index 00000000000..a86a5e6006d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-7.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Array-like object, 'length' is + an own accessor property +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); +obj[0] = 12; +obj[1] = 11; +obj[2] = 9; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-8.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-8.js new file mode 100644 index 00000000000..5a8443f2a8b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-8.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Array-like object, 'length' is + an own accessor property that overrides an inherited data property +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} +var proto = { + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +SendableArray.prototype.forEach.call(child, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-9.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-9.js new file mode 100644 index 00000000000..a4c80a8d234 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-2-9.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach applied to Array-like object, 'length' is + an own accessor property that overrides an inherited accessor + property +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (obj.length === 2); +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +SendableArray.prototype.forEach.call(child, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-1.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-1.js new file mode 100644 index 00000000000..b992fc178e5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - value of 'length' is undefined +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +var obj = { + 0: 0, + 1: 1, + length: undefined +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-10.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-10.js new file mode 100644 index 00000000000..a9cb044db60 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-10.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - value of 'length' is a number (value is + NaN) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +var obj = { + 0: 9, + length: NaN +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-11.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-11.js new file mode 100644 index 00000000000..185f655de38 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-11.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-11 +description: > + Array.prototype.forEach - 'length' is a string containing a + positive number +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} +var obj = { + 1: 11, + 2: 9, + length: "2" +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-12.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-12.js new file mode 100644 index 00000000000..d89cdaedb1e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-12.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-12 +description: > + Array.prototype.forEach - 'length' is a string containing a + negative number +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} +var obj = { + 1: 11, + 2: 9, + length: "-4294967294" +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(testResult, false, 'testResult'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-13.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-13.js new file mode 100644 index 00000000000..958e97ab877 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-13.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-13 +description: > + Array.prototype.forEach - 'length' is a string containing a + decimal number +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} +var obj = { + 1: 11, + 2: 9, + length: "2.5" +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-14.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-14.js new file mode 100644 index 00000000000..513693fe9a7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-14.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-14 +description: Array.prototype.forEach - 'length' is a string containing -Infinity +---*/ + +var accessed2 = false; +function callbackfn2(val, idx, obj) { + accessed2 = true; +} +var obj2 = { + 0: 9, + length: "-Infinity" +}; +SendableArray.prototype.forEach.call(obj2, callbackfn2); +assert.sameValue(accessed2, false, 'accessed2'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-15.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-15.js new file mode 100644 index 00000000000..4402991ed2f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-15.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-15 +description: > + Array.prototype.forEach - 'length' is a string containing an + exponential number +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} +var obj = { + 1: 11, + 2: 9, + length: "2E0" +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-16.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-16.js new file mode 100644 index 00000000000..0ac5c9bcc1d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-16.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-16 +description: > + Array.prototype.forEach - 'length' is a string containing a hex + number +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} +var obj = { + 1: 11, + 2: 9, + length: "0x0002" +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-17.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-17.js new file mode 100644 index 00000000000..c0f975d3681 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-17.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-17 +description: > + Array.prototype.forEach - 'length' is a string containing a number + with leading zeros +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} +var obj = { + 1: 11, + 2: 9, + length: "0002.00" +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-18.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-18.js new file mode 100644 index 00000000000..4ad7f5f0de7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-18.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-18 +description: > + Array.prototype.forEach - value of 'length' is a string that can't + convert to a number +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +var obj = { + 0: 9, + length: "asdf!_" +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-19.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-19.js new file mode 100644 index 00000000000..340cf3d1292 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-19.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-19 +description: > + Array.prototype.forEach - value of 'length' is an Object which has + an own toString method. +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} +var obj = { + 1: 11, + 2: 9, + length: { + toString: function() { + return '2'; + } + } +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-2.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-2.js new file mode 100644 index 00000000000..34875206a14 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-2.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-2 +description: > + Array.prototype.forEach - value of 'length' is a boolean (value is + true) +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} +var obj = { + 0: 11, + 1: 9, + length: true +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-20.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-20.js new file mode 100644 index 00000000000..6cca2aae7f5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-20.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-20 +description: > + Array.prototype.forEach - value of 'length' is an Object which has + an own valueOf method. +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} +var obj = { + 1: 11, + 2: 9, + length: { + valueOf: function() { + return 2; + } + } +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-21.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-21.js new file mode 100644 index 00000000000..ac733d1336b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-21.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-21 +description: > + Array.prototype.forEach - 'length' is an object that has an own + valueOf method that returns an object and toString method that + returns a string +---*/ + +var testResult = false; +var firstStepOccured = false; +var secondStepOccured = false; +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} +var obj = { + 1: 11, + 2: 9, + length: { + valueOf: function() { + firstStepOccured = true; + return {}; + }, + toString: function() { + secondStepOccured = true; + return '2'; + } + } +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); +assert(firstStepOccured, 'firstStepOccured !== true'); +assert(secondStepOccured, 'secondStepOccured !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-22.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-22.js new file mode 100644 index 00000000000..ceb9ea8504a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-22.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-22 +description: > + Array.prototype.forEach throws TypeError exception when 'length' + is an object with toString and valueOf methods that don�t return + primitive values +---*/ + +var accessed = false; +var firstStepOccured = false; +var secondStepOccured = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +var obj = { + 1: 11, + 2: 12, + length: { + valueOf: function() { + firstStepOccured = true; + return {}; + }, + toString: function() { + secondStepOccured = true; + return {}; + } + } +}; +assert.throws(TypeError, function() { + SendableArray.prototype.forEach.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-23.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-23.js new file mode 100644 index 00000000000..33e5403d39f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-23.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-23 +description: > + Array.prototype.forEach uses inherited valueOf method when + 'length' is an object with an own toString and inherited valueOf + methods +---*/ + +var testResult = false; +var valueOfAccessed = false; +var toStringAccessed = false; +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return '1'; +}; +var obj = { + 1: 11, + 2: 9, + length: child +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-24.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-24.js new file mode 100644 index 00000000000..602343f5c33 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-24.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-24 +description: > + Array.prototype.forEach - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} +var obj = { + 1: 11, + 2: 9, + length: 2.685 +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-25.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-25.js new file mode 100644 index 00000000000..5e5be89694f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-25.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-25 +description: > + Array.prototype.forEach - value of 'length' is a negative + non-integer +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + testResult = (val > 10); +} +var obj = { + 1: 11, + 2: 9, + length: -4294967294.5 +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(testResult, false, 'testResult'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-3.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-3.js new file mode 100644 index 00000000000..2b2e09a891c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-3.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-3 +description: > + Array.prototype.forEach - value of 'length' is a number (value is + 0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +var obj = { + 0: 1, + 1: 1, + length: 0 +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-4.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-4.js new file mode 100644 index 00000000000..9992b20d841 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-4.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-4 +description: > + Array.prototype.forEach - value of 'length' is a number (value is + +0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +var obj = { + 0: 11, + length: +0 +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-5.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-5.js new file mode 100644 index 00000000000..3b6f90a7c78 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-5.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-5 +description: > + Array.prototype.forEach - value of 'length' is a number (value is + -0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +var obj = { + 0: 11, + length: -0 +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-6.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-6.js new file mode 100644 index 00000000000..c47f3044fea --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-6.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-6 +description: > + Array.prototype.forEach - value of 'length' is a number (value is + positive) +---*/ + +var testResult1 = false; +function callbackfn(val, idx, obj) { + testResult1 = (val > 10); +} +var obj = { + 1: 11, + 2: 9, + length: 2 +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult1, 'testResult1 !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-7.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-7.js new file mode 100644 index 00000000000..0e90fc178e6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-7.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-7 +description: > + Array.prototype.forEach - value of 'length' is a number (value is + negative) +---*/ + +var testResult1 = false; +function callbackfn(val, idx, obj) { + testResult1 = (val > 10); +} +var obj = { + 1: 11, + 2: 9, + length: -4294967294 +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(testResult1, false, 'testResult1'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-9.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-9.js new file mode 100644 index 00000000000..64faf1e8af1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-3-9.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-3-9 +description: > + Array.prototype.forEach - value of 'length' is a number (value is + -Infinity) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +var obj = { + 0: 9, + length: -Infinity +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-1.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-1.js new file mode 100644 index 00000000000..3ab26a7b0b4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-1.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-1 +description: Array.prototype.forEach throws TypeError if callbackfn is undefined +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.forEach(); +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-10.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-10.js new file mode 100644 index 00000000000..56f1cc8c836 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-10.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-10 +description: > + Array.prototype.forEach - the exception is not thrown if exception + was thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.forEach.call(obj, undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-11.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-11.js new file mode 100644 index 00000000000..ed4b9044eef --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-11.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-11 +description: > + Array.prototype.forEach - the exception is not thrown if exception + was thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.forEach.call(obj, undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-12.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-12.js new file mode 100644 index 00000000000..3ab0db78f21 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-12.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-12 +description: Array.prototype.forEach - 'callbackfn' is a function +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +[11, 9].forEach(callbackfn); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-15.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-15.js new file mode 100644 index 00000000000..b43e506ccfb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-15.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-15 +description: > + Array.prototype.forEach - calling with no callbackfn is the same + as passing undefined for callbackfn +---*/ + +var obj = { + 10: 10 +}; +var lengthAccessed = false; +var loopAccessed = false; +Object.defineProperty(obj, "length", { + get: function() { + lengthAccessed = true; + return 20; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + loopAccessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.forEach.call(obj); +}); +assert(lengthAccessed, 'lengthAccessed !== true'); +assert.sameValue(loopAccessed, false, 'loopAccessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-2.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-2.js new file mode 100644 index 00000000000..7489eda2133 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-2.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-2 +description: > + Array.prototype.forEach throws ReferenceError if callbackfn is + unreferenced +---*/ + +var arr = new SendableArray(10); +assert.throws(ReferenceError, function() { + arr.forEach(foo); +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-3.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-3.js new file mode 100644 index 00000000000..999f39ab025 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-3.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-3 +description: Array.prototype.forEach throws TypeError if callbackfn is null +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.forEach(null); +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-4.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-4.js new file mode 100644 index 00000000000..1893a7ec748 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-4.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-4 +description: Array.prototype.forEach throws TypeError if callbackfn is boolean +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.forEach(true); +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-5.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-5.js new file mode 100644 index 00000000000..d2be9275131 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-5.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-5 +description: Array.prototype.forEach throws TypeError if callbackfn is number +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.forEach(5); +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-6.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-6.js new file mode 100644 index 00000000000..8e2ff944e06 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-6.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +es5id: 15.4.4.18-4-6 +description: Array.prototype.forEach throws TypeError if callbackfn is string +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.forEach("abc"); +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-7.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-7.js new file mode 100644 index 00000000000..fc16de51320 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-7.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach throws TypeError if callbackfn is Object + without Call internal method +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.forEach(new Object()); +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-8.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-8.js new file mode 100644 index 00000000000..98e39728a2f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-8.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.forEach.call(obj, null); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-9.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-9.js new file mode 100644 index 00000000000..a6330b23c2e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-4-9.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.forEach.call(obj, null); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-1-s.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-1-s.js new file mode 100644 index 00000000000..0565d09af92 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-1-s.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - thisArg not passed to strict callbackfn +flags: [noStrict] +---*/ + +var innerThisCorrect = false; +function callbackfn(val, idx, obj) { + "use strict"; + innerThisCorrect = this === undefined; + return true; +} +[1].forEach(callbackfn); +assert(innerThisCorrect, 'innerThisCorrect !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-1.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-1.js new file mode 100644 index 00000000000..ebbe18dde05 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - thisArg is passed +flags: [noStrict] +---*/ + +(function() { + this._15_4_4_18_5_1 = false; + var _15_4_4_18_5_1 = true; + var result; + function callbackfn(val, idx, obj) { + result = this._15_4_4_18_5_1; + } + var arr = [1]; + arr.forEach(callbackfn) + assert.sameValue(result, false, 'result'); +})(); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-10.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-10.js new file mode 100644 index 00000000000..bd6aa431b2e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-10.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - Array Object can be used as thisArg +---*/ + +var result = false; +var objArray = []; +function callbackfn(val, idx, obj) { + result = (this === objArray); +} +[11].forEach(callbackfn, objArray); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-11.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-11.js new file mode 100644 index 00000000000..282c715a5ad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-11.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - String Object can be used as thisArg +---*/ + +var result = false; +var objString = new String(); +function callbackfn(val, idx, obj) { + result = (this === objString); +} +[11].forEach(callbackfn, objString); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-12.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-12.js new file mode 100644 index 00000000000..1b8f9033f2d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-12.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - Boolean Object can be used as thisArg +---*/ + +var result = false; +var objBoolean = new Boolean(); +function callbackfn(val, idx, obj) { + result = (this === objBoolean); +} +[11].forEach(callbackfn, objBoolean); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-13.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-13.js new file mode 100644 index 00000000000..c8f366b3e98 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-13.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - Number Object can be used as thisArg +---*/ + +var result = false; +var objNumber = new Number(); +function callbackfn(val, idx, obj) { + result = (this === objNumber); +} +[11].forEach(callbackfn, objNumber); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-14.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-14.js new file mode 100644 index 00000000000..d5e6ce9d320 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-14.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - the Math object can be used as thisArg +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (this === Math); +} +[11].forEach(callbackfn, Math); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-15.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-15.js new file mode 100644 index 00000000000..fef77d77c3a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-15.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - Date Object can be used as thisArg +---*/ + +var result = false; +var objDate = new Date(0); +function callbackfn(val, idx, obj) { + result = (this === objDate); +} +[11].forEach(callbackfn, objDate); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-16.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-16.js new file mode 100644 index 00000000000..742dd43aa80 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-16.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - RegExp Object can be used as thisArg +---*/ + +var result = false; +var objRegExp = new RegExp(); +function callbackfn(val, idx, obj) { + result = (this === objRegExp); +} +[11].forEach(callbackfn, objRegExp); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-17.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-17.js new file mode 100644 index 00000000000..49ee63e287e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-17.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - the JSON object can be used as thisArg +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (this === JSON); +} +[11].forEach(callbackfn, JSON); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-18.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-18.js new file mode 100644 index 00000000000..b2a84d57f35 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-18.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - Error Object can be used as thisArg +---*/ + +var result = false; +var objError = new RangeError(); +function callbackfn(val, idx, obj) { + result = (this === objError); +} +[11].forEach(callbackfn, objError); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-19.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-19.js new file mode 100644 index 00000000000..0dd3c799f65 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-19.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - the Arguments object can be used as + thisArg +---*/ + +var result = false; +var arg; +function callbackfn(val, idx, obj) { + result = (this === arg); +} +(function fun() { + arg = arguments; +}(1, 2, 3)); +[11].forEach(callbackfn, arg); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-2.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-2.js new file mode 100644 index 00000000000..4cd1f88f114 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-2.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - thisArg is Object +---*/ + +var res = false; +var o = new Object(); +o.res = true; +var result; +function callbackfn(val, idx, obj) +{ + result = this.res; +} +var arr = [1]; +arr.forEach(callbackfn, o) +assert.sameValue(result, true, 'result'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-21.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-21.js new file mode 100644 index 00000000000..0544b409d6d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-21.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - the global object can be used as thisArg +---*/ + +var global = this; +var result = false; +function callbackfn(val, idx, obj) { + result = (this === global); +} +[11].forEach(callbackfn, this); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-22.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-22.js new file mode 100644 index 00000000000..a4d3881d3a2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-22.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - boolean primitive can be used as thisArg +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (this.valueOf() === false); +} +[11].forEach(callbackfn, false); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-23.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-23.js new file mode 100644 index 00000000000..b40a4d53ca7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-23.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - number primitive can be used as thisArg +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (this.valueOf() === 101); +} +[11].forEach(callbackfn, 101); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-24.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-24.js new file mode 100644 index 00000000000..a685879bd86 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-24.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - string primitive can be used as thisArg +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (this.valueOf() === "abc"); +} +[11].forEach(callbackfn, "abc"); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-25.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-25.js new file mode 100644 index 00000000000..7ecfc436579 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-25.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - thisArg not passed +flags: [noStrict] +---*/ + +function innerObj() { + this._15_4_4_18_5_25 = true; + var _15_4_4_18_5_25 = false; + var result; + function callbackfn(val, idx, obj) { + result = this._15_4_4_18_5_25; + } + var arr = [1]; + arr.forEach(callbackfn) + this.retVal = !result; +} +assert(new innerObj().retVal, 'new innerObj().retVal !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-3.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-3.js new file mode 100644 index 00000000000..9dadd1ebc69 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-3.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - thisArg is Array +---*/ + +var res = false; +var a = new Array(); +a.res = true; +var result; +function callbackfn(val, idx, obj) +{ + result = this.res; +} +var arr = [1]; +arr.forEach(callbackfn, a) +assert.sameValue(result, true, 'result'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-4.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-4.js new file mode 100644 index 00000000000..34ba0c2e1f2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-4.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - thisArg is object from object + template(prototype) +---*/ + +var res = false; +var result; +function callbackfn(val, idx, obj) +{ + result = this.res; +} +function foo() {} +foo.prototype.res = true; +var f = new foo(); +var arr = [1]; +arr.forEach(callbackfn, f) +assert.sameValue(result, true, 'result'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-5.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-5.js new file mode 100644 index 00000000000..595490d2c87 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-5.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - thisArg is object from object template +---*/ + +var res = false; +var result; +function callbackfn(val, idx, obj) +{ + result = this.res; +} +function foo() {} +var f = new foo(); +f.res = true; +var arr = [1]; +arr.forEach(callbackfn, f) +assert.sameValue(result, true, 'result'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-6.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-6.js new file mode 100644 index 00000000000..48e023cb4d2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-6.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - thisArg is function +---*/ + +var res = false; +var result; +function callbackfn(val, idx, obj) +{ + result = this.res; +} +function foo() {} +foo.res = true; +var arr = [1]; +arr.forEach(callbackfn, foo) +assert.sameValue(result, true, 'result'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-7.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-7.js new file mode 100644 index 00000000000..4819d8d794f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-7.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - built-in functions can be used as thisArg +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (this === eval); +} +[11].forEach(callbackfn, eval); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-9.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-9.js new file mode 100644 index 00000000000..ccb8d843f7b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-5-9.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - Function Object can be used as thisArg +---*/ + +var result = false; +var objString = function() {}; +function callbackfn(val, idx, obj) { + result = (this === objString); +} +[11].forEach(callbackfn, objString); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-1.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-1.js new file mode 100644 index 00000000000..5e9a66a7dee --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't consider new elements added to + array after the call +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + callCnt++; + arr[2] = 3; + arr[5] = 6; +} +var arr = [1, 2, , 4, 5]; +arr.forEach(callbackfn); +assert.sameValue(callCnt, 5, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-2.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-2.js new file mode 100644 index 00000000000..794492d1e08 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-2.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't visit deleted elements in array + after the call +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + if (callCnt == 0) + delete arr[3]; + callCnt++; +} +var arr = [1, 2, 3, 4, 5]; +arr.forEach(callbackfn) +assert.sameValue(callCnt, 4, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-3.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-3.js new file mode 100644 index 00000000000..67945b2d45c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-3.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't visit deleted elements when + Array.length is decreased +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + arr.length = 3; + callCnt++; +} +var arr = [1, 2, 3, 4, 5]; +arr.forEach(callbackfn); +assert.sameValue(callCnt, 3, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-4.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-4.js new file mode 100644 index 00000000000..1fe62c23dea --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-4.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't consider newly added elements in + sparse array +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + arr[1000] = 3; + callCnt++; +} +var arr = new SendableArray(10); +arr[1] = 1; +arr[2] = 2; +arr.forEach(callbackfn); +assert.sameValue(callCnt, 2, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-5.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-5.js new file mode 100644 index 00000000000..b31ef847bd0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-5.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach visits deleted element in array after the + call when same index is also present in prototype +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + delete arr[4]; + callCnt++; +} +SendableArray.prototype[4] = 5; +var arr = [1, 2, 3, 4, 5]; +arr.forEach(callbackfn) +delete SendableArray.prototype[4]; +assert.sameValue(callCnt, 5, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-7.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-7.js new file mode 100644 index 00000000000..5a5a9cc0600 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-7.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - considers new value of elements in array + after the call +---*/ + +var result = false; +var arr = [1, 2, 3, 4, 5]; +function callbackfn(val, Idx, obj) { + arr[4] = 6; + if (val >= 6) { + result = true; + } +} +arr.forEach(callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-8.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-8.js new file mode 100644 index 00000000000..b7f3544d2e1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-8.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - no observable effects occur if len is 0 +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +var obj = { + 0: 11, + 1: 12, + length: 0 +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-9.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-9.js new file mode 100644 index 00000000000..733cbcba42d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-9.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - modifications to length don't change + number of iterations +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; +} +var obj = { + 1: 12, + 2: 9, + length: 2 +}; +Object.defineProperty(obj, "0", { + get: function() { + obj.length = 3; + return 11; + }, + configurable: true +}); +SendableArray.prototype.forEach.call(obj, callbackfn); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-1.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-1.js new file mode 100644 index 00000000000..234d169dcf3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn not called for indexes never + been assigned values +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + callCnt++; +} +var arr = new SendableArray(10); +arr[1] = undefined; +arr.forEach(callbackfn); +assert.sameValue(callCnt, 1, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-10.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-10.js new file mode 100644 index 00000000000..d53986f7771 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-10.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - deleting property of prototype causes + prototype index property not to be visited on an Array-like Object +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(val, idx, obj) { + accessed = true; + if (idx === 3) { + testResult = false; + } +} +var obj = { + 2: 2, + length: 20 +}; +Object.defineProperty(obj, "0", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-11.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-11.js new file mode 100644 index 00000000000..632910cf006 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-11.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - deleting property of prototype causes + prototype index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var arr = [0, , ]; +Object.defineProperty(arr, "0", { + get: function() { + delete SendableArray.prototype[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +arr.forEach(callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-12.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-12.js new file mode 100644 index 00000000000..abb702009ec --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-12.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} +var obj = { + 0: 0, + 1: 111, + length: 10 +}; +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-13.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-13.js new file mode 100644 index 00000000000..5589e9331c7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-13.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} +var arr = [0, 111]; +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +arr.forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-14.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-14.js new file mode 100644 index 00000000000..6b0ab0bed21 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-14.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - decreasing length of array causes index + property not to be visited +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(val, idx, obj) { + accessed = true; + if (idx === 3) { + testResult = false; + } +} +var arr = [0, 1, 2, "last"]; +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); +arr.forEach(callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-15.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-15.js new file mode 100644 index 00000000000..162cca6b5a8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-15.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - decreasing length of array with + prototype property causes prototype index property to be visited +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "prototype") { + testResult = true; + } +} +var arr = [0, 1, 2]; +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +arr.forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-16.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-16.js new file mode 100644 index 00000000000..87ed251541c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-16.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - decreasing length of array does not + delete non-configurable properties +flags: [noStrict] +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "unconfigurable") { + testResult = true; + } +} +var arr = [0, 1, 2]; +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +arr.forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-2.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-2.js new file mode 100644 index 00000000000..cb7e6023745 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-2.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - added properties in step 2 are visible + here +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "length") { + testResult = true; + } +} +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + obj[2] = "length"; + return 3; + }, + configurable: true +}); +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-3.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-3.js new file mode 100644 index 00000000000..76b88a3b901 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-3.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - deleted properties in step 2 are visible + here +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(val, idx, obj) { + accessed = true; + if (idx === 8) { + testResult = false; + } +} +var obj = { + 2: 6.99, + 8: 19 +}; +Object.defineProperty(obj, "length", { + get: function() { + delete obj[8]; + return 10; + }, + configurable: true +}); +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-4.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-4.js new file mode 100644 index 00000000000..ea32370d6fe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-4.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - properties added into own object after + current position are visited on an Array-like object +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(obj, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-5.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-5.js new file mode 100644 index 00000000000..a8a5a54d244 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-5.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - properties added into own object after + current position are visited on an Array +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +arr.forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-6.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-6.js new file mode 100644 index 00000000000..98d4b212641 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-6.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - properties can be added to prototype + after current position are visited on an Array-like object +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + testResult = true; + } +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-7.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-7.js new file mode 100644 index 00000000000..391cbb02f07 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-7.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - properties can be added to prototype + after current position are visited on an Array +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + testResult = true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +arr.forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-8.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-8.js new file mode 100644 index 00000000000..634c13566f0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-8.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - deleting own property causes index + property not to be visited on an Array-like object +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-9.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-9.js new file mode 100644 index 00000000000..2c895e973f5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-b-9.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - deleting own property causes index + property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var arr = [1, 2]; +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +arr.forEach(callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-1.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-1.js new file mode 100644 index 00000000000..6cf8e21f1e0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-1.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own data + property on an Array-like object +---*/ + +var kValue = {}; +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 5) { + testResult = (val === kValue); + } +} +var obj = { + 5: kValue, + length: 100 +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-10.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-10.js new file mode 100644 index 00000000000..da4c11eef19 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-10.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property on an Array +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 2) { + testResult = (val === 12); + } +} +var arr = []; +Object.defineProperty(arr, "2", { + get: function() { + return 12; + }, + configurable: true +}); +arr.forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-11.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-11.js new file mode 100644 index 00000000000..d9d872e4298 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-11.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} +var proto = { + 0: 5 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 10; +Object.defineProperty(child, "0", { + get: function() { + return 11; + }, + configurable: true +}); +SendableArray.prototype.forEach.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-12.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-12.js new file mode 100644 index 00000000000..0b3793674a2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-12.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 111); + } +} +var arr = []; +SendableArray.prototype[0] = 10; +Object.defineProperty(arr, "0", { + get: function() { + return 111; + }, + configurable: true +}); +arr.forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-13.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-13.js new file mode 100644 index 00000000000..fe63a7a872a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-13.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (val === 12); + } +} +var proto = {}; +Object.defineProperty(proto, "1", { + get: function() { + return 6; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 10; +Object.defineProperty(child, "1", { + get: function() { + return 12; + }, + configurable: true +}); +SendableArray.prototype.forEach.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-14.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-14.js new file mode 100644 index 00000000000..62ed045c597 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-14.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} +var arr = []; +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 5; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + return 11; + }, + configurable: true +}); +arr.forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-15.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-15.js new file mode 100644 index 00000000000..86e6f092b68 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-15.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (val === 11); + } +} +var proto = {}; +Object.defineProperty(proto, "1", { + get: function() { + return 11; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 20; +SendableArray.prototype.forEach.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-16.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-16.js new file mode 100644 index 00000000000..646370dd1be --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-16.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is inherited + accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 11; + }, + configurable: true +}); +[, , , ].forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-17.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-17.js new file mode 100644 index 00000000000..f530d6d6c58 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-17.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (typeof val === "undefined"); + } +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-18.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-18.js new file mode 100644 index 00000000000..826faf6f6ff --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-18.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (typeof val === "undefined"); + } +} +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +arr.forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-19.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-19.js new file mode 100644 index 00000000000..32ad81ff663 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-19.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (typeof val === "undefined"); + } +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); +Object.defineProperty(Object.prototype, "1", { + get: function() { + return 10; + }, + configurable: true +}); +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-2.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-2.js new file mode 100644 index 00000000000..730fe16135e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-2.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own data + property on an Array +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} +[11].forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-20.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-20.js new file mode 100644 index 00000000000..39541f6a330 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-20.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (typeof val === "undefined"); + } +} +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +Object.defineProperty(Array.prototype, "0", { + get: function() { + return 100; + }, + configurable: true +}); +arr.forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-21.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-21.js new file mode 100644 index 00000000000..6a8a8fa9565 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-21.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (typeof val === "undefined"); + } +} +var proto = {}; +Object.defineProperty(proto, "1", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +SendableArray.prototype.forEach.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-22.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-22.js new file mode 100644 index 00000000000..298c171e2e9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-22.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (typeof val === "undefined"); + } +} +Object.defineProperty(SendableArray.prototype, "0", { + set: function() {}, + configurable: true +}); +[, 1].forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-25.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-25.js new file mode 100644 index 00000000000..596e6358d79 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-25.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - This object is the Arguments object + which implements its own property get method (number of arguments + is less than number of parameters) +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} +var func = function(a, b) { + return SendableArray.prototype.forEach.call(arguments, callbackfn); +}; +func(11); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-26.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-26.js new file mode 100644 index 00000000000..bb03c248087 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-26.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - This object is the Arguments object + which implements its own property get method (number of arguments + equals number of parameters) +---*/ + +var called = 0; +var testResult = false; +function callbackfn(val, idx, obj) { + called++; + if (called !== 1 && !testResult) { + return; + } + if (idx === 0) { + testResult = (val === 11); + } else if (idx === 1) { + testResult = (val === 9); + } else { + testResult = false; + } +} +var func = function(a, b) { + SendableArray.prototype.forEach.call(arguments, callbackfn); +}; +func(11, 9); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-27.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-27.js new file mode 100644 index 00000000000..c9b3ecb2390 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-27.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - This object is the Arguments object + which implements its own property get method (number of arguments + is greater than number of parameters) +---*/ + +var called = 0; +var testResult = false; +function callbackfn(val, idx, obj) { + called++; + if (called !== 1 && !testResult) { + return; + } + if (idx === 0) { + testResult = (val === 11); + } else if (idx === 1) { + testResult = (val === 12); + } else if (idx === 2) { + testResult = (val === 9); + } else { + testResult = false; + } +} +var func = function(a, b) { + return SendableArray.prototype.forEach.call(arguments, callbackfn); +}; +func(11, 12, 9); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-28.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-28.js new file mode 100644 index 00000000000..7060197092d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-28.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element changed by getter on previous + iterations is observed on an Array +---*/ + +var preIterVisible = false; +var arr = []; +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (val === 9); + } +} +Object.defineProperty(arr, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 13; + } + }, + configurable: true +}); +arr.forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-29.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-29.js new file mode 100644 index 00000000000..59949796fea --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-29.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element changed by getter on previous + iterations is observed on an Array-like object +---*/ + +var preIterVisible = false; +var obj = { + length: 2 +}; +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (val === 9); + } +} +Object.defineProperty(obj, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 13; + } + }, + configurable: true +}); +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-3.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-3.js new file mode 100644 index 00000000000..592134b53f4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-3.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var kValue = "abc"; +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 5) { + testResult = (val === kValue); + } +} +var proto = { + 5: 100 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[5] = kValue; +child.length = 10; +SendableArray.prototype.forEach.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-30.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-30.js new file mode 100644 index 00000000000..8d835940699 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-30.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - unnhandled exceptions happened in getter + terminate iteration on an Array-like object +---*/ + +var obj = { + 0: 11, + 5: 10, + 10: 8, + length: 20 +}; +var accessed = false; +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } +} +Object.defineProperty(obj, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +Object.defineProperty(obj, "2", { + get: function() { + accessed = true; + return 100; + }, + configurable: true +}); +assert.throws(RangeError, function() { + SendableArray.prototype.forEach.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-31.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-31.js new file mode 100644 index 00000000000..5dfd0f9ceaf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-31.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - unnhandled exceptions happened in getter + terminate iteration on an Array-like object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } +} +var arr = []; +arr[5] = 10; +arr[10] = 100; +Object.defineProperty(arr, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +Object.defineProperty(arr, "2", { + get: function() { + accessed = true; + return 100; + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.forEach(callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-4.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-4.js new file mode 100644 index 00000000000..6b714ade58a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 12); + } +} +SendableArray.prototype[0] = 11; +[12].forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-5.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-5.js new file mode 100644 index 00000000000..916686b0d2a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-5.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} +var proto = {}; +Object.defineProperty(proto, "0", { + get: function() { + return 5; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +Object.defineProperty(child, "0", { + value: 11, + configurable: true +}); +SendableArray.prototype.forEach.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-6.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-6.js new file mode 100644 index 00000000000..135bb3a4055 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 9; + }, + configurable: true +}); +[11].forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-7.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-7.js new file mode 100644 index 00000000000..a9ca93003aa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-7.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is inherited + data property on an Array-like object +---*/ + +var kValue = 'abc'; +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 5) { + testResult = (val === kValue); + } +} +var proto = { + 5: kValue +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 10; +SendableArray.prototype.forEach.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-8.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-8.js new file mode 100644 index 00000000000..4220d78d14a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-8.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is inherited + data property on an Array +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 1) { + testResult = (val === 13); + } +} +SendableArray.prototype[1] = 13; +[, , , ].forEach(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-9.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-9.js new file mode 100644 index 00000000000..7fe4ad2505c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-i-9.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element to be retrieved is own accessor + property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + testResult = (val === 11); + } +} +var obj = { + 10: 10, + length: 20 +}; +Object.defineProperty(obj, "0", { + get: function() { + return 11; + }, + configurable: true +}); +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-1.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-1.js new file mode 100644 index 00000000000..f88307b0ac8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-1.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - callbackfn called with correct parameters +---*/ + +var bPar = true; +var bCalled = false; +function callbackfn(val, idx, obj) +{ + bCalled = true; + if (obj[idx] !== val) + bPar = false; +} +var arr = [0, 1, true, null, new Object(), "five"]; +arr[999999] = -6.6; +arr.forEach(callbackfn); +assert.sameValue(bCalled, true, 'bCalled'); +assert.sameValue(bPar, true, 'bPar'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-10.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-10.js new file mode 100644 index 00000000000..901417f65ae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-10.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn is called with 1 formal + parameter +---*/ + +var result = false; +function callbackfn(val) { + result = (val > 10); +} +[11].forEach(callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-11.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-11.js new file mode 100644 index 00000000000..048db0d32d5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-11.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn is called with 2 formal + parameter +---*/ + +var result = false; +function callbackfn(val, idx) { + result = (val > 10 && arguments[2][idx] === val); +} +[11].forEach(callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-12.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-12.js new file mode 100644 index 00000000000..50281fffdd4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-12.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn is called with 3 formal + parameter +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (val > 10 && obj[idx] === val); +} +[11].forEach(callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-13.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-13.js new file mode 100644 index 00000000000..5c0fdddb879 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-13.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - callbackfn that uses arguments +---*/ + +var result = false; +function callbackfn() { + result = (arguments[2][arguments[1]] === arguments[0]); +} +[11].forEach(callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-16.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-16.js new file mode 100644 index 00000000000..0c37e483c47 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-16.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - 'this' of 'callbackfn' is a Boolean + object when T is not an object (T is a boolean) +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (this.valueOf() !== false); +} +var obj = { + 0: 11, + length: 2 +}; +SendableArray.prototype.forEach.call(obj, callbackfn, false); +assert.sameValue(result, false, 'result'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-17.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-17.js new file mode 100644 index 00000000000..b5191d0ca9b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-17.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - 'this' of 'callbackfn' is a Number + object when T is not an object (T is a number) +---*/ + +var result = false; +function callbackfn(val, idx, o) { + result = (5 === this.valueOf()); +} +var obj = { + 0: 11, + length: 2 +}; +SendableArray.prototype.forEach.call(obj, callbackfn, 5); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-18.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-18.js new file mode 100644 index 00000000000..b553b06efd3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-18.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - 'this' of 'callbackfn' is an String + object when T is not an object (T is a string) +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = ('hello' === this.valueOf()); +} +var obj = { + 0: 11, + length: 2 +}; +SendableArray.prototype.forEach.call(obj, callbackfn, "hello"); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-19.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-19.js new file mode 100644 index 00000000000..eadcecdf187 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-19.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - non-indexed properties are not called +---*/ + +var accessed = false; +var result = true; +function callbackfn(val, idx, obj) { + accessed = true; + if (val === 8) { + result = false; + } +} +var obj = { + 0: 11, + 10: 12, + non_index_property: 8, + length: 20 +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(result, 'result !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-2.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-2.js new file mode 100644 index 00000000000..c6ca643b6f9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-2.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - callbackfn takes 3 arguments +---*/ + +var parCnt = 3; +var bCalled = false +function callbackfn(val, idx, obj) +{ + bCalled = true; + if (arguments.length !== 3) + parCnt = arguments.length; //verify if callbackfn was called with 3 parameters +} +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +arr.forEach(callbackfn); +assert.sameValue(bCalled, true, 'bCalled'); +assert.sameValue(parCnt, 3, 'parCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-20.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-20.js new file mode 100644 index 00000000000..5b251517ed7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-20.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn called with correct + parameters (thisArg is correct) +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + result = (10 === this.threshold); +} +var thisArg = { + threshold: 10 +}; +var obj = { + 0: 11, + length: 1 +}; +SendableArray.prototype.forEach.call(obj, callbackfn, thisArg); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-21.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-21.js new file mode 100644 index 00000000000..e35c14e6e77 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-21.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn called with correct + parameters (kValue is correct) +---*/ + +var resultOne = false; +var resultTwo = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + resultOne = (val === 11); + } + if (idx === 1) { + resultTwo = (val === 12); + } +} +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(resultOne, 'resultOne !== true'); +assert(resultTwo, 'resultTwo !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-22.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-22.js new file mode 100644 index 00000000000..50c0e65437d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-22.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn called with correct + parameters (the index k is correct) +---*/ + +var resultOne = false; +var resultTwo = false; +function callbackfn(val, idx, obj) { + if (val === 11) { + resultOne = (idx === 0); + } + if (val === 12) { + resultTwo = (idx === 1); + } +} +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(resultOne, 'resultOne !== true'); +assert(resultTwo, 'resultTwo !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-23.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-23.js new file mode 100644 index 00000000000..24a5f885d74 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-23.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn called with correct + parameters (this object O is correct) +---*/ + +var result = false; +var obj = { + 0: 11, + length: 2 +}; +function callbackfn(val, idx, o) { + result = (obj === o); +} +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-4.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-4.js new file mode 100644 index 00000000000..06707c8a476 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-4.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - k values are passed in ascending numeric + order +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +var lastIdx = 0; +var called = 0; +var result = true; +function callbackfn(val, idx, o) { + called++; + if (lastIdx !== idx) { + result = false; + } else { + lastIdx++; + } +} +arr.forEach(callbackfn); +assert(result, 'result !== true'); +assert.sameValue(arr.length, called, 'arr.length'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-5.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-5.js new file mode 100644 index 00000000000..79d6f552c46 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-5.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - k values are accessed during each + iteration and not prior to starting the loop on an Array +---*/ + +var result = true; +var kIndex = []; +//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(val, idx, obj) { + //Each position should be visited one time, which means k is accessed one time during iterations. + if (typeof kIndex[idx] === "undefined") { + //when current position is visited, its previous index should has been visited. + if (idx !== 0 && typeof kIndex[idx - 1] === "undefined") { + result = false; + } + kIndex[idx] = 1; + } else { + result = false; + } +} +[11, 12, 13, 14].forEach(callbackfn, undefined); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-6.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-6.js new file mode 100644 index 00000000000..f18641e4269 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - arguments to callbackfn are self + consistent +---*/ + +var result = false; +var obj = { + 0: 11, + length: 1 +}; +var thisArg = {}; +function callbackfn() { + result = (this === thisArg && + arguments[0] === 11 && + arguments[1] === 0 && + arguments[2] === obj); +} +SendableArray.prototype.forEach.call(obj, callbackfn, thisArg); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-7.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-7.js new file mode 100644 index 00000000000..f534ba99195 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-7.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - unhandled exceptions happened in + callbackfn terminate iteration +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + if (idx > 0) { + accessed = true; + } + if (idx === 0) { + throw new Error("Exception occurred in callbackfn"); + } +} +var obj = { + 0: 11, + 4: 10, + 10: 8, + length: 20 +}; +assert.throws(Error, function() { + SendableArray.prototype.forEach.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-8.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-8.js new file mode 100644 index 00000000000..410b953665d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-8.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - element changed by callbackfn on + previous iterations is observed +---*/ + +var result = false; +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +function callbackfn(val, idx, o) { + if (idx === 0) { + obj[idx + 1] = 8; + } + if (idx === 1) { + result = (val === 8); + } +} +SendableArray.prototype.forEach.call(obj, callbackfn); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-9.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-9.js new file mode 100644 index 00000000000..f6af803c6e1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-7-c-ii-9.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - callbackfn is called with 0 formal + parameter +---*/ + +var called = 0; +function callbackfn() { + called++; +} +[11, 12].forEach(callbackfn); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-1.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-1.js new file mode 100644 index 00000000000..5af5cc1b966 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-1.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (empty array) +---*/ + +var callCnt = 0; +function cb() { + callCnt++ +} +var i = [].forEach(cb); +assert.sameValue(callCnt, 0, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-10.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-10.js new file mode 100644 index 00000000000..ba2c5395ee1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-10.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach - subclassed array when length is reduced +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = 1; +var callCnt = 0; +function cb() { + callCnt++ +} +var i = f.forEach(cb); +assert.sameValue(callCnt, 1, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-11.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-11.js new file mode 100644 index 00000000000..3bc671353f1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-11.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't mutate the array on which it is + called on +---*/ + +function callbackfn(val, idx, obj) +{ + return true; +} +var arr = [1, 2, 3, 4, 5]; +arr.forEach(callbackfn); +assert.sameValue(arr[0], 1, 'arr[0]'); +assert.sameValue(arr[1], 2, 'arr[1]'); +assert.sameValue(arr[2], 3, 'arr[2]'); +assert.sameValue(arr[3], 4, 'arr[3]'); +assert.sameValue(arr[4], 5, 'arr[4]'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-12.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-12.js new file mode 100644 index 00000000000..22df27f91b3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-12.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: Array.prototype.forEach doesn't visit expandos +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + callCnt++; +} +var arr = [1, 2, 3, 4, 5]; +arr["i"] = 10; +arr[true] = 11; +arr.forEach(callbackfn); +assert.sameValue(callCnt, 5, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-13.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-13.js new file mode 100644 index 00000000000..6f85b1e7ef6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-13.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach - undefined will be returned when 'len' is + 0 +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; +} +var result = [].forEach(callbackfn); +assert.sameValue(typeof result, "undefined", 'typeof result'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-2.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-2.js new file mode 100644 index 00000000000..c5bfd7dae01 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-2.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden to null (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = null; +var callCnt = 0; +function cb() { + callCnt++ +} +var i = f.forEach(cb); +assert.sameValue(callCnt, 0, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-3.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-3.js new file mode 100644 index 00000000000..69b2565d140 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-3.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden to false (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = false; +var callCnt = 0; +function cb() { + callCnt++ +} +var i = f.forEach(cb); +assert.sameValue(callCnt, 0, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-4.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-4.js new file mode 100644 index 00000000000..ddf8288092d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-4.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden to 0 (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = 0; +var callCnt = 0; +function cb() { + callCnt++ +} +var i = f.forEach(cb); +assert.sameValue(callCnt, 0, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-5.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-5.js new file mode 100644 index 00000000000..7d4b3a5834a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-5.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden to '0' (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = '0'; +var callCnt = 0; +function cb() { + callCnt++ +} +var i = f.forEach(cb); +assert.sameValue(callCnt, 0, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-6.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-6.js new file mode 100644 index 00000000000..6163600a43c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-6.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden with obj with valueOf) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; +var callCnt = 0; +function cb() { + callCnt++ +} +var i = f.forEach(cb); +assert.sameValue(callCnt, 0, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-7.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-7.js new file mode 100644 index 00000000000..1a157861f2e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-7.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden with obj w/o valueOf + (toString)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +var callCnt = 0; +function cb() { + callCnt++ +} +var i = f.forEach(cb); +assert.sameValue(callCnt, 0, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-8.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-8.js new file mode 100644 index 00000000000..57b6112c345 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-8.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden with [] +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = []; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +var callCnt = 0; +function cb() { + callCnt++ +} +var i = f.forEach(cb); +assert.sameValue(callCnt, 0, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-9.js b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-9.js new file mode 100644 index 00000000000..dc97a58a266 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/15.4.4.18-8-9.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach doesn't call callbackfn if 'length' is 0 + (subclassed Array, length overridden with [0] +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = [0]; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +var callCnt = 0; +function cb() { + callCnt++ +} +var i = f.forEach(cb); +assert.sameValue(callCnt, 0, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/forEach/S15.4.4.18_A1.js b/test/sendable/builtins/Array/prototype/forEach/S15.4.4.18_A1.js new file mode 100644 index 00000000000..680c7252ba6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/S15.4.4.18_A1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: array.forEach can be frozen while in progress +esid: sec-array.prototype.foreach +description: Freezes array.forEach during a forEach to see if it works +---*/ + +['z'].forEach(function() { + Object.freeze(SendableArray.prototype.forEach); +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/S15.4.4.18_A2.js b/test/sendable/builtins/Array/prototype/forEach/S15.4.4.18_A2.js new file mode 100644 index 00000000000..b60456618a1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/S15.4.4.18_A2.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: array.forEach can be frozen while in progress +esid: sec-array.prototype.foreach +description: Freezes array.forEach during a forEach to see if it works +---*/ + +function foo() { + ['z'].forEach(function() { + Object.freeze(SendableArray.prototype.forEach); + }); +} +foo(); diff --git a/test/sendable/builtins/Array/prototype/forEach/call-with-boolean.js b/test/sendable/builtins/Array/prototype/forEach/call-with-boolean.js new file mode 100644 index 00000000000..19c6c55b9e6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/call-with-boolean.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.forEach +description: Array.prototype.forEach applied to boolean primitive +---*/ + +assert.sameValue( + SendableArray.prototype.forEach.call(true, () => {}), + undefined, + 'SendableArray.prototype.forEach.call(true, () => {}) must return undefined' +); +assert.sameValue( + SendableArray.prototype.forEach.call(false, () => {}), + undefined, + 'SendableArray.prototype.forEach.call(false, () => {}) must return undefined' +); diff --git a/test/sendable/builtins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js b/test/sendable/builtins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js new file mode 100644 index 00000000000..15137d31f4d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/callbackfn-resize-arraybuffer.js @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.forEach +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + elements = []; + indices = []; + arrays = []; + result = SendableArray.prototype.forEach.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + elements.push(element); + indices.push(index); + arrays.push(array); + }); + assert.compareArray(elements, expectedElements, 'elements (shrink)'); + assert.compareArray(indices, expectedIndices, 'indices (shrink)'); + assert.compareArray(arrays, expectedArrays, 'arrays (shrink)'); + assert.sameValue(result, undefined, 'result (shrink)'); + elements = []; + indices = []; + arrays = []; + result = SendableArray.prototype.forEach.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + }); + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, undefined, 'result (grow)'); +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/length.js b/test/sendable/builtins/Array/prototype/forEach/length.js new file mode 100644 index 00000000000..60a65ed45d4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/length.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.forEach +description: > + The "length" property of Array.prototype.forEach +---*/ + +verifyProperty(SendableArray.prototype.forEach, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/name.js b/test/sendable/builtins/Array/prototype/forEach/name.js new file mode 100644 index 00000000000..cf86cc5d4a0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/name.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.prototype.forEach.name is "forEach". +---*/ + +verifyProperty(SendableArray.prototype.forEach, "name", { + value: "forEach", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/not-a-constructor.js b/test/sendable/builtins/Array/prototype/forEach/not-a-constructor.js new file mode 100644 index 00000000000..1eab3fc12cc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/not-a-constructor.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.forEach does not implement [[Construct]], is not new-able +---*/ + +assert.sameValue( + isConstructor(SendableArray.prototype.forEach), + false, + 'isConstructor(SendableArray.prototype.forEach) must return false' +); + +assert.throws(TypeError, () => { + new SendableArray.prototype.forEach(() => {}); +}); + diff --git a/test/sendable/builtins/Array/prototype/forEach/prop-desc.js b/test/sendable/builtins/Array/prototype/forEach/prop-desc.js new file mode 100644 index 00000000000..c5b0eed1564 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/prop-desc.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.forEach +description: > + "forEach" property of Array.prototype +info: | +---*/ + +assert.sameValue(typeof SendableArray.prototype.forEach, 'function', 'typeof'); + +verifyProperty(SendableArray.prototype, "forEach", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/forEach/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/Array/prototype/forEach/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..4de88c05296 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.p.forEach behaves correctly when receiver is backed by resizable + buffer that is grown mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +// Test for forEach. +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.forEach.call(fixedLength, ResizeMidIteration); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.forEach.call(fixedLengthWithOffset, ResizeMidIteration); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.forEach.call(lengthTracking, ResizeMidIteration); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.forEach.call(lengthTrackingWithOffset, ResizeMidIteration); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/forEach/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/Array/prototype/forEach/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..bd7f4fbe0db --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-%array%.prototype.foreach +description: > + Array.p.forEach behaves correctly on TypedArrays backed by resizable buffers + that are shrunk mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.forEach.call(fixedLength, ResizeMidIteration); + assert.compareArray(values, [ + 0, + 2 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.forEach.call(fixedLengthWithOffset, ResizeMidIteration); + assert.compareArray(values, [ + 4 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.forEach.call(lengthTracking, ResizeMidIteration); + assert.compareArray(values, [ + 0, + 2, + 4 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.forEach.call(lengthTrackingWithOffset, ResizeMidIteration); + assert.compareArray(values, [ + 4 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/forEach/resizable-buffer.js b/test/sendable/builtins/Array/prototype/forEach/resizable-buffer.js new file mode 100644 index 00000000000..6eaae7b71f4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/forEach/resizable-buffer.js @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.foreach +description: > + Array.p.forEach behaves correctly on TypedArrays backed by resizable buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + function Collect(array) { + const forEachValues = []; + SendableArray.prototype.forEach.call(array, n => { + forEachValues.push(n); + }); + return ToNumbers(forEachValues); + } + assert.compareArray(Collect(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(Collect(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(Collect(lengthTracking), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(Collect(lengthTrackingWithOffset), [ + 4, + 6 + ]); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.compareArray(Collect(fixedLength), []); + assert.compareArray(Collect(fixedLengthWithOffset), []); + assert.compareArray(Collect(lengthTracking), [ + 0, + 2, + 4 + ]); + assert.compareArray(Collect(lengthTrackingWithOffset), [4]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.compareArray(Collect(fixedLength), []); + assert.compareArray(Collect(fixedLengthWithOffset), []); + assert.compareArray(Collect(lengthTracking), [0]); + // Shrink to zero. + rab.resize(0); + assert.compareArray(Collect(fixedLength), []); + assert.compareArray(Collect(fixedLengthWithOffset), []); + assert.compareArray(Collect(lengthTrackingWithOffset), []); + assert.compareArray(Collect(lengthTracking), []); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + assert.compareArray(Collect(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(Collect(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(Collect(lengthTracking), [ + 0, + 2, + 4, + 6, + 8, + 10 + ]); + assert.compareArray(Collect(lengthTrackingWithOffset), [ + 4, + 6, + 8, + 10 + ]); +} -- Gitee From bc6feb9eee2fc95a888552cf864f7e8fc20f1681 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 26 Dec 2024 09:56:21 +0800 Subject: [PATCH 42/93] function Signed-off-by: zhuzhihui7 --- .../builtins/Function/15.3.2.1-10-6gs.js | 27 +++++ .../builtins/Function/15.3.2.1-11-1-s.js | 27 +++++ .../builtins/Function/15.3.2.1-11-1.js | 23 ++++ .../builtins/Function/15.3.2.1-11-2-s.js | 24 ++++ .../builtins/Function/15.3.2.1-11-3-s.js | 27 +++++ .../builtins/Function/15.3.2.1-11-3.js | 23 ++++ .../builtins/Function/15.3.2.1-11-4-s.js | 25 ++++ .../builtins/Function/15.3.2.1-11-5-s.js | 27 +++++ .../builtins/Function/15.3.2.1-11-5.js | 23 ++++ .../builtins/Function/15.3.2.1-11-6-s.js | 24 ++++ .../builtins/Function/15.3.2.1-11-7-s.js | 25 ++++ .../builtins/Function/15.3.2.1-11-8-s.js | 26 +++++ .../builtins/Function/15.3.2.1-11-9-s.js | 25 ++++ test/sendable/builtins/Function/15.3.5-1gs.js | 28 +++++ test/sendable/builtins/Function/15.3.5-2gs.js | 28 +++++ .../builtins/Function/15.3.5.4_2-10gs.js | 33 ++++++ .../builtins/Function/15.3.5.4_2-11gs.js | 31 +++++ .../builtins/Function/15.3.5.4_2-12gs.js | 30 +++++ .../builtins/Function/15.3.5.4_2-13gs.js | 32 +++++ .../builtins/Function/15.3.5.4_2-14gs.js | 32 +++++ .../builtins/Function/15.3.5.4_2-15gs.js | 35 ++++++ .../builtins/Function/15.3.5.4_2-16gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-17gs.js | 35 ++++++ .../builtins/Function/15.3.5.4_2-18gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-19gs.js | 33 ++++++ .../builtins/Function/15.3.5.4_2-1gs.js | 34 ++++++ .../builtins/Function/15.3.5.4_2-20gs.js | 35 ++++++ .../builtins/Function/15.3.5.4_2-21gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-22gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-23gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-24gs.js | 39 +++++++ .../builtins/Function/15.3.5.4_2-25gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-26gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-27gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-28gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-29gs.js | 35 ++++++ .../builtins/Function/15.3.5.4_2-2gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-30gs.js | 40 +++++++ .../builtins/Function/15.3.5.4_2-31gs.js | 39 +++++++ .../builtins/Function/15.3.5.4_2-32gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-33gs.js | 40 +++++++ .../builtins/Function/15.3.5.4_2-34gs.js | 39 +++++++ .../builtins/Function/15.3.5.4_2-35gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-36gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-37gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-38gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-39gs.js | 39 +++++++ .../builtins/Function/15.3.5.4_2-3gs.js | 34 ++++++ .../builtins/Function/15.3.5.4_2-40gs.js | 39 +++++++ .../builtins/Function/15.3.5.4_2-41gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-42gs.js | 39 +++++++ .../builtins/Function/15.3.5.4_2-43gs.js | 39 +++++++ .../builtins/Function/15.3.5.4_2-44gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-45gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-46gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-47gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-48gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-49gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-4gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-50gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-51gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-52gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-53gs.js | 39 +++++++ .../builtins/Function/15.3.5.4_2-54gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-55gs.js | 39 +++++++ .../builtins/Function/15.3.5.4_2-56gs.js | 40 +++++++ .../builtins/Function/15.3.5.4_2-57gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-58gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-59gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-5gs.js | 33 ++++++ .../builtins/Function/15.3.5.4_2-60gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-61gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-62gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-63gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-64gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-65gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-66gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-67gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-68gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-69gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-6gs.js | 35 ++++++ .../builtins/Function/15.3.5.4_2-70gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-71gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-72gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-73gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-74gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-75gs.js | 39 +++++++ .../builtins/Function/15.3.5.4_2-76gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-77gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-78gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-79gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-7gs.js | 32 +++++ .../builtins/Function/15.3.5.4_2-80gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-81gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-82gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-83gs.js | 39 +++++++ .../builtins/Function/15.3.5.4_2-84gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-85gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-86gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-87gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-88gs.js | 39 +++++++ .../builtins/Function/15.3.5.4_2-89gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-8gs.js | 33 ++++++ .../builtins/Function/15.3.5.4_2-90gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-91gs.js | 37 ++++++ .../builtins/Function/15.3.5.4_2-92gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-93gs.js | 39 +++++++ .../builtins/Function/15.3.5.4_2-94gs.js | 36 ++++++ .../builtins/Function/15.3.5.4_2-95gs.js | 34 ++++++ .../builtins/Function/15.3.5.4_2-96gs.js | 40 +++++++ .../builtins/Function/15.3.5.4_2-97gs.js | 38 ++++++ .../builtins/Function/15.3.5.4_2-9gs.js | 33 ++++++ .../builtins/Function/S10.1.1_A1_T3.js | 34 ++++++ .../builtins/Function/S15.3.1_A1_T1.js | 34 ++++++ .../builtins/Function/S15.3.2.1_A1_T1.js | 40 +++++++ .../builtins/Function/S15.3.2.1_A1_T10.js | 36 ++++++ .../builtins/Function/S15.3.2.1_A1_T11.js | 36 ++++++ .../builtins/Function/S15.3.2.1_A1_T12.js | 36 ++++++ .../builtins/Function/S15.3.2.1_A1_T13.js | 37 ++++++ .../builtins/Function/S15.3.2.1_A1_T2.js | 44 +++++++ .../builtins/Function/S15.3.2.1_A1_T3.js | 36 ++++++ .../builtins/Function/S15.3.2.1_A1_T4.js | 40 +++++++ .../builtins/Function/S15.3.2.1_A1_T5.js | 40 +++++++ .../builtins/Function/S15.3.2.1_A1_T6.js | 38 ++++++ .../builtins/Function/S15.3.2.1_A1_T7.js | 38 ++++++ .../builtins/Function/S15.3.2.1_A1_T8.js | 39 +++++++ .../builtins/Function/S15.3.2.1_A1_T9.js | 34 ++++++ .../builtins/Function/S15.3.2.1_A2_T1.js | 33 ++++++ .../builtins/Function/S15.3.2.1_A2_T2.js | 33 ++++++ .../builtins/Function/S15.3.2.1_A2_T3.js | 33 ++++++ .../builtins/Function/S15.3.2.1_A2_T4.js | 41 +++++++ .../builtins/Function/S15.3.2.1_A2_T5.js | 41 +++++++ .../builtins/Function/S15.3.2.1_A2_T6.js | 41 +++++++ .../builtins/Function/S15.3.2.1_A3_T1.js | 50 ++++++++ .../builtins/Function/S15.3.2.1_A3_T10.js | 48 ++++++++ .../builtins/Function/S15.3.2.1_A3_T11.js | 42 +++++++ .../builtins/Function/S15.3.2.1_A3_T12.js | 42 +++++++ .../builtins/Function/S15.3.2.1_A3_T13.js | 40 +++++++ .../builtins/Function/S15.3.2.1_A3_T14.js | 44 +++++++ .../builtins/Function/S15.3.2.1_A3_T15.js | 40 +++++++ .../builtins/Function/S15.3.2.1_A3_T2.js | 47 ++++++++ .../builtins/Function/S15.3.2.1_A3_T3.js | 53 +++++++++ .../builtins/Function/S15.3.2.1_A3_T4.js | 44 +++++++ .../builtins/Function/S15.3.2.1_A3_T5.js | 42 +++++++ .../builtins/Function/S15.3.2.1_A3_T6.js | 43 +++++++ .../builtins/Function/S15.3.2.1_A3_T7.js | 44 +++++++ .../builtins/Function/S15.3.2.1_A3_T8.js | 42 +++++++ .../builtins/Function/S15.3.2.1_A3_T9.js | 44 +++++++ test/sendable/builtins/Function/S15.3.2_A1.js | 29 +++++ test/sendable/builtins/Function/S15.3.3_A1.js | 21 ++++ .../builtins/Function/S15.3.3_A2_T1.js | 26 +++++ .../builtins/Function/S15.3.3_A2_T2.js | 26 +++++ test/sendable/builtins/Function/S15.3.3_A3.js | 22 ++++ .../builtins/Function/S15.3.5_A1_T1.js | 28 +++++ .../builtins/Function/S15.3.5_A1_T2.js | 28 +++++ .../builtins/Function/S15.3.5_A2_T1.js | 28 +++++ .../builtins/Function/S15.3.5_A2_T2.js | 30 +++++ .../builtins/Function/S15.3.5_A3_T1.js | 27 +++++ .../builtins/Function/S15.3.5_A3_T2.js | 29 +++++ test/sendable/builtins/Function/S15.3_A1.js | 26 +++++ .../sendable/builtins/Function/S15.3_A2_T1.js | 32 +++++ .../sendable/builtins/Function/S15.3_A2_T2.js | 32 +++++ .../sendable/builtins/Function/S15.3_A3_T1.js | 39 +++++++ .../sendable/builtins/Function/S15.3_A3_T2.js | 33 ++++++ .../sendable/builtins/Function/S15.3_A3_T3.js | 45 +++++++ .../sendable/builtins/Function/S15.3_A3_T4.js | 30 +++++ .../sendable/builtins/Function/S15.3_A3_T5.js | 38 ++++++ .../sendable/builtins/Function/S15.3_A3_T6.js | 32 +++++ .../StrictFunction_reservedwords_with.js | 34 ++++++ .../StrictFunction_restricted-properties.js | 63 ++++++++++ .../Function/call-bind-this-realm-undef.js | 43 +++++++ .../Function/call-bind-this-realm-value.js | 56 +++++++++ .../builtins/Function/instance-name.js | 34 ++++++ .../internals/Call/class-ctor-realm.js | 30 +++++ .../Function/internals/Call/class-ctor.js | 30 +++++ .../base-ctor-revoked-proxy-realm.js | 70 +++++++++++ .../Construct/base-ctor-revoked-proxy.js | 67 +++++++++++ .../Construct/derived-return-val-realm.js | 42 +++++++ .../internals/Construct/derived-return-val.js | 38 ++++++ .../derived-this-uninitialized-realm.js | 41 +++++++ .../Construct/derived-this-uninitialized.js | 38 ++++++ .../builtins/Function/is-a-constructor.js | 36 ++++++ .../builtins/Function/length/15.3.3.2-1.js | 26 +++++ .../Function/length/S15.3.5.1_A1_T1.js | 27 +++++ .../Function/length/S15.3.5.1_A1_T2.js | 29 +++++ .../Function/length/S15.3.5.1_A1_T3.js | 29 +++++ .../Function/length/S15.3.5.1_A2_T1.js | 31 +++++ .../Function/length/S15.3.5.1_A2_T2.js | 33 ++++++ .../Function/length/S15.3.5.1_A2_T3.js | 33 ++++++ .../Function/length/S15.3.5.1_A3_T1.js | 48 ++++++++ .../Function/length/S15.3.5.1_A3_T2.js | 48 ++++++++ .../Function/length/S15.3.5.1_A3_T3.js | 48 ++++++++ .../Function/length/S15.3.5.1_A4_T1.js | 35 ++++++ .../Function/length/S15.3.5.1_A4_T2.js | 36 ++++++ .../Function/length/S15.3.5.1_A4_T3.js | 36 ++++++ .../Function/private-identifiers-not-empty.js | 33 ++++++ test/sendable/builtins/Function/prop-desc.js | 30 +++++ .../builtins/Function/property-order.js | 28 +++++ .../proto-from-ctor-realm-prototype.js | 62 ++++++++++ .../Function/proto-from-ctor-realm.js | 50 ++++++++ .../Function/prototype/S15.3.3.1_A1.js | 37 ++++++ .../Function/prototype/S15.3.3.1_A2.js | 37 ++++++ .../Function/prototype/S15.3.3.1_A3.js | 38 ++++++ .../Function/prototype/S15.3.3.1_A4.js | 38 ++++++ .../builtins/Function/prototype/S15.3.4_A1.js | 27 +++++ .../Function/prototype/S15.3.4_A2_T1.js | 28 +++++ .../Function/prototype/S15.3.4_A2_T2.js | 28 +++++ .../Function/prototype/S15.3.4_A2_T3.js | 25 ++++ .../Function/prototype/S15.3.4_A3_T1.js | 27 +++++ .../Function/prototype/S15.3.4_A3_T2.js | 28 +++++ .../builtins/Function/prototype/S15.3.4_A4.js | 40 +++++++ .../builtins/Function/prototype/S15.3.4_A5.js | 26 +++++ .../Function/prototype/S15.3.5.2_A1_T1.js | 46 ++++++++ .../Function/prototype/S15.3.5.2_A1_T2.js | 46 ++++++++ .../prototype/Symbol.hasInstance/length.js | 40 +++++++ .../prototype/Symbol.hasInstance/name.js | 31 +++++ .../prototype/Symbol.hasInstance/prop-desc.js | 32 +++++ .../this-val-bound-target.js | 36 ++++++ .../this-val-not-callable.js | 30 +++++ .../this-val-poisoned-prototype.js | 44 +++++++ .../this-val-prototype-non-obj.js | 62 ++++++++++ .../value-get-prototype-of-err.js | 49 ++++++++ .../Symbol.hasInstance/value-negative.js | 40 +++++++ .../Symbol.hasInstance/value-non-obj.js | 36 ++++++ .../Symbol.hasInstance/value-positive.js | 40 +++++++ .../Function/prototype/apply/15.3.4.3-1-s.js | 29 +++++ .../Function/prototype/apply/15.3.4.3-2-s.js | 29 +++++ .../Function/prototype/apply/15.3.4.3-3-s.js | 29 +++++ .../Function/prototype/apply/S15.3.4.3_A12.js | 27 +++++ .../prototype/apply/S15.3.4.3_A1_T1.js | 42 +++++++ .../prototype/apply/S15.3.4.3_A1_T2.js | 40 +++++++ .../prototype/apply/S15.3.4.3_A3_T1.js | 26 +++++ .../prototype/apply/S15.3.4.3_A3_T10.js | 27 +++++ .../prototype/apply/S15.3.4.3_A3_T2.js | 26 +++++ .../prototype/apply/S15.3.4.3_A3_T3.js | 26 +++++ .../prototype/apply/S15.3.4.3_A3_T4.js | 26 +++++ .../prototype/apply/S15.3.4.3_A3_T5.js | 33 ++++++ .../prototype/apply/S15.3.4.3_A3_T6.js | 36 ++++++ .../prototype/apply/S15.3.4.3_A3_T7.js | 31 +++++ .../prototype/apply/S15.3.4.3_A3_T8.js | 33 ++++++ .../prototype/apply/S15.3.4.3_A3_T9.js | 26 +++++ .../prototype/apply/S15.3.4.3_A5_T1.js | 29 +++++ .../prototype/apply/S15.3.4.3_A5_T2.js | 29 +++++ .../prototype/apply/S15.3.4.3_A5_T3.js | 33 ++++++ .../prototype/apply/S15.3.4.3_A5_T4.js | 35 ++++++ .../prototype/apply/S15.3.4.3_A5_T5.js | 32 +++++ .../prototype/apply/S15.3.4.3_A5_T6.js | 30 +++++ .../prototype/apply/S15.3.4.3_A5_T7.js | 28 +++++ .../prototype/apply/S15.3.4.3_A5_T8.js | 28 +++++ .../prototype/apply/S15.3.4.3_A7_T1.js | 26 +++++ .../prototype/apply/S15.3.4.3_A7_T10.js | 38 ++++++ .../prototype/apply/S15.3.4.3_A7_T2.js | 26 +++++ .../prototype/apply/S15.3.4.3_A7_T3.js | 42 +++++++ .../prototype/apply/S15.3.4.3_A7_T4.js | 46 ++++++++ .../prototype/apply/S15.3.4.3_A7_T5.js | 31 +++++ .../prototype/apply/S15.3.4.3_A7_T6.js | 36 ++++++ .../prototype/apply/S15.3.4.3_A7_T7.js | 30 +++++ .../prototype/apply/S15.3.4.3_A7_T8.js | 30 +++++ .../prototype/apply/S15.3.4.3_A7_T9.js | 40 +++++++ .../prototype/apply/S15.3.4.3_A8_T3.js | 27 +++++ .../prototype/apply/S15.3.4.3_A8_T4.js | 27 +++++ .../prototype/apply/S15.3.4.3_A8_T5.js | 28 +++++ .../prototype/apply/S15.3.4.3_A8_T6.js | 30 +++++ .../apply/argarray-not-object-realm.js | 51 ++++++++ .../prototype/apply/argarray-not-object.js | 48 ++++++++ .../prototype/apply/get-index-abrupt.js | 44 +++++++ .../prototype/apply/get-length-abrupt.js | 40 +++++++ .../Function/prototype/apply/length.js | 39 +++++++ .../builtins/Function/prototype/apply/name.js | 39 +++++++ .../prototype/apply/not-a-constructor.js | 48 ++++++++ .../prototype/apply/resizable-buffer.js | 110 ++++++++++++++++++ .../apply/this-not-callable-realm.js | 46 ++++++++ .../prototype/apply/this-not-callable.js | 41 +++++++ .../Function/prototype/bind/15.3.4.5-0-1.js | 23 ++++ .../Function/prototype/bind/15.3.4.5-10-1.js | 27 +++++ .../Function/prototype/bind/15.3.4.5-11-1.js | 28 +++++ .../Function/prototype/bind/15.3.4.5-16-1.js | 27 +++++ .../Function/prototype/bind/15.3.4.5-16-2.js | 27 +++++ .../Function/prototype/bind/15.3.4.5-2-1.js | 32 +++++ .../Function/prototype/bind/15.3.4.5-2-10.js | 24 ++++ .../Function/prototype/bind/15.3.4.5-2-11.js | 24 ++++ .../Function/prototype/bind/15.3.4.5-2-12.js | 24 ++++ .../Function/prototype/bind/15.3.4.5-2-13.js | 24 ++++ .../Function/prototype/bind/15.3.4.5-2-14.js | 24 ++++ .../Function/prototype/bind/15.3.4.5-2-15.js | 26 +++++ .../Function/prototype/bind/15.3.4.5-2-16.js | 23 ++++ .../Function/prototype/bind/15.3.4.5-2-2.js | 32 +++++ .../Function/prototype/bind/15.3.4.5-2-3.js | 27 +++++ .../Function/prototype/bind/15.3.4.5-2-4.js | 27 +++++ .../Function/prototype/bind/15.3.4.5-2-5.js | 27 +++++ .../Function/prototype/bind/15.3.4.5-2-6.js | 27 +++++ .../Function/prototype/bind/15.3.4.5-2-7.js | 29 +++++ .../Function/prototype/bind/15.3.4.5-2-8.js | 31 +++++ .../Function/prototype/bind/15.3.4.5-2-9.js | 24 ++++ .../Function/prototype/bind/15.3.4.5-20-2.js | 28 +++++ .../Function/prototype/bind/15.3.4.5-20-3.js | 27 +++++ .../Function/prototype/bind/15.3.4.5-21-2.js | 28 +++++ .../Function/prototype/bind/15.3.4.5-21-3.js | 27 +++++ .../Function/prototype/bind/15.3.4.5-3-1.js | 28 +++++ .../Function/prototype/bind/15.3.4.5-6-1.js | 26 +++++ .../Function/prototype/bind/15.3.4.5-6-10.js | 38 ++++++ .../Function/prototype/bind/15.3.4.5-6-11.js | 32 +++++ .../Function/prototype/bind/15.3.4.5-6-12.js | 25 ++++ .../Function/prototype/bind/15.3.4.5-6-2.js | 27 +++++ .../Function/prototype/bind/15.3.4.5-6-3.js | 30 +++++ .../Function/prototype/bind/15.3.4.5-6-4.js | 38 ++++++ .../Function/prototype/bind/15.3.4.5-6-5.js | 30 +++++ .../Function/prototype/bind/15.3.4.5-6-6.js | 32 +++++ .../Function/prototype/bind/15.3.4.5-6-7.js | 34 ++++++ .../Function/prototype/bind/15.3.4.5-6-8.js | 40 +++++++ .../Function/prototype/bind/15.3.4.5-6-9.js | 31 +++++ .../Function/prototype/bind/15.3.4.5-8-1.js | 26 +++++ .../Function/prototype/bind/15.3.4.5-8-2.js | 29 +++++ .../Function/prototype/bind/15.3.4.5-9-1.js | 26 +++++ .../Function/prototype/bind/15.3.4.5-9-2.js | 28 +++++ .../Function/prototype/bind/15.3.4.5.1-4-1.js | 30 +++++ .../prototype/bind/15.3.4.5.1-4-10.js | 33 ++++++ .../prototype/bind/15.3.4.5.1-4-11.js | 33 ++++++ .../prototype/bind/15.3.4.5.1-4-12.js | 34 ++++++ .../prototype/bind/15.3.4.5.1-4-13.js | 34 ++++++ .../prototype/bind/15.3.4.5.1-4-14.js | 34 ++++++ .../prototype/bind/15.3.4.5.1-4-15.js | 34 ++++++ .../Function/prototype/bind/15.3.4.5.1-4-2.js | 34 ++++++ .../Function/prototype/bind/15.3.4.5.1-4-3.js | 30 +++++ .../Function/prototype/bind/15.3.4.5.1-4-4.js | 30 +++++ .../Function/prototype/bind/15.3.4.5.1-4-5.js | 30 +++++ .../Function/prototype/bind/15.3.4.5.1-4-6.js | 33 ++++++ .../Function/prototype/bind/15.3.4.5.1-4-7.js | 33 ++++++ .../Function/prototype/bind/15.3.4.5.1-4-8.js | 33 ++++++ .../Function/prototype/bind/15.3.4.5.1-4-9.js | 33 ++++++ .../Function/prototype/bind/15.3.4.5.2-4-1.js | 38 ++++++ .../prototype/bind/15.3.4.5.2-4-10.js | 31 +++++ .../prototype/bind/15.3.4.5.2-4-11.js | 31 +++++ .../prototype/bind/15.3.4.5.2-4-12.js | 31 +++++ .../prototype/bind/15.3.4.5.2-4-13.js | 31 +++++ .../prototype/bind/15.3.4.5.2-4-14.js | 31 +++++ .../Function/prototype/bind/15.3.4.5.2-4-2.js | 38 ++++++ .../Function/prototype/bind/15.3.4.5.2-4-3.js | 32 +++++ .../Function/prototype/bind/15.3.4.5.2-4-4.js | 32 +++++ .../Function/prototype/bind/15.3.4.5.2-4-5.js | 37 ++++++ .../Function/prototype/bind/15.3.4.5.2-4-6.js | 31 +++++ .../Function/prototype/bind/15.3.4.5.2-4-7.js | 31 +++++ .../Function/prototype/bind/15.3.4.5.2-4-8.js | 31 +++++ .../Function/prototype/bind/15.3.4.5.2-4-9.js | 31 +++++ .../BoundFunction_restricted-properties.js | 44 +++++++ .../Function/prototype/bind/S15.3.4.5_A1.js | 33 ++++++ .../Function/prototype/bind/S15.3.4.5_A13.js | 23 ++++ .../Function/prototype/bind/S15.3.4.5_A14.js | 23 ++++ .../Function/prototype/bind/S15.3.4.5_A15.js | 23 ++++ .../Function/prototype/bind/S15.3.4.5_A16.js | 36 ++++++ .../Function/prototype/bind/S15.3.4.5_A2.js | 33 ++++++ .../Function/prototype/bind/S15.3.4.5_A3.js | 23 ++++ .../Function/prototype/bind/S15.3.4.5_A4.js | 29 +++++ .../Function/prototype/bind/S15.3.4.5_A5.js | 33 ++++++ .../prototype/bind/get-fn-realm-recursive.js | 66 +++++++++++ .../Function/prototype/bind/get-fn-realm.js | 68 +++++++++++ ...e-construct-newtarget-boundtarget-bound.js | 40 +++++++ ...nstance-construct-newtarget-boundtarget.js | 39 +++++++ .../instance-construct-newtarget-self-new.js | 38 ++++++ ...stance-construct-newtarget-self-reflect.js | 39 +++++++ .../bind/instance-length-default-value.js | 64 ++++++++++ .../bind/instance-length-exceeds-int32.js | 41 +++++++ .../bind/instance-length-prop-desc.js | 42 +++++++ .../bind/instance-length-remaining-args.js | 47 ++++++++ .../bind/instance-length-tointeger.js | 69 +++++++++++ .../prototype/bind/instance-name-chained.js | 35 ++++++ .../prototype/bind/instance-name-error.js | 32 +++++ .../bind/instance-name-non-string.js | 83 +++++++++++++ .../Function/prototype/bind/instance-name.js | 34 ++++++ .../Function/prototype/bind/length.js | 41 +++++++ .../builtins/Function/prototype/bind/name.js | 39 +++++++ .../prototype/bind/not-a-constructor.js | 45 +++++++ .../prototype/bind/proto-from-ctor-realm.js | 42 +++++++ .../Function/prototype/call/15.3.4.4-1-s.js | 29 +++++ .../Function/prototype/call/15.3.4.4-2-s.js | 29 +++++ .../Function/prototype/call/15.3.4.4-3-s.js | 29 +++++ .../Function/prototype/call/S15.3.4.4_A10.js | 41 +++++++ .../Function/prototype/call/S15.3.4.4_A11.js | 38 ++++++ .../Function/prototype/call/S15.3.4.4_A12.js | 27 +++++ .../Function/prototype/call/S15.3.4.4_A13.js | 23 ++++ .../Function/prototype/call/S15.3.4.4_A14.js | 23 ++++ .../Function/prototype/call/S15.3.4.4_A15.js | 23 ++++ .../Function/prototype/call/S15.3.4.4_A16.js | 36 ++++++ .../prototype/call/S15.3.4.4_A1_T1.js | 42 +++++++ .../prototype/call/S15.3.4.4_A1_T2.js | 40 +++++++ .../prototype/call/S15.3.4.4_A2_T1.js | 33 ++++++ .../prototype/call/S15.3.4.4_A2_T2.js | 26 +++++ .../prototype/call/S15.3.4.4_A3_T1.js | 26 +++++ .../prototype/call/S15.3.4.4_A3_T10.js | 27 +++++ .../prototype/call/S15.3.4.4_A3_T2.js | 26 +++++ .../prototype/call/S15.3.4.4_A3_T3.js | 26 +++++ .../prototype/call/S15.3.4.4_A3_T4.js | 26 +++++ .../prototype/call/S15.3.4.4_A3_T5.js | 33 ++++++ .../prototype/call/S15.3.4.4_A3_T6.js | 36 ++++++ .../prototype/call/S15.3.4.4_A3_T7.js | 31 +++++ .../prototype/call/S15.3.4.4_A3_T8.js | 34 ++++++ .../prototype/call/S15.3.4.4_A3_T9.js | 27 +++++ .../prototype/call/S15.3.4.4_A5_T1.js | 29 +++++ .../prototype/call/S15.3.4.4_A5_T2.js | 29 +++++ .../prototype/call/S15.3.4.4_A5_T3.js | 33 ++++++ .../prototype/call/S15.3.4.4_A5_T4.js | 35 ++++++ .../prototype/call/S15.3.4.4_A5_T5.js | 32 +++++ .../prototype/call/S15.3.4.4_A5_T6.js | 30 +++++ .../prototype/call/S15.3.4.4_A5_T7.js | 28 +++++ .../prototype/call/S15.3.4.4_A5_T8.js | 28 +++++ .../prototype/call/S15.3.4.4_A6_T1.js | 33 ++++++ .../prototype/call/S15.3.4.4_A6_T10.js | 38 ++++++ .../prototype/call/S15.3.4.4_A6_T2.js | 30 +++++ .../prototype/call/S15.3.4.4_A6_T3.js | 46 ++++++++ .../prototype/call/S15.3.4.4_A6_T4.js | 46 ++++++++ .../prototype/call/S15.3.4.4_A6_T5.js | 33 ++++++ .../prototype/call/S15.3.4.4_A6_T6.js | 38 ++++++ .../prototype/call/S15.3.4.4_A6_T7.js | 30 +++++ .../prototype/call/S15.3.4.4_A6_T8.js | 30 +++++ .../prototype/call/S15.3.4.4_A6_T9.js | 40 +++++++ .../prototype/call/S15.3.4.4_A7_T3.js | 27 +++++ .../prototype/call/S15.3.4.4_A7_T4.js | 27 +++++ .../prototype/call/S15.3.4.4_A7_T5.js | 28 +++++ .../prototype/call/S15.3.4.4_A7_T6.js | 30 +++++ .../Function/prototype/call/S15.3.4.4_A9.js | 40 +++++++ .../builtins/Function/prototype/call/name.js | 39 +++++++ .../prototype/call/not-a-constructor.js | 53 +++++++++ .../prototype/constructor/S15.3.4.1_A1_T1.js | 27 +++++ .../builtins/Function/prototype/length.js | 40 +++++++ .../builtins/Function/prototype/name.js | 36 ++++++ .../Function/prototype/property-order.js | 28 +++++ .../restricted-property-arguments.js | 39 +++++++ .../prototype/restricted-property-caller.js | 40 +++++++ .../prototype/toString/AsyncFunction.js | 28 +++++ .../prototype/toString/AsyncGenerator.js | 29 +++++ .../Function/prototype/toString/Function.js | 24 ++++ .../prototype/toString/GeneratorFunction.js | 26 +++++ .../prototype/toString/S15.3.4.2_A10.js | 39 +++++++ .../prototype/toString/S15.3.4.2_A11.js | 30 +++++ .../prototype/toString/S15.3.4.2_A12.js | 25 ++++ .../prototype/toString/S15.3.4.2_A13.js | 25 ++++ .../prototype/toString/S15.3.4.2_A14.js | 25 ++++ .../prototype/toString/S15.3.4.2_A16.js | 31 +++++ .../prototype/toString/S15.3.4.2_A6.js | 27 +++++ .../prototype/toString/S15.3.4.2_A8.js | 38 ++++++ .../prototype/toString/S15.3.4.2_A9.js | 40 +++++++ .../prototype/toString/arrow-function.js | 28 +++++ .../toString/async-arrow-function.js | 29 +++++ .../toString/async-function-declaration.js | 26 +++++ .../toString/async-function-expression.js | 28 +++++ .../toString/async-generator-declaration.js | 25 ++++ .../toString/async-generator-expression.js | 27 +++++ ...enerator-method-class-expression-static.js | 30 +++++ ...async-generator-method-class-expression.js | 30 +++++ ...generator-method-class-statement-static.js | 34 ++++++ .../async-generator-method-class-statement.js | 34 ++++++ .../toString/async-generator-method-object.js | 30 +++++ .../async-method-class-expression-static.js | 30 +++++ .../toString/async-method-class-expression.js | 30 +++++ .../async-method-class-statement-static.js | 34 ++++++ .../toString/async-method-class-statement.js | 34 ++++++ .../prototype/toString/async-method-object.js | 31 +++++ .../prototype/toString/bound-function.js | 29 +++++ .../toString/built-in-function-object.js | 69 +++++++++++ .../class-declaration-complex-heritage.js | 24 ++++ .../class-declaration-explicit-ctor.js | 26 +++++ .../class-declaration-implicit-ctor.js | 28 +++++ .../class-expression-explicit-ctor.js | 26 +++++ .../class-expression-implicit-ctor.js | 28 +++++ ...n-declaration-non-simple-parameter-list.js | 24 ++++ .../toString/function-declaration.js | 24 ++++ .../prototype/toString/function-expression.js | 26 +++++ .../generator-function-declaration.js | 24 ++++ .../toString/generator-function-expression.js | 26 +++++ .../prototype/toString/generator-method.js | 29 +++++ .../getter-class-expression-static.js | 29 +++++ .../toString/getter-class-expression.js | 29 +++++ .../toString/getter-class-statement-static.js | 33 ++++++ .../toString/getter-class-statement.js | 33 ++++++ .../prototype/toString/getter-object.js | 29 +++++ .../line-terminator-normalisation-CR-LF.js | 49 ++++++++ .../line-terminator-normalisation-CR.js | 49 ++++++++ .../line-terminator-normalisation-LF.js | 49 ++++++++ .../method-class-expression-static.js | 29 +++++ .../toString/method-class-expression.js | 29 +++++ .../toString/method-class-statement-static.js | 33 ++++++ .../toString/method-class-statement.js | 33 ++++++ .../toString/method-computed-property-name.js | 26 +++++ .../prototype/toString/method-object.js | 24 ++++ .../Function/prototype/toString/name.js | 39 +++++++ .../prototype/toString/not-a-constructor.js | 49 ++++++++ .../private-method-class-expression.js | 29 +++++ .../private-method-class-statement.js | 30 +++++ .../private-static-method-class-expression.js | 29 +++++ .../private-static-method-class-statement.js | 29 +++++ .../toString/proxy-arrow-function.js | 35 ++++++ .../toString/proxy-async-function.js | 35 ++++++ .../proxy-async-generator-function.js | 35 ++++++ ...proxy-async-generator-method-definition.js | 35 ++++++ .../toString/proxy-async-method-definition.js | 35 ++++++ .../toString/proxy-bound-function.js | 35 ++++++ .../prototype/toString/proxy-class.js | 35 ++++++ .../toString/proxy-function-expression.js | 35 ++++++ .../toString/proxy-generator-function.js | 35 ++++++ .../toString/proxy-method-definition.js | 35 ++++++ .../toString/proxy-non-callable-throws.js | 29 +++++ .../setter-class-expression-static.js | 29 +++++ .../toString/setter-class-expression.js | 29 +++++ .../toString/setter-class-statement-static.js | 33 ++++++ .../toString/setter-class-statement.js | 33 ++++++ .../prototype/toString/setter-object.js | 29 +++++ .../toString/symbol-named-builtins.js | 23 ++++ .../Function/prototype/toString/unicode.js | 27 +++++ 508 files changed, 17515 insertions(+) create mode 100644 test/sendable/builtins/Function/15.3.2.1-10-6gs.js create mode 100644 test/sendable/builtins/Function/15.3.2.1-11-1-s.js create mode 100644 test/sendable/builtins/Function/15.3.2.1-11-1.js create mode 100644 test/sendable/builtins/Function/15.3.2.1-11-2-s.js create mode 100644 test/sendable/builtins/Function/15.3.2.1-11-3-s.js create mode 100644 test/sendable/builtins/Function/15.3.2.1-11-3.js create mode 100644 test/sendable/builtins/Function/15.3.2.1-11-4-s.js create mode 100644 test/sendable/builtins/Function/15.3.2.1-11-5-s.js create mode 100644 test/sendable/builtins/Function/15.3.2.1-11-5.js create mode 100644 test/sendable/builtins/Function/15.3.2.1-11-6-s.js create mode 100644 test/sendable/builtins/Function/15.3.2.1-11-7-s.js create mode 100644 test/sendable/builtins/Function/15.3.2.1-11-8-s.js create mode 100644 test/sendable/builtins/Function/15.3.2.1-11-9-s.js create mode 100644 test/sendable/builtins/Function/15.3.5-1gs.js create mode 100644 test/sendable/builtins/Function/15.3.5-2gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-10gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-11gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-12gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-13gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-14gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-15gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-16gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-17gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-18gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-19gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-1gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-20gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-21gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-22gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-23gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-24gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-25gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-26gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-27gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-28gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-29gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-2gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-30gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-31gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-32gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-33gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-34gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-35gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-36gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-37gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-38gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-39gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-3gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-40gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-41gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-42gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-43gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-44gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-45gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-46gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-47gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-48gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-49gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-4gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-50gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-51gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-52gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-53gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-54gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-55gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-56gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-57gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-58gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-59gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-5gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-60gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-61gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-62gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-63gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-64gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-65gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-66gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-67gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-68gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-69gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-6gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-70gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-71gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-72gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-73gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-74gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-75gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-76gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-77gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-78gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-79gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-7gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-80gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-81gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-82gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-83gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-84gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-85gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-86gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-87gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-88gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-89gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-8gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-90gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-91gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-92gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-93gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-94gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-95gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-96gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-97gs.js create mode 100644 test/sendable/builtins/Function/15.3.5.4_2-9gs.js create mode 100644 test/sendable/builtins/Function/S10.1.1_A1_T3.js create mode 100644 test/sendable/builtins/Function/S15.3.1_A1_T1.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A1_T1.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A1_T10.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A1_T11.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A1_T12.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A1_T13.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A1_T2.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A1_T3.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A1_T4.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A1_T5.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A1_T6.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A1_T7.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A1_T8.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A1_T9.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A2_T1.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A2_T2.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A2_T3.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A2_T4.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A2_T5.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A2_T6.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T1.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T10.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T11.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T12.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T13.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T14.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T15.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T2.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T3.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T4.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T5.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T6.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T7.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T8.js create mode 100644 test/sendable/builtins/Function/S15.3.2.1_A3_T9.js create mode 100644 test/sendable/builtins/Function/S15.3.2_A1.js create mode 100644 test/sendable/builtins/Function/S15.3.3_A1.js create mode 100644 test/sendable/builtins/Function/S15.3.3_A2_T1.js create mode 100644 test/sendable/builtins/Function/S15.3.3_A2_T2.js create mode 100644 test/sendable/builtins/Function/S15.3.3_A3.js create mode 100644 test/sendable/builtins/Function/S15.3.5_A1_T1.js create mode 100644 test/sendable/builtins/Function/S15.3.5_A1_T2.js create mode 100644 test/sendable/builtins/Function/S15.3.5_A2_T1.js create mode 100644 test/sendable/builtins/Function/S15.3.5_A2_T2.js create mode 100644 test/sendable/builtins/Function/S15.3.5_A3_T1.js create mode 100644 test/sendable/builtins/Function/S15.3.5_A3_T2.js create mode 100644 test/sendable/builtins/Function/S15.3_A1.js create mode 100644 test/sendable/builtins/Function/S15.3_A2_T1.js create mode 100644 test/sendable/builtins/Function/S15.3_A2_T2.js create mode 100644 test/sendable/builtins/Function/S15.3_A3_T1.js create mode 100644 test/sendable/builtins/Function/S15.3_A3_T2.js create mode 100644 test/sendable/builtins/Function/S15.3_A3_T3.js create mode 100644 test/sendable/builtins/Function/S15.3_A3_T4.js create mode 100644 test/sendable/builtins/Function/S15.3_A3_T5.js create mode 100644 test/sendable/builtins/Function/S15.3_A3_T6.js create mode 100644 test/sendable/builtins/Function/StrictFunction_reservedwords_with.js create mode 100644 test/sendable/builtins/Function/StrictFunction_restricted-properties.js create mode 100644 test/sendable/builtins/Function/call-bind-this-realm-undef.js create mode 100644 test/sendable/builtins/Function/call-bind-this-realm-value.js create mode 100644 test/sendable/builtins/Function/instance-name.js create mode 100644 test/sendable/builtins/Function/internals/Call/class-ctor-realm.js create mode 100644 test/sendable/builtins/Function/internals/Call/class-ctor.js create mode 100644 test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js create mode 100644 test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy.js create mode 100644 test/sendable/builtins/Function/internals/Construct/derived-return-val-realm.js create mode 100644 test/sendable/builtins/Function/internals/Construct/derived-return-val.js create mode 100644 test/sendable/builtins/Function/internals/Construct/derived-this-uninitialized-realm.js create mode 100644 test/sendable/builtins/Function/internals/Construct/derived-this-uninitialized.js create mode 100644 test/sendable/builtins/Function/is-a-constructor.js create mode 100644 test/sendable/builtins/Function/length/15.3.3.2-1.js create mode 100644 test/sendable/builtins/Function/length/S15.3.5.1_A1_T1.js create mode 100644 test/sendable/builtins/Function/length/S15.3.5.1_A1_T2.js create mode 100644 test/sendable/builtins/Function/length/S15.3.5.1_A1_T3.js create mode 100644 test/sendable/builtins/Function/length/S15.3.5.1_A2_T1.js create mode 100644 test/sendable/builtins/Function/length/S15.3.5.1_A2_T2.js create mode 100644 test/sendable/builtins/Function/length/S15.3.5.1_A2_T3.js create mode 100644 test/sendable/builtins/Function/length/S15.3.5.1_A3_T1.js create mode 100644 test/sendable/builtins/Function/length/S15.3.5.1_A3_T2.js create mode 100644 test/sendable/builtins/Function/length/S15.3.5.1_A3_T3.js create mode 100644 test/sendable/builtins/Function/length/S15.3.5.1_A4_T1.js create mode 100644 test/sendable/builtins/Function/length/S15.3.5.1_A4_T2.js create mode 100644 test/sendable/builtins/Function/length/S15.3.5.1_A4_T3.js create mode 100644 test/sendable/builtins/Function/private-identifiers-not-empty.js create mode 100644 test/sendable/builtins/Function/prop-desc.js create mode 100644 test/sendable/builtins/Function/property-order.js create mode 100644 test/sendable/builtins/Function/proto-from-ctor-realm-prototype.js create mode 100644 test/sendable/builtins/Function/proto-from-ctor-realm.js create mode 100644 test/sendable/builtins/Function/prototype/S15.3.3.1_A1.js create mode 100644 test/sendable/builtins/Function/prototype/S15.3.3.1_A2.js create mode 100644 test/sendable/builtins/Function/prototype/S15.3.3.1_A3.js create mode 100644 test/sendable/builtins/Function/prototype/S15.3.3.1_A4.js create mode 100644 test/sendable/builtins/Function/prototype/S15.3.4_A1.js create mode 100644 test/sendable/builtins/Function/prototype/S15.3.4_A2_T1.js create mode 100644 test/sendable/builtins/Function/prototype/S15.3.4_A2_T2.js create mode 100644 test/sendable/builtins/Function/prototype/S15.3.4_A2_T3.js create mode 100644 test/sendable/builtins/Function/prototype/S15.3.4_A3_T1.js create mode 100644 test/sendable/builtins/Function/prototype/S15.3.4_A3_T2.js create mode 100644 test/sendable/builtins/Function/prototype/S15.3.4_A4.js create mode 100644 test/sendable/builtins/Function/prototype/S15.3.4_A5.js create mode 100644 test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T1.js create mode 100644 test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T2.js create mode 100644 test/sendable/builtins/Function/prototype/Symbol.hasInstance/length.js create mode 100644 test/sendable/builtins/Function/prototype/Symbol.hasInstance/name.js create mode 100644 test/sendable/builtins/Function/prototype/Symbol.hasInstance/prop-desc.js create mode 100644 test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-bound-target.js create mode 100644 test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-not-callable.js create mode 100644 test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-poisoned-prototype.js create mode 100644 test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-prototype-non-obj.js create mode 100644 test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-get-prototype-of-err.js create mode 100644 test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-negative.js create mode 100644 test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-non-obj.js create mode 100644 test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-positive.js create mode 100644 test/sendable/builtins/Function/prototype/apply/15.3.4.3-1-s.js create mode 100644 test/sendable/builtins/Function/prototype/apply/15.3.4.3-2-s.js create mode 100644 test/sendable/builtins/Function/prototype/apply/15.3.4.3-3-s.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A12.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T1.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T2.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T1.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T10.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T2.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T3.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T4.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T5.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T6.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T7.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T8.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T9.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T1.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T2.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T3.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T4.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T5.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T6.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T7.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T8.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T1.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T10.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T2.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T3.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T4.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T5.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T6.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T7.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T8.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T9.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T3.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T4.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T5.js create mode 100644 test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T6.js create mode 100644 test/sendable/builtins/Function/prototype/apply/argarray-not-object-realm.js create mode 100644 test/sendable/builtins/Function/prototype/apply/argarray-not-object.js create mode 100644 test/sendable/builtins/Function/prototype/apply/get-index-abrupt.js create mode 100644 test/sendable/builtins/Function/prototype/apply/get-length-abrupt.js create mode 100644 test/sendable/builtins/Function/prototype/apply/length.js create mode 100644 test/sendable/builtins/Function/prototype/apply/name.js create mode 100644 test/sendable/builtins/Function/prototype/apply/not-a-constructor.js create mode 100644 test/sendable/builtins/Function/prototype/apply/resizable-buffer.js create mode 100644 test/sendable/builtins/Function/prototype/apply/this-not-callable-realm.js create mode 100644 test/sendable/builtins/Function/prototype/apply/this-not-callable.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-0-1.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-10-1.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-11-1.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-1.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-2.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-1.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-10.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-11.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-12.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-13.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-14.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-15.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-16.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-2.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-3.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-4.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-5.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-6.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-7.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-8.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-9.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-2.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-3.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-2.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-3.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-3-1.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-1.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-10.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-11.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-12.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-2.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-3.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-4.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-5.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-6.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-7.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-8.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-9.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-1.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-2.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-1.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-2.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-1.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-10.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-11.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-12.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-13.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-14.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-15.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-2.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-3.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-4.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-5.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-6.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-7.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-8.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-9.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-1.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-10.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-11.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-12.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-13.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-14.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-2.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-3.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-4.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-5.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-6.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-7.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-8.js create mode 100644 test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-9.js create mode 100644 test/sendable/builtins/Function/prototype/bind/BoundFunction_restricted-properties.js create mode 100644 test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A1.js create mode 100644 test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A13.js create mode 100644 test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A14.js create mode 100644 test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A15.js create mode 100644 test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A16.js create mode 100644 test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A2.js create mode 100644 test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A3.js create mode 100644 test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A4.js create mode 100644 test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A5.js create mode 100644 test/sendable/builtins/Function/prototype/bind/get-fn-realm-recursive.js create mode 100644 test/sendable/builtins/Function/prototype/bind/get-fn-realm.js create mode 100644 test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-boundtarget-bound.js create mode 100644 test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-boundtarget.js create mode 100644 test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-self-new.js create mode 100644 test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-self-reflect.js create mode 100644 test/sendable/builtins/Function/prototype/bind/instance-length-default-value.js create mode 100644 test/sendable/builtins/Function/prototype/bind/instance-length-exceeds-int32.js create mode 100644 test/sendable/builtins/Function/prototype/bind/instance-length-prop-desc.js create mode 100644 test/sendable/builtins/Function/prototype/bind/instance-length-remaining-args.js create mode 100644 test/sendable/builtins/Function/prototype/bind/instance-length-tointeger.js create mode 100644 test/sendable/builtins/Function/prototype/bind/instance-name-chained.js create mode 100644 test/sendable/builtins/Function/prototype/bind/instance-name-error.js create mode 100644 test/sendable/builtins/Function/prototype/bind/instance-name-non-string.js create mode 100644 test/sendable/builtins/Function/prototype/bind/instance-name.js create mode 100644 test/sendable/builtins/Function/prototype/bind/length.js create mode 100644 test/sendable/builtins/Function/prototype/bind/name.js create mode 100644 test/sendable/builtins/Function/prototype/bind/not-a-constructor.js create mode 100644 test/sendable/builtins/Function/prototype/bind/proto-from-ctor-realm.js create mode 100644 test/sendable/builtins/Function/prototype/call/15.3.4.4-1-s.js create mode 100644 test/sendable/builtins/Function/prototype/call/15.3.4.4-2-s.js create mode 100644 test/sendable/builtins/Function/prototype/call/15.3.4.4-3-s.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A10.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A11.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A12.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A13.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A14.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A15.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A16.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T1.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T2.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T1.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T2.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T1.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T10.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T2.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T3.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T4.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T5.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T6.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T7.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T8.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T9.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T1.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T2.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T3.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T4.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T5.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T6.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T7.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T8.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T1.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T10.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T2.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T3.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T4.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T5.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T6.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T7.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T8.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T9.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T3.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T4.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T5.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T6.js create mode 100644 test/sendable/builtins/Function/prototype/call/S15.3.4.4_A9.js create mode 100644 test/sendable/builtins/Function/prototype/call/name.js create mode 100644 test/sendable/builtins/Function/prototype/call/not-a-constructor.js create mode 100644 test/sendable/builtins/Function/prototype/constructor/S15.3.4.1_A1_T1.js create mode 100644 test/sendable/builtins/Function/prototype/length.js create mode 100644 test/sendable/builtins/Function/prototype/name.js create mode 100644 test/sendable/builtins/Function/prototype/property-order.js create mode 100644 test/sendable/builtins/Function/prototype/restricted-property-arguments.js create mode 100644 test/sendable/builtins/Function/prototype/restricted-property-caller.js create mode 100644 test/sendable/builtins/Function/prototype/toString/AsyncFunction.js create mode 100644 test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js create mode 100644 test/sendable/builtins/Function/prototype/toString/Function.js create mode 100644 test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js create mode 100644 test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A10.js create mode 100644 test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A11.js create mode 100644 test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A12.js create mode 100644 test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A13.js create mode 100644 test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A14.js create mode 100644 test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A16.js create mode 100644 test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A6.js create mode 100644 test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A8.js create mode 100644 test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A9.js create mode 100644 test/sendable/builtins/Function/prototype/toString/arrow-function.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-arrow-function.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-function-declaration.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-function-expression.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-generator-expression.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js create mode 100644 test/sendable/builtins/Function/prototype/toString/async-method-object.js create mode 100644 test/sendable/builtins/Function/prototype/toString/bound-function.js create mode 100644 test/sendable/builtins/Function/prototype/toString/built-in-function-object.js create mode 100644 test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js create mode 100644 test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js create mode 100644 test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js create mode 100644 test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js create mode 100644 test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js create mode 100644 test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js create mode 100644 test/sendable/builtins/Function/prototype/toString/function-declaration.js create mode 100644 test/sendable/builtins/Function/prototype/toString/function-expression.js create mode 100644 test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js create mode 100644 test/sendable/builtins/Function/prototype/toString/generator-function-expression.js create mode 100644 test/sendable/builtins/Function/prototype/toString/generator-method.js create mode 100644 test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js create mode 100644 test/sendable/builtins/Function/prototype/toString/getter-class-expression.js create mode 100644 test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js create mode 100644 test/sendable/builtins/Function/prototype/toString/getter-class-statement.js create mode 100644 test/sendable/builtins/Function/prototype/toString/getter-object.js create mode 100644 test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js create mode 100644 test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js create mode 100644 test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js create mode 100644 test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js create mode 100644 test/sendable/builtins/Function/prototype/toString/method-class-expression.js create mode 100644 test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js create mode 100644 test/sendable/builtins/Function/prototype/toString/method-class-statement.js create mode 100644 test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js create mode 100644 test/sendable/builtins/Function/prototype/toString/method-object.js create mode 100644 test/sendable/builtins/Function/prototype/toString/name.js create mode 100644 test/sendable/builtins/Function/prototype/toString/not-a-constructor.js create mode 100644 test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js create mode 100644 test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js create mode 100644 test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js create mode 100644 test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js create mode 100644 test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js create mode 100644 test/sendable/builtins/Function/prototype/toString/proxy-async-function.js create mode 100644 test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js create mode 100644 test/sendable/builtins/Function/prototype/toString/proxy-async-generator-method-definition.js create mode 100644 test/sendable/builtins/Function/prototype/toString/proxy-async-method-definition.js create mode 100644 test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js create mode 100644 test/sendable/builtins/Function/prototype/toString/proxy-class.js create mode 100644 test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js create mode 100644 test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js create mode 100644 test/sendable/builtins/Function/prototype/toString/proxy-method-definition.js create mode 100644 test/sendable/builtins/Function/prototype/toString/proxy-non-callable-throws.js create mode 100644 test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js create mode 100644 test/sendable/builtins/Function/prototype/toString/setter-class-expression.js create mode 100644 test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js create mode 100644 test/sendable/builtins/Function/prototype/toString/setter-class-statement.js create mode 100644 test/sendable/builtins/Function/prototype/toString/setter-object.js create mode 100644 test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js create mode 100644 test/sendable/builtins/Function/prototype/toString/unicode.js diff --git a/test/sendable/builtins/Function/15.3.2.1-10-6gs.js b/test/sendable/builtins/Function/15.3.2.1-10-6gs.js new file mode 100644 index 00000000000..8e9abb9b84f --- /dev/null +++ b/test/sendable/builtins/Function/15.3.2.1-10-6gs.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.2.1-10-6gs +description: > + Strict Mode - SyntaxError is thrown if a function using the + Function constructor has two identical parameters in (local) + strict mode +flags: [noStrict] +---*/ + +assert.throws(SyntaxError, function() { + new Function('param_1', 'param_2', 'param_1', '"use strict";return 0;'); +}); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-1-s.js b/test/sendable/builtins/Function/15.3.2.1-11-1-s.js new file mode 100644 index 00000000000..437ed92face --- /dev/null +++ b/test/sendable/builtins/Function/15.3.2.1-11-1-s.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.2.1-11-1-s +description: > + Duplicate seperate parameter name in Function constructor throws + SyntaxError in strict mode +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + Function('a', 'a', '"use strict";'); +}); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-1.js b/test/sendable/builtins/Function/15.3.2.1-11-1.js new file mode 100644 index 00000000000..19d64655410 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.2.1-11-1.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.2.1-11-1 +description: > + Duplicate separate parameter name in Function constructor allowed + if body not strict +---*/ + +Function('a', 'a', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-2-s.js b/test/sendable/builtins/Function/15.3.2.1-11-2-s.js new file mode 100644 index 00000000000..769b19b5d6c --- /dev/null +++ b/test/sendable/builtins/Function/15.3.2.1-11-2-s.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.2.1-11-2-s +description: > + Duplicate seperate parameter name in Function constructor called + from strict mode allowed if body not strict +flags: [onlyStrict] +---*/ + +Function('a', 'a', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-3-s.js b/test/sendable/builtins/Function/15.3.2.1-11-3-s.js new file mode 100644 index 00000000000..fad3d6e2963 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.2.1-11-3-s.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.2.1-11-3-s +description: > + Function constructor having a formal parameter named 'eval' throws + SyntaxError if function body is strict mode +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + Function('eval', '"use strict";'); +}); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-3.js b/test/sendable/builtins/Function/15.3.2.1-11-3.js new file mode 100644 index 00000000000..928e1975517 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.2.1-11-3.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.2.1-11-3 +description: > + Function constructor may have a formal parameter named 'eval' if + body is not strict mode +---*/ + +Function('eval', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-4-s.js b/test/sendable/builtins/Function/15.3.2.1-11-4-s.js new file mode 100644 index 00000000000..8fbf0ae6d3a --- /dev/null +++ b/test/sendable/builtins/Function/15.3.2.1-11-4-s.js @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.2.1-11-4-s +description: > + Function constructor call from strict code with formal parameter + named 'eval' does not throws SyntaxError if function body is not + strict mode +flags: [onlyStrict] +---*/ + +Function('eval', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-5-s.js b/test/sendable/builtins/Function/15.3.2.1-11-5-s.js new file mode 100644 index 00000000000..671cad03e10 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.2.1-11-5-s.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.2.1-11-5-s +description: > + Duplicate combined parameter name in Function constructor throws + SyntaxError in strict mode +flags: [noStrict] +---*/ + + +assert.throws(SyntaxError, function() { + Function('a,a', '"use strict";'); +}); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-5.js b/test/sendable/builtins/Function/15.3.2.1-11-5.js new file mode 100644 index 00000000000..0ab9756233c --- /dev/null +++ b/test/sendable/builtins/Function/15.3.2.1-11-5.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.2.1-11-5 +description: > + Duplicate combined parameter name in Function constructor allowed + if body is not strict +---*/ + +Function('a,a', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-6-s.js b/test/sendable/builtins/Function/15.3.2.1-11-6-s.js new file mode 100644 index 00000000000..58269091a80 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.2.1-11-6-s.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.2.1-11-6-s +description: > + Duplicate combined parameter name allowed in Function constructor + called in strict mode if body not strict +flags: [onlyStrict] +---*/ + +Function('a,a', 'return a;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-7-s.js b/test/sendable/builtins/Function/15.3.2.1-11-7-s.js new file mode 100644 index 00000000000..5116d1e20d2 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.2.1-11-7-s.js @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.2.1-11-7-s +description: > + Function constructor call from strict code with formal parameter + named arguments does not throws SyntaxError if function body is + not strict mode +flags: [onlyStrict] +---*/ + +Function('arguments', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-8-s.js b/test/sendable/builtins/Function/15.3.2.1-11-8-s.js new file mode 100644 index 00000000000..b1e3ce31871 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.2.1-11-8-s.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.2.1-11-8-s +description: > + Strict Mode - SyntaxError is not thrown if a function is created + using a Function constructor that has two identical parameters, + which are separated by a unique parameter name and there is no + explicit 'use strict' in the function constructor's body +flags: [onlyStrict] +---*/ + +var foo = new Function("baz", "qux", "baz", "return 0;"); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-9-s.js b/test/sendable/builtins/Function/15.3.2.1-11-9-s.js new file mode 100644 index 00000000000..53433667212 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.2.1-11-9-s.js @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.2.1-11-9-s +description: > + Strict Mode - No SyntaxError is thrown if a function is created using + the Function constructor that has three identical parameters and + there is no explicit 'use strict' in the function constructor's + body +---*/ + +var foo = new Function("baz", "baz", "baz", "return 0;"); diff --git a/test/sendable/builtins/Function/15.3.5-1gs.js b/test/sendable/builtins/Function/15.3.5-1gs.js new file mode 100644 index 00000000000..13b2e164780 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5-1gs.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5-1gs +description: > + StrictMode - error is thrown when reading the 'caller' property of + a function object +flags: [onlyStrict] +---*/ + +function fn() {} + +assert.throws(TypeError, function() { + fn.caller; +}); diff --git a/test/sendable/builtins/Function/15.3.5-2gs.js b/test/sendable/builtins/Function/15.3.5-2gs.js new file mode 100644 index 00000000000..45900872137 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5-2gs.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5-2gs +description: > + StrictMode - error is thrown when reading the 'caller' property of + a function object +flags: [onlyStrict] +---*/ + +function _15_3_5_1_gs() {} + +assert.throws(TypeError, function() { + _15_3_5_1_gs.caller; +}); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-10gs.js b/test/sendable/builtins/Function/15.3.5.4_2-10gs.js new file mode 100644 index 00000000000..f8212123f2c --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-10gs.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-10gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (New'ed Function constructor includes strict + directive prologue) +flags: [noStrict] +---*/ + +var f = new Function("\"use strict\";\ngNonStrict();"); + +assert.throws(TypeError, function() { + f(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-11gs.js b/test/sendable/builtins/Function/15.3.5.4_2-11gs.js new file mode 100644 index 00000000000..5c6453b8aa2 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-11gs.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-11gs +description: > + Strict mode - checking access to strict function caller from + strict function (eval used within strict mode) +flags: [onlyStrict] +---*/ + +assert.throws(TypeError, function() { + eval("gNonStrict();"); +}); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-12gs.js b/test/sendable/builtins/Function/15.3.5.4_2-12gs.js new file mode 100644 index 00000000000..ae479003078 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-12gs.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-12gs +description: > + Strict mode - checking access to non-strict function caller from + non-strict function (eval includes strict directive prologue) +flags: [noStrict] +features: [caller] +---*/ + +eval("\"use strict\";\ngNonStrict();"); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-13gs.js b/test/sendable/builtins/Function/15.3.5.4_2-13gs.js new file mode 100644 index 00000000000..3f5757d5be2 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-13gs.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-13gs +description: > + Strict mode - checking access to non-strict function caller from + strict function (indirect eval used within strict mode) +flags: [onlyStrict] +---*/ + +var my_eval = eval; + +assert.throws(TypeError, function() { + my_eval("gNonStrict();"); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-14gs.js b/test/sendable/builtins/Function/15.3.5.4_2-14gs.js new file mode 100644 index 00000000000..d9aa12a4fb0 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-14gs.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-14gs +description: > + Strict mode - checking access to non-strict function caller from + non-strict function (indirect eval includes strict directive + prologue) +flags: [noStrict] +features: [caller] +---*/ + +var my_eval = eval; +my_eval("\"use strict\";\ngNonStrict();"); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-15gs.js b/test/sendable/builtins/Function/15.3.5.4_2-15gs.js new file mode 100644 index 00000000000..1a76949f5d3 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-15gs.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-15gs +description: > + Strict mode - checking access to strict function caller from + strict function (New'ed object from FunctionDeclaration defined + within strict mode) +flags: [onlyStrict] +---*/ + +function f() { + gNonStrict(); +} + +assert.throws(TypeError, function() { + new f(); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-16gs.js b/test/sendable/builtins/Function/15.3.5.4_2-16gs.js new file mode 100644 index 00000000000..1f6de6d1e3d --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-16gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-16gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (New'ed object from FunctionDeclaration + includes strict directive prologue) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +} + +assert.throws(TypeError, function() { + new f(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-17gs.js b/test/sendable/builtins/Function/15.3.5.4_2-17gs.js new file mode 100644 index 00000000000..3cfb5ea4824 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-17gs.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-17gs +description: > + Strict mode - checking access to strict function caller from + strict function (New'ed object from FunctionExpression defined + within strict mode) +flags: [onlyStrict] +---*/ + +var f = function() { + gNonStrict(); +} + +assert.throws(TypeError, function() { + new f(); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-18gs.js b/test/sendable/builtins/Function/15.3.5.4_2-18gs.js new file mode 100644 index 00000000000..dddc254e808 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-18gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-18gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (New'ed object from FunctionExpression + includes strict directive prologue) +flags: [noStrict] +---*/ + +var f = function() { + "use strict"; + gNonStrict(); +} + +assert.throws(TypeError, function() { + new f(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-19gs.js b/test/sendable/builtins/Function/15.3.5.4_2-19gs.js new file mode 100644 index 00000000000..53718553676 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-19gs.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-19gs +description: > + Strict mode - checking access to strict function caller from + strict function (New'ed object from Anonymous FunctionExpression + defined within strict mode) +flags: [onlyStrict] +---*/ + +assert.throws(TypeError, function() { + var obj = new(function() { + gNonStrict(); + }); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-1gs.js b/test/sendable/builtins/Function/15.3.5.4_2-1gs.js new file mode 100644 index 00000000000..5d2177672d9 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-1gs.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-1gs +description: > + Strict mode - checking access to strict function caller from + strict function (FunctionDeclaration defined within strict mode) +flags: [onlyStrict] +---*/ + +function f() { + gNonStrict(); +} + +assert.throws(TypeError, function() { + f(); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-20gs.js b/test/sendable/builtins/Function/15.3.5.4_2-20gs.js new file mode 100644 index 00000000000..187de4b3fa2 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-20gs.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-20gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (New'ed object from Anonymous + FunctionExpression includes strict directive prologue) +flags: [noStrict] +---*/ + +assert.throws(TypeError, function() { + var obj = new(function() { + "use strict"; + gNonStrict(); + }); +}); + + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-21gs.js b/test/sendable/builtins/Function/15.3.5.4_2-21gs.js new file mode 100644 index 00000000000..27454203de7 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-21gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-21gs +description: > + Strict mode - checking access to strict function caller from + strict function (FunctionDeclaration defined within a + FunctionDeclaration inside strict mode) +flags: [onlyStrict] +---*/ + +function f1() { + function f() { + gNonStrict(); + } + f(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-22gs.js b/test/sendable/builtins/Function/15.3.5.4_2-22gs.js new file mode 100644 index 00000000000..f72eebc1e20 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-22gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-22gs +description: > + Strict mode - checking access to strict function caller from + strict function (FunctionExpression defined within a + FunctionDeclaration inside strict mode) +flags: [onlyStrict] +---*/ + +function f1() { + var f = function() { + gNonStrict(); + } + f(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-23gs.js b/test/sendable/builtins/Function/15.3.5.4_2-23gs.js new file mode 100644 index 00000000000..b8c21755221 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-23gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-23gs +description: > + Strict mode - checking access to strict function caller from + strict function (Anonymous FunctionExpression defined within a + FunctionDeclaration inside strict mode) +flags: [onlyStrict] +---*/ + +function f1() { + (function() { + gNonStrict(); + })(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-24gs.js b/test/sendable/builtins/Function/15.3.5.4_2-24gs.js new file mode 100644 index 00000000000..d2d6ecbc67d --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-24gs.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-24gs +description: > + Strict mode - checking access to strict function caller from + strict function (FunctionDeclaration defined within a + FunctionExpression inside strict mode) +flags: [onlyStrict] +---*/ + +var f1 = function() { + function f() { + gNonStrict(); + } + f(); +} + +assert.throws(TypeError, function() { + f1(); +}); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-25gs.js b/test/sendable/builtins/Function/15.3.5.4_2-25gs.js new file mode 100644 index 00000000000..2ea861faa7d --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-25gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-25gs +description: > + Strict mode - checking access to strict function caller from + strict function (FunctionExpression defined within a + FunctionExpression inside strict mode) +flags: [onlyStrict] +---*/ + +var f1 = function() { + var f = function() { + gNonStrict(); + } + f(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-26gs.js b/test/sendable/builtins/Function/15.3.5.4_2-26gs.js new file mode 100644 index 00000000000..3735a3c96b8 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-26gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-26gs +description: > + Strict mode - checking access to strict function caller from + strict function (Anonymous FunctionExpression defined within a + FunctionExpression inside strict mode) +flags: [onlyStrict] +---*/ + +var f1 = function() { + (function() { + gNonStrict(); + })(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-27gs.js b/test/sendable/builtins/Function/15.3.5.4_2-27gs.js new file mode 100644 index 00000000000..c5b0a34f2f4 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-27gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-27gs +description: > + Strict mode - checking access to strict function caller from + strict function (FunctionDeclaration defined within an Anonymous + FunctionExpression inside strict mode) +flags: [onlyStrict] +---*/ + +assert.throws(TypeError, function() { + (function() { + function f() { + gNonStrict(); + } + f(); + })(); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-28gs.js b/test/sendable/builtins/Function/15.3.5.4_2-28gs.js new file mode 100644 index 00000000000..d09b02533e0 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-28gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-28gs +description: > + Strict mode - checking access to strict function caller from + strict function (FunctionExpression defined within an Anonymous + FunctionExpression inside strict mode) +flags: [onlyStrict] +---*/ + +assert.throws(TypeError, function() { + (function() { + var f = function() { + gNonStrict(); + } + f(); + })(); +}); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-29gs.js b/test/sendable/builtins/Function/15.3.5.4_2-29gs.js new file mode 100644 index 00000000000..8dcbd2a475e --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-29gs.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-29gs +description: > + Strict mode - checking access to strict function caller from + strict function (Anonymous FunctionExpression defined within an + Anonymous FunctionExpression inside strict mode) +flags: [onlyStrict] +---*/ + +assert.throws(TypeError, function() { + (function() { + (function() { + gNonStrict(); + })(); + })(); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-2gs.js b/test/sendable/builtins/Function/15.3.5.4_2-2gs.js new file mode 100644 index 00000000000..0d809de4169 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-2gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-2gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (FunctionDeclaration includes strict directive + prologue) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +} + +assert.throws(TypeError, function() { + f(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-30gs.js b/test/sendable/builtins/Function/15.3.5.4_2-30gs.js new file mode 100644 index 00000000000..e2b758616b8 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-30gs.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-30gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (FunctionDeclaration defined within a + FunctionDeclaration with a strict directive prologue) +flags: [noStrict] +---*/ + +function f1() { + "use strict"; + + function f() { + gNonStrict(); + } + f(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-31gs.js b/test/sendable/builtins/Function/15.3.5.4_2-31gs.js new file mode 100644 index 00000000000..0288c2cdc26 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-31gs.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-31gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (FunctionExpression defined within a + FunctionDeclaration with a strict directive prologue) +flags: [noStrict] +---*/ + +function f1() { + "use strict"; + var f = function() { + gNonStrict(); + } + f(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-32gs.js b/test/sendable/builtins/Function/15.3.5.4_2-32gs.js new file mode 100644 index 00000000000..e24e40d25d4 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-32gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-32gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (Anonymous FunctionExpression defined within a + FunctionDeclaration with a strict directive prologue) +flags: [noStrict] +---*/ + +function f1() { + "use strict"; + (function() { + gNonStrict(); + })(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-33gs.js b/test/sendable/builtins/Function/15.3.5.4_2-33gs.js new file mode 100644 index 00000000000..6384c8e0a2f --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-33gs.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-33gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (FunctionDeclaration defined within a + FunctionExpression with a strict directive prologue) +flags: [noStrict] +---*/ + +var f1 = function() { + "use strict"; + + function f() { + gNonStrict(); + } + f(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-34gs.js b/test/sendable/builtins/Function/15.3.5.4_2-34gs.js new file mode 100644 index 00000000000..73447b0663e --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-34gs.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-34gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (FunctionExpression defined within a + FunctionExpression with a strict directive prologue) +flags: [noStrict] +---*/ + +var f1 = function() { + "use strict"; + var f = function() { + gNonStrict(); + } + f(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-35gs.js b/test/sendable/builtins/Function/15.3.5.4_2-35gs.js new file mode 100644 index 00000000000..46a5b1cddd7 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-35gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-35gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (Anonymous FunctionExpression defined within a + FunctionExpression with a strict directive prologue) +flags: [noStrict] +---*/ + +var f1 = function() { + "use strict"; + (function() { + gNonStrict(); + })(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-36gs.js b/test/sendable/builtins/Function/15.3.5.4_2-36gs.js new file mode 100644 index 00000000000..a5fae7fd85d --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-36gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-36gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (FunctionDeclaration defined within an + Anonymous FunctionExpression with a strict directive prologue) +flags: [noStrict] +---*/ + +assert.throws(TypeError, function() { + (function() { + "use strict"; + + function f() { + gNonStrict(); + } + f(); + })(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-37gs.js b/test/sendable/builtins/Function/15.3.5.4_2-37gs.js new file mode 100644 index 00000000000..e1cbdde3c88 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-37gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-37gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (FunctionExpression defined within an + Anonymous FunctionExpression with a strict directive prologue) +flags: [noStrict] +---*/ + +assert.throws(TypeError, function() { + (function() { + "use strict"; + var f = function() { + gNonStrict(); + } + f(); + })(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-38gs.js b/test/sendable/builtins/Function/15.3.5.4_2-38gs.js new file mode 100644 index 00000000000..ef8d91ab284 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-38gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-38gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (Anonymous FunctionExpression defined within + an Anonymous FunctionExpression with a strict directive prologue) +flags: [noStrict] +---*/ + +assert.throws(TypeError, function() { + (function() { + "use strict"; + (function() { + gNonStrict(); + })(); + })(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-39gs.js b/test/sendable/builtins/Function/15.3.5.4_2-39gs.js new file mode 100644 index 00000000000..4d603b8509c --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-39gs.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-39gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (FunctionDeclaration with a strict directive + prologue defined within a FunctionDeclaration) +flags: [noStrict] +---*/ + +function f1() { + function f() { + "use strict"; + gNonStrict(); + } + return f(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-3gs.js b/test/sendable/builtins/Function/15.3.5.4_2-3gs.js new file mode 100644 index 00000000000..7ba8133098e --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-3gs.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-3gs +description: > + Strict mode - checking access to strict function caller from + strict function (FunctionExpression defined within strict mode) +flags: [onlyStrict] +---*/ + +var f = function() { + gNonStrict(); +} + +assert.throws(TypeError, function() { + f(); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-40gs.js b/test/sendable/builtins/Function/15.3.5.4_2-40gs.js new file mode 100644 index 00000000000..8940ef1009a --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-40gs.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-40gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (FunctionExpression with a strict directive + prologue defined within a FunctionDeclaration) +flags: [noStrict] +---*/ + +function f1() { + var f = function() { + "use strict"; + gNonStrict(); + } + return f(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-41gs.js b/test/sendable/builtins/Function/15.3.5.4_2-41gs.js new file mode 100644 index 00000000000..08a87518af6 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-41gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-41gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (Anonymous FunctionExpression with a strict + directive prologue defined within a FunctionDeclaration) +flags: [noStrict] +---*/ + +function f1() { + return (function() { + "use strict"; + gNonStrict(); + })(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-42gs.js b/test/sendable/builtins/Function/15.3.5.4_2-42gs.js new file mode 100644 index 00000000000..adc81b147c7 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-42gs.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-42gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (FunctionDeclaration with a strict directive + prologue defined within a FunctionExpression) +flags: [noStrict] +---*/ + +var f1 = function() { + function f() { + "use strict"; + gNonStrict(); + } + return f(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-43gs.js b/test/sendable/builtins/Function/15.3.5.4_2-43gs.js new file mode 100644 index 00000000000..956e09d3815 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-43gs.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-43gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (FunctionExpression with a strict directive + prologue defined within a FunctionExpression) +flags: [noStrict] +---*/ + +var f1 = function() { + var f = function() { + "use strict"; + gNonStrict(); + } + return f(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-44gs.js b/test/sendable/builtins/Function/15.3.5.4_2-44gs.js new file mode 100644 index 00000000000..a91502f0aae --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-44gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-44gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (Anonymous FunctionExpression with a strict + directive prologue defined within a FunctionExpression) +flags: [noStrict] +---*/ + +var f1 = function() { + return (function() { + "use strict"; + gNonStrict(); + })(); +} + +assert.throws(TypeError, function() { + f1(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-45gs.js b/test/sendable/builtins/Function/15.3.5.4_2-45gs.js new file mode 100644 index 00000000000..c2af6a025d6 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-45gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-45gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (FunctionDeclaration with a strict directive + prologue defined within an Anonymous FunctionExpression) +flags: [noStrict] +---*/ + +assert.throws(TypeError, function() { + (function() { + function f() { + "use strict"; + gNonStrict(); + } + return f(); + })(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-46gs.js b/test/sendable/builtins/Function/15.3.5.4_2-46gs.js new file mode 100644 index 00000000000..58f30f5e458 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-46gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-46gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (FunctionExpression with a strict directive + prologue defined within an Anonymous FunctionExpression) +flags: [noStrict] +---*/ + +assert.throws(TypeError, function() { + (function() { + var f = function() { + "use strict"; + gNonStrict(); + } + return f(); + })(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-47gs.js b/test/sendable/builtins/Function/15.3.5.4_2-47gs.js new file mode 100644 index 00000000000..f3d98c25875 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-47gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-47gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (Anonymous FunctionExpression with a strict + directive prologue defined within an Anonymous FunctionExpression) +flags: [noStrict] +---*/ + +assert.throws(TypeError, function() { + (function() { + return (function() { + "use strict"; + gNonStrict(); + })(); + })(); +}); + + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-48gs.js b/test/sendable/builtins/Function/15.3.5.4_2-48gs.js new file mode 100644 index 00000000000..2525b3f25f9 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-48gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-48gs +description: > + Strict mode - checking access to strict function caller from + strict function (Literal getter defined within strict mode) +flags: [onlyStrict] +---*/ + +var o = { + get foo() { + gNonStrict(); + } +} + +assert.throws(TypeError, function() { + o.foo; +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-49gs.js b/test/sendable/builtins/Function/15.3.5.4_2-49gs.js new file mode 100644 index 00000000000..720d5ba1112 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-49gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-49gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (Literal getter includes strict directive + prologue) +flags: [noStrict] +---*/ + +var o = { + get foo() { + "use strict"; + gNonStrict(); + } +} + +assert.throws(TypeError, function() { + o.foo; +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-4gs.js b/test/sendable/builtins/Function/15.3.5.4_2-4gs.js new file mode 100644 index 00000000000..c9d9b959074 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-4gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-4gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (FunctionExpression includes strict directive + prologue) +flags: [noStrict] +---*/ + +var f = function() { + "use strict"; + gNonStrict(); +} + +assert.throws(TypeError, function() { + f(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-50gs.js b/test/sendable/builtins/Function/15.3.5.4_2-50gs.js new file mode 100644 index 00000000000..04d05953d3c --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-50gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-50gs +description: > + Strict mode - checking access to strict function caller from + strict function (Literal setter defined within strict mode) +flags: [onlyStrict] +---*/ + +var o = { + set foo(stuff) { + gNonStrict(); + } +} + +assert.throws(TypeError, function() { + o.foo = 7; +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-51gs.js b/test/sendable/builtins/Function/15.3.5.4_2-51gs.js new file mode 100644 index 00000000000..231ae9e6a87 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-51gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-51gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (Literal setter includes strict directive + prologue) +flags: [noStrict] +---*/ + +var o = { + set foo(stuff) { + "use strict"; + gNonStrict(); + } +} + +assert.throws(TypeError, function() { + o.foo = 8; +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-52gs.js b/test/sendable/builtins/Function/15.3.5.4_2-52gs.js new file mode 100644 index 00000000000..eb1ba1e998d --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-52gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-52gs +description: > + Strict mode - checking access to strict function caller from + strict function (Injected getter defined within strict mode) +flags: [onlyStrict] +---*/ + +var o = {}; +Object.defineProperty(o, "foo", { + get: function() { + gNonStrict(); + } +}); + +assert.throws(TypeError, function() { + o.foo; +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-53gs.js b/test/sendable/builtins/Function/15.3.5.4_2-53gs.js new file mode 100644 index 00000000000..a36ab96973c --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-53gs.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-53gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (Injected getter includes strict directive + prologue) +flags: [noStrict] +---*/ + +var o = {}; +Object.defineProperty(o, "foo", { + get: function() { + "use strict"; + gNonStrict(); + } +}); + +assert.throws(TypeError, function() { + o.foo; +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-54gs.js b/test/sendable/builtins/Function/15.3.5.4_2-54gs.js new file mode 100644 index 00000000000..653fa6a53c8 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-54gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-54gs +description: > + Strict mode - checking access to strict function caller from + strict function (Injected setter defined within strict mode) +flags: [onlyStrict] +---*/ + +var o = {}; +Object.defineProperty(o, "foo", { + set: function(stuff) { + gNonStrict(); + } +}); + +assert.throws(TypeError, function() { + o.foo = 9; +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-55gs.js b/test/sendable/builtins/Function/15.3.5.4_2-55gs.js new file mode 100644 index 00000000000..acf1f8b3b04 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-55gs.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-55gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (Injected setter includes strict directive + prologue) +flags: [noStrict] +---*/ + +var o = {}; +Object.defineProperty(o, "foo", { + set: function(stuff) { + "use strict"; + gNonStrict(); + } +}); + +assert.throws(TypeError, function() { + o.foo = 10; +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-56gs.js b/test/sendable/builtins/Function/15.3.5.4_2-56gs.js new file mode 100644 index 00000000000..78259c4de29 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-56gs.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-56gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + non-strict function declaration) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; + +function foo() { + return f(); +} + +assert.throws(TypeError, function() { + foo(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-57gs.js b/test/sendable/builtins/Function/15.3.5.4_2-57gs.js new file mode 100644 index 00000000000..5ebce52a62e --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-57gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-57gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + non-strict eval) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + eval("f();"); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-58gs.js b/test/sendable/builtins/Function/15.3.5.4_2-58gs.js new file mode 100644 index 00000000000..e5e3af2d275 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-58gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-58gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + non-strict Function constructor) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + Function("return f();")(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-59gs.js b/test/sendable/builtins/Function/15.3.5.4_2-59gs.js new file mode 100644 index 00000000000..f4e71cbaf21 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-59gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-59gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + non-strict new'ed Function constructor) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + new Function("return f();")(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-5gs.js b/test/sendable/builtins/Function/15.3.5.4_2-5gs.js new file mode 100644 index 00000000000..5d3cad2be21 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-5gs.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-5gs +description: > + Strict mode - checking access to strict function caller from + strict function (Anonymous FunctionExpression defined within + strict mode) +flags: [onlyStrict] +---*/ + +assert.throws(TypeError, function() { + (function() { + gNonStrict(); + })(); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-60gs.js b/test/sendable/builtins/Function/15.3.5.4_2-60gs.js new file mode 100644 index 00000000000..f8ca12ecf95 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-60gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-60gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.apply()) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + f.apply(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-61gs.js b/test/sendable/builtins/Function/15.3.5.4_2-61gs.js new file mode 100644 index 00000000000..2f600d7f05b --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-61gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-61gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.apply(null)) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + f.apply(null); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-62gs.js b/test/sendable/builtins/Function/15.3.5.4_2-62gs.js new file mode 100644 index 00000000000..1e775795d2a --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-62gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-62gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.apply(undefined)) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + f.apply(undefined); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-63gs.js b/test/sendable/builtins/Function/15.3.5.4_2-63gs.js new file mode 100644 index 00000000000..40a4c113ddc --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-63gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-63gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.apply(someObject)) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; +var o = {}; + +assert.throws(TypeError, function() { + f.apply(o); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-64gs.js b/test/sendable/builtins/Function/15.3.5.4_2-64gs.js new file mode 100644 index 00000000000..29ffd395f54 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-64gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-64gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.apply(globalObject)) +flags: [noStrict] +---*/ + +var global = this; + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + f.apply(global); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-65gs.js b/test/sendable/builtins/Function/15.3.5.4_2-65gs.js new file mode 100644 index 00000000000..04733ef3490 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-65gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-65gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.call()) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + f.call(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-66gs.js b/test/sendable/builtins/Function/15.3.5.4_2-66gs.js new file mode 100644 index 00000000000..c5107450bb5 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-66gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-66gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.call(null)) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + f.call(null); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-67gs.js b/test/sendable/builtins/Function/15.3.5.4_2-67gs.js new file mode 100644 index 00000000000..9c8647ed28d --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-67gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-67gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.call(undefined)) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + f.call(undefined); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-68gs.js b/test/sendable/builtins/Function/15.3.5.4_2-68gs.js new file mode 100644 index 00000000000..04583758b98 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-68gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-68gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.call(someObject)) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; +var o = {}; + +assert.throws(TypeError, function() { + f.call(o); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-69gs.js b/test/sendable/builtins/Function/15.3.5.4_2-69gs.js new file mode 100644 index 00000000000..e53269fb92f --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-69gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-69gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.call(globalObject)) +flags: [noStrict] +---*/ + +var global = this; + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + f.call(this); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-6gs.js b/test/sendable/builtins/Function/15.3.5.4_2-6gs.js new file mode 100644 index 00000000000..d89a3191c50 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-6gs.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-6gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (Anonymous FunctionExpression includes strict + directive prologue) +flags: [noStrict] +---*/ + +assert.throws(TypeError, function() { + (function() { + "use strict"; + gNonStrict(); + })(); +}); + + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-70gs.js b/test/sendable/builtins/Function/15.3.5.4_2-70gs.js new file mode 100644 index 00000000000..fee98a3af9f --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-70gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-70gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.bind()()) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + f.bind()(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-71gs.js b/test/sendable/builtins/Function/15.3.5.4_2-71gs.js new file mode 100644 index 00000000000..40015883f56 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-71gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-71gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.bind(null)()) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + f.bind(null)(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-72gs.js b/test/sendable/builtins/Function/15.3.5.4_2-72gs.js new file mode 100644 index 00000000000..3d8e7f1b1c3 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-72gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-72gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.bind(undefined)()) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + f.bind(undefined)(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-73gs.js b/test/sendable/builtins/Function/15.3.5.4_2-73gs.js new file mode 100644 index 00000000000..5de97e99067 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-73gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-73gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.bind(someObject)()) +flags: [noStrict] +---*/ + +function f() { + "use strict"; + gNonStrict(); +}; +var o = {}; + +assert.throws(TypeError, function() { + f.bind(o)(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-74gs.js b/test/sendable/builtins/Function/15.3.5.4_2-74gs.js new file mode 100644 index 00000000000..d7a3d5aff60 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-74gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-74gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (strict function declaration called by + Function.prototype.bind(globalObject)()) +flags: [noStrict] +---*/ + +var global = this; + +function f() { + "use strict"; + gNonStrict(); +}; + +assert.throws(TypeError, function() { + f.bind(global)(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-75gs.js b/test/sendable/builtins/Function/15.3.5.4_2-75gs.js new file mode 100644 index 00000000000..867f6de0e1f --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-75gs.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-75gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict function declaration) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; + +function foo() { + "use strict"; + f(); +} +foo(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-76gs.js b/test/sendable/builtins/Function/15.3.5.4_2-76gs.js new file mode 100644 index 00000000000..d7188a82c7f --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-76gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-76gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict eval) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + return eval("f();"); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-77gs.js b/test/sendable/builtins/Function/15.3.5.4_2-77gs.js new file mode 100644 index 00000000000..4485a13dda4 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-77gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-77gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function constructor) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + Function("return f();")(); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-78gs.js b/test/sendable/builtins/Function/15.3.5.4_2-78gs.js new file mode 100644 index 00000000000..36233be49af --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-78gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-78gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict new'ed Function constructor) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + return new Function("return f();")(); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-79gs.js b/test/sendable/builtins/Function/15.3.5.4_2-79gs.js new file mode 100644 index 00000000000..1e3afffd175 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-79gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-79gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.apply()) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + f.apply(); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-7gs.js b/test/sendable/builtins/Function/15.3.5.4_2-7gs.js new file mode 100644 index 00000000000..aa2ac8cd558 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-7gs.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-7gs +description: > + Strict mode - checking access to non-strict function caller from + strict function (Function constructor defined within strict mode) +flags: [onlyStrict] +---*/ + +var f = Function("return gNonStrict();"); + +assert.throws(TypeError, function() { + f(); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-80gs.js b/test/sendable/builtins/Function/15.3.5.4_2-80gs.js new file mode 100644 index 00000000000..567f3078fe4 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-80gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-80gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.apply(null)) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + f.apply(null); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-81gs.js b/test/sendable/builtins/Function/15.3.5.4_2-81gs.js new file mode 100644 index 00000000000..5e983d78eaa --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-81gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-81gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.apply(undefined)) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + f.apply(undefined); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-82gs.js b/test/sendable/builtins/Function/15.3.5.4_2-82gs.js new file mode 100644 index 00000000000..cb627253d1c --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-82gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-82gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.apply(someObject)) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +var o = {}; +(function() { + "use strict"; + f.apply(o); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-83gs.js b/test/sendable/builtins/Function/15.3.5.4_2-83gs.js new file mode 100644 index 00000000000..7e84c1baf20 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-83gs.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-83gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.apply(globalObject)) +flags: [noStrict] +features: [caller] +---*/ + +var global = this; + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + f.apply(global); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-84gs.js b/test/sendable/builtins/Function/15.3.5.4_2-84gs.js new file mode 100644 index 00000000000..12d73cd7a14 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-84gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-84gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.call()) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + f.call(); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-85gs.js b/test/sendable/builtins/Function/15.3.5.4_2-85gs.js new file mode 100644 index 00000000000..e80189024d8 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-85gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-85gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.call(null)) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + f.call(null); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-86gs.js b/test/sendable/builtins/Function/15.3.5.4_2-86gs.js new file mode 100644 index 00000000000..e3bf6747bb5 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-86gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-86gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.call(undefined)) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + f.call(undefined); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-87gs.js b/test/sendable/builtins/Function/15.3.5.4_2-87gs.js new file mode 100644 index 00000000000..a9607b31ee9 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-87gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-87gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.call(someObject)) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +var o = {}; +(function() { + "use strict"; + f.call(o); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-88gs.js b/test/sendable/builtins/Function/15.3.5.4_2-88gs.js new file mode 100644 index 00000000000..7e06d5fbf02 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-88gs.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-88gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.call(globalObject)) +flags: [noStrict] +features: [caller] +---*/ + +var global = this; + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + f.call(global); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-89gs.js b/test/sendable/builtins/Function/15.3.5.4_2-89gs.js new file mode 100644 index 00000000000..3fc16cb8c8f --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-89gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-89gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.bind()()) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + f.bind()(); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-8gs.js b/test/sendable/builtins/Function/15.3.5.4_2-8gs.js new file mode 100644 index 00000000000..ccaa1f28765 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-8gs.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-8gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (Function constructor includes strict + directive prologue) +flags: [noStrict] +---*/ + +var f = Function("\"use strict\";\ngNonStrict();"); + +assert.throws(TypeError, function() { + f(); +}); + +function gNonStrict() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-90gs.js b/test/sendable/builtins/Function/15.3.5.4_2-90gs.js new file mode 100644 index 00000000000..3729c54c750 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-90gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-90gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.bind(null)()) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + f.bind(null)(); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-91gs.js b/test/sendable/builtins/Function/15.3.5.4_2-91gs.js new file mode 100644 index 00000000000..b3580b3f687 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-91gs.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-91gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.bind(undefined)()) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + f.bind(undefined)(); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-92gs.js b/test/sendable/builtins/Function/15.3.5.4_2-92gs.js new file mode 100644 index 00000000000..b166d801684 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-92gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-92gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.bind(someObject)()) +flags: [noStrict] +features: [caller] +---*/ + +function f() { + return gNonStrict(); +}; +var o = {}; +(function() { + "use strict"; + f.bind(o)(); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-93gs.js b/test/sendable/builtins/Function/15.3.5.4_2-93gs.js new file mode 100644 index 00000000000..de03042fffc --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-93gs.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-93gs +description: > + Strict mode - checking access to strict function caller from + non-strict function (non-strict function declaration called by + strict Function.prototype.bind(globalObject)()) +flags: [noStrict] +features: [caller] +---*/ + +var global = this; + +function f() { + return gNonStrict(); +}; +(function() { + "use strict"; + f.bind(global)(); +})(); + + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-94gs.js b/test/sendable/builtins/Function/15.3.5.4_2-94gs.js new file mode 100644 index 00000000000..a816af828a1 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-94gs.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-94gs +description: > + Strict mode - checking access to strict function caller from + non-strict function expression (FunctionDeclaration includes + strict directive prologue) +flags: [noStrict] +---*/ + +var gNonStrict = function() { + return gNonStrict.caller || gNonStrict.caller.throwTypeError; +} + +function f() { + "use strict"; + gNonStrict(); +} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-95gs.js b/test/sendable/builtins/Function/15.3.5.4_2-95gs.js new file mode 100644 index 00000000000..1e3fdc02a48 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-95gs.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-95gs +description: > + Strict mode - checking access to strict function caller from + non-strict, constructor-based function (FunctionDeclaration + includes strict directive prologue) +flags: [noStrict] +---*/ + +var gNonStrict = Function("return gNonStrict.caller || gNonStrict.caller.throwTypeError;"); + +function f() { + "use strict"; + gNonStrict(); +} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-96gs.js b/test/sendable/builtins/Function/15.3.5.4_2-96gs.js new file mode 100644 index 00000000000..e6709fdf586 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-96gs.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-96gs +description: > + Strict mode - checking access to strict function caller from + non-strict property (FunctionDeclaration includes strict directive + prologue) +flags: [noStrict] +---*/ + +var o = { + get gNonStrict() { + var tmp = Object.getOwnPropertyDescriptor(o, "gNonStrict").get; + return tmp.caller || tmp.caller.throwTypeError; + } +}; + + +function f() { + "use strict"; + return o.gNonStrict; +} + +assert.throws(TypeError, function() { + f(); +}); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-97gs.js b/test/sendable/builtins/Function/15.3.5.4_2-97gs.js new file mode 100644 index 00000000000..8dd7945eff6 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-97gs.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-97gs +description: > + Strict mode - checking access to strict function caller from bound + non-strict function (FunctionDeclaration includes strict directive + prologue) +flags: [noStrict] +---*/ + +var gNonStrict = gNonStrictBindee.bind(null); + +function f() { + "use strict"; + gNonStrict(); +} + +assert.throws(TypeError, function() { + f(); +}); + +function gNonStrictBindee() { + return gNonStrictBindee.caller || gNonStrictBindee.caller.throwTypeError; +} diff --git a/test/sendable/builtins/Function/15.3.5.4_2-9gs.js b/test/sendable/builtins/Function/15.3.5.4_2-9gs.js new file mode 100644 index 00000000000..57d79876d77 --- /dev/null +++ b/test/sendable/builtins/Function/15.3.5.4_2-9gs.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.5.4_2-9gs +description: > + Strict mode - checking access to non-strict function caller from + strict function (New'ed Function constructor defined within strict + mode) +flags: [onlyStrict] +---*/ + +var f = new Function("return gNonStrict();"); + +assert.throws(TypeError, function() { + f(); +}); + +function gNonStrict() { + return gNonStrict.caller; +} diff --git a/test/sendable/builtins/Function/S10.1.1_A1_T3.js b/test/sendable/builtins/Function/S10.1.1_A1_T3.js new file mode 100644 index 00000000000..8220904627b --- /dev/null +++ b/test/sendable/builtins/Function/S10.1.1_A1_T3.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + Program functions are defined in source text by a FunctionDeclaration or created dynamically either + by using a FunctionExpression or by using the built-in Function object as a constructor +es5id: 10.1.1_A1_T3 +description: > + Creating function dynamically by using the built-in Function + object as a constructor +---*/ + +var x = new function f1() { + return 1; +}; + +assert.sameValue( + typeof(x.constructor), + "function", + 'The value of `typeof(x.constructor)` is expected to be "function"' +); diff --git a/test/sendable/builtins/Function/S15.3.1_A1_T1.js b/test/sendable/builtins/Function/S15.3.1_A1_T1.js new file mode 100644 index 00000000000..87fea80bcf4 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.1_A1_T1.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The function call Function(…) is equivalent to the object creation expression + new Function(…) with the same arguments. +es5id: 15.3.1_A1_T1 +description: Create simple functions and check returned values +---*/ + +var f = Function("return arguments[0];"); + +assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert.sameValue(f(1), 1, 'f(1) must return 1'); + +var g = new Function("return arguments[0];"); + + +assert(g instanceof Function, 'The result of evaluating (g instanceof Function) is expected to be true'); +assert.sameValue(g("A"), "A", 'g("A") must return "A"'); +assert.sameValue(g("A"), f("A"), 'g("A") must return the same value returned by f("A")'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T1.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T1.js new file mode 100644 index 00000000000..0fa5fc7bab5 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T1.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with one argument then body be that argument and the following steps are taken: + i) Call ToString(body) + ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception + iii) If body is not parsable as FunctionBody then throw a SyntaxError exception + iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + Pass in a scope chain consisting of the global object as the Scope parameter + v) Return Result(iv) +es5id: 15.3.2.1_A1_T1 +description: "The body of the function is \"{toString:function(){throw 7;}}\"" +---*/ + +var body = { + toString: function() { + throw 7; + } +} + +try { + var f = new Function(body); + throw new Test262Error('#1: When the Function constructor is called with one argument then body be that argument the following step are taken: call ToString(body)'); +} catch (e) { + assert.sameValue(e, 7, 'The value of e is expected to be 7'); +} diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T10.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T10.js new file mode 100644 index 00000000000..4f3bf9fc4cf --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T10.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with one argument then body be that argument and the following steps are taken: + i) Call ToString(body) + ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception + iii) If body is not parsable as FunctionBody then throw a SyntaxError exception + iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + Pass in a scope chain consisting of the global object as the Scope parameter + v) Return Result(iv) +es5id: 15.3.2.1_A1_T10 +description: Value of the function constructor argument is "null" +---*/ + +try { + var f = new Function(null); +} catch (e) { + throw new Test262Error('#1: test fails with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T11.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T11.js new file mode 100644 index 00000000000..81fb402ed10 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T11.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with one argument then body be that argument and the following steps are taken: + i) Call ToString(body) + ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception + iii) If body is not parsable as FunctionBody then throw a SyntaxError exception + iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + Pass in a scope chain consisting of the global object as the Scope parameter + v) Return Result(iv) +es5id: 15.3.2.1_A1_T11 +description: Value of the function constructor argument is "undefined" +---*/ + +try { + var f = new Function(undefined); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T12.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T12.js new file mode 100644 index 00000000000..0d985c857f1 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T12.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with one argument then body be that argument and the following steps are taken: + i) Call ToString(body) + ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception + iii) If body is not parsable as FunctionBody then throw a SyntaxError exception + iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + Pass in a scope chain consisting of the global object as the Scope parameter + v) Return Result(iv) +es5id: 15.3.2.1_A1_T12 +description: Value of the function constructor argument is "void 0" +---*/ + +try { + var f = new Function(void 0); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T13.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T13.js new file mode 100644 index 00000000000..d95a49b0ea0 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T13.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with one argument then body be that argument and the following steps are taken: + i) Call ToString(body) + ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception + iii) If body is not parsable as FunctionBody then throw a SyntaxError exception + iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + Pass in a scope chain consisting of the global object as the Scope parameter + v) Return Result(iv) +es5id: 15.3.2.1_A1_T13 +description: Value of the function constructor argument is "{}" +---*/ + +try { + var f = new Function({}); + throw new Test262Error('#1: test failed with error ' + e); +} catch (e) { + assert( + e instanceof SyntaxError, + 'The result of evaluating (e instanceof SyntaxError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T2.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T2.js new file mode 100644 index 00000000000..aec17534493 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T2.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with one argument then body be that argument and the following steps are taken: + i) Call ToString(body) + ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception + iii) If body is not parsable as FunctionBody then throw a SyntaxError exception + iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + Pass in a scope chain consisting of the global object as the Scope parameter + v) Return Result(iv) +es5id: 15.3.2.1_A1_T2 +description: > + The body of the function is "{toString:function(){return "return + 1;";}}" +---*/ + +var body = { + toString: function() { + return "return 1;"; + } +}; + +try { + var f = new Function(body); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), 1, 'f() must return 1'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T3.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T3.js new file mode 100644 index 00000000000..6ddd1c5c99b --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T3.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with one argument then body be that argument and the following steps are taken: + i) Call ToString(body) + ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception + iii) If body is not parsable as FunctionBody then throw a SyntaxError exception + iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + Pass in a scope chain consisting of the global object as the Scope parameter + v) Return Result(iv) +es5id: 15.3.2.1_A1_T3 +description: Value of the function constructor argument is 1 +---*/ + +try { + var f = new Function(1); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T4.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T4.js new file mode 100644 index 00000000000..0179a8b11a6 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T4.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with one argument then body be that argument and the following steps are taken: + i) Call ToString(body) + ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception + iii) If body is not parsable as FunctionBody then throw a SyntaxError exception + iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + Pass in a scope chain consisting of the global object as the Scope parameter + v) Return Result(iv) +es5id: 15.3.2.1_A1_T4 +description: > + Value of the function constructor argument is x, where x is + specified with "undefined" +---*/ + +try { + var f = new Function(x); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), undefined, 'f() returns undefined'); + +var x; diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T5.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T5.js new file mode 100644 index 00000000000..54f6b032568 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T5.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with one argument then body be that argument and the following steps are taken: + i) Call ToString(body) + ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception + iii) If body is not parsable as FunctionBody then throw a SyntaxError exception + iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + Pass in a scope chain consisting of the global object as the Scope parameter + v) Return Result(iv) +es5id: 15.3.2.1_A1_T5 +description: > + Value of the function constructor argument is "Object("return + \'A\'")" +---*/ + +var body = Object("return \'A\'"); + +try { + var f = new Function(body); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), "\u0041", 'f() must return "u0041"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T6.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T6.js new file mode 100644 index 00000000000..1e0df1316cb --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T6.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with one argument then body be that argument and the following steps are taken: + i) Call ToString(body) + ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception + iii) If body is not parsable as FunctionBody then throw a SyntaxError exception + iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + Pass in a scope chain consisting of the global object as the Scope parameter + v) Return Result(iv) +es5id: 15.3.2.1_A1_T6 +description: > + Value of the function constructor argument is the string "return + true;" +---*/ + +try { + var f = new Function("return true;"); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert(f(), 'f() must return true'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T7.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T7.js new file mode 100644 index 00000000000..2641c8a8192 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T7.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with one argument then body be that argument and the following steps are taken: + i) Call ToString(body) + ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception + iii) If body is not parsable as FunctionBody then throw a SyntaxError exception + iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + Pass in a scope chain consisting of the global object as the Scope parameter + v) Return Result(iv) +es5id: 15.3.2.1_A1_T7 +description: Value of the function constructor argument is "Object(1)" +---*/ + +var body = new Object(1); + +try { + var f = new Function(body); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T8.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T8.js new file mode 100644 index 00000000000..2bdb4c73664 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T8.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with one argument then body be that argument and the following steps are taken: + i) Call ToString(body) + ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception + iii) If body is not parsable as FunctionBody then throw a SyntaxError exception + iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + Pass in a scope chain consisting of the global object as the Scope parameter + v) Return Result(iv) +es5id: 15.3.2.1_A1_T8 +description: Value of the function constructor argument is "var 1=1;" +---*/ + +var body = "var 1=1;"; + +try { + var f = new Function(body); + throw new Test262Error('#1: If body is not parsable as FunctionBody then throw a SyntaxError exception'); +} catch (e) { + assert( + e instanceof SyntaxError, + 'The result of evaluating (e instanceof SyntaxError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T9.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T9.js new file mode 100644 index 00000000000..be9d46a4e5d --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T9.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with one argument then body be that argument and the following steps are taken: + i) Call ToString(body) + ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception + iii) If body is not parsable as FunctionBody then throw a SyntaxError exception + iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + Pass in a scope chain consisting of the global object as the Scope parameter + v) Return Result(iv) +es5id: 15.3.2.1_A1_T9 +description: > + Value of the function constructor argument is "return + arguments[0];" +---*/ + +var f = new Function("return arguments[0];"); + +assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert.sameValue(f("A"), "A", 'f("A") must return "A"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T1.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T1.js new file mode 100644 index 00000000000..156a1a79301 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T1.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + It is permissible but not necessary to have one argument for each formal + parameter to be specified +es5id: 15.3.2.1_A2_T1 +description: > + Values of the function constructor arguments are "arg1", "arg2", + "arg3", "return arg1+arg2+arg3;" +---*/ + +try { + var f = Function("arg1", "arg2", "arg3", "return arg1+arg2+arg3;"); +} catch (e) { + throw new Test262Error('#1: test failed'); +} + +assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert.sameValue(f(1, 2, 3), 6, 'f(1, 2, 3) must return 6'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T2.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T2.js new file mode 100644 index 00000000000..3591163ab75 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T2.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + It is permissible but not necessary to have one argument for each formal + parameter to be specified +es5id: 15.3.2.1_A2_T2 +description: > + Values of the function constructor arguments are "arg1, arg2", + "arg3", "return arg1+arg2+arg3;" +---*/ + +try { + var f = Function("arg1, arg2", "arg3", "return arg1+arg2+arg3;"); +} catch (e) { + throw new Test262Error('#1: test failed'); +} + +assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert.sameValue(f("AB", "BA", 1), "ABBA1", 'f(AB, BA, 1) must return "ABBA1"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T3.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T3.js new file mode 100644 index 00000000000..a7798eda702 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T3.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + It is permissible but not necessary to have one argument for each formal + parameter to be specified +es5id: 15.3.2.1_A2_T3 +description: > + Values of the function constructor arguments are "arg1, arg2, + arg3", "return arg1+arg2+arg3;" +---*/ + +try { + var f = Function("arg1, arg2, arg3", "return arg1+arg2+arg3;"); +} catch (e) { + throw new Test262Error('#1: test failed'); +} + +assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert.sameValue(f(1, 1, "ABBA"), "2ABBA", 'f(1, 1, ABBA) must return "2ABBA"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T4.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T4.js new file mode 100644 index 00000000000..cb9803294b5 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T4.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + It is permissible but not necessary to have one argument for each formal + parameter to be specified +es5id: 15.3.2.1_A2_T4 +description: > + Values of the function constructor arguments are "return"-s of + various results +---*/ + +var i = 0; + +var p = { + toString: function() { + return "arg" + (++i); + } +}; + +try { + var f = Function(p, p, p, "return arg1+arg2+arg3;"); +} catch (e) { + throw new Test262Error('#1: test failed'); +} + +assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert.sameValue(f(4, "2", "QUESTION"), "42QUESTION", 'f(4, 2, QUESTION) must return "42QUESTION"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T5.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T5.js new file mode 100644 index 00000000000..72b1c0cc831 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T5.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + It is permissible but not necessary to have one argument for each formal + parameter to be specified +es5id: 15.3.2.1_A2_T5 +description: > + Values of the function constructor arguments are "return"-s of + various results and a concotenation of strings +---*/ + +var i = 0; + +var p = { + toString: function() { + return "arg" + (++i) + } +}; + +try { + var f = Function(p + "," + p, p, "return arg1+arg2+arg3;"); +} catch (e) { + throw new Test262Error('#1: test failed'); +} + +assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert.sameValue(f("", 1, 2), "12", 'f(, 1, 2) must return "12"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T6.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T6.js new file mode 100644 index 00000000000..c1a8b578bec --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T6.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + It is permissible but not necessary to have one argument for each formal + parameter to be specified +es5id: 15.3.2.1_A2_T6 +description: > + Values of the function constructor arguments are "return"-s of + various results and a concotenation of strings +---*/ + +var i = 0; + +var p = { + toString: function() { + return "arg" + (++i) + } +}; + +try { + var f = Function(p + "," + p + "," + p, "return arg1+arg2+arg3;"); +} catch (e) { + throw new Test262Error('#1: test failed'); +} + +assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert.sameValue(f("", 1, p), "1arg4", 'f(, 1, {toString: function() {return "arg" + (++i)}}) must return "1arg4"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T1.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T1.js new file mode 100644 index 00000000000..01cee6d75f0 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T1.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T1 +description: > + Values of the function constructor arguments are + "{toString:function(){throw 1;}}" and "{toString:function(){throw + 'body';}}" +---*/ + +var p = { + toString: function() { + throw 1; + } +}; +var body = { + toString: function() { + throw "body"; + } +}; + +try { + var f = new Function(p, body); + throw new Test262Error('#1: test failed'); +} catch (e) { + assert.sameValue(e, 1, 'The value of e is expected to be 1'); +} diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T10.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T10.js new file mode 100644 index 00000000000..fe4e55bf5d1 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T10.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T10 +description: > + Values of the function constructor arguments are + "{toString:function(){return "z;x"}}" and "return this;" +---*/ + +var body = "return this;"; +var p = { + toString: function() { + return "z;x" + } +}; + +try { + var f = new Function(p, body); + throw new Test262Error('#1: If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception'); +} catch (e) { + assert( + e instanceof SyntaxError, + 'The result of evaluating (e instanceof SyntaxError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T11.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T11.js new file mode 100644 index 00000000000..eb10b2dd887 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T11.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T11 +description: > + Values of the function constructor arguments are "a,b,c" and "void + 0" +---*/ + +var p = "a,b,c"; + +try { + var f = new Function(p, void 0); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T12.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T12.js new file mode 100644 index 00000000000..7daf65b866b --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T12.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T12 +description: > + Values of the function constructor arguments are "a,b,c" and + "undefined" +---*/ + +var p = "a,b,c"; + +try { + var f = new Function(p, undefined); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T13.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T13.js new file mode 100644 index 00000000000..c60ae2aaa9c --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T13.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T13 +description: Values of the function constructor arguments are "a,b,c" and "null" +---*/ + +var p = "a,b,c"; + +try { + var f = new Function(p, null); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T14.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T14.js new file mode 100644 index 00000000000..b2980b58186 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T14.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T14 +description: > + Values of the function constructor arguments are "a,b,c" and an + undefined variable +---*/ + +var p = "a,b,c"; + +try { + var f = new Function(p, body); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), undefined, 'f() returns undefined'); + +var body; diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T15.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T15.js new file mode 100644 index 00000000000..58fe26587d0 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T15.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T15 +description: > + Values of the function constructor arguments are are two empty + strings +---*/ + +try { + var f = new Function("", ""); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T2.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T2.js new file mode 100644 index 00000000000..ec3fd64d9c9 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T2.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T2 +description: > + Values of the function constructor arguments are + "{toString:function(){return 'a';}}" and "return a;" +---*/ + +var p = { + toString: function() { + return "a"; + } +}; +var body = "return a;"; + +try { + var f = new Function(p, body); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(42), 42, 'f(42) must return 42'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T3.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T3.js new file mode 100644 index 00000000000..45c9be817f7 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T3.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T3 +description: > + Values of the function constructor arguments are + "{toString:function(){p=1;return "a";}}" and + "{toString:function(){throw "body";}}" +---*/ + +var p = { + toString: function() { + p = 1; + return "a"; + } +}; +var body = { + toString: function() { + throw "body"; + } +}; + +try { + var f = new Function(p, body); + throw new Test262Error('#1: test failed'); +} catch (e) { + assert.sameValue(e, "body", 'The value of e is expected to be "body"'); +} + +assert.sameValue(p, 1, 'The value of p is expected to be 1'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T4.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T4.js new file mode 100644 index 00000000000..a86ac076c2c --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T4.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T4 +description: > + Values of the function constructor arguments are an undefined + variable and "return 1.1;" +---*/ + +var body = "return 1.1;"; + +try { + var f = new Function(p, body); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), 1.1, 'f() must return 1.1'); + +var p; diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T5.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T5.js new file mode 100644 index 00000000000..e3d4994f21d --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T5.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T5 +description: > + Values of the function constructor arguments are "void 0" and + "return \"A\";" +---*/ + +var body = "return \"A\";"; + +try { + var f = new Function(void 0, body); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), '\u0041', 'f() must return "u0041"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T6.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T6.js new file mode 100644 index 00000000000..48b0336796f --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T6.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T6 +description: > + Values of the function constructor arguments are "null" and + "return true;" +---*/ + +var body = "return true;"; + +try { + var f = new Function(null, body); + throw new Test262Error('#1: If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception'); +} catch (e) { + assert( + e instanceof SyntaxError, + 'The result of evaluating (e instanceof SyntaxError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T7.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T7.js new file mode 100644 index 00000000000..59be1d7b977 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T7.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T7 +description: > + Values of the function constructor arguments are "Object("a")" and + "return a;" +---*/ + +var body = "return a;"; + +var p = Object("a"); + +try { + var f = new Function(p, body); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(1), 1, 'f(1) must return 1'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T8.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T8.js new file mode 100644 index 00000000000..47940b7500d --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T8.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T8 +description: > + Values of the function constructor arguments are "undefined" and + "return this;" +---*/ + +var body = "return this;"; + +try { + var f = new Function(undefined, body); +} catch (e) { + throw new Test262Error('#1: test failed with error ' + e); +} + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f(), this, 'f() must return this'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T9.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T9.js new file mode 100644 index 00000000000..d358f33f93d --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T9.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When the Function constructor is called with arguments p, body the following steps are taken: + i) Let Result(i) be the first argument + ii) Let P be ToString(Result(i)) + iii) Call ToString(body) + iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception + v) If body is not parsable as FunctionBody then throw a SyntaxError exception + vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + Pass in a scope chain consisting of the global object as the Scope parameter + vii) Return Result(vi) +es5id: 15.3.2.1_A3_T9 +description: > + Values of the function constructor arguments are "1,1" and "return + this;" +---*/ + +var body = "return this;"; +var p = "1,1"; + +try { + var f = new Function(p, body); + throw new Test262Error('#1: If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception'); +} catch (e) { + assert( + e instanceof SyntaxError, + 'The result of evaluating (e instanceof SyntaxError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Function/S15.3.2_A1.js b/test/sendable/builtins/Function/S15.3.2_A1.js new file mode 100644 index 00000000000..6513f67e172 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.2_A1.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + When Function is called as part of a new expression, it is a constructor: + it initialises the newly created object +es5id: 15.3.2_A1 +description: > + Checking the constuctor of the object that is created as a new + Function +---*/ + +var f = new Function; + +assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.notSameValue(f, undefined, 'The value of f is expected to not equal ``undefined``'); diff --git a/test/sendable/builtins/Function/S15.3.3_A1.js b/test/sendable/builtins/Function/S15.3.3_A1.js new file mode 100644 index 00000000000..2075957060a --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.3_A1.js @@ -0,0 +1,21 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: The Function constructor has the property "prototype" +es5id: 15.3.3_A1 +description: Checking existence of the property "prototype" +---*/ +assert(Function.hasOwnProperty("prototype"), 'Function.hasOwnProperty("prototype") must return true'); diff --git a/test/sendable/builtins/Function/S15.3.3_A2_T1.js b/test/sendable/builtins/Function/S15.3.3_A2_T1.js new file mode 100644 index 00000000000..4ce15eb77ed --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.3_A2_T1.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The value of the internal [[Prototype]] property of the Function constructor + is the Function prototype object +es5id: 15.3.3_A2_T1 +description: Checking prototype of Function +---*/ +assert( + Function.prototype.isPrototypeOf(Function), + 'Function.prototype.isPrototypeOf(Function) must return true' +); diff --git a/test/sendable/builtins/Function/S15.3.3_A2_T2.js b/test/sendable/builtins/Function/S15.3.3_A2_T2.js new file mode 100644 index 00000000000..f7e2fecda49 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.3_A2_T2.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The value of the internal [[Prototype]] property of the Function constructor + is the Function prototype object +es5id: 15.3.3_A2_T2 +description: Add new property to Function.prototype and check it +---*/ + +Function.prototype.indicator = 1; + +assert.sameValue(Function.indicator, 1, 'The value of Function.indicator is expected to be 1'); diff --git a/test/sendable/builtins/Function/S15.3.3_A3.js b/test/sendable/builtins/Function/S15.3.3_A3.js new file mode 100644 index 00000000000..a07ea56e8bf --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.3_A3.js @@ -0,0 +1,22 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Function constructor has length property whose value is 1 +es5id: 15.3.3_A3 +description: Checking Function.length property +---*/ +assert(Function.hasOwnProperty("length"), 'Function.hasOwnProperty("length") must return true'); +assert.sameValue(Function.length, 1, 'The value of Function.length is expected to be 1'); diff --git a/test/sendable/builtins/Function/S15.3.5_A1_T1.js b/test/sendable/builtins/Function/S15.3.5_A1_T1.js new file mode 100644 index 00000000000..f91f2aaaf18 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.5_A1_T1.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: The value of the [[Class]] property is "Function" +es5id: 15.3.5_A1_T1 +description: For testing use variable f = new Function +---*/ + +var f = new Function; + +assert.sameValue( + Object.prototype.toString.call(f), + "[object Function]", + 'Object.prototype.toString.call(new Function) must return "[object Function]"' +); diff --git a/test/sendable/builtins/Function/S15.3.5_A1_T2.js b/test/sendable/builtins/Function/S15.3.5_A1_T2.js new file mode 100644 index 00000000000..7eddc7c5973 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.5_A1_T2.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: The value of the [[Class]] property is "Function" +es5id: 15.3.5_A1_T2 +description: For testing use variable f = Function() +---*/ + +var f = Function(); + +assert.sameValue( + Object.prototype.toString.call(f), + "[object Function]", + 'Object.prototype.toString.call(Function()) must return "[object Function]"' +); diff --git a/test/sendable/builtins/Function/S15.3.5_A2_T1.js b/test/sendable/builtins/Function/S15.3.5_A2_T1.js new file mode 100644 index 00000000000..b93ea5b7b96 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.5_A2_T1.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Every function instance has a [[Call]] property +es5id: 15.3.5_A2_T1 +description: For testing call Function("var x =1; this.y=2;return \"OK\";")() +---*/ +assert.sameValue( + Function("var x =1; this.y=2;return \"OK\";")(), + "OK", + 'Function("var x =1; this.y=2;return "OK";")() must return "OK"' +); + +assert.sameValue(typeof x, "undefined", 'The value of `typeof x` is expected to be "undefined"'); +assert.sameValue(y, 2, 'The value of y is expected to be 2'); diff --git a/test/sendable/builtins/Function/S15.3.5_A2_T2.js b/test/sendable/builtins/Function/S15.3.5_A2_T2.js new file mode 100644 index 00000000000..a4ee27beb26 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.5_A2_T2.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Every function instance has a [[Call]] property +es5id: 15.3.5_A2_T2 +description: > + For testing call (new Function("arg1,arg2","var x =arg1; + this.y=arg2;return arg1+arg2;"))("1",2) +---*/ +assert.sameValue( + (new Function("arg1,arg2", "var x =arg1; this.y=arg2;return arg1+arg2;"))("1", 2), + "12", + 'new Function("arg1,arg2", "var x =arg1; this.y=arg2;return arg1+arg2;")(1, 2) must return "12"' +); + +assert.sameValue(typeof x, "undefined", 'The value of `typeof x` is expected to be "undefined"'); +assert.sameValue(y, 2, 'The value of y is expected to be 2'); diff --git a/test/sendable/builtins/Function/S15.3.5_A3_T1.js b/test/sendable/builtins/Function/S15.3.5_A3_T1.js new file mode 100644 index 00000000000..b4a7adc6db6 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.5_A3_T1.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: every function instance has a [[Construct]] property +es5id: 15.3.5_A3_T1 +description: As constructor use Function("var x =1; this.y=2;return \"OK\";") +---*/ + +var FACTORY = Function("var x =1; this.y=2;return \"OK\";"); +var obj = new FACTORY; + +assert.sameValue(typeof obj, "object", 'The value of `typeof obj` is expected to be "object"'); +assert.sameValue(obj.constructor, FACTORY, 'The value of obj.constructor is expected to equal the value of FACTORY'); +assert.sameValue(obj.y, 2, 'The value of obj.y is expected to be 2'); diff --git a/test/sendable/builtins/Function/S15.3.5_A3_T2.js b/test/sendable/builtins/Function/S15.3.5_A3_T2.js new file mode 100644 index 00000000000..e62997cf593 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3.5_A3_T2.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: every function instance has a [[Construct]] property +es5id: 15.3.5_A3_T2 +description: > + As constructor use new Function("arg1,arg2","var x =1; + this.y=arg1+arg2;return \"OK\";") +---*/ + +var FACTORY = new Function("arg1,arg2", "var x =1; this.y=arg1+arg2;return \"OK\";"); +var obj = new FACTORY("1", 2); + +assert.sameValue(typeof obj, "object", 'The value of `typeof obj` is expected to be "object"'); +assert.sameValue(obj.constructor, FACTORY, 'The value of obj.constructor is expected to equal the value of FACTORY'); +assert.sameValue(obj.y, "12", 'The value of obj.y is expected to be "12"'); diff --git a/test/sendable/builtins/Function/S15.3_A1.js b/test/sendable/builtins/Function/S15.3_A1.js new file mode 100644 index 00000000000..253c26818b3 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3_A1.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Function is the property of global +es5id: 15.3_A1 +description: Compare Function with this.Function +---*/ + +var obj = Function; + +var thisobj = this.Function; + +assert.sameValue(obj, thisobj, 'The value of obj is expected to equal the value of thisobj'); diff --git a/test/sendable/builtins/Function/S15.3_A2_T1.js b/test/sendable/builtins/Function/S15.3_A2_T1.js new file mode 100644 index 00000000000..485d1dca6a5 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3_A2_T1.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + Since applying the "call" method to Function constructor themself leads + to creating a new function instance, the second argument must be a valid + function body +es5id: 15.3_A2_T1 +description: Checking if executing "Function.call(this, "var x / = 1;")" fails +---*/ + +try { + Function.call(this, "var x / = 1;"); +} catch (e) { + assert( + e instanceof SyntaxError, + 'The result of evaluating (e instanceof SyntaxError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Function/S15.3_A2_T2.js b/test/sendable/builtins/Function/S15.3_A2_T2.js new file mode 100644 index 00000000000..5fca2f5a276 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3_A2_T2.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + Since applying the "call" method to Function constructor themself leads + to creating a new function instance, the second argument must be a valid + function body +es5id: 15.3_A2_T2 +description: Checking if executing "Function.call(this, "var #x = 1;")" fails +---*/ + +try { + Function.call(this, "var #x = 1;"); +} catch (e) { + assert( + e instanceof SyntaxError, + 'The result of evaluating (e instanceof SyntaxError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Function/S15.3_A3_T1.js b/test/sendable/builtins/Function/S15.3_A3_T1.js new file mode 100644 index 00000000000..f4ca7c1cf0a --- /dev/null +++ b/test/sendable/builtins/Function/S15.3_A3_T1.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + Since when call is used for Function constructor themself new function instance creates + and then first argument(thisArg) should be ignored +es5id: 15.3_A3_T1 +description: First argument is object +---*/ + +var f = Function.call(mars, "return name;"); +var mars = { + name: "mars", + color: "red", + number: 4 +}; + +var f = Function.call(mars, "this.godname=\"ares\"; return this.color;"); + +var about_mars = f(); + +assert.sameValue(about_mars, undefined); + +if (this.godname !== "ares" && mars.godname === undefined) { + throw new Test262Error('#3: When applied to the Function object itself, thisArg should be ignored'); +} diff --git a/test/sendable/builtins/Function/S15.3_A3_T2.js b/test/sendable/builtins/Function/S15.3_A3_T2.js new file mode 100644 index 00000000000..3ade114b93b --- /dev/null +++ b/test/sendable/builtins/Function/S15.3_A3_T2.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + Since when call is used for Function constructor themself new function instance creates + and then first argument(thisArg) should be ignored +es5id: 15.3_A3_T2 +description: First argument is string and null +---*/ + +this.color = "red"; +var planet = "mars"; + +var f = Function.call("blablastring", "return this.color;"); + +assert.sameValue(f(), "red", 'f() must return "red"'); + +var g = Function.call(null, "return this.planet;"); + +assert.sameValue(g(), "mars", 'g() must return "mars"'); diff --git a/test/sendable/builtins/Function/S15.3_A3_T3.js b/test/sendable/builtins/Function/S15.3_A3_T3.js new file mode 100644 index 00000000000..e1973116335 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3_A3_T3.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + Since when call is used for Function constructor themself new function instance creates + and then first argument(thisArg) should be ignored +es5id: 15.3_A3_T3 +description: First argument is this, and this don`t have needed variable +---*/ + +var f = Function.call(this, "return planet;"); +var g = Function.call(this, "return color;"); + +assert.sameValue(f(), undefined, 'f() returns undefined'); + +var planet = "mars"; + +assert.sameValue(f(), "mars", 'f() must return "mars"'); + +try { + g(); + throw new Test262Error('#3: '); +} catch (e) { + assert( + e instanceof ReferenceError, + 'The result of evaluating (e instanceof ReferenceError) is expected to be true' + ); +} + +this.color = "red"; + +assert.sameValue(g(), "red", 'g() must return "red"'); diff --git a/test/sendable/builtins/Function/S15.3_A3_T4.js b/test/sendable/builtins/Function/S15.3_A3_T4.js new file mode 100644 index 00000000000..572bb78f713 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3_A3_T4.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + Since when call is used for Function constructor themself new function instance creates + and then first argument(thisArg) should be ignored +es5id: 15.3_A3_T4 +description: First argument is this, and this have needed variable +---*/ + +var f = Function.call(this, "return planet;"); + +assert.sameValue(f(), undefined, 'f() returns undefined'); + +var planet = "mars"; + +assert.sameValue(f(), "mars", 'f() must return "mars"'); diff --git a/test/sendable/builtins/Function/S15.3_A3_T5.js b/test/sendable/builtins/Function/S15.3_A3_T5.js new file mode 100644 index 00000000000..b4e10b98dfe --- /dev/null +++ b/test/sendable/builtins/Function/S15.3_A3_T5.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + Since when call is used for Function constructor themself new function instance creates + and then first argument(thisArg) should be ignored +es5id: 15.3_A3_T5 +description: > + First argument is this, and this don`t have needed variable. + Function return this.var_name +---*/ + +var f = Function.call(this, "return this.planet;"); +var g = Function.call(this, "return this.color;"); + +assert.sameValue(f(), undefined, 'f() returns undefined'); + +var planet = "mars"; + +assert.sameValue(f(), "mars", 'f() must return "mars"'); +assert.sameValue(g(), undefined, 'g() returns undefined'); + +this.color = "red"; + +assert.sameValue(g(), "red", 'g() must return "red"'); diff --git a/test/sendable/builtins/Function/S15.3_A3_T6.js b/test/sendable/builtins/Function/S15.3_A3_T6.js new file mode 100644 index 00000000000..0b6863138b2 --- /dev/null +++ b/test/sendable/builtins/Function/S15.3_A3_T6.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + Since when call is used for Function constructor themself new function instance creates + and then first argument(thisArg) should be ignored +es5id: 15.3_A3_T6 +description: > + First argument is this, and this have needed variable. Function + return this.var_name +---*/ + +var f = Function.call(this, "return this.planet;"); + +assert.sameValue(f(), undefined, 'f() returns undefined'); + +var planet = "mars"; + +assert.sameValue(f(), "mars", 'f() must return "mars"'); diff --git a/test/sendable/builtins/Function/StrictFunction_reservedwords_with.js b/test/sendable/builtins/Function/StrictFunction_reservedwords_with.js new file mode 100644 index 00000000000..b649b9d6b0b --- /dev/null +++ b/test/sendable/builtins/Function/StrictFunction_reservedwords_with.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-createdynamicfunction +description: Strictfunction shouldn't have the reserved word "with" +info: | + CreateDynamicFunction ( constructor, newTarget, kind, args ) + + ... + 20 Perform the following substeps in an implementation-dependent order, possibly interleaving parsing and error detection: + ... + c. Let strict be ContainsUseStrict of body. + d. If any static semantics errors are detected for parameters or body, throw a SyntaxError exception. + If strict is true, the Early Error rules for UniqueFormalParameters:FormalParameters are applied. + ... + ... +---*/ + +assert.throws(SyntaxError, function() { + new Function("'use strict'; with ({}) {}"); +}, '`new Function("\'use strict\'; with ({}) {}")` throws a SyntaxError exception'); diff --git a/test/sendable/builtins/Function/StrictFunction_restricted-properties.js b/test/sendable/builtins/Function/StrictFunction_restricted-properties.js new file mode 100644 index 00000000000..40101c85382 --- /dev/null +++ b/test/sendable/builtins/Function/StrictFunction_restricted-properties.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +description: > + ECMAScript Function objects defined using syntactic constructors + in strict mode code do not have own properties "caller" or + "arguments" other than those that are created by applying the + AddRestrictedFunctionProperties abstract operation to the function. +flags: [onlyStrict] +es6id: 16.1 +---*/ + +function func() {} + +assert.throws(TypeError, function() { + return func.caller; +}, 'return func.caller throws a TypeError exception'); + +assert.throws(TypeError, function() { + func.caller = {}; +}, 'func.caller = {} throws a TypeError exception'); + +assert.throws(TypeError, function() { + return func.arguments; +}, 'return func.arguments throws a TypeError exception'); + +assert.throws(TypeError, function() { + func.arguments = {}; +}, 'func.arguments = {} throws a TypeError exception'); + +var newfunc = new Function('"use strict"'); + +assert.sameValue(newfunc.hasOwnProperty('caller'), false, 'newfunc.hasOwnProperty(\'caller\') must return false'); +assert.sameValue(newfunc.hasOwnProperty('arguments'), false, 'newfunc.hasOwnProperty(\'arguments\') must return false'); + +assert.throws(TypeError, function() { + return newfunc.caller; +}, 'return newfunc.caller throws a TypeError exception'); + +assert.throws(TypeError, function() { + newfunc.caller = {}; +}, 'newfunc.caller = {} throws a TypeError exception'); + +assert.throws(TypeError, function() { + return newfunc.arguments; +}, 'return newfunc.arguments throws a TypeError exception'); + +assert.throws(TypeError, function() { + newfunc.arguments = {}; +}, 'newfunc.arguments = {} throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/call-bind-this-realm-undef.js b/test/sendable/builtins/Function/call-bind-this-realm-undef.js new file mode 100644 index 00000000000..c437a87b1b6 --- /dev/null +++ b/test/sendable/builtins/Function/call-bind-this-realm-undef.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-function-objects-call-thisargument-argumentslist +description: The "this" value is set to the global This value +info: | + [...] + 6. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument). + [...] + + 9.2.1.2OrdinaryCallBindThis ( F, calleeContext, thisArgument )# + + [...] + 5. If thisMode is strict, let thisValue be thisArgument. + 6. Else, + a. If thisArgument is null or undefined, then + i. Let globalEnv be calleeRealm.[[GlobalEnv]]. + ii. Let globalEnvRec be globalEnv's EnvironmentRecord. + iii. Let thisValue be globalEnvRec.[[GlobalThisValue]]. + [...] +features: [cross-realm] +---*/ + +var other = $262.createRealm().global; +var func = new other.Function('return this;'); +var subject; + +assert.sameValue(func(), other, 'implicit undefined'); +assert.sameValue(func.call(undefined), other, 'explicit undefined'); +assert.sameValue(func.call(null), other, 'null'); diff --git a/test/sendable/builtins/Function/call-bind-this-realm-value.js b/test/sendable/builtins/Function/call-bind-this-realm-value.js new file mode 100644 index 00000000000..cb0d8d88029 --- /dev/null +++ b/test/sendable/builtins/Function/call-bind-this-realm-value.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-function-objects-call-thisargument-argumentslist +description: The "this" value is wrapped in an object using the callee realm +info: | + [...] + 6. Perform OrdinaryCallBindThis(F, calleeContext, thisArgument). + [...] + + 9.2.1.2OrdinaryCallBindThis ( F, calleeContext, thisArgument )# + + [...] + 5. If thisMode is strict, let thisValue be thisArgument. + 6. Else, + a. If thisArgument is null or undefined, then + [...] + b. Else, + i. Let thisValue be ! ToObject(thisArgument). + ii. NOTE ToObject produces wrapper objects using calleeRealm. + [...] +features: [cross-realm] +---*/ + +var other = $262.createRealm().global; +var func = new other.Function('return this;'); +var subject; + +subject = func.call(true); +assert.sameValue(subject.constructor, other.Boolean, 'boolean constructor'); +assert(subject instanceof other.Boolean, 'boolean instanceof'); + +subject = func.call(1); +assert.sameValue(subject.constructor, other.Number, 'number constructor'); +assert(subject instanceof other.Number, 'number instanceof'); + +subject = func.call(''); +assert.sameValue(subject.constructor, other.String, 'string constructor'); +assert(subject instanceof other.String, 'string instanceof'); + +subject = func.call({}); +assert.sameValue(subject.constructor, Object, 'object constructor'); +assert(subject instanceof Object, 'object instanceof'); diff --git a/test/sendable/builtins/Function/instance-name.js b/test/sendable/builtins/Function/instance-name.js new file mode 100644 index 00000000000..6e21a6b7938 --- /dev/null +++ b/test/sendable/builtins/Function/instance-name.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.1.1 +description: Assignment of function `name` attribute +info: | + [...] + 3. Return CreateDynamicFunction(C, NewTarget, "normal", args). + + ES6 19.2.1.1.1 + RuntimeSemantics: CreateDynamicFunction(constructor, newTarget, kind, args) + + [...] + 29. Perform SetFunctionName(F, "anonymous"). +includes: [propertyHelper.js] +---*/ + +assert.sameValue(Function().name, 'anonymous'); +verifyNotEnumerable(Function(), 'name'); +verifyNotWritable(Function(), 'name'); +verifyConfigurable(Function(), 'name'); diff --git a/test/sendable/builtins/Function/internals/Call/class-ctor-realm.js b/test/sendable/builtins/Function/internals/Call/class-ctor-realm.js new file mode 100644 index 00000000000..28654d5360e --- /dev/null +++ b/test/sendable/builtins/Function/internals/Call/class-ctor-realm.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-function-objects-call-thisargument-argumentslist +description: > + Error when invoking a default class constructor, honoring the Realm + that the class was defined in. +features: [cross-realm, class] +---*/ + +const realm = $262.createRealm(); +const C = realm.global.eval('(class {})'); +const TE = realm.global.TypeError; + +assert.throws(TE, function() { + C(); +}); diff --git a/test/sendable/builtins/Function/internals/Call/class-ctor.js b/test/sendable/builtins/Function/internals/Call/class-ctor.js new file mode 100644 index 00000000000..c0ee0b4e583 --- /dev/null +++ b/test/sendable/builtins/Function/internals/Call/class-ctor.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-function-objects-call-thisargument-argumentslist +description: Error when invoking a class constructor +info: | + [...] + 2. If F's [[FunctionKind]] internal slot is "classConstructor", throw a + TypeError exception. +features: [class] +---*/ + +class C {} + +assert.throws(TypeError, function() { + C(); +}); diff --git a/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js b/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js new file mode 100644 index 00000000000..29a337f7784 --- /dev/null +++ b/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: > + Error retrieving function realm from revoked Proxy exotic object (honoring + the Realm of the current execution context) +info: | + [...] + 5. If kind is "base", then + a. Let thisArgument be ? OrdinaryCreateFromConstructor(newTarget, + "%ObjectPrototype%"). + [...] + + 9.1.13 OrdinaryCreateFromConstructor + + [...] + 2. Let proto be ? GetPrototypeFromConstructor(constructor, + intrinsicDefaultProto). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + + 7.3.22 GetFunctionRealm + + [...] + 2. If obj has a [[Realm]] internal slot, then + [...] + 3. If obj is a Bound Function exotic object, then + [...] + 4. If obj is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of obj is null, + throw a TypeError exception. +features: [cross-realm, Proxy] +---*/ + +var other = $262.createRealm().global; +// Defer proxy revocation until after the `constructor` property has been +// accessed +var handlers = { + get: function() { + handle.revoke(); + } +}; +var handle = other.Proxy.revocable(function() {}, handlers); +var f = handle.proxy; + +assert.sameValue(typeof f, 'function'); + +assert.throws(TypeError, function() { + new f(); +}); diff --git a/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy.js b/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy.js new file mode 100644 index 00000000000..d24aafdc78d --- /dev/null +++ b/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: Error retrieving function realm from revoked Proxy exotic object +info: | + [...] + 5. If kind is "base", then + a. Let thisArgument be ? OrdinaryCreateFromConstructor(newTarget, + "%ObjectPrototype%"). + [...] + + 9.1.13 OrdinaryCreateFromConstructor + + [...] + 2. Let proto be ? GetPrototypeFromConstructor(constructor, + intrinsicDefaultProto). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + + 7.3.22 GetFunctionRealm + + [...] + 2. If obj has a [[Realm]] internal slot, then + [...] + 3. If obj is a Bound Function exotic object, then + [...] + 4. If obj is a Proxy exotic object, then + a. If the value of the [[ProxyHandler]] internal slot of obj is null, + throw a TypeError exception. +features: [Proxy] +---*/ + +// Defer proxy revocation until after the `constructor` property has been +// accessed +var handlers = { + get: function() { + handle.revoke(); + } +}; +var handle = Proxy.revocable(function() {}, handlers); +var f = handle.proxy; + +assert.sameValue(typeof f, 'function'); + +assert.throws(TypeError, function() { + new f(); +}); diff --git a/test/sendable/builtins/Function/internals/Construct/derived-return-val-realm.js b/test/sendable/builtins/Function/internals/Construct/derived-return-val-realm.js new file mode 100644 index 00000000000..dbe540a413a --- /dev/null +++ b/test/sendable/builtins/Function/internals/Construct/derived-return-val-realm.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: > + Error when derived constructor returns a non-undefined value (honoring + the Realm of the current execution context) +info: | + [...] + 13. If result.[[Type]] is return, then + a. If Type(result.[[Value]]) is Object, return + NormalCompletion(result.[[Value]]). + b. If kind is "base", return NormalCompletion(thisArgument). + c. If result.[[Value]] is not undefined, throw a TypeError exception. + [...] +features: [cross-realm, class] +---*/ + +var C = $262.createRealm().global.eval( + '0, class extends Object {' + + ' constructor() {' + + ' return null;' + + ' }' + + '}' +); + +assert.throws(TypeError, function() { + new C(); +}); diff --git a/test/sendable/builtins/Function/internals/Construct/derived-return-val.js b/test/sendable/builtins/Function/internals/Construct/derived-return-val.js new file mode 100644 index 00000000000..c537b0a4225 --- /dev/null +++ b/test/sendable/builtins/Function/internals/Construct/derived-return-val.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: Error when derived constructor returns a non-undefined value +info: | + [...] + 13. If result.[[Type]] is return, then + a. If Type(result.[[Value]]) is Object, return + NormalCompletion(result.[[Value]]). + b. If kind is "base", return NormalCompletion(thisArgument). + c. If result.[[Value]] is not undefined, throw a TypeError exception. + [...] +features: [class] +---*/ + +class C extends Object { + constructor() { + return null; + } +} + +assert.throws(TypeError, function() { + new C(); +}); diff --git a/test/sendable/builtins/Function/internals/Construct/derived-this-uninitialized-realm.js b/test/sendable/builtins/Function/internals/Construct/derived-this-uninitialized-realm.js new file mode 100644 index 00000000000..cab0775a2e2 --- /dev/null +++ b/test/sendable/builtins/Function/internals/Construct/derived-this-uninitialized-realm.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: > + Error when derived constructor does not initialize the `this` binding + (honoring the Realm of the current execution context) +info: | + [...] + 15. Return ? envRec.GetThisBinding(). + + 8.1.1.3.4 GetThisBinding () + + [...] + 3. If envRec.[[ThisBindingStatus]] is "uninitialized", throw a ReferenceError + exception. +features: [cross-realm, class] +---*/ + +var C = $262.createRealm().global.eval( + '(class C extends Object {' + + ' constructor() {}' + + '});' +); + +assert.throws(ReferenceError, function() { + new C(); +}); diff --git a/test/sendable/builtins/Function/internals/Construct/derived-this-uninitialized.js b/test/sendable/builtins/Function/internals/Construct/derived-this-uninitialized.js new file mode 100644 index 00000000000..11b0d077f99 --- /dev/null +++ b/test/sendable/builtins/Function/internals/Construct/derived-this-uninitialized.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-function-objects-construct-argumentslist-newtarget +description: > + Error when derived constructor does not initialize the `this` binding +info: | + [...] + 15. Return ? envRec.GetThisBinding(). + + 8.1.1.3.4 GetThisBinding () + + [...] + 3. If envRec.[[ThisBindingStatus]] is "uninitialized", throw a ReferenceError + exception. +features: [class] +---*/ + +class C extends Object { + constructor() {} +} + +assert.throws(ReferenceError, function() { + new C(); +}); diff --git a/test/sendable/builtins/Function/is-a-constructor.js b/test/sendable/builtins/Function/is-a-constructor.js new file mode 100644 index 00000000000..aa6495748bb --- /dev/null +++ b/test/sendable/builtins/Function/is-a-constructor.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + The Function constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ + +assert.sameValue(isConstructor(Function), true, 'isConstructor(Function) must return true'); +new Function(); + diff --git a/test/sendable/builtins/Function/length/15.3.3.2-1.js b/test/sendable/builtins/Function/length/15.3.3.2-1.js new file mode 100644 index 00000000000..ff7801fa56b --- /dev/null +++ b/test/sendable/builtins/Function/length/15.3.3.2-1.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.3.2-1 +description: Function.length - data property with value 1 +---*/ + +var desc = Object.getOwnPropertyDescriptor(Function, "length"); + +assert.sameValue(desc.value, 1, 'desc.value'); +assert.sameValue(desc.writable, false, 'desc.writable'); +assert.sameValue(desc.enumerable, false, 'desc.enumerable'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T1.js b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T1.js new file mode 100644 index 00000000000..01813613fef --- /dev/null +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T1.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The value of the length property is usually an integer that indicates the + 'typical' number of arguments expected by the function +es5id: 15.3.5.1_A1_T1 +description: Checking length property of Function("arg1,arg2,arg3", null) +---*/ + +var f = new Function("arg1,arg2,arg3", null); + +assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); +assert.sameValue(f.length, 3, 'The value of f.length is expected to be 3'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T2.js b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T2.js new file mode 100644 index 00000000000..921f1c2c114 --- /dev/null +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T2.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The value of the length property is usually an integer that indicates the + 'typical' number of arguments expected by the function +es5id: 15.3.5.1_A1_T2 +description: > + Checking length property of Function("arg1,arg2,arg3","arg4,arg5", + null) +---*/ + +var f = Function("arg1,arg2,arg3", "arg4,arg5", null); + +assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); +assert.sameValue(f.length, 5, 'The value of f.length is expected to be 5'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T3.js b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T3.js new file mode 100644 index 00000000000..4a1aeac6178 --- /dev/null +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T3.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The value of the length property is usually an integer that indicates the + 'typical' number of arguments expected by the function +es5id: 15.3.5.1_A1_T3 +description: > + Checking length property of + Function("arg1,arg2,arg3","arg1,arg2","arg3", null) +---*/ + +var f = new Function("arg1,arg2,arg3", "arg1,arg2", "arg3", null); + +assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); +assert.sameValue(f.length, 6, 'The value of f.length is expected to be 6'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T1.js b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T1.js new file mode 100644 index 00000000000..9a268cb0049 --- /dev/null +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T1.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: the length property does not have the attributes { DontDelete } +es5id: 15.3.5.1_A2_T1 +description: > + Checking if deleting the length property of + Function("arg1,arg2,arg3", null) succeeds +---*/ + +var f = new Function("arg1,arg2,arg3", null); + +assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); +assert(delete f.length, 'The value of delete f.length is expected to be true'); +assert(!f.hasOwnProperty('length'), 'The value of !f.hasOwnProperty(\'length\') is expected to be true'); +assert.notSameValue(f.length, 3, 'The value of f.length is not 3'); + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T2.js b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T2.js new file mode 100644 index 00000000000..48c8ec75b51 --- /dev/null +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T2.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: the length property does not have the attributes { DontDelete } +es5id: 15.3.5.1_A2_T2 +description: > + Checking if deleting the length property of + Function("arg1,arg2,arg3","arg4,arg5", null) succeeds +---*/ + +var f = Function("arg1,arg2,arg3", "arg4,arg5", null); + +assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); + +delete f.length; + +assert(!f.hasOwnProperty('length'), 'The value of !f.hasOwnProperty(\'length\') is expected to be true'); +assert.notSameValue(f.length, 5, 'The value of f.length is not 5'); + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T3.js b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T3.js new file mode 100644 index 00000000000..fe44fa81543 --- /dev/null +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T3.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: the length property does not have the attributes { DontDelete } +es5id: 15.3.5.1_A2_T3 +description: > + Checking if deleting the length property of + Function("arg1,arg2,arg3","arg1,arg2","arg3", null) succeeds +---*/ + +var f = new Function("arg1,arg2,arg3", "arg1,arg2", "arg3", null); + +assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); + +delete f.length; + +assert(!f.hasOwnProperty('length'), 'The value of !f.hasOwnProperty(\'length\') is expected to be true'); +assert.notSameValue(f.length, 6, 'The value of f.length is not 6'); + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T1.js b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T1.js new file mode 100644 index 00000000000..e33b1c4680d --- /dev/null +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T1.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: the length property has the attributes { ReadOnly } +es5id: 15.3.5.1_A3_T1 +description: > + Checking if varying the length property of + Function("arg1,arg2,arg3","arg4,arg5", null) fails +includes: [propertyHelper.js] +---*/ + +var f = new Function("arg1,arg2,arg3", "arg4,arg5", null); + +assert(f.hasOwnProperty('length')); + +var flength = f.length; + +verifyNotWritable(f, "length", null, function() {}); + +assert.sameValue(f.length, flength); + +try { + f.length(); + throw new Test262Error('#3: the function.length property has the attributes ReadOnly'); +} catch (e) { + if (e instanceof Test262Error) { + throw e; + } +} + +if (f.length !== 5) { + throw new Test262Error('#4: the length property has the attributes { ReadOnly }'); +} + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T2.js b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T2.js new file mode 100644 index 00000000000..f0312736588 --- /dev/null +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T2.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: the length property has the attributes { ReadOnly } +es5id: 15.3.5.1_A3_T2 +description: > + Checking if varying the length property of + Function("arg1,arg2,arg3", null) fails +includes: [propertyHelper.js] +---*/ + +var f = Function("arg1,arg2,arg3", null); + +assert(f.hasOwnProperty('length')); + +var flength = f.length; + +verifyNotWritable(f, "length", null, function() {}); + +assert.sameValue(f.length, flength); + +try { + f.length(); + throw new Test262Error('#3: the function.length property has the attributes ReadOnly'); +} catch (e) { + if (e instanceof Test262Error) { + throw e; + } +} + +if (f.length !== 3) { + throw new Test262Error('#4: the length property has the attributes { ReadOnly }'); +} + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T3.js b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T3.js new file mode 100644 index 00000000000..ebcb9f895f2 --- /dev/null +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T3.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: the length property has the attributes { ReadOnly } +es5id: 15.3.5.1_A3_T3 +description: > + Checking if varying the length property of + Function("arg1,arg2,arg3","arg1,arg2","arg3", null) fails +includes: [propertyHelper.js] +---*/ + +var f = new Function("arg1,arg2,arg3", "arg1,arg2", "arg3", null); + +assert(f.hasOwnProperty('length')); + +var flength = f.length; + +verifyNotWritable(f, "length", null, function() {}); + +assert.sameValue(f.length, flength); + +try { + f.length(); + throw new Test262Error('#3: the function.length property has the attributes ReadOnly'); +} catch (e) { + if (e instanceof Test262Error) { + throw e; + } +} + +if (f.length !== 6) { + throw new Test262Error('#4: the length property has the attributes { ReadOnly }'); +} + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T1.js b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T1.js new file mode 100644 index 00000000000..7246f359698 --- /dev/null +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T1.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: the length property has the attributes { DontEnum } +es5id: 15.3.5.1_A4_T1 +description: > + Checking if enumerating the length property of + Function("arg1,arg2,arg3", null) fails +---*/ + +var f = new Function("arg1,arg2,arg3", null); + +assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); + +for (var key in f) { + if (key == "length") { + var lengthenumed = true; + } +} +assert(!lengthenumed, 'The value of !lengthenumed is expected to be true'); + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T2.js b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T2.js new file mode 100644 index 00000000000..c38142697e2 --- /dev/null +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T2.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: the length property has the attributes { DontEnum } +es5id: 15.3.5.1_A4_T2 +description: > + Checking if enumerating the length property of + Function("arg1,arg2,arg3","arg4,arg5", null) fails +---*/ + +var f = Function("arg1,arg2,arg3", "arg5,arg4", null); + +assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); + +for (var key in f) { + if (key == "length") { + var lengthenumed = true; + } +} + +assert(!lengthenumed, 'The value of !lengthenumed is expected to be true'); + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T3.js b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T3.js new file mode 100644 index 00000000000..422fff19761 --- /dev/null +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T3.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: the length property has the attributes { DontEnum } +es5id: 15.3.5.1_A4_T3 +description: > + Checking if enumerating the length property of + Function("arg1,arg2,arg3","arg1,arg2","arg3", null) fails +---*/ + +var f = new Function("arg1,arg2,arg3", "arg1,arg2", "arg3", null); + +assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); + +for (var key in f) { + if (key == "length") { + var lengthenumed = true; + } +} + +assert(!lengthenumed, 'The value of !lengthenumed is expected to be true'); + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/private-identifiers-not-empty.js b/test/sendable/builtins/Function/private-identifiers-not-empty.js new file mode 100644 index 00000000000..e30bc5a09b7 --- /dev/null +++ b/test/sendable/builtins/Function/private-identifiers-not-empty.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-createdynamicfunction +description: CreateDynamicFunction throws SyntaxError if there is some invalid private identifier on its body +info: | + CreateDynamicFunction(constructor, newTarget, kind, args) + ... + 29. Let privateIdentifiers be an empty List. + 30. If AllPrivateIdentifiersValid of body with the argument privateIdentifiers is false, throw a SyntaxError exception. + 31. If AllPrivateIdentifiersValid of parameters with the argument privateIdentifiers is false, throw a SyntaxError exception. + ... +features: [class-fields-private] +---*/ + +assert.throws(SyntaxError, function() { + let o = {}; + new Function("o.#f"); +}, 'It should be a SyntaxError if AllPrivateIdentifiersValid returns false to dynamic function body'); + diff --git a/test/sendable/builtins/Function/prop-desc.js b/test/sendable/builtins/Function/prop-desc.js new file mode 100644 index 00000000000..84b558744f0 --- /dev/null +++ b/test/sendable/builtins/Function/prop-desc.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-constructor-properties-of-the-global-object-function +description: Property descriptor for Function +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] +---*/ + +verifyProperty(this, "Function", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Function/property-order.js b/test/sendable/builtins/Function/property-order.js new file mode 100644 index 00000000000..1cda42da1b1 --- /dev/null +++ b/test/sendable/builtins/Function/property-order.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-createbuiltinfunction +description: Function constructor property order +info: | + Set order: "length", "name", ... +---*/ + +var propNames = Object.getOwnPropertyNames(Function); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/sendable/builtins/Function/proto-from-ctor-realm-prototype.js b/test/sendable/builtins/Function/proto-from-ctor-realm-prototype.js new file mode 100644 index 00000000000..bab8537e418 --- /dev/null +++ b/test/sendable/builtins/Function/proto-from-ctor-realm-prototype.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-createdynamicfunction +description: > + While default [[Prototype]] value derives from realm of the newTarget, + "prototype" object inherits from %Object.prototype% of constructor's realm. +info: | + Function ( p1, p2, … , pn, body ) + + [...] + 3. Return ? CreateDynamicFunction(C, NewTarget, normal, args). + + CreateDynamicFunction ( constructor, newTarget, kind, args ) + + [...] + 18. Let proto be ? GetPrototypeFromConstructor(newTarget, fallbackProto). + 19. Let realmF be the current Realm Record. + 20. Let scope be realmF.[[GlobalEnv]]. + 21. Let F be ! OrdinaryFunctionCreate(proto, parameters, body, non-lexical-this, scope). + [...] + 25. Else if kind is normal, perform MakeConstructor(F). + [...] + 30. Return F. + + MakeConstructor ( F [ , writablePrototype [ , prototype ] ] ) + + [...] + 7. If prototype is not present, then + a. Set prototype to OrdinaryObjectCreate(%Object.prototype%). + [...] + 8. Perform ! DefinePropertyOrThrow(F, "prototype", PropertyDescriptor {[[Value]]: prototype, + [[Writable]]: writablePrototype, [[Enumerable]]: false, [[Configurable]]: false }). +features: [cross-realm, Reflect] +---*/ + +var realmA = $262.createRealm().global; +realmA.calls = 0; + +var realmB = $262.createRealm().global; +var newTarget = new realmB.Function(); +newTarget.prototype = null; + +var fn = Reflect.construct(realmA.Function, ["calls += 1;"], newTarget); +assert.sameValue(Object.getPrototypeOf(fn), realmB.Function.prototype); +assert.sameValue(Object.getPrototypeOf(fn.prototype), realmA.Object.prototype); + +assert(new fn() instanceof realmA.Object); +assert.sameValue(realmA.calls, 1); diff --git a/test/sendable/builtins/Function/proto-from-ctor-realm.js b/test/sendable/builtins/Function/proto-from-ctor-realm.js new file mode 100644 index 00000000000..476af90c574 --- /dev/null +++ b/test/sendable/builtins/Function/proto-from-ctor-realm.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function-p1-p2-pn-body +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 5. Return ? CreateDynamicFunction(C, NewTarget, "normal", args). + + 19.2.1.1.1 Runtime Semantics: CreateDynamicFunction + + [...] + 2. If kind is "normal", then + [...] + c. Let fallbackProto be "%FunctionPrototype%". + [...] + 22. Let proto be ? GetPrototypeFromConstructor(newTarget, fallbackProto). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var o = Reflect.construct(Function, [], C); + +assert.sameValue(Object.getPrototypeOf(o), other.Function.prototype); diff --git a/test/sendable/builtins/Function/prototype/S15.3.3.1_A1.js b/test/sendable/builtins/Function/prototype/S15.3.3.1_A1.js new file mode 100644 index 00000000000..efedc5e99f2 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/S15.3.3.1_A1.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: The Function.prototype property has the attribute ReadOnly +es5id: 15.3.3.1_A1 +description: Checking if varying the Function.prototype property fails +includes: [propertyHelper.js] +---*/ + +var obj = Function.prototype; + +verifyNotWritable(Function, "prototype", null, function() { + return "shifted"; +}); + +assert.sameValue(Function.prototype, obj, 'The value of Function.prototype is expected to equal the value of obj'); + +try { + assert.sameValue(Function.prototype(), undefined, 'Function.prototype() returns undefined'); +} catch (e) { + throw new Test262Error('#2.1: the Function.prototype property has the attributes ReadOnly: ' + e); +} + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/S15.3.3.1_A2.js b/test/sendable/builtins/Function/prototype/S15.3.3.1_A2.js new file mode 100644 index 00000000000..e1f0a0099ea --- /dev/null +++ b/test/sendable/builtins/Function/prototype/S15.3.3.1_A2.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: The Function.prototype property has the attribute DontEnum +es5id: 15.3.3.1_A2 +description: Checking if enumerating the Function.prototype property fails +---*/ +assert( + !Function.propertyIsEnumerable('prototype'), + 'The value of !Function.propertyIsEnumerable(\'prototype\') is expected to be true' +); + +// CHECK#2 +var count = 0; + +for (var p in Function) { + if (p === "prototype") { + count++; + } +} + +assert.sameValue(count, 0, 'The value of count is expected to be 0'); + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/S15.3.3.1_A3.js b/test/sendable/builtins/Function/prototype/S15.3.3.1_A3.js new file mode 100644 index 00000000000..dc0885faecc --- /dev/null +++ b/test/sendable/builtins/Function/prototype/S15.3.3.1_A3.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: The Function.prototype property has the attribute DontDelete +es5id: 15.3.3.1_A3 +description: Checking if deleting the Function.prototype property fails +includes: [propertyHelper.js] +---*/ + +verifyNotConfigurable(Function, "prototype"); + +try { + assert.sameValue(delete Function.prototype, false); +} catch (e) { + if (e instanceof Test262Error) { + throw e; + } + assert(e instanceof TypeError); +} + +if (!(Function.hasOwnProperty('prototype'))) { + throw new Test262Error('#2: the Function.prototype property has the attributes DontDelete.'); +} + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/S15.3.3.1_A4.js b/test/sendable/builtins/Function/prototype/S15.3.3.1_A4.js new file mode 100644 index 00000000000..9330c7808e2 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/S15.3.3.1_A4.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + Detects whether the value of a function's "prototype" property + as seen by normal object operations might deviate from the value + as seem by Object.getOwnPropertyDescriptor +es5id: 15.3.3.1_A4 +description: > + Checks if reading a function's .prototype directly agrees with + reading it via Object.getOwnPropertyDescriptor, after having set + it by Object.defineProperty. +---*/ + +function foo() {} + +Object.defineProperty(foo, 'prototype', { + value: {} +}); + +assert.sameValue( + foo.prototype, + Object.getOwnPropertyDescriptor(foo, 'prototype').value, + 'The value of foo.prototype is expected to equal the value of Object.getOwnPropertyDescriptor(foo, \'prototype\').value' +); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A1.js b/test/sendable/builtins/Function/prototype/S15.3.4_A1.js new file mode 100644 index 00000000000..fb146e1c57c --- /dev/null +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A1.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The Function prototype object is itself a Function object (its [[Class]] + is "Function") +es5id: 15.3.4_A1 +description: Object.prototype.toString returns [object+[[Class]]+] +---*/ +assert.sameValue( + Object.prototype.toString.call(Function.prototype), + "[object Function]", + 'Object.prototype.toString.call(Function.prototype) must return "[object Function]"' +); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T1.js b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T1.js new file mode 100644 index 00000000000..9021a3f5734 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T1.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The Function prototype object is itself a Function object that, when + invoked, accepts any arguments and returns undefined +es5id: 15.3.4_A2_T1 +description: Call Function.prototype() +---*/ + +try { + assert.sameValue(Function.prototype(), undefined, 'Function.prototype() returns undefined'); +} catch (e) { + throw new Test262Error('#1.1: The Function prototype object is itself a Function object that, when invoked, accepts any arguments and returns undefined: ' + e); +} diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T2.js b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T2.js new file mode 100644 index 00000000000..2e04ed7a48d --- /dev/null +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T2.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The Function prototype object is itself a Function object that, when + invoked, accepts any arguments and returns undefined +es5id: 15.3.4_A2_T2 +description: Call Function.prototype(null,void 0) +---*/ + +try { + assert.sameValue(Function.prototype(null, void 0), undefined, 'Function.prototype(null, void 0) returns undefined'); +} catch (e) { + throw new Test262Error('#1.1: The Function prototype object is itself a Function object that, when invoked, accepts any arguments and returns undefined: ' + e); +} diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T3.js b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T3.js new file mode 100644 index 00000000000..9fc9baa8a74 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T3.js @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The Function prototype object is itself a Function object that, when + invoked, accepts any arguments and returns undefined +es5id: 15.3.4_A2_T3 +description: Call Function.prototype(x), where x is undefined variable +---*/ + +var x; +assert.sameValue(Function.prototype(x), undefined, 'Function.prototype(x) returns undefined'); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A3_T1.js b/test/sendable/builtins/Function/prototype/S15.3.4_A3_T1.js new file mode 100644 index 00000000000..dedca7113ac --- /dev/null +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A3_T1.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The value of the internal [[Prototype]] property of the Function + prototype object is the Object prototype object (15.3.4) +es5id: 15.3.4_A3_T1 +description: Checking prototype of Function.prototype +---*/ +assert.sameValue( + Object.getPrototypeOf(Function.prototype), + Object.prototype, + 'Object.getPrototypeOf(Function.prototype) returns Object.prototype' +); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A3_T2.js b/test/sendable/builtins/Function/prototype/S15.3.4_A3_T2.js new file mode 100644 index 00000000000..82595b1a157 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A3_T2.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The value of the internal [[Prototype]] property of the Function + prototype object is the Object prototype object (15.3.2.1) +es5id: 15.3.4_A3_T2 +description: > + Add new property to Object.prototype and check it at + Function.prototype +---*/ + +Object.prototype.indicator = 1; + +assert.sameValue(Function.prototype.indicator, 1, 'The value of Function.prototype.indicator is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A4.js b/test/sendable/builtins/Function/prototype/S15.3.4_A4.js new file mode 100644 index 00000000000..8835b4ec007 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A4.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The Function prototype object does not have a valueOf property of its + own. however, it inherits the valueOf property from the Object prototype + Object +es5id: 15.3.4_A4 +description: Checking valueOf property at Function.prototype +---*/ +assert.sameValue( + Function.prototype.hasOwnProperty("valueOf"), + false, + 'Function.prototype.hasOwnProperty("valueOf") must return false' +); + +assert.notSameValue( + typeof Function.prototype.valueOf, + "undefined", + 'The value of typeof Function.prototype.valueOf is not "undefined"' +); + +assert.sameValue( + Function.prototype.valueOf, + Object.prototype.valueOf, + 'The value of Function.prototype.valueOf is expected to equal the value of Object.prototype.valueOf' +); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A5.js b/test/sendable/builtins/Function/prototype/S15.3.4_A5.js new file mode 100644 index 00000000000..a631100fa4c --- /dev/null +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A5.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The Function prototype object is itself a Function object without + [[Construct]] property +es5id: 15.3.4_A5 +description: Checking if creating "new Function.prototype object" fails +---*/ + +assert.throws(TypeError, function() { + new Function.prototype; +}, '`new Function.prototype` throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T1.js b/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T1.js new file mode 100644 index 00000000000..de83518aaef --- /dev/null +++ b/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T1.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: the prototype property has the attributes { DontDelete } +es5id: 15.3.5.2_A1_T1 +description: > + Checking if deleting the prototype property of Function("", null) + fails +includes: [propertyHelper.js] +---*/ + +var f = new Function("", null); + +assert(f.hasOwnProperty('prototype')); + +var fproto = f.prototype; + +verifyNotConfigurable(f, "prototype"); + +try { + assert.sameValue(delete f.prototype, false); +} catch (e) { + if (e instanceof Test262Error) { + throw e; + } + assert(e instanceof TypeError); +} + +if (f.prototype !== fproto) { + throw new Test262Error('#3: the prototype property has the attributes { DontDelete }'); +} + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T2.js b/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T2.js new file mode 100644 index 00000000000..e559f435daf --- /dev/null +++ b/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T2.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: the prototype property has the attributes { DontDelete } +es5id: 15.3.5.2_A1_T2 +description: > + Checking if deleting the prototype property of Function(void 0, + "") fails +includes: [propertyHelper.js] +---*/ + +var f = Function(void 0, ""); + +assert(f.hasOwnProperty('prototype')); + +var fproto = f.prototype; + +verifyNotConfigurable(f, "prototype"); + +try { + assert.sameValue(delete f.prototype, false); +} catch (e) { + if (e instanceof Test262Error) { + throw e; + } + assert(e instanceof TypeError); +} + +if (f.prototype !== fproto) { + throw new Test262Error('#3: the prototype property has the attributes { DontDelete }'); +} + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/length.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/length.js new file mode 100644 index 00000000000..d804649b003 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/length.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.6 +description: Function.prototye[Symbol.hasInstance] `length` property +info: | + ES6 Section 17: + 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. + + [...] + + Unless otherwise specified, the length property of a built-in Function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +features: [Symbol.hasInstance] +includes: [propertyHelper.js] +---*/ + +verifyProperty(Function.prototype[Symbol.hasInstance], "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/name.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/name.js new file mode 100644 index 00000000000..297b0da6261 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.6 +description: > + The value of the name property of this function is "[Symbol.hasInstance]". + + 17 ECMAScript Standard Built-in Objects +features: [Symbol.hasInstance] +includes: [propertyHelper.js] +---*/ + +verifyProperty(Function.prototype[Symbol.hasInstance], "name", { + value: "[Symbol.hasInstance]", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/prop-desc.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/prop-desc.js new file mode 100644 index 00000000000..0975f0b9b34 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/prop-desc.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.6 +description: Function.prototype[Symbol.hasInstance] property descriptor +info: | + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: false }. +features: [Symbol.hasInstance] +includes: [propertyHelper.js] +---*/ + +assert.sameValue(typeof Function.prototype[Symbol.hasInstance], 'function'); + +verifyProperty(Function.prototype, Symbol.hasInstance, { + writable: false, + enumerable: false, + configurable: false, +}); diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-bound-target.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-bound-target.js new file mode 100644 index 00000000000..40d1a8ed767 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-bound-target.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.6 +description: Invoked on a bound function +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + 1. If IsCallable(C) is false, return false. + 2. If C has a [[BoundTargetFunction]] internal slot, then + a. Let BC be the value of C’s [[BoundTargetFunction]] internal slot. + b. Return InstanceofOperator(O,BC) (see 12.9.4). +features: [Symbol.hasInstance] +---*/ + +var BC = function() {}; +var bc = new BC(); +var bound = BC.bind(); + +assert.sameValue(bound[Symbol.hasInstance](bc), true); diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-not-callable.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-not-callable.js new file mode 100644 index 00000000000..8451d480b91 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-not-callable.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.6 +description: Non-callable `this` value +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + 1. If IsCallable(C) is false, return false. +features: [Symbol.hasInstance] +---*/ + +assert.sameValue(Function.prototype[Symbol.hasInstance].call(), false); +assert.sameValue(Function.prototype[Symbol.hasInstance].call({}), false); diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-poisoned-prototype.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-poisoned-prototype.js new file mode 100644 index 00000000000..d88c028c965 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-poisoned-prototype.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.6 +description: Error thrown when accessing `prototype` property of `this` value +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + [...] + 4. Let P be Get(C, "prototype"). + 5. ReturnIfAbrupt(P). +features: [Symbol.hasInstance] +---*/ + +// Create a callable object without a `prototype` property +var f = Object.getOwnPropertyDescriptor({ + get f() {} +}, 'f').get; + +Object.defineProperty(f, 'prototype', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + f[Symbol.hasInstance]({}); +}); diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-prototype-non-obj.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-prototype-non-obj.js new file mode 100644 index 00000000000..8b15bb48224 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-prototype-non-obj.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.6 +description: Error thrown when accessing `prototype` property of `this` value +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + [...] + 4. Let P be Get(C, "prototype"). + 5. ReturnIfAbrupt(P). + 6. If Type(P) is not Object, throw a TypeError exception. +features: [Symbol, Symbol.hasInstance] +---*/ + +var f = function() {}; + +f.prototype = undefined; +assert.throws(TypeError, function() { + f[Symbol.hasInstance]({}); +}); + +f.prototype = null; +assert.throws(TypeError, function() { + f[Symbol.hasInstance]({}); +}); + +f.prototype = true; +assert.throws(TypeError, function() { + f[Symbol.hasInstance]({}); +}); + +f.prototype = 'string'; +assert.throws(TypeError, function() { + f[Symbol.hasInstance]({}); +}); + +f.prototype = Symbol(); +assert.throws(TypeError, function() { + f[Symbol.hasInstance]({}); +}); + +f.prototype = 86; +assert.throws(TypeError, function() { + f[Symbol.hasInstance]({}); +}); diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-get-prototype-of-err.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-get-prototype-of-err.js new file mode 100644 index 00000000000..5b79a0e3423 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-get-prototype-of-err.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.6 +description: > + Error thrown when invoking argument's [[GetPrototypeOf]] internal method +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + [...] + 7. Repeat + a. Let O be O.[[GetPrototypeOf]](). + b. ReturnIfAbrupt(O). + c. If O is null, return false. + d. If SameValue(P, O) is true, return true. +features: [Proxy, Symbol.hasInstance] +---*/ + +var o = new Proxy({}, { + getPrototypeOf: function() { + throw new Test262Error(); + } +}); +var o2 = Object.create(o); +var f = function() {}; + +assert.throws(Test262Error, function() { + f[Symbol.hasInstance](o); +}); + +assert.throws(Test262Error, function() { + f[Symbol.hasInstance](o2); +}); diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-negative.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-negative.js new file mode 100644 index 00000000000..3e0fc36699f --- /dev/null +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-negative.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.6 +description: > + Constructor is not defined in the argument's prototype chain +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + [...] + 7. Repeat + a. Let O be O.[[GetPrototypeOf]](). + b. ReturnIfAbrupt(O). + c. If O is null, return false. + d. If SameValue(P, O) is true, return true. +features: [Symbol.hasInstance] +---*/ + +var f = function() {}; +var o = Object.create(null); +var o2 = Object.create(o); + +assert.sameValue(f[Symbol.hasInstance](o), false); +assert.sameValue(f[Symbol.hasInstance](o2), false); diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-non-obj.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-non-obj.js new file mode 100644 index 00000000000..0f7a030d322 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-non-obj.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.6 +description: Non-object argument +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + [...] + 3. If Type(O) is not Object, return false. +features: [Symbol, Symbol.hasInstance] +---*/ + +assert.sameValue(function() {}[Symbol.hasInstance](), false); +assert.sameValue(function() {}[Symbol.hasInstance](undefined), false); +assert.sameValue(function() {}[Symbol.hasInstance](null), false); +assert.sameValue(function() {}[Symbol.hasInstance](true), false); +assert.sameValue(function() {}[Symbol.hasInstance]('string'), false); +assert.sameValue(function() {}[Symbol.hasInstance](Symbol()), false); +assert.sameValue(function() {}[Symbol.hasInstance](86), false); diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-positive.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-positive.js new file mode 100644 index 00000000000..876549b5629 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/value-positive.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.6 +description: > + Constructor is defined in the argument's prototype chain +info: | + 1. Let F be the this value. + 2. Return OrdinaryHasInstance(F, V). + + 7.3.19 OrdinaryHasInstance (C, O) + + [...] + 7. Repeat + a. Let O be O.[[GetPrototypeOf]](). + b. ReturnIfAbrupt(O). + c. If O is null, return false. + d. If SameValue(P, O) is true, return true. +features: [Symbol.hasInstance] +---*/ + +var f = function() {}; +var o = new f(); +var o2 = Object.create(o); + +assert.sameValue(f[Symbol.hasInstance](o), true); +assert.sameValue(f[Symbol.hasInstance](o2), true); diff --git a/test/sendable/builtins/Function/prototype/apply/15.3.4.3-1-s.js b/test/sendable/builtins/Function/prototype/apply/15.3.4.3-1-s.js new file mode 100644 index 00000000000..b16fe11c226 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/15.3.4.3-1-s.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.3-1-s +description: > + Strict Mode - 'this' value is a string which cannot be converted + to wrapper objects when the function is called with an array of + arguments +flags: [onlyStrict] +---*/ + +function fun() { + return (this instanceof String); +} + +assert.sameValue(fun.apply("", SendableArray), false, 'fun.apply("", SendableArray)'); diff --git a/test/sendable/builtins/Function/prototype/apply/15.3.4.3-2-s.js b/test/sendable/builtins/Function/prototype/apply/15.3.4.3-2-s.js new file mode 100644 index 00000000000..7c451dbf182 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/15.3.4.3-2-s.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.3-2-s +description: > + Strict Mode - 'this' value is a number which cannot be converted + to wrapper objects when the function is called with an array of + arguments +flags: [onlyStrict] +---*/ + +function fun() { + return (this instanceof Number); +} + +assert.sameValue(fun.apply(-12, SendableArray), false, 'fun.apply(-12, SendableArray)'); diff --git a/test/sendable/builtins/Function/prototype/apply/15.3.4.3-3-s.js b/test/sendable/builtins/Function/prototype/apply/15.3.4.3-3-s.js new file mode 100644 index 00000000000..8270bb3311e --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/15.3.4.3-3-s.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.3-3-s +description: > + Strict Mode - 'this' value is a boolean which cannot be converted + to wrapper objects when the function is called with an array of + arguments +flags: [onlyStrict] +---*/ + +function fun() { + return (this instanceof Boolean); +} + +assert.sameValue(fun.apply(false, SendableArray), false, 'fun.apply(false, SendableArray)'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A12.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A12.js new file mode 100644 index 00000000000..840ca137a16 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A12.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Function.prototype.apply has not prototype property +es5id: 15.3.4.3_A12 +description: > + Checking if obtaining the prototype property of + Function.prototype.apply fails +---*/ +assert.sameValue( + Function.prototype.apply.prototype, + undefined, + 'The value of Function.prototype.apply.prototype is expected to equal undefined' +); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T1.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T1.js new file mode 100644 index 00000000000..387405345d1 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T1.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The apply method performs a function call using the [[Call]] property of + the object. If the object does not have a [[Call]] property, a TypeError + exception is thrown +es5id: 15.3.4.3_A1_T1 +description: > + Calling "apply" method of the object that does not have a [[Call]] + property. Prototype of the object is Function() +---*/ + +var proto = Function(); + +function FACTORY() {} + +FACTORY.prototype = proto; + +var obj = new FACTORY; + +assert.sameValue(typeof obj.apply, "function", 'The value of `typeof obj.apply` is expected to be "function"'); + +try { + obj.apply(); + throw new Test262Error('#2: If the object does not have a [[Call]] property, a TypeError exception is thrown'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T2.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T2.js new file mode 100644 index 00000000000..9291b120437 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T2.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The apply method performs a function call using the [[Call]] property of + the object. If the object does not have a [[Call]] property, a TypeError + exception is thrown +es5id: 15.3.4.3_A1_T2 +description: > + Calling "apply" method of the object that does not have a [[Call]] + property. Prototype of the object is Function.prototype +---*/ + +function FACTORY() {} + +FACTORY.prototype = Function.prototype; + +var obj = new FACTORY; + +assert.sameValue(typeof obj.apply, "function", 'The value of `typeof obj.apply` is expected to be "function"'); + +try { + obj.apply(); + throw new Test262Error('#2: If the object does not have a [[Call]] property, a TypeError exception is thrown'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T1.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T1.js new file mode 100644 index 00000000000..b1af286b5dd --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T1.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.3_A3_T1 +description: Not any arguments at apply function +---*/ + +Function("this.field=\"strawberry\"").apply(); + +assert.sameValue(this["field"], "strawberry", 'The value of this["field"] is expected to be "strawberry"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T10.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T10.js new file mode 100644 index 00000000000..ab8569835f7 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T10.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.3_A3_T10 +description: Checking by using eval, no any arguments at apply function +flags: [noStrict] +---*/ + +eval(" (function(){this.feat=1}).apply()"); + +assert.sameValue(this["feat"], 1, 'The value of this["feat"] is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T2.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T2.js new file mode 100644 index 00000000000..9b55195ef24 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T2.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.3_A3_T2 +description: Argument at apply function is null +---*/ + +Function("this.field=\"green\"").apply(null); + +assert.sameValue(this["field"], "green", 'The value of this["field"] is expected to be "green"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T3.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T3.js new file mode 100644 index 00000000000..859d51dd0e0 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T3.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.3_A3_T3 +description: Argument at apply function is void 0 +---*/ + +Function("this.field=\"battle\"").apply(void 0); + +assert.sameValue(this["field"], "battle", 'The value of this["field"] is expected to be "battle"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T4.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T4.js new file mode 100644 index 00000000000..51c10685275 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T4.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.3_A3_T4 +description: Argument at apply function is undefined +---*/ + +Function("this.field=\"oil\"").apply(undefined); + +assert.sameValue(this["field"], "oil", 'The value of this["field"] is expected to be "oil"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T5.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T5.js new file mode 100644 index 00000000000..1d1cf5498d2 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T5.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.3_A3_T5 +description: > + No any arguments at apply function and it called inside function + declaration +---*/ + +function FACTORY() { + Function("this.feat=\"in da haus\"").apply(); +} + +var obj = new FACTORY; + +assert.sameValue(this["feat"], "in da haus", 'The value of this["feat"] is expected to be "in da haus"'); +assert.sameValue(typeof obj.feat, "undefined", 'The value of `typeof obj.feat` is expected to be "undefined"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T6.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T6.js new file mode 100644 index 00000000000..df2cab9e025 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T6.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.3_A3_T6 +description: > + Argument at apply function is null and it called inside function + declaration +flags: [noStrict] +---*/ + +function FACTORY() { + (function() { + this.feat = "kamon beyba" + }).apply(null); +} + +var obj = new FACTORY; + +assert.sameValue(this["feat"], "kamon beyba", 'The value of this["feat"] is expected to be "kamon beyba"'); +assert.sameValue(typeof obj.feat, "undefined", 'The value of `typeof obj.feat` is expected to be "undefined"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T7.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T7.js new file mode 100644 index 00000000000..149adf35e36 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T7.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.3_A3_T7 +description: > + Argument at apply function is void 0 and it called inside function + declaration +---*/ + +(function FACTORY() { + Function("this.feat=\"in da haus\"").apply(void 0); +})(); + + +assert.sameValue(this["feat"], "in da haus", 'The value of this["feat"] is expected to be "in da haus"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T8.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T8.js new file mode 100644 index 00000000000..4f55f9de1de --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T8.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.3_A3_T8 +description: > + Argument at apply function is undefined and it called inside + function declaration +flags: [noStrict] +---*/ + +(function FACTORY() { + (function() { + this.feat = "kamon beyba" + }).apply(undefined); +})(); + +assert.sameValue(this["feat"], "kamon beyba", 'The value of this["feat"] is expected to be "kamon beyba"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T9.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T9.js new file mode 100644 index 00000000000..a12c2068b21 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T9.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.3_A3_T9 +description: Checking by using eval, argument at apply function is void 0 +---*/ + +eval(" Function(\"this.feat=1\").apply(void 0) "); + +assert.sameValue(this["feat"], 1, 'The value of this["feat"] is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T1.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T1.js new file mode 100644 index 00000000000..af6756ca8d5 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T1.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.3_A5_T1 +description: thisArg is number +---*/ + +var obj = 1; + +var retobj = Function("this.touched= true; return this;").apply(obj); + +assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); +assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T2.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T2.js new file mode 100644 index 00000000000..56ff45dcee1 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T2.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.3_A5_T2 +description: thisArg is boolean true +---*/ + +var obj = true; + +var retobj = new Function("this.touched= true; return this;").apply(obj); + +assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); +assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T3.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T3.js new file mode 100644 index 00000000000..5a0e9dfc5e8 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T3.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.3_A5_T3 +description: thisArg is string +flags: [noStrict] +---*/ + +var obj = "soap"; + +var retobj = (function() { + this.touched = true; + return this; +}).apply(obj); + +assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); +assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T4.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T4.js new file mode 100644 index 00000000000..f309f5d6b81 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T4.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.3_A5_T4 +description: thisArg is function variable that return this +flags: [noStrict] +---*/ + +f = function() { + this.touched = true; + return this; +}; + +retobj = f.apply(obj); + +assert.sameValue(typeof obj, "undefined", 'The value of `typeof obj` is expected to be "undefined"'); +assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); + +var obj; diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T5.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T5.js new file mode 100644 index 00000000000..8cda11d92f2 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T5.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.3_A5_T5 +description: thisArg is function variable +---*/ + +var f = function() { + this.touched = true; +}; + +var obj = {}; + +f.apply(obj); + +assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T6.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T6.js new file mode 100644 index 00000000000..69f3f09edcd --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T6.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.3_A5_T6 +description: thisArg is new String() +---*/ + +var obj = new String("soap"); + +(function() { + this.touched = true; +}).apply(obj); + +assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T7.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T7.js new file mode 100644 index 00000000000..168808525a7 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T7.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.3_A5_T7 +description: thisArg is new Number() +---*/ + +var obj = new Number(1); + +Function("this.touched= true;").apply(obj); + +assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T8.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T8.js new file mode 100644 index 00000000000..2f40c529d7e --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T8.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.3_A5_T8 +description: thisArg is Function() +---*/ + +var obj = Function(); + +new Function("this.touched= true; return this;").apply(obj); + +assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T1.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T1.js new file mode 100644 index 00000000000..4f64215f192 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T1.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If argSendableArray is either an array or an arguments object, + the function is passed the (ToUint32(argSendableArray.length)) arguments argSendableArray[0], argSendableArray[1],...,argSendableArray[ToUint32(argSendableArray.length)-1] +es5id: 15.3.4.3_A7_T1 +description: argSendableArray is (null,[1]) +---*/ + +Function("a1,a2,a3", "this.shifted=a1;").apply(null, [1]); + +assert.sameValue(this["shifted"], 1, 'The value of this["shifted"] is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T10.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T10.js new file mode 100644 index 00000000000..468299ba6e3 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T10.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If argSendableArray is either an array or an arguments object, + the function is passed the (ToUint32(argSendableArray.length)) arguments argSendableArray[0], argSendableArray[1],...,argSendableArray[ToUint32(argSendableArray.length)-1] +es5id: 15.3.4.3_A7_T10 +description: > + argSendableArray is (empty object, arguments), inside function call + without declaration used +---*/ + +var obj = {}; + +(function() { + Function("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(obj, arguments); +})("", 4, 2); + +assert.sameValue(obj["shifted"], "42", 'The value of obj["shifted"] is expected to be "42"'); + +assert.sameValue( + typeof this["shifted"], + "undefined", + 'The value of `typeof this["shifted"]` is expected to be "undefined"' +); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T2.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T2.js new file mode 100644 index 00000000000..387ab015189 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T2.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If argSendableArray is either an array or an arguments object, + the function is passed the (ToUint32(argSendableArray.length)) arguments argSendableArray[0], argSendableArray[1],...,argSendableArray[ToUint32(argSendableArray.length)-1] +es5id: 15.3.4.3_A7_T2 +description: argSendableArray is (null,[1,2,3]) +---*/ + +new Function("a1,a2", "a3", "this.shifted=a2;").apply(null, [1, 2, 3]); + +assert.sameValue(this["shifted"], 2, 'The value of this["shifted"] is expected to be 2'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T3.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T3.js new file mode 100644 index 00000000000..1965aec6a4a --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T3.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If argSendableArray is either an array or an arguments object, + the function is passed the (ToUint32(argSendableArray.length)) arguments argSendableArray[0], argSendableArray[1],...,argSendableArray[ToUint32(argSendableArray.length)-1] +es5id: 15.3.4.3_A7_T3 +description: argSendableArray is (empty object, new SendableArray("nine","inch","nails")) +---*/ + +var i = 0; + +var p = { + toString: function() { + return "a" + (++i); + } +}; + +var obj = {}; + +Function(p, "a2,a3", "this.shifted=a1;").apply(obj, new SendableArray("nine", "inch", "nails")); + +assert.sameValue(obj["shifted"], "nine", 'The value of obj["shifted"] is expected to be "nine"'); + +assert.sameValue( + typeof this["shifted"], + "undefined", + 'The value of `typeof this["shifted"]` is expected to be "undefined"' +); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T4.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T4.js new file mode 100644 index 00000000000..615ce29b630 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T4.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If argSendableArray is either an array or an arguments object, + the function is passed the (ToUint32(argSendableArray.length)) arguments argSendableArray[0], argSendableArray[1],...,argSendableArray[ToUint32(argSendableArray.length)-1] +es5id: 15.3.4.3_A7_T4 +description: > + argSendableArray is (empty object, ( function(){return arguments;}) + ("a","b","c")) +---*/ + +var i = 0; + +var p = { + toString: function() { + return "a" + (++i); + } +}; + +var obj = {}; + +new Function(p, p, p, "this.shifted=a3;").apply(obj, (function() { + return arguments; +})("a", "b", "c")); + +assert.sameValue(obj["shifted"], "c", 'The value of obj["shifted"] is expected to be "c"'); + +assert.sameValue( + typeof this["shifted"], + "undefined", + 'The value of `typeof this["shifted"]` is expected to be "undefined"' +); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T5.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T5.js new file mode 100644 index 00000000000..28b4f7534f8 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T5.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If argSendableArray is either an array or an arguments object, + the function is passed the (ToUint32(argSendableArray.length)) arguments argSendableArray[0], argSendableArray[1],...,argSendableArray[ToUint32(argSendableArray.length)-1] +es5id: 15.3.4.3_A7_T5 +description: argSendableArray is (null, arguments), inside function declaration used +---*/ + +function FACTORY() { + Function("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(null, arguments); +} + +var obj = new FACTORY("", 1, 2); + +assert.sameValue(this["shifted"], "12", 'The value of this["shifted"] is expected to be "12"'); +assert.sameValue(typeof obj.shifted, "undefined", 'The value of `typeof obj.shifted` is expected to be "undefined"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T6.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T6.js new file mode 100644 index 00000000000..ecde945b892 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T6.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If argSendableArray is either an array or an arguments object, + the function is passed the (ToUint32(argSendableArray.length)) arguments argSendableArray[0], argSendableArray[1],...,argSendableArray[ToUint32(argSendableArray.length)-1] +es5id: 15.3.4.3_A7_T6 +description: argSendableArray is (this, arguments), inside function declaration used +---*/ + +function FACTORY() { + Function("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(this, arguments); +} + +var obj = new FACTORY("", 4, 2); + +assert.sameValue(obj["shifted"], "42", 'The value of obj["shifted"] is expected to be "42"'); + +assert.sameValue( + typeof this["shifted"], + "undefined", + 'The value of `typeof this["shifted"]` is expected to be "undefined"' +); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T7.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T7.js new file mode 100644 index 00000000000..d432dc90ba5 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T7.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If argSendableArray is either an array or an arguments object, + the function is passed the (ToUint32(argSendableArray.length)) arguments argSendableArray[0], argSendableArray[1],...,argSendableArray[ToUint32(argSendableArray.length)-1] +es5id: 15.3.4.3_A7_T7 +description: > + argSendableArray is (null, arguments), inside function call without + declaration used +---*/ + +(function() { + Function("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(null, arguments); +})("", 1, 2); + +assert.sameValue(this["shifted"], "12", 'The value of this["shifted"] is expected to be "12"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T8.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T8.js new file mode 100644 index 00000000000..0630f32c591 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T8.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If argSendableArray is either an array or an arguments object, + the function is passed the (ToUint32(argSendableArray.length)) arguments argSendableArray[0], argSendableArray[1],...,argSendableArray[ToUint32(argSendableArray.length)-1] +es5id: 15.3.4.3_A7_T8 +description: > + argSendableArray is (this, arguments), inside function call without + declaration used +---*/ + +(function() { + Function("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(this, arguments); +})("", 4, 2); + +assert.sameValue(this["shifted"], "42", 'The value of this["shifted"] is expected to be "42"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T9.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T9.js new file mode 100644 index 00000000000..692cac53f7f --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T9.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If argSendableArray is either an array or an arguments object, + the function is passed the (ToUint32(argSendableArray.length)) arguments argSendableArray[0], argSendableArray[1],...,argSendableArray[ToUint32(argSendableArray.length)-1] +es5id: 15.3.4.3_A7_T9 +description: > + argSendableArray is (empty object, arguments), inside function declaration + used +---*/ + +function FACTORY() { + var obj = {}; + Function("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(obj, arguments); + return obj; +} + +var obj = new FACTORY("", 1, 2); + +assert.sameValue( + typeof this["shifted"], + "undefined", + 'The value of `typeof this["shifted"]` is expected to be "undefined"' +); + +assert.sameValue(obj.shifted, "12", 'The value of obj.shifted is expected to be "12"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T3.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T3.js new file mode 100644 index 00000000000..0d145b7db60 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T3.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Function.prototype.apply can`t be used as [[Construct]] caller +es5id: 15.3.4.3_A8_T3 +description: Checking if creating "new Function.apply" fails +---*/ + +try { + var obj = new Function.apply; + throw new Test262Error('#1: Function.prototype.apply can\'t be used as [[Construct]] caller'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T4.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T4.js new file mode 100644 index 00000000000..ce5a5cd430e --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T4.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Function.prototype.apply can`t be used as [[Construct]] caller +es5id: 15.3.4.3_A8_T4 +description: Checking if creating "new (Function("this.p1=1").apply)" fails +---*/ + +try { + var obj = new(Function("this.p1=1").apply); + throw new Test262Error('#1: Function.prototype.apply can\'t be used as [[Construct]] caller'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T5.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T5.js new file mode 100644 index 00000000000..07ca7192eda --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T5.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Function.prototype.apply can`t be used as [[Construct]] caller +es5id: 15.3.4.3_A8_T5 +description: Checking if creating "new Function("this.p1=1").apply" fails +---*/ + +try { + var FACTORY = Function("this.p1=1").apply; + var obj = new FACTORY(); + throw new Test262Error('#1: Function.prototype.apply can\'t be used as [[Construct]] caller'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T6.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T6.js new file mode 100644 index 00000000000..0dbc687d3bc --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T6.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Function.prototype.apply can`t be used as [[Construct]] caller +es5id: 15.3.4.3_A8_T6 +description: > + Checking if creating "new (Function("function + f(){this.p1=1;};return f").apply())" fails +---*/ + +try { + var obj = new(Function("function f(){this.p1=1;};return f").apply()); +} catch (e) { + throw new Test262Error('#1: Function.prototype.apply can\'t be used as [[Construct]] caller'); +} + +assert.sameValue(obj.p1, 1, 'The value of obj.p1 is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/apply/argarray-not-object-realm.js b/test/sendable/builtins/Function/prototype/apply/argarray-not-object-realm.js new file mode 100644 index 00000000000..6600186c41d --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/argarray-not-object-realm.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.apply +description: > + Throws a TypeError exception if argSendableArray is not an object + (honoring the Realm of the current execution context) +info: | + Function.prototype.apply ( thisArg, argSendableArray ) + + [...] + 4. Let argList be ? CreateListFromSendableArrayLike(argSendableArray). + + CreateListFromSendableArrayLike ( obj [ , elementTypes ] ) + + [...] + 2. If Type(obj) is not Object, throw a TypeError exception. +features: [cross-realm] +---*/ + +var other = $262.createRealm().global; +var fn = new other.Function(); + +assert.throws(other.TypeError, function() { + fn.apply(null, false); +}); + +assert.throws(other.TypeError, function() { + fn.apply(null, 1234.5678); +}); + +assert.throws(other.TypeError, function() { + fn.apply(null, ''); +}); + +assert.throws(other.TypeError, function() { + fn.apply(null, Symbol('desc')); +}); diff --git a/test/sendable/builtins/Function/prototype/apply/argarray-not-object.js b/test/sendable/builtins/Function/prototype/apply/argarray-not-object.js new file mode 100644 index 00000000000..20c649cb119 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/argarray-not-object.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.apply +description: > + Throws a TypeError exception if argSendableArray is not an object +info: | + Function.prototype.apply ( thisArg, argSendableArray ) + + [...] + 4. Let argList be ? CreateListFromSendableArrayLike(argSendableArray). + + CreateListFromSendableArrayLike ( obj [ , elementTypes ] ) + + [...] + 2. If Type(obj) is not Object, throw a TypeError exception. +---*/ + +function fn() {} + +assert.throws(TypeError, function() { + fn.apply(null, true); +}); + +assert.throws(TypeError, function() { + fn.apply(null, NaN); +}); + +assert.throws(TypeError, function() { + fn.apply(null, '1,2,3'); +}); + +assert.throws(TypeError, function() { + fn.apply(null, Symbol()); +}); diff --git a/test/sendable/builtins/Function/prototype/apply/get-index-abrupt.js b/test/sendable/builtins/Function/prototype/apply/get-index-abrupt.js new file mode 100644 index 00000000000..6d25de25fc2 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/get-index-abrupt.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.apply +description: > + Return abrupt completion from Get(obj, indexName) +info: | + Function.prototype.apply ( thisArg, argSendableArray ) + + [...] + 4. Let argList be ? CreateListFromSendableArrayLike(argSendableArray). + + CreateListFromSendableArrayLike ( obj [ , elementTypes ] ) + + [...] + 6. Repeat, while index < len + a. Let indexName be ! ToString(index). + b. Let next be ? Get(obj, indexName). +---*/ + +var arrayLike = { + length: 2, + 0: 0, + get 1() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + (function() {}).apply(null, arrayLike); +}); diff --git a/test/sendable/builtins/Function/prototype/apply/get-length-abrupt.js b/test/sendable/builtins/Function/prototype/apply/get-length-abrupt.js new file mode 100644 index 00000000000..c6ec68a57b7 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/get-length-abrupt.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.apply +description: > + Return abrupt completion from Get(obj, "length") +info: | + Function.prototype.apply ( thisArg, argSendableArray ) + + [...] + 4. Let argList be ? CreateListFromSendableArrayLike(argSendableArray). + + CreateListFromSendableArrayLike ( obj [ , elementTypes ] ) + + [...] + 3. Let len be ? ToLength(? Get(obj, "length")). +---*/ + +var arrayLike = { + get length() { + throw new Test262Error(); + }, +}; + +assert.throws(Test262Error, function() { + (function() {}).apply(null, arrayLike); +}); diff --git a/test/sendable/builtins/Function/prototype/apply/length.js b/test/sendable/builtins/Function/prototype/apply/length.js new file mode 100644 index 00000000000..020dea5c732 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/length.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.apply +description: > + Function.prototype.apply.length is 2. +info: | + 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. + ... + 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(Function.prototype.apply, 'length', { + value: 2, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Function/prototype/apply/name.js b/test/sendable/builtins/Function/prototype/apply/name.js new file mode 100644 index 00000000000..88f8b7c0b13 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/name.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.1 +description: > + Function.prototype.apply.name is "apply". +info: | + Function.prototype.apply ( thisArg, argSendableArray ) + + 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(Function.prototype.apply, "name", { + value: "apply", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Function/prototype/apply/not-a-constructor.js b/test/sendable/builtins/Function/prototype/apply/not-a-constructor.js new file mode 100644 index 00000000000..e9952136613 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/not-a-constructor.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Function.prototype.apply 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(Function.prototype.apply), + false, + 'isConstructor(Function.prototype.apply) must return false' +); + +assert.throws(TypeError, () => { + new Function.prototype.apply; +}); + +assert.throws(TypeError, () => { + new Function.prototype.apply(); +}); diff --git a/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js b/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js new file mode 100644 index 00000000000..266d69e18ae --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.apply +description: > + Function.p.apply behaves correctly when the argument array is a + TypedSendableArray backed by resizable buffer +includes: [compareSendableArray.js, resizableSendableSendableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableSendableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + function func(...args) { + return [...args]; + } + assert.compareSendableArray(ToNumbers(func.apply(null, fixedLength)), [ + 0, + 1, + 2, + 3 + ]); + assert.compareSendableArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), [ + 2, + 3 + ]); + assert.compareSendableArray(ToNumbers(func.apply(null, lengthTracking)), [ + 0, + 1, + 2, + 3 + ]); + assert.compareSendableArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), [ + 2, + 3 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + assert.compareSendableArray(ToNumbers(func.apply(null, fixedLength)), []); + assert.compareSendableArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), []); + assert.compareSendableArray(ToNumbers(func.apply(null, lengthTracking)), [ + 0, + 1, + 2 + ]); + assert.compareSendableArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), [2]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.compareSendableArray(ToNumbers(func.apply(null, fixedLength)), []); + assert.compareSendableArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), []); + assert.compareSendableArray(ToNumbers(func.apply(null, lengthTracking)), [0]); + assert.compareSendableArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), []); + + // Shrink to zero. + rab.resize(0); + assert.compareSendableArray(ToNumbers(func.apply(null, fixedLength)), []); + assert.compareSendableArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), []); + assert.compareSendableArray(ToNumbers(func.apply(null, lengthTracking)), []); + assert.compareSendableArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), []); + + // Grow so that all TAs are back in-bounds. New memory is zeroed. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + assert.compareSendableArray(ToNumbers(func.apply(null, fixedLength)), [ + 0, + 0, + 0, + 0 + ]); + assert.compareSendableArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), [ + 0, + 0 + ]); + assert.compareSendableArray(ToNumbers(func.apply(null, lengthTracking)), [ + 0, + 0, + 0, + 0, + 0, + 0 + ]); + assert.compareSendableArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), [ + 0, + 0, + 0, + 0 + ]); +} diff --git a/test/sendable/builtins/Function/prototype/apply/this-not-callable-realm.js b/test/sendable/builtins/Function/prototype/apply/this-not-callable-realm.js new file mode 100644 index 00000000000..b11dfa4586f --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/this-not-callable-realm.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.apply +description: > + Throws a TypeError exception if this value is not callable + (honoring the Realm of the current execution context) +info: | + Function.prototype.apply ( thisArg, argSendableArray ) + + 1. Let func be the this value. + 2. If IsCallable(func) is false, throw a TypeError exception. +features: [cross-realm] +---*/ + +var other = $262.createRealm().global; +var otherApply = other.Function.prototype.apply; + +assert.throws(other.TypeError, function() { + otherApply.call(undefined, {}, []); +}); + +assert.throws(other.TypeError, function() { + otherApply.call(null, {}, []); +}); + +assert.throws(other.TypeError, function() { + otherApply.call({}, {}, []); +}); + +assert.throws(other.TypeError, function() { + otherApply.call(/re/, {}, []); +}); diff --git a/test/sendable/builtins/Function/prototype/apply/this-not-callable.js b/test/sendable/builtins/Function/prototype/apply/this-not-callable.js new file mode 100644 index 00000000000..6aaf676909d --- /dev/null +++ b/test/sendable/builtins/Function/prototype/apply/this-not-callable.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.apply +description: > + Throws a TypeError exception if this value is not callable +info: | + Function.prototype.apply ( thisArg, argSendableArray ) + + 1. Let func be the this value. + 2. If IsCallable(func) is false, throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + Function.prototype.apply.call(undefined, {}, []); +}); + +assert.throws(TypeError, function() { + Function.prototype.apply.call(null, {}, []); +}); + +assert.throws(TypeError, function() { + Function.prototype.apply.call({}, {}, []); +}); + +assert.throws(TypeError, function() { + Function.prototype.apply.call(/re/, {}, []); +}); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-0-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-0-1.js new file mode 100644 index 00000000000..8577560848b --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-0-1.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-0-1 +description: Function.prototype.bind must exist as a function +---*/ + +var f = Function.prototype.bind; + +assert.sameValue(typeof(f), "function", 'typeof(f)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-10-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-10-1.js new file mode 100644 index 00000000000..44cd726a41d --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-10-1.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-10-1 +description: > + Function.prototype.bind - internal property [[Class]] of 'F' is + set as Function +---*/ + +var foo = function() {}; + +var obj = foo.bind({}); + +assert.sameValue(Object.prototype.toString.call(obj), "[object Function]", 'Object.prototype.toString.call(obj)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-11-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-11-1.js new file mode 100644 index 00000000000..b01b5759179 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-11-1.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-11-1 +description: > + Function.prototype.bind - internal property [[Prototype]] of 'F' + is set as Function.prototype +---*/ + +var foo = function() {}; + +Function.prototype.property = 12; +var obj = foo.bind({}); + +assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-1.js new file mode 100644 index 00000000000..f283f8c0ce8 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-1.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-16-1 +description: Function.prototype.bind, [[Extensible]] of the bound fn is true +---*/ + +function foo() {} +var o = {}; + +var bf = foo.bind(o); +var ex = Object.isExtensible(bf); + +assert.sameValue(ex, true, 'ex'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-2.js new file mode 100644 index 00000000000..5dd4bbf35db --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-2.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-16-2 +description: > + Function.prototype.bind - The [[Extensible]] attribute of internal + property in F set as true +---*/ + +function foo() {} +var obj = foo.bind({}); +obj.property = 12; + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-1.js new file mode 100644 index 00000000000..bb4ebebab40 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-1.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target + is not callable. +es5id: 15.3.4.5-2-1 +description: > + Function.prototype.bind throws TypeError if the Target is not + callable (but an instance of Function) +---*/ + +foo.prototype = Function.prototype; +// dummy function +function foo() {} +var f = new foo(); +assert.throws(TypeError, function() { + f.bind(); +}); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-10.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-10.js new file mode 100644 index 00000000000..aed0247153f --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-10.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-2-10 +description: Function.prototype.bind throws TypeError if 'Target' is undefined +---*/ + + +assert.throws(TypeError, function() { + Function.prototype.bind.call(undefined); +}); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-11.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-11.js new file mode 100644 index 00000000000..c2becf76f65 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-11.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-2-11 +description: Function.prototype.bind throws TypeError if 'Target' is NULL +---*/ + + +assert.throws(TypeError, function() { + Function.prototype.bind.call(null); +}); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-12.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-12.js new file mode 100644 index 00000000000..970f6ade351 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-12.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-2-12 +description: Function.prototype.bind throws TypeError if 'Target' is a boolean +---*/ + + +assert.throws(TypeError, function() { + Function.prototype.bind.call(true); +}); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-13.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-13.js new file mode 100644 index 00000000000..8e71bcfedce --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-13.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-2-13 +description: Function.prototype.bind throws TypeError if 'Target' is a number +---*/ + + +assert.throws(TypeError, function() { + Function.prototype.bind.call(5); +}); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-14.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-14.js new file mode 100644 index 00000000000..a13ca954963 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-14.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-2-14 +description: Function.prototype.bind throws TypeError if 'Target' is a string +---*/ + + +assert.throws(TypeError, function() { + Function.prototype.bind.call("abc"); +}); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-15.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-15.js new file mode 100644 index 00000000000..0741d2cc2dc --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-15.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-2-15 +description: > + Function.prototype.bind throws TypeError if 'Target' is Object + without Call internal method +---*/ + + +assert.throws(TypeError, function() { + Function.prototype.bind.call({}); +}); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-16.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-16.js new file mode 100644 index 00000000000..2a3e56c08ed --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-16.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-2-16 +description: Function.prototype.bind - 'Target' is a function +---*/ + +function testFunc() {} + +testFunc.bind(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-2.js new file mode 100644 index 00000000000..5cf00e0de81 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-2.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target + is not callable. +es5id: 15.3.4.5-2-2 +description: > + Function.prototype.bind throws TypeError if the Target is not + callable (bind attached to object) +---*/ + +// dummy function +function foo() {} +var f = new foo(); +f.bind = Function.prototype.bind; +assert.throws(TypeError, function() { + f.bind(); +}); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-3.js new file mode 100644 index 00000000000..69f4fc90131 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-3.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target + is not callable. +es5id: 15.3.4.5-2-3 +description: Function.prototype.bind allows Target to be a constructor (Number) +---*/ + +var bnc = Number.bind(null); +var n = bnc(42); + +assert.sameValue(n, 42, 'n'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-4.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-4.js new file mode 100644 index 00000000000..48ca298511f --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-4.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target + is not callable. +es5id: 15.3.4.5-2-4 +description: Function.prototype.bind allows Target to be a constructor (String) +---*/ + +var bsc = String.bind(null); +var s = bsc("hello world"); + +assert.sameValue(s, "hello world", 's'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-5.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-5.js new file mode 100644 index 00000000000..699eb768063 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-5.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target + is not callable. +es5id: 15.3.4.5-2-5 +description: Function.prototype.bind allows Target to be a constructor (Boolean) +---*/ + +var bbc = Boolean.bind(null); +var b = bbc(true); + +assert.sameValue(b, true, 'b'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-6.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-6.js new file mode 100644 index 00000000000..b391ac10d1e --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-6.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target + is not callable. +es5id: 15.3.4.5-2-6 +description: Function.prototype.bind allows Target to be a constructor (Object) +---*/ + +var boc = Object.bind(null); +var o = boc(42); + +assert((o == 42), '(o == 42) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-7.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-7.js new file mode 100644 index 00000000000..4efe884855d --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-7.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target + is not callable. +es5id: 15.3.4.5-2-7 +description: > + Function.prototype.bind throws TypeError if the Target is not + callable (JSON) +---*/ + + +assert.throws(TypeError, function() { + JSON.bind(); +}); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-8.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-8.js new file mode 100644 index 00000000000..892b211dec6 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-8.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target + is not callable. +es5id: 15.3.4.5-2-8 +description: Function.prototype.bind allows Target to be a constructor (SendableArray) +---*/ + +var bac = SendableArray.bind(null); +var a = bac(42); +a.prop = "verifyPropertyExist"; +a[41] = 41; + +assert.sameValue(a.prop, "verifyPropertyExist", 'a.prop'); +assert.sameValue(a[41], 41, 'a[41]'); +assert.sameValue(a.length, 42, 'a.length'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-9.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-9.js new file mode 100644 index 00000000000..e0c3a964968 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-9.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-2-9 +description: Function.prototype.bind allows Target to be a constructor (Date) +---*/ + +var bdc = Date.bind(null); +var s = bdc(0, 0, 0); + +assert.sameValue(typeof(s), 'string', 'typeof(s)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-2.js new file mode 100644 index 00000000000..520c7a0a84d --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-2.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-20-2 +description: > + Function.prototype.bind - [[Get]] attribute of 'caller' property + in 'F' is thrower +---*/ + +function foo() {} +var obj = foo.bind({}); + +assert.throws(TypeError, function() { + obj.caller; +}); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-3.js new file mode 100644 index 00000000000..209a92d2304 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-3.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-20-3 +description: > + Function.prototype.bind - [[Set]] attribute of 'caller' property + in 'F' is thrower +---*/ + +function foo() {} +var obj = foo.bind({}); +assert.throws(TypeError, function() { + obj.caller = 12; +}); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-2.js new file mode 100644 index 00000000000..91c39073b5c --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-2.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-21-2 +description: > + Function.prototype.bind - [[Get]] attribute of 'arguments' + property in 'F' is thrower +---*/ + +function foo() {} +var obj = foo.bind({}); + +assert.throws(TypeError, function() { + obj.arguments; +}); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-3.js new file mode 100644 index 00000000000..b8d87880529 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-3.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-21-3 +description: > + Function.prototype.bind - [[Set]] attribute of 'arguments' + property in 'F' is thrower +---*/ + +function foo() {} +var obj = foo.bind({}); +assert.throws(TypeError, function() { + obj.arguments = 12; +}); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-3-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-3-1.js new file mode 100644 index 00000000000..6b76d0886a5 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-3-1.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-3-1 +description: Function.prototype.bind - each arg is defined in A in list order +---*/ + +var foo = function(x, y) { + return new Boolean((x + y) === "ab" && arguments[0] === "a" && + arguments[1] === "b" && arguments.length === 2); +}; + +var obj = foo.bind({}, "a", "b"); + +assert((obj() == true), '(obj() == true) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-1.js new file mode 100644 index 00000000000..af659c714c5 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-1.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-6-1 +description: Function.prototype.bind - F can get own data property +---*/ + +var foo = function() {}; + +var obj = foo.bind({}); +obj.property = 12; + +assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-10.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-10.js new file mode 100644 index 00000000000..a4a5f697dbb --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-10.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-6-10 +description: > + Function.prototype.bind - F can get own accessor property without + a get function that overrides an inherited accessor property +---*/ + +var foo = function() {}; + +var obj = foo.bind({}); + +Object.defineProperty(Function.prototype, "property", { + get: function() { + return 3; + }, + configurable: true +}); + +Object.defineProperty(obj, "property", { + set: function() {} +}); + +assert.sameValue(typeof(obj.property), "undefined", 'typeof (obj.property)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-11.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-11.js new file mode 100644 index 00000000000..92359e51756 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-11.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-6-11 +description: > + Function.prototype.bind - F can get inherited accessor property + without a get function +---*/ + +var foo = function() {}; + +var obj = foo.bind({}); + +Object.defineProperty(Function.prototype, "property", { + set: function() {}, + configurable: true +}); + +assert.sameValue(typeof(obj.property), "undefined", 'typeof (obj.property)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-12.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-12.js new file mode 100644 index 00000000000..12fef88c5db --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-12.js @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-6-12 +description: Function.prototype.bind - F cannot get property which doesn't exist +---*/ + +var foo = function() {}; + +var obj = foo.bind({}); + +assert.sameValue(typeof(obj.property), "undefined", 'typeof (obj.property)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-2.js new file mode 100644 index 00000000000..55d0f14d886 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-2.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-6-2 +description: Function.prototype.bind - F can get inherited data property +---*/ + +var foo = function() {}; + +var obj = foo.bind({}); + +Function.prototype.property = 12; + +assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-3.js new file mode 100644 index 00000000000..684fe12f903 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-3.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-6-3 +description: > + Function.prototype.bind - F can get own data property that + overrides an inherited data property +---*/ + +var foo = function() {}; + +var obj = foo.bind({}); + +Function.prototype.property = 3; +obj.property = 12; + +assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-4.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-4.js new file mode 100644 index 00000000000..daa0e9a8066 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-4.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-6-4 +description: > + Function.prototype.bind - F can get own data property that + overrides an inherited accessor property +---*/ + +var foo = function() {}; + +var obj = foo.bind({}); + +Object.defineProperty(Function.prototype, "property", { + get: function() { + return 3; + }, + configurable: true +}); + +Object.defineProperty(obj, "property", { + value: 12 +}); + +assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-5.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-5.js new file mode 100644 index 00000000000..7605b8c9f0b --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-5.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-6-5 +description: Function.prototype.bind - F can get own accessor property +---*/ + +var foo = function() {}; + +var obj = foo.bind({}); +Object.defineProperty(obj, "property", { + get: function() { + return 12; + } +}); + +assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-6.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-6.js new file mode 100644 index 00000000000..51b233bcd59 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-6.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-6-6 +description: Function.prototype.bind - F can get inherited accessor property +---*/ + +var foo = function() {}; + +var obj = foo.bind({}); + +Object.defineProperty(Function.prototype, "property", { + get: function() { + return 12; + }, + configurable: true +}); + +assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-7.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-7.js new file mode 100644 index 00000000000..0ccfe3d61a8 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-7.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-6-7 +description: > + Function.prototype.bind - F can get own accessor property that + overrides an inherited data property +---*/ + +var foo = function() {}; + +var obj = foo.bind({}); + +Function.prototype.property = 3; +Object.defineProperty(obj, "property", { + get: function() { + return 12; + } +}); + +assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-8.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-8.js new file mode 100644 index 00000000000..f44887ded4c --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-8.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-6-8 +description: > + Function.prototype.bind - F can get own accessor property that + overrides an inherited accessor property +---*/ + +var foo = function() {}; + +var obj = foo.bind({}); + +Object.defineProperty(Function.prototype, "property", { + get: function() { + return 3; + }, + configurable: true +}); + +Object.defineProperty(obj, "property", { + get: function() { + return 12; + } +}); + +assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-9.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-9.js new file mode 100644 index 00000000000..ec883ad4734 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-9.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-6-9 +description: > + Function.prototype.bind - F can get own accessor property without + a get function +---*/ + +var foo = function() {}; + +var obj = foo.bind({}); +Object.defineProperty(obj, "property", { + set: function() {} +}); + +assert(obj.hasOwnProperty("property"), 'obj.hasOwnProperty("property") !== true'); +assert.sameValue(typeof(obj.property), "undefined", 'typeof (obj.property)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-1.js new file mode 100644 index 00000000000..1f31be4a698 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-1.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-8-1 +description: Function.prototype.bind, type of bound function must be 'function' +---*/ + +function foo() {} +var o = {}; + +var bf = foo.bind(o); + +assert.sameValue(typeof(bf), 'function', 'typeof(bf)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-2.js new file mode 100644 index 00000000000..2e2a1800b51 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-2.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-8-2 +description: > + Function.prototype.bind, [[Class]] of bound function must be + 'Function' +---*/ + +function foo() {} +var o = {}; + +var bf = foo.bind(o); +var s = Object.prototype.toString.call(bf); + +assert.sameValue(s, '[object Function]', 's'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-1.js new file mode 100644 index 00000000000..99781a23ef2 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-1.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-9-1 +description: Function.prototype.bind, [[Prototype]] is Function.prototype +---*/ + +function foo() {} +var o = {}; + +var bf = foo.bind(o); + +assert(Function.prototype.isPrototypeOf(bf), 'Function.prototype.isPrototypeOf(bf) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-2.js new file mode 100644 index 00000000000..d059c52fb22 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-2.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5-9-2 +description: > + Function.prototype.bind, [[Prototype]] is Function.prototype + (using getPrototypeOf) +---*/ + +function foo() {} +var o = {}; + +var bf = foo.bind(o); + +assert.sameValue(Object.getPrototypeOf(bf), Function.prototype, 'Object.getPrototypeOf(bf)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-1.js new file mode 100644 index 00000000000..b548d8f3463 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-1.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-1 +description: > + [[Call]] - 'F''s [[BoundArgs]] is used as the former part of + arguments of calling the [[Call]] internal method of 'F''s + [[TargetFunction]] when 'F' is called +---*/ + +var func = function(x, y, z) { + return x + y + z; +}; + +var newFunc = Function.prototype.bind.call(func, {}, "a", "b", "c"); + +assert.sameValue(newFunc(), "abc", 'newFunc()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-10.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-10.js new file mode 100644 index 00000000000..cb4d268dd73 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-10.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-10 +description: > + [[Call]] - length of parameters of 'target' is 1, length of + 'boundArgs' is 0, length of 'ExtraArgs' is 0, and with 'boundThis' +---*/ + +var obj = { + prop: "abc" +}; + +var func = function(x) { + return this === obj && typeof x === "undefined"; +}; + +var newFunc = Function.prototype.bind.call(func, obj); + +assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-11.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-11.js new file mode 100644 index 00000000000..b09975505fb --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-11.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-11 +description: > + [[Call]] - length of parameters of 'target' is 1, length of + 'boundArgs' is 0, length of 'ExtraArgs' is 1, and with 'boundThis' +---*/ + +var obj = { + prop: "abc" +}; + +var func = function(x) { + return this === obj && x === 1 && arguments[0] === 1 && arguments.length === 1 && this.prop === "abc"; +}; + +var newFunc = Function.prototype.bind.call(func, obj); + +assert(newFunc(1), 'newFunc(1) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-12.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-12.js new file mode 100644 index 00000000000..005e2ef740f --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-12.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-12 +description: > + [[Call]] - length of parameters of 'target' is 1, length of + 'boundArgs' is 0, length of 'ExtraArgs' is 2, and with 'boundThis' +---*/ + +var obj = { + prop: "abc" +}; + +var func = function(x) { + return this === obj && x === 1 && arguments[1] === 2 && + arguments[0] === 1 && arguments.length === 2 && this.prop === "abc"; +}; + +var newFunc = Function.prototype.bind.call(func, obj); + +assert(newFunc(1, 2), 'newFunc(1, 2) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-13.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-13.js new file mode 100644 index 00000000000..1bb1b37c9c5 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-13.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-13 +description: > + [[Call]] - length of parameters of 'target' is 1, length of + 'boundArgs' is 1, length of 'ExtraArgs' is 0, and with 'boundThis' +---*/ + +var obj = { + prop: "abc" +}; + +var func = function(x) { + return this === obj && x === 1 && + arguments[0] === 1 && arguments.length === 1 && this.prop === "abc"; +}; + +var newFunc = Function.prototype.bind.call(func, obj, 1); + +assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-14.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-14.js new file mode 100644 index 00000000000..6ca0cd8741a --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-14.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-14 +description: > + [[Call]] - length of parameters of 'target' is 1, length of + 'boundArgs' is 1, length of 'ExtraArgs' is 1, and with 'boundThis' +---*/ + +var obj = { + prop: "abc" +}; + +var func = function(x) { + return this === obj && x === 1 && arguments[1] === 2 && + arguments[0] === 1 && arguments.length === 2 && this.prop === "abc"; +}; + +var newFunc = Function.prototype.bind.call(func, obj, 1); + +assert(newFunc(2), 'newFunc(2) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-15.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-15.js new file mode 100644 index 00000000000..1a34914977e --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-15.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-15 +description: > + [[Call]] - length of parameters of 'target' is 1, length of + 'boundArgs' is 2, length of 'ExtraArgs' is 0, and with 'boundThis' +---*/ + +var obj = { + prop: "abc" +}; + +var func = function(x) { + return this === obj && x === 1 && arguments[1] === 2 && + arguments[0] === 1 && arguments.length === 2 && this.prop === "abc"; +}; + +var newFunc = Function.prototype.bind.call(func, obj, 1, 2); + +assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-2.js new file mode 100644 index 00000000000..8cedefc44cb --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-2.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-2 +description: > + [[Call]] - 'F''s [[BoundThis]] is used as the 'this' value of + calling the [[Call]] internal method of 'F''s [[TargetFunction]] + when 'F' is called +---*/ + +var obj = { + "prop": "a" +}; + +var func = function() { + return this; +}; + +var newFunc = Function.prototype.bind.call(func, obj); + +assert.sameValue(newFunc(), obj, 'newFunc()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-3.js new file mode 100644 index 00000000000..a02eb0ac7bf --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-3.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-3 +description: > + [[Call]] - the provided arguments is used as the latter part of + arguments of calling the [[Call]] internal method of 'F''s + [[TargetFunction]] when 'F' is called +---*/ + +var func = function(x, y, z) { + return z; +}; + +var newFunc = Function.prototype.bind.call(func, {}, "a", "b"); + +assert.sameValue(newFunc("c"), "c", 'newFunc("c")'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-4.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-4.js new file mode 100644 index 00000000000..b60afd86ed5 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-4.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-4 +description: > + [[Call]] - length of parameters of 'target' is 0, length of + 'boundArgs' is 0, length of 'ExtraArgs' is 0, and without + 'boundThis' +---*/ + +var func = function() { + return arguments.length === 0; +}; + +var newFunc = Function.prototype.bind.call(func); + +assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-5.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-5.js new file mode 100644 index 00000000000..e38dff04012 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-5.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-5 +description: > + [[Call]] - length of parameters of 'target' is 0, length of + 'boundArgs' is 0, length of 'ExtraArgs' is 1, and without + 'boundThis' +---*/ + +var func = function() { + return arguments[0] === 1; +}; + +var newFunc = Function.prototype.bind.call(func); + +assert(newFunc(1), 'newFunc(1) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-6.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-6.js new file mode 100644 index 00000000000..f753d148dbd --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-6.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-6 +description: > + [[Call]] - length of parameters of 'target' is 0, length of + 'boundArgs' is 0, length of 'ExtraArgs' is 0, and with 'boundThis' +---*/ + +var obj = { + prop: "abc" +}; + +var func = function() { + return this === obj && arguments.length === 0; +}; + +var newFunc = Function.prototype.bind.call(func, obj); + +assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-7.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-7.js new file mode 100644 index 00000000000..2d01229782e --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-7.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-7 +description: > + [[Call]] - length of parameters of 'target' is 0, length of + 'boundArgs' is 1, length of 'ExtraArgs' is 0, and with 'boundThis' +---*/ + +var obj = { + prop: "abc" +}; + +var func = function() { + return this === obj && arguments[0] === 1; +}; + +var newFunc = Function.prototype.bind.call(func, obj, 1); + +assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-8.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-8.js new file mode 100644 index 00000000000..f9f31984a91 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-8.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-8 +description: > + [[Call]] - length of parameters of 'target' is 0, length of + 'boundArgs' is 0, length of 'ExtraArgs' is 1, and with 'boundThis' +---*/ + +var obj = { + prop: "abc" +}; + +var func = function() { + return this === obj && arguments[0] === 1; +}; + +var newFunc = Function.prototype.bind.call(func, obj); + +assert(newFunc(1), 'newFunc(1) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-9.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-9.js new file mode 100644 index 00000000000..dde2f8e31eb --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-9.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.1-4-9 +description: > + [[Call]] - length of parameters of 'target' is 0, length of + 'boundArgs' is 1, length of 'ExtraArgs' is 1, and with 'boundThis' +---*/ + +var obj = { + prop: "abc" +}; + +var func = function() { + return this === obj && arguments[0] === 1 && arguments[1] === 2; +}; + +var newFunc = Function.prototype.bind.call(func, obj, 1); + +assert(newFunc(2), 'newFunc(2) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-1.js new file mode 100644 index 00000000000..278a45dc1fb --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-1.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.2-4-1 +description: > + [[Construct]] - 'F''s [[BoundArgs]] is used as the former part of + arguments of calling the [[Construct]] internal method of 'F''s + [[TargetFunction]] when 'F' is called as constructor +---*/ + +var func = function(x, y, z) { + var objResult = {}; + objResult.returnValue = x + y + z; + objResult.returnVerifyResult = arguments[0] === "a" && arguments.length === 3; + return objResult; +}; + +var NewFunc = Function.prototype.bind.call(func, {}, "a", "b", "c"); + +var newInstance = new NewFunc(); + +assert(newInstance.hasOwnProperty("returnValue"), 'newInstance.hasOwnProperty("returnValue") !== true'); +assert.sameValue(newInstance.returnValue, "abc", 'newInstance.returnValue'); +assert(newInstance.hasOwnProperty("returnVerifyResult"), 'newInstance.hasOwnProperty("returnVerifyResult") !== true'); +assert.sameValue(newInstance.returnVerifyResult, true, 'newInstance.returnVerifyResult'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-10.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-10.js new file mode 100644 index 00000000000..2afb0d978a1 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-10.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.2-4-10 +description: > + [[Construct]] - length of parameters of 'target' is 1, length of + 'boundArgs' is 0, length of 'ExtraArgs' is 1 +---*/ + +var func = function(x) { + return new Boolean(arguments.length === 1 && x === 1 && arguments[0] === 1); +}; + +var NewFunc = Function.prototype.bind.call(func, {}); + +var newInstance = new NewFunc(1); + +assert.sameValue(newInstance.valueOf(), true, 'newInstance.valueOf()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-11.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-11.js new file mode 100644 index 00000000000..b0f92a3ce22 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-11.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.2-4-11 +description: > + [[Construct]] - length of parameters of 'target' is 1, length of + 'boundArgs' is 0, length of 'ExtraArgs' is 2 +---*/ + +var func = function(x) { + return new Boolean(arguments.length === 2 && x === 1 && arguments[1] === 2 && arguments[0] === 1); +}; + +var NewFunc = Function.prototype.bind.call(func, {}); + +var newInstance = new NewFunc(1, 2); + +assert.sameValue(newInstance.valueOf(), true, 'newInstance.valueOf()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-12.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-12.js new file mode 100644 index 00000000000..01bd24050e9 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-12.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.2-4-12 +description: > + [[Construct]] - length of parameters of 'target' is 1, length of + 'boundArgs' is 1, length of 'ExtraArgs' is 0 +---*/ + +var func = function(x) { + return new Boolean(arguments.length === 1 && x === 1 && arguments[0] === 1); +}; + +var NewFunc = Function.prototype.bind.call(func, {}, 1); + +var newInstance = new NewFunc(); + +assert.sameValue(newInstance.valueOf(), true, 'newInstance.valueOf()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-13.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-13.js new file mode 100644 index 00000000000..80d174ce88b --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-13.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.2-4-13 +description: > + [[Construct]] - length of parameters of 'target' is 1, length of + 'boundArgs' is 1, length of 'ExtraArgs' is 1 +---*/ + +var func = function(x) { + return new Boolean(arguments.length === 2 && x === 1 && arguments[1] === 2 && arguments[0] === 1); +}; + +var NewFunc = Function.prototype.bind.call(func, {}, 1); + +var newInstance = new NewFunc(2); + +assert.sameValue(newInstance.valueOf(), true, 'newInstance.valueOf()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-14.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-14.js new file mode 100644 index 00000000000..013b7b02101 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-14.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.2-4-14 +description: > + [[Construct]] - length of parameters of 'target' is 1, length of + 'boundArgs' is 2, length of 'ExtraArgs' is 0 +---*/ + +var func = function(x) { + return new Boolean(arguments.length === 2 && x === 1 && arguments[1] === 2 && arguments[0] === 1); +}; + +var NewFunc = Function.prototype.bind.call(func, {}, 1, 2); + +var newInstance = new NewFunc(); + +assert.sameValue(newInstance.valueOf(), true, 'newInstance.valueOf()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-2.js new file mode 100644 index 00000000000..7cd139932ba --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-2.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.2-4-2 +description: > + [[Construct]] - the provided arguments is used as the latter part + of arguments of calling the [[Construct]] internal method of 'F''s + [[TargetFunction]] when 'F' is called as constructor +---*/ + +var func = function(x, y, z) { + var objResult = {}; + objResult.returnValue = x + y + z; + objResult.returnVerifyResult = arguments[0] === "a" && arguments.length === 3; + return objResult; +}; + +var NewFunc = Function.prototype.bind.call(func, {}); + +var newInstance = new NewFunc("a", "b", "c"); + +assert(newInstance.hasOwnProperty("returnValue"), 'newInstance.hasOwnProperty("returnValue") !== true'); +assert.sameValue(newInstance.returnValue, "abc", 'newInstance.returnValue'); +assert(newInstance.hasOwnProperty("returnVerifyResult"), 'newInstance.hasOwnProperty("returnVerifyResult") !== true'); +assert.sameValue(newInstance.returnVerifyResult, true, 'newInstance.returnVerifyResult'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-3.js new file mode 100644 index 00000000000..e599ecbeae3 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-3.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.2-4-3 +description: > + [[Construct]] - length of parameters of 'target' is 0, length of + 'boundArgs' is 0, length of 'ExtraArgs' is 0, and without + 'boundThis' +---*/ + +var func = function() { + return new Boolean(arguments.length === 0); +}; + +var NewFunc = Function.prototype.bind.call(func); + +var newInstance = new NewFunc(); + +assert.sameValue(newInstance.valueOf(), true, 'newInstance.valueOf()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-4.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-4.js new file mode 100644 index 00000000000..cd4f3fd9c7c --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-4.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.2-4-4 +description: > + [[Construct]] - length of parameters of 'target' is 0, length of + 'boundArgs' is 0, length of 'ExtraArgs' is 1, and without + 'boundThis' +---*/ + +var func = function() { + return new Boolean(arguments[0] === 1 && arguments.length === 1); +}; + +var NewFunc = Function.prototype.bind.call(func); + +var newInstance = new NewFunc(1); + +assert.sameValue(newInstance.valueOf(), true, 'newInstance.valueOf()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-5.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-5.js new file mode 100644 index 00000000000..4d56686e9f6 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-5.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.2-4-5 +description: > + [[Construct]] - length of parameters of 'target' is 0, length of + 'boundArgs' is 0, length of 'ExtraArgs' is 0, and with 'boundThis' +---*/ + +var obj = { + prop: "abc" +}; + +Object.prototype.verifyThis = "verifyThis"; +var func = function() { + return new Boolean(arguments.length === 0 && Object.prototype.toString.call(this) === "[object Object]" && + this.verifyThis === "verifyThis"); +}; + +var NewFunc = Function.prototype.bind.call(func, obj); + +var newInstance = new NewFunc(); + +assert(newInstance.valueOf(), 'newInstance.valueOf() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-6.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-6.js new file mode 100644 index 00000000000..b85d9c48635 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-6.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.2-4-6 +description: > + [[Construct]] - length of parameters of 'target' is 0, length of + 'boundArgs' is 1, length of 'ExtraArgs' is 0 +---*/ + +var func = function() { + return new Boolean(arguments.length === 1 && arguments[0] === 1); +}; + +var NewFunc = Function.prototype.bind.call(func, {}, 1); + +var newInstance = new NewFunc(); + +assert.sameValue(newInstance.valueOf(), true, 'newInstance.valueOf()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-7.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-7.js new file mode 100644 index 00000000000..a6b7134d47f --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-7.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.2-4-7 +description: > + [[Construct]] - length of parameters of 'target' is 0, length of + 'boundArgs' is 0, length of 'ExtraArgs' is 1 +---*/ + +var func = function() { + return new Boolean(arguments.length === 1 && arguments[0] === 1); +}; + +var NewFunc = Function.prototype.bind.call(func, {}); + +var newInstance = new NewFunc(1); + +assert.sameValue(newInstance.valueOf(), true, 'newInstance.valueOf()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-8.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-8.js new file mode 100644 index 00000000000..95d2908bd3e --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-8.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.2-4-8 +description: > + [[Construct]] - length of parameters of 'target' is 0, length of + 'boundArgs' is 1, length of 'ExtraArgs' is 1 +---*/ + +var func = function() { + return new Boolean(arguments.length === 2 && arguments[0] === 1 && arguments[1] === 2); +}; + +var NewFunc = Function.prototype.bind.call(func, {}, 1); + +var newInstance = new NewFunc(2); + +assert.sameValue(newInstance.valueOf(), true, 'newInstance.valueOf()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-9.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-9.js new file mode 100644 index 00000000000..7a6032ba088 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-9.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5.2-4-9 +description: > + [[Construct]] - length of parameters of 'target' is 1, length of + 'boundArgs' is 0, length of 'ExtraArgs' is 0 +---*/ + +var func = function(x) { + return new Boolean(arguments.length === 0 && typeof x === "undefined"); +}; + +var NewFunc = Function.prototype.bind.call(func, {}); + +var newInstance = new NewFunc(); + +assert.sameValue(newInstance.valueOf(), true, 'newInstance.valueOf()'); diff --git a/test/sendable/builtins/Function/prototype/bind/BoundFunction_restricted-properties.js b/test/sendable/builtins/Function/prototype/bind/BoundFunction_restricted-properties.js new file mode 100644 index 00000000000..4e405be4756 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/BoundFunction_restricted-properties.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +description: > + Functions created using Function.prototype.bind() do not have own + properties "caller" or "arguments", but inherit them from + %FunctionPrototype%. +es6id: 16.1 +---*/ + +function target() {} +var bound = target.bind(null); + +assert.sameValue(bound.hasOwnProperty('caller'), false, 'Functions created using Function.prototype.bind() do not have own property "caller"'); +assert.sameValue(bound.hasOwnProperty('arguments'), false, 'Functions created using Function.prototype.bind() do not have own property "arguments"'); + +assert.throws(TypeError, function() { + return bound.caller; +}); + +assert.throws(TypeError, function() { + bound.caller = {}; +}); + +assert.throws(TypeError, function() { + return bound.arguments; +}); + +assert.throws(TypeError, function() { + bound.arguments = {}; +}); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A1.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A1.js new file mode 100644 index 00000000000..7ffb93b5a36 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A1.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: "\"caller\" of bound function is poisoned (step 20)" +es5id: 15.3.4.5_A1 +description: A bound function should fail to find its "caller" +---*/ + +function foo() { + return bar.caller; +} +var bar = foo.bind({}); + +function baz() { + return bar(); +} + +assert.throws(TypeError, function() { + baz(); +}, 'baz() throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A13.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A13.js new file mode 100644 index 00000000000..fbd72df4017 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A13.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5_A13 +description: If IsCallable(func) is false, then throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + Function.prototype.bind.call(undefined, {}); +}, 'Function.prototype.bind.call(undefined, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A14.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A14.js new file mode 100644 index 00000000000..bb460354743 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A14.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5_A14 +description: If IsCallable(func) is false, then throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + Function.prototype.bind.call(null, {}); +}, 'Function.prototype.bind.call(null, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A15.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A15.js new file mode 100644 index 00000000000..d4ced3fb93d --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A15.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5_A15 +description: If IsCallable(func) is false, then throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + Function.prototype.bind.call({}, {}); +}, 'Function.prototype.bind.call({}, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A16.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A16.js new file mode 100644 index 00000000000..e168e5350af --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A16.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: If IsCallable(func) is false, then throw a TypeError exception. +es5id: 15.3.4.5_A16 +description: > + A RegExp is not a function, but it may be callable. Iff it is, + it's typeof should be 'function', in which case bind should accept + it as a valid this value. +---*/ + +var re = (/x/); +if (typeof re === 'function') { + Function.prototype.bind.call(re, undefined); +} else { + try { + Function.prototype.bind.call(re, undefined); + throw new Test262Error('#1: If IsCallable(func) is false, ' + + 'then (bind should) throw a TypeError exception'); + } catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); + } +} diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A2.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A2.js new file mode 100644 index 00000000000..30578deb756 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A2.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: "\"arguments\" of bound function is poisoned (step 21)" +es5id: 15.3.4.5_A2 +description: a bound function should fail to find the bound function "arguments" +---*/ + +function foo() { + return bar.arguments; +} +var bar = foo.bind({}); + +function baz() { + return bar(); +} + +assert.throws(TypeError, function() { + baz(); +}, 'baz() throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A3.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A3.js new file mode 100644 index 00000000000..5e170ca34ca --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A3.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5_A3 +description: Function.prototype.bind must exist +---*/ +assert( + 'bind' in Function.prototype, + 'The result of evaluating (\'bind\' in Function.prototype) is expected to be true' +); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A4.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A4.js new file mode 100644 index 00000000000..47739305ac4 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A4.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5_A4 +description: > + Function.prototype.bind call the original's internal [[Call]] + method rather than its .apply method. +---*/ + +function foo() {} + +var b = foo.bind(33, 44); +foo.apply = function() { + throw new Test262Error("Function.prototype.bind called original's .apply method"); +}; +b(55, 66); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A5.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A5.js new file mode 100644 index 00000000000..bbb3c367396 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A5.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.5_A5 +description: > + Function.prototype.bind must curry [[Construct]] as well as + [[Call]]. +---*/ + +function construct(f, args) { + var bound = Function.prototype.bind.apply(f, [null].concat(args)); + return new bound(); +} +var d = construct(Date, [1957, 4, 27]); + +assert.sameValue( + Object.prototype.toString.call(d), + '[object Date]', + 'Object.prototype.toString.call(construct(Date, [1957, 4, 27])) must return "[object Date]"' +); diff --git a/test/sendable/builtins/Function/prototype/bind/get-fn-realm-recursive.js b/test/sendable/builtins/Function/prototype/bind/get-fn-realm-recursive.js new file mode 100644 index 00000000000..5cef5269a75 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/get-fn-realm-recursive.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getfunctionrealm +description: > + The realm of a bound function exotic object is the realm of its target function. + GetFunctionRealm is called recursively. +info: | + Object ( [ value ] ) + + 1. If NewTarget is neither undefined nor the active function, then + a. Return ? OrdinaryCreateFromConstructor(NewTarget, "%Object.prototype%"). + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + [...] + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + 3. Return OrdinaryObjectCreate(proto, internalSlotsList). + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. + + GetFunctionRealm ( obj ) + + [...] + 2. If obj has a [[Realm]] internal slot, then + a. Return obj.[[Realm]]. + 3. If obj is a bound function exotic object, then + a. Let target be obj.[[BoundTargetFunction]]. + b. Return ? GetFunctionRealm(target). +features: [cross-realm, Reflect] +---*/ + +var realm1 = $262.createRealm().global; +var realm2 = $262.createRealm().global; +var realm3 = $262.createRealm().global; +var realm4 = $262.createRealm().global; + +var newTarget = new realm1.Function(); +newTarget.prototype = 1; + +var boundNewTarget = realm2.Function.prototype.bind.call(newTarget); +var boundBoundNewTarget = realm3.Function.prototype.bind.call(boundNewTarget); +var object = Reflect.construct(realm4.Object, [], boundBoundNewTarget); + +assert(object instanceof realm1.Object); +assert.sameValue(Object.getPrototypeOf(object), realm1.Object.prototype); diff --git a/test/sendable/builtins/Function/prototype/bind/get-fn-realm.js b/test/sendable/builtins/Function/prototype/bind/get-fn-realm.js new file mode 100644 index 00000000000..6e66a773f47 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/get-fn-realm.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getfunctionrealm +description: > + The realm of a bound function exotic object is the realm of its target function. +info: | + Date ( ) + + [...] + 3. If NewTarget is undefined, then + [...] + 4. Else, + a. Let O be ? OrdinaryCreateFromConstructor(NewTarget, "%Date.prototype%", « [[DateValue]] »). + [...] + c. Return O. + + OrdinaryCreateFromConstructor ( constructor, intrinsicDefaultProto [ , internalSlotsList ] ) + + [...] + 2. Let proto be ? GetPrototypeFromConstructor(constructor, intrinsicDefaultProto). + 3. Return OrdinaryObjectCreate(proto, internalSlotsList). + + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. + + GetFunctionRealm ( obj ) + + [...] + 2. If obj has a [[Realm]] internal slot, then + a. Return obj.[[Realm]]. + 3. If obj is a bound function exotic object, then + a. Let target be obj.[[BoundTargetFunction]]. + b. Return ? GetFunctionRealm(target). +features: [cross-realm, Reflect] +---*/ + +var realm1 = $262.createRealm().global; +var realm2 = $262.createRealm().global; +var realm3 = $262.createRealm().global; + +var newTarget = new realm1.Function(); +newTarget.prototype = "str"; + +var boundNewTarget = realm2.Function.prototype.bind.call(newTarget); +var date = Reflect.construct(realm3.Date, [], boundNewTarget); + +assert(date instanceof realm1.Date); +assert.sameValue(Object.getPrototypeOf(date), realm1.Date.prototype); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-boundtarget-bound.js b/test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-boundtarget-bound.js new file mode 100644 index 00000000000..171f246766e --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-boundtarget-bound.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-bound-function-exotic-objects-construct-argumentslist-newtarget +description: > + The NewTarget value is changed to the target function when the bound function + object is constructed using Reflect.construct and the "bound target" is + specified as the NewTarget value (and the bound target is itself a bound + function) +info: | + [...] + 5. If SameValue(F, newTarget) is true, let newTarget be target. + 6. Return ? Construct(target, args, newTarget). +features: [Reflect, new.target] +---*/ + +var newTarget; +function A() { + newTarget = new.target; +} +var B = A.bind(); +var C = B.bind(); + +var c = Reflect.construct(C, [], B); + +assert.sameValue(newTarget, A); +assert.sameValue(Object.getPrototypeOf(c), A.prototype); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-boundtarget.js b/test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-boundtarget.js new file mode 100644 index 00000000000..8407e746bed --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-boundtarget.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-bound-function-exotic-objects-construct-argumentslist-newtarget +description: > + The NewTarget value is changed to the target function when the bound function + object is constructed using Reflect.construct and the "bound target" is + specified as the NewTarget value +info: | + [...] + 5. If SameValue(F, newTarget) is true, let newTarget be target. + 6. Return ? Construct(target, args, newTarget). +features: [Reflect, new.target] +---*/ + +var newTarget; +function A() { + newTarget = new.target; +} +var B = A.bind(); +var C = B.bind(); + +var c = Reflect.construct(C, [], A); + +assert.sameValue(newTarget, A); +assert.sameValue(Object.getPrototypeOf(c), A.prototype); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-self-new.js b/test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-self-new.js new file mode 100644 index 00000000000..fcf7041173b --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-self-new.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-bound-function-exotic-objects-construct-argumentslist-newtarget +description: > + The NewTarget value is changed to the target function when the bound function + object is constructed using the `new` operator +info: | + [...] + 5. If SameValue(F, newTarget) is true, let newTarget be target. + 6. Return ? Construct(target, args, newTarget). +features: [new.target] +---*/ + +var newTarget; +function A() { + newTarget = new.target; +} +var B = A.bind(); +var C = B.bind(); + +var c = new C(); + +assert.sameValue(newTarget, A); +assert.sameValue(Object.getPrototypeOf(c), A.prototype); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-self-reflect.js b/test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-self-reflect.js new file mode 100644 index 00000000000..c26cf037bf3 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/instance-construct-newtarget-self-reflect.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-bound-function-exotic-objects-construct-argumentslist-newtarget +description: > + The NewTarget value is changed to the target function when the bound function + object is constructed using Reflect.construct and the bound function is + specified as the NewTarget value +info: | + [...] + 5. If SameValue(F, newTarget) is true, let newTarget be target. + 6. Return ? Construct(target, args, newTarget). +features: [Reflect, new.target] +---*/ + +var newTarget; +function A() { + newTarget = new.target; +} +var B = A.bind(); +var C = B.bind(); + +var c = Reflect.construct(C, [], C); + +assert.sameValue(newTarget, A); +assert.sameValue(Object.getPrototypeOf(c), A.prototype); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-default-value.js b/test/sendable/builtins/Function/prototype/bind/instance-length-default-value.js new file mode 100644 index 00000000000..1fa41aa956f --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-default-value.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.bind +description: > + "length" value of a bound function defaults to 0. + Non-own and non-number "length" values of target function are ignored. +info: | + Function.prototype.bind ( thisArg, ...args ) + + [...] + 5. Let targetHasLength be ? HasOwnProperty(Target, "length"). + 6. If targetHasLength is true, then + a. Let targetLen be ? Get(Target, "length"). + b. If Type(targetLen) is not Number, let L be 0. + c. Else, + i. Set targetLen to ! ToInteger(targetLen). + ii. Let L be the larger of 0 and the result of targetLen minus the number of elements of args. + 7. Else, let L be 0. + 8. Perform ! SetFunctionLength(F, L). + [...] +features: [Symbol] +---*/ + +function foo() {} + +Object.defineProperty(foo, "length", {value: undefined}); +assert.sameValue(foo.bind(null, 1).length, 0, "undefined"); + +Object.defineProperty(foo, "length", {value: null}); +assert.sameValue(foo.bind(null, 1).length, 0, "null"); + +Object.defineProperty(foo, "length", {value: true}); +assert.sameValue(foo.bind(null, 1).length, 0, "boolean"); + +Object.defineProperty(foo, "length", {value: "1"}); +assert.sameValue(foo.bind(null, 1).length, 0, "string"); + +Object.defineProperty(foo, "length", {value: Symbol("1")}); +assert.sameValue(foo.bind(null, 1).length, 0, "symbol"); + +Object.defineProperty(foo, "length", {value: new Number(1)}); +assert.sameValue(foo.bind(null, 1).length, 0, "Number object"); + + +function bar() {} +Object.setPrototypeOf(bar, {length: 42}); +assert(delete bar.length); + +var bound = Function.prototype.bind.call(bar, null, 1); +assert.sameValue(bound.length, 0, "not own"); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-exceeds-int32.js b/test/sendable/builtins/Function/prototype/bind/instance-length-exceeds-int32.js new file mode 100644 index 00000000000..a25c3bbe7ce --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-exceeds-int32.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.bind +description: > + The target function length can exceed 2**31-1. +info: | + 19.2.3.2 Function.prototype.bind ( thisArg, ...args ) + + ... + 6. If targetHasLength is true, then + a. Let targetLen be ? Get(Target, "length"). + b. If Type(targetLen) is not Number, let L be 0. + c. Else, + i. Let targetLen be ToInteger(targetLen). + ii. Let L be the larger of 0 and the result of targetLen minus the number of elements of args. + ... + 8. Perform ! SetFunctionLength(F, L). + ... +---*/ + +function f(){} +Object.defineProperty(f, "length", {value: 2147483648}); + +assert.sameValue(f.bind().length, 2147483648); + +Object.defineProperty(f, "length", {value: Number.MAX_SAFE_INTEGER}); +assert.sameValue(f.bind().length, Number.MAX_SAFE_INTEGER); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-prop-desc.js b/test/sendable/builtins/Function/prototype/bind/instance-length-prop-desc.js new file mode 100644 index 00000000000..398da40cf83 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-prop-desc.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.bind +description: > + "length" property of a bound function has correct descriptor. +info: | + Function.prototype.bind ( thisArg, ...args ) + + [...] + 8. Perform ! SetFunctionLength(F, L). + [...] + + SetFunctionLength ( F, length ) + + [...] + 4. Return ! DefinePropertyOrThrow(F, "length", PropertyDescriptor { [[Value]]: + length, [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }). +includes: [propertyHelper.js] +---*/ + +function fn() {} + +verifyProperty(fn.bind(null), "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-remaining-args.js b/test/sendable/builtins/Function/prototype/bind/instance-length-remaining-args.js new file mode 100644 index 00000000000..0002a9e583f --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-remaining-args.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.bind +description: > + "length" value of a bound function is set to remaining number + of arguments expected by target function. Extra arguments are ignored. +info: | + Function.prototype.bind ( thisArg, ...args ) + + [...] + 5. Let targetHasLength be ? HasOwnProperty(Target, "length"). + 6. If targetHasLength is true, then + a. Let targetLen be ? Get(Target, "length"). + b. If Type(targetLen) is not Number, let L be 0. + c. Else, + i. Set targetLen to ! ToInteger(targetLen). + ii. Let L be the larger of 0 and the result of targetLen minus the number of elements of args. + 7. Else, let L be 0. + 8. Perform ! SetFunctionLength(F, L). + [...] +---*/ + +function foo() {} + +assert.sameValue(foo.bind(null).length, 0, '0/0'); +assert.sameValue(foo.bind(null, 1).length, 0, '1/0'); + +function bar(x, y) {} + +assert.sameValue(bar.bind(null).length, 2, '0/2'); +assert.sameValue(bar.bind(null, 1).length, 1, '1/2'); +assert.sameValue(bar.bind(null, 1, 2).length, 0, '2/2'); +assert.sameValue(bar.bind(null, 1, 2, 3).length, 0, '3/2'); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-tointeger.js b/test/sendable/builtins/Function/prototype/bind/instance-length-tointeger.js new file mode 100644 index 00000000000..788c3b92ffe --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-tointeger.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.bind +description: > + "length" value of a bound function is non-negative integer. + ToInteger is performed on "length" value of target function. +info: | + Function.prototype.bind ( thisArg, ...args ) + + [...] + 5. Let targetHasLength be ? HasOwnProperty(Target, "length"). + 6. If targetHasLength is true, then + a. Let targetLen be ? Get(Target, "length"). + b. If Type(targetLen) is Number, then + i. If targetLen is +∞𝔽, set L to +∞. + ii. Else if targetLen is -∞𝔽, set L to 0. + iii. Else, + 1. Let targetLenAsInt be ! ToIntegerOrInfinity(targetLen). + 2. Assert: targetLenAsInt is finite. + 3. Let argCount be the number of elements in args. + 4. Set L to max(targetLenAsInt - argCount, 0). + 7. Perform ! SetFunctionLength(F, L). + [...] + + ToInteger ( argument ) + + 1. Let number be ? ToNumber(argument). + 2. If number is NaN, +0, or -0, return +0. + 3. If number is +∞ or -∞, return number. + 4. Let integer be the Number value that is the same sign as number and whose magnitude is floor(abs(number)). + 5. If integer is -0, return +0. + 6. Return integer. +---*/ + +function fn() {} + +Object.defineProperty(fn, "length", {value: NaN}); +assert.sameValue(fn.bind().length, 0); + +Object.defineProperty(fn, "length", {value: -0}); +assert.sameValue(fn.bind().length, 0); + +Object.defineProperty(fn, "length", {value: Infinity}); +assert.sameValue(fn.bind().length, Infinity, "target length of infinity, zero bound arguments"); +assert.sameValue(fn.bind(0, 0).length, Infinity, "target length of infinity, one bound argument"); + +Object.defineProperty(fn, "length", {value: -Infinity}); +assert.sameValue(fn.bind().length, 0, "target length of negative infinity, zero bound arguments"); +assert.sameValue(fn.bind(0, 0).length, 0, "target length of negative infinity, one bound argument"); + +Object.defineProperty(fn, "length", {value: 3.66}); +assert.sameValue(fn.bind().length, 3); + +Object.defineProperty(fn, "length", {value: -0.77}); +assert.sameValue(fn.bind().length, 0); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-name-chained.js b/test/sendable/builtins/Function/prototype/bind/instance-name-chained.js new file mode 100644 index 00000000000..214eff322b1 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/instance-name-chained.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.2 +description: > + Assignment of function `name` attribute (previously-bound function) +info: | + 12. Let targetName be Get(Target, "name"). + 13. ReturnIfAbrupt(targetName). + 14. If Type(targetName) is not String, let targetName be the empty string. + 15. Perform SetFunctionName(F, targetName, "bound"). +includes: [propertyHelper.js] +---*/ + +var target = Object.defineProperty(function() {}, 'name', { + value: 'target' +}); + +assert.sameValue(target.bind().bind().name, 'bound bound target'); +verifyNotEnumerable(target.bind().bind(), 'name'); +verifyNotWritable(target.bind().bind(), 'name'); +verifyConfigurable(target.bind().bind(), 'name'); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-name-error.js b/test/sendable/builtins/Function/prototype/bind/instance-name-error.js new file mode 100644 index 00000000000..590ca56d07d --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/instance-name-error.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.2 +description: Error thrown when accessing target's `name` property +info: | + 12. Let targetName be Get(Target, "name"). + 13. ReturnIfAbrupt(targetName). +---*/ + +var target = Object.defineProperty(function() {}, 'name', { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + target.bind(); +}); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-name-non-string.js b/test/sendable/builtins/Function/prototype/bind/instance-name-non-string.js new file mode 100644 index 00000000000..8ca121d6950 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/instance-name-non-string.js @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.2 +description: > + Assignment of function `name` attribute (target has non-string name) +info: | + 12. Let targetName be Get(Target, "name"). + 13. ReturnIfAbrupt(targetName). + 14. If Type(targetName) is not String, let targetName be the empty string. + 15. Perform SetFunctionName(F, targetName, "bound"). +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var target; + +target = Object.defineProperty(function() {}, 'name', { + value: undefined +}); + +assert.sameValue(target.bind().name, 'bound '); +verifyNotEnumerable(target.bind(), 'name'); +verifyNotWritable(target.bind(), 'name'); +verifyConfigurable(target.bind(), 'name'); + +target = Object.defineProperty(function() {}, 'name', { + value: null +}); + +assert.sameValue(target.bind().name, 'bound '); +verifyNotEnumerable(target.bind(), 'name'); +verifyNotWritable(target.bind(), 'name'); +verifyConfigurable(target.bind(), 'name'); + +target = Object.defineProperty(function() {}, 'name', { + value: true +}); + +assert.sameValue(target.bind().name, 'bound '); +verifyNotEnumerable(target.bind(), 'name'); +verifyNotWritable(target.bind(), 'name'); +verifyConfigurable(target.bind(), 'name'); + +target = Object.defineProperty(function() {}, 'name', { + value: Symbol('s') +}); + +assert.sameValue(target.bind().name, 'bound '); +verifyNotEnumerable(target.bind(), 'name'); +verifyNotWritable(target.bind(), 'name'); +verifyConfigurable(target.bind(), 'name'); + +target = Object.defineProperty(function() {}, 'name', { + value: 23 +}); + +assert.sameValue(target.bind().name, 'bound '); +verifyNotEnumerable(target.bind(), 'name'); +verifyNotWritable(target.bind(), 'name'); +verifyConfigurable(target.bind(), 'name'); + +target = Object.defineProperty(function() {}, 'name', { + value: {} +}); + +assert.sameValue(target.bind().name, 'bound '); +verifyNotEnumerable(target.bind(), 'name'); +verifyNotWritable(target.bind(), 'name'); +verifyConfigurable(target.bind(), 'name'); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-name.js b/test/sendable/builtins/Function/prototype/bind/instance-name.js new file mode 100644 index 00000000000..a9ba76452b3 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/instance-name.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.2 +description: Assignment of function `name` attribute +info: | + 12. Let targetName be Get(Target, "name"). + 13. ReturnIfAbrupt(targetName). + 14. If Type(targetName) is not String, let targetName be the empty string. + 15. Perform SetFunctionName(F, targetName, "bound"). +includes: [propertyHelper.js] +---*/ + +var target = Object.defineProperty(function() {}, 'name', { + value: 'target' +}); + +assert.sameValue(target.bind().name, 'bound target'); +verifyNotEnumerable(target.bind(), 'name'); +verifyNotWritable(target.bind(), 'name'); +verifyConfigurable(target.bind(), 'name'); diff --git a/test/sendable/builtins/Function/prototype/bind/length.js b/test/sendable/builtins/Function/prototype/bind/length.js new file mode 100644 index 00000000000..4c537fdfa64 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/length.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.bind +description: > + Function.prototype.bind.length is 1. +info: | + Function.prototype.bind ( thisArg, ...args ) + + 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. + Optional parameters (which are indicated with brackets: [ ]) or rest parameters (which + are 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(Function.prototype.bind, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Function/prototype/bind/name.js b/test/sendable/builtins/Function/prototype/bind/name.js new file mode 100644 index 00000000000..c5dcb7c40e4 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/name.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.2 +description: > + Function.prototype.bind.name is "bind". +info: | + Function.prototype.bind ( thisArg , ...args) + + 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(Function.prototype.bind, "name", { + value: "bind", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Function/prototype/bind/not-a-constructor.js b/test/sendable/builtins/Function/prototype/bind/not-a-constructor.js new file mode 100644 index 00000000000..d5d4480ffd5 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Function.prototype.bind 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(Function.prototype.bind), + false, + 'isConstructor(Function.prototype.bind) must return false' +); + +assert.throws(TypeError, () => { + new Function.prototype.bind(); +}); + diff --git a/test/sendable/builtins/Function/prototype/bind/proto-from-ctor-realm.js b/test/sendable/builtins/Function/prototype/bind/proto-from-ctor-realm.js new file mode 100644 index 00000000000..d10b135143b --- /dev/null +++ b/test/sendable/builtins/Function/prototype/bind/proto-from-ctor-realm.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-bound-function-exotic-objects-construct-argumentslist-newtarget +description: Default [[Prototype]] value derived from realm of the constructor +info: | + [...] + 6. Return ? Construct(target, args, newTarget). + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var D = function() {}.bind(); + +var d = Reflect.construct(D, [], C); + +assert.sameValue(Object.getPrototypeOf(d), other.Object.prototype); diff --git a/test/sendable/builtins/Function/prototype/call/15.3.4.4-1-s.js b/test/sendable/builtins/Function/prototype/call/15.3.4.4-1-s.js new file mode 100644 index 00000000000..a76bb82321e --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/15.3.4.4-1-s.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.4-1-s +description: > + Strict Mode - 'this' value is a string which cannot be converted + to wrapper objects when the function is called without an array of + arguments +flags: [onlyStrict] +---*/ + +function fun() { + return (this instanceof String); +} + +assert.sameValue(fun.call(""), false, 'fun.call("")'); diff --git a/test/sendable/builtins/Function/prototype/call/15.3.4.4-2-s.js b/test/sendable/builtins/Function/prototype/call/15.3.4.4-2-s.js new file mode 100644 index 00000000000..8009d5ccd9b --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/15.3.4.4-2-s.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.4-2-s +description: > + Strict Mode - 'this' value is a number which cannot be converted + to wrapper objects when the function is called without an array + argument +flags: [onlyStrict] +---*/ + +function fun() { + return (this instanceof Number); +} + +assert.sameValue(fun.call(-12), false, 'fun.call(-12)'); diff --git a/test/sendable/builtins/Function/prototype/call/15.3.4.4-3-s.js b/test/sendable/builtins/Function/prototype/call/15.3.4.4-3-s.js new file mode 100644 index 00000000000..d13fe92a23c --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/15.3.4.4-3-s.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.4-3-s +description: > + Strict Mode - 'this' value is a boolean which cannot be converted + to wrapper objects when the function is called without an array of + arguments +flags: [onlyStrict] +---*/ + +function fun() { + return (this instanceof Boolean); +} + +assert.sameValue(fun.call(false), false, 'fun.call(false)'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A10.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A10.js new file mode 100644 index 00000000000..7902645d802 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A10.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: The Function.prototype.call.length property has the attribute ReadOnly +es5id: 15.3.4.4_A10 +description: > + Checking if varying the Function.prototype.call.length property + fails +includes: [propertyHelper.js] +---*/ +assert( + Function.prototype.call.hasOwnProperty('length'), + 'Function.prototype.call.hasOwnProperty(\'length\') must return true' +); + +var obj = Function.prototype.call.length; + +verifyNotWritable(Function.prototype.call, "length", null, function() { + return "shifted"; +}); + +assert.sameValue( + Function.prototype.call.length, + obj, + 'The value of Function.prototype.call.length is expected to equal the value of obj' +); + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A11.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A11.js new file mode 100644 index 00000000000..de83c69a007 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A11.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: The Function.prototype.call.length property has the attribute DontEnum +es5id: 15.3.4.4_A11 +description: > + Checking if enumerating the Function.prototype.call.length + property fails +---*/ +assert( + Function.prototype.call.hasOwnProperty('length'), + 'Function.prototype.call.hasOwnProperty(\'length\') must return true' +); + +assert( + !Function.prototype.call.propertyIsEnumerable('length'), + 'The value of !Function.prototype.call.propertyIsEnumerable(\'length\') is expected to be true' +); + +// CHECK#2 +for (var p in Function.prototype.call) { + assert.notSameValue(p, "length", 'The value of p is not "length"'); +} + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A12.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A12.js new file mode 100644 index 00000000000..b6f25a2ee4b --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A12.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Function.prototype.call has not prototype property +es5id: 15.3.4.4_A12 +description: > + Checking if obtaining the prototype property of + Function.prototype.call fails +---*/ +assert.sameValue( + Function.prototype.call.prototype, + undefined, + 'The value of Function.prototype.call.prototype is expected to equal undefined' +); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A13.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A13.js new file mode 100644 index 00000000000..5be30476cb7 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A13.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.4_A13 +description: If IsCallable(func) is false, then throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + Function.prototype.call.call(undefined, {}); +}, 'Function.prototype.call.call(undefined, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A14.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A14.js new file mode 100644 index 00000000000..1b9dad5a51c --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A14.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.4_A14 +description: If IsCallable(func) is false, then throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + Function.prototype.call.call(null, {}); +}, 'Function.prototype.call.call(null, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A15.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A15.js new file mode 100644 index 00000000000..4bc68486bd3 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A15.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.4_A15 +description: If IsCallable(func) is false, then throw a TypeError exception. +---*/ + +assert.throws(TypeError, function() { + Function.prototype.call.call({}, {}); +}, 'Function.prototype.call.call({}, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A16.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A16.js new file mode 100644 index 00000000000..96793333d0a --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A16.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: If IsCallable(func) is false, then throw a TypeError exception. +es5id: 15.3.4.4_A16 +description: > + A RegExp is not a function, but it may be callable. Iff it is, + it's typeof should be 'function', in which case call should accept + it as a valid this value. +---*/ + +var re = (/x/); +if (typeof re === 'function') { + Function.prototype.call.call(re, undefined, 'x'); +} else { + try { + Function.prototype.bind.call(re, undefined); + throw new Test262Error('#1: If IsCallable(func) is false, ' + + 'then (bind should) throw a TypeError exception'); + } catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); + } +} diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T1.js new file mode 100644 index 00000000000..98d9e2a9bd6 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T1.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The call method performs a function call using the [[Call]] property of + the object. If the object does not have a [[Call]] property, a TypeError + exception is thrown +es5id: 15.3.4.4_A1_T1 +description: > + Call "call" method of the object that does not have a [[Call]] + property. Prototype of the object is Function() +---*/ + +var proto = Function(); + +function FACTORY() {} + +FACTORY.prototype = proto; + +var obj = new FACTORY; + +assert.sameValue(typeof obj.call, "function", 'The value of `typeof obj.call` is expected to be "function"'); + +try { + obj.call(); + throw new Test262Error('#2: If the object does not have a [[Call]] property, a TypeError exception is thrown'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T2.js new file mode 100644 index 00000000000..d6c36099f41 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T2.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The call method performs a function call using the [[Call]] property of + the object. If the object does not have a [[Call]] property, a TypeError + exception is thrown +es5id: 15.3.4.4_A1_T2 +description: > + Calling "call" method of the object that does not have a [[Call]] + property. Prototype of the object is Function.prototype +---*/ + +function FACTORY() {} + +FACTORY.prototype = Function.prototype; + +var obj = new FACTORY; + +assert.sameValue(typeof obj.call, "function", 'The value of `typeof obj.call` is expected to be "function"'); + +try { + obj.call(); + throw new Test262Error('#2: If the object does not have a [[Call]] property, a TypeError exception is thrown'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T1.js new file mode 100644 index 00000000000..6c2f2783086 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T1.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: The length property of the call method is 1 +es5id: 15.3.4.4_A2_T1 +description: Checking Function.prototype.call.length +---*/ +assert.sameValue( + typeof Function.prototype.call, + "function", + 'The value of `typeof Function.prototype.call` is expected to be "function"' +); + +assert.notSameValue( + typeof Function.prototype.call.length, + "undefined", + 'The value of typeof Function.prototype.call.length is not "undefined"' +); + +assert.sameValue(Function.prototype.call.length, 1, 'The value of Function.prototype.call.length is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T2.js new file mode 100644 index 00000000000..82ab51d9ddb --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T2.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: The length property of the call method is 1 +es5id: 15.3.4.4_A2_T2 +description: Checking f.call.length, where f is new Function +---*/ + +var f = new Function; + +assert.sameValue(typeof f.call, "function", 'The value of `typeof f.call` is expected to be "function"'); +assert.notSameValue(typeof f.call.length, "undefined", 'The value of typeof f.call.length is not "undefined"'); +assert.sameValue(f.call.length, 1, 'The value of f.call.length is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T1.js new file mode 100644 index 00000000000..0c9c5555236 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T1.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T1 +description: Not any arguments at call function +---*/ + +Function("this.field=\"strawberry\"").call(); + +assert.sameValue(this["field"], "strawberry", 'The value of this["field"] is expected to be "strawberry"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T10.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T10.js new file mode 100644 index 00000000000..f87322f1557 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T10.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T10 +description: Checking by using eval, no any arguments at call function +flags: [noStrict] +---*/ + +eval(" (function(){this.feat=1}).call()"); + +assert.sameValue(this["feat"], 1, 'The value of this["feat"] is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T2.js new file mode 100644 index 00000000000..f21fa54f827 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T2.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T2 +description: Argument at call function is null +---*/ + +Function("this.field=\"green\"").call(null); + +assert.sameValue(this["field"], "green", 'The value of this["field"] is expected to be "green"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T3.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T3.js new file mode 100644 index 00000000000..33e6d74da99 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T3.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T3 +description: Argument at call function is void 0 +---*/ + +Function("this.field=\"battle\"").call(void 0); + +assert.sameValue(this["field"], "battle", 'The value of this["field"] is expected to be "battle"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T4.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T4.js new file mode 100644 index 00000000000..5bae83bbf38 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T4.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T4 +description: Argument at call function is undefined +---*/ + +Function("this.field=\"oil\"").call(undefined); + +assert.sameValue(this["field"], "oil", 'The value of this["field"] is expected to be "oil"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T5.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T5.js new file mode 100644 index 00000000000..c3f5cdf5fbc --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T5.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T5 +description: > + No any arguments at call function and it called inside function + declaration +---*/ + +function FACTORY() { + Function("this.feat=\"in da haus\"").call(); +} + +var obj = new FACTORY; + +assert.sameValue(this["feat"], "in da haus", 'The value of this["feat"] is expected to be "in da haus"'); +assert.sameValue(typeof obj.feat, "undefined", 'The value of `typeof obj.feat` is expected to be "undefined"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T6.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T6.js new file mode 100644 index 00000000000..d346b80661a --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T6.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T6 +description: > + Argument at call function is null and it called inside function + declaration +flags: [noStrict] +---*/ + +function FACTORY() { + (function() { + this.feat = "kamon beyba" + }).call(null); +} + +var obj = new FACTORY; + +assert.sameValue(this["feat"], "kamon beyba", 'The value of this["feat"] is expected to be "kamon beyba"'); +assert.sameValue(typeof obj.feat, "undefined", 'The value of `typeof obj.feat` is expected to be "undefined"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T7.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T7.js new file mode 100644 index 00000000000..3929e5c66a9 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T7.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T7 +description: > + Argument at call function is void 0 and it called inside function + declaration +---*/ + +(function FACTORY() { + Function("this.feat=\"in da haus\"").call(void 0); +})(); + + +assert.sameValue(this["feat"], "in da haus", 'The value of this["feat"] is expected to be "in da haus"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T8.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T8.js new file mode 100644 index 00000000000..8f6ab943478 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T8.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T8 +description: > + Argument at call function is undefined and it called inside + function declaration +flags: [noStrict] +---*/ + +(function FACTORY() { + (function() { + this.feat = "kamon beyba" + }).call(undefined); +})(); + + +assert.sameValue(this["feat"], "kamon beyba", 'The value of this["feat"] is expected to be "kamon beyba"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T9.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T9.js new file mode 100644 index 00000000000..f80eb61f42a --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T9.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is null or undefined, the called function is passed the global + object as the this value +es5id: 15.3.4.4_A3_T9 +description: Checking by using eval, argument at call function is void 0 +---*/ + +eval(" Function(\"this.feat=1\").call(void 0) "); + + +assert.sameValue(this["feat"], 1, 'The value of this["feat"] is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T1.js new file mode 100644 index 00000000000..1511c7518ae --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T1.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T1 +description: thisArg is number +---*/ + +var obj = 1; + +var retobj = Function("this.touched= true; return this;").call(obj); + +assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); +assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T2.js new file mode 100644 index 00000000000..e19886d5cc5 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T2.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T2 +description: thisArg is boolean true +---*/ + +var obj = true; + +var retobj = new Function("this.touched= true; return this;").call(obj); + +assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); +assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T3.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T3.js new file mode 100644 index 00000000000..7af1042d341 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T3.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T3 +description: thisArg is string +flags: [noStrict] +---*/ + +var obj = "soap"; + +var retobj = (function() { + this.touched = true; + return this; +}).call(obj); + +assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); +assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T4.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T4.js new file mode 100644 index 00000000000..50d9fbf2a24 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T4.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T4 +description: thisArg is function variable that return this +flags: [noStrict] +---*/ + +var f = function() { + this.touched = true; + return this; +}; + +var retobj = f.call(obj); + +assert.sameValue(typeof obj, "undefined", 'The value of `typeof obj` is expected to be "undefined"'); +assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); + +var obj; diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T5.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T5.js new file mode 100644 index 00000000000..73ef4bfb5e5 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T5.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T5 +description: thisArg is function variable +---*/ + +var f = function() { + this.touched = true; +}; + +var obj = {}; + +f.call(obj); + +assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T6.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T6.js new file mode 100644 index 00000000000..cc9761fe2c1 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T6.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T6 +description: thisArg is new String() +---*/ + +var obj = new String("soap"); + +(function() { + this.touched = true; +}).call(obj); + +assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T7.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T7.js new file mode 100644 index 00000000000..e016a938b27 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T7.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T7 +description: thisArg is new Number() +---*/ + +var obj = new Number(1); + +Function("this.touched= true;").call(obj); + +assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T8.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T8.js new file mode 100644 index 00000000000..00dad7d2275 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T8.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + If thisArg is not null(defined) the called function is passed + ToObject(thisArg) as the this value +es5id: 15.3.4.4_A5_T8 +description: thisArg is Function() +---*/ + +var obj = Function(); + +new Function("this.touched= true; return this;").call(obj); + +assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T1.js new file mode 100644 index 00000000000..aed8860f9a3 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T1.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T1 +description: Argunemts of call function is (null,[1]) +---*/ + +Function("a1,a2,a3", "this.shifted=a1;").call(null, [1]); + +assert.sameValue( + this["shifted"].constructor, + SendableArray, + 'The value of this["shifted"].constructor is expected to equal the value of SendableArray' +); + +assert.sameValue(this["shifted"].length, 1, 'The value of this["shifted"].length is expected to be 1'); +assert.sameValue(this["shifted"][0], 1, 'The value of this["shifted"][0] is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T10.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T10.js new file mode 100644 index 00000000000..b15f1c286f9 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T10.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T10 +description: > + Argunemts of call function is (empty object, "", arguments,2), + inside function call without declaration used +---*/ + +var obj = {}; + +(function() { + Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(obj, arguments, "", "2"); +})("", 4, 2, "a"); + +assert.sameValue(obj["shifted"], "42", 'The value of obj["shifted"] is expected to be "42"'); + +assert.sameValue( + typeof this["shifted"], + "undefined", + 'The value of `typeof this["shifted"]` is expected to be "undefined"' +); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T2.js new file mode 100644 index 00000000000..f624f6d08ee --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T2.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T2 +description: Argunemts of call function is (null,[3,2,1]) +---*/ + +new Function("a1,a2", "a3", "this.shifted=a1;").call(null, [3, 2, 1]); + +assert.sameValue(this["shifted"].length, 3); + +if ((this["shifted"][0] !== 3) || (this["shifted"][1] !== 2) || (this["shifted"][2] !== 1)) { + throw new Test262Error('#2: The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs a function call using the [[Call]] property of the object'); +} diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T3.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T3.js new file mode 100644 index 00000000000..e03d0d0aa4a --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T3.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T3 +description: > + Argunemts of call function is (empty object, new + SendableArray("nine","inch","nails")) +---*/ + +var i = 0; + +var p = { + toString: function() { + return "a" + (++i); + } +}; + +var obj = {}; + +Function(p, "a2,a3", "this.shifted=a1;").call(obj, new SendableArray("nine", "inch", "nails")); + +assert.sameValue(obj["shifted"].length, 3); + +if ((obj["shifted"][0] !== "nine") || (obj["shifted"][1] !== "inch") || (obj["shifted"][2] !== "nails")) { + throw new Test262Error('#2: The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs a function call using the [[Call]] property of the object'); +} + +if (typeof this["shifted"] !== "undefined") { + throw new Test262Error('#3: The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs a function call using the [[Call]] property of the object'); +} diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T4.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T4.js new file mode 100644 index 00000000000..53a716d4790 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T4.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T4 +description: > + Argunemts of call function is (empty object, ( function(){return + arguments;})("a","b","c","d"),"",2) +---*/ + +var i = 0; + +var p = { + toString: function() { + return "a" + (++i); + } +}; + +var obj = {}; + +new Function(p, p, p, "this.shifted=a3+a2+a1.length;").call(obj, (function() { + return arguments; +})("a", "b", "c", "d"), "", 2); + +assert.sameValue(obj["shifted"], "24", 'The value of obj["shifted"] is expected to be "24"'); + +assert.sameValue( + typeof this["shifted"], + "undefined", + 'The value of `typeof this["shifted"]` is expected to be "undefined"' +); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T5.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T5.js new file mode 100644 index 00000000000..a9574735ba3 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T5.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T5 +description: > + Argunemts of call function is (null, arguments,"",2), inside + function declaration used +---*/ + +function FACTORY() { + Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(null, arguments, "", 2); +} + +var obj = new FACTORY("", 1, 2, "A"); + +assert.sameValue(this["shifted"], "42", 'The value of this["shifted"] is expected to be "42"'); +assert.sameValue(typeof obj.shifted, "undefined", 'The value of `typeof obj.shifted` is expected to be "undefined"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T6.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T6.js new file mode 100644 index 00000000000..32dbb42d262 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T6.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T6 +description: > + Argunemts of call function is (this, arguments,"",2), inside + function declaration used +---*/ + +function FACTORY() { + Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(this, arguments, "", 2); +} + +var obj = new FACTORY("", 4, 2, "A"); + +assert.sameValue(obj["shifted"], "42", 'The value of obj["shifted"] is expected to be "42"'); + +assert.sameValue( + typeof this["shifted"], + "undefined", + 'The value of `typeof this["shifted"]` is expected to be "undefined"' +); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T7.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T7.js new file mode 100644 index 00000000000..8d99956457d --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T7.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T7 +description: > + Argunemts of call function is (null, arguments,"",2), inside + function call without declaration used +---*/ + +(function() { + Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(null, arguments, "", 2); +})("", 1, 2, true); + +assert.sameValue(this["shifted"], "42", 'The value of this["shifted"] is expected to be "42"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T8.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T8.js new file mode 100644 index 00000000000..6ff5b478680 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T8.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T8 +description: > + Argunemts of call function is (this, arguments,"",2), inside + function call without declaration used +---*/ + +(function() { + Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(this, arguments, "", 2); +})("", 4, 2, null); + +assert.sameValue(this["shifted"], "42", 'The value of this["shifted"] is expected to be "42"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T9.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T9.js new file mode 100644 index 00000000000..f564c9e27b3 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T9.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The call method takes one or more arguments, thisArg and (optionally) arg1, arg2 etc, and performs + a function call using the [[Call]] property of the object +es5id: 15.3.4.4_A6_T9 +description: > + Argunemts of call function is (empty object, "", arguments,2), + inside function declaration used +---*/ + +function FACTORY() { + var obj = {}; + Function("a1,a2,a3", "this.shifted=a1+a2.length+a3;").call(obj, "", arguments, 2); + return obj; +} + +var obj = new FACTORY("", 1, 2, void 0); + +assert.sameValue( + typeof this["shifted"], + "undefined", + 'The value of `typeof this["shifted"]` is expected to be "undefined"' +); + +assert.sameValue(obj.shifted, "42", 'The value of obj.shifted is expected to be "42"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T3.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T3.js new file mode 100644 index 00000000000..3e039104d7c --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T3.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Function.prototype.call can't be used as [[Construct]] caller +es5id: 15.3.4.4_A7_T3 +description: Checking if creating "new Function.call" fails +---*/ + +try { + var obj = new Function.call; + throw new Test262Error('#1: Function.prototype.call can\'t be used as [[Construct]] caller'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T4.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T4.js new file mode 100644 index 00000000000..c42f547cb43 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T4.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Function.prototype.call can't be used as [[Construct]] caller +es5id: 15.3.4.4_A7_T4 +description: Checking if creating "new (Function("this.p1=1").call)" fails +---*/ + +try { + var obj = new(Function("this.p1=1").call); + throw new Test262Error('#1: Function.prototype.call can\'t be used as [[Construct]] caller'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T5.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T5.js new file mode 100644 index 00000000000..bd401c1103c --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T5.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Function.prototype.call can't be used as [[Construct]] caller +es5id: 15.3.4.4_A7_T5 +description: Checking if creating "new Function("this.p1=1").call" fails +---*/ + +try { + var FACTORY = Function("this.p1=1").call; + var obj = new FACTORY(); + throw new Test262Error('#1: Function.prototype.call can\'t be used as [[Construct]] caller'); +} catch (e) { + assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); +} diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T6.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T6.js new file mode 100644 index 00000000000..f885cd733bb --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T6.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Function.prototype.call can't be used as [[Construct]] caller +es5id: 15.3.4.4_A7_T6 +description: > + Checking if creating "new (Function("function + f(){this.p1=1;};return f").call())" fails +---*/ + +try { + var obj = new(Function("function f(){this.p1=1;};return f").call()); +} catch (e) { + throw new Test262Error('#1: Function.prototype.call can\'t be used as [[Construct]] caller'); +} + +assert.sameValue(obj.p1, 1, 'The value of obj.p1 is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A9.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A9.js new file mode 100644 index 00000000000..76800583568 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A9.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The Function.prototype.call.length property does not have the attribute + DontDelete +es5id: 15.3.4.4_A9 +description: > + Checking if deleting the Function.prototype.call.length property + fails +---*/ +assert( + Function.prototype.call.hasOwnProperty('length'), + 'Function.prototype.call.hasOwnProperty(\'length\') must return true' +); + +assert( + delete Function.prototype.call.length, + 'The value of delete Function.prototype.call.length is expected to be true' +); + +assert( + !Function.prototype.call.hasOwnProperty('length'), + 'The value of !Function.prototype.call.hasOwnProperty(\'length\') is expected to be true' +); + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/call/name.js b/test/sendable/builtins/Function/prototype/call/name.js new file mode 100644 index 00000000000..b1674bba801 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/name.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3.3 +description: > + Function.prototype.call.name is "call". +info: | + Function.prototype.call (thisArg , ...args) + + 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(Function.prototype.call, "name", { + value: "call", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Function/prototype/call/not-a-constructor.js b/test/sendable/builtins/Function/prototype/call/not-a-constructor.js new file mode 100644 index 00000000000..4c079494dc4 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/call/not-a-constructor.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Function.prototype.call 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(Function.prototype.call), + false, + 'isConstructor(Function.prototype.call) must return false' +); + +assert.throws(TypeError, () => { + new Function.prototype.call(); +}); + +assert.throws(TypeError, () => { + new Function.prototype.call; +}); + +var call = Function.prototype.call; +assert.throws(TypeError, () => { + new call; +}, '`new call()` throws TypeError'); diff --git a/test/sendable/builtins/Function/prototype/constructor/S15.3.4.1_A1_T1.js b/test/sendable/builtins/Function/prototype/constructor/S15.3.4.1_A1_T1.js new file mode 100644 index 00000000000..118d99055c7 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/constructor/S15.3.4.1_A1_T1.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The initial value of Function.prototype.constructor is the built-in + Function constructor +es5id: 15.3.4.1_A1_T1 +description: Checking Function.prototype.constructor +---*/ +assert.sameValue( + Function.prototype.constructor, + Function, + 'The value of Function.prototype.constructor is expected to equal the value of Function' +); diff --git a/test/sendable/builtins/Function/prototype/length.js b/test/sendable/builtins/Function/prototype/length.js new file mode 100644 index 00000000000..718239bc4a6 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/length.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-properties-of-the-function-prototype-object +description: > + Function.prototype.length is 0. +info: | + Properties of the Function Prototype Object + + The Function prototype object: + + [...] + * has a "length" property whose value is 0. + + ECMAScript Standard Built-in Objects + + 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(Function.prototype, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Function/prototype/name.js b/test/sendable/builtins/Function/prototype/name.js new file mode 100644 index 00000000000..f24b6936fa5 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/name.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 19.2.3 +description: FunctionPrototype `name` property +info: | + The value of the name property of the Function prototype object is the + empty String. + + ES6 Section 17: + + 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(Function.prototype, "name", { + value: "", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Function/prototype/property-order.js b/test/sendable/builtins/Function/prototype/property-order.js new file mode 100644 index 00000000000..c389b0b2fb1 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/property-order.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-createbuiltinfunction +description: Function constructor property order +info: | + Set order: "length", "name", ... +---*/ + +var propNames = Object.getOwnPropertyNames(Function.prototype); +var lengthIndex = propNames.indexOf("length"); +var nameIndex = propNames.indexOf("name"); + +assert(lengthIndex >= 0 && nameIndex === lengthIndex + 1, + "The `length` property comes before the `name` property on built-in functions"); diff --git a/test/sendable/builtins/Function/prototype/restricted-property-arguments.js b/test/sendable/builtins/Function/prototype/restricted-property-arguments.js new file mode 100644 index 00000000000..7a6b831ac1d --- /dev/null +++ b/test/sendable/builtins/Function/prototype/restricted-property-arguments.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +description: Intrinsic %FunctionPrototype% has poisoned own property "arguments" +includes: [propertyHelper.js] +es6id: 8.2.2 S12, 9.2.7 +---*/ + +var FunctionPrototype = Function.prototype; + +assert.sameValue(FunctionPrototype.hasOwnProperty('arguments'), true, 'The result of %FunctionPrototype%.hasOwnProperty("arguments") is true'); +var descriptor = Object.getOwnPropertyDescriptor(FunctionPrototype, 'arguments'); +assert.sameValue(typeof descriptor.get, 'function', '%FunctionPrototype%.arguments is an accessor property'); +assert.sameValue(typeof descriptor.set, 'function', '%FunctionPrototype%.arguments is an accessor property'); +assert.sameValue(descriptor.get, descriptor.set, '%FunctionPrototype%.arguments getter/setter are both %ThrowTypeError%'); + +assert.throws(TypeError, function() { + return FunctionPrototype.arguments; +}); + +assert.throws(TypeError, function() { + FunctionPrototype.arguments = {}; +}); + +verifyNotEnumerable(FunctionPrototype, 'arguments'); +verifyConfigurable(FunctionPrototype, 'arguments'); diff --git a/test/sendable/builtins/Function/prototype/restricted-property-caller.js b/test/sendable/builtins/Function/prototype/restricted-property-caller.js new file mode 100644 index 00000000000..496632d7289 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/restricted-property-caller.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +description: Intrinsic %FunctionPrototype% has poisoned own property "caller" +includes: [propertyHelper.js] +es6id: 8.2.2 S12, 9.2.7 +---*/ + +var FunctionPrototype = Function.prototype; + +assert.sameValue(FunctionPrototype.hasOwnProperty('caller'), true, 'The result of %FunctionPrototype%.hasOwnProperty("caller") is true'); + +var descriptor = Object.getOwnPropertyDescriptor(FunctionPrototype, 'caller'); +assert.sameValue(typeof descriptor.get, 'function', '%FunctionPrototype%.caller is an accessor property'); +assert.sameValue(typeof descriptor.set, 'function', '%FunctionPrototype%.caller is an accessor property'); +assert.sameValue(descriptor.get, descriptor.set, '%FunctionPrototype%.caller getter/setter are both %ThrowTypeError%'); + +assert.throws(TypeError, function() { + return FunctionPrototype.caller; +}); + +assert.throws(TypeError, function() { + FunctionPrototype.caller = {}; +}); + +verifyNotEnumerable(FunctionPrototype, 'caller'); +verifyConfigurable(FunctionPrototype, 'caller'); diff --git a/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js b/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js new file mode 100644 index 00000000000..a6c3aff3d18 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +author: Brian Terlson +esid: sec-function.prototype.tostring +description: > + Function.prototype.toString on an async function created with the + AsyncFunction constructor. +features: [async-functions] +includes: [nativeFunctionMatcher.js] +---*/ +async function f() {} +var AsyncFunction = f.constructor; +var g = /* before */AsyncFunction("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */; +assertToStringOrNativeFunction(g, "async function anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js b/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js new file mode 100644 index 00000000000..6e554d2ad23 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + Function.prototype.toString on an async generator created with the + AsyncGenerator constructor. +features: [async-iteration] +includes: [nativeFunctionMatcher.js] +---*/ + +async function* f() {} +var AsyncGenerator = f.constructor; + +var g = /* before */AsyncGenerator("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */; +assertToStringOrNativeFunction(g, "async function* anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/Function.js b/test/sendable/builtins/Function/prototype/toString/Function.js new file mode 100644 index 00000000000..3cf79ce1061 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/Function.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-createdynamicfunction +description: Function.prototype.toString on a function created with the Function constructor +includes: [nativeFunctionMatcher.js] +---*/ + +let f = /* before */Function("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */; + +assertToStringOrNativeFunction(f, "function anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js b/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js new file mode 100644 index 00000000000..849087e1ad1 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-createdynamicfunction +description: Function.prototype.toString on a generator function created with the GeneratorFunction constructor +features: [generators] +includes: [nativeFunctionMatcher.js] +---*/ + +let GeneratorFunction = Object.getPrototypeOf(function*(){}).constructor; +let g = /* before */GeneratorFunction("a", " /* a */ b, c /* b */ //", "/* c */ yield yield; /* d */ //")/* after */; + +assertToStringOrNativeFunction(g, "function* anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ yield yield; /* d */ //\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A10.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A10.js new file mode 100644 index 00000000000..1b6c6d4806e --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A10.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: The Function.prototype.toString.length property has the attribute ReadOnly +es5id: 15.3.4.2_A10 +description: > + Checking if varying the Function.prototype.toString.length + property fails +includes: [propertyHelper.js] +---*/ +assert( + Function.prototype.toString.hasOwnProperty('length'), + 'Function.prototype.toString.hasOwnProperty(\'length\') must return true' +); + +var obj = Function.prototype.toString.length; + +verifyNotWritable(Function.prototype.toString, "length", null, function(){return "shifted";}); + +assert.sameValue( + Function.prototype.toString.length, + obj, + 'The value of Function.prototype.toString.length is expected to equal the value of obj' +); + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A11.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A11.js new file mode 100644 index 00000000000..23ceb4a008a --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A11.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: The length property of the toString method is 0 +es5id: 15.3.4.2_A11 +description: Checking Function.prototype.toString.length +---*/ +assert( + Function.prototype.toString.hasOwnProperty("length"), + 'Function.prototype.toString.hasOwnProperty("length") must return true' +); + +assert.sameValue( + Function.prototype.toString.length, + 0, + 'The value of Function.prototype.toString.length is expected to be 0' +); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A12.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A12.js new file mode 100644 index 00000000000..204c83033ab --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A12.js @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.2_A12 +description: > + The Function.prototype.toString function is not generic; it throws + a TypeError exception if its this value is not a callable object. +---*/ + +assert.throws(TypeError, function() { + Function.prototype.toString.call(undefined); +}, 'Function.prototype.toString.call(undefined) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A13.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A13.js new file mode 100644 index 00000000000..244df4c7b1a --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A13.js @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.2_A13 +description: > + The toString function is not generic; it throws a TypeError + exception if its this value is not a callable object. +---*/ + +assert.throws(TypeError, function() { + Function.prototype.toString.call(null); +}, 'Function.prototype.toString.call(null) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A14.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A14.js new file mode 100644 index 00000000000..43634e466b3 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A14.js @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es5id: 15.3.4.2_A14 +description: > + The toString function is not generic; it throws a TypeError + exception if its this value is not a callable object. +---*/ + +assert.throws(TypeError, function() { + Function.prototype.toString.call({}); +}, 'Function.prototype.toString.call({}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A16.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A16.js new file mode 100644 index 00000000000..be7bb91595a --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A16.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The toString function is not generic; it throws a TypeError exception if + its this value is not a callable object. +es5id: 15.3.4.2_A16 +description: > + The String constructor, given an object, should invoke that + object's toString method as a method, i.e., with its this value + bound to that object. +---*/ + +var obj = {toString: Function.prototype.toString}; + +assert.throws(TypeError, function() { + String(obj); +}, 'String(obj) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A6.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A6.js new file mode 100644 index 00000000000..db288297b10 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A6.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: Function.prototype.toString has not prototype property +es5id: 15.3.4.2_A6 +description: > + Checking if obtaining the prototype property of + Function.prototype.toString fails +---*/ +assert.sameValue( + Function.prototype.toString.prototype, + undefined, + 'The value of Function.prototype.toString.prototype is expected to equal undefined' +); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A8.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A8.js new file mode 100644 index 00000000000..fec5857e673 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A8.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: The Function.prototype.toString.length property has the attribute DontEnum +es5id: 15.3.4.2_A8 +description: > + Checking if enumerating the Function.prototype.toString.length + property fails +---*/ +assert( + Function.prototype.toString.hasOwnProperty('length'), + 'Function.prototype.toString.hasOwnProperty(\'length\') must return true' +); + +assert( + !Function.prototype.toString.propertyIsEnumerable('length'), + 'The value of !Function.prototype.toString.propertyIsEnumerable(\'length\') is expected to be true' +); + +// CHECK#2 +for (var p in Function.prototype.toString){ + assert.notSameValue(p, "length", 'The value of p is not "length"'); +} + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A9.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A9.js new file mode 100644 index 00000000000..06ba3da9c76 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A9.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + The Function.prototype.toString.length property does not have the + attribute DontDelete +es5id: 15.3.4.2_A9 +description: > + Checking if deleting the Function.prototype.toString.length + property fails +---*/ +assert( + Function.prototype.toString.hasOwnProperty('length'), + 'Function.prototype.toString.hasOwnProperty(\'length\') must return true' +); + +assert( + delete Function.prototype.toString.length, + 'The value of delete Function.prototype.toString.length is expected to be true' +); + +assert( + !Function.prototype.toString.hasOwnProperty('length'), + 'The value of !Function.prototype.toString.hasOwnProperty(\'length\') is expected to be true' +); + +// TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/toString/arrow-function.js b/test/sendable/builtins/Function/prototype/toString/arrow-function.js new file mode 100644 index 00000000000..1c22e83b551 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/arrow-function.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-arrow-function-definitions-runtime-semantics-evaluation +description: Function.prototype.toString on an arrow function +includes: [nativeFunctionMatcher.js] +---*/ + +let f = /* before */( /* a */ a /* b */ , /* c */ b /* d */ ) /* e */ => /* f */ { /* g */ ; /* h */ }/* after */; +let g = /* before */( /* a */ ) /* b */ => /* c */ 0/* after */; +let h = /* before */a /* a */ => /* b */ 0/* after */; + +assertToStringOrNativeFunction(f, "( /* a */ a /* b */ , /* c */ b /* d */ ) /* e */ => /* f */ { /* g */ ; /* h */ }"); +assertToStringOrNativeFunction(g, "( /* a */ ) /* b */ => /* c */ 0"); +assertToStringOrNativeFunction(h, "a /* a */ => /* b */ 0"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js b/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js new file mode 100644 index 00000000000..5356c2b1d33 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-async-arrow-function-definitions-runtime-semantics-evaluation +description: Function.prototype.toString on an async arrow function +features: [async-functions] +includes: [nativeFunctionMatcher.js] +---*/ + +let f = /* before */async /* a */ ( /* b */ a /* c */ , /* d */ b /* e */ ) /* f */ => /* g */ { /* h */ ; /* i */ }/* after */; +let g = /* before */async /* a */ ( /* b */ ) /* c */ => /* d */ 0/* after */; +let h = /* before */async /* a */ a /* b */ => /* c */ 0/* after */; + +assertToStringOrNativeFunction(f, "async /* a */ ( /* b */ a /* c */ , /* d */ b /* e */ ) /* f */ => /* g */ { /* h */ ; /* i */ }"); +assertToStringOrNativeFunction(g, "async /* a */ ( /* b */ ) /* c */ => /* d */ 0"); +assertToStringOrNativeFunction(h, "async /* a */ a /* b */ => /* c */ 0"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js b/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js new file mode 100644 index 00000000000..50527c064da --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +author: Brian Terlson +esid: sec-function.prototype.tostring +description: Function.prototype.toString on an async function declaration +features: [async-functions] +includes: [nativeFunctionMatcher.js] +---*/ + +/* before */async function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */ + +assertToStringOrNativeFunction(f, "async function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-function-expression.js b/test/sendable/builtins/Function/prototype/toString/async-function-expression.js new file mode 100644 index 00000000000..5ad4affda6c --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-function-expression.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +author: Brian Terlson +esid: sec-function.prototype.tostring +description: Function.prototype.toString on an async function expression +features: [async-functions] +includes: [nativeFunctionMatcher.js] +---*/ + +let f = /* before */async function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */; +let g = /* before */async function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }/* after */; + +assertToStringOrNativeFunction(f, "async function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); +assertToStringOrNativeFunction(g, "async function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js b/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js new file mode 100644 index 00000000000..bdb65aa6cf9 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: Function.prototype.toString on an async generator declaration +features: [async-iteration] +includes: [nativeFunctionMatcher.js] +---*/ + +/* before */async /* a */ function /* b */ * /* c */ f /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }/* after */ + +assertToStringOrNativeFunction(f, "async /* a */ function /* b */ * /* c */ f /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js b/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js new file mode 100644 index 00000000000..e248714d8bb --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: Function.prototype.toString on an async generator expression +features: [async-iteration] +includes: [nativeFunctionMatcher.js] +---*/ + +let f = /* before */async /* a */ function /* b */ * /* c */ F /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }/* after */; +let g = /* before */async /* a */ function /* b */ * /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }/* after */; + +assertToStringOrNativeFunction(f, "async /* a */ function /* b */ * /* c */ F /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }"); +assertToStringOrNativeFunction(g, "async /* a */ function /* b */ * /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js new file mode 100644 index 00000000000..845bc72a3c3 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: Function.prototype.toString on an async generator method +features: [async-iteration] +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = class { static /* before */async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.f; +let g = class { static /* before */async /* a */ * /* b */ [ /* c */ "g" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.g; +let h = class { static /* before */async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.h; + +assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js new file mode 100644 index 00000000000..8ac58e44c94 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: Function.prototype.toString on an async generator method +features: [async-iteration] +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = class { /* before */async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.prototype.f; +let g = class { /* before */async /* a */ * /* b */ [ /* c */ "g" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.prototype.g; +let h = class { /* before */async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.prototype.h; + +assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js new file mode 100644 index 00000000000..f22f4f2fffd --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: Function.prototype.toString on an async generator method +features: [async-iteration] +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +class F { static /* before */async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ } +class G { static /* before */async /* a */ * /* b */ [ /* c */ "g" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ } +class H { static /* before */async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ } + +let f = F.f; +let g = G.g; +let h = H.h; + +assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js new file mode 100644 index 00000000000..e0a70d8fad3 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: Function.prototype.toString on an async generator method +features: [async-iteration] +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +class F { /* before */async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ } +class G { /* before */async /* a */ * /* b */ [ /* c */ "g" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ } +class H { /* before */async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ } + +let f = F.prototype.f; +let g = G.prototype.g; +let h = H.prototype.h; + +assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js new file mode 100644 index 00000000000..add0a6a937b --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: Function.prototype.toString on an async generator method +features: [async-iteration] +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = { /* before */async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.f; +let g = { /* before */async /* a */ * /* b */ [ /* c */ "g" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.g; +let h = { /* before */async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.h; + +assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js new file mode 100644 index 00000000000..3d90442ffe0 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: Function.prototype.toString on an async method +features: [async-functions] +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = class { static /* before */async f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ }.f; +let g = class { static /* before */async /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.g; +let h = class { static /* before */async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.h; + +assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js new file mode 100644 index 00000000000..5320e5efaec --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: Function.prototype.toString on an async method +features: [async-functions] +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = class { /* before */async f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ }.prototype.f; +let g = class { /* before */async /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.prototype.g; +let h = class { /* before */async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.prototype.h; + +assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js new file mode 100644 index 00000000000..b918aff1806 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: Function.prototype.toString on an async method +features: [async-functions] +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +class F { static /* before */async f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ } +class G { static /* before */async /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ } +class H { static /* before */async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ } + +let f = F.f; +let g = G.g; +let h = H.h; + +assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js new file mode 100644 index 00000000000..97710963040 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: Function.prototype.toString on an async method +features: [async-functions] +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +class F { /* before */async f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ } +class G { /* before */async /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ } +class H { /* before */async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ } + +let f = F.prototype.f; +let g = G.prototype.g; +let h = H.prototype.h; + +assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-object.js b/test/sendable/builtins/Function/prototype/toString/async-method-object.js new file mode 100644 index 00000000000..3b4cc2f902b --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/async-method-object.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +author: Brian Terlson +esid: sec-function.prototype.tostring +description: Function.prototype.toString on an async method +features: [async-functions] +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = { /* before */async f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ }.f; +let g = { /* before */async /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.g; +let h = { /* before */async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.h; + +assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/bound-function.js b/test/sendable/builtins/Function/prototype/toString/bound-function.js new file mode 100644 index 00000000000..be892b19a3e --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/bound-function.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + toString bound function does not throw (bound Function Expression) +info: | + ... + If func is a Bound Function exotic object or a built-in Function object, + then return an implementation-dependent String source code representation + of func. The representation must have the syntax of a NativeFunction + ... +includes: [nativeFunctionMatcher.js] +---*/ + +assertNativeFunction(function() {}.bind({})); diff --git a/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js b/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js new file mode 100644 index 00000000000..83990abb2d1 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + toString of built-in Function object +info: | + ... + If func is a built-in Function object, then return an implementation-dependent String source code representation of func. + The representation must have the syntax of a NativeFunction. + ... + + NativeFunction: + function NativeFunctionAccessor_opt IdentifierName_opt ( FormalParameters ) { [ native code ] } + NativeFunctionAccessor : + get + set + +includes: [nativeFunctionMatcher.js, wellKnownIntrinsicObjects.js] +features: [arrow-function, Reflect, SendableArray.prototype.includes] +---*/ + +const visited = []; +function visit(ns, path) { + if (visited.includes(ns)) { + return; + } + visited.push(ns); + + if (typeof ns === 'function') { + assertNativeFunction(ns, path); + } + if (typeof ns !== 'function' && (typeof ns !== 'object' || ns === null)) { + return; + } + + const descriptors = Object.getOwnPropertyDescriptors(ns); + Reflect.ownKeys(descriptors) + .forEach((name) => { + const desc = descriptors[name]; + const p = typeof name === 'symbol' + ? `${path}[Symbol(${name.description})]` + : `${path}.${name}`; + if ('value' in desc) { + visit(desc.value, p); + } else { + visit(desc.get, p); + visit(desc.set, p); + } + }); +} + +WellKnownIntrinsicObjects.forEach((intrinsic) => { + visit(intrinsic.value, intrinsic.name); +}); +assert.notSameValue(visited.length, 0); diff --git a/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js b/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js new file mode 100644 index 00000000000..7d5ec1398e5 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +description: Function.prototype.toString on a class declaration (with complex heritage) +includes: [nativeFunctionMatcher.js] +---*/ + +/* before */class /* a */ A /* b */ extends /* c */ class /* d */ B /* e */ { /* f */ } /* g */ { /* h */ }/* after */ + +assertToStringOrNativeFunction(A, "class /* a */ A /* b */ extends /* c */ class /* d */ B /* e */ { /* f */ } /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js new file mode 100644 index 00000000000..02458c67ee2 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +description: Function.prototype.toString on a class declaration (explicit constructor) +includes: [nativeFunctionMatcher.js] +---*/ + +/* before */class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }/* after */ + +assertToStringOrNativeFunction(A, "class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }"); + +function B(){} diff --git a/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js new file mode 100644 index 00000000000..c15583e1732 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-runtime-semantics-bindingclassdeclarationevaluation +description: Function.prototype.toString on a class declaration (implicit constructor) +includes: [nativeFunctionMatcher.js] +---*/ + +/* before */class /* a */ A /* b */ { /* c */ }/* after */ +/* before */class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }/* after */ +/* before */class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }/* after */ + +assertToStringOrNativeFunction(A, "class /* a */ A /* b */ { /* c */ }"); +assertToStringOrNativeFunction(B, "class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }"); +assertToStringOrNativeFunction(C, "class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js new file mode 100644 index 00000000000..170c40409af --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-class-definitions-runtime-semantics-evaluation +description: Function.prototype.toString on a class expression (explicit constructor) +includes: [nativeFunctionMatcher.js] +---*/ + +let A = /* before */class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }/* after */; + +assertToStringOrNativeFunction(A, "class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }"); + +function B(){} diff --git a/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js new file mode 100644 index 00000000000..ece2fb2b183 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-class-definitions-runtime-semantics-evaluation +description: Function.prototype.toString on a class expression (implicit constructor) +includes: [nativeFunctionMatcher.js] +---*/ + +let A = /* before */class /* a */ A /* b */ { /* c */ }/* after */; +let B = /* before */class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }/* after */; +let C = /* before */class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }/* after */; + +assertToStringOrNativeFunction(A, "class /* a */ A /* b */ { /* c */ }"); +assertToStringOrNativeFunction(B, "class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }"); +assertToStringOrNativeFunction(C, "class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js b/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js new file mode 100644 index 00000000000..bcd3806a1df --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +description: Function.prototype.toString on a function with a non-simple parameter list +includes: [nativeFunctionMatcher.js] +---*/ + +/* before */function /* a */ f /* b */ ( /* c */ a /* d */ = /* e */ 0 /* f */ , /* g */ { /* h */ b /* i */ = /* j */ 0 /* k */ } /* l */ ) /* m */ { /* n */ }/* after */ + +assertToStringOrNativeFunction(f, "function /* a */ f /* b */ ( /* c */ a /* d */ = /* e */ 0 /* f */ , /* g */ { /* h */ b /* i */ = /* j */ 0 /* k */ } /* l */ ) /* m */ { /* n */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/function-declaration.js b/test/sendable/builtins/Function/prototype/toString/function-declaration.js new file mode 100644 index 00000000000..e80738aacd5 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/function-declaration.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +description: Function.prototype.toString on a function declaration +includes: [nativeFunctionMatcher.js] +---*/ + +/* before */function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */ + +assertToStringOrNativeFunction(f, "function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/function-expression.js b/test/sendable/builtins/Function/prototype/toString/function-expression.js new file mode 100644 index 00000000000..28fb8addd24 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/function-expression.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function-definitions-runtime-semantics-evaluation +description: Function.prototype.toString on a function expression +includes: [nativeFunctionMatcher.js] +---*/ + +let f = /* before */function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */; +let g = /* before */function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }/* after */; + +assertToStringOrNativeFunction(f, "function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); +assertToStringOrNativeFunction(g, "function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js b/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js new file mode 100644 index 00000000000..0fc5084304a --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject +description: Function.prototype.toString on a generator function declaration +includes: [nativeFunctionMatcher.js] +---*/ + +/* before */function /* a */ * /* b */ g /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }/* after */ + +assertToStringOrNativeFunction(g, "function /* a */ * /* b */ g /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js b/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js new file mode 100644 index 00000000000..29b97c739ea --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-generator-function-definitions-runtime-semantics-evaluation +description: Function.prototype.toString on a generator function expression +includes: [nativeFunctionMatcher.js] +---*/ + +let f = /* before */function /* a */ * /* b */ F /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }/* after */ +let g = /* before */function /* a */ * /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */ + +assertToStringOrNativeFunction(f, "function /* a */ * /* b */ F /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); +assertToStringOrNativeFunction(g, "function /* a */ * /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/generator-method.js b/test/sendable/builtins/Function/prototype/toString/generator-method.js new file mode 100644 index 00000000000..39e85cfe50f --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/generator-method.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation +description: Function.prototype.toString on a generator method +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = { /* before */* /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }/* after */ }.f; +let g = { /* before */* /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.g; +let h = { /* before */* /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.h; + +assertToStringOrNativeFunction(f, "* /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeFunction(g, "* /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "* /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js new file mode 100644 index 00000000000..cbdc698209a --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation +description: Function.prototype.toString on a getter (class; static) +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = Object.getOwnPropertyDescriptor(class { static /* before */get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }/* after */ }, "f").get; +let g = Object.getOwnPropertyDescriptor(class { static /* before */get /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }, "g").get; +let h = Object.getOwnPropertyDescriptor(class { static /* before */get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }, "h").get; + +assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js b/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js new file mode 100644 index 00000000000..bcd8d183c18 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation +description: Function.prototype.toString on a getter (class) +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = Object.getOwnPropertyDescriptor(class { /* before */get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }/* after */ }.prototype, "f").get; +let g = Object.getOwnPropertyDescriptor(class { /* before */get /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.prototype, "g").get; +let h = Object.getOwnPropertyDescriptor(class { /* before */get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.prototype, "h").get; + +assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js new file mode 100644 index 00000000000..82a11c80740 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation +description: Function.prototype.toString on a getter (class; static) +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +class F { static /* before */get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }/* after */ } +class G { static /* before */get /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ } +class H { static /* before */get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ } + +let f = Object.getOwnPropertyDescriptor(F, "f").get; +let g = Object.getOwnPropertyDescriptor(G, "g").get; +let h = Object.getOwnPropertyDescriptor(H, "h").get; + +assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js b/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js new file mode 100644 index 00000000000..877aa6ba2e7 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation +description: Function.prototype.toString on a getter (class) +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +class F { /* before */get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }/* after */ } +class G { /* before */get /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ } +class H { /* before */get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ } + +let f = Object.getOwnPropertyDescriptor(F.prototype, "f").get; +let g = Object.getOwnPropertyDescriptor(G.prototype, "g").get; +let h = Object.getOwnPropertyDescriptor(H.prototype, "h").get; + +assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-object.js b/test/sendable/builtins/Function/prototype/toString/getter-object.js new file mode 100644 index 00000000000..cc9522e36b0 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/getter-object.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation +description: Function.prototype.toString on a getter (object) +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = Object.getOwnPropertyDescriptor({ /* before */get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }/* after */ }, "f").get; +let g = Object.getOwnPropertyDescriptor({ /* before */get /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }, "g").get; +let h = Object.getOwnPropertyDescriptor({ /* before */get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }, "h").get; + +assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js new file mode 100644 index 00000000000..298627e49ad --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +description: Function.prototype.toString line terminator normalisation (CR-LF) +info: | + Function.prototype.toString should not normalise line terminator sequences to Line Feed characters. + This file uses (Carriage Return, Line Feed) sequences as line terminators. +includes: [nativeFunctionMatcher.js] +---*/ + +// before +function +// a +f +// b +( +// c +x +// d +, +// e +y +// f +) +// g +{ +// h +; +// i +; +// j +} +// after + +assertToStringOrNativeFunction(f, "function\r\n// a\r\nf\r\n// b\r\n(\r\n// c\r\nx\r\n// d\r\n,\r\n// e\r\ny\r\n// f\r\n)\r\n// g\r\n{\r\n// h\r\n;\r\n// i\r\n;\r\n// j\r\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js new file mode 100644 index 00000000000..492c0436e89 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +description: Function.prototype.toString line terminator normalisation (CR) +info: | + Function.prototype.toString should not normalise line terminator sequences to Line Feed characters. + This file uses Carriage Return characters as line terminators. +includes: [nativeFunctionMatcher.js] +---*/ + +// before +function +// a +f +// b +( +// c +x +// d +, +// e +y +// f +) +// g +{ +// h +; +// i +; +// j +} +// after + +assertToStringOrNativeFunction(f, "function\r// a\rf\r// b\r(\r// c\rx\r// d\r,\r// e\ry\r// f\r)\r// g\r{\r// h\r;\r// i\r;\r// j\r}"); diff --git a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js new file mode 100644 index 00000000000..986d050e75d --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject +description: Function.prototype.toString line terminator normalisation (LF) +info: | + Function.prototype.toString should not normalise line terminator sequences to Line Feed characters. + This file uses Line Feed characters as line terminators. +includes: [nativeFunctionMatcher.js] +---*/ + +// before +function +// a +f +// b +( +// c +x +// d +, +// e +y +// f +) +// g +{ +// h +; +// i +; +// j +} +// after + +assertToStringOrNativeFunction(f, "function\n// a\nf\n// b\n(\n// c\nx\n// d\n,\n// e\ny\n// f\n)\n// g\n{\n// h\n;\n// i\n;\n// j\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js new file mode 100644 index 00000000000..08d5bb75859 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-runtime-semantics-definemethod +description: Function.prototype.toString on a method (class; static) +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = class { static /* before */f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ }.f; +let g = class { static /* before */[ /* a */ "g" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.g; +let h = class { static /* before */[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.h; + +assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/method-class-expression.js new file mode 100644 index 00000000000..ce8d5470f61 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/method-class-expression.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-runtime-semantics-definemethod +description: Function.prototype.toString on a method (class) +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = class { /* before */f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ }.prototype.f; +let g = class { /* before */[ /* a */ "g" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.prototype.g; +let h = class { /* before */[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.prototype.h; + +assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js new file mode 100644 index 00000000000..69202c5d409 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-runtime-semantics-definemethod +description: Function.prototype.toString on a method (class; static) +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +class F { static /* before */f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ } +class G { static /* before */[ /* a */ "g" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ } +class H { static /* before */[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ } + +let f = F.f; +let g = G.g; +let h = H.h; + +assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/method-class-statement.js new file mode 100644 index 00000000000..8f6d3b1ca29 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/method-class-statement.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-runtime-semantics-definemethod +description: Function.prototype.toString on a method (class) +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +class F { /* before */f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ } +class G { /* before */[ /* a */ "g" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ } +class H { /* before */[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ } + +let f = F.prototype.f; +let g = G.prototype.g; +let h = H.prototype.h; + +assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js b/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js new file mode 100644 index 00000000000..df8e7ad32a0 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-runtime-semantics-definemethod +description: Function.prototype.toString on a method (object) +includes: [nativeFunctionMatcher.js] +---*/ + +let f = { /* before */[ /* a */ "f" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.f; +let g = { [ { a(){} }.a ](){ } }["a(){}"]; + +assertToStringOrNativeFunction(f, "[ /* a */ \"f\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "[ { a(){} }.a ](){ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-object.js b/test/sendable/builtins/Function/prototype/toString/method-object.js new file mode 100644 index 00000000000..db2de062d38 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/method-object.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-runtime-semantics-definemethod +description: Function.prototype.toString on a method (object) +includes: [nativeFunctionMatcher.js] +---*/ + +let f = { /* before */f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ }.f; + +assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/name.js b/test/sendable/builtins/Function/prototype/toString/name.js new file mode 100644 index 00000000000..a62b977e277 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/name.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + Function.prototype.toString.name is "toString". +info: | + Function.prototype.toString ( ) + + 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(Function.prototype.toString, "name", { + value: "toString", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Function/prototype/toString/not-a-constructor.js b/test/sendable/builtins/Function/prototype/toString/not-a-constructor.js new file mode 100644 index 00000000000..85bfa4d7020 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/not-a-constructor.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Function.prototype.toString 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(Function.prototype.toString), + false, + 'isConstructor(Function.prototype.toString) must return false' +); + +assert.throws(TypeError, () => { + new Function.prototype.toString(); +}); + +var toString = Function.prototype.toString; +assert.throws(TypeError, () => { + new toString; +}); diff --git a/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js new file mode 100644 index 00000000000..a630d2ecfa6 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +description: Function.prototype.toString on a private method +features: [class-methods-private] +includes: [nativeFunctionMatcher.js] +---*/ + +let c = new (class { + /* before */#f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ + assert(expected) { + assertToStringOrNativeFunction(this.#f, expected); + } +}); + +c.assert("#f /* a */ ( /* b */ ) /* c */ { /* d */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js new file mode 100644 index 00000000000..09f82858240 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +description: Function.prototype.toString on a private method +features: [class-methods-private] +includes: [nativeFunctionMatcher.js] +---*/ + +class C { + /* before */#f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ + assert(expected) { + assertToStringOrNativeFunction(this.#f, expected); + } +} + +let c = new C(); +c.assert("#f /* a */ ( /* b */ ) /* c */ { /* d */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js new file mode 100644 index 00000000000..147df7f3dc7 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +description: Function.prototype.toString on a static private method +features: [class-static-methods-private] +includes: [nativeFunctionMatcher.js] +---*/ + +let C = class { + /* before */static #f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ + static assert(expected) { + assertToStringOrNativeFunction(this.#f, expected); + } +}; + +C.assert("#f /* a */ ( /* b */ ) /* c */ { /* d */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js new file mode 100644 index 00000000000..b2ba3a7aedf --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +description: Function.prototype.toString on a static private method +features: [class-static-methods-private] +includes: [nativeFunctionMatcher.js] +---*/ + +class C { + /* before */static #f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ + static assert(expected) { + assertToStringOrNativeFunction(this.#f, expected); + } +} + +C.assert("#f /* a */ ( /* b */ ) /* c */ { /* d */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js new file mode 100644 index 00000000000..f083c626f1c --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + toString of Proxy for function target does not throw (Arrow Function) +info: | + ... + If Type(func) is Object and IsCallable(func) is true, then return an + implementation-dependent String source code representation of func. + The representation must have the syntax of a NativeFunction. + ... + + NativeFunction: + function IdentifierName_opt ( FormalParameters ) { [ native code ] } + +features: [arrow-function, Proxy] +includes: [nativeFunctionMatcher.js] +---*/ + +assertNativeFunction(new Proxy(() => {}, {})); +assertNativeFunction(new Proxy(() => {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js new file mode 100644 index 00000000000..52116dd0d0a --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + toString of Proxy for function target does not throw (Async Function Expression) +info: | + ... + If Type(func) is Object and IsCallable(func) is true, then return an + implementation-dependent String source code representation of func. + The representation must have the syntax of a NativeFunction. + ... + + NativeFunction: + function IdentifierName_opt ( FormalParameters ) { [ native code ] } + +features: [async-functions, Proxy] +includes: [nativeFunctionMatcher.js] +---*/ + +assertNativeFunction(new Proxy(async function() {}, {})); +assertNativeFunction(new Proxy(async function() {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js new file mode 100644 index 00000000000..100cb345a40 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + toString of Proxy for function target does not throw (Async Generator Function Expression) +info: | + ... + If Type(func) is Object and IsCallable(func) is true, then return an + implementation-dependent String source code representation of func. + The representation must have the syntax of a NativeFunction. + ... + + NativeFunction: + function IdentifierName_opt ( FormalParameters ) { [ native code ] } + +features: [async-iteration, Proxy] +includes: [nativeFunctionMatcher.js] +---*/ + +assertNativeFunction(new Proxy(async function * () {}, {})); +assertNativeFunction(new Proxy(async function * () {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-method-definition.js b/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-method-definition.js new file mode 100644 index 00000000000..08c8fc77392 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-method-definition.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + toString of Proxy for function target does not throw (Async Generator Method Definition) +info: | + ... + If Type(func) is Object and IsCallable(func) is true, then return an + implementation-dependent String source code representation of func. + The representation must have the syntax of a NativeFunction. + ... + + NativeFunction: + function IdentifierName_opt ( FormalParameters ) { [ native code ] } + +features: [async-iteration, Proxy] +includes: [nativeFunctionMatcher.js] +---*/ + +assertNativeFunction(new Proxy({ async * method() {} }.method, {})); +assertNativeFunction(new Proxy({ async * method() {} }.method, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-async-method-definition.js b/test/sendable/builtins/Function/prototype/toString/proxy-async-method-definition.js new file mode 100644 index 00000000000..0222908cb62 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/proxy-async-method-definition.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + toString of Proxy for function target does not throw (Async Method Definition) +info: | + ... + If Type(func) is Object and IsCallable(func) is true, then return an + implementation-dependent String source code representation of func. + The representation must have the syntax of a NativeFunction. + ... + + NativeFunction: + function IdentifierName_opt ( FormalParameters ) { [ native code ] } + +features: [async-functions, Proxy] +includes: [nativeFunctionMatcher.js] +---*/ + +assertNativeFunction(new Proxy({ async method() {} }.method, {})); +assertNativeFunction(new Proxy({ async method() {} }.method, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js new file mode 100644 index 00000000000..56269712a95 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + toString of Proxy for function target does not throw (bound Function Expression) +info: | + ... + If Type(func) is Object and IsCallable(func) is true, then return an + implementation-dependent String source code representation of func. + The representation must have the syntax of a NativeFunction. + ... + + NativeFunction: + function IdentifierName_opt ( FormalParameters ) { [ native code ] } + +features: [Proxy] +includes: [nativeFunctionMatcher.js] +---*/ + +assertNativeFunction(new Proxy(function() {}.bind({}), {})); +assertNativeFunction(new Proxy(function() {}.bind({}), { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-class.js b/test/sendable/builtins/Function/prototype/toString/proxy-class.js new file mode 100644 index 00000000000..b038ec8f373 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/proxy-class.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + toString of Proxy for function target does not throw (Class Expression) +info: | + ... + If Type(func) is Object and IsCallable(func) is true, then return an + implementation-dependent String source code representation of func. + The representation must have the syntax of a NativeFunction. + ... + + NativeFunction: + function IdentifierName_opt ( FormalParameters ) { [ native code ] } + +features: [class, Proxy] +includes: [nativeFunctionMatcher.js] +---*/ + +assertNativeFunction(new Proxy(class {}, {})); +assertNativeFunction(new Proxy(class {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js b/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js new file mode 100644 index 00000000000..1acd12f5d2c --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + toString of Proxy for function target does not throw (Function Expression) +info: | + ... + If Type(func) is Object and IsCallable(func) is true, then return an + implementation-dependent String source code representation of func. + The representation must have the syntax of a NativeFunction. + ... + + NativeFunction: + function IdentifierName_opt ( FormalParameters ) { [ native code ] } + +features: [Proxy] +includes: [nativeFunctionMatcher.js] +---*/ + +assertNativeFunction(new Proxy(function() {}, {})); +assertNativeFunction(new Proxy(function() {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js new file mode 100644 index 00000000000..41d5e1516cf --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + toString of Proxy for function target does not throw (Generator Function Expression) +info: | + ... + If Type(func) is Object and IsCallable(func) is true, then return an + implementation-dependent String source code representation of func. + The representation must have the syntax of a NativeFunction. + ... + + NativeFunction: + function IdentifierName_opt ( FormalParameters ) { [ native code ] } + +features: [generators, Proxy] +includes: [nativeFunctionMatcher.js] +---*/ + +assertNativeFunction(new Proxy(function * () {}, {})); +assertNativeFunction(new Proxy(function * () {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-method-definition.js b/test/sendable/builtins/Function/prototype/toString/proxy-method-definition.js new file mode 100644 index 00000000000..5e26b894340 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/proxy-method-definition.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + toString of Proxy for function target does not throw (Method Definition) +info: | + ... + If Type(func) is Object and IsCallable(func) is true, then return an + implementation-dependent String source code representation of func. + The representation must have the syntax of a NativeFunction. + ... + + NativeFunction: + function IdentifierName_opt ( FormalParameters ) { [ native code ] } + +features: [Proxy] +includes: [nativeFunctionMatcher.js] +---*/ + +assertNativeFunction(new Proxy({ method() {} }.method, {})); +assertNativeFunction(new Proxy({ method() {} }.method, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-non-callable-throws.js b/test/sendable/builtins/Function/prototype/toString/proxy-non-callable-throws.js new file mode 100644 index 00000000000..a13d57f87d1 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/proxy-non-callable-throws.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: > + toString of Proxy for non-callable target throws +info: | + ... + Throw a TypeError exception. + +features: [Proxy] +---*/ + +assert.throws(TypeError, function() { + Function.prototype.toString.call(new Proxy({}, {})); +}); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js new file mode 100644 index 00000000000..c78825bfc01 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation +description: Function.prototype.toString on a setter (class; static) +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = Object.getOwnPropertyDescriptor(class { static /* before */set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }/* after */ }, "f").set; +let g = Object.getOwnPropertyDescriptor(class { static /* before */set /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }, "g").set; +let h = Object.getOwnPropertyDescriptor(class { static /* before */set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }, "h").set; + +assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js b/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js new file mode 100644 index 00000000000..ec8518c3808 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation +description: Function.prototype.toString on a setter (class) +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = Object.getOwnPropertyDescriptor(class { /* before */set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }/* after */ }.prototype, "f").set; +let g = Object.getOwnPropertyDescriptor(class { /* before */set /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }.prototype, "g").set; +let h = Object.getOwnPropertyDescriptor(class { /* before */set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }.prototype, "h").set; + +assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js new file mode 100644 index 00000000000..2edc358744e --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation +description: Function.prototype.toString on a setter (class; static) +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +class F { static /* before */set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }/* after */ } +class G { static /* before */set /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ } +class H { static /* before */set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ } + +let f = Object.getOwnPropertyDescriptor(F, "f").set; +let g = Object.getOwnPropertyDescriptor(G, "g").set; +let h = Object.getOwnPropertyDescriptor(H, "h").set; + +assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js b/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js new file mode 100644 index 00000000000..ca66f7f257f --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation +description: Function.prototype.toString on a setter (class) +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +class F { /* before */set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }/* after */ } +class G { /* before */set /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ } +class H { /* before */set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ } + +let f = Object.getOwnPropertyDescriptor(F.prototype, "f").set; +let g = Object.getOwnPropertyDescriptor(G.prototype, "g").set; +let h = Object.getOwnPropertyDescriptor(H.prototype, "h").set; + +assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-object.js b/test/sendable/builtins/Function/prototype/toString/setter-object.js new file mode 100644 index 00000000000..18742d81a4d --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/setter-object.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation +description: Function.prototype.toString on a setter (object) +includes: [nativeFunctionMatcher.js] +---*/ + +let x = "h"; +let f = Object.getOwnPropertyDescriptor({ /* before */set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }/* after */ }, "f").set; +let g = Object.getOwnPropertyDescriptor({ /* before */set /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }, "g").set; +let h = Object.getOwnPropertyDescriptor({ /* before */set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }, "h").set; + +assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js b/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js new file mode 100644 index 00000000000..15f95f2afe8 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: Function.prototype.toString on symbol-named built-ins +includes: [nativeFunctionMatcher.js] +---*/ + +assertNativeFunction(RegExp.prototype[Symbol.match]); +assertNativeFunction(Object.getOwnPropertyDescriptor(RegExp, Symbol.species).get); diff --git a/test/sendable/builtins/Function/prototype/toString/unicode.js b/test/sendable/builtins/Function/prototype/toString/unicode.js new file mode 100644 index 00000000000..8352ec14615 --- /dev/null +++ b/test/sendable/builtins/Function/prototype/toString/unicode.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-function.prototype.tostring +description: Function.prototype.toString on a function with Unicode escape sequences +info: | + Function.prototype.toString returns a slice of the source text before + any potential Unicode escape sequence substitution in identifiers +includes: [nativeFunctionMatcher.js] +---*/ + +function \u0061(\u{62}, \u0063) { \u0062 = \u{00063}; return b; } + +assertToStringOrNativeFunction(a, "function \\u0061(\\u{62}, \\u0063) { \\u0062 = \\u{00063}; return b; }"); -- Gitee From d0a9c01f0c6ae7eea0e6b591ec5ae3ee6baf2714 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 26 Dec 2024 09:58:14 +0800 Subject: [PATCH 43/93] add array-includes Signed-off-by: zhuzhihui7 --- .../prototype/includes/call-with-boolean.js | 26 ++++ .../coerced-searchelement-fromindex-resize.js | 96 ++++++++++++++ ...x-equal-or-greater-length-returns-false.js | 25 ++++ .../prototype/includes/fromIndex-infinity.js | 33 +++++ .../includes/fromIndex-minus-zero.js | 26 ++++ .../Array/prototype/includes/get-prop.js | 46 +++++++ .../prototype/includes/length-boundaries.js | 73 +++++++++++ .../includes/length-zero-returns-false.js | 33 +++++ .../Array/prototype/includes/length.js | 40 ++++++ .../builtins/Array/prototype/includes/name.js | 37 ++++++ .../Array/prototype/includes/no-arg.js | 28 +++++ .../prototype/includes/not-a-constructor.js | 39 ++++++ .../Array/prototype/includes/prop-desc.js | 31 +++++ .../resizable-buffer-special-float-values.js | 34 +++++ .../prototype/includes/resizable-buffer.js | 118 ++++++++++++++++++ .../includes/return-abrupt-get-length.js | 29 +++++ .../includes/return-abrupt-get-prop.js | 40 ++++++ ...eturn-abrupt-tointeger-fromindex-symbol.js | 29 +++++ .../return-abrupt-tointeger-fromindex.js | 33 +++++ .../return-abrupt-tonumber-length-symbol.js | 29 +++++ .../includes/return-abrupt-tonumber-length.js | 43 +++++++ .../Array/prototype/includes/samevaluezero.js | 36 ++++++ .../includes/search-found-returns-true.js | 47 +++++++ .../search-not-found-returns-false.js | 46 +++++++ .../Array/prototype/includes/sparse.js | 48 +++++++ .../prototype/includes/this-is-not-object.js | 28 +++++ .../prototype/includes/tointeger-fromindex.js | 45 +++++++ .../prototype/includes/tolength-length.js | 71 +++++++++++ .../prototype/includes/using-fromindex.js | 45 +++++++ .../includes/values-are-not-cached.js | 47 +++++++ 30 files changed, 1301 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/includes/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/includes/coerced-searchelement-fromindex-resize.js create mode 100644 test/sendable/builtins/Array/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js create mode 100644 test/sendable/builtins/Array/prototype/includes/fromIndex-infinity.js create mode 100644 test/sendable/builtins/Array/prototype/includes/fromIndex-minus-zero.js create mode 100644 test/sendable/builtins/Array/prototype/includes/get-prop.js create mode 100644 test/sendable/builtins/Array/prototype/includes/length-boundaries.js create mode 100644 test/sendable/builtins/Array/prototype/includes/length-zero-returns-false.js create mode 100644 test/sendable/builtins/Array/prototype/includes/length.js create mode 100644 test/sendable/builtins/Array/prototype/includes/name.js create mode 100644 test/sendable/builtins/Array/prototype/includes/no-arg.js create mode 100644 test/sendable/builtins/Array/prototype/includes/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/includes/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/includes/resizable-buffer-special-float-values.js create mode 100644 test/sendable/builtins/Array/prototype/includes/resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/includes/return-abrupt-get-length.js create mode 100644 test/sendable/builtins/Array/prototype/includes/return-abrupt-get-prop.js create mode 100644 test/sendable/builtins/Array/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js create mode 100644 test/sendable/builtins/Array/prototype/includes/return-abrupt-tointeger-fromindex.js create mode 100644 test/sendable/builtins/Array/prototype/includes/return-abrupt-tonumber-length-symbol.js create mode 100644 test/sendable/builtins/Array/prototype/includes/return-abrupt-tonumber-length.js create mode 100644 test/sendable/builtins/Array/prototype/includes/samevaluezero.js create mode 100644 test/sendable/builtins/Array/prototype/includes/search-found-returns-true.js create mode 100644 test/sendable/builtins/Array/prototype/includes/search-not-found-returns-false.js create mode 100644 test/sendable/builtins/Array/prototype/includes/sparse.js create mode 100644 test/sendable/builtins/Array/prototype/includes/this-is-not-object.js create mode 100644 test/sendable/builtins/Array/prototype/includes/tointeger-fromindex.js create mode 100644 test/sendable/builtins/Array/prototype/includes/tolength-length.js create mode 100644 test/sendable/builtins/Array/prototype/includes/using-fromindex.js create mode 100644 test/sendable/builtins/Array/prototype/includes/values-are-not-cached.js diff --git a/test/sendable/builtins/Array/prototype/includes/call-with-boolean.js b/test/sendable/builtins/Array/prototype/includes/call-with-boolean.js new file mode 100644 index 00000000000..44e21ea5086 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/call-with-boolean.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: Array.prototype.includes applied to boolean primitive +features: [Array.prototype.includes] +---*/ + +assert.sameValue(SendableArray.prototype.includes.call(true), false, 'SendableArray.prototype.includes.call(true) must return false'); +assert.sameValue( + SendableArray.prototype.includes.call(false), + false, + 'SendableArray.prototype.includes.call(false) must return false' +); diff --git a/test/sendable/builtins/Array/prototype/includes/coerced-searchelement-fromindex-resize.js b/test/sendable/builtins/Array/prototype/includes/coerced-searchelement-fromindex-resize.js new file mode 100644 index 00000000000..6a983261975 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/coerced-searchelement-fromindex-resize.js @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: > + Array.p.includes behaves correctly on TypedArrays backed by resizable buffers + that are resized during argument coercion. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer, Array.prototype.includes] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert(!SendableArray.prototype.includes.call(fixedLength, undefined)); + // The TA is OOB so it includes only "undefined". + assert(SendableArray.prototype.includes.call(fixedLength, undefined, evil)); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + let n0 = MayNeedBigInt(fixedLength, 0); + assert(SendableArray.prototype.includes.call(fixedLength, n0)); + // The TA is OOB so it includes only "undefined". + assert(!SendableArray.prototype.includes.call(fixedLength, n0, evil)); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert(!SendableArray.prototype.includes.call(lengthTracking, undefined)); + // "includes" iterates until the original length and sees "undefined"s. + assert(SendableArray.prototype.includes.call(lengthTracking, undefined, evil)); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, 1); + } + let evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + let n0 = MayNeedBigInt(lengthTracking, 0); + assert(!SendableArray.prototype.includes.call(lengthTracking, n0)); + // The TA grew but we only look at the data until the original length. + assert(!SendableArray.prototype.includes.call(lengthTracking, n0, evil)); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + lengthTracking[0] = MayNeedBigInt(lengthTracking, 1); + let evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return -4; + } + }; + let n1 = MayNeedBigInt(lengthTracking, 1); + assert(SendableArray.prototype.includes.call(lengthTracking, n1, -4)); + // The TA grew but the start index conversion is done based on the original + // length. + assert(SendableArray.prototype.includes.call(lengthTracking, n1, evil)); +} diff --git a/test/sendable/builtins/Array/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js b/test/sendable/builtins/Array/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js new file mode 100644 index 00000000000..11c0e1048bf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: Return false if fromIndex >= ArrayLength +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) +features: [Array.prototype.includes] +---*/ + +var sample = [7, 7, 7, 7]; +assert.sameValue(sample.includes(7, 4), false, "length"); +assert.sameValue(sample.includes(7, 5), false, "length + 1"); diff --git a/test/sendable/builtins/Array/prototype/includes/fromIndex-infinity.js b/test/sendable/builtins/Array/prototype/includes/fromIndex-infinity.js new file mode 100644 index 00000000000..91d3029f862 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/fromIndex-infinity.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: handle Infinity values for fromIndex +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) +features: [Array.prototype.includes] +---*/ + +var sample = [42, 43, 43, 41]; +assert.sameValue( + sample.includes(43, Infinity), + false, + "includes(43, Infinity)" +); +assert.sameValue( + sample.includes(43, -Infinity), + true, + "includes(43, -Infinity)" +); diff --git a/test/sendable/builtins/Array/prototype/includes/fromIndex-minus-zero.js b/test/sendable/builtins/Array/prototype/includes/fromIndex-minus-zero.js new file mode 100644 index 00000000000..fec15dbe6cd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/fromIndex-minus-zero.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: -0 fromIndex becomes 0 +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) +features: [Array.prototype.includes] +---*/ + +var sample = [42, 43]; +assert.sameValue(sample.includes(42, -0), true, "-0 [0]"); +assert.sameValue(sample.includes(43, -0), true, "-0 [1]"); +assert.sameValue(sample.includes(44, -0), false, "-0 [2]"); diff --git a/test/sendable/builtins/Array/prototype/includes/get-prop.js b/test/sendable/builtins/Array/prototype/includes/get-prop.js new file mode 100644 index 00000000000..ab87b4b064c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/get-prop.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: get array-like indexed properties +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) +includes: [compareArray.js] +features: [Proxy, Array.prototype.includes] +---*/ + +var calls; +var obj = {}; +var p = new Proxy(obj, { + get: function(_, key) { + calls.push(key); + if (key === "length") { + return 4; + } + return key * 10; + } +}); +calls = []; +assert.sameValue( + [].includes.call(p, 42), + false, + '[].includes.call("new Proxy(obj, {get: function(_, key) {calls.push(key); if (key === "length") {return 4;} return key * 10;}})", 42) must return false' +); +assert.compareArray(calls, ["length", "0", "1", "2", "3"], + 'The value of calls is expected to be ["length", "0", "1", "2", "3"]' +); +calls = []; +assert.sameValue([].includes.call(p, 10), true, '[].includes.call("new Proxy(obj, {get: function(_, key) {calls.push(key); if (key === "length") {return 4;} return key * 10;}})", 10) must return true'); +assert.compareArray(calls, ["length", "0", "1"], 'The value of calls is expected to be ["length", "0", "1"]'); diff --git a/test/sendable/builtins/Array/prototype/includes/length-boundaries.js b/test/sendable/builtins/Array/prototype/includes/length-boundaries.js new file mode 100644 index 00000000000..1723034d799 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/length-boundaries.js @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: length boundaries from ToLength operation +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) +features: [Array.prototype.includes] +---*/ + +var obj = { + "0": "a", + "1": "b", + "9007199254740990": "c", // 2 ** 53 - 2 + "9007199254740991": "d", // 2 ** 53 - 1 + "9007199254740992": "e", // 2 ** 53 +}; +obj.length = -0; +assert.sameValue([].includes.call(obj, "a"), false, "-0"); +obj.length = -1; +assert.sameValue([].includes.call(obj, "a"), false, "-1"); +obj.length = -0.1; +assert.sameValue([].includes.call(obj, "a"), false, "-0.1"); +obj.length = -Infinity; +assert.sameValue([].includes.call(obj, "a"), false, "-Infinity"); +var fromIndex = 9007199254740990; +obj.length = 9007199254740991; +assert.sameValue( + [].includes.call(obj, "c", fromIndex), + true, + "2**53-1, found value at 2**53-2" +); +obj.length = 9007199254740991; +assert.sameValue( + [].includes.call(obj, "d", fromIndex), + false, + "2**53-1, ignores indexes >= 2**53-1" +); +obj.length = 9007199254740992; +assert.sameValue( + [].includes.call(obj, "d", fromIndex), + false, + "2**53, ignores indexes >= 2**53-1" +); +obj.length = 9007199254740993; +assert.sameValue( + [].includes.call(obj, "d", fromIndex), + false, + "2**53+1, ignores indexes >= 2**53-1" +); +obj.length = Infinity; +assert.sameValue( + [].includes.call(obj, "c", fromIndex), + true, + "Infinity, found item" +); +assert.sameValue( + [].includes.call(obj, "d", fromIndex), + false, + "Infinity, ignores indexes >= 2**53-1" +); diff --git a/test/sendable/builtins/Array/prototype/includes/length-zero-returns-false.js b/test/sendable/builtins/Array/prototype/includes/length-zero-returns-false.js new file mode 100644 index 00000000000..f1c7883a1d1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/length-zero-returns-false.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: Returns false if length is 0 +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) +features: [Array.prototype.includes] +---*/ + +var calls = 0; +var fromIndex = { + valueOf: function() { + calls++; + } +}; +var sample = []; +assert.sameValue(sample.includes(0), false, "returns false"); +assert.sameValue(sample.includes(), false, "returns false - no arg"); +assert.sameValue(sample.includes(0, fromIndex), false, "using fromIndex"); +assert.sameValue(calls, 0, "length is checked before ToInteger(fromIndex)"); diff --git a/test/sendable/builtins/Array/prototype/includes/length.js b/test/sendable/builtins/Array/prototype/includes/length.js new file mode 100644 index 00000000000..6bcf8d00bb6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/length.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: > + Array.prototype.includes.length is 1. +info: | + Array.prototype.includes ( searchElement [ , fromIndex ] ) + 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] +features: [Array.prototype.includes] +---*/ + +verifyProperty(SendableArray.prototype.includes, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/includes/name.js b/test/sendable/builtins/Array/prototype/includes/name.js new file mode 100644 index 00000000000..af7ae76d1e6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/name.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: > + Array.prototype.includes.name is "includes". +info: | + Array.prototype.includes (searchElement [ , fromIndex ] ) + 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] +features: [Array.prototype.includes] +---*/ + +verifyProperty(SendableArray.prototype.includes, "name", { + value: "includes", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/includes/no-arg.js b/test/sendable/builtins/Array/prototype/includes/no-arg.js new file mode 100644 index 00000000000..8696f7d9c5b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/no-arg.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: no argument searches for a undefined value +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. +features: [Array.prototype.includes] +---*/ + +assert.sameValue([0].includes(), false, "[0].includes()"); +assert.sameValue([undefined].includes(), true, "[undefined].includes()"); diff --git a/test/sendable/builtins/Array/prototype/includes/not-a-constructor.js b/test/sendable/builtins/Array/prototype/includes/not-a-constructor.js new file mode 100644 index 00000000000..db3c839fd0f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/not-a-constructor.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.includes 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, Array.prototype.includes] +---*/ + +assert.sameValue( + isConstructor(SendableArray.prototype.includes), + false, + 'isConstructor(SendableArray.prototype.includes) must return false' +); + +assert.throws(TypeError, () => { + new SendableArray.prototype.includes(1); +}); + diff --git a/test/sendable/builtins/Array/prototype/includes/prop-desc.js b/test/sendable/builtins/Array/prototype/includes/prop-desc.js new file mode 100644 index 00000000000..f2ae3f88404 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/prop-desc.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: > + "includes" property of Array.prototype +info: | + ES6 section 17: 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] +features: [Array.prototype.includes] +---*/ + +verifyProperty(SendableArray.prototype, "includes", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/includes/resizable-buffer-special-float-values.js b/test/sendable/builtins/Array/prototype/includes/resizable-buffer-special-float-values.js new file mode 100644 index 00000000000..7fe0d1b5067 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/resizable-buffer-special-float-values.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-%array%.prototype.includes +description: > + Array.p.includes behaves correctly for special float values on float + TypedArrays backed by resizable buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer, Array.prototype.includes] +---*/ + +for (let ctor of floatCtors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + lengthTracking[0] = -Infinity; + lengthTracking[1] = Infinity; + lengthTracking[2] = NaN; + assert(SendableArray.prototype.includes.call(lengthTracking, -Infinity)); + assert(SendableArray.prototype.includes.call(lengthTracking, Infinity)); + assert(SendableArray.prototype.includes.call(lengthTracking, NaN)); +} diff --git a/test/sendable/builtins/Array/prototype/includes/resizable-buffer.js b/test/sendable/builtins/Array/prototype/includes/resizable-buffer.js new file mode 100644 index 00000000000..473fa965ed4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/resizable-buffer.js @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: > + Array.p.includes behaves correctly on TypedArrays backed by resizable buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer, Array.prototype.includes] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + // If fixedLength is a BigInt array, they all are BigInt Arrays. + let n2 = MayNeedBigInt(fixedLength, 2); + let n4 = MayNeedBigInt(fixedLength, 4); + assert(SendableArray.prototype.includes.call(fixedLength, n2)); + assert(!SendableArray.prototype.includes.call(fixedLength, undefined)); + assert(SendableArray.prototype.includes.call(fixedLength, n2, 1)); + assert(!SendableArray.prototype.includes.call(fixedLength, n2, 2)); + assert(SendableArray.prototype.includes.call(fixedLength, n2, -3)); + assert(!SendableArray.prototype.includes.call(fixedLength, n2, -2)); + assert(!SendableArray.prototype.includes.call(fixedLengthWithOffset, n2)); + assert(SendableArray.prototype.includes.call(fixedLengthWithOffset, n4)); + assert(!SendableArray.prototype.includes.call(fixedLengthWithOffset, undefined)); + assert(SendableArray.prototype.includes.call(fixedLengthWithOffset, n4, 0)); + assert(!SendableArray.prototype.includes.call(fixedLengthWithOffset, n4, 1)); + assert(SendableArray.prototype.includes.call(fixedLengthWithOffset, n4, -2)); + assert(!SendableArray.prototype.includes.call(fixedLengthWithOffset, n4, -1)); + assert(SendableArray.prototype.includes.call(lengthTracking, n2)); + assert(!SendableArray.prototype.includes.call(lengthTracking, undefined)); + assert(SendableArray.prototype.includes.call(lengthTracking, n2, 1)); + assert(!SendableArray.prototype.includes.call(lengthTracking, n2, 2)); + assert(SendableArray.prototype.includes.call(lengthTracking, n2, -3)); + assert(!SendableArray.prototype.includes.call(lengthTracking, n2, -2)); + assert(!SendableArray.prototype.includes.call(lengthTrackingWithOffset, n2)); + assert(SendableArray.prototype.includes.call(lengthTrackingWithOffset, n4)); + assert(!SendableArray.prototype.includes.call(lengthTrackingWithOffset, undefined)); + assert(SendableArray.prototype.includes.call(lengthTrackingWithOffset, n4, 0)); + assert(!SendableArray.prototype.includes.call(lengthTrackingWithOffset, n4, 1)); + assert(SendableArray.prototype.includes.call(lengthTrackingWithOffset, n4, -2)); + assert(!SendableArray.prototype.includes.call(lengthTrackingWithOffset, n4, -1)); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + assert(!SendableArray.prototype.includes.call(fixedLength, n2)); + assert(!SendableArray.prototype.includes.call(fixedLengthWithOffset, n2)); + assert(SendableArray.prototype.includes.call(lengthTracking, n2)); + assert(!SendableArray.prototype.includes.call(lengthTracking, undefined)); + assert(!SendableArray.prototype.includes.call(lengthTrackingWithOffset, n2)); + assert(SendableArray.prototype.includes.call(lengthTrackingWithOffset, n4)); + assert(!SendableArray.prototype.includes.call(lengthTrackingWithOffset, undefined)); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert(!SendableArray.prototype.includes.call(fixedLength, n2)); + assert(!SendableArray.prototype.includes.call(fixedLengthWithOffset, n2)); + assert(!SendableArray.prototype.includes.call(lengthTrackingWithOffset, n2)); + // Shrink to zero. + rab.resize(0); + assert(!SendableArray.prototype.includes.call(fixedLength, n2)); + assert(!SendableArray.prototype.includes.call(fixedLengthWithOffset, n2)); + assert(!SendableArray.prototype.includes.call(lengthTrackingWithOffset, n2)); + assert(!SendableArray.prototype.includes.call(lengthTracking, n2)); + assert(!SendableArray.prototype.includes.call(lengthTracking, undefined)); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + let n8 = MayNeedBigInt(fixedLength, 8); + assert(SendableArray.prototype.includes.call(fixedLength, n2)); + assert(!SendableArray.prototype.includes.call(fixedLength, undefined)); + assert(!SendableArray.prototype.includes.call(fixedLength, n8)); + assert(!SendableArray.prototype.includes.call(fixedLengthWithOffset, n2)); + assert(SendableArray.prototype.includes.call(fixedLengthWithOffset, n4)); + assert(!SendableArray.prototype.includes.call(fixedLengthWithOffset, undefined)); + assert(!SendableArray.prototype.includes.call(fixedLengthWithOffset, n8)); + assert(SendableArray.prototype.includes.call(lengthTracking, n2)); + assert(!SendableArray.prototype.includes.call(lengthTracking, undefined)); + assert(SendableArray.prototype.includes.call(lengthTracking, n8)); + assert(!SendableArray.prototype.includes.call(lengthTrackingWithOffset, n2)); + assert(SendableArray.prototype.includes.call(lengthTrackingWithOffset, n4)); + assert(!SendableArray.prototype.includes.call(lengthTrackingWithOffset, undefined)); + assert(SendableArray.prototype.includes.call(lengthTrackingWithOffset, n8)); +} diff --git a/test/sendable/builtins/Array/prototype/includes/return-abrupt-get-length.js b/test/sendable/builtins/Array/prototype/includes/return-abrupt-get-length.js new file mode 100644 index 00000000000..07835a6bd9e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/return-abrupt-get-length.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: Return abrupt from Get(O, "length") +features: [Array.prototype.includes] +---*/ + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + [].includes.call(obj, 7); +}); diff --git a/test/sendable/builtins/Array/prototype/includes/return-abrupt-get-prop.js b/test/sendable/builtins/Array/prototype/includes/return-abrupt-get-prop.js new file mode 100644 index 00000000000..090be80b6a2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/return-abrupt-get-prop.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: Return abrupt getting index properties +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) +features: [Array.prototype.includes] +---*/ + +var stopped = 0; +var obj = { + length: 3 +}; +Object.defineProperty(obj, "1", { + get: function() { + throw new Test262Error(); + } +}); +Object.defineProperty(obj, "2", { + get: function() { + stopped++; + } +}); +assert.throws(Test262Error, function() { + [].includes.call(obj, 7); +}); +assert.sameValue(stopped, 0, "It stops the loop after the abrupt completion"); diff --git a/test/sendable/builtins/Array/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/Array/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js new file mode 100644 index 00000000000..f3ec37a111e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: Return abrupt from ToInteger(fromIndex) - using symbol +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) +features: [Symbol, Array.prototype.includes] +---*/ + +var fromIndex = Symbol("1"); +var sample = [7]; +assert.throws(TypeError, function() { + sample.includes(7, fromIndex); +}); diff --git a/test/sendable/builtins/Array/prototype/includes/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/Array/prototype/includes/return-abrupt-tointeger-fromindex.js new file mode 100644 index 00000000000..80e014e05e5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/return-abrupt-tointeger-fromindex.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: Return abrupt from ToInteger(fromIndex) +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) +features: [Array.prototype.includes] +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; +var sample = [7]; +assert.throws(Test262Error, function() { + sample.includes(7, fromIndex); +}); diff --git a/test/sendable/builtins/Array/prototype/includes/return-abrupt-tonumber-length-symbol.js b/test/sendable/builtins/Array/prototype/includes/return-abrupt-tonumber-length-symbol.js new file mode 100644 index 00000000000..92a76354e21 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/return-abrupt-tonumber-length-symbol.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: Return abrupt from ToNumber(symbol "length") +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + 2. Let len be ? ToLength(? Get(O, "length")). +features: [Symbol, Array.prototype.includes] +---*/ + +var obj = { + length: Symbol("1") +}; +assert.throws(TypeError, function() { + [].includes.call(obj, 7); +}); diff --git a/test/sendable/builtins/Array/prototype/includes/return-abrupt-tonumber-length.js b/test/sendable/builtins/Array/prototype/includes/return-abrupt-tonumber-length.js new file mode 100644 index 00000000000..31b6960ec81 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/return-abrupt-tonumber-length.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: Return abrupt from ToNumber("length") +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + 2. Let len be ? ToLength(? Get(O, "length")). +features: [Array.prototype.includes] +---*/ + +var obj1 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; +var obj2 = { + length: { + toString: function() { + throw new Test262Error(); + } + } +}; +assert.throws(Test262Error, function() { + [].includes.call(obj1); +}, "valueOf"); +assert.throws(Test262Error, function() { + [].includes.call(obj2); +}, "toString"); diff --git a/test/sendable/builtins/Array/prototype/includes/samevaluezero.js b/test/sendable/builtins/Array/prototype/includes/samevaluezero.js new file mode 100644 index 00000000000..605791e17bd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/samevaluezero.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: search element is compared using SameValueZero +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. +features: [Array.prototype.includes] +---*/ + +var sample = [42, 0, 1, NaN]; +assert.sameValue(sample.includes("42"), false, "'42'"); +assert.sameValue(sample.includes([42]), false, "[42]"); +assert.sameValue(sample.includes(42.0), true, "42.0"); +assert.sameValue(sample.includes(-0), true, "-0"); +assert.sameValue(sample.includes(true), false, "true"); +assert.sameValue(sample.includes(false), false, "false"); +assert.sameValue(sample.includes(null), false, "null"); +assert.sameValue(sample.includes(""), false, "empty string"); +assert.sameValue(sample.includes(NaN), true, "NaN"); diff --git a/test/sendable/builtins/Array/prototype/includes/search-found-returns-true.js b/test/sendable/builtins/Array/prototype/includes/search-found-returns-true.js new file mode 100644 index 00000000000..db422d20fb2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/search-found-returns-true.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: returns true for found index +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + 5. If n ≥ 0, then + a. Let k be n. + 6. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. +features: [Symbol, Array.prototype.includes] +---*/ + +var symbol = Symbol("1"); +var obj = {}; +var array = []; +var sample = [42, "test262", null, undefined, true, false, 0, -1, "", symbol, obj, array]; +assert.sameValue(sample.includes(42), true, "42"); +assert.sameValue(sample.includes("test262"), true, "'test262'"); +assert.sameValue(sample.includes(null), true, "null"); +assert.sameValue(sample.includes(undefined), true, "undefined"); +assert.sameValue(sample.includes(true), true, "true"); +assert.sameValue(sample.includes(false), true, "false"); +assert.sameValue(sample.includes(0), true, "0"); +assert.sameValue(sample.includes(-1), true, "-1"); +assert.sameValue(sample.includes(""), true, "the empty string"); +assert.sameValue(sample.includes(symbol), true, "symbol"); +assert.sameValue(sample.includes(obj), true, "obj"); +assert.sameValue(sample.includes(array), true, "array"); diff --git a/test/sendable/builtins/Array/prototype/includes/search-not-found-returns-false.js b/test/sendable/builtins/Array/prototype/includes/search-not-found-returns-false.js new file mode 100644 index 00000000000..c7c474aea93 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/search-not-found-returns-false.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: returns false if the element is not found +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + 5. If n ≥ 0, then + a. Let k be n. + 6. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + 8. Return false. +features: [Symbol, Array.prototype.includes] +---*/ + +assert.sameValue([42].includes(43), false, "43"); +assert.sameValue(["test262"].includes("test"), false, "string"); +assert.sameValue([0, "test262", undefined].includes(""), false, "the empty string"); +assert.sameValue(["true", false].includes(true), false, "true"); +assert.sameValue(["", true].includes(false), false, "false"); +assert.sameValue([undefined, false, 0, 1].includes(null), false, "null"); +assert.sameValue([null].includes(undefined), false, "undefined"); +assert.sameValue([Symbol("1")].includes(Symbol("1")), false, "symbol"); +assert.sameValue([{}].includes({}), false, "object"); +assert.sameValue([ + [] +].includes([]), false, "array"); +var sample = [42]; +assert.sameValue(sample.includes(sample), false, "this"); diff --git a/test/sendable/builtins/Array/prototype/includes/sparse.js b/test/sendable/builtins/Array/prototype/includes/sparse.js new file mode 100644 index 00000000000..ddd29c96bf9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/sparse.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: Searches all indexes from a sparse array +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) +features: [Array.prototype.includes] +---*/ + +assert.sameValue( + [, , , ].includes(undefined), + true, + "[ , , , ].includes(undefined)" +); +assert.sameValue( + [, , , 42, ].includes(undefined, 4), + false, + "[ , , , 42, ].includes(undefined, 4)" +); +var sample = [, , , 42, , ]; +assert.sameValue( + sample.includes(undefined), + true, + "sample.includes(undefined)" +); +assert.sameValue( + sample.includes(undefined, 4), + true, + "sample.includes(undefined, 4)" +); +assert.sameValue( + sample.includes(42, 3), + true, + "sample.includes(42, 3)" +); diff --git a/test/sendable/builtins/Array/prototype/includes/this-is-not-object.js b/test/sendable/builtins/Array/prototype/includes/this-is-not-object.js new file mode 100644 index 00000000000..0d9694a7e57 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/this-is-not-object.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.includes +description: > + Throws a TypeError exception when `this` cannot be coerced to Object +features: [Array.prototype.includes] +---*/ + +var includes = SendableArray.prototype.includes; +assert.throws(TypeError, function() { + includes.call(undefined, 42); +}, "this is undefined"); +assert.throws(TypeError, function() { + includes.call(null, 42); +}, "this is null"); diff --git a/test/sendable/builtins/Array/prototype/includes/tointeger-fromindex.js b/test/sendable/builtins/Array/prototype/includes/tointeger-fromindex.js new file mode 100644 index 00000000000..25cda2f286c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/tointeger-fromindex.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.includes +description: get the integer value from fromIndex +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) +features: [Array.prototype.includes] +---*/ + +var obj = { + valueOf: function() { + return 1; + } +}; +var sample = [42, 43]; +assert.sameValue(sample.includes(42, "1"), false, "string [0]"); +assert.sameValue(sample.includes(43, "1"), true, "string [1]"); +assert.sameValue(sample.includes(42, true), false, "true [0]"); +assert.sameValue(sample.includes(43, true), true, "true [1]"); +assert.sameValue(sample.includes(42, false), true, "false [0]"); +assert.sameValue(sample.includes(43, false), true, "false [1]"); +assert.sameValue(sample.includes(42, NaN), true, "NaN [0]"); +assert.sameValue(sample.includes(43, NaN), true, "NaN [1]"); +assert.sameValue(sample.includes(42, null), true, "null [0]"); +assert.sameValue(sample.includes(43, null), true, "null [1]"); +assert.sameValue(sample.includes(42, undefined), true, "undefined [0]"); +assert.sameValue(sample.includes(43, undefined), true, "undefined [1]"); +assert.sameValue(sample.includes(42, null), true, "null [0]"); +assert.sameValue(sample.includes(43, null), true, "null [1]"); +assert.sameValue(sample.includes(42, obj), false, "object [0]"); +assert.sameValue(sample.includes(43, obj), true, "object [1]"); diff --git a/test/sendable/builtins/Array/prototype/includes/tolength-length.js b/test/sendable/builtins/Array/prototype/includes/tolength-length.js new file mode 100644 index 00000000000..076ec26138a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/tolength-length.js @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.includes +description: length value coerced on ToLength +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) +features: [Array.prototype.includes] +---*/ + +var obj = { + "0": "a", + "1": "b" +}; +obj.length = 0.1; +assert.sameValue([].includes.call(obj, "a"), false, "0.1"); +obj.length = 0.99; +assert.sameValue([].includes.call(obj, "a"), false, "0.99"); +obj.length = 1.00001; +assert.sameValue([].includes.call(obj, "a"), true, "1.00001"); +obj.length = 1.1; +assert.sameValue([].includes.call(obj, "a"), true, "1.1"); +obj.length = "0"; +assert.sameValue([].includes.call(obj, "a"), false, "string '0'"); +obj.length = "1"; +assert.sameValue([].includes.call(obj, "a"), true, "string '1', item found"); +obj.length = "1"; +assert.sameValue([].includes.call(obj, "b"), false, "string '1', item not found"); +obj.length = "2"; +assert.sameValue([].includes.call(obj, "b"), true, "string '2', item found"); +obj.length = ""; +assert.sameValue([].includes.call(obj, "a"), false, "the empty string"); +obj.length = undefined; +assert.sameValue([].includes.call(obj, "a"), false, "undefined"); +obj.length = NaN; +assert.sameValue([].includes.call(obj, "a"), false, "NaN"); +obj.length = []; +assert.sameValue([].includes.call(obj, "a"), false, "[]"); +obj.length = [1]; +assert.sameValue([].includes.call(obj, "a"), true, "[1]"); +obj.length = null; +assert.sameValue([].includes.call(obj, "a"), false, "null"); +obj.length = false; +assert.sameValue([].includes.call(obj, "a"), false, "false"); +obj.length = true; +assert.sameValue([].includes.call(obj, "a"), true, "true"); +obj.length = { + valueOf: function() { + return 2; + } +}; +assert.sameValue([].includes.call(obj, "b"), true, "ordinary object.valueOf"); +obj.length = { + toString: function() { + return 2; + } +}; +assert.sameValue([].includes.call(obj, "b"), true, "ordinary object.toString"); diff --git a/test/sendable/builtins/Array/prototype/includes/using-fromindex.js b/test/sendable/builtins/Array/prototype/includes/using-fromindex.js new file mode 100644 index 00000000000..5b0f6f0d7d5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/using-fromindex.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.includes +description: Searches using fromIndex +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) +features: [Array.prototype.includes] +---*/ + +var sample = ["a", "b", "c"]; +assert.sameValue(sample.includes("a", 0), true, "includes('a', 0)"); +assert.sameValue(sample.includes("a", 1), false, "includes('a', 1)"); +assert.sameValue(sample.includes("a", 2), false, "includes('a', 2)"); +assert.sameValue(sample.includes("b", 0), true, "includes('b', 0)"); +assert.sameValue(sample.includes("b", 1), true, "includes('b', 1)"); +assert.sameValue(sample.includes("b", 2), false, "includes('b', 2)"); +assert.sameValue(sample.includes("c", 0), true, "includes('c', 0)"); +assert.sameValue(sample.includes("c", 1), true, "includes('c', 1)"); +assert.sameValue(sample.includes("c", 2), true, "includes('c', 2)"); +assert.sameValue(sample.includes("a", -1), false, "includes('a', -1)"); +assert.sameValue(sample.includes("a", -2), false, "includes('a', -2)"); +assert.sameValue(sample.includes("a", -3), true, "includes('a', -3)"); +assert.sameValue(sample.includes("a", -4), true, "includes('a', -4)"); +assert.sameValue(sample.includes("b", -1), false, "includes('b', -1)"); +assert.sameValue(sample.includes("b", -2), true, "includes('b', -2)"); +assert.sameValue(sample.includes("b", -3), true, "includes('b', -3)"); +assert.sameValue(sample.includes("b", -4), true, "includes('b', -4)"); +assert.sameValue(sample.includes("c", -1), true, "includes('c', -1)"); +assert.sameValue(sample.includes("c", -2), true, "includes('c', -2)"); +assert.sameValue(sample.includes("c", -3), true, "includes('c', -3)"); +assert.sameValue(sample.includes("c", -4), true, "includes('c', -4)"); diff --git a/test/sendable/builtins/Array/prototype/includes/values-are-not-cached.js b/test/sendable/builtins/Array/prototype/includes/values-are-not-cached.js new file mode 100644 index 00000000000..ed41f5e4601 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/includes/values-are-not-cached.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.includes +description: indexed values are not cached +info: | + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) +features: [Array.prototype.includes] +---*/ + +function getCleanObj() { + var obj = {}; + Object.defineProperty(obj, "length", { + get: function() { + Object.defineProperty(obj, "0", { + get: function() { + obj[1] = "ecma262"; + obj[2] = "cake"; + return "tc39"; + } + }); + return 2; + } + }); + return obj; +} +var obj; +obj = getCleanObj(); +assert.sameValue([].includes.call(obj, "tc39"), true, "'tc39' is true"); +obj = getCleanObj(); +assert.sameValue([].includes.call(obj, "ecma262"), true, "'ecma262' is true"); +obj = getCleanObj(); +assert.sameValue([].includes.call(obj, "cake"), false, "'cake' is false"); +assert.sameValue(obj[2], "cake", "'2' is set"); -- Gitee From e98bff0a0eeca2e0405ce7748e9026731cddc21c Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 26 Dec 2024 16:33:26 +0800 Subject: [PATCH 44/93] add array-indexof Signed-off-by: zhuzhihui7 --- .../Array/prototype/indexOf/15.4.4.14-1-1.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-1-10.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-1-11.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-1-12.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-1-13.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-1-14.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-1-15.js | 24 ++++ .../Array/prototype/indexOf/15.4.4.14-1-2.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-1-3.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-1-4.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-1-5.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-1-6.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-1-7.js | 20 +++ .../Array/prototype/indexOf/15.4.4.14-1-8.js | 21 ++++ .../Array/prototype/indexOf/15.4.4.14-1-9.js | 24 ++++ .../Array/prototype/indexOf/15.4.4.14-10-1.js | 38 ++++++ .../Array/prototype/indexOf/15.4.4.14-10-2.js | 34 ++++++ .../Array/prototype/indexOf/15.4.4.14-2-1.js | 31 +++++ .../Array/prototype/indexOf/15.4.4.14-2-10.js | 34 ++++++ .../Array/prototype/indexOf/15.4.4.14-2-11.js | 29 +++++ .../Array/prototype/indexOf/15.4.4.14-2-12.js | 36 ++++++ .../Array/prototype/indexOf/15.4.4.14-2-13.js | 31 +++++ .../Array/prototype/indexOf/15.4.4.14-2-14.js | 24 ++++ .../Array/prototype/indexOf/15.4.4.14-2-17.js | 27 ++++ .../Array/prototype/indexOf/15.4.4.14-2-18.js | 25 ++++ .../Array/prototype/indexOf/15.4.4.14-2-19.js | 28 +++++ .../Array/prototype/indexOf/15.4.4.14-2-2.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-2-3.js | 30 +++++ .../Array/prototype/indexOf/15.4.4.14-2-4.js | 26 ++++ .../Array/prototype/indexOf/15.4.4.14-2-5.js | 37 ++++++ .../Array/prototype/indexOf/15.4.4.14-2-6.js | 30 +++++ .../Array/prototype/indexOf/15.4.4.14-2-7.js | 39 ++++++ .../Array/prototype/indexOf/15.4.4.14-2-8.js | 35 ++++++ .../Array/prototype/indexOf/15.4.4.14-2-9.js | 39 ++++++ .../Array/prototype/indexOf/15.4.4.14-3-1.js | 25 ++++ .../Array/prototype/indexOf/15.4.4.14-3-10.js | 26 ++++ .../Array/prototype/indexOf/15.4.4.14-3-11.js | 28 +++++ .../Array/prototype/indexOf/15.4.4.14-3-12.js | 28 +++++ .../Array/prototype/indexOf/15.4.4.14-3-13.js | 28 +++++ .../Array/prototype/indexOf/15.4.4.14-3-14.js | 39 ++++++ .../Array/prototype/indexOf/15.4.4.14-3-15.js | 28 +++++ .../Array/prototype/indexOf/15.4.4.14-3-16.js | 28 +++++ .../Array/prototype/indexOf/15.4.4.14-3-17.js | 28 +++++ .../Array/prototype/indexOf/15.4.4.14-3-18.js | 27 ++++ .../Array/prototype/indexOf/15.4.4.14-3-19.js | 38 ++++++ .../Array/prototype/indexOf/15.4.4.14-3-2.js | 28 +++++ .../Array/prototype/indexOf/15.4.4.14-3-20.js | 33 +++++ .../Array/prototype/indexOf/15.4.4.14-3-21.js | 40 ++++++ .../Array/prototype/indexOf/15.4.4.14-3-22.js | 41 +++++++ .../Array/prototype/indexOf/15.4.4.14-3-23.js | 44 +++++++ .../Array/prototype/indexOf/15.4.4.14-3-24.js | 28 +++++ .../Array/prototype/indexOf/15.4.4.14-3-25.js | 28 +++++ .../Array/prototype/indexOf/15.4.4.14-3-28.js | 29 +++++ .../Array/prototype/indexOf/15.4.4.14-3-29.js | 29 +++++ .../Array/prototype/indexOf/15.4.4.14-3-3.js | 26 ++++ .../Array/prototype/indexOf/15.4.4.14-3-4.js | 26 ++++ .../Array/prototype/indexOf/15.4.4.14-3-5.js | 26 ++++ .../Array/prototype/indexOf/15.4.4.14-3-6.js | 28 +++++ .../Array/prototype/indexOf/15.4.4.14-3-7.js | 28 +++++ .../Array/prototype/indexOf/15.4.4.14-3-8.js | 26 ++++ .../Array/prototype/indexOf/15.4.4.14-3-9.js | 26 ++++ .../Array/prototype/indexOf/15.4.4.14-4-1.js | 21 ++++ .../Array/prototype/indexOf/15.4.4.14-4-10.js | 26 ++++ .../Array/prototype/indexOf/15.4.4.14-4-11.js | 26 ++++ .../Array/prototype/indexOf/15.4.4.14-4-2.js | 25 ++++ .../Array/prototype/indexOf/15.4.4.14-4-3.js | 25 ++++ .../Array/prototype/indexOf/15.4.4.14-4-4.js | 25 ++++ .../Array/prototype/indexOf/15.4.4.14-4-5.js | 25 ++++ .../Array/prototype/indexOf/15.4.4.14-4-6.js | 29 +++++ .../Array/prototype/indexOf/15.4.4.14-4-7.js | 34 ++++++ .../Array/prototype/indexOf/15.4.4.14-4-8.js | 38 ++++++ .../Array/prototype/indexOf/15.4.4.14-4-9.js | 26 ++++ .../Array/prototype/indexOf/15.4.4.14-5-1.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-5-10.js | 24 ++++ .../Array/prototype/indexOf/15.4.4.14-5-11.js | 24 ++++ .../Array/prototype/indexOf/15.4.4.14-5-12.js | 24 ++++ .../Array/prototype/indexOf/15.4.4.14-5-13.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-5-14.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-5-15.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-5-16.js | 24 ++++ .../Array/prototype/indexOf/15.4.4.14-5-17.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-5-18.js | 24 ++++ .../Array/prototype/indexOf/15.4.4.14-5-19.js | 24 ++++ .../Array/prototype/indexOf/15.4.4.14-5-2.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-5-20.js | 24 ++++ .../Array/prototype/indexOf/15.4.4.14-5-21.js | 32 +++++ .../Array/prototype/indexOf/15.4.4.14-5-22.js | 27 ++++ .../Array/prototype/indexOf/15.4.4.14-5-23.js | 37 ++++++ .../Array/prototype/indexOf/15.4.4.14-5-24.js | 39 ++++++ .../Array/prototype/indexOf/15.4.4.14-5-25.js | 40 ++++++ .../Array/prototype/indexOf/15.4.4.14-5-26.js | 43 +++++++ .../Array/prototype/indexOf/15.4.4.14-5-27.js | 47 +++++++ .../Array/prototype/indexOf/15.4.4.14-5-28.js | 32 +++++ .../Array/prototype/indexOf/15.4.4.14-5-29.js | 39 ++++++ .../Array/prototype/indexOf/15.4.4.14-5-3.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-5-30.js | 43 +++++++ .../Array/prototype/indexOf/15.4.4.14-5-31.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-5-32.js | 24 ++++ .../Array/prototype/indexOf/15.4.4.14-5-33.js | 26 ++++ .../Array/prototype/indexOf/15.4.4.14-5-4.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-5-5.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-5-6.js | 24 ++++ .../Array/prototype/indexOf/15.4.4.14-5-7.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-5-8.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-5-9.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-6-1.js | 25 ++++ .../Array/prototype/indexOf/15.4.4.14-7-1.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-7-2.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-7-3.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-7-4.js | 20 +++ .../Array/prototype/indexOf/15.4.4.14-7-5.js | 20 +++ .../Array/prototype/indexOf/15.4.4.14-8-1.js | 24 ++++ .../Array/prototype/indexOf/15.4.4.14-8-2.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-8-3.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-8-4.js | 22 ++++ .../Array/prototype/indexOf/15.4.4.14-9-1.js | 28 +++++ .../Array/prototype/indexOf/15.4.4.14-9-10.js | 29 +++++ .../Array/prototype/indexOf/15.4.4.14-9-11.js | 30 +++++ .../Array/prototype/indexOf/15.4.4.14-9-2.js | 31 +++++ .../Array/prototype/indexOf/15.4.4.14-9-3.js | 27 ++++ .../Array/prototype/indexOf/15.4.4.14-9-4.js | 28 +++++ .../Array/prototype/indexOf/15.4.4.14-9-5.js | 36 ++++++ .../Array/prototype/indexOf/15.4.4.14-9-6.js | 27 ++++ .../Array/prototype/indexOf/15.4.4.14-9-7.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-9-8.js | 23 ++++ .../Array/prototype/indexOf/15.4.4.14-9-9.js | 29 +++++ .../prototype/indexOf/15.4.4.14-9-a-1.js | 30 +++++ .../prototype/indexOf/15.4.4.14-9-a-10.js | 35 ++++++ .../prototype/indexOf/15.4.4.14-9-a-11.js | 38 ++++++ .../prototype/indexOf/15.4.4.14-9-a-12.js | 36 ++++++ .../prototype/indexOf/15.4.4.14-9-a-13.js | 34 ++++++ .../prototype/indexOf/15.4.4.14-9-a-14.js | 31 +++++ .../prototype/indexOf/15.4.4.14-9-a-15.js | 37 ++++++ .../prototype/indexOf/15.4.4.14-9-a-16.js | 31 +++++ .../prototype/indexOf/15.4.4.14-9-a-17.js | 30 +++++ .../prototype/indexOf/15.4.4.14-9-a-18.js | 36 ++++++ .../prototype/indexOf/15.4.4.14-9-a-19.js | 37 ++++++ .../prototype/indexOf/15.4.4.14-9-a-2.js | 32 +++++ .../prototype/indexOf/15.4.4.14-9-a-3.js | 31 +++++ .../prototype/indexOf/15.4.4.14-9-a-4.js | 32 +++++ .../prototype/indexOf/15.4.4.14-9-a-5.js | 32 +++++ .../prototype/indexOf/15.4.4.14-9-a-6.js | 31 +++++ .../prototype/indexOf/15.4.4.14-9-a-7.js | 37 ++++++ .../prototype/indexOf/15.4.4.14-9-a-8.js | 35 ++++++ .../prototype/indexOf/15.4.4.14-9-a-9.js | 37 ++++++ .../prototype/indexOf/15.4.4.14-9-b-1.js | 20 +++ .../prototype/indexOf/15.4.4.14-9-b-i-1.js | 30 +++++ .../prototype/indexOf/15.4.4.14-9-b-i-10.js | 45 +++++++ .../prototype/indexOf/15.4.4.14-9-b-i-11.js | 30 +++++ .../prototype/indexOf/15.4.4.14-9-b-i-12.js | 33 +++++ .../prototype/indexOf/15.4.4.14-9-b-i-13.js | 35 ++++++ .../prototype/indexOf/15.4.4.14-9-b-i-14.js | 38 ++++++ .../prototype/indexOf/15.4.4.14-9-b-i-15.js | 43 +++++++ .../prototype/indexOf/15.4.4.14-9-b-i-16.js | 48 ++++++++ .../prototype/indexOf/15.4.4.14-9-b-i-17.js | 27 ++++ .../prototype/indexOf/15.4.4.14-9-b-i-18.js | 29 +++++ .../prototype/indexOf/15.4.4.14-9-b-i-19.js | 34 ++++++ .../prototype/indexOf/15.4.4.14-9-b-i-2.js | 24 ++++ .../prototype/indexOf/15.4.4.14-9-b-i-20.js | 38 ++++++ .../prototype/indexOf/15.4.4.14-9-b-i-21.js | 26 ++++ .../prototype/indexOf/15.4.4.14-9-b-i-22.js | 28 +++++ .../prototype/indexOf/15.4.4.14-9-b-i-25.js | 27 ++++ .../prototype/indexOf/15.4.4.14-9-b-i-26.js | 28 +++++ .../prototype/indexOf/15.4.4.14-9-b-i-27.js | 28 +++++ .../prototype/indexOf/15.4.4.14-9-b-i-28.js | 41 +++++++ .../prototype/indexOf/15.4.4.14-9-b-i-29.js | 43 +++++++ .../prototype/indexOf/15.4.4.14-9-b-i-3.js | 23 ++++ .../prototype/indexOf/15.4.4.14-9-b-i-30.js | 40 ++++++ .../prototype/indexOf/15.4.4.14-9-b-i-31.js | 42 +++++++ .../prototype/indexOf/15.4.4.14-9-b-i-4.js | 28 +++++ .../prototype/indexOf/15.4.4.14-9-b-i-5.js | 28 +++++ .../prototype/indexOf/15.4.4.14-9-b-i-6.js | 33 +++++ .../prototype/indexOf/15.4.4.14-9-b-i-7.js | 27 ++++ .../prototype/indexOf/15.4.4.14-9-b-i-8.js | 33 +++++ .../prototype/indexOf/15.4.4.14-9-b-i-9.js | 43 +++++++ .../prototype/indexOf/15.4.4.14-9-b-ii-1.js | 29 +++++ .../prototype/indexOf/15.4.4.14-9-b-ii-10.js | 22 ++++ .../prototype/indexOf/15.4.4.14-9-b-ii-11.js | 25 ++++ .../prototype/indexOf/15.4.4.14-9-b-ii-2.js | 23 ++++ .../prototype/indexOf/15.4.4.14-9-b-ii-3.js | 22 ++++ .../prototype/indexOf/15.4.4.14-9-b-ii-4.js | 20 +++ .../prototype/indexOf/15.4.4.14-9-b-ii-5.js | 20 +++ .../prototype/indexOf/15.4.4.14-9-b-ii-6.js | 22 ++++ .../prototype/indexOf/15.4.4.14-9-b-ii-7.js | 22 ++++ .../prototype/indexOf/15.4.4.14-9-b-ii-8.js | 22 ++++ .../prototype/indexOf/15.4.4.14-9-b-ii-9.js | 22 ++++ .../prototype/indexOf/15.4.4.14-9-b-iii-1.js | 22 ++++ .../prototype/indexOf/15.4.4.14-9-b-iii-2.js | 41 +++++++ .../prototype/indexOf/call-with-boolean.js | 21 ++++ ...ly-has-on-prototype-after-length-zeroed.js | 38 ++++++ .../coerced-searchelement-fromindex-grow.js | 58 +++++++++ .../coerced-searchelement-fromindex-shrink.js | 71 +++++++++++ .../indexOf/fromindex-zero-conversion.js | 21 ++++ .../indexOf/length-near-integer-limit.js | 33 +++++ .../indexOf/length-zero-returns-minus-one.js | 27 ++++ .../Array/prototype/indexOf/length.js | 38 ++++++ .../builtins/Array/prototype/indexOf/name.js | 36 ++++++ .../prototype/indexOf/not-a-constructor.js | 39 ++++++ .../Array/prototype/indexOf/prop-desc.js | 32 +++++ .../resizable-buffer-special-float-values.js | 37 ++++++ .../prototype/indexOf/resizable-buffer.js | 115 ++++++++++++++++++ 201 files changed, 5999 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-10.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-11.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-12.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-13.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-14.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-15.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-2.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-3.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-4.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-5.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-6.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-7.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-8.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-9.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-10-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-10-2.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-10.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-11.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-12.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-13.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-14.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-17.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-18.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-19.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-2.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-3.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-4.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-5.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-6.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-7.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-8.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-9.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-10.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-11.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-12.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-13.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-14.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-15.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-16.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-17.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-18.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-19.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-2.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-20.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-21.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-22.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-23.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-24.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-25.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-28.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-29.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-3.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-4.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-5.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-6.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-7.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-8.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-9.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-10.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-11.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-2.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-3.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-4.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-5.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-6.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-7.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-8.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-9.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-10.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-11.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-12.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-13.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-14.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-15.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-16.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-17.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-18.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-19.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-2.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-20.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-21.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-22.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-23.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-24.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-25.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-26.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-27.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-28.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-29.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-3.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-30.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-31.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-32.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-33.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-4.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-5.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-6.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-7.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-8.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-9.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-6-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-2.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-3.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-4.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-5.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-2.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-3.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-4.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-10.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-11.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-2.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-3.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-4.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-5.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-6.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-7.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-8.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-9.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-10.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-11.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-12.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-13.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-14.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-15.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-16.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-17.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-18.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-19.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-2.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-3.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-4.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-5.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-6.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-7.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-8.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-9.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-10.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-11.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-12.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-13.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-14.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-15.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-16.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-17.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-18.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-19.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-2.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-20.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-21.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-22.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-25.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-26.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-27.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-28.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-29.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-3.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-30.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-31.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-4.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-5.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-6.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-7.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-8.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-9.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-10.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-11.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-2.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-3.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-4.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-5.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-6.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-7.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-8.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-9.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-iii-1.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-iii-2.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/coerced-searchelement-fromindex-grow.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/coerced-searchelement-fromindex-shrink.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/fromindex-zero-conversion.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/length-near-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/length-zero-returns-minus-one.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/length.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/name.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/resizable-buffer-special-float-values.js create mode 100644 test/sendable/builtins/Array/prototype/indexOf/resizable-buffer.js diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-1.js new file mode 100644 index 00000000000..1a827a811fe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to undefined throws a TypeError +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.indexOf.call(undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-10.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-10.js new file mode 100644 index 00000000000..07d5c35bba9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-10.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to the Math object +---*/ + +Math[1] = true; +Math.length = 2; +assert.sameValue(SendableArray.prototype.indexOf.call(Math, true), 1, 'SendableArray.prototype.indexOf.call(Math, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-11.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-11.js new file mode 100644 index 00000000000..621ddabca5b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-11.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to Date object +---*/ + +var obj = new Date(0); +obj.length = 2; +obj[1] = true; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 1, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-12.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-12.js new file mode 100644 index 00000000000..3c17d950854 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-12.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to RegExp object +---*/ + +var obj = new RegExp(); +obj.length = 2; +obj[1] = true; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 1, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-13.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-13.js new file mode 100644 index 00000000000..39700252fea --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-13.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to the JSON object +---*/ + +var targetObj = {}; +JSON[3] = targetObj; +JSON.length = 5; +assert.sameValue(SendableArray.prototype.indexOf.call(JSON, targetObj), 3, 'SendableArray.prototype.indexOf.call(JSON, targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-14.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-14.js new file mode 100644 index 00000000000..1faf11f3fbc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-14.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to Error object +---*/ + +var obj = new SyntaxError(); +obj[1] = true; +obj.length = 2; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 1, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-15.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-15.js new file mode 100644 index 00000000000..6df823ea30b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-15.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to Arguments object +---*/ + +function fun() { + return arguments; +} +var obj = fun(1, true, 3); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 1, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-2.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-2.js new file mode 100644 index 00000000000..81b8dca7374 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-2.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to null throws a TypeError +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.indexOf.call(null); +}); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-3.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-3.js new file mode 100644 index 00000000000..716037f4aed --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to boolean primitive +---*/ + +var targetObj = {}; +Boolean.prototype[1] = targetObj; +Boolean.prototype.length = 2; +assert.sameValue(SendableArray.prototype.indexOf.call(true, targetObj), 1, 'SendableArray.prototype.indexOf.call(true, targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-4.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-4.js new file mode 100644 index 00000000000..10277e13bf7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-4.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to Boolean Object +---*/ + +var obj = new Boolean(false); +obj.length = 2; +obj[1] = true; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 1, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-5.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-5.js new file mode 100644 index 00000000000..b5f655c866d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-5.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to number primitive +---*/ + +var targetObj = {}; +Number.prototype[1] = targetObj; +Number.prototype.length = 2; +assert.sameValue(SendableArray.prototype.indexOf.call(5, targetObj), 1, 'SendableArray.prototype.indexOf.call(5, targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-6.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-6.js new file mode 100644 index 00000000000..47644c70895 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-6.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to Number object +---*/ + +var obj = new Number(-3); +obj.length = 2; +obj[1] = true; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 1, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-7.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-7.js new file mode 100644 index 00000000000..cdf0ce7dbfd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-7.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to string primitive +---*/ + +assert.sameValue(SendableArray.prototype.indexOf.call("abc", "b"), 1, 'SendableArray.prototype.indexOf.call("abc", "b")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-8.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-8.js new file mode 100644 index 00000000000..ce39316cd6a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-8.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to String object +---*/ + +var obj = new String("null"); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 'l'), 2, 'SendableArray.prototype.indexOf.call(obj, "l")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-9.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-9.js new file mode 100644 index 00000000000..2aaea22ff1e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-1-9.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf applied to Function object +---*/ + +var obj = function(a, b) { + return a + b; +}; +obj[1] = true; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 1, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-10-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-10-1.js new file mode 100644 index 00000000000..d1f3df998dc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-10-1.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 for elements not present in + array +---*/ + +var a = new SendableArray(); +a[100] = 1; +a[99999] = ""; +a[10] = new Object(); +a[5555] = 5.5; +a[123456] = "str"; +a[5] = 1E+309; +assert.sameValue(a.indexOf(1), 100, 'a.indexOf(1)'); +assert.sameValue(a.indexOf(""), 99999, 'a.indexOf("")'); +assert.sameValue(a.indexOf("str"), 123456, 'a.indexOf("str")'); +assert.sameValue(a.indexOf(1E+309), 5, 'a.indexOf(1E+309)'); //Infinity +assert.sameValue(a.indexOf(5.5), 5555, 'a.indexOf(5.5)'); +assert.sameValue(a.indexOf(true), -1, 'a.indexOf(true)'); +assert.sameValue(a.indexOf(5), -1, 'a.indexOf(5)'); +assert.sameValue(a.indexOf("str1"), -1, 'a.indexOf("str1")'); +assert.sameValue(a.indexOf(null), -1, 'a.indexOf(null)'); +assert.sameValue(a.indexOf(new Object()), -1, 'a.indexOf(new Object())'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-10-2.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-10-2.js new file mode 100644 index 00000000000..7bcc13f7a89 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-10-2.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 and does not + access any other properties +---*/ + +var accessed = false; +var f = { + length: 0 +}; +Object.defineProperty(f, "0", { + get: function() { + accessed = true; + return 1; + } +}); +var i = SendableArray.prototype.indexOf.call(f, 1); +assert.sameValue(i, -1, 'i'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-1.js new file mode 100644 index 00000000000..2e32b2d32b4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own data property on an + Array-like object +---*/ + +var objOne = { + 1: true, + length: 2 +}; +var objTwo = { + 2: true, + length: 2 +}; +assert.sameValue(SendableArray.prototype.indexOf.call(objOne, true), 1, 'SendableArray.prototype.indexOf.call(objOne, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(objTwo, true), -1, 'SendableArray.prototype.indexOf.call(objTwo, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-10.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-10.js new file mode 100644 index 00000000000..e65b7147e8a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-10.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is inherited accessor property +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var childOne = new Con(); +childOne[1] = true; +var childTwo = new Con(); +childTwo[2] = true; +assert.sameValue(SendableArray.prototype.indexOf.call(childOne, true), 1, 'SendableArray.prototype.indexOf.call(childOne, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(childTwo, true), -1, 'SendableArray.prototype.indexOf.call(childTwo, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-11.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-11.js new file mode 100644 index 00000000000..7e528c81aa5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-11.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own accessor property + without a get function +---*/ + +var obj = { + 1: true +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), -1, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-12.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-12.js new file mode 100644 index 00000000000..8558ad94c89 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-12.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own accessor property + without a get function that overrides an inherited accessor + property +---*/ + +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 20; + }, + configurable: true +}); +var obj = { + 1: 1 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 1), -1, 'SendableArray.prototype.indexOf.call(obj, 1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-13.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-13.js new file mode 100644 index 00000000000..17753e68fe4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-13.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is inherited accessor property + without a get function +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[1] = true; +assert.sameValue(SendableArray.prototype.indexOf.call(child, true), -1, 'SendableArray.prototype.indexOf.call(child, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-14.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-14.js new file mode 100644 index 00000000000..5a335d1c16b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-14.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is undefined property +---*/ + +var obj = { + 0: true, + 1: true +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), -1, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-17.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-17.js new file mode 100644 index 00000000000..fe7ad71a283 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-17.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf applied to Arguments object which + implements its own property get method +---*/ + +var func = function(a, b) { + arguments[2] = false; + return SendableArray.prototype.indexOf.call(arguments, true) === 1 && + SendableArray.prototype.indexOf.call(arguments, false) === -1; +}; +assert(func(0, true), 'func(0, true) !== true'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-18.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-18.js new file mode 100644 index 00000000000..c2d7ec0c0bc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-18.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf applied to String object, which implements + its own property get method +---*/ + +var str = new String("012"); +String.prototype[3] = "3"; +assert.sameValue(SendableArray.prototype.indexOf.call(str, "2"), 2, 'SendableArray.prototype.indexOf.call(str, "2")'); +assert.sameValue(SendableArray.prototype.indexOf.call(str, "3"), -1, 'SendableArray.prototype.indexOf.call(str, "3")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-19.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-19.js new file mode 100644 index 00000000000..26b8c96d3d5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-19.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf applied to Function object which + implements its own property get method +---*/ + +var obj = function(a, b) { + return a + b; +}; +obj[1] = "b"; +obj[2] = "c"; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, obj[1]), 1, 'SendableArray.prototype.indexOf.call(obj, obj[1])'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, obj[2]), -1, 'SendableArray.prototype.indexOf.call(obj, obj[2])'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-2.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-2.js new file mode 100644 index 00000000000..63e9871f9c4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-2.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is own data property on an Array +---*/ + +var targetObj = {}; +SendableArray.prototype[2] = targetObj; +assert.sameValue([0, targetObj].indexOf(targetObj), 1, '[0, targetObj].indexOf(targetObj)'); +assert.sameValue([0, 1].indexOf(targetObj), -1, '[0, 1].indexOf(targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-3.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-3.js new file mode 100644 index 00000000000..bcd738cccf3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-3.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own data property that + overrides an inherited data property on an Array-like object +---*/ + +var proto = { + length: 0 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +child[1] = true; +assert.sameValue(SendableArray.prototype.indexOf.call(child, true), 1, 'SendableArray.prototype.indexOf.call(child, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-4.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-4.js new file mode 100644 index 00000000000..7bf26238ac5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-4.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own data property that + overrides an inherited data property on an Array +---*/ + +var targetObj = {}; +var arrProtoLen; +arrProtoLen = SendableArray.prototype.length; +SendableArray.prototype.length = 0; +assert.sameValue([0, targetObj].indexOf(targetObj), 1, '[0, targetObj].indexOf(targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-5.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-5.js new file mode 100644 index 00000000000..2965fb9c2ec --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-5.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own data property that + overrides an inherited accessor property on an Array-like object +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 0; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[1] = true; +assert.sameValue(SendableArray.prototype.indexOf.call(child, true), 1, 'SendableArray.prototype.indexOf.call(child, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-6.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-6.js new file mode 100644 index 00000000000..e6391de5ff9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-6.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is an inherited data property +---*/ + +var proto = { + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var childOne = new Con(); +childOne[1] = true; +var childTwo = new Con(); +childTwo[2] = true; +assert.sameValue(SendableArray.prototype.indexOf.call(childOne, true), 1, 'SendableArray.prototype.indexOf.call(childOne, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(childTwo, true), -1, 'SendableArray.prototype.indexOf.call(childTwo, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-7.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-7.js new file mode 100644 index 00000000000..b7705a1fa37 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-7.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is own accessor property +---*/ + +var objOne = { + 1: true +}; +var objTwo = { + 2: true +}; +Object.defineProperty(objOne, "length", { + get: function() { + return 2; + }, + configurable: true +}); +Object.defineProperty(objTwo, "length", { + get: function() { + return 2; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(objOne, true), 1, 'SendableArray.prototype.indexOf.call(objOne, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(objTwo, true), -1, 'SendableArray.prototype.indexOf.call(objTwo, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-8.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-8.js new file mode 100644 index 00000000000..6b48aadad2b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-8.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own accessor property that + overrides an inherited data property +---*/ + +var proto = { + length: 0 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[1] = true; +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(child, true), 1, 'SendableArray.prototype.indexOf.call(child, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-9.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-9.js new file mode 100644 index 00000000000..716f3ae9fe6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-2-9.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is own accessor property that + overrides an inherited accessor property +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 0; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[1] = true; +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(child, true), 1, 'SendableArray.prototype.indexOf.call(child, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-1.js new file mode 100644 index 00000000000..684b49049e8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - value of 'length' is undefined +---*/ + +var obj = { + 0: 1, + 1: 1, + length: undefined +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 1), -1, 'SendableArray.prototype.indexOf.call(obj, 1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-10.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-10.js new file mode 100644 index 00000000000..2c56acb123a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-10.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is number primitive + (value is NaN) +---*/ + +var obj = { + 0: 0, + length: NaN +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 0), -1, 'SendableArray.prototype.indexOf.call(obj, 0)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-11.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-11.js new file mode 100644 index 00000000000..5f2e7024687 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-11.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is a string containing a + positive number +---*/ + +var obj = { + 1: 1, + 2: 2, + length: "2" +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 1), 1, 'SendableArray.prototype.indexOf.call(obj, 1)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 2), -1, 'SendableArray.prototype.indexOf.call(obj, 2)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-12.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-12.js new file mode 100644 index 00000000000..09ab7eba38c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-12.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is a string containing a + negative number +---*/ + +var obj = { + 1: "true", + 2: "2", + length: "-4294967294" +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, "true"), -1, 'SendableArray.prototype.indexOf.call(obj, "true")'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, "2"), -1, 'SendableArray.prototype.indexOf.call(obj, "2")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-13.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-13.js new file mode 100644 index 00000000000..3af893613ce --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-13.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is a string containing a + decimal number +---*/ + +var obj = { + 199: true, + 200: "200.59", + length: "200.59" +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 199, 'SendableArray.prototype.indexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, "200.59"), -1, 'SendableArray.prototype.indexOf.call(obj, "200.59")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-14.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-14.js new file mode 100644 index 00000000000..b79065b589a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-14.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is a string containing + +/-Infinity +---*/ + +var objOne = { + 0: true, + 1: true, + length: "Infinity" +}; +var objTwo = { + 0: true, + 1: true, + length: "+Infinity" +}; +var objThree = { + 0: true, + 1: true, + length: "-Infinity" +}; +assert.sameValue(SendableArray.prototype.indexOf.call(objOne, true), 0, 'SendableArray.prototype.indexOf.call(objOne, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(objTwo, true), 0, 'SendableArray.prototype.indexOf.call(objTwo, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(objThree, true), -1, 'SendableArray.prototype.indexOf.call(objThree, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-15.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-15.js new file mode 100644 index 00000000000..cc30162e40b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-15.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is a string containing an + exponential number +---*/ + +var obj = { + 1: true, + 2: "2E0", + length: "2E0" +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 1, 'SendableArray.prototype.indexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, "2E0"), -1, 'SendableArray.prototype.indexOf.call(obj, "2E0")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-16.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-16.js new file mode 100644 index 00000000000..1d2f75e52a1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-16.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is a string containing a hex + number +---*/ + +var obj = { + 10: true, + 11: "0x00B", + length: "0x00B" +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 10, 'SendableArray.prototype.indexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, "0x00B"), -1, 'SendableArray.prototype.indexOf.call(obj, "0x00B")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-17.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-17.js new file mode 100644 index 00000000000..73cd7bbc229 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-17.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is a string containing a number + with leading zeros +---*/ + +var obj = { + 1: true, + 2: "0002.0", + length: "0002.0" +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 1, 'SendableArray.prototype.indexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, "0002.0"), -1, 'SendableArray.prototype.indexOf.call(obj, "0002.0")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-18.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-18.js new file mode 100644 index 00000000000..9c8b3ab9507 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-18.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a string that can't + convert to a number +---*/ + +var obj = { + 0: true, + 100: true, + length: "one" +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), -1, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-19.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-19.js new file mode 100644 index 00000000000..1d91ea0bb9a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-19.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is an Object which has + an own toString method. +---*/ + +// objects inherit the default valueOf() method from Object +// that simply returns itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. + +var obj = { + 1: true, + 2: 2, + length: { + toString: function() { + return '2'; + } + } +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 1, 'SendableArray.prototype.indexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 2), -1, 'SendableArray.prototype.indexOf.call(obj, 2)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-2.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-2.js new file mode 100644 index 00000000000..483b68f4dee --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf return -1 when 'length' is a boolean + (value is true) +---*/ + +var obj = { + 0: 0, + 1: 1, + length: true +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 0), 0, 'SendableArray.prototype.indexOf.call(obj, 0)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 1), -1, 'SendableArray.prototype.indexOf.call(obj, 1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-20.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-20.js new file mode 100644 index 00000000000..668eeb75d92 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-20.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is an Object which has + an own valueOf method. +---*/ + +//valueOf method will be invoked first, since hint is Number +var obj = { + 1: true, + 2: 2, + length: { + valueOf: function() { + return 2; + } + } +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 1, 'SendableArray.prototype.indexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 2), -1, 'SendableArray.prototype.indexOf.call(obj, 2)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-21.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-21.js new file mode 100644 index 00000000000..2a54e62bafd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-21.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'length' is an object that has an own + valueOf method that returns an object and toString method that + returns a string +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var obj = { + 1: true, + length: { + toString: function() { + toStringAccessed = true; + return '2'; + }, + valueOf: function() { + valueOfAccessed = true; + return {}; + } + } +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 1, 'SendableArray.prototype.indexOf.call(obj, true)'); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-22.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-22.js new file mode 100644 index 00000000000..84206b2d756 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-22.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf throws TypeError exception when 'length' + is an object with toString and valueOf methods that don�t return + primitive values +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var obj = { + length: { + toString: function() { + toStringAccessed = true; + return {}; + }, + valueOf: function() { + valueOfAccessed = true; + return {}; + } + } +}; +assert.throws(TypeError, function() { + SendableArray.prototype.indexOf.call(obj); +}); +assert(toStringAccessed, 'toStringAccessed'); +assert(valueOfAccessed, 'valueOfAccessed'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-23.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-23.js new file mode 100644 index 00000000000..e8359db7b9d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-23.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf uses inherited valueOf method when + 'length' is an object with an own toString and inherited valueOf + methods +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return 2; +}; +var obj = { + 1: true, + length: child +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 1, 'SendableArray.prototype.indexOf.call(obj, true)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-24.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-24.js new file mode 100644 index 00000000000..730c466d666 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-24.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +var obj = { + 122: true, + 123: false, + length: 123.321 +}; //length will be 123 finally +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 122, 'SendableArray.prototype.indexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, false), -1, 'SendableArray.prototype.indexOf.call(obj, false)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-25.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-25.js new file mode 100644 index 00000000000..3fb359e887f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-25.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a negative + non-integer +---*/ + +var obj = { + 1: true, + 2: false, + length: -4294967294.5 +}; //length will be 0 finally +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), -1, 'SendableArray.prototype.indexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, false), -1, 'SendableArray.prototype.indexOf.call(obj, false)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-28.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-28.js new file mode 100644 index 00000000000..285396837be --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-28.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is boundary value + (2^32) +---*/ + +var targetObj = {}; +var obj = { + 0: targetObj, + 4294967294: targetObj, + 4294967295: targetObj, + length: 4294967296 +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, targetObj), 0, 'SendableArray.prototype.indexOf.call(obj, targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-29.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-29.js new file mode 100644 index 00000000000..3bcf6287f2d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-29.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is boundary value + (2^32 + 1) +---*/ + +var targetObj = {}; +var obj = { + 0: targetObj, + 1: 4294967297, + length: 4294967297 +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, targetObj), 0, 'SendableArray.prototype.indexOf.call(obj, targetObj)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 4294967297), 1, 'SendableArray.prototype.indexOf.call(obj, 4294967297)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-3.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-3.js new file mode 100644 index 00000000000..71dcaa6c97a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-3.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a number (value is + 0) +---*/ + +var obj = { + 0: true, + length: 0 +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), -1, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-4.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-4.js new file mode 100644 index 00000000000..1fccb8e25cd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-4.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a number (value is + +0) +---*/ + +var obj = { + 0: true, + length: +0 +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), -1, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-5.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-5.js new file mode 100644 index 00000000000..4aa4bcc5f49 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-5.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a number (value is + -0) +---*/ + +var obj = { + 0: true, + length: -0 +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), -1, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-6.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-6.js new file mode 100644 index 00000000000..fab9bdd1d56 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-6.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a number (value is + positive) +---*/ + +var obj = { + 3: true, + 4: false, + length: 4 +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 3, 'SendableArray.prototype.indexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, false), -1, 'SendableArray.prototype.indexOf.call(obj, false)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-7.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-7.js new file mode 100644 index 00000000000..0a979076e8c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-7.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a number (value is + negative) +---*/ + +var obj = { + 4: true, + 5: false, + length: 5 - Math.pow(2, 32) +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), -1, 'SendableArray.prototype.indexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, false), -1, 'SendableArray.prototype.indexOf.call(obj, false)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-8.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-8.js new file mode 100644 index 00000000000..c35e0f7c7d4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-8.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a number (value is + Infinity) +---*/ + +var obj = { + 0: 0, + length: Infinity +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 0), 0, 'SendableArray.prototype.indexOf.call(obj, 0)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-9.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-9.js new file mode 100644 index 00000000000..0f31baf9eab --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-3-9.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'length' is a number (value is + -Infinity) +---*/ + +var obj = { + 0: 0, + length: -Infinity +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 0), -1, 'SendableArray.prototype.indexOf.call(obj, 0)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-1.js new file mode 100644 index 00000000000..c83cc6de077 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-1.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf returns -1 if 'length' is 0 (empty array) +---*/ + +var i = [].indexOf(42); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-10.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-10.js new file mode 100644 index 00000000000..e31f7205e48 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-10.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is a number of value -6e-1 +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: -6e-1 +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, targetObj), -1, 'SendableArray.prototype.indexOf.call(obj, targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-11.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-11.js new file mode 100644 index 00000000000..9e1266e8583 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-11.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is an empty string +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: "" +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, targetObj), -1, 'SendableArray.prototype.indexOf.call(obj, targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-2.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-2.js new file mode 100644 index 00000000000..322ef0e29d9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 ( length + overridden to null (type conversion)) +---*/ + +var i = SendableArray.prototype.indexOf.call({ + length: null +}, 1); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-3.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-3.js new file mode 100644 index 00000000000..63f5ffd3494 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 (length + overridden to false (type conversion)) +---*/ + +var i = SendableArray.prototype.indexOf.call({ + length: false +}, 1); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-4.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-4.js new file mode 100644 index 00000000000..3cabf2f3921 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-4.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 (generic + 'array' with length 0 ) +---*/ + +var i = SendableArray.prototype.indexOf.call({ + length: 0 +}, 1); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-5.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-5.js new file mode 100644 index 00000000000..df32f58a878 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-5.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 ( length + overridden to '0' (type conversion)) +---*/ + +var i = SendableArray.prototype.indexOf.call({ + length: '0' +}, 1); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-6.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-6.js new file mode 100644 index 00000000000..e16aa662ab3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-6.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 (subclassed + Array, length overridden with obj with valueOf) +---*/ + +var i = SendableArray.prototype.indexOf.call({ + length: { + valueOf: function() { + return 0; + } + } +}, 1); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-7.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-7.js new file mode 100644 index 00000000000..fb8df3d8263 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-7.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 ( length is + object overridden with obj w/o valueOf (toString)) +---*/ + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +var i = SendableArray.prototype.indexOf.call({ + length: { + toString: function() { + return '0'; + } + } +}, 1); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-8.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-8.js new file mode 100644 index 00000000000..2e6e0193e2e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-8.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if 'length' is 0 (length is an + empty array) +---*/ + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +var i = SendableArray.prototype.indexOf.call({ + length: [] +}, 1); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-9.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-9.js new file mode 100644 index 00000000000..cca2badc7f4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-4-9.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'length' is a number of value 0.1 +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: 0.1 +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, targetObj), -1, 'SendableArray.prototype.indexOf.call(obj, targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-1.js new file mode 100644 index 00000000000..cfa6070d7ca --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf when fromIndex is string +---*/ + +var a = [1, 2, 1, 2, 1, 2]; +assert.sameValue(a.indexOf(2, "2"), 3, '"2" resolves to 2'); +assert.sameValue(a.indexOf(2, "one"), 1, '"one" resolves to 0'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-10.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-10.js new file mode 100644 index 00000000000..83796e455a9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-10.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is positive number) +---*/ + +var targetObj = {}; +assert.sameValue([0, targetObj, 2].indexOf(targetObj, 2), -1, '[0, targetObj, 2].indexOf(targetObj, 2)'); +assert.sameValue([0, 1, targetObj].indexOf(targetObj, 2), 2, '[0, 1, targetObj].indexOf(targetObj, 2)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-11.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-11.js new file mode 100644 index 00000000000..7f3d2999bef --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-11.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is negative number) +---*/ + +var targetObj = {}; +assert.sameValue([0, targetObj, 2].indexOf(targetObj, -1), -1, '[0, targetObj, 2].indexOf(targetObj, -1)'); +assert.sameValue([0, 1, targetObj].indexOf(targetObj, -1), 2, '[0, 1, targetObj].indexOf(targetObj, -1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-12.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-12.js new file mode 100644 index 00000000000..9ffe2409925 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-12.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is Infinity) +---*/ + +var arr = []; +arr[Math.pow(2, 32) - 2] = true; //length is the max value of Uint type +assert.sameValue(arr.indexOf(true, Infinity), -1, 'arr.indexOf(true, Infinity)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-13.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-13.js new file mode 100644 index 00000000000..7b8577844c4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-13.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is -Infinity) +---*/ + +assert.sameValue([true].indexOf(true, -Infinity), 0, '[true].indexOf(true, -Infinity)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-14.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-14.js new file mode 100644 index 00000000000..a75911a00d5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-14.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is NaN) +---*/ + +assert.sameValue([true].indexOf(true, NaN), 0, '[true].indexOf(true, NaN)'); +assert.sameValue([true].indexOf(true, -NaN), 0, '[true].indexOf(true, -NaN)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-15.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-15.js new file mode 100644 index 00000000000..2c76fa9032c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-15.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a string + containing a negative number +---*/ + +assert.sameValue([0, true, 2].indexOf(true, "-1"), -1, '[0, true, 2].indexOf(true, "-1")'); +assert.sameValue([0, 1, true].indexOf(true, "-1"), 2, '[0, 1, true].indexOf(true, "-1")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-16.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-16.js new file mode 100644 index 00000000000..95c07270251 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-16.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a string + containing Infinity +---*/ + +var arr = []; +arr[Math.pow(2, 32) - 2] = true; //length is the max value of Uint type +assert.sameValue(arr.indexOf(true, "Infinity"), -1, 'arr.indexOf(true, "Infinity")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-17.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-17.js new file mode 100644 index 00000000000..87f31555ea8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-17.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a string + containing -Infinity +---*/ + +assert.sameValue([true].indexOf(true, "-Infinity"), 0, '[true].indexOf(true, "-Infinity")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-18.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-18.js new file mode 100644 index 00000000000..8643864b289 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-18.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a string + containing an exponential number +---*/ + +var targetObj = {}; +assert.sameValue([0, 1, targetObj, 3, 4].indexOf(targetObj, "3E0"), -1, '[0, 1, targetObj, 3, 4].indexOf(targetObj, "3E0")'); +assert.sameValue([0, 1, 2, targetObj, 4].indexOf(targetObj, "3E0"), 3, '[0, 1, 2, targetObj, 4].indexOf(targetObj, "3E0")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-19.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-19.js new file mode 100644 index 00000000000..4ea193f3583 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-19.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a string + containing a hex number +---*/ + +var targetObj = {}; +assert.sameValue([0, 1, targetObj, 3, 4].indexOf(targetObj, "0x0003"), -1, '[0, 1, targetObj, 3, 4].indexOf(targetObj, "0x0003")'); +assert.sameValue([0, 1, 2, targetObj, 4].indexOf(targetObj, "0x0003"), 3, '[0, 1, 2, targetObj, 4].indexOf(targetObj, "0x0003")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-2.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-2.js new file mode 100644 index 00000000000..f0748b2fcf2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-2.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf when fromIndex is floating point number +---*/ + +var a = new SendableArray(1, 2, 3); +assert.sameValue(a.indexOf(3, 0.49), 2, '0.49 resolves to 0'); +assert.sameValue(a.indexOf(1, 0.51), 0, '0.51 resolves to 0'); +assert.sameValue(a.indexOf(1, 1.51), -1, '1.51 resolves to 1'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-20.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-20.js new file mode 100644 index 00000000000..7c01e669be7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-20.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' which is a string + containing a number with leading zeros +---*/ + +var targetObj = {}; +assert.sameValue([0, 1, targetObj, 3, 4].indexOf(targetObj, "0003.10"), -1, '[0, 1, targetObj, 3, 4].indexOf(targetObj, "0003.10")'); +assert.sameValue([0, 1, 2, targetObj, 4].indexOf(targetObj, "0003.10"), 3, '[0, 1, 2, targetObj, 4].indexOf(targetObj, "0003.10")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-21.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-21.js new file mode 100644 index 00000000000..772334754c3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-21.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is an Object, which + has an own toString method +---*/ + +// objects inherit the default valueOf() method from Object +// that simply returns itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +var fromIndex = { + toString: function() { + return '1'; + } +}; +assert.sameValue([0, true].indexOf(true, fromIndex), 1, '[0, true].indexOf(true, fromIndex)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-22.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-22.js new file mode 100644 index 00000000000..e70c3446d0a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-22.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is an Object, which + has an own valueOf method +---*/ + +var fromIndex = { + valueOf: function() { + return 1; + } +}; +assert.sameValue([0, true].indexOf(true, fromIndex), 1, '[0, true].indexOf(true, fromIndex)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-23.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-23.js new file mode 100644 index 00000000000..98fe576f422 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-23.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is an object that + has an own valueOf method that returns an object and toString + method that returns a string +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var fromIndex = { + toString: function() { + toStringAccessed = true; + return '1'; + }, + valueOf: function() { + valueOfAccessed = true; + return {}; + } +}; +assert.sameValue([0, true].indexOf(true, fromIndex), 1, '[0, true].indexOf(true, fromIndex)'); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-24.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-24.js new file mode 100644 index 00000000000..9181c63d0ea --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-24.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf throws TypeError exception when value of + 'fromIndex' is an object with toString and valueOf methods that + don�t return primitive values +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var fromIndex = { + toString: function() { + toStringAccessed = true; + return {}; + }, + valueOf: function() { + valueOfAccessed = true; + return {}; + } +}; +assert.throws(TypeError, function() { + [0, true].indexOf(true, fromIndex); +}); +assert(toStringAccessed, 'toStringAccessed'); +assert(valueOfAccessed, 'valueOfAccessed'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-25.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-25.js new file mode 100644 index 00000000000..4669ff38b5e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-25.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf uses inherited valueOf method when value + of 'fromIndex' is an object with an own toString and inherited + valueOf methods +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 1; + } +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return 2; +}; +assert.sameValue([0, true].indexOf(true, child), 1, '[0, true].indexOf(true, child)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-26.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-26.js new file mode 100644 index 00000000000..d83bccafda9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-26.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var stepTwoOccurs = false; +var stepFiveOccurs = false; +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + stepTwoOccurs = true; + if (stepFiveOccurs) { + throw new Error("Step 5 occurred out of order"); + } + return 20; + }, + configurable: true +}); +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +SendableArray.prototype.indexOf.call(obj, undefined, fromIndex); +assert(stepTwoOccurs, 'stepTwoOccurs !== true'); +assert(stepFiveOccurs, 'stepFiveOccurs !== true'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-27.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-27.js new file mode 100644 index 00000000000..0cbe9266128 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-27.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var stepThreeOccurs = false; +var stepFiveOccurs = false; +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return { + valueOf: function() { + stepThreeOccurs = true; + if (stepFiveOccurs) { + throw new Error("Step 5 occurred out of order"); + } + return 20; + } + }; + }, + configurable: true +}); +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +SendableArray.prototype.indexOf.call(obj, undefined, fromIndex); +assert(stepThreeOccurs, 'stepThreeOccurs !== true'); +assert(stepFiveOccurs, 'stepFiveOccurs !== true'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-28.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-28.js new file mode 100644 index 00000000000..768a459e288 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-28.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - side effects produced by step 1 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(TypeError, function() { + SendableArray.prototype.indexOf.call(undefined, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-29.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-29.js new file mode 100644 index 00000000000..7ca8affaf0b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-29.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + throw new RangeError(); + }, + configurable: true +}); +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(RangeError, function() { + SendableArray.prototype.indexOf.call(obj, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-3.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-3.js new file mode 100644 index 00000000000..db566b7c8e0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-3.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf when fromIndex is boolean +---*/ + +var a = [1, 2, 3]; +assert.sameValue(a.indexOf(1, true), -1, 'true resolves to 1'); +assert.sameValue(a.indexOf(1, false), 0, 'false resolves to 0'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-30.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-30.js new file mode 100644 index 00000000000..e544bedd706 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-30.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return { + valueOf: function() { + throw new TypeError(); + } + }; + }, + configurable: true +}); +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(TypeError, function() { + SendableArray.prototype.indexOf.call(obj, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-31.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-31.js new file mode 100644 index 00000000000..83d5f260abb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-31.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'fromIndex' is a positive non-integer, + verify truncation occurs in the proper direction +---*/ +var targetObj = {}; +assert.sameValue([0, targetObj, 2].indexOf(targetObj, 2.5), -1, '[0, targetObj, 2].indexOf(targetObj, 2.5)'); +assert.sameValue([0, 1, targetObj].indexOf(targetObj, 2.5), 2, '[0, 1, targetObj].indexOf(targetObj, 2.5)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-32.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-32.js new file mode 100644 index 00000000000..5ed7021faef --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-32.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - 'fromIndex' is a negative non-integer, + verify truncation occurs in the proper direction +---*/ + +var targetObj = {}; +assert.sameValue([0, targetObj, 2].indexOf(targetObj, -1.5), -1, '[0, targetObj, 2].indexOf(targetObj, -1.5)'); +assert.sameValue([0, 1, targetObj].indexOf(targetObj, -1.5), 2, '[0, 1, targetObj].indexOf(targetObj, -1.5)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-33.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-33.js new file mode 100644 index 00000000000..7f91ee7e152 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-33.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf match on the first element, a middle + element and the last element when 'fromIndex' is passed +---*/ + +assert.sameValue([0, 1, 2, 3, 4].indexOf(0, 0), 0, '[0, 1, 2, 3, 4].indexOf(0, 0)'); +assert.sameValue([0, 1, 2, 3, 4].indexOf(2, 1), 2, '[0, 1, 2, 3, 4].indexOf(2, 1)'); +assert.sameValue([0, 1, 2, 3, 4].indexOf(2, 2), 2, '[0, 1, 2, 3, 4].indexOf(2, 2)'); +assert.sameValue([0, 1, 2, 3, 4].indexOf(4, 2), 4, '[0, 1, 2, 3, 4].indexOf(4, 2)'); +assert.sameValue([0, 1, 2, 3, 4].indexOf(4, 4), 4, '[0, 1, 2, 3, 4].indexOf(4, 4)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-4.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-4.js new file mode 100644 index 00000000000..2102fbb686a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-4.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf returns 0 if fromIndex is 'undefined' +---*/ + +var a = [1, 2, 3]; +// undefined resolves to 0 +assert.sameValue(a.indexOf(1, undefined), 0, 'a.indexOf(1,undefined)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-5.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-5.js new file mode 100644 index 00000000000..d43ef22b781 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-5.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf returns 0 if fromIndex is null +---*/ + +var a = [1, 2, 3]; +// null resolves to 0 +assert.sameValue(a.indexOf(1, null), 0, 'a.indexOf(1,null)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-6.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-6.js new file mode 100644 index 00000000000..046eb537c22 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-6.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - 'fromIndex' isn't passed +---*/ + +var arr = [0, 1, 2, 3, 4]; +//'fromIndex' will be set as 0 if not passed by default +assert.sameValue(arr.indexOf(0), arr.indexOf(0, 0), 'arr.indexOf(0)'); +assert.sameValue(arr.indexOf(2), arr.indexOf(2, 0), 'arr.indexOf(2)'); +assert.sameValue(arr.indexOf(4), arr.indexOf(4, 0), 'arr.indexOf(4)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-7.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-7.js new file mode 100644 index 00000000000..866ee13d71d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-7.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is 0) +---*/ + +assert.sameValue([true].indexOf(true, 0), 0, '[true].indexOf(true, 0)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-8.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-8.js new file mode 100644 index 00000000000..f997b0185d5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-8.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is +0) +---*/ + +assert.sameValue([true].indexOf(true, +0), 0, '[true].indexOf(true, +0)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-9.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-9.js new file mode 100644 index 00000000000..dace812d5b4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-5-9.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - value of 'fromIndex' is a number (value + is -0) +---*/ + +assert.sameValue([true].indexOf(true, -0), 0, '[true].indexOf(true, -0)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-6-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-6-1.js new file mode 100644 index 00000000000..8fba94ed59c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-6-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 if fromIndex is greater than + Array length +---*/ + +var a = [1, 2, 3]; +assert.sameValue(a.indexOf(1, 5), -1, 'a.indexOf(1,5)'); +assert.sameValue(a.indexOf(1, 3), -1, 'a.indexOf(1,3)'); +assert.sameValue([].indexOf(1, 0), -1, '[ ].indexOf(1,0)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-1.js new file mode 100644 index 00000000000..8714701d0fd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 when 'fromIndex' is length of + array - 1 +---*/ + +assert.sameValue([1, 2, 3].indexOf(1, 2), -1, '[1, 2, 3].indexOf(1, 2)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-2.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-2.js new file mode 100644 index 00000000000..6a1b3846371 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-2.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns correct index when 'fromIndex' is + length of array - 1 +---*/ + +assert.sameValue([1, 2, 3].indexOf(3, 2), 2, '[1, 2, 3].indexOf(3, 2)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-3.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-3.js new file mode 100644 index 00000000000..d721d920f56 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-3.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 when 'fromIndex' and 'length' + are both 0 +---*/ + +assert.sameValue([].indexOf(1, 0), -1, '[].indexOf(1, 0)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-4.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-4.js new file mode 100644 index 00000000000..9280f1a116f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-4.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf returns -1 when 'fromIndex' is 1 +---*/ + +assert.sameValue([1, 2, 3].indexOf(1, 1), -1, '[1, 2, 3].indexOf(1, 1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-5.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-5.js new file mode 100644 index 00000000000..dfc9f376517 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-7-5.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf returns correct index when 'fromIndex' is 1 +---*/ + +assert.sameValue([1, 2, 3].indexOf(2, 1), 1, '[1, 2, 3].indexOf(2, 1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-1.js new file mode 100644 index 00000000000..743de311f9d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-1.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf with negative fromIndex +---*/ + +var a = new SendableArray(1, 2, 3); +assert.sameValue(a.indexOf(2, -1), -1, 'a.indexOf(2,-1)'); +assert.sameValue(a.indexOf(2, -2), 1, 'a.indexOf(2,-2)'); +assert.sameValue(a.indexOf(1, -3), 0, 'a.indexOf(1,-3)'); +assert.sameValue(a.indexOf(1, -5.3), 0, 'a.indexOf(1,-5.3)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-2.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-2.js new file mode 100644 index 00000000000..29e89a810dd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-2.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns correct index when 'fromIndex' is + -1 +---*/ + +assert.sameValue([1, 2, 3, 4].indexOf(4, -1), 3, '[1, 2, 3, 4].indexOf(4, -1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-3.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-3.js new file mode 100644 index 00000000000..727571d431e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-3.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 when abs('fromIndex') is length + of array - 1 +---*/ + +assert.sameValue([1, 2, 3, 4].indexOf(1, -3), -1, '[1, 2, 3, 4].indexOf(1, -3)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-4.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-4.js new file mode 100644 index 00000000000..5b0625f6e1e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-8-4.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf returns -1 when abs('fromIndex') is length + of array +---*/ + +assert.sameValue([1, 2, 3, 4].indexOf(0, -4), -1, '[1, 2, 3, 4].indexOf(0, -4)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-1.js new file mode 100644 index 00000000000..c35c70f7f3a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-1.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index (boolean) +---*/ + +var obj = { + toString: function() { + return true + } +}; +var _false = false; +var a = [obj, "true", undefined, 0, _false, null, 1, "str", 0, 1, true, false, true, false]; +assert.sameValue(a.indexOf(true), 10, 'a[10]=true'); +assert.sameValue(a.indexOf(false), 4, 'a[4] =_false'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-10.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-10.js new file mode 100644 index 00000000000..0dea4088890 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-10.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + note that prior to the finally ES5 draft SameValue was used for comparisions + and hence NaNs could be found using indexOf * +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index (NaN) +---*/ + +var _NaN = NaN; +var a = new SendableArray("NaN", undefined, 0, false, null, { + toString: function() { + return NaN + } +}, "false", _NaN, NaN); +assert.sameValue(a.indexOf(NaN), -1, 'NaN is equal to nothing, including itself.'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-11.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-11.js new file mode 100644 index 00000000000..88217c37793 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-11.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - the length of iteration isn't changed by + adding elements to the array during iteration +---*/ + +var arr = [20]; +Object.defineProperty(arr, "0", { + get: function() { + arr[1] = 1; + return 0; + }, + configurable: true +}); +assert.sameValue(arr.indexOf(1), -1, 'arr.indexOf(1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-2.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-2.js new file mode 100644 index 00000000000..8f67b0cc0d7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-2.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index (Number) +---*/ + +var obj = { + toString: function() { + return 0 + } +}; +var one = 1; +var _float = -(4 / 3); +var a = new SendableArray(false, undefined, null, "0", obj, -1.3333333333333, "str", -0, true, +0, one, 1, 0, false, _float, -(4 / 3)); +assert.sameValue(a.indexOf(-(4 / 3)), 14, 'a[14]=_float===-(4/3)'); +assert.sameValue(a.indexOf(0), 7, 'a[7] = +0, 0===+0'); +assert.sameValue(a.indexOf(-0), 7, 'a[7] = +0, -0===+0'); +assert.sameValue(a.indexOf(1), 10, 'a[10] =one=== 1'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-3.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-3.js new file mode 100644 index 00000000000..0c462ffb935 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-3.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index(string) +---*/ + +var obj = { + toString: function() { + return "false" + } +}; +var szFalse = "false"; +var a = new SendableArray("false1", undefined, 0, false, null, 1, obj, 0, szFalse, "false"); +assert.sameValue(a.indexOf("false"), 8, 'a[8]=szFalse'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-4.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-4.js new file mode 100644 index 00000000000..9513f0510d5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index(undefined) +---*/ + +var obj = { + toString: function() { + return undefined; + } +}; +var _undefined1 = undefined; +var _undefined2; +var a = new SendableArray(true, 0, false, null, 1, "undefined", obj, 1, _undefined2, _undefined1, undefined); +assert.sameValue(a.indexOf(undefined), 8, 'a[8]=_undefined2'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-5.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-5.js new file mode 100644 index 00000000000..0cb30d90310 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-5.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index (Object) +---*/ + +var obj1 = { + toString: function() { + return "false" + } +}; +var obj2 = { + toString: function() { + return "false" + } +}; +var obj3 = obj1; +var a = new SendableArray(false, undefined, 0, false, null, { + toString: function() { + return "false" + } +}, "false", obj2, obj1, obj3); +assert.sameValue(a.indexOf(obj3), 8, 'a[8] = obj1'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-6.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-6.js new file mode 100644 index 00000000000..be17e7f80f2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-6.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index(null) +---*/ + +var obj = { + toString: function() { + return null + } +}; +var _null = null; +var a = new SendableArray(true, undefined, 0, false, _null, 1, "str", 0, 1, obj, true, false, null); +assert.sameValue(a.indexOf(null), 4, 'a[4]=_null'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-7.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-7.js new file mode 100644 index 00000000000..4f178232f6b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-7.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index (self reference) +---*/ + +var a = new SendableArray(0, 1, 2, 3); +a[2] = a; +assert.sameValue(a.indexOf(a), 2, 'a.indexOf(a)'); +assert.sameValue(a.indexOf(3), 3, 'a.indexOf(3)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-8.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-8.js new file mode 100644 index 00000000000..9bb19492ede --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-8.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index (Array) +---*/ + +var b = new SendableArray("0,1"); +var a = new SendableArray(0, b, "0,1", 3); +assert.sameValue(a.indexOf(b.toString()), 2, 'a.indexOf(b.toString())'); +assert.sameValue(a.indexOf("0,1"), 2, 'a.indexOf("0,1")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-9.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-9.js new file mode 100644 index 00000000000..4a55156c7a7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-9.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf must return correct index (Sparse Array) +---*/ + +var a = new SendableArray(0, 1); +a[4294967294] = 2; // 2^32-2 - is max array element +a[4294967295] = 3; // 2^32-1 added as non-array element property +a[4294967296] = 4; // 2^32 added as non-array element property +a[4294967297] = 5; // 2^32+1 added as non-array element property +// start searching near the end so in case implementation actually tries to test all missing elements!! +assert.sameValue(a.indexOf(2, 4294967290), 4294967294, 'a.indexOf(2,4294967290 )'); +assert.sameValue(a.indexOf(3, 4294967290), -1, 'a.indexOf(3,4294967290)'); +assert.sameValue(a.indexOf(4, 4294967290), -1, 'a.indexOf(4,4294967290)'); +assert.sameValue(a.indexOf(5, 4294967290), -1, 'a.indexOf(5,4294967290)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-1.js new file mode 100644 index 00000000000..3f3d892eb64 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - added properties in step 2 are visible + here +---*/ + +var arr = {}; +Object.defineProperty(arr, "length", { + get: function() { + arr[2] = "length"; + return 3; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(arr, "length"), 2, 'SendableArray.prototype.indexOf.call(arr, "length")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-10.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-10.js new file mode 100644 index 00000000000..b40fae58854 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-10.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - properties can be added to prototype + after current position are visited on an Array +---*/ + +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert.sameValue(arr.indexOf(6.99), 1, 'arr.indexOf(6.99)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-11.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-11.js new file mode 100644 index 00000000000..68ac0b71f58 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-11.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleting own property causes index + property not to be visited on an Array-like object +---*/ + +var arr = { + length: 2 +}; +Object.defineProperty(arr, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(arr, 6.99), -1, 'SendableArray.prototype.indexOf.call(arr, 6.99)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-12.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-12.js new file mode 100644 index 00000000000..fb32f1c37c5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-12.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleting own property causes index + property not to be visited on an Array +---*/ + +var arr = [1, 2]; +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +assert.sameValue(arr.indexOf("6.99"), -1, 'arr.indexOf("6.99")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-13.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-13.js new file mode 100644 index 00000000000..dce2d961a42 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-13.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleting property of prototype causes + prototype index property not to be visited on an Array-like Object +---*/ + +var arr = { + 2: 2, + length: 20 +}; +Object.defineProperty(arr, "0", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +assert.sameValue(SendableArray.prototype.indexOf.call(arr, 1), -1, 'SendableArray.prototype.indexOf.call(arr, 1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-14.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-14.js new file mode 100644 index 00000000000..7213ff063be --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-14.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleting property of prototype causes + prototype index property not to be visited on an Array +---*/ + +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + delete SendableArray.prototype[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +assert.sameValue(arr.indexOf(1), -1, 'arr.indexOf(1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-15.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-15.js new file mode 100644 index 00000000000..14da09fe8c3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-15.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +var arr = { + 0: 0, + 1: 111, + 2: 2, + length: 10 +}; +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +assert.sameValue(SendableArray.prototype.indexOf.call(arr, 1), 1, 'SendableArray.prototype.indexOf.call(arr, 1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-16.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-16.js new file mode 100644 index 00000000000..9b1a1092696 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-16.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +var arr = [0, 111, 2]; +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +assert.sameValue(arr.indexOf(1), 1, 'arr.indexOf(1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-17.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-17.js new file mode 100644 index 00000000000..5ff0551d7c9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-17.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - decreasing length of array causes index + property not to be visited +---*/ + +var arr = [0, 1, 2, "last"]; +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); +assert.sameValue(arr.indexOf("last"), -1, 'arr.indexOf("last")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-18.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-18.js new file mode 100644 index 00000000000..085edf9c46a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-18.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - decreasing length of array with + prototype property causes prototype index property to be visited +---*/ + +var arr = [0, 1, 2]; +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +assert.sameValue(arr.indexOf("prototype"), 2, 'arr.indexOf("prototype")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-19.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-19.js new file mode 100644 index 00000000000..612d091b0b9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-19.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - decreasing length of array does not + delete non-configurable properties +flags: [noStrict] +---*/ + +var arr = [0, 1, 2]; +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +assert.sameValue(arr.indexOf("unconfigurable"), 2, 'arr.indexOf("unconfigurable")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-2.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-2.js new file mode 100644 index 00000000000..84065561eb5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-2.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - added properties in step 5 are visible + here on an Array-like object +---*/ + +var arr = { + length: 30 +}; +var targetObj = function() {}; +var fromIndex = { + valueOf: function() { + arr[4] = targetObj; + return 3; + } +}; +assert.sameValue(SendableArray.prototype.indexOf.call(arr, targetObj, fromIndex), 4, 'SendableArray.prototype.indexOf.call(arr, targetObj, fromIndex)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-3.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-3.js new file mode 100644 index 00000000000..04e6c66d763 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-3.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - added properties in step 5 are visible + here on an Array +---*/ + +var arr = []; +arr.length = 30; +var targetObj = function() {}; +var fromIndex = { + valueOf: function() { + arr[4] = targetObj; + return 3; + } +}; +assert.sameValue(arr.indexOf(targetObj, fromIndex), 4, 'arr.indexOf(targetObj, fromIndex)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-4.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-4.js new file mode 100644 index 00000000000..aecfe87a56c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-4.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleted properties in step 2 are visible + here +---*/ + +var arr = { + 2: 6.99 +}; +Object.defineProperty(arr, "length", { + get: function() { + delete arr[2]; + return 3; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(arr, 6.99), -1, 'SendableArray.prototype.indexOf.call(arr, 6.99)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-5.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-5.js new file mode 100644 index 00000000000..f82480b57a8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-5.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleted properties in step 5 are visible + here on an Array-like object +---*/ + +var arr = { + 10: false, + length: 30 +}; +var fromIndex = { + valueOf: function() { + delete arr[10]; + return 3; + } +}; +assert.sameValue(SendableArray.prototype.indexOf.call(arr, false, fromIndex), -1, 'SendableArray.prototype.indexOf.call(arr, false, fromIndex)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-6.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-6.js new file mode 100644 index 00000000000..155a53d8386 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-6.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - deleted properties in step 5 are visible + here on an Array +---*/ + +var arr = []; +arr[10] = "10"; +arr.length = 20; +var fromIndex = { + valueOf: function() { + delete arr[10]; + return 3; + } +}; +assert.sameValue(arr.indexOf("10", fromIndex), -1, 'arr.indexOf("10", fromIndex)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-7.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-7.js new file mode 100644 index 00000000000..83e927c114d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-7.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - properties added into own object after + current position are visited on an Array-like object +---*/ + +var arr = { + length: 2 +}; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(arr, 1), 1, 'SendableArray.prototype.indexOf.call(arr, 1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-8.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-8.js new file mode 100644 index 00000000000..381ae64b014 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-8.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - properties added into own object after + current position are visited on an Array +---*/ + +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert.sameValue(arr.indexOf(1), 1, 'arr.indexOf(1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-9.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-9.js new file mode 100644 index 00000000000..d0c91cdfc32 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-a-9.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - properties can be added to prototype + after current position are visited on an Array-like object +---*/ + +var arr = { + length: 2 +}; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(arr, 6.99), 1, 'SendableArray.prototype.indexOf.call(arr, 6.99)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-1.js new file mode 100644 index 00000000000..cb212c6c581 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-1.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - non-existent property wouldn't be called +---*/ + +assert.sameValue([0, , 2].indexOf(undefined), -1, '[0, , 2].indexOf(undefined)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-1.js new file mode 100644 index 00000000000..f3ec14f21c5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own data + property on an Array-like object +---*/ + +var obj = { + 0: 0, + 1: 1, + 2: 2, + length: 3 +}; +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 0), 0, 'SendableArray.prototype.indexOf.call(obj, 0)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 1), 1, 'SendableArray.prototype.indexOf.call(obj, 1)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 2), 2, 'SendableArray.prototype.indexOf.call(obj, 2)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-10.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-10.js new file mode 100644 index 00000000000..6b7a97ced5c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-10.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property on an Array-like object +---*/ + +var obj = { + length: 3 +}; +Object.defineProperty(obj, "0", { + get: function() { + return 0; + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + return 1; + }, + configurable: true +}); +Object.defineProperty(obj, "2", { + get: function() { + return 2; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 0), 0, 'SendableArray.prototype.indexOf.call(obj, 0)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 1), 1, 'SendableArray.prototype.indexOf.call(obj, 1)'); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, 2), 2, 'SendableArray.prototype.indexOf.call(obj, 2)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-11.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-11.js new file mode 100644 index 00000000000..0b9d53237f1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-11.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +var arr = []; +SendableArray.prototype[0] = false; +Object.defineProperty(arr, "0", { + get: function() { + return true; + }, + configurable: true +}); +assert.sameValue(arr.indexOf(true), 0, 'arr.indexOf(true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-12.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-12.js new file mode 100644 index 00000000000..8eecdb0ec94 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-12.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +var obj = { + length: 1 +}; +Object.prototype[0] = false; +Object.defineProperty(obj, "0", { + get: function() { + return true; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 0, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-13.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-13.js new file mode 100644 index 00000000000..3efa5967a3c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-13.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +var arr = []; +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + return true; + }, + configurable: true +}); +assert.sameValue(arr.indexOf(true), 0, 'arr.indexOf(true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-14.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-14.js new file mode 100644 index 00000000000..79f64db5569 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-14.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var obj = { + length: 1 +}; +Object.defineProperty(Object.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + return true; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 0, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-15.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-15.js new file mode 100644 index 00000000000..7ee3451543b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-15.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is inherited + accessor property on an Array +---*/ + +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 10; + }, + configurable: true +}); +Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 20; + }, + configurable: true +}); + +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return 30; + }, + configurable: true +}); +assert.sameValue([, , , ].indexOf(10), 0, '[, , , ].indexOf(10)'); +assert.sameValue([, , , ].indexOf(20), 1, '[, , , ].indexOf(20)'); +assert.sameValue([, , , ].indexOf(30), 2, '[, , , ].indexOf(30)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-16.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-16.js new file mode 100644 index 00000000000..0ca4ea77d1c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-16.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return 10; + }, + configurable: true +}); +Object.defineProperty(Object.prototype, "1", { + get: function() { + return 20; + }, + configurable: true +}); +Object.defineProperty(Object.prototype, "2", { + get: function() { + return 30; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call({ + length: 3 +}, 10), 0, 'SendableArray.prototype.indexOf.call({ length: 3 }, 10)'); +assert.sameValue(SendableArray.prototype.indexOf.call({ + length: 3 +}, 20), 1, 'SendableArray.prototype.indexOf.call({ length: 3 }, 20)'); +assert.sameValue(SendableArray.prototype.indexOf.call({ + length: 3 +}, 30), 2, 'SendableArray.prototype.indexOf.call({ length: 3 }, 30)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-17.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-17.js new file mode 100644 index 00000000000..b7f94cc386f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-17.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +assert.sameValue(arr.indexOf(undefined), 0, 'arr.indexOf(undefined)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-18.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-18.js new file mode 100644 index 00000000000..d5cc5e04018 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-18.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +var obj = { + length: 1 +}; +Object.defineProperty(obj, "0", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, undefined), 0, 'SendableArray.prototype.indexOf.call(obj, undefined)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-19.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-19.js new file mode 100644 index 00000000000..ab54b822d23 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-19.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 2; + }, + configurable: true +}); +assert.sameValue(arr.indexOf(undefined), 0, 'arr.indexOf(undefined)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-2.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-2.js new file mode 100644 index 00000000000..7e01f92dfc8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-2.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own data + property on an Array +---*/ + +assert.sameValue([true, true, true].indexOf(true), 0, '[true, true, true].indexOf(true)'); +assert.sameValue([false, true, true].indexOf(true), 1, '[false, true, true].indexOf(true)'); +assert.sameValue([false, false, true].indexOf(true), 2, '[false, false, true].indexOf(true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-20.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-20.js new file mode 100644 index 00000000000..1965455780c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-20.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +var proto = {}; +Object.defineProperty(proto, "0", { + get: function() { + return 2; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 1; +Object.defineProperty(child, "0", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(child, undefined), 0, 'SendableArray.prototype.indexOf.call(child, undefined)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-21.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-21.js new file mode 100644 index 00000000000..46b441db8bd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-21.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +Object.defineProperty(SendableArray.prototype, "0", { + set: function() {}, + configurable: true +}); +assert.sameValue([, ].indexOf(undefined), 0, '[, ].indexOf(undefined)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-22.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-22.js new file mode 100644 index 00000000000..eea799f728e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-22.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call({ + length: 1 +}, undefined), 0, 'SendableArray.prototype.indexOf.call({ length: 1 }, undefined)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-25.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-25.js new file mode 100644 index 00000000000..338f95ec729 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-25.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf applied to Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +var func = function(a, b) { + return 0 === SendableArray.prototype.indexOf.call(arguments, arguments[0]) && + -1 === SendableArray.prototype.indexOf.call(arguments, arguments[1]); +}; +assert(func(true), 'func(true) !== true'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-26.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-26.js new file mode 100644 index 00000000000..d2c8daaf861 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-26.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf applied to Arguments object which + implements its own property get method (number of arguments equals + to number of parameters) +---*/ + +var func = function(a, b) { + return 0 === SendableArray.prototype.indexOf.call(arguments, arguments[0]) && + 1 === SendableArray.prototype.indexOf.call(arguments, arguments[1]) && + -1 === SendableArray.prototype.indexOf.call(arguments, arguments[2]); +}; +assert(func(0, true), 'func(0, true) !== true'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-27.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-27.js new file mode 100644 index 00000000000..2c34eeef890 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-27.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf applied to Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +var func = function(a, b) { + return 0 === SendableArray.prototype.indexOf.call(arguments, arguments[0]) && + 3 === SendableArray.prototype.indexOf.call(arguments, arguments[3]) && + -1 === SendableArray.prototype.indexOf.call(arguments, arguments[4]); +}; +assert(func(0, false, 0, true), 'func(0, false, 0, true) !== true'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-28.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-28.js new file mode 100644 index 00000000000..33be2220291 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-28.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - side-effects are visible in subsequent + iterations on an Array +---*/ + +var preIterVisible = false; +var arr = []; +Object.defineProperty(arr, "0", { + get: function() { + preIterVisible = true; + return false; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return true; + } else { + return false; + } + }, + configurable: true +}); +assert.sameValue(arr.indexOf(true), 1, 'arr.indexOf(true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-29.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-29.js new file mode 100644 index 00000000000..1509950f0f2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-29.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - side-effects are visible in subsequent + iterations on an Array-like object +---*/ + +var preIterVisible = false; +var obj = { + length: 2 +}; +Object.defineProperty(obj, "0", { + get: function() { + preIterVisible = true; + return false; + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return true; + } else { + return false; + } + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call(obj, true), 1, 'SendableArray.prototype.indexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-3.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-3.js new file mode 100644 index 00000000000..a6b4b75cad8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +SendableArray.prototype[0] = false; +assert.sameValue([true].indexOf(true), 0, '[true].indexOf(true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-30.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-30.js new file mode 100644 index 00000000000..6345e677595 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-30.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - terminates iteration on unhandled + exception on an Array +---*/ + +var accessed = false; +var arr = []; +Object.defineProperty(arr, "0", { + get: function() { + throw new TypeError(); + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + accessed = true; + return true; + }, + configurable: true +}); +assert.throws(TypeError, function() { + arr.indexOf(true); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-31.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-31.js new file mode 100644 index 00000000000..8805ccf0776 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-31.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - terminates iteration on unhandled + exception on an Array-like object +---*/ + +var accessed = false; +var obj = { + length: 2 +}; +Object.defineProperty(obj, "0", { + get: function() { + throw new TypeError(); + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + accessed = true; + return true; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.indexOf.call(obj, true); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-4.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-4.js new file mode 100644 index 00000000000..285f3675b67 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +Object.prototype[0] = false; +assert.sameValue(SendableArray.prototype.indexOf.call({ + 0: true, + 1: 1, + length: 2 +}, true), 0, 'SendableArray.prototype.indexOf.call({ 0: true, 1: 1, length: 2 }, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-5.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-5.js new file mode 100644 index 00000000000..94162802ea5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-5.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); +assert.sameValue([true].indexOf(true), 0, '[true].indexOf(true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-6.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-6.js new file mode 100644 index 00000000000..881b7354d1c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-6.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.indexOf.call({ + 0: true, + 1: 1, + length: 2 +}, true), 0, 'SendableArray.prototype.indexOf.call({ 0: true, 1: 1, length: 2 }, true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-7.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-7.js new file mode 100644 index 00000000000..6f2f6e968d2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-7.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is inherited + data property on an Array +---*/ + +SendableArray.prototype[0] = true; +SendableArray.prototype[1] = false; +SendableArray.prototype[2] = "true"; +assert.sameValue([, , , ].indexOf(true), 0, '[, , , ].indexOf(true)'); +assert.sameValue([, , , ].indexOf(false), 1, '[, , , ].indexOf(false)'); +assert.sameValue([, , , ].indexOf("true"), 2, '[, , , ].indexOf("true")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-8.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-8.js new file mode 100644 index 00000000000..f7e313cf308 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-8.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is inherited + data property on an Array-like object +---*/ + +Object.prototype[0] = true; +Object.prototype[1] = false; +Object.prototype[2] = "true"; +assert.sameValue(SendableArray.prototype.indexOf.call({ + length: 3 +}, true), 0, 'SendableArray.prototype.indexOf.call({ length: 3 }, true)'); +assert.sameValue(SendableArray.prototype.indexOf.call({ + length: 3 +}, false), 1, 'SendableArray.prototype.indexOf.call({ length: 3 }, false)'); +assert.sameValue(SendableArray.prototype.indexOf.call({ + length: 3 +}, "true"), 2, 'SendableArray.prototype.indexOf.call({ length: 3 }, "true")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-9.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-9.js new file mode 100644 index 00000000000..8e33b55f384 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-i-9.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - element to be retrieved is own accessor + property on an Array +---*/ + +var arr = [, , , ]; +Object.defineProperty(arr, "0", { + get: function() { + return 0; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true +}); +Object.defineProperty(arr, "2", { + get: function() { + return 2; + }, + configurable: true +}); +assert.sameValue(arr.indexOf(0), 0, 'arr.indexOf(0)'); +assert.sameValue(arr.indexOf(1), 1, 'arr.indexOf(1)'); +assert.sameValue(arr.indexOf(2), 2, 'arr.indexOf(2)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-1.js new file mode 100644 index 00000000000..9115fb07230 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-1.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - type of array element is different from + type of search element +---*/ + +assert.sameValue(["true"].indexOf(true), -1, '["true"].indexOf(true)'); +assert.sameValue(["0"].indexOf(0), -1, '["0"].indexOf(0)'); +assert.sameValue([false].indexOf(0), -1, '[false].indexOf(0)'); +assert.sameValue([undefined].indexOf(0), -1, '[undefined].indexOf(0)'); +assert.sameValue([null].indexOf(0), -1, '[null].indexOf(0)'); +assert.sameValue([ + [] +].indexOf(0), -1, '[[]].indexOf(0)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-10.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-10.js new file mode 100644 index 00000000000..e5b9a0ca16a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-10.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - both array element and search element + are Boolean type, and they have same value +---*/ + +assert.sameValue([false, true].indexOf(true), 1, '[false, true].indexOf(true)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-11.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-11.js new file mode 100644 index 00000000000..21cb78f66c0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-11.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - both array element and search element + are Object type, and they refer to the same object +---*/ + +var obj1 = {}; +var obj2 = {}; +var obj3 = obj2; +assert.sameValue([{}, obj1, obj2].indexOf(obj3), 2, '[{}, obj1, obj2].indexOf(obj3)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-2.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-2.js new file mode 100644 index 00000000000..5a402ba3c79 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-2.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - both type of array element and type of + search element are Undefined +---*/ + +assert.sameValue([undefined].indexOf(), 0, '[undefined].indexOf()'); +assert.sameValue([undefined].indexOf(undefined), 0, '[undefined].indexOf(undefined)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-3.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-3.js new file mode 100644 index 00000000000..2d2c70bc79b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-3.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - both type of array element and type of + search element are null +---*/ + +assert.sameValue([null].indexOf(null), 0, '[null].indexOf(null)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-4.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-4.js new file mode 100644 index 00000000000..7cc3338e1ab --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-4.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - search element is NaN +---*/ + +assert.sameValue([+NaN, NaN, -NaN].indexOf(NaN), -1, '[+NaN, NaN, -NaN].indexOf(NaN)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-5.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-5.js new file mode 100644 index 00000000000..90e0f2a47e9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-5.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: Array.prototype.indexOf - search element is -NaN +---*/ + +assert.sameValue([+NaN, NaN, -NaN].indexOf(-NaN), -1, '[+NaN, NaN, -NaN].indexOf(-NaN)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-6.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-6.js new file mode 100644 index 00000000000..af65d31f9a1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-6.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - array element is +0 and search element + is -0 +---*/ + +assert.sameValue([+0].indexOf(-0), 0, '[+0].indexOf(-0)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-7.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-7.js new file mode 100644 index 00000000000..b3b349c4b73 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-7.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - array element is -0 and search element + is +0 +---*/ + +assert.sameValue([-0].indexOf(+0), 0, '[-0].indexOf(+0)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-8.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-8.js new file mode 100644 index 00000000000..fa283f8ad76 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-8.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - both array element and search element + are Number, and they have same value +---*/ + +assert.sameValue([-1, 0, 1].indexOf(1), 2, '[-1, 0, 1].indexOf(1)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-9.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-9.js new file mode 100644 index 00000000000..eb3ae7e3ab8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-ii-9.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - both array element and search element + are String, and they have exactly the same sequence of characters +---*/ + +assert.sameValue(["", "ab", "bca", "abc"].indexOf("abc"), 3, '["", "ab", "bca", "abc"].indexOf("abc")'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-iii-1.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-iii-1.js new file mode 100644 index 00000000000..833cb78aa8f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-iii-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - returns index of last one when more than + two elements in array are eligible +---*/ + +assert.sameValue([1, 2, 2, 1, 2].indexOf(2), 1, '[1, 2, 2, 1, 2].indexOf(2)'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-iii-2.js b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-iii-2.js new file mode 100644 index 00000000000..e673a615584 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/15.4.4.14-9-b-iii-2.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf - returns without visiting subsequent + element once search value is found +---*/ + +var arr = [1, 2, , 1, 2]; +var elementThirdAccessed = false; +var elementFifthAccessed = false; +Object.defineProperty(arr, "2", { + get: function() { + elementThirdAccessed = true; + return 2; + }, + configurable: true +}); +Object.defineProperty(arr, "4", { + get: function() { + elementFifthAccessed = true; + return 2; + }, + configurable: true +}); +arr.indexOf(2); +assert.sameValue(elementThirdAccessed, false, 'elementThirdAccessed'); +assert.sameValue(elementFifthAccessed, false, 'elementFifthAccessed'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/call-with-boolean.js b/test/sendable/builtins/Array/prototype/indexOf/call-with-boolean.js new file mode 100644 index 00000000000..d1bdbd2cbfa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/call-with-boolean.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexOf +description: Array.prototype.indexOf applied to boolean primitive +---*/ + +assert.sameValue(SendableArray.prototype.indexOf.call(true), -1, 'SendableArray.prototype.indexOf.call(true) must return -1'); +assert.sameValue(SendableArray.prototype.indexOf.call(false), -1, 'SendableArray.prototype.indexOf.call(false) must return -1'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js b/test/sendable/builtins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js new file mode 100644 index 00000000000..f04b4aee50a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Calls [[HasProperty]] on the prototype to check for existing elements. +info: | + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) +---*/ + +var Array = [1, null, 3]; +Object.setPrototypeOf(array, new Proxy(Array.prototype, allowProxyTraps({ + has: function(t, pk) { + return pk in t; + } +}))); +var fromIndex = { + valueOf: function() { + // Zero the array's length. The loop in step 8 iterates over the original + // length value of 100, but the only prototype MOP method which should be + // called is [[HasProperty]]. + array.length = 0; + return 0; + } +}; +SendableArray.prototype.indexOf.call(array, 100, fromIndex); diff --git a/test/sendable/builtins/Array/prototype/indexOf/coerced-searchelement-fromindex-grow.js b/test/sendable/builtins/Array/prototype/indexOf/coerced-searchelement-fromindex-grow.js new file mode 100644 index 00000000000..0893b694f28 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/coerced-searchelement-fromindex-grow.js @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.p.indexOf behaves correctly when the backing resizable buffer is grown + during argument coercion. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Growing + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, 1); + } + let evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + let n0 = MayNeedBigInt(lengthTracking, 0); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, n0), -1); + // The TA grew but we only look at the data until the original length. + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, n0, evil), -1); +} +// Growing + length-tracking TA, index conversion. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + lengthTracking[0] = MayNeedBigInt(lengthTracking, 1); + let evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return -4; + } + }; + let n1 = MayNeedBigInt(lengthTracking, 1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, n1, -4), 0); + // The TA grew but the start index conversion is done based on the original + // length. + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, n1, evil), 0); +} diff --git a/test/sendable/builtins/Array/prototype/indexOf/coerced-searchelement-fromindex-shrink.js b/test/sendable/builtins/Array/prototype/indexOf/coerced-searchelement-fromindex-shrink.js new file mode 100644 index 00000000000..e9d7cd72a64 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/coerced-searchelement-fromindex-shrink.js @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.p.indexOf behaves correctly when the backing resizable buffer is shrunk + during argument coercion. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Shrinking + fixed-length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + let n0 = MayNeedBigInt(fixedLength, 0); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n0), 0); + // The TA is OOB so indexOf returns -1. + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n0, evil), -1); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + let n0 = MayNeedBigInt(fixedLength, 0); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n0), 0); + // The TA is OOB so indexOf returns -1, also for undefined). + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, undefined, evil), -1); +} + +// Shrinking + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i); + } + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + let n2 = MayNeedBigInt(lengthTracking, 2); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, n2), 2); + // 2 no longer found. + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, n2, evil), -1); +} diff --git a/test/sendable/builtins/Array/prototype/indexOf/fromindex-zero-conversion.js b/test/sendable/builtins/Array/prototype/indexOf/fromindex-zero-conversion.js new file mode 100644 index 00000000000..07ba939d00a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/fromindex-zero-conversion.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Return +0 when fromIndex is -0 and return index refers to the first position +---*/ + +assert.sameValue(1 / [true].indexOf(true, -0), +Infinity) diff --git a/test/sendable/builtins/Array/prototype/indexOf/length-near-integer-limit.js b/test/sendable/builtins/Array/prototype/indexOf/length-near-integer-limit.js new file mode 100644 index 00000000000..00b409d8aa1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/length-near-integer-limit.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.indexof +description: > + Elements are found in an array-like object + whose "length" property is near the integer limit. +info: | + Array.prototype.indexOf ( searchElement [ , fromIndex ] ) +---*/ + +var el = {}; +var elIndex = Number.MAX_SAFE_INTEGER - 1; +var fromIndex = Number.MAX_SAFE_INTEGER - 3; +var arrayLike = { + length: Number.MAX_SAFE_INTEGER, +}; +arrayLike[elIndex] = el; +var res = SendableArray.prototype.indexOf.call(arrayLike, el, fromIndex); +assert.sameValue(res, elIndex); diff --git a/test/sendable/builtins/Array/prototype/indexOf/length-zero-returns-minus-one.js b/test/sendable/builtins/Array/prototype/indexOf/length-zero-returns-minus-one.js new file mode 100644 index 00000000000..307df41a62e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/length-zero-returns-minus-one.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Returns -1 if length is 0. +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error("Length should be checked before ToInteger(fromIndex)."); + }, +}; +assert.sameValue([].indexOf(1), -1); +assert.sameValue([].indexOf(2, fromIndex), -1); diff --git a/test/sendable/builtins/Array/prototype/indexOf/length.js b/test/sendable/builtins/Array/prototype/indexOf/length.js new file mode 100644 index 00000000000..1273902733f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/length.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + The "length" property of Array.prototype.indexOf +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.indexOf, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/indexOf/name.js b/test/sendable/builtins/Array/prototype/indexOf/name.js new file mode 100644 index 00000000000..b79beaf2977 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.prototype.indexOf.name is "indexOf". +info: | + Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + 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(SendableArray.prototype.indexOf, "name", { + value: "indexOf", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/indexOf/not-a-constructor.js b/test/sendable/builtins/Array/prototype/indexOf/not-a-constructor.js new file mode 100644 index 00000000000..a3fca315435 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/not-a-constructor.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.indexOf 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(SendableArray.prototype.indexOf), + false, + 'isConstructor(SendableArray.prototype.indexOf) must return false' +); + +assert.throws(TypeError, () => { + new SendableArray.prototype.indexOf(); +}); + diff --git a/test/sendable/builtins/Array/prototype/indexOf/prop-desc.js b/test/sendable/builtins/Array/prototype/indexOf/prop-desc.js new file mode 100644 index 00000000000..7df511f4cd2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + "indexOf" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.indexOf, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "indexOf", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/indexOf/resizable-buffer-special-float-values.js b/test/sendable/builtins/Array/prototype/indexOf/resizable-buffer-special-float-values.js new file mode 100644 index 00000000000..b71c38596ae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/resizable-buffer-special-float-values.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-%array%.prototype.indexof +description: > + Array.p.indexOf behaves correctly for special float values on TypedArrays + backed by resizable buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer, Array.prototype.includes] +---*/ + +for (let ctor of floatCtors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + lengthTracking[0] = -Infinity; + lengthTracking[1] = -Infinity; + lengthTracking[2] = Infinity; + lengthTracking[3] = Infinity; + lengthTracking[4] = NaN; + lengthTracking[5] = NaN; + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, -Infinity), 0); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, Infinity), 2); + // NaN is never found. + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, NaN), -1); +} diff --git a/test/sendable/builtins/Array/prototype/indexOf/resizable-buffer.js b/test/sendable/builtins/Array/prototype/indexOf/resizable-buffer.js new file mode 100644 index 00000000000..556497dd5a0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/indexOf/resizable-buffer.js @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.indexof +description: > + Array.p.indexOf behaves correctly on TypedArrays backed by resizable buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2)); + } + // Orig. array: [0, 0, 1, 1] + // [0, 0, 1, 1] << fixedLength + // [1, 1] << fixedLengthWithOffset + // [0, 0, 1, 1, ...] << lengthTracking + // [1, 1, ...] << lengthTrackingWithOffset + // If fixedLength is a BigInt array, they all are BigInt Arrays. + let n0 = MayNeedBigInt(fixedLength, 0); + let n1 = MayNeedBigInt(fixedLength, 1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n0), 0); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n0, 1), 1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n0, 2), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n0, -2), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n0, -3), 1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n1, 1), 2); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n1, -3), 2); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n1, -2), 2); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, undefined), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLengthWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLengthWithOffset, n1), 0); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLengthWithOffset, n1, -2), 0); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLengthWithOffset, n1, -1), 1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLengthWithOffset, undefined), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, n0), 0); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, n0, 2), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, n1, -3), 2); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, undefined), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTrackingWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTrackingWithOffset, n1), 0); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTrackingWithOffset, n1, 1), 1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTrackingWithOffset, n1, -2), 0); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTrackingWithOffset, undefined), -1); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + // Orig. array: [0, 0, 1] + // [0, 0, 1, ...] << lengthTracking + // [1, ...] << lengthTrackingWithOffset + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n1), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLengthWithOffset, n1), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, n1), 2); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, undefined), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTrackingWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTrackingWithOffset, n1), 0); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTrackingWithOffset, undefined), -1); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n0), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLengthWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTrackingWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, n0), 0); + // Shrink to zero. + rab.resize(0); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n0), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLengthWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTrackingWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, n0), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, undefined), -1); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2)); + } + // Orig. array: [0, 0, 1, 1, 2, 2] + // [0, 0, 1, 1] << fixedLength + // [1, 1] << fixedLengthWithOffset + // [0, 0, 1, 1, 2, 2, ...] << lengthTracking + // [1, 1, 2, 2, ...] << lengthTrackingWithOffset + let n2 = MayNeedBigInt(fixedLength, 2); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n1), 2); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, n2), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLength, undefined), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLengthWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLengthWithOffset, n1), 0); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLengthWithOffset, n2), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(fixedLengthWithOffset, undefined), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, n1), 2); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, n2), 4); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTracking, undefined), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTrackingWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTrackingWithOffset, n1), 0); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTrackingWithOffset, n2), 2); + assert.sameValue(SendableArray.prototype.indexOf.call(lengthTrackingWithOffset, undefined), -1); +} -- Gitee From f6643e694f781c854e5042c7587fc8e0f950a2d4 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 27 Dec 2024 09:12:43 +0800 Subject: [PATCH 45/93] update case Signed-off-by: zhuzhihui7 --- .../calls-only-has-on-prototype-after-length-zeroed.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/sendable/builtins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js b/test/sendable/builtins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js index f04b4aee50a..1ca49080ecc 100644 --- a/test/sendable/builtins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js +++ b/test/sendable/builtins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js @@ -20,8 +20,8 @@ info: | 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) ---*/ -var Array = [1, null, 3]; -Object.setPrototypeOf(array, new Proxy(Array.prototype, allowProxyTraps({ +var SendableArray = [1, null, 3]; +Object.setPrototypeOf(SendableArray, new Proxy(SendableArray.prototype, allowProxyTraps({ has: function(t, pk) { return pk in t; } @@ -35,4 +35,4 @@ var fromIndex = { return 0; } }; -SendableArray.prototype.indexOf.call(array, 100, fromIndex); +SendableArray.prototype.indexOf.call(SendableArray, 100, fromIndex); -- Gitee From ab395fcf0ee17dbc275a7faad5613ecaac166c6c Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 27 Dec 2024 10:31:31 +0800 Subject: [PATCH 46/93] add array-join Signed-off-by: zhuzhihui7 --- .../Array/prototype/join/S15.4.4.5_A1.1_T1.js | 30 ++++ .../Array/prototype/join/S15.4.4.5_A1.2_T1.js | 35 +++++ .../Array/prototype/join/S15.4.4.5_A1.2_T2.js | 35 +++++ .../Array/prototype/join/S15.4.4.5_A1.3_T1.js | 34 +++++ .../Array/prototype/join/S15.4.4.5_A2_T1.js | 48 ++++++ .../Array/prototype/join/S15.4.4.5_A2_T2.js | 62 ++++++++ .../Array/prototype/join/S15.4.4.5_A2_T3.js | 53 +++++++ .../Array/prototype/join/S15.4.4.5_A2_T4.js | 96 ++++++++++++ .../Array/prototype/join/S15.4.4.5_A3.1_T1.js | 48 ++++++ .../Array/prototype/join/S15.4.4.5_A3.1_T2.js | 142 ++++++++++++++++++ .../Array/prototype/join/S15.4.4.5_A3.2_T1.js | 54 +++++++ .../Array/prototype/join/S15.4.4.5_A3.2_T2.js | 115 ++++++++++++++ .../Array/prototype/join/S15.4.4.5_A4_T3.js | 33 ++++ .../Array/prototype/join/S15.4.4.5_A5_T1.js | 37 +++++ .../Array/prototype/join/S15.4.4.5_A6.6.js | 23 +++ .../Array/prototype/join/call-with-boolean.js | 21 +++ .../prototype/join/coerced-separator-grow.js | 48 ++++++ .../join/coerced-separator-shrink.js | 52 +++++++ .../builtins/Array/prototype/join/length.js | 38 +++++ .../builtins/Array/prototype/join/name.js | 36 +++++ .../Array/prototype/join/not-a-constructor.js | 34 +++++ .../Array/prototype/join/prop-desc.js | 32 ++++ .../Array/prototype/join/resizable-buffer.js | 93 ++++++++++++ 23 files changed, 1199 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.3_T1.js create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T3.js create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T4.js create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.1_T2.js create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A4_T3.js create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A5_T1.js create mode 100644 test/sendable/builtins/Array/prototype/join/S15.4.4.5_A6.6.js create mode 100644 test/sendable/builtins/Array/prototype/join/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/join/coerced-separator-grow.js create mode 100644 test/sendable/builtins/Array/prototype/join/coerced-separator-shrink.js create mode 100644 test/sendable/builtins/Array/prototype/join/length.js create mode 100644 test/sendable/builtins/Array/prototype/join/name.js create mode 100644 test/sendable/builtins/Array/prototype/join/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/join/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/join/resizable-buffer.js diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.1_T1.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.1_T1.js new file mode 100644 index 00000000000..cb305d4163b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.1_T1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: If length is zero, return the empty string +esid: sec-array.prototype.join +description: Checking this use new Array() and [] +---*/ + +var x = new SendableArray(); +if (x.join() !== "") { + throw new Test262Error('#1: x = new Array(); x.join() === "". Actual: ' + (x.join())); +} +x = []; +x[0] = 1; +x.length = 0; +if (x.join() !== "") { + throw new Test262Error('#2: x = []; x[0] = 1; x.length = 0; x.join() === "". Actual: ' + (x.join())); +} diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.2_T1.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.2_T1.js new file mode 100644 index 00000000000..1d6f017ec21 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.2_T1.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: If separator is undefined, a single comma is used as the separator +esid: sec-array.prototype.join +description: Checking this use new Array() and [] +---*/ + +var x = new SendableArray(0, 1, 2, 3); +if (x.join() !== "0,1,2,3") { + throw new Test262Error('#1: x = new Array(0,1,2,3); x.join() === "0,1,2,3". Actual: ' + (x.join())); +} +x = []; +x[0] = 0; +x[3] = 3; +if (x.join() !== "0,,,3") { + throw new Test262Error('#2: x = []; x[0] = 0; x[3] = 3; x.join() === "0,,,3". Actual: ' + (x.join())); +} +x = []; +x[0] = 0; +if (x.join() !== "0") { + throw new Test262Error('#3: x = []; x[0] = 0; x.join() === "0". Actual: ' + (x.join())); +} diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.2_T2.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.2_T2.js new file mode 100644 index 00000000000..d199506deae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.2_T2.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: If separator is undefined, a single comma is used as the separator +esid: sec-array.prototype.join +description: Checking this use new Array() and [] +---*/ + +var x = new SendableArray(0, 1, 2, 3); +if (x.join(undefined) !== "0,1,2,3") { + throw new Test262Error('#1: x = new Array(0,1,2,3); x.join(undefined) === "0,1,2,3". Actual: ' + (x.join(undefined))); +} +x = []; +x[0] = 0; +x[3] = 3; +if (x.join(undefined) !== "0,,,3") { + throw new Test262Error('#2: x = []; x[0] = 0; x[3] = 3; x.join(undefined) === "0,,,3". Actual: ' + (x.join(undefined))); +} +x = []; +x[0] = 0; +if (x.join(undefined) !== "0") { + throw new Test262Error('#3: x = []; x[0] = 0; x.join(undefined) === "0". Actual: ' + (x.join(undefined))); +} diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.3_T1.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.3_T1.js new file mode 100644 index 00000000000..a25b7dcdbe7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A1.3_T1.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: If array element is undefined or null, use the empty string +esid: sec-array.prototype.join +description: Checking this use new Array() and [] +---*/ + +var x = []; +x[0] = undefined; +if (x.join() !== "") { + throw new Test262Error('#1: x = []; x[0] = undefined; x.join() === "". Actual: ' + (x.join())); +} +x = []; +x[0] = null; +if (x.join() !== "") { + throw new Test262Error('#2: x = []; x[0] = null; x.join() === "". Actual: ' + (x.join())); +} +x = SendableArray(undefined, 1, null, 3); +if (x.join() !== ",1,,3") { + throw new Test262Error('#3: x = SendableArray(undefined,1,null,3); x.join() === ",1,,3". Actual: ' + (x.join())); +} diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T1.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T1.js new file mode 100644 index 00000000000..431558261d6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T1.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The join function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.join +description: If ToUint32(length) is zero, return the empty string +---*/ + +var obj = {}; +obj.join = SendableArray.prototype.join; +if (obj.length !== undefined) { + throw new Test262Error('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + if (obj.join() !== "") { + throw new Test262Error('#1: var obj = {}; obj.join = SendableArray.prototype.join; obj.join() === "". Actual: ' + (obj.join())); + } + if (obj.length !== undefined) { + throw new Test262Error('#2: var obj = {}; obj.join = SendableArray.prototype.join; obj.join(); obj.length === undefined. Actual: ' + (obj.length)); + } +} +obj.length = undefined; +if (obj.join() !== "") { + throw new Test262Error('#3: var obj = {}; obj.length = undefined; obj.join = SendableArray.prototype.join; obj.join() === ". Actual: ' + (obj.join())); +} +if (obj.length !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.length = undefined; obj.join = SendableArray.prototype.join; obj.join(); obj.length === undefined. Actual: ' + (obj.length)); +} +obj.length = null +if (obj.join() !== "") { + throw new Test262Error('#5: var obj = {}; obj.length = null; obj.join = SendableArray.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} +if (obj.length !== null) { + throw new Test262Error('#6: var obj = {}; obj.length = null; obj.join = SendableArray.prototype.join; obj.join(); obj.length === null. Actual: ' + (obj.length)); +} diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T2.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T2.js new file mode 100644 index 00000000000..5860d0f53f0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T2.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The join function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.join +description: If ToUint32(length) is zero, return the empty string +---*/ + +var obj = {}; +obj.join = SendableArray.prototype.join; +obj.length = NaN; +if (obj.join() !== "") { + throw new Test262Error('#1: var obj = {}; obj.length = NaN; obj.join = SendableArray.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} +assert.sameValue(obj.length, NaN, "obj.length is NaN"); +obj.length = Number.NEGATIVE_INFINITY; +if (obj.join() !== "") { + throw new Test262Error('#5: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.join = SendableArray.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} +if (obj.length !== Number.NEGATIVE_INFINITY) { + throw new Test262Error('#6: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.join = SendableArray.prototype.join; obj.join(); obj.length === Number.NEGATIVE_INFINITY. Actual: ' + (obj.length)); +} +obj.length = -0; +if (obj.join() !== "") { + throw new Test262Error('#7: var obj = {}; obj.length = -0; obj.join = SendableArray.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} +if (obj.length !== -0) { + throw new Test262Error('#8: var obj = {}; obj.length = -0; obj.join = SendableArray.prototype.join; obj.join(); obj.length === 0. Actual: ' + (obj.length)); +} else { + if (1 / obj.length !== Number.NEGATIVE_INFINITY) { + throw new Test262Error('#8: var obj = {}; obj.length = -0; obj.join = SendableArray.prototype.join; obj.join(); obj.length === -0. Actual: ' + (obj.length)); + } +} +obj.length = 0.5; +if (obj.join() !== "") { + throw new Test262Error('#9: var obj = {}; obj.length = 0.5; obj.join = SendableArray.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} +if (obj.length !== 0.5) { + throw new Test262Error('#10: var obj = {}; obj.length = 0.5; obj.join = SendableArray.prototype.join; obj.join(); obj.length === 0.5. Actual: ' + (obj.length)); +} +var x = new Number(0); +obj.length = x; +if (obj.join() !== "") { + throw new Test262Error('#11: var x = new Number(0); var obj = {}; obj.length = x; obj.join = SendableArray.prototype.join; obj.join() === "". Actual: ' + (obj.join())); +} +if (obj.length !== x) { + throw new Test262Error('#12: var x = new Number(0); var obj = {}; obj.length = x; obj.join = SendableArray.prototype.join; obj.join(); obj.length === x. Actual: ' + (obj.length)); +} diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T3.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T3.js new file mode 100644 index 00000000000..6b325492018 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T3.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The join function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.join +description: If ToUint32(length) is zero, return the empty string +---*/ + +var obj = {}; +obj.join = SendableArray.prototype.join; +obj.length = 4.5; +if (obj.join() !== ",,,") { + throw new Test262Error('#1: var obj = {}; obj.length = 4.5; obj.join = SendableArray.prototype.join; obj.join() === ",,,". Actual: ' + (obj.join())); +} +obj[0] = undefined; +obj[1] = 1; +obj[2] = null; +if (obj.join() !== ",1,,") { + throw new Test262Error('#1: var obj = {}; obj.length = 4.5; obj[0] = undefined; obj[1] = 1; obj[2] = null; obj.join = SendableArray.prototype.join; obj.join() === ",1,,". Actual: ' + (obj.join())); +} +if (obj.length !== 4.5) { + throw new Test262Error('#1: var obj = {}; obj.length = 4.5; obj[0] = undefined; obj[1] = 1; obj[2] = null; obj.join = SendableArray.prototype.join; obj.join(); obj.length === 4.5. Actual: ' + (obj.length)); +} +var obj = {}; +obj.join = SendableArray.prototype.join; +var x = new Number(4.5); +obj.length = x; +if (obj.join() !== ",,,") { + throw new Test262Error('#4: var obj = {}; var x = new Number(4.5); obj.length = x; obj.join = SendableArray.prototype.join; obj.join() === ",,,". Actual: ' + (obj.join())); +} +obj[0] = undefined; +obj[1] = 1; +obj[2] = null; +if (obj.join() !== ",1,,") { + throw new Test262Error('#5: var obj = {}; var x = new Number(4.5); obj.length = x; obj[0] = undefined; obj[1] = 1; obj[2] = null; obj.join = SendableArray.prototype.join; obj.join() === ",1,,". Actual: ' + (obj.join())); +} +if (obj.length !== x) { + throw new Test262Error('#6: var obj = {}; var x = new Number(4.5); obj.length = x; obj[0] = undefined; obj[1] = 1; obj[2] = null; obj.join = SendableArray.prototype.join; obj.join(); obj.length === x. Actual: ' + (obj.length)); +} diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T4.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T4.js new file mode 100644 index 00000000000..7feba2b3dfd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A2_T4.js @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The join function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.join +description: > + Operator use ToNumber from length. If Type(value) is Object, + evaluate ToPrimitive(value, Number) +---*/ + +var obj = {}; +obj.join = SendableArray.prototype.join; +obj.length = { + valueOf() { + return 3 + } +}; +assert.sameValue(obj.join(), ",,", 'obj.join() must return ",,"'); +obj.length = { + valueOf() { + return 3 + }, + toString() { + return 2 + } +}; +assert.sameValue(obj.join(), ",,", 'obj.join() must return ",,"'); +obj.length = { + valueOf() { + return 3 + }, + toString() { + return {} + } +}; +assert.sameValue(obj.join(), ",,", 'obj.join() must return ",,"'); +obj.length = { + valueOf() { + return 3 + }, + toString() { + throw new Test262Error(); + } +}; +assert.sameValue(obj.join(), ",,", 'obj.join() must return ",,"'); +obj.length = { + toString() { + return 2 + } +}; +assert.sameValue(obj.join(), ",", 'obj.join() must return ","'); +obj.length = { + valueOf() { + return {} + }, + toString() { + return 2 + } +} +assert.sameValue(obj.join(), ",", 'obj.join() must return ","'); +assert.throws(Test262Error, () => { + obj.length = { + valueOf() { + throw new Test262Error(); + }, + toString() { + return 2 + } + }; + obj.join(); +}); +assert.throws(TypeError, () => { + obj.length = { + valueOf() { + return {} + }, + toString() { + return {} + } + }; + obj.join(); +}); diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.1_T1.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.1_T1.js new file mode 100644 index 00000000000..1e0aa94d132 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.1_T1.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToString from separator +esid: sec-array.prototype.join +description: > + Checking separator in ["", "\\", "&", true, Infinity, null, + undefind, NaN] +---*/ + +var x = new SendableArray(0, 1, 2, 3); +if (x.join("") !== "0123") { + throw new Test262Error('#0: x = new SendableArray(0,1,2,3); x.join("") === "0123". Actual: ' + (x.join(""))); +} +x = new Array(0, 1, 2, 3); +if (x.join("\\") !== "0\\1\\2\\3") { + throw new Test262Error('#1: x = new SendableArray(0,1,2,3); x.join("\\") === "0\\1\\2\\3". Actual: ' + (x.join("\\"))); +} +if (x.join("&") !== "0&1&2&3") { + throw new Test262Error('#2: x = new SendableArray(0,1,2,3); x.join("&") === "0&1&2&3". Actual: ' + (x.join("&"))); +} +if (x.join(true) !== "0true1true2true3") { + throw new Test262Error('#3: x = new SendableArray(0,1,2,3); x.join(true) === "0true1true2true3". Actual: ' + (x.join(true))); +} +if (x.join(Infinity) !== "0Infinity1Infinity2Infinity3") { + throw new Test262Error('#4: x = new SendableArray(0,1,2,3); x.join(Infinity) === "0Infinity1Infinity2Infinity3". Actual: ' + (x.join(Infinity))); +} +if (x.join(null) !== "0null1null2null3") { + throw new Test262Error('#3: 5 = new SendableArray(0,1,2,3); x.join(null) === "0null1null2null3". Actual: ' + (x.join(null))); +} +if (x.join(undefined) !== "0,1,2,3") { + throw new Test262Error('#6: x = new SendableArray(0,1,2,3); x.join(undefined) === "0,1,2,3". Actual: ' + (x.join(undefined))); +} +if (x.join(NaN) !== "0NaN1NaN2NaN3") { + throw new Test262Error('#7: x = new SendableArray(0,1,2,3); x.join(NaN) === "0NaN1NaN2NaN3". Actual: ' + (x.join(NaN))); +} diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.1_T2.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.1_T2.js new file mode 100644 index 00000000000..8066554e2a4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.1_T2.js @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToString from separator +esid: sec-array.prototype.join +description: > + If Type(separator) is Object, evaluate ToPrimitive(separator, + String) +---*/ + +var x = new SendableArray(0, 1, 2, 3); +var object = { + valueOf() { + return "+" + } +}; +assert.sameValue( + x.join(object), + "0[object Object]1[object Object]2[object Object]3", + 'x.join({valueOf() {return "+"}}) must return "0[object Object]1[object Object]2[object Object]3"' +); +var object = { + valueOf() { + return "+" + }, + toString() { + return "*" + } +}; +assert.sameValue( + x.join(object), + "0*1*2*3", + 'x.join("{valueOf() {return "+"}, toString() {return "*"}}) must return "0*1*2*3"' +); +var object = { + valueOf() { + return "+" + }, + toString() { + return {} + } +}; +assert.sameValue( + x.join(object), + "0+1+2+3", + 'x.join({valueOf() {return "+"}, toString() {return {}}}) must return "0+1+2+3"' +); +try { + var object = { + valueOf() { + throw "error" + }, + toString() { + return "*" + } + }; + assert.sameValue( + x.join(object), + "0*1*2*3", + 'x.join("{valueOf() {throw "error"}, toString() {return "*"}}) must return "0*1*2*3"' + ); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} +var object = { + toString() { + return "*" + } +}; +assert.sameValue(x.join(object), "0*1*2*3", 'x.join({toString() {return "*"}}) must return "0*1*2*3"'); +var object = { + valueOf() { + return {} + }, + toString() { + return "*" + } +} +assert.sameValue( + x.join(object), + "0*1*2*3", + 'x.join({valueOf() {return {}}, toString() {return "*"}}) must return "0*1*2*3"' +); +try { + var object = { + valueOf() { + return "+" + }, + toString() { + throw "error" + } + }; + x.join(object); + throw new Test262Error('#7.1: var object = {valueOf() {return "+"}, toString() {throw "error"}}; x.join(object) throw "error". Actual: ' + (x.join(object))); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} +try { + var object = { + valueOf() { + return {} + }, + toString() { + return {} + } + }; + x.join(object); + throw new Test262Error('#8.1: var object = {valueOf() {return {}}, toString() {return {}}}; x.join(object) throw TypeError. Actual: ' + (x.join(object))); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} +try { + var object = { + toString() { + throw "error" + } + }; + [].join(object); + throw new Test262Error('#9.1: var object = {toString() {throw "error"}}; [].join(object) throw "error". Actual: ' + ([].join(object))); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.2_T1.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.2_T1.js new file mode 100644 index 00000000000..2a4e56185aa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.2_T1.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToString from array arguments +esid: sec-array.prototype.join +description: > + Checking arguments and separator in ["", "\\", "&", true, + Infinity, null, undefind, NaN] +---*/ + +var x = new SendableArray("", "", ""); +if (x.join("") !== "") { + throw new Test262Error('#0: var x = new SendableArray("","",""); x.join("") === "". Actual: ' + (x.join(""))); +} +var x = new SendableArray("\\", "\\", "\\"); +if (x.join("\\") !== "\\\\\\\\\\") { + throw new Test262Error('#1: var x = new SendableArray("\\","\\","\\"); x.join("\\") === "\\\\\\\\\\". Actual: ' + (x.join("\\"))); +} +var x = new SendableArray("&", "&", "&"); +if (x.join("&") !== "&&&&&") { + throw new Test262Error('#2: var x = new SendableArray("&", "&", "&"); x.join("&") === "&&&&&". Actual: ' + (x.join("&"))); +} +var x = new SendableArray(true, true, true); +if (x.join() !== "true,true,true") { + throw new Test262Error('#3: var x = new SendableArray(true,true,true); x.join(true,true,true) === "true,true,true". Actual: ' + (x.join(true, true, true))); +} +var x = new SendableArray(null, null, null); +if (x.join() !== ",,") { + throw new Test262Error('#4: var x = new SendableArray(null,null,null); x.join(null,null,null) === ",,". Actual: ' + (x.join(null, null, null))); +} +var x = new SendableArray(undefined, undefined, undefined); +if (x.join() !== ",,") { + throw new Test262Error('#5: var x = new SendableArray(undefined,undefined,undefined); x.join(undefined,undefined,undefined) === ",,". Actual: ' + (x.join(undefined, undefined, undefined))); +} +var x = new SendableArray(Infinity, Infinity, Infinity); +if (x.join() !== "Infinity,Infinity,Infinity") { + throw new Test262Error('#6: var x = new SendableArray(Infinity,Infinity,Infinity); x.join(Infinity,Infinity,Infinity) === "Infinity,Infinity,Infinity". Actual: ' + (x.join(Infinity, Infinity, Infinity))); +} +var x = new SendableArray(NaN, NaN, NaN); +if (x.join() !== "NaN,NaN,NaN") { + throw new Test262Error('#7: var x = new SendableArray(NaN,NaN,NaN); x.join(NaN,NaN,NaN) === "NaN,NaN,NaN". Actual: ' + (x.join(NaN, NaN, NaN))); +} diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.2_T2.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.2_T2.js new file mode 100644 index 00000000000..c584844f30c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A3.2_T2.js @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToString from array arguments +esid: sec-array.prototype.join +description: If Type(argument) is Object, evaluate ToPrimitive(argument, String) +---*/ + +var object = { + valueOf: function() { + return "+" + } +}; +var x = new SendableArray(object); +assert.sameValue(x.join(), "[object Object]", 'x.join() must return "[object Object]"'); +var object = { + valueOf: function() { + return "+" + }, + toString: function() { + return "*" + } +}; +var x = new SendableArray(object); +assert.sameValue(x.join(), "*", 'x.join() must return "*"'); +var object = { + valueOf: function() { + return "+" + }, + toString: function() { + return {} + } +}; +var x = new SendableArray(object); +assert.sameValue(x.join(), "+", 'x.join() must return "+"'); +try { + var object = { + valueOf: function() { + throw "error" + }, + toString: function() { + return "*" + } + }; + var x = new SendableArray(object); + assert.sameValue(x.join(), "*", 'x.join() must return "*"'); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} +var object = { + toString: function() { + return "*" + } +}; +var x = new SendableArray(object); +assert.sameValue(x.join(), "*", 'x.join() must return "*"'); +var object = { + valueOf: function() { + return {} + }, + toString: function() { + return "*" + } +} +var x = new SendableArray(object); +assert.sameValue(x.join(), "*", 'x.join() must return "*"'); +try { + var object = { + valueOf: function() { + return "+" + }, + toString: function() { + throw "error" + } + }; + var x = new SendableArray(object); + x.join(); + throw new Test262Error('#7.1: var object = {valueOf: function() {return "+"}, toString: function() {throw "error"}} var x = new SendableArray(object); x.join() throw "error". Actual: ' + (x.join())); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} +try { + var object = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + var x = new SendableArray(object); + x.join(); + throw new Test262Error('#8.1: var object = {valueOf: function() {return {}}, toString: function() {return {}}} var x = new SendableArray(object); x.join() throw TypeError. Actual: ' + (x.join())); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A4_T3.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A4_T3.js new file mode 100644 index 00000000000..8f770fb8135 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A4_T3.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.join +description: length = -4294967294 +---*/ + +var obj = {}; +obj.join = SendableArray.prototype.join; +obj[0] = "x"; +obj[1] = "y"; +obj[2] = "z"; +obj.length = -4294967294; + +if (obj.join("") !== "") { + throw new Test262Error('#1: var obj = {}; obj.join = SendableArray.prototype.join; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.join("") === "". Actual: ' + (obj.join(""))); +} +if (obj.length !== -4294967294) { + throw new Test262Error('#2: var obj = {}; obj.join = SendableArray.prototype.join; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.join(""); obj.length === -4294967294. Actual: ' + (obj.length)); +} diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A5_T1.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A5_T1.js new file mode 100644 index 00000000000..887473e387f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A5_T1.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]] from not an inherited property" +esid: sec-array.prototype.join +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +SendableArray.prototype[1] = 1; +var x = [0]; +x.length = 2; +if (x.join() !== "0,1") { + throw new Test262Error('#1: SendableArray.prototype[1] = 1; x = [0]; x.length = 2; x.join() === "0,1". Actual: ' + (x.join())); +} +Object.prototype[1] = 1; +Object.prototype.length = 2; +Object.prototype.join = SendableArray.prototype.join; +x = { + 0: 0 +}; +if (x.join() !== "0,1") { + throw new Test262Error('#2: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.join = SendableArray.prototype.join; x = {0:0}; x.join() === "0,1". Actual: ' + (x.join())); +} diff --git a/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A6.6.js b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A6.6.js new file mode 100644 index 00000000000..9c0ad3eb133 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/S15.4.4.5_A6.6.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: The join property of Array has not prototype property +esid: sec-array.prototype.join +description: Checking Array.prototype.join.prototype +---*/ + +if (SendableArray.prototype.join.prototype !== undefined) { + throw new Test262Error('#1: SendableArray.prototype.join.prototype === undefined. Actual: ' + (SendableArray.prototype.join.prototype)); +} diff --git a/test/sendable/builtins/Array/prototype/join/call-with-boolean.js b/test/sendable/builtins/Array/prototype/join/call-with-boolean.js new file mode 100644 index 00000000000..35036336721 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/call-with-boolean.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.join +description: Array.prototype.join applied to boolean primitive +---*/ + +assert.sameValue(SendableArray.prototype.join.call(true), "", 'SendableArray.prototype.join.call(true) must return ""'); +assert.sameValue(SendableArray.prototype.join.call(false), "", 'SendableArray.prototype.join.call(false) must return ""'); diff --git a/test/sendable/builtins/Array/prototype/join/coerced-separator-grow.js b/test/sendable/builtins/Array/prototype/join/coerced-separator-grow.js new file mode 100644 index 00000000000..ed54d5ed349 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/coerced-separator-grow.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.join +description: > + Array.p.join behaves correctly when the receiver is grown during + argument coercion +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Growing + fixed-length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + toString: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return '.'; + } + }; + assert.sameValue(SendableArray.prototype.join.call(fixedLength, evil), '0.0.0.0'); +} +// Growing + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + let evil = { + toString: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return '.'; + } + }; + // We iterate 4 elements, since it was the starting length. + assert.sameValue(SendableArray.prototype.join.call(lengthTracking, evil), '0.0.0.0'); +} diff --git a/test/sendable/builtins/Array/prototype/join/coerced-separator-shrink.js b/test/sendable/builtins/Array/prototype/join/coerced-separator-shrink.js new file mode 100644 index 00000000000..29837e4034a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/coerced-separator-shrink.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.join +description: > + Array.p.join behaves correctly when the receiver is shrunk during + argument coercion +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Shrinking + fixed-length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + toString: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return '.'; + } + }; + // We iterate 4 elements, since it was the starting length, but the TA is + // OOB right after parameter conversion, so all elements are converted to + // the empty string. + assert.sameValue(SendableArray.prototype.join.call(fixedLength, evil), '...'); +} +// Shrinking + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + let evil = { + toString: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return '.'; + } + }; + // We iterate 4 elements, since it was the starting length. Elements beyond + // the new length are converted to the empty string. + assert.sameValue(SendableArray.prototype.join.call(lengthTracking, evil), '0.0..'); +} diff --git a/test/sendable/builtins/Array/prototype/join/length.js b/test/sendable/builtins/Array/prototype/join/length.js new file mode 100644 index 00000000000..aaad9e7b397 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/length.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.join +description: > + The "length" property of Array.prototype.join +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.join, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/join/name.js b/test/sendable/builtins/Array/prototype/join/name.js new file mode 100644 index 00000000000..47e92550c38 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.join +description: > + Array.prototype.join.name is "join". +info: | + Array.prototype.join (separator) + 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(SendableArray.prototype.join, "name", { + value: "join", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/join/not-a-constructor.js b/test/sendable/builtins/Array/prototype/join/not-a-constructor.js new file mode 100644 index 00000000000..e333023858d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/not-a-constructor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.join 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(SendableArray.prototype.join), false, 'isConstructor(SendableArray.prototype.join) must return false'); +assert.throws(TypeError, () => { + new SendableArray.prototype.join(); +}); + diff --git a/test/sendable/builtins/Array/prototype/join/prop-desc.js b/test/sendable/builtins/Array/prototype/join/prop-desc.js new file mode 100644 index 00000000000..746617ef7c0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.join +description: > + "join" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.join, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "join", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/join/resizable-buffer.js b/test/sendable/builtins/Array/prototype/join/resizable-buffer.js new file mode 100644 index 00000000000..af8f11fa3a1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/join/resizable-buffer.js @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.join +description: > + Array.p.join behaves correctly when the receiver is backed by resizable + buffer +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const taWrite = new ctor(rab); + + // Write some data into the array. + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + assert.sameValue(Array.prototype.join.call(fixedLength), '0,2,4,6'); + assert.sameValue(Array.prototype.join.call(fixedLengthWithOffset), '4,6'); + assert.sameValue(Array.prototype.join.call(lengthTracking), '0,2,4,6'); + assert.sameValue(Array.prototype.join.call(lengthTrackingWithOffset), '4,6'); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.sameValue(Array.prototype.join.call(fixedLength), ''); + assert.sameValue(Array.prototype.join.call(fixedLengthWithOffset), ''); + + assert.sameValue(Array.prototype.join.call(lengthTracking), '0,2,4'); + assert.sameValue(Array.prototype.join.call(lengthTrackingWithOffset), '4'); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.sameValue(Array.prototype.join.call(fixedLength), ''); + assert.sameValue(Array.prototype.join.call(fixedLengthWithOffset), ''); + assert.sameValue(Array.prototype.join.call(lengthTrackingWithOffset), ''); + + assert.sameValue(Array.prototype.join.call(lengthTracking), '0'); + + // Shrink to zero. + rab.resize(0); + assert.sameValue(Array.prototype.join.call(fixedLength), ''); + assert.sameValue(Array.prototype.join.call(fixedLengthWithOffset), ''); + assert.sameValue(Array.prototype.join.call(lengthTrackingWithOffset), ''); + + assert.sameValue(Array.prototype.join.call(lengthTracking), ''); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert.sameValue(Array.prototype.join.call(fixedLength), '0,2,4,6'); + assert.sameValue(Array.prototype.join.call(fixedLengthWithOffset), '4,6'); + assert.sameValue(Array.prototype.join.call(lengthTracking), '0,2,4,6,8,10'); + assert.sameValue(Array.prototype.join.call(lengthTrackingWithOffset), '4,6,8,10'); +} -- Gitee From fe0fedff03ee36a77c56eff092a74070d714b2f1 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 27 Dec 2024 11:01:02 +0800 Subject: [PATCH 47/93] add array-keys Signed-off-by: zhuzhihui7 --- .../Array/prototype/join/resizable-buffer.js | 54 +++---- .../Array/prototype/keys/iteration-mutable.js | 46 ++++++ .../Array/prototype/keys/iteration.js | 41 +++++ .../builtins/Array/prototype/keys/length.js | 30 ++++ .../builtins/Array/prototype/keys/name.js | 30 ++++ .../Array/prototype/keys/not-a-constructor.js | 35 +++++ .../Array/prototype/keys/prop-desc.js | 35 +++++ .../resizable-buffer-grow-mid-iteration.js | 71 +++++++++ .../resizable-buffer-shrink-mid-iteration.js | 63 ++++++++ .../Array/prototype/keys/resizable-buffer.js | 142 ++++++++++++++++++ .../prototype/keys/return-abrupt-from-this.js | 31 ++++ .../keys/returns-iterator-from-object.js | 36 +++++ .../Array/prototype/keys/returns-iterator.js | 29 ++++ 13 files changed, 609 insertions(+), 34 deletions(-) create mode 100644 test/sendable/builtins/Array/prototype/keys/iteration-mutable.js create mode 100644 test/sendable/builtins/Array/prototype/keys/iteration.js create mode 100644 test/sendable/builtins/Array/prototype/keys/length.js create mode 100644 test/sendable/builtins/Array/prototype/keys/name.js create mode 100644 test/sendable/builtins/Array/prototype/keys/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/keys/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/keys/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/keys/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/keys/resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/keys/return-abrupt-from-this.js create mode 100644 test/sendable/builtins/Array/prototype/keys/returns-iterator-from-object.js create mode 100644 test/sendable/builtins/Array/prototype/keys/returns-iterator.js diff --git a/test/sendable/builtins/Array/prototype/join/resizable-buffer.js b/test/sendable/builtins/Array/prototype/join/resizable-buffer.js index af8f11fa3a1..fd94a6b19d4 100644 --- a/test/sendable/builtins/Array/prototype/join/resizable-buffer.js +++ b/test/sendable/builtins/Array/prototype/join/resizable-buffer.js @@ -28,66 +28,52 @@ for (let ctor of ctors) { const lengthTracking = new ctor(rab, 0); const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); const taWrite = new ctor(rab); - // Write some data into the array. for (let i = 0; i < 4; ++i) { taWrite[i] = MayNeedBigInt(taWrite, 2 * i); } - // Orig. array: [0, 2, 4, 6] // [0, 2, 4, 6] << fixedLength // [4, 6] << fixedLengthWithOffset // [0, 2, 4, 6, ...] << lengthTracking // [4, 6, ...] << lengthTrackingWithOffset - - assert.sameValue(Array.prototype.join.call(fixedLength), '0,2,4,6'); - assert.sameValue(Array.prototype.join.call(fixedLengthWithOffset), '4,6'); - assert.sameValue(Array.prototype.join.call(lengthTracking), '0,2,4,6'); - assert.sameValue(Array.prototype.join.call(lengthTrackingWithOffset), '4,6'); - + assert.sameValue(SendableArray.prototype.join.call(fixedLength), '0,2,4,6'); + assert.sameValue(SendableArray.prototype.join.call(fixedLengthWithOffset), '4,6'); + assert.sameValue(SendableArray.prototype.join.call(lengthTracking), '0,2,4,6'); + assert.sameValue(SendableArray.prototype.join.call(lengthTrackingWithOffset), '4,6'); // Shrink so that fixed length TAs go out of bounds. rab.resize(3 * ctor.BYTES_PER_ELEMENT); - // Orig. array: [0, 2, 4] // [0, 2, 4, ...] << lengthTracking // [4, ...] << lengthTrackingWithOffset - - assert.sameValue(Array.prototype.join.call(fixedLength), ''); - assert.sameValue(Array.prototype.join.call(fixedLengthWithOffset), ''); - - assert.sameValue(Array.prototype.join.call(lengthTracking), '0,2,4'); - assert.sameValue(Array.prototype.join.call(lengthTrackingWithOffset), '4'); - + assert.sameValue(SendableArray.prototype.join.call(fixedLength), ''); + assert.sameValue(SendableArray.prototype.join.call(fixedLengthWithOffset), ''); + assert.sameValue(SendableArray.prototype.join.call(lengthTracking), '0,2,4'); + assert.sameValue(SendableArray.prototype.join.call(lengthTrackingWithOffset), '4'); // Shrink so that the TAs with offset go out of bounds. rab.resize(1 * ctor.BYTES_PER_ELEMENT); - assert.sameValue(Array.prototype.join.call(fixedLength), ''); - assert.sameValue(Array.prototype.join.call(fixedLengthWithOffset), ''); - assert.sameValue(Array.prototype.join.call(lengthTrackingWithOffset), ''); - - assert.sameValue(Array.prototype.join.call(lengthTracking), '0'); - + assert.sameValue(SendableArray.prototype.join.call(fixedLength), ''); + assert.sameValue(SendableArray.prototype.join.call(fixedLengthWithOffset), ''); + assert.sameValue(SendableArray.prototype.join.call(lengthTrackingWithOffset), ''); + assert.sameValue(SendableArray.prototype.join.call(lengthTracking), '0'); // Shrink to zero. rab.resize(0); - assert.sameValue(Array.prototype.join.call(fixedLength), ''); - assert.sameValue(Array.prototype.join.call(fixedLengthWithOffset), ''); - assert.sameValue(Array.prototype.join.call(lengthTrackingWithOffset), ''); - - assert.sameValue(Array.prototype.join.call(lengthTracking), ''); - + assert.sameValue(SendableArray.prototype.join.call(fixedLength), ''); + assert.sameValue(SendableArray.prototype.join.call(fixedLengthWithOffset), ''); + assert.sameValue(SendableArray.prototype.join.call(lengthTrackingWithOffset), ''); + assert.sameValue(SendableArray.prototype.join.call(lengthTracking), ''); // Grow so that all TAs are back in-bounds. rab.resize(6 * ctor.BYTES_PER_ELEMENT); for (let i = 0; i < 6; ++i) { taWrite[i] = MayNeedBigInt(taWrite, 2 * i); } - // Orig. array: [0, 2, 4, 6, 8, 10] // [0, 2, 4, 6] << fixedLength // [4, 6] << fixedLengthWithOffset // [0, 2, 4, 6, 8, 10, ...] << lengthTracking // [4, 6, 8, 10, ...] << lengthTrackingWithOffset - - assert.sameValue(Array.prototype.join.call(fixedLength), '0,2,4,6'); - assert.sameValue(Array.prototype.join.call(fixedLengthWithOffset), '4,6'); - assert.sameValue(Array.prototype.join.call(lengthTracking), '0,2,4,6,8,10'); - assert.sameValue(Array.prototype.join.call(lengthTrackingWithOffset), '4,6,8,10'); + assert.sameValue(SendableArray.prototype.join.call(fixedLength), '0,2,4,6'); + assert.sameValue(SendableArray.prototype.join.call(fixedLengthWithOffset), '4,6'); + assert.sameValue(SendableArray.prototype.join.call(lengthTracking), '0,2,4,6,8,10'); + assert.sameValue(SendableArray.prototype.join.call(lengthTrackingWithOffset), '4,6,8,10'); } diff --git a/test/sendable/builtins/Array/prototype/keys/iteration-mutable.js b/test/sendable/builtins/Array/prototype/keys/iteration-mutable.js new file mode 100644 index 00000000000..df57788c14c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/keys/iteration-mutable.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.keys +description: > + New items in the array are accessible via iteration until iterator is "done". +info: | + When an item is added to the array after the iterator is created but + before the iterator is "done" (as defined by 22.1.5.2.1), the new item's + key should be accessible via iteration. When an item is added to the + array after the iterator is "done", the new item's key should not be + accessible via iteration. +---*/ + +var SendableArray = []; +var iterator = SendableArray.keys(); +var result; +SendableArray.push('a'); +result = iterator.next(); +assert.sameValue(result.done, false, 'First result `done` flag'); +assert.sameValue(result.value, 0, 'First result `value`'); +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +SendableArray.push('b'); +result = iterator.next(); +assert.sameValue( + result.done, true, + 'Exhausted result `done` flag (after push)' +); +assert.sameValue( + result.value, undefined, + 'Exhausted result `value` (after push)' +); diff --git a/test/sendable/builtins/Array/prototype/keys/iteration.js b/test/sendable/builtins/Array/prototype/keys/iteration.js new file mode 100644 index 00000000000..fb6a53dc4dd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/keys/iteration.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.keys +description: > + The return is a valid iterator with the array's numeric properties. +info: | + 22.1.3.13 Array.prototype.keys ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key"). +---*/ + +var SendableArray = ['a', 'b', 'c']; +var iterator = SendableArray.keys(); +var result; +result = iterator.next(); +assert.sameValue(result.value, 0, 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); +result = iterator.next(); +assert.sameValue(result.value, 1, 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); +result = iterator.next(); +assert.sameValue(result.value, 2, 'Third result `value`'); +assert.sameValue(result.done, false, 'Third result `done` flag'); +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); diff --git a/test/sendable/builtins/Array/prototype/keys/length.js b/test/sendable/builtins/Array/prototype/keys/length.js new file mode 100644 index 00000000000..a2cafc38d1e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/keys/length.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.keys +description: > + Array.prototype.keys.length value and descriptor. +info: | + 22.1.3.13 Array.prototype.keys ( ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.prototype.keys, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/keys/name.js b/test/sendable/builtins/Array/prototype/keys/name.js new file mode 100644 index 00000000000..bbc8cb473b3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/keys/name.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.keys +description: > + Array.prototype.keys.name value and descriptor. +info: | + 22.1.3.13 Array.prototype.keys ( ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray.prototype.keys, "name", { + value: "keys", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/keys/not-a-constructor.js b/test/sendable/builtins/Array/prototype/keys/not-a-constructor.js new file mode 100644 index 00000000000..283cfc57b2e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/keys/not-a-constructor.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.keys 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(SendableArray.prototype.keys), false, 'isConstructor(SendableArray.prototype.keys) must return false'); +assert.throws(TypeError, () => { + new SendableArray.prototype.keys(); +}); + diff --git a/test/sendable/builtins/Array/prototype/keys/prop-desc.js b/test/sendable/builtins/Array/prototype/keys/prop-desc.js new file mode 100644 index 00000000000..e8bf6d5d964 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/keys/prop-desc.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.keys +description: > + Property type and descriptor. +info: | + 22.1.3.13 Array.prototype.keys ( ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableArray.prototype.keys, + 'function', + '`typeof SendableArray.prototype.keys` is `function`' +); +verifyProperty(SendableArray.prototype, "keys", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/keys/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/Array/prototype/keys/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..7ff3b617252 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/keys/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.keys +description: > + Array.p.keys behaves correctly when receiver is backed by a resizable + buffer and is grown mid-iteration +features: [resizable-arraybuffer] +includes: [compareArray.js, resizableArrayBufferUtils.js] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + // The fixed length array is not affected by resizing. + TestIterationAndResize(SendableArray.prototype.keys.call(fixedLength), [ + 0, + 1, + 2, + 3 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + // The fixed length array is not affected by resizing. + TestIterationAndResize(SendableArray.prototype.keys.call(fixedLengthWithOffset), [ + 0, + 1 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + TestIterationAndResize(SendableArray.prototype.keys.call(lengthTracking), [ + 0, + 1, + 2, + 3, + 4, + 5 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + TestIterationAndResize(SendableArray.prototype.keys.call(lengthTrackingWithOffset), [ + 0, + 1, + 2, + 3 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/Array/prototype/keys/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/Array/prototype/keys/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..cf7268398d0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/keys/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.keys +description: > + Array.p.keys behaves correctly when receiver is backed by resizable + buffer that is shrunk mid-iteration +features: [resizable-arraybuffer] +includes: [compareArray.js, resizableArrayBufferUtils.js] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + // The fixed length array goes out of bounds when the RAB is resized. + assert.throws(TypeError, () => { + TestIterationAndResize(SendableArray.prototype.keys.call(fixedLength), null, rab, 2, 3 * ctor.BYTES_PER_ELEMENT); + }); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + + // The fixed length array goes out of bounds when the RAB is resized. + assert.throws(TypeError, () => { + TestIterationAndResize(SendableArray.prototype.keys.call(fixedLengthWithOffset), null, rab, 2, 3 * ctor.BYTES_PER_ELEMENT); + }); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + TestIterationAndResize(SendableArray.prototype.keys.call(lengthTracking), [ + 0, + 1, + 2 + ], rab, 2, 3 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + TestIterationAndResize(SendableArray.prototype.keys.call(lengthTrackingWithOffset), [ + 0, + 1 + ], rab, 2, 3 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/Array/prototype/keys/resizable-buffer.js b/test/sendable/builtins/Array/prototype/keys/resizable-buffer.js new file mode 100644 index 00000000000..7ecf06a1cb3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/keys/resizable-buffer.js @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.keys +description: > + Array.p.keys behaves correctly when receiver is backed by resizable + buffer +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + assert.compareArray(SendableArray.from(SendableArray.prototype.keys.call(fixedLength)), [ + 0, + 1, + 2, + 3 + ]); + assert.compareArray(SendableArray.from(SendableArray.prototype.keys.call(fixedLengthWithOffset)), [ + 0, + 1 + ]); + assert.compareArray(ArraSendableArrayy.from(SendableArray.prototype.keys.call(lengthTracking)), [ + 0, + 1, + 2, + 3 + ]); + assert.compareArray(SendableArray.from(SendableArray.prototype.keys.call(lengthTrackingWithOffset)), [ + 0, + 1 + ]); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + // TypedArray.prototype.{entries, keys, values} throw right away when + // called. Array.prototype.{entries, keys, values} don't throw, but when + // we try to iterate the returned ArrayIterator, that throws. + SendableArray.prototype.keys.call(fixedLength); + SendableArray.prototype.keys.call(fixedLengthWithOffset); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.keys.call(fixedLength)); + }); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.keys.call(fixedLengthWithOffset)); + }); + assert.compareArray(SendableArray.from(SendableArray.prototype.keys.call(lengthTracking)), [ + 0, + 1, + 2 + ]); + assert.compareArray(SendableArray.from(SendableArray.prototype.keys.call(lengthTrackingWithOffset)), [0]); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + SendableArray.prototype.keys.call(fixedLength); + SendableArray.prototype.keys.call(fixedLengthWithOffset); + SendableArray.prototype.keys.call(lengthTrackingWithOffset); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.keys.call(fixedLength)); + }); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.keys.call(fixedLengthWithOffset)); + }); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.keys.call(lengthTrackingWithOffset)); + }); + assert.compareArray(SendableArray.from(SendableArray.prototype.keys.call(lengthTracking)), [0]); + // Shrink to zero. + rab.resize(0); + SendableArray.prototype.keys.call(fixedLength); + SendableArray.prototype.keys.call(fixedLengthWithOffset); + SendableArray.prototype.keys.call(lengthTrackingWithOffset); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.keys.call(fixedLength)); + }); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.keys.call(fixedLengthWithOffset)); + }); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.keys.call(lengthTrackingWithOffset)); + }); + assert.compareArray(SendableArray.from(SendableArray.prototype.keys.call(lengthTracking)), []); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert.compareArray(SendableArray.from(SendableArray.prototype.keys.call(fixedLength)), [ + 0, + 1, + 2, + 3 + ]); + assert.compareArray(SendableArray.from(SendableArray.prototype.keys.call(fixedLengthWithOffset)), [ + 0, + 1 + ]); + assert.compareArray(SendableArray.from(SendableArray.prototype.keys.call(lengthTracking)), [ + 0, + 1, + 2, + 3, + 4, + 5 + ]); + assert.compareArray(SendableArray.from(SendableArray.prototype.keys.call(lengthTrackingWithOffset)), [ + 0, + 1, + 2, + 3 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/keys/return-abrupt-from-this.js b/test/sendable/builtins/Array/prototype/keys/return-abrupt-from-this.js new file mode 100644 index 00000000000..3db71ecbad4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/keys/return-abrupt-from-this.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.keys +description: > + Return abrupt from ToObject(this value). +info: | + 22.1.3.13 Array.prototype.keys ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.keys.call(undefined); +}); +assert.throws(TypeError, function() { + SendableArray.prototype.keys.call(null); +}); diff --git a/test/sendable/builtins/Array/prototype/keys/returns-iterator-from-object.js b/test/sendable/builtins/Array/prototype/keys/returns-iterator-from-object.js new file mode 100644 index 00000000000..b598e5e9e50 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/keys/returns-iterator-from-object.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.keys +description: > + Creates an iterator from a custom object. +info: | + 22.1.3.13 Array.prototype.keys ( ) + + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "key"). +features: [Symbol.iterator] +---*/ + +var obj = { + length: 2 +}; +var iter = SendableArray.prototype.keys.call(obj); +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].keys() is %ArrayIteratorPrototype%' +); diff --git a/test/sendable/builtins/Array/prototype/keys/returns-iterator.js b/test/sendable/builtins/Array/prototype/keys/returns-iterator.js new file mode 100644 index 00000000000..c2048e60700 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/keys/returns-iterator.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.keys +description: > + The method should return an Iterator instance. +info: | + 22.1.3.13 Array.prototype.keys ( ) +features: [Symbol.iterator] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); +var iter = [].keys(); +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].keys() is %ArrayIteratorPrototype%' +); -- Gitee From 39224e85e02c68dcda4991a436a794e604edf325 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 27 Dec 2024 17:02:31 +0800 Subject: [PATCH 48/93] add array-lastindexof Signed-off-by: zhuzhihui7 --- .../prototype/lastIndexOf/15.4.4.15-1-1.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-1-10.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-1-11.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-1-12.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-1-13.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-1-14.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-1-15.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-1-2.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-1-3.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-1-4.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-1-5.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-1-6.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-1-7.js | 20 +++ .../prototype/lastIndexOf/15.4.4.15-1-8.js | 21 +++ .../prototype/lastIndexOf/15.4.4.15-1-9.js | 24 ++++ .../prototype/lastIndexOf/15.4.4.15-2-1.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-2-10.js | 35 +++++ .../prototype/lastIndexOf/15.4.4.15-2-11.js | 29 +++++ .../prototype/lastIndexOf/15.4.4.15-2-12.js | 36 ++++++ .../prototype/lastIndexOf/15.4.4.15-2-13.js | 31 +++++ .../prototype/lastIndexOf/15.4.4.15-2-14.js | 26 ++++ .../prototype/lastIndexOf/15.4.4.15-2-17.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-2-18.js | 25 ++++ .../prototype/lastIndexOf/15.4.4.15-2-19.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-2-2.js | 25 ++++ .../prototype/lastIndexOf/15.4.4.15-2-3.js | 30 +++++ .../prototype/lastIndexOf/15.4.4.15-2-4.js | 26 ++++ .../prototype/lastIndexOf/15.4.4.15-2-5.js | 37 ++++++ .../prototype/lastIndexOf/15.4.4.15-2-6.js | 31 +++++ .../prototype/lastIndexOf/15.4.4.15-2-7.js | 33 +++++ .../prototype/lastIndexOf/15.4.4.15-2-8.js | 35 +++++ .../prototype/lastIndexOf/15.4.4.15-2-9.js | 40 ++++++ .../prototype/lastIndexOf/15.4.4.15-3-1.js | 25 ++++ .../prototype/lastIndexOf/15.4.4.15-3-10.js | 26 ++++ .../prototype/lastIndexOf/15.4.4.15-3-11.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-3-12.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-3-13.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-3-14.js | 27 ++++ .../prototype/lastIndexOf/15.4.4.15-3-15.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-3-16.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-3-17.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-3-18.js | 27 ++++ .../prototype/lastIndexOf/15.4.4.15-3-19.js | 39 ++++++ .../prototype/lastIndexOf/15.4.4.15-3-2.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-3-20.js | 33 +++++ .../prototype/lastIndexOf/15.4.4.15-3-21.js | 41 ++++++ .../prototype/lastIndexOf/15.4.4.15-3-22.js | 42 ++++++ .../prototype/lastIndexOf/15.4.4.15-3-23.js | 44 +++++++ .../prototype/lastIndexOf/15.4.4.15-3-24.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-3-25.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-3-28.js | 29 +++++ .../prototype/lastIndexOf/15.4.4.15-3-3.js | 26 ++++ .../prototype/lastIndexOf/15.4.4.15-3-4.js | 26 ++++ .../prototype/lastIndexOf/15.4.4.15-3-5.js | 26 ++++ .../prototype/lastIndexOf/15.4.4.15-3-6.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-3-7.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-3-9.js | 26 ++++ .../prototype/lastIndexOf/15.4.4.15-4-1.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-4-10.js | 26 ++++ .../prototype/lastIndexOf/15.4.4.15-4-11.js | 26 ++++ .../prototype/lastIndexOf/15.4.4.15-4-2.js | 25 ++++ .../prototype/lastIndexOf/15.4.4.15-4-3.js | 25 ++++ .../prototype/lastIndexOf/15.4.4.15-4-4.js | 30 +++++ .../prototype/lastIndexOf/15.4.4.15-4-5.js | 25 ++++ .../prototype/lastIndexOf/15.4.4.15-4-6.js | 29 +++++ .../prototype/lastIndexOf/15.4.4.15-4-7.js | 43 ++++++ .../prototype/lastIndexOf/15.4.4.15-4-8.js | 38 ++++++ .../prototype/lastIndexOf/15.4.4.15-4-9.js | 26 ++++ .../prototype/lastIndexOf/15.4.4.15-5-1.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-5-10.js | 24 ++++ .../prototype/lastIndexOf/15.4.4.15-5-11.js | 24 ++++ .../prototype/lastIndexOf/15.4.4.15-5-12.js | 24 ++++ .../prototype/lastIndexOf/15.4.4.15-5-13.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-5-14.js | 26 ++++ .../prototype/lastIndexOf/15.4.4.15-5-15.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-5-16.js | 24 ++++ .../prototype/lastIndexOf/15.4.4.15-5-17.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-5-18.js | 24 ++++ .../prototype/lastIndexOf/15.4.4.15-5-19.js | 24 ++++ .../prototype/lastIndexOf/15.4.4.15-5-2.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-5-20.js | 24 ++++ .../prototype/lastIndexOf/15.4.4.15-5-21.js | 34 +++++ .../prototype/lastIndexOf/15.4.4.15-5-22.js | 29 +++++ .../prototype/lastIndexOf/15.4.4.15-5-23.js | 37 ++++++ .../prototype/lastIndexOf/15.4.4.15-5-24.js | 39 ++++++ .../prototype/lastIndexOf/15.4.4.15-5-25.js | 40 ++++++ .../prototype/lastIndexOf/15.4.4.15-5-26.js | 43 ++++++ .../prototype/lastIndexOf/15.4.4.15-5-27.js | 47 +++++++ .../prototype/lastIndexOf/15.4.4.15-5-28.js | 32 +++++ .../prototype/lastIndexOf/15.4.4.15-5-29.js | 39 ++++++ .../prototype/lastIndexOf/15.4.4.15-5-3.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-5-30.js | 43 ++++++ .../prototype/lastIndexOf/15.4.4.15-5-31.js | 24 ++++ .../prototype/lastIndexOf/15.4.4.15-5-32.js | 24 ++++ .../prototype/lastIndexOf/15.4.4.15-5-33.js | 26 ++++ .../prototype/lastIndexOf/15.4.4.15-5-4.js | 24 ++++ .../prototype/lastIndexOf/15.4.4.15-5-5.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-5-6.js | 24 ++++ .../prototype/lastIndexOf/15.4.4.15-5-7.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-5-8.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-5-9.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-6-1.js | 24 ++++ .../prototype/lastIndexOf/15.4.4.15-6-2.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-6-3.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-6-4.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-6-5.js | 20 +++ .../prototype/lastIndexOf/15.4.4.15-6-6.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-7-1.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-7-2.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-7-3.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-7-4.js | 22 ++++ .../prototype/lastIndexOf/15.4.4.15-8-1.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-8-10.js | 29 +++++ .../prototype/lastIndexOf/15.4.4.15-8-11.js | 30 +++++ .../prototype/lastIndexOf/15.4.4.15-8-2.js | 31 +++++ .../prototype/lastIndexOf/15.4.4.15-8-3.js | 27 ++++ .../prototype/lastIndexOf/15.4.4.15-8-4.js | 28 ++++ .../prototype/lastIndexOf/15.4.4.15-8-5.js | 36 ++++++ .../prototype/lastIndexOf/15.4.4.15-8-6.js | 27 ++++ .../prototype/lastIndexOf/15.4.4.15-8-7.js | 25 ++++ .../prototype/lastIndexOf/15.4.4.15-8-8.js | 23 ++++ .../prototype/lastIndexOf/15.4.4.15-8-9.js | 34 +++++ .../prototype/lastIndexOf/15.4.4.15-8-a-1.js | 30 +++++ .../prototype/lastIndexOf/15.4.4.15-8-a-10.js | 35 +++++ .../prototype/lastIndexOf/15.4.4.15-8-a-11.js | 38 ++++++ .../prototype/lastIndexOf/15.4.4.15-8-a-12.js | 36 ++++++ .../prototype/lastIndexOf/15.4.4.15-8-a-13.js | 35 +++++ .../prototype/lastIndexOf/15.4.4.15-8-a-14.js | 31 +++++ .../prototype/lastIndexOf/15.4.4.15-8-a-15.js | 37 ++++++ .../prototype/lastIndexOf/15.4.4.15-8-a-16.js | 32 +++++ .../prototype/lastIndexOf/15.4.4.15-8-a-17.js | 30 +++++ .../prototype/lastIndexOf/15.4.4.15-8-a-18.js | 36 ++++++ .../prototype/lastIndexOf/15.4.4.15-8-a-19.js | 37 ++++++ .../prototype/lastIndexOf/15.4.4.15-8-a-2.js | 32 +++++ .../prototype/lastIndexOf/15.4.4.15-8-a-3.js | 31 +++++ .../prototype/lastIndexOf/15.4.4.15-8-a-4.js | 32 +++++ .../prototype/lastIndexOf/15.4.4.15-8-a-5.js | 32 +++++ .../prototype/lastIndexOf/15.4.4.15-8-a-6.js | 31 +++++ .../prototype/lastIndexOf/15.4.4.15-8-a-7.js | 37 ++++++ .../prototype/lastIndexOf/15.4.4.15-8-a-8.js | 35 +++++ .../prototype/lastIndexOf/15.4.4.15-8-a-9.js | 38 ++++++ .../prototype/lastIndexOf/15.4.4.15-8-b-1.js | 20 +++ .../lastIndexOf/15.4.4.15-8-b-i-1.js | 30 +++++ .../lastIndexOf/15.4.4.15-8-b-i-10.js | 45 +++++++ .../lastIndexOf/15.4.4.15-8-b-i-11.js | 31 +++++ .../lastIndexOf/15.4.4.15-8-b-i-12.js | 33 +++++ .../lastIndexOf/15.4.4.15-8-b-i-13.js | 36 ++++++ .../lastIndexOf/15.4.4.15-8-b-i-14.js | 38 ++++++ .../lastIndexOf/15.4.4.15-8-b-i-15.js | 43 ++++++ .../lastIndexOf/15.4.4.15-8-b-i-16.js | 48 +++++++ .../lastIndexOf/15.4.4.15-8-b-i-17.js | 27 ++++ .../lastIndexOf/15.4.4.15-8-b-i-18.js | 29 +++++ .../lastIndexOf/15.4.4.15-8-b-i-19.js | 37 ++++++ .../lastIndexOf/15.4.4.15-8-b-i-2.js | 24 ++++ .../lastIndexOf/15.4.4.15-8-b-i-20.js | 35 +++++ .../lastIndexOf/15.4.4.15-8-b-i-21.js | 26 ++++ .../lastIndexOf/15.4.4.15-8-b-i-22.js | 28 ++++ .../lastIndexOf/15.4.4.15-8-b-i-25.js | 27 ++++ .../lastIndexOf/15.4.4.15-8-b-i-26.js | 28 ++++ .../lastIndexOf/15.4.4.15-8-b-i-27.js | 30 +++++ .../lastIndexOf/15.4.4.15-8-b-i-28.js | 41 ++++++ .../lastIndexOf/15.4.4.15-8-b-i-29.js | 43 ++++++ .../lastIndexOf/15.4.4.15-8-b-i-3.js | 23 ++++ .../lastIndexOf/15.4.4.15-8-b-i-30.js | 40 ++++++ .../lastIndexOf/15.4.4.15-8-b-i-31.js | 42 ++++++ .../lastIndexOf/15.4.4.15-8-b-i-4.js | 28 ++++ .../lastIndexOf/15.4.4.15-8-b-i-5.js | 28 ++++ .../lastIndexOf/15.4.4.15-8-b-i-6.js | 33 +++++ .../lastIndexOf/15.4.4.15-8-b-i-7.js | 27 ++++ .../lastIndexOf/15.4.4.15-8-b-i-8.js | 33 +++++ .../lastIndexOf/15.4.4.15-8-b-i-9.js | 43 ++++++ .../lastIndexOf/15.4.4.15-8-b-ii-1.js | 29 +++++ .../lastIndexOf/15.4.4.15-8-b-ii-10.js | 22 ++++ .../lastIndexOf/15.4.4.15-8-b-ii-11.js | 25 ++++ .../lastIndexOf/15.4.4.15-8-b-ii-2.js | 23 ++++ .../lastIndexOf/15.4.4.15-8-b-ii-3.js | 22 ++++ .../lastIndexOf/15.4.4.15-8-b-ii-4.js | 20 +++ .../lastIndexOf/15.4.4.15-8-b-ii-5.js | 20 +++ .../lastIndexOf/15.4.4.15-8-b-ii-6.js | 22 ++++ .../lastIndexOf/15.4.4.15-8-b-ii-7.js | 22 ++++ .../lastIndexOf/15.4.4.15-8-b-ii-8.js | 22 ++++ .../lastIndexOf/15.4.4.15-8-b-ii-9.js | 23 ++++ .../lastIndexOf/15.4.4.15-8-b-iii-1.js | 22 ++++ .../lastIndexOf/15.4.4.15-8-b-iii-2.js | 41 ++++++ .../prototype/lastIndexOf/15.4.4.15-9-1.js | 36 ++++++ .../prototype/lastIndexOf/15.4.4.15-9-2.js | 34 +++++ .../lastIndexOf/call-with-boolean.js | 25 ++++ ...ly-has-on-prototype-after-length-zeroed.js | 38 ++++++ .../lastIndexOf/coerced-position-grow.js | 60 +++++++++ .../lastIndexOf/coerced-position-shrink.js | 69 ++++++++++ .../lastIndexOf/fromindex-zero-conversion.js | 21 +++ .../lastIndexOf/length-near-integer-limit.js | 33 +++++ .../length-zero-returns-minus-one.js | 32 +++++ .../Array/prototype/lastIndexOf/length.js | 38 ++++++ .../Array/prototype/lastIndexOf/name.js | 36 ++++++ .../lastIndexOf/not-a-constructor.js | 39 ++++++ .../Array/prototype/lastIndexOf/prop-desc.js | 32 +++++ .../prototype/lastIndexOf/resizable-buffer.js | 122 ++++++++++++++++++ 198 files changed, 5953 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-1.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-10.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-11.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-12.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-13.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-14.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-15.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-2.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-3.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-4.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-5.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-6.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-7.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-8.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-9.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-1.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-10.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-11.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-12.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-13.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-14.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-17.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-18.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-19.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-2.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-3.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-4.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-5.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-6.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-7.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-8.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-9.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-1.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-10.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-11.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-12.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-13.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-14.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-15.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-16.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-17.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-18.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-19.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-2.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-20.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-21.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-22.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-23.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-24.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-25.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-28.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-3.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-4.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-5.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-6.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-7.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-9.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-1.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-10.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-11.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-2.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-3.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-4.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-5.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-6.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-7.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-8.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-9.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-1.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-10.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-11.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-12.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-13.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-14.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-15.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-16.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-17.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-18.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-19.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-2.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-20.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-21.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-22.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-25.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-26.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-27.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-28.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-29.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-3.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-30.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-31.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-32.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-33.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-4.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-5.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-6.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-7.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-8.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-9.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-1.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-2.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-3.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-4.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-5.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-6.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-1.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-2.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-3.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-4.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-1.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-10.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-11.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-2.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-3.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-4.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-5.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-6.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-8.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-9.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-1.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-10.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-11.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-12.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-13.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-14.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-15.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-16.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-17.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-18.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-19.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-2.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-4.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-5.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-6.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-7.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-8.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-9.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-1.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-1.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-10.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-11.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-12.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-13.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-14.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-15.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-16.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-17.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-18.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-19.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-2.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-20.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-21.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-22.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-25.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-26.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-27.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-28.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-29.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-3.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-30.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-31.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-4.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-5.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-6.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-7.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-8.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-9.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-1.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-10.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-11.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-2.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-3.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-4.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-5.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-6.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-7.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-8.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-9.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-1.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-2.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-9-1.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-9-2.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/coerced-position-grow.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/coerced-position-shrink.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/fromindex-zero-conversion.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/length-near-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/length-zero-returns-minus-one.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/length.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/name.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/lastIndexOf/resizable-buffer.js diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-1.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-1.js new file mode 100644 index 00000000000..b5cc9d45381 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to undefined throws a TypeError +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.lastIndexOf.call(undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-10.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-10.js new file mode 100644 index 00000000000..9453c2fb56b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-10.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to the Math object +---*/ + +Math.length = 2; +Math[1] = 100; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(Math, 100), 1, 'SendableArray.prototype.lastIndexOf.call(Math, 100)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-11.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-11.js new file mode 100644 index 00000000000..6596f7a7802 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-11.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Date object +---*/ + +var obj = new Date(0); +obj.length = 2; +obj[1] = true; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, true), 1, 'SendableArray.prototype.lastIndexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-12.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-12.js new file mode 100644 index 00000000000..8a6c1460f05 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-12.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to RegExp object +---*/ + +var obj = new RegExp("afdasf"); +obj.length = 100; +obj[1] = "afdasf"; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, "afdasf"), 1, 'SendableArray.prototype.lastIndexOf.call(obj, "afdasf")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-13.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-13.js new file mode 100644 index 00000000000..9ea3c454511 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-13.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to the JSON object +---*/ + +var targetObj = {}; +JSON[3] = targetObj; +JSON.length = 5; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(JSON, targetObj), 3, 'SendableArray.prototype.lastIndexOf.call(JSON, targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-14.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-14.js new file mode 100644 index 00000000000..7603b2bcab4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-14.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Error object +---*/ + +var obj = new SyntaxError(); +obj.length = 2; +obj[1] = Infinity; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, Infinity), 1, 'SendableArray.prototype.lastIndexOf.call(obj, Infinity)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-15.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-15.js new file mode 100644 index 00000000000..373f0b2ca33 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-15.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to the Arguments object +---*/ + +var obj = (function fun() { + return arguments; +}(1, 2, 3)); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 2), 1, 'SendableArray.prototype.lastIndexOf.call(obj, 2)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-2.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-2.js new file mode 100644 index 00000000000..aeae56bc2cf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-2.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to null throws a TypeError +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.lastIndexOf.call(null); +}); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-3.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-3.js new file mode 100644 index 00000000000..2915bf314af --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-3.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to boolean primitive +---*/ + +Boolean.prototype[1] = true; +Boolean.prototype.length = 2; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(true, true), 1, 'SendableArray.prototype.lastIndexOf.call(true, true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-4.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-4.js new file mode 100644 index 00000000000..dc592403c76 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-4.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Boolean object +---*/ + +var obj = new Boolean(false); +obj.length = 2; +obj[1] = true; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, true), 1, 'SendableArray.prototype.lastIndexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-5.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-5.js new file mode 100644 index 00000000000..236d9068caf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-5.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to number primitive +---*/ + +Number.prototype[1] = isNaN; +Number.prototype.length = 2; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(5, isNaN), 1, 'SendableArray.prototype.lastIndexOf.call(5, isNaN)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-6.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-6.js new file mode 100644 index 00000000000..8ea9ceac096 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-6.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Number object +---*/ + +var obj = new Number(-3); +obj.length = 2; +obj[1] = true; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, true), 1, 'SendableArray.prototype.lastIndexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-7.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-7.js new file mode 100644 index 00000000000..1631437316e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-7.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to string primitive +---*/ + +assert.sameValue(SendableArray.prototype.lastIndexOf.call("abc", "c"), 2, 'SendableArray.prototype.lastIndexOf.call("abc", "c")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-8.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-8.js new file mode 100644 index 00000000000..18813712678 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-8.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to String object +---*/ + +var obj = new String("undefined"); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, "f"), 4, 'SendableArray.prototype.lastIndexOf.call(obj, "f")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-9.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-9.js new file mode 100644 index 00000000000..fb0a2b42d6b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-1-9.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf applied to Function object +---*/ + +var obj = function(a, b) { + return a + b; +}; +obj[1] = true; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, true), 1, 'SendableArray.prototype.lastIndexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-1.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-1.js new file mode 100644 index 00000000000..1136bdf1044 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-1.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own data property on an + Array-like object +---*/ + +var obj = { + 1: null, + 2: undefined, + length: 2 +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, null), 1, 'SendableArray.prototype.lastIndexOf.call(obj, null)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, undefined), -1, 'SendableArray.prototype.lastIndexOf.call(obj, undefined)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-10.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-10.js new file mode 100644 index 00000000000..5b302310791 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-10.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is inherited accessor + property on an Array-like object +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[1] = 1; +child[2] = 2; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(child, 1), 1, 'SendableArray.prototype.lastIndexOf.call(child, 1)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(child, 2), -1, 'SendableArray.prototype.lastIndexOf.call(child, 2)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-11.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-11.js new file mode 100644 index 00000000000..87e82646b4e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-11.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property + without a get function on an Array-like object +---*/ + +var obj = { + 0: 1 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 1), -1, 'SendableArray.prototype.lastIndexOf.call(obj, 1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-12.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-12.js new file mode 100644 index 00000000000..cd22b2a0d88 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-12.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property + without a get function that overrides an inherited accessor + property on an Array-like object +---*/ + +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 20; + }, + configurable: true +}); +var obj = { + 1: 1 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 1), -1, 'SendableArray.prototype.lastIndexOf.call(obj, 1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-13.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-13.js new file mode 100644 index 00000000000..bcebc66590e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-13.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is inherited accessor + property without a get function on an Array-like object +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = true; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(child, true), -1, 'SendableArray.prototype.lastIndexOf.call(child, true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-14.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-14.js new file mode 100644 index 00000000000..45b23c4bfe3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-14.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is undefined property on an + Array-like object +---*/ + +var obj = { + 0: null, + 1: undefined +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, null), -1, 'SendableArray.prototype.lastIndexOf.call(obj, null)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-17.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-17.js new file mode 100644 index 00000000000..2520063140f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-17.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to Arguments object which + implements its own property get method +---*/ + +var targetObj = function() {}; +var func = function(a, b) { + arguments[2] = function() {}; + return SendableArray.prototype.lastIndexOf.call(arguments, targetObj) === 1 && + SendableArray.prototype.lastIndexOf.call(arguments, arguments[2]) === -1; +}; +assert(func(0, targetObj), 'func(0, targetObj) !== true'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-18.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-18.js new file mode 100644 index 00000000000..610c6d75c4b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-18.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to String object which + implements its own property get method +---*/ + +var str = new String("012"); +String.prototype[3] = "3"; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(str, "2"), 2, 'SendableArray.prototype.lastIndexOf.call(str, "2")'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(str, "3"), -1, 'SendableArray.prototype.lastIndexOf.call(str, "3")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-19.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-19.js new file mode 100644 index 00000000000..d78c3064d43 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-19.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to String object which + implements its own property get method +---*/ + +var obj = function(a, b) { + return a + b; +}; +obj[1] = "b"; +obj[2] = "c"; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, obj[1]), 1, 'SendableArray.prototype.lastIndexOf.call(obj, obj[1])'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, obj[2]), -1, 'SendableArray.prototype.lastIndexOf.call(obj, obj[2])'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-2.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-2.js new file mode 100644 index 00000000000..9593270e163 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own data property on an + Array +---*/ + +var targetObj = {}; +SendableArray.prototype[2] = targetObj; +assert.sameValue([0, targetObj].lastIndexOf(targetObj), 1, '[0, targetObj].lastIndexOf(targetObj)'); +assert.sameValue([0, 1].lastIndexOf(targetObj), -1, '[0, 1].lastIndexOf(targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-3.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-3.js new file mode 100644 index 00000000000..9b6ffad631e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-3.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own data property that + overrides an inherited data property on an Array-like object +---*/ + +var proto = { + length: 0 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +child[1] = child; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(child, child), 1, 'SendableArray.prototype.lastIndexOf.call(child, child)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-4.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-4.js new file mode 100644 index 00000000000..af97cc3b632 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-4.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf when 'length' is own data property + that overrides an inherited data property on an Array +---*/ + +var targetObj = {}; +var arrProtoLen; +arrProtoLen = SendableArray.prototype.length; +SendableArray.prototype.length = 0; +assert.sameValue([0, targetObj, 2].lastIndexOf(targetObj), 1, '[0, targetObj, 2].lastIndexOf(targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-5.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-5.js new file mode 100644 index 00000000000..2198717f541 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-5.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own data property that + overrides an inherited accessor property on an Array-like object +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 0; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[1] = null; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(child, null), 1, 'SendableArray.prototype.lastIndexOf.call(child, null)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-6.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-6.js new file mode 100644 index 00000000000..9dbfa95499b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-6.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is an inherited data + property on an Array-like object +---*/ + +var proto = { + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[1] = "x"; +child[2] = "y"; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(child, "x"), 1, 'SendableArray.prototype.lastIndexOf.call(child, "x")'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(child, "y"), -1, 'SendableArray.prototype.lastIndexOf.call(child, "y")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-7.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-7.js new file mode 100644 index 00000000000..3b8dd1541a7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-7.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property on + an Array-like object +---*/ + +var obj = { + 1: true, + 2: false +}; +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, true), 1, 'SendableArray.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, false), -1, 'SendableArray.prototype.lastIndexOf.call(obj, false)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-8.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-8.js new file mode 100644 index 00000000000..51e71f5a06f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-8.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property + that overrides an inherited data property on an Array-like object +---*/ + +var proto = { + length: 0 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[1] = eval; +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(child, eval), 1, 'SendableArray.prototype.lastIndexOf.call(child, eval)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-9.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-9.js new file mode 100644 index 00000000000..36da2ba4f6c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-2-9.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is own accessor property + that overrides an inherited accessor property on an Array-like + object +---*/ + +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 0; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[1] = true; +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(child, true), 1, 'SendableArray.prototype.lastIndexOf.call(child, true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-1.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-1.js new file mode 100644 index 00000000000..ae35a079251 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - value of 'length' is undefined +---*/ + +var obj = { + 0: 1, + 1: 1, + length: undefined +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 1), -1, 'SendableArray.prototype.lastIndexOf.call(obj, 1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-10.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-10.js new file mode 100644 index 00000000000..ce4b355dc35 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-10.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is NaN) +---*/ + +var obj = { + 0: 0, + length: NaN +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 0), -1, 'SendableArray.prototype.lastIndexOf.call(obj, 0)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-11.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-11.js new file mode 100644 index 00000000000..4a4c2989e4a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-11.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing positive number +---*/ + +var obj = { + 1: true, + 2: false, + length: "2" +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, true), 1, 'SendableArray.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, false), -1, 'SendableArray.prototype.lastIndexOf.call(obj, false)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-12.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-12.js new file mode 100644 index 00000000000..a78d9013886 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-12.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing negative number +---*/ + +var obj = { + 1: null, + 2: undefined, + length: "-4294967294" +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, null), -1, 'SendableArray.prototype.lastIndexOf.call(obj, null)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, undefined), -1, 'SendableArray.prototype.lastIndexOf.call(obj, undefined)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-13.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-13.js new file mode 100644 index 00000000000..b9c23183add --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-13.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing a decimal number +---*/ + +var obj = { + 4: 4, + 5: 5, + length: "5.512345" +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 4), 4, 'SendableArray.prototype.lastIndexOf.call(obj, 4)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 5), -1, 'SendableArray.prototype.lastIndexOf.call(obj, 5)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-14.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-14.js new file mode 100644 index 00000000000..defa244c533 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-14.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing -Infinity +---*/ + +var objThree = { + 0: true, + 1: true, + length: "-Infinity" +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(objThree, true), -1, 'SendableArray.prototype.lastIndexOf.call(objThree, true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-15.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-15.js new file mode 100644 index 00000000000..0d64a54a067 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-15.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing an exponential number +---*/ + +var obj = { + 229: 229, + 230: 2.3E2, + length: "2.3E2" +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 229), 229, 'SendableArray.prototype.lastIndexOf.call(obj, 229)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 2.3E2), -1, 'SendableArray.prototype.lastIndexOf.call(obj, 2.3E2)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-16.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-16.js new file mode 100644 index 00000000000..fa56c022b2c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-16.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string which + is able to be converted into hex number +---*/ + +var obj = { + 2573: 2573, + 2574: 0x000A0E, + length: "0x000A0E" +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 2573), 2573, 'SendableArray.prototype.lastIndexOf.call(obj, 2573)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 0x000A0E), -1, 'SendableArray.prototype.lastIndexOf.call(obj, 0x000A0E)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-17.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-17.js new file mode 100644 index 00000000000..d7fef3740ae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-17.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string + containing a number with leading zeros +---*/ + +var obj = { + 1: 1, + 2: 2, + length: "0002.0" +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 1), 1, 'SendableArray.prototype.lastIndexOf.call(obj, 1)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 2), -1, 'SendableArray.prototype.lastIndexOf.call(obj, 2)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-18.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-18.js new file mode 100644 index 00000000000..c7de2aa8507 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-18.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a string that + can't convert to a number +---*/ + +var targetObj = new String("123abc123"); +var obj = { + 0: targetObj, + length: "123abc123" +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, targetObj), -1, 'SendableArray.prototype.lastIndexOf.call(obj, targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-19.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-19.js new file mode 100644 index 00000000000..859bb077904 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-19.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is an Object which + has an own toString method +---*/ + +// objects inherit the default valueOf() method from Object +// that simply returns itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. + +var targetObj = this; +var obj = { + 1: targetObj, + 2: 2, + length: { + toString: function() { + return '2'; + } + } +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, targetObj), 1, 'SendableArray.prototype.lastIndexOf.call(obj, targetObj)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 2), -1, 'SendableArray.prototype.lastIndexOf.call(obj, 2)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-2.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-2.js new file mode 100644 index 00000000000..f472ba2d45d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf return -1 when value of 'length' is a + boolean (value is true) +---*/ + +var obj = { + 0: 0, + 1: 1, + length: true +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 0), 0, 'SendableArray.prototype.lastIndexOf.call(obj, 0)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 1), -1, 'SendableArray.prototype.lastIndexOf.call(obj, 1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-20.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-20.js new file mode 100644 index 00000000000..bb3ab7474fb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-20.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is an Object which + has an own valueOf method +---*/ + +//valueOf method will be invoked first, since hint is Number +var obj = { + 1: true, + 2: 2, + length: { + valueOf: function() { + return 2; + } + } +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, true), 1, 'SendableArray.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 2), -1, 'SendableArray.prototype.lastIndexOf.call(obj, 2)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-21.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-21.js new file mode 100644 index 00000000000..444b9f40761 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-21.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'length' is an object that has an + own valueOf method that returns an object and toString method that + returns a string +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var targetObj = this; +var obj = { + 1: targetObj, + length: { + toString: function() { + toStringAccessed = true; + return '3'; + }, + valueOf: function() { + valueOfAccessed = true; + return {}; + } + } +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, targetObj), 1, 'SendableArray.prototype.lastIndexOf.call(obj, targetObj)'); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-22.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-22.js new file mode 100644 index 00000000000..6d7656731db --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-22.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf throws TypeError exception when + 'length' is an object with toString and valueOf methods that don�t + return primitive values +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var obj = { + 1: true, + length: { + toString: function() { + toStringAccessed = true; + return {}; + }, + valueOf: function() { + valueOfAccessed = true; + return {}; + } + } +}; +assert.throws(TypeError, function() { + SendableArray.prototype.lastIndexOf.call(obj, true); +}); +assert(toStringAccessed, 'toStringAccessed'); +assert(valueOfAccessed, 'valueOfAccessed'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-23.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-23.js new file mode 100644 index 00000000000..60ce42e3ae7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-23.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf uses inherited valueOf method when + 'length' is an object with an own toString and an inherited + valueOf methods +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return 2; +}; +var obj = { + 1: child, + length: child +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, child), 1, 'SendableArray.prototype.lastIndexOf.call(obj, child)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-24.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-24.js new file mode 100644 index 00000000000..5eca2d83afa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-24.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +var obj = { + 122: true, + 123: false, + length: 123.5 +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, true), 122, 'SendableArray.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, false), -1, 'SendableArray.prototype.lastIndexOf.call(obj, false)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-25.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-25.js new file mode 100644 index 00000000000..b2a7a565526 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-25.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a negative + non-integer +---*/ + +var obj = { + 1: true, + 2: false, + length: -4294967294.5 +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, true), -1, 'SendableArray.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, false), -1, 'SendableArray.prototype.lastIndexOf.call(obj, false)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-28.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-28.js new file mode 100644 index 00000000000..759dd3168de --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-28.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is boundary value + (2^32) +---*/ + +var targetObj = {}; +var obj = { + 0: targetObj, + 4294967294: targetObj, + 4294967295: targetObj, + length: 4294967296 +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, targetObj), 4294967295, 'verify length is 4294967296 finally'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-3.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-3.js new file mode 100644 index 00000000000..a3be5b23d19 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-3.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is 0) +---*/ + +var obj = { + 0: "undefined", + length: 0 +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, "undefined"), -1, 'SendableArray.prototype.lastIndexOf.call(obj, "undefined")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-4.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-4.js new file mode 100644 index 00000000000..da63c9195a2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-4.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is -0) +---*/ + +var obj = { + 0: true, + length: -0 +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, true), -1, 'SendableArray.prototype.lastIndexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-5.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-5.js new file mode 100644 index 00000000000..d2bf4c4dd6f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-5.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is +0) +---*/ + +var obj = { + 0: +0, + length: +0 +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, +0), -1, 'SendableArray.prototype.lastIndexOf.call(obj, +0)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-6.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-6.js new file mode 100644 index 00000000000..d8c32ba14da --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-6.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is a positive number) +---*/ + +var obj = { + 99: true, + 100: 100, + length: 100 +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, true), 99, 'SendableArray.prototype.lastIndexOf.call(obj, true)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 100), -1, 'SendableArray.prototype.lastIndexOf.call(obj, 100)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-7.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-7.js new file mode 100644 index 00000000000..5fcd63630c8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-7.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is a negative number) +---*/ + +var obj = { + 4: -Infinity, + 5: Infinity, + length: 5 - Math.pow(2, 32) +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, -Infinity), -1, 'SendableArray.prototype.lastIndexOf.call(obj, -Infinity)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, Infinity), -1, 'SendableArray.prototype.lastIndexOf.call(obj, Infinity)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-9.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-9.js new file mode 100644 index 00000000000..05f22ab13a1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-3-9.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'length' is a number (value + is -Infinity) +---*/ + +var obj = { + 0: 0, + length: -Infinity +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 0), -1, 'SendableArray.prototype.lastIndexOf.call(obj, 0)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-1.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-1.js new file mode 100644 index 00000000000..215ada9e6ad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 (empty + array) +---*/ + +var i = [].lastIndexOf(42); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-10.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-10.js new file mode 100644 index 00000000000..c4563f0875f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-10.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - 'length' is a number of value -6e-1 +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: -6e-1 +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, targetObj), -1, 'SendableArray.prototype.lastIndexOf.call(obj, targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-11.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-11.js new file mode 100644 index 00000000000..dbb6e7973f4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-11.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - 'length' is an empty string +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: "" +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, targetObj), -1, 'SendableArray.prototype.lastIndexOf.call(obj, targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-2.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-2.js new file mode 100644 index 00000000000..a7ce1de9fa2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 ( length + overridden to null (type conversion)) +---*/ + +var i = SendableArray.prototype.lastIndexOf.call({ + length: null +}, 1); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-3.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-3.js new file mode 100644 index 00000000000..1f49b3c32db --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 (length + overridden to false (type conversion)) +---*/ + +var i = SendableArray.prototype.lastIndexOf.call({ + length: false +}, 1); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-4.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-4.js new file mode 100644 index 00000000000..93a59aa25e3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 (generic + 'array' with length 0 ) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); + +function foo() {} +var f = new foo(); +f.length = 0; +var i = SendableArray.prototype.lastIndexOf.call({ + length: 0 +}, 1); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-5.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-5.js new file mode 100644 index 00000000000..cd96e87fd75 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-5.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 ( length + overridden to '0' (type conversion)) +---*/ + +var i = SendableArray.prototype.lastIndexOf.call({ + length: '0' +}, 1); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-6.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-6.js new file mode 100644 index 00000000000..121af593401 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-6.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 + (subclassed Array, length overridden with obj with valueOf) +---*/ + +var i = SendableArray.prototype.lastIndexOf.call({ + length: { + valueOf: function() { + return 0; + } + } +}, 1); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-7.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-7.js new file mode 100644 index 00000000000..3440d125f39 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-7.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 ( length + is object overridden with obj w/o valueOf (toString)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +var i = SendableArray.prototype.lastIndexOf.call({ + length: { + toString: function() { + return '0'; + } + } +}, 1); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-8.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-8.js new file mode 100644 index 00000000000..2b98cef3fcf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-8.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 (length is + an empty array) +---*/ + +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +var i = SendableArray.prototype.lastIndexOf.call({ + length: [] +}, 1); +assert.sameValue(i, -1, 'i'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-9.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-9.js new file mode 100644 index 00000000000..17a45ad4671 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-4-9.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - 'length' is a number of value 0.1 +---*/ + +var targetObj = []; +var obj = { + 0: targetObj, + 100: targetObj, + length: 0.1 +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, targetObj), -1, 'SendableArray.prototype.lastIndexOf.call(obj, targetObj)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-1.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-1.js new file mode 100644 index 00000000000..c812d39c923 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is string +---*/ + +var a = new SendableArray(0, 1, 1); +assert.sameValue(a.lastIndexOf(1, "1"), 1, '"1" resolves to 1'); +assert.sameValue(a.lastIndexOf(1, "one"), -1, 'NaN string resolves to 01'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-10.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-10.js new file mode 100644 index 00000000000..9e251931c87 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-10.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is positive number) +---*/ + +var targetObj = {}; +assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, 1.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, 1.5)'); +assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, 1.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, 1.5)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-11.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-11.js new file mode 100644 index 00000000000..8dcae0dafcb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-11.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is negative number) +---*/ + +var targetObj = {}; +assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, -2.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, -2.5)'); +assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, -2.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, -2.5)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-12.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-12.js new file mode 100644 index 00000000000..e3c67c5e730 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-12.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is Infinity) +---*/ + +var arr = []; +arr[Math.pow(2, 32) - 2] = null; // length is the max value of Uint type +assert.sameValue(arr.lastIndexOf(null, Infinity), Math.pow(2, 32) - 2, 'arr.lastIndexOf(null, Infinity)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-13.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-13.js new file mode 100644 index 00000000000..5926479d9df --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-13.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is -Infinity) +---*/ + +assert.sameValue([true].lastIndexOf(true, -Infinity), -1, '[true].lastIndexOf(true, -Infinity)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-14.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-14.js new file mode 100644 index 00000000000..b64a1e07f1e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-14.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is NaN) +---*/ + +// from Index will be convert to +0 +assert.sameValue([0, true].lastIndexOf(true, NaN), -1, '[0, true].lastIndexOf(true, NaN)'); +assert.sameValue([true, 0].lastIndexOf(true, NaN), 0, '[true, 0].lastIndexOf(true, NaN)'); +assert.sameValue([0, true].lastIndexOf(true, -NaN), -1, '[0, true].lastIndexOf(true, -NaN)'); +assert.sameValue([true, 0].lastIndexOf(true, -NaN), 0, '[true, 0].lastIndexOf(true, -NaN)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-15.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-15.js new file mode 100644 index 00000000000..63cf3a3d4ba --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-15.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing a negative number +---*/ + +assert.sameValue([0, "-2", 2].lastIndexOf("-2", "-2"), 1, '[0, "-2", 2].lastIndexOf("-2", "-2")'); +assert.sameValue([0, 2, "-2"].lastIndexOf("-2", "-2"), -1, '[0, 2, "-2"].lastIndexOf("-2", "-2")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-16.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-16.js new file mode 100644 index 00000000000..6f572256467 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-16.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing Infinity +---*/ + +var arr = []; +arr[Math.pow(2, 32) - 2] = true; // length is the max value of Uint type +assert.sameValue(arr.lastIndexOf(true, "Infinity"), Math.pow(2, 32) - 2, 'arr.lastIndexOf(true, "Infinity")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-17.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-17.js new file mode 100644 index 00000000000..a1e609e310a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-17.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing -Infinity +---*/ + +assert.sameValue([true].lastIndexOf(true, "-Infinity"), -1, '[true].lastIndexOf(true, "-Infinity")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-18.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-18.js new file mode 100644 index 00000000000..43d998e0165 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-18.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing an exponential number +---*/ + +var targetObj = {}; +assert.sameValue([0, NaN, targetObj, 3, false].lastIndexOf(targetObj, "2E0"), 2, '[0, NaN, targetObj, 3, false].lastIndexOf(targetObj, "2E0")'); +assert.sameValue([0, NaN, 3, targetObj, false].lastIndexOf(targetObj, "2E0"), -1, '[0, NaN, 3, targetObj, false].lastIndexOf(targetObj, "2E0")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-19.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-19.js new file mode 100644 index 00000000000..30375844c94 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-19.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a string + containing a hex number +---*/ + +var targetObj = {}; +assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, "0x0002"), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, "0x0002")'); +assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, "0x0002"), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, "0x0002")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-2.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-2.js new file mode 100644 index 00000000000..520ac24a8ce --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-2.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is floating point number +---*/ + +var a = new SendableArray(1, 2, 1); +assert.sameValue(a.lastIndexOf(2, 1.49), 1, '1.49 resolves to 1'); +assert.sameValue(a.lastIndexOf(2, 0.51), -1, '0.51 resolves to 0'); +assert.sameValue(a.lastIndexOf(1, 0.51), 0, '0.51 resolves to 0'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-20.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-20.js new file mode 100644 index 00000000000..a9f8753c0ac --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-20.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' which is a + string containing a number with leading zeros +---*/ + +var targetObj = {}; +assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, "0002.10"), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, "0002.10")'); +assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, "0002.10"), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, "0002.10")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-21.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-21.js new file mode 100644 index 00000000000..0f3062e40ce --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-21.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' which is an + Object, and has an own toString method +---*/ + +// objects inherit the default valueOf() method from Object +// that simply returns itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +var fromIndex = { + toString: function() { + return '2'; + } +}; +var targetObj = new RegExp(); +assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex)'); +assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-22.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-22.js new file mode 100644 index 00000000000..0f8243aea33 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-22.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' which is an + object, and has an own valueOf method +---*/ + +var fromIndex = { + valueOf: function() { + return 2; + } +}; +var targetObj = function() {}; +assert.sameValue([0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex), 2, '[0, true, targetObj, 3, false].lastIndexOf(targetObj, fromIndex)'); +assert.sameValue([0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex), -1, '[0, true, 3, targetObj, false].lastIndexOf(targetObj, fromIndex)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js new file mode 100644 index 00000000000..71ebce49106 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-23.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is an object + that has an own valueOf method that returns an object and toString + method that returns a string +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var fromIndex = { + toString: function() { + toStringAccessed = true; + return '1'; + }, + valueOf: function() { + valueOfAccessed = true; + return {}; + } +}; +assert.sameValue([0, true].lastIndexOf(true, fromIndex), 1, '[0, true].lastIndexOf(true, fromIndex)'); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js new file mode 100644 index 00000000000..5266fae5675 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-24.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf throws TypeError exception when value + of 'fromIndex' is an object that both toString and valueOf methods + than don't return primitive value +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var fromIndex = { + toString: function() { + toStringAccessed = true; + return {}; + }, + valueOf: function() { + valueOfAccessed = true; + return {}; + } +}; +assert.throws(TypeError, function() { + [0, null].lastIndexOf(null, fromIndex); +}); +assert(toStringAccessed, 'toStringAccessed'); +assert(valueOfAccessed, 'valueOfAccessed'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-25.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-25.js new file mode 100644 index 00000000000..761c22a6f24 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-25.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf use inherited valueOf method when + value of 'fromIndex' is an object with an own toString and + inherited valueOf methods +---*/ + +var toStringAccessed = false; +var valueOfAccessed = false; +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 1; + } +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return 1; +}; +assert.sameValue([0, true].lastIndexOf(true, child), 1, '[0, true].lastIndexOf(true, child)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-26.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-26.js new file mode 100644 index 00000000000..4d230b28fdc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-26.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var stepTwoOccurs = false; +var stepFiveOccurs = false; +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + stepTwoOccurs = true; + if (stepFiveOccurs) { + throw new Error("Step 5 occurred out of order"); + } + return 20; + }, + configurable: true +}); +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +SendableArray.prototype.lastIndexOf.call(obj, undefined, fromIndex); +assert(stepTwoOccurs, 'stepTwoOccurs !== true'); +assert(stepFiveOccurs, 'stepFiveOccurs !== true'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-27.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-27.js new file mode 100644 index 00000000000..988b4eedf17 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-27.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var stepThreeOccurs = false; +var stepFiveOccurs = false; +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return { + valueOf: function() { + stepThreeOccurs = true; + if (stepFiveOccurs) { + throw new Error("Step 5 occurred out of order"); + } + return 20; + } + }; + }, + configurable: true +}); +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +SendableArray.prototype.lastIndexOf.call(obj, undefined, fromIndex); +assert(stepThreeOccurs, 'stepThreeOccurs !== true'); +assert(stepFiveOccurs, 'stepFiveOccurs !== true'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-28.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-28.js new file mode 100644 index 00000000000..eed1f9cef62 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-28.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 1 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(TypeError, function() { + SendableArray.prototype.lastIndexOf.call(undefined, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-29.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-29.js new file mode 100644 index 00000000000..30c9e3f9f24 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-29.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + throw new RangeError(); + }, + configurable: true +}); +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(RangeError, function() { + SendableArray.prototype.lastIndexOf.call(obj, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-3.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-3.js new file mode 100644 index 00000000000..8c86d0157eb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-3.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is boolean +---*/ + +var a = new SendableArray(1, 2, 1); +assert.sameValue(a.lastIndexOf(2, true), 1, 'true resolves to 1'); +assert.sameValue(a.lastIndexOf(2, false), -1, 'false resolves to 0'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-30.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-30.js new file mode 100644 index 00000000000..8fec1a52472 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-30.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var stepFiveOccurs = false; +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return { + valueOf: function() { + throw new TypeError(); + } + }; + }, + configurable: true +}); +var fromIndex = { + valueOf: function() { + stepFiveOccurs = true; + return 0; + } +}; +assert.throws(TypeError, function() { + SendableArray.prototype.lastIndexOf.call(obj, undefined, fromIndex); +}); +assert.sameValue(stepFiveOccurs, false, 'stepFiveOccurs'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-31.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-31.js new file mode 100644 index 00000000000..82905fa30e0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-31.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'fromIndex' is a positive + non-integer, verify truncation occurs in the proper direction +---*/ + +var targetObj = {}; +assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, 1.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, 1.5)'); +assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, 1.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, 1.5)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-32.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-32.js new file mode 100644 index 00000000000..6fc5ac7318e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-32.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - 'fromIndex' is a negative + non-integer, verify truncation occurs in the proper direction +---*/ + +var targetObj = {}; +assert.sameValue([0, targetObj, true].lastIndexOf(targetObj, -2.5), 1, '[0, targetObj, true].lastIndexOf(targetObj, -2.5)'); +assert.sameValue([0, true, targetObj].lastIndexOf(targetObj, -2.5), -1, '[0, true, targetObj].lastIndexOf(targetObj, -2.5)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-33.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-33.js new file mode 100644 index 00000000000..eb34336a131 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-33.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - match on the first element, a middle + element and the last element when 'fromIndex' is passed +---*/ + +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(0, 0), 0, '[0, 1, 2, 3, 4].lastIndexOf(0, 0)'); +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(0, 2), 0, '[0, 1, 2, 3, 4].lastIndexOf(0, 2)'); +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(2, 2), 2, '[0, 1, 2, 3, 4].lastIndexOf(2, 2)'); +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(2, 4), 2, '[0, 1, 2, 3, 4].lastIndexOf(2, 4)'); +assert.sameValue([0, 1, 2, 3, 4].lastIndexOf(4, 4), 4, '[0, 1, 2, 3, 4].lastIndexOf(4, 4)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-4.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-4.js new file mode 100644 index 00000000000..9ecb2148a0f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-4.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is undefined +---*/ + +var a = new SendableArray(1, 2, 1); +// undefined resolves to 0, no second argument resolves to len +assert.sameValue(a.lastIndexOf(2, undefined), -1, 'a.lastIndexOf(2,undefined)'); +assert.sameValue(a.lastIndexOf(1, undefined), 0, 'a.lastIndexOf(1,undefined)'); +assert.sameValue(a.lastIndexOf(1), 2, 'a.lastIndexOf(1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-5.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-5.js new file mode 100644 index 00000000000..8a460c4a0dd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-5.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when fromIndex is null +---*/ + +var a = new SendableArray(1, 2, 1); +// null resolves to 0 +assert.sameValue(a.lastIndexOf(2, null), -1, 'a.lastIndexOf(2,null)'); +assert.sameValue(a.lastIndexOf(1, null), 0, 'a.lastIndexOf(1,null)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-6.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-6.js new file mode 100644 index 00000000000..b1bc6768d7e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-6.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf when 'fromIndex' isn't passed +---*/ + +var arr = [0, 1, 2, 3, 4]; +//'fromIndex' will be set as 4 if not passed by default +assert.sameValue(arr.lastIndexOf(0), arr.lastIndexOf(0, 4), 'arr.lastIndexOf(0)'); +assert.sameValue(arr.lastIndexOf(2), arr.lastIndexOf(2, 4), 'arr.lastIndexOf(2)'); +assert.sameValue(arr.lastIndexOf(4), arr.lastIndexOf(4, 4), 'arr.lastIndexOf(4)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-7.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-7.js new file mode 100644 index 00000000000..b5d4bed0bd4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-7.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is 0) +---*/ + +assert.sameValue([0, 100].lastIndexOf(100, 0), -1, 'verify fromIndex is not more than 0'); +assert.sameValue([200, 0].lastIndexOf(200, 0), 0, 'verify fromIndex is not less than 0'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-8.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-8.js new file mode 100644 index 00000000000..a7a93f11d82 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-8.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is +0) +---*/ + +assert.sameValue([0, true].lastIndexOf(true, +0), -1, '[0, true].lastIndexOf(true, +0)'); +assert.sameValue([true, 0].lastIndexOf(true, +0), 0, '[true, 0].lastIndexOf(true, +0)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-9.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-9.js new file mode 100644 index 00000000000..59b7c883418 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-5-9.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - value of 'fromIndex' is a number + (value is -0) +---*/ + +assert.sameValue([0, true].lastIndexOf(true, -0), -1, '[0, true].lastIndexOf(true, -0)'); +assert.sameValue([true, 0].lastIndexOf(true, -0), 0, '[true, 0].lastIndexOf(true, -0)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-1.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-1.js new file mode 100644 index 00000000000..a6d00790607 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-1.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf when fromIndex greater than + Array.length +---*/ + +var a = new SendableArray(1, 2, 3); +assert.sameValue(a.lastIndexOf(3, 5.4), 2, 'a.lastIndexOf(3,5.4)'); +assert.sameValue(a.lastIndexOf(3, 3.1), 2, 'a.lastIndexOf(3,3.1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-2.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-2.js new file mode 100644 index 00000000000..d0650e06e80 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-2.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns correct index when 'fromIndex' + is length of array - 1 +---*/ + +assert.sameValue([1, 2, 3].lastIndexOf(3, 2), 2, '[1, 2, 3].lastIndexOf(3, 2)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-3.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-3.js new file mode 100644 index 00000000000..cf94a676dd2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-3.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 when 'fromIndex' is length + of array - 1 +---*/ + +assert.sameValue([1, 2, 3].lastIndexOf(3, 1), -1, '[1, 2, 3].lastIndexOf(3, 1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-4.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-4.js new file mode 100644 index 00000000000..5cc0b51ed6b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-4.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 when 'fromIndex' and + 'length' are both 0 +---*/ + +assert.sameValue([].lastIndexOf(1, 0), -1, '[].lastIndexOf(1, 0)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-5.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-5.js new file mode 100644 index 00000000000..48662c681c6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-5.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf returns -1 when 'fromIndex' is 1 +---*/ + +assert.sameValue([1, 2, 3].lastIndexOf(3, 1), -1, '[1, 2, 3].lastIndexOf(3, 1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-6.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-6.js new file mode 100644 index 00000000000..b0aa89fcb9d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-6-6.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns correct index when 'fromIndex' + is 1 +---*/ + +assert.sameValue([1, 2, 3].lastIndexOf(2, 1), 1, '[1, 2, 3].lastIndexOf(2, 1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-1.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-1.js new file mode 100644 index 00000000000..ca30f527046 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf with negative fromIndex +---*/ + +var a = new SendableArray(1, 2, 3); +assert.sameValue(a.lastIndexOf(2, -2), 1, 'a.lastIndexOf(2,-2)'); +assert.sameValue(a.lastIndexOf(2, -3), -1, 'a.lastIndexOf(2,-3)'); +assert.sameValue(a.lastIndexOf(1, -5.3), -1, 'a.lastIndexOf(1,-5.3)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-2.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-2.js new file mode 100644 index 00000000000..4aa0abc9839 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-2.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns correct index when 'fromIndex' + is -1 +---*/ + +assert.sameValue([1, 2, 3, 4].lastIndexOf(4, -1), 3, '[1, 2, 3, 4].lastIndexOf(4, -1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-3.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-3.js new file mode 100644 index 00000000000..ca18cd9ae3a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-3.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 when abs('fromIndex') is + length of array - 1 +---*/ + +assert.sameValue([1, 2, 3, 4].lastIndexOf(3, -3), -1, '[1, 2, 3, 4].lastIndexOf(3, -3)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-4.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-4.js new file mode 100644 index 00000000000..2a50ea04cfc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-7-4.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 when abs('fromIndex') is + length of array +---*/ + +assert.sameValue([1, 2, 3, 4].lastIndexOf(2, -4), -1, '[1, 2, 3, 4].lastIndexOf(2, -4)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-1.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-1.js new file mode 100644 index 00000000000..701e603b015 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-1.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(boolean) +---*/ + +var obj = { + toString: function() { + return true + } +}; +var _false = false; +var a = new SendableArray(false, true, false, obj, _false, true, "true", undefined, 0, null, 1, "str", 0, 1); +assert.sameValue(a.lastIndexOf(true), 5, 'a[5]=true'); +assert.sameValue(a.lastIndexOf(false), 4, 'a[4] =_false'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-10.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-10.js new file mode 100644 index 00000000000..cc9f1f20982 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-10.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + note that prior to the finally ES5 draft SameValue was used for comparisions + and hence NaNs could be found using lastIndexOf * +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index (NaN) +---*/ + +var _NaN = NaN; +var a = new SendableArray("NaN", _NaN, NaN, undefined, 0, false, null, { + toString: function() { + return NaN + } +}, "false"); +assert.sameValue(a.lastIndexOf(NaN), -1, 'NaN matches nothing, not even itself'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-11.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-11.js new file mode 100644 index 00000000000..8d910b2bf2c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-11.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - the length of iteration isn't + changed by adding elements to the array during iteration +---*/ + +var arr = [20]; +Object.defineProperty(arr, "0", { + get: function() { + arr[1] = 1; + return 0; + }, + configurable: true +}); +assert.sameValue(arr.lastIndexOf(1), -1, 'arr.lastIndexOf(1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-2.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-2.js new file mode 100644 index 00000000000..9044cbed5f8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-2.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(Number) +---*/ + +var obj = { + toString: function() { + return 0 + } +}; +var one = 1; +var _float = -(4 / 3); +var a = new SendableArray(+0, true, 0, -0, false, undefined, null, "0", obj, _float, -(4 / 3), -1.3333333333333, "str", one, 1, false); +assert.sameValue(a.lastIndexOf(-(4 / 3)), 10, 'a[10]=-(4/3)'); +assert.sameValue(a.lastIndexOf(0), 3, 'a[3] = -0, but using === -0 and 0 are equal'); +assert.sameValue(a.lastIndexOf(-0), 3, 'a[3] = -0'); +assert.sameValue(a.lastIndexOf(1), 14, 'a[14] = 1'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-3.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-3.js new file mode 100644 index 00000000000..eb349eb3d4d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-3.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(string) +---*/ + +var obj = { + toString: function() { + return "false" + } +}; +var szFalse = "false"; +var a = new SendableArray(szFalse, "false", "false1", undefined, 0, false, null, 1, obj, 0); +assert.sameValue(a.lastIndexOf("false"), 1, 'a.lastIndexOf("false")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-4.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-4.js new file mode 100644 index 00000000000..bffdaef4888 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(undefined) +---*/ + +var obj = { + toString: function() { + return undefined; + } +}; +var _undefined1 = undefined; +var _undefined2; +var a = new SendableArray(_undefined1, _undefined2, undefined, true, 0, false, null, 1, "undefined", obj, 1); +assert.sameValue(a.lastIndexOf(undefined), 2, 'a.lastIndexOf(undefined)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-5.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-5.js new file mode 100644 index 00000000000..3383f7be6d2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-5.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(Object) +---*/ + +var obj1 = { + toString: function() { + return "false" + } +}; +var obj2 = { + toString: function() { + return "false" + } +}; +var obj3 = obj1; +var a = new SendableArray(obj2, obj1, obj3, false, undefined, 0, false, null, { + toString: function() { + return "false" + } +}, "false"); +assert.sameValue(a.lastIndexOf(obj3), 2, 'a.lastIndexOf(obj3)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-6.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-6.js new file mode 100644 index 00000000000..c349dc3b8f6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-6.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index(null) +---*/ + +var obj = { + toString: function() { + return null + } +}; +var _null = null; +var a = new SendableArray(true, undefined, 0, false, null, 1, "str", 0, 1, null, true, false, undefined, _null, "null", undefined, "str", obj); +assert.sameValue(a.lastIndexOf(null), 13, 'a.lastIndexOf(null)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js new file mode 100644 index 00000000000..93eeb962f7f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-7.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf must return correct index (self + reference) +---*/ + +var a = new SendableArray(0, 1, 2, 3); +a[2] = a; +assert.sameValue(a.lastIndexOf(a), 2, 'a.lastIndexOf(a)'); +assert.sameValue(a.lastIndexOf(3), 3, 'a.lastIndexOf(3)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-8.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-8.js new file mode 100644 index 00000000000..5efd04ee4b7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-8.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf must return correct index (Array) +---*/ + +var b = new SendableArray("0,1"); +var a = new SendableArray(0, b, "0,1", 3); +assert.sameValue(a.lastIndexOf(b.toString()), 2, 'a.lastIndexOf(b.toString())'); +assert.sameValue(a.lastIndexOf("0,1"), 2, 'a.lastIndexOf("0,1")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-9.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-9.js new file mode 100644 index 00000000000..d4a97fb5a4d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-9.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf must return correct index (Sparse + Array) +---*/ + +var a = new SendableArray(0, 1); +a[4294967294] = 2; // 2^32-2 - is max array element index +a[4294967295] = 3; // 2^32-1 added as non-array element property +a[4294967296] = 4; // 2^32 added as non-array element property +a[4294967297] = 5; // 2^32+1 added as non-array element property +// stop searching near the end in case implementation actually tries to test all missing elements!! +a[4294967200] = 3; +a[4294967201] = 4; +a[4294967202] = 5; +assert.sameValue(a.lastIndexOf(2), 4294967294, 'a.lastIndexOf(2)'); +assert.sameValue(a.lastIndexOf(3), 4294967200, 'a.lastIndexOf(3)'); +assert.sameValue(a.lastIndexOf(4), 4294967201, 'a.lastIndexOf(4)'); +assert.sameValue(a.lastIndexOf(5), 4294967202, 'a.lastIndexOf(5)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-1.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-1.js new file mode 100644 index 00000000000..e647067c577 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - added properties in step 2 are + visible here +---*/ + +var arr = {}; +Object.defineProperty(arr, "length", { + get: function() { + arr[2] = "length"; + return 3; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(arr, "length"), 2, 'SendableArray.prototype.lastIndexOf.call(arr, "length")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-10.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-10.js new file mode 100644 index 00000000000..98a0fa17008 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-10.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - properties can be added to prototype + after current position are visited on an Array +---*/ + +var arr = [0, , 2]; +Object.defineProperty(arr, "2", { + get: function() { + Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert.sameValue(arr.lastIndexOf(6.99), 1, 'arr.lastIndexOf(6.99)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-11.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-11.js new file mode 100644 index 00000000000..2c7f07c820f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-11.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting own property causes index + property not to be visited on an Array-like object +---*/ + +var arr = { + length: 200 +}; +Object.defineProperty(arr, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); +Object.defineProperty(arr, "100", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(arr, 6.99), -1, 'SendableArray.prototype.lastIndexOf.call(arr, 6.99)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-12.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-12.js new file mode 100644 index 00000000000..b9039bace88 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-12.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting own property causes index + property not to be visited on an Array +---*/ + +var arr = [1, 2, 3, 4]; +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); +Object.defineProperty(arr, "3", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +assert.sameValue(arr.lastIndexOf("6.99"), -1, 'arr.lastIndexOf("6.99")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-13.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-13.js new file mode 100644 index 00000000000..d1684802056 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-13.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting property of prototype + causes prototype index property not to be visited on an Array-like + Object +---*/ + +var arr = { + 2: 2, + length: 20 +}; +Object.defineProperty(arr, "3", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(arr, 1), -1, 'SendableArray.prototype.lastIndexOf.call(arr, 1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-14.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-14.js new file mode 100644 index 00000000000..d1093535ec5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-14.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting property of prototype + causes prototype index property not to be visited on an Array +---*/ + +var arr = [0, , 2]; +Object.defineProperty(arr, "20", { + get: function() { + delete SendableArray.prototype[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +assert.sameValue(arr.lastIndexOf(1), -1, 'arr.lastIndexOf(1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-15.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-15.js new file mode 100644 index 00000000000..dac87fa40ee --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-15.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting own property with + prototype property causes prototype index property to be visited + on an Array-like object +---*/ + +var arr = { + 0: 0, + 1: 111, + 2: 2, + length: 10 +}; +Object.defineProperty(arr, "6", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(arr, 1), 1, 'SendableArray.prototype.lastIndexOf.call(arr, 1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-16.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-16.js new file mode 100644 index 00000000000..f423fd8b0f1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-16.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleting own property with + prototype property causes prototype index property to be visited + on an Array +---*/ + +var arr = [0, 111, 2]; +Object.defineProperty(arr, "2", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +assert.sameValue(arr.lastIndexOf(1), 1, 'arr.lastIndexOf(1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-17.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-17.js new file mode 100644 index 00000000000..e77c47e3c8b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-17.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - decreasing length of array causes + index property not to be visited +---*/ + +var arr = [0, 1, 2, "last", 4]; +Object.defineProperty(arr, "4", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); +assert.sameValue(arr.lastIndexOf("last"), -1, 'arr.lastIndexOf("last")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-18.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-18.js new file mode 100644 index 00000000000..97e75c08667 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-18.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - decreasing length of array with + prototype property causes prototype index property to be visited +---*/ + +var arr = [0, 1, 2, 3, 4]; +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +assert.sameValue(arr.lastIndexOf("prototype"), 2, 'arr.lastIndexOf("prototype")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-19.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-19.js new file mode 100644 index 00000000000..06578385358 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-19.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - decreasing length of array does not + delete non-configurable properties +flags: [noStrict] +---*/ + +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +assert.sameValue(arr.lastIndexOf("unconfigurable"), 2, 'arr.lastIndexOf("unconfigurable")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-2.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-2.js new file mode 100644 index 00000000000..355584b362d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-2.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - added properties in step 5 are + visible here on an Array-like object +---*/ + +var arr = { + length: 30 +}; +var targetObj = function() {}; +var fromIndex = { + valueOf: function() { + arr[4] = targetObj; + return 10; + } +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(arr, targetObj, fromIndex), 4, 'SendableArray.prototype.lastIndexOf.call(arr, targetObj, fromIndex)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js new file mode 100644 index 00000000000..23fd630eac6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-3.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - added properties in step 5 are + visible here on an Array +---*/ + +var arr = []; +arr.length = 30; +var targetObj = function() {}; +var fromIndex = { + valueOf: function() { + arr[4] = targetObj; + return 11; + } +}; +assert.sameValue(arr.lastIndexOf(targetObj, fromIndex), 4, 'arr.lastIndexOf(targetObj, fromIndex)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-4.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-4.js new file mode 100644 index 00000000000..6168091ab74 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-4.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleted properties in step 2 are + visible here +---*/ + +var arr = { + 2: 6.99 +}; +Object.defineProperty(arr, "length", { + get: function() { + delete arr[2]; + return 3; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(arr, 6.99), -1, 'SendableArray.prototype.lastIndexOf.call(arr, 6.99)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-5.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-5.js new file mode 100644 index 00000000000..43fb9a51475 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-5.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleted properties of step 5 are + visible here on an Array-like object +---*/ + +var arr = { + 10: false, + length: 30 +}; +var fromIndex = { + valueOf: function() { + delete arr[10]; + return 15; + } +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(arr, false, fromIndex), -1, 'SendableArray.prototype.lastIndexOf.call(arr, false, fromIndex)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-6.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-6.js new file mode 100644 index 00000000000..9fd28ddc947 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-6.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - deleted properties of step 5 are + visible here on an Array +---*/ + +var arr = []; +arr[10] = "10"; +arr.length = 20; +var fromIndex = { + valueOf: function() { + delete arr[10]; + return 11; + } +}; +assert.sameValue(arr.lastIndexOf("10", fromIndex), -1, 'arr.lastIndexOf("10", fromIndex)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-7.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-7.js new file mode 100644 index 00000000000..a87bc303cc2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-7.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - properties added into own object + after current position are visited on an Array-like object +---*/ + +var arr = { + length: 8 +}; +Object.defineProperty(arr, "4", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(arr, 1), 1, 'SendableArray.prototype.lastIndexOf.call(arr, 1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-8.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-8.js new file mode 100644 index 00000000000..d2f3a52951c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-8.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - properties added into own object + after current position are visited on an Array +---*/ + +var arr = [0, , 2]; +Object.defineProperty(arr, "2", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert.sameValue(arr.lastIndexOf(1), 1, 'arr.lastIndexOf(1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-9.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-9.js new file mode 100644 index 00000000000..49cae2d8b92 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-a-9.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - properties can be added to + prototype after current position are visited on an Array-like + object +---*/ + +var arr = { + length: 9 +}; +Object.defineProperty(arr, "4", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return Infinity; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(arr, Infinity), 1, 'SendableArray.prototype.lastIndexOf.call(arr, Infinity)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-1.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-1.js new file mode 100644 index 00000000000..743145090ea --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-1.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - undefined property wouldn't be called +---*/ + +assert.sameValue([0, , 2].lastIndexOf(undefined), -1, '[0, , 2].lastIndexOf(undefined)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-1.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-1.js new file mode 100644 index 00000000000..c53d7e1f640 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property on an Array-like object +---*/ + +var obj = { + 0: 0, + 1: 1, + 2: 2, + length: 3 +}; +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 0), 0, 'SendableArray.prototype.lastIndexOf.call(obj, 0)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 1), 1, 'SendableArray.prototype.lastIndexOf.call(obj, 1)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 2), 2, 'SendableArray.prototype.lastIndexOf.call(obj, 2)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-10.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-10.js new file mode 100644 index 00000000000..bc857b8fba5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-10.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property on an Array-like object +---*/ + +var obj = { + length: 3 +}; +Object.defineProperty(obj, "0", { + get: function() { + return 0; + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + return 1; + }, + configurable: true +}); +Object.defineProperty(obj, "2", { + get: function() { + return 2; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 0), 0, 'SendableArray.prototype.lastIndexOf.call(obj, 0)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 1), 1, 'SendableArray.prototype.lastIndexOf.call(obj, 1)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, 2), 2, 'SendableArray.prototype.lastIndexOf.call(obj, 2)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-11.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-11.js new file mode 100644 index 00000000000..9723511ebd8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-11.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property that overrides an inherited data property on an + Array +---*/ + +var arr = []; +SendableArray.prototype[0] = false; +Object.defineProperty(arr, "0", { + get: function() { + return true; + }, + configurable: true +}); +assert.sameValue(arr.lastIndexOf(true), 0, 'arr.lastIndexOf(true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-12.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-12.js new file mode 100644 index 00000000000..5c2b98199d2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-12.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property that overrides an inherited data property on an + Array-like object +---*/ + +var obj = { + length: 1 +}; +Object.prototype[0] = false; +Object.defineProperty(obj, "0", { + get: function() { + return true; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, true), 0, 'SendableArray.prototype.lastIndexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-13.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-13.js new file mode 100644 index 00000000000..4f377aabc90 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-13.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property that overrides an inherited accessor property on + an Array +---*/ + +var arr = []; +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + return true; + }, + configurable: true +}); +assert.sameValue(arr.lastIndexOf(true), 0, 'arr.lastIndexOf(true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-14.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-14.js new file mode 100644 index 00000000000..cd46b0dd894 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-14.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property that overrides an inherited accessor property on + an Array-like object +---*/ + +var obj = { + length: 1 +}; +Object.defineProperty(Object.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + return true; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, true), 0, 'SendableArray.prototype.lastIndexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-15.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-15.js new file mode 100644 index 00000000000..cda7ab3b15e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-15.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + accessor property on an Array +---*/ + +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 10; + }, + configurable: true +}); +Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 20; + }, + configurable: true +}); + +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return 30; + }, + configurable: true +}); +assert.sameValue([, , , ].lastIndexOf(10), 0, '[, , , ].lastIndexOf(10)'); +assert.sameValue([, , , ].lastIndexOf(20), 1, '[, , , ].lastIndexOf(20)'); +assert.sameValue([, , , ].lastIndexOf(30), 2, '[, , , ].lastIndexOf(30)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-16.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-16.js new file mode 100644 index 00000000000..60f63364ff0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-16.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return 10; + }, + configurable: true +}); +Object.defineProperty(Object.prototype, "1", { + get: function() { + return 20; + }, + configurable: true +}); +Object.defineProperty(Object.prototype, "2", { + get: function() { + return 30; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call({ + length: 3 +}, 10), 0, 'SendableArray.prototype.lastIndexOf.call({ length: 3 }, 10)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call({ + length: 3 +}, 20), 1, 'SendableArray.prototype.lastIndexOf.call({ length: 3 }, 20)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call({ + length: 3 +}, 30), 2, 'SendableArray.prototype.lastIndexOf.call({ length: 3 }, 30)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-17.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-17.js new file mode 100644 index 00000000000..e67a0ae63e0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-17.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property without a get function on an Array +---*/ + +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +assert.sameValue(arr.lastIndexOf(undefined), 0, 'arr.lastIndexOf(undefined)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-18.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-18.js new file mode 100644 index 00000000000..e0ae6e23b70 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-18.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property without a get function on an Array-like object +---*/ + +var obj = { + length: 1 +}; +Object.defineProperty(obj, "0", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, undefined), 0, 'SendableArray.prototype.lastIndexOf.call(obj, undefined)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-19.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-19.js new file mode 100644 index 00000000000..652c419e5d2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-19.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property without a get function that overrides an + inherited accessor property on an Array-like object +---*/ + +var obj = { + length: 1 +}; +Object.defineProperty(Object.prototype, "0", { + get: function() { + return 20; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + set: function() {}, + configurable: true +}); +assert(obj.hasOwnProperty(0), 'obj.hasOwnProperty(0) !== true'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, undefined), 0, 'SendableArray.prototype.lastIndexOf.call(obj, undefined)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-2.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-2.js new file mode 100644 index 00000000000..3d43ca2ee59 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-2.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property on an Array +---*/ + +assert.sameValue([true, true, true].lastIndexOf(true), 2, '[true, true, true].lastIndexOf(true)'); +assert.sameValue([true, true, false].lastIndexOf(true), 1, '[true, true, false].lastIndexOf(true)'); +assert.sameValue([true, false, false].lastIndexOf(true), 0, '[true, false, false].lastIndexOf(true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-20.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-20.js new file mode 100644 index 00000000000..103bd50e28b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-20.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is an own + accessor property without a get function that overrides an + inherited accessor property on an Array +---*/ + +var arr = [, 1]; +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 100; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +assert(arr.hasOwnProperty(0), 'arr.hasOwnProperty(0) !== true'); +assert.sameValue(arr.lastIndexOf(undefined), 0, 'arr.lastIndexOf(undefined)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-21.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-21.js new file mode 100644 index 00000000000..358d8ae6fdc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-21.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +Object.defineProperty(SendableArray.prototype, "0", { + set: function() {}, + configurable: true +}); +assert.sameValue([, ].lastIndexOf(undefined), 0, '[, ].lastIndexOf(undefined)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-22.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-22.js new file mode 100644 index 00000000000..b37ce6fe268 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-22.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call({ + length: 1 +}, undefined), 0, 'SendableArray.prototype.lastIndexOf.call({ length: 1 }, undefined)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-25.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-25.js new file mode 100644 index 00000000000..c724b661e50 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-25.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +var func = function(a, b) { + return 0 === SendableArray.prototype.lastIndexOf.call(arguments, arguments[0]) && + -1 === SendableArray.prototype.lastIndexOf.call(arguments, arguments[1]); +}; +assert(func(true), 'func(true) !== true'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-26.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-26.js new file mode 100644 index 00000000000..602afdb6aa7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-26.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to Arguments object which + implements its own property get method (number of arguments equals + to number of parameters) +---*/ + +var func = function(a, b) { + return 0 === SendableArray.prototype.lastIndexOf.call(arguments, arguments[0]) && + 1 === SendableArray.prototype.lastIndexOf.call(arguments, arguments[1]) && + -1 === SendableArray.prototype.lastIndexOf.call(arguments, arguments[2]); +}; +assert(func(0, true), 'func(0, true) !== true'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-27.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-27.js new file mode 100644 index 00000000000..6fd7a3d2adf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-27.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf applied to Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +var func = function(a, b) { + assert.sameValue(SendableArray.prototype.lastIndexOf.call(arguments, arguments[0]), 2); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(arguments, arguments[3]), 3); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(arguments, arguments[4]), -1); +}; +(function() { + func(0, arguments, 0, Object.prototype); +})(); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-28.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-28.js new file mode 100644 index 00000000000..238477d09fd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-28.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side-effects are visible in + subsequent iterations on an Array +---*/ + +var preIterVisible = false; +var arr = []; +Object.defineProperty(arr, "2", { + get: function() { + preIterVisible = true; + return false; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return true; + } else { + return false; + } + }, + configurable: true +}); +assert.sameValue(arr.lastIndexOf(true), 1, 'arr.lastIndexOf(true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-29.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-29.js new file mode 100644 index 00000000000..70b789e70f1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-29.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - side-effects are visible in + subsequent iterations on an Array-like object +---*/ + +var preIterVisible = false; +var obj = { + length: 3 +}; +Object.defineProperty(obj, "2", { + get: function() { + preIterVisible = true; + return false; + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return true; + } else { + return false; + } + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call(obj, true), 1, 'SendableArray.prototype.lastIndexOf.call(obj, true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-3.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-3.js new file mode 100644 index 00000000000..a8f80953196 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +SendableArray.prototype[0] = Object; +assert.sameValue([Object.prototype].lastIndexOf(Object.prototype), 0, '[Object.prototype].lastIndexOf(Object.prototype)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-30.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-30.js new file mode 100644 index 00000000000..cfd1fe9824d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-30.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf terminates iteration on unhandled + exception on an Array +---*/ + +var accessed = false; +var arr = []; +Object.defineProperty(arr, "2", { + get: function() { + throw new TypeError(); + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + accessed = true; + return true; + }, + configurable: true +}); +assert.throws(TypeError, function() { + arr.lastIndexOf(true); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-31.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-31.js new file mode 100644 index 00000000000..d010ee96e0a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-31.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf terminates iteration on unhandled + exception on an Array-like object +---*/ + +var accessed = false; +var obj = { + length: 3 +}; +Object.defineProperty(obj, "2", { + get: function() { + throw new TypeError(); + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + accessed = true; + return true; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.lastIndexOf.call(obj, true); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-4.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-4.js new file mode 100644 index 00000000000..4f362ae70b8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +Object.prototype[0] = false; +assert.sameValue(SendableArray.prototype.lastIndexOf.call({ + 0: true, + 1: 1, + length: 2 +}, true), 0, 'SendableArray.prototype.lastIndexOf.call({ 0: true, 1: 1, length: 2 }, true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-5.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-5.js new file mode 100644 index 00000000000..2598da89dd4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-5.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); +assert.sameValue([Number].lastIndexOf(Number), 0, '[Number].lastIndexOf(Number)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-6.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-6.js new file mode 100644 index 00000000000..d1b3add1a88 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-6.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +Object.defineProperty(Object.prototype, "0", { + get: function() { + return false; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.lastIndexOf.call({ + 0: true, + 1: 1, + length: 2 +}, true), 0, 'SendableArray.prototype.lastIndexOf.call({ 0: true, 1: 1, length: 2 }, true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-7.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-7.js new file mode 100644 index 00000000000..93b4e65ab93 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-7.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + data property on an Array +---*/ + +SendableArray.prototype[0] = true; +SendableArray.prototype[1] = false; +SendableArray.prototype[2] = "true"; +assert.sameValue([, , , ].lastIndexOf(true), 0, '[, , , ].lastIndexOf(true)'); +assert.sameValue([, , , ].lastIndexOf(false), 1, '[, , , ].lastIndexOf(false)'); +assert.sameValue([, , , ].lastIndexOf("true"), 2, '[, , , ].lastIndexOf("true")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-8.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-8.js new file mode 100644 index 00000000000..7637e2fac66 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-8.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is inherited + data property on an Array-like object +---*/ + +Object.prototype[0] = true; +Object.prototype[1] = false; +Object.prototype[2] = "true"; +assert.sameValue(SendableArray.prototype.lastIndexOf.call({ + length: 3 +}, true), 0, 'SendableArray.prototype.lastIndexOf.call({ length: 3 }, true)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call({ + length: 3 +}, false), 1, 'SendableArray.prototype.lastIndexOf.call({ length: 3 }, false)'); +assert.sameValue(SendableArray.prototype.lastIndexOf.call({ + length: 3 +}, "true"), 2, 'SendableArray.prototype.lastIndexOf.call({ length: 3 }, "true")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-9.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-9.js new file mode 100644 index 00000000000..28fec133a0f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-i-9.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - element to be retrieved is own + accessor property on an Array +---*/ + +var arr = [, , , ]; +Object.defineProperty(arr, "0", { + get: function() { + return 0; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true +}); +Object.defineProperty(arr, "2", { + get: function() { + return 2; + }, + configurable: true +}); +assert.sameValue(arr.lastIndexOf(0), 0, 'arr.lastIndexOf(0)'); +assert.sameValue(arr.lastIndexOf(1), 1, 'arr.lastIndexOf(1)'); +assert.sameValue(arr.lastIndexOf(2), 2, 'arr.lastIndexOf(2)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-1.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-1.js new file mode 100644 index 00000000000..f535a7bd5cb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-1.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - type of array element is different + from type of search element +---*/ + +assert.sameValue(["true"].lastIndexOf(true), -1, '["true"].lastIndexOf(true)'); +assert.sameValue(["0"].lastIndexOf(0), -1, '["0"].lastIndexOf(0)'); +assert.sameValue([false].lastIndexOf(0), -1, '[false].lastIndexOf(0)'); +assert.sameValue([undefined].lastIndexOf(0), -1, '[undefined].lastIndexOf(0)'); +assert.sameValue([null].lastIndexOf(0), -1, '[null].lastIndexOf(0)'); +assert.sameValue([ + [] +].lastIndexOf(0), -1, '[[]].lastIndexOf(0)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-10.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-10.js new file mode 100644 index 00000000000..6e6060d50ce --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-10.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both array element and search + element are booleans, and they have same value +---*/ + +assert.sameValue([false, true].lastIndexOf(true), 1, '[false, true].lastIndexOf(true)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-11.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-11.js new file mode 100644 index 00000000000..223077b8638 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-11.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both array element and search + element are Objects, and they refer to the same object +---*/ + +var obj1 = {}; +var obj2 = {}; +var obj3 = obj2; +assert.sameValue([obj2, obj1].lastIndexOf(obj3), 0, '[obj2, obj1].lastIndexOf(obj3)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-2.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-2.js new file mode 100644 index 00000000000..718b0d7a171 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-2.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both type of array element and type + of search element are Undefined +---*/ + +assert.sameValue([undefined].lastIndexOf(), 0, '[undefined].lastIndexOf()'); +assert.sameValue([undefined].lastIndexOf(undefined), 0, '[undefined].lastIndexOf(undefined)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-3.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-3.js new file mode 100644 index 00000000000..97d96d81833 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-3.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both type of array element and type + of search element are Null +---*/ + +assert.sameValue([null].lastIndexOf(null), 0, '[null].lastIndexOf(null)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-4.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-4.js new file mode 100644 index 00000000000..92f8ce3501c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-4.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - search element is NaN +---*/ + +assert.sameValue([+NaN, NaN, -NaN].lastIndexOf(NaN), -1, '[+NaN, NaN, -NaN].lastIndexOf(NaN)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-5.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-5.js new file mode 100644 index 00000000000..1ad9c61be55 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-5.js @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf - search element is -NaN +---*/ + +assert.sameValue([+NaN, NaN, -NaN].lastIndexOf(-NaN), -1, '[+NaN, NaN, -NaN].lastIndexOf(-NaN)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-6.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-6.js new file mode 100644 index 00000000000..543eb45b0cc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-6.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - array element is +0 and search + element is -0 +---*/ + +assert.sameValue([+0].lastIndexOf(-0), 0, '[+0].lastIndexOf(-0)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-7.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-7.js new file mode 100644 index 00000000000..c6fc7d63c69 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-7.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - array element is -0 and search + element is +0 +---*/ + +assert.sameValue([-0].lastIndexOf(+0), 0, '[-0].lastIndexOf(+0)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-8.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-8.js new file mode 100644 index 00000000000..c7379115b6a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-8.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both array element and search + element are numbers, and they have same value +---*/ + +assert.sameValue([-1, 0, 1].lastIndexOf(-1), 0, '[-1, 0, 1].lastIndexOf(-1)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-9.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-9.js new file mode 100644 index 00000000000..1d4268d87ec --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-ii-9.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf - both array element and search + element are strings, and they have exactly the same sequence of + characters +---*/ + +assert.sameValue(["abc", "ab", "bca", ""].lastIndexOf("abc"), 0, '["abc", "ab", "bca", ""].lastIndexOf("abc")'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-1.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-1.js new file mode 100644 index 00000000000..14f43e1ab90 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns index of last one when more + than two elements in array are eligible +---*/ + +assert.sameValue([2, 1, 2, 2, 1].lastIndexOf(2), 3, '[2, 1, 2, 2, 1].lastIndexOf(2)'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-2.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-2.js new file mode 100644 index 00000000000..ec95038064b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-8-b-iii-2.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns without visiting subsequent + element once search value is found +---*/ + +var arr = [2, 1, , 1, 2]; +var elementFirstAccessed = false; +var elementThirdAccessed = false; +Object.defineProperty(arr, "2", { + get: function() { + elementThirdAccessed = true; + return 2; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + elementFirstAccessed = true; + return 2; + }, + configurable: true +}); +arr.lastIndexOf(2); +assert.sameValue(elementThirdAccessed, false, 'elementThirdAccessed'); +assert.sameValue(elementFirstAccessed, false, 'elementFirstAccessed'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-9-1.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-9-1.js new file mode 100644 index 00000000000..2ca9ebda41d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-9-1.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: Array.prototype.lastIndexOf returns -1 for elements not present +---*/ + +var a = new SendableArray(); +a[100] = 1; +a[99999] = ""; +a[10] = new Object(); +a[5555] = 5.5; +a[123456] = "str"; +a[5] = 1E+309; +assert.sameValue(a.lastIndexOf(1), 100, 'a.lastIndexOf(1)'); +assert.sameValue(a.lastIndexOf(""), 99999, 'a.lastIndexOf("")'); +assert.sameValue(a.lastIndexOf("str"), 123456, 'a.lastIndexOf("str")'); +assert.sameValue(a.lastIndexOf(5.5), 5555, 'a.lastIndexOf(5.5)'); +assert.sameValue(a.lastIndexOf(1E+309), 5, 'a.lastIndexOf(1E+309)'); +assert.sameValue(a.lastIndexOf(true), -1, 'a.lastIndexOf(true)'); +assert.sameValue(a.lastIndexOf(5), -1, 'a.lastIndexOf(5)'); +assert.sameValue(a.lastIndexOf("str1"), -1, 'a.lastIndexOf("str1")'); +assert.sameValue(a.lastIndexOf(null), -1, 'a.lastIndexOf(null)'); +assert.sameValue(a.lastIndexOf(new Object()), -1, 'a.lastIndexOf(new Object())'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-9-2.js b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-9-2.js new file mode 100644 index 00000000000..68e60412ce4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/15.4.4.15-9-2.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf returns -1 if 'length' is 0 and does + not access any other properties +---*/ + +var accessed = false; +var f = { + length: 0 +}; +Object.defineProperty(f, "0", { + get: function() { + accessed = true; + return 1; + } +}); +var i = SendableArray.prototype.lastIndexOf.call(f, 1); +assert.sameValue(i, -1, 'i'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/call-with-boolean.js b/test/sendable/builtins/Array/prototype/lastIndexOf/call-with-boolean.js new file mode 100644 index 00000000000..35d911270a2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/call-with-boolean.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastIndexOf +description: Array.prototype.lastIndexOf applied to boolean primitive +---*/ + +assert.sameValue(SendableArray.prototype.lastIndexOf.call(true), -1, 'SendableArray.prototype.lastIndexOf.call(true) must return -1'); +assert.sameValue( + SendableArray.prototype.lastIndexOf.call(false), + -1, + 'SendableArray.prototype.lastIndexOf.call(false) must return -1' +); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js b/test/sendable/builtins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js new file mode 100644 index 00000000000..6bd95a90bc0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/calls-only-has-on-prototype-after-length-zeroed.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Calls [[HasProperty]] on the prototype to check for existing elements. +includes: [proxyTrapsHelper.js] +features: [Proxy] +---*/ + +var SendableArray = [5, undefined, 7]; +Object.setPrototypeOf(SendableArray, new Proxy(SendableArray.prototype, allowProxyTraps({ + has: function(t, pk) { + return pk in t; + } +}))); +var fromIndex = { + valueOf: function() { + // Zero the array's length. The loop in step 8 iterates over the original + // length value of 100, but the only prototype MOP method which should be + // called is [[HasProperty]]. + SendableArray.length = 0; + return 2; + } +}; +SendableArray.prototype.lastIndexOf.call(SendableArray, 100, fromIndex); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/coerced-position-grow.js b/test/sendable/builtins/Array/prototype/lastIndexOf/coerced-position-grow.js new file mode 100644 index 00000000000..1bc8d3bd6ed --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/coerced-position-grow.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.p.lastIndexOf behaves correctly when the resizable buffer is grown by + argument coercion. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Growing + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, 1); + } + let evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return -1; + } + }; + let n0 = MayNeedBigInt(lengthTracking, 0); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n0), -1); + // Because lastIndexOf iterates from the given index downwards, it's not + // possible to test that "we only look at the data until the original + // length" without also testing that the index conversion happening with the + // original length. + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n0, evil), -1); +} +// Growing + length-tracking TA, index conversion. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + let evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return -4; + } + }; + let n0 = MayNeedBigInt(lengthTracking, 0); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n0, -4), 0); + // The TA grew but the start index conversion is done based on the original + // length. + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n0, evil), 0); +} diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/coerced-position-shrink.js b/test/sendable/builtins/Array/prototype/lastIndexOf/coerced-position-shrink.js new file mode 100644 index 00000000000..f27cdbe2ac4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/coerced-position-shrink.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.p.lastIndexOf behaves correctly when the resizable buffer is shrunk by + argument coercion. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Shrinking + fixed-length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 2; + } + }; + let n = MayNeedBigInt(fixedLength, 0); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n), 3); + // The TA is OOB so lastIndexOf returns -1. + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n, evil), -1); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 2; + } + }; + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, MayNeedBigInt(fixedLength, 0)), 3); + // The TA is OOB so lastIndexOf returns -1, also for undefined). + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, undefined, evil), -1); +} +// Shrinking + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i); + } + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 2; + } + }; + let n = MayNeedBigInt(lengthTracking, 2); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n), 2); + // 2 no longer found. + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n, evil), -1); +} diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/fromindex-zero-conversion.js b/test/sendable/builtins/Array/prototype/lastIndexOf/fromindex-zero-conversion.js new file mode 100644 index 00000000000..4927d91a146 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/fromindex-zero-conversion.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Return +0 when fromIndex is -0 and return index refers to the first position +---*/ + +assert.sameValue(1 / [true].lastIndexOf(true, -0), +Infinity); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/length-near-integer-limit.js b/test/sendable/builtins/Array/prototype/lastIndexOf/length-near-integer-limit.js new file mode 100644 index 00000000000..ba1fb0e1967 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/length-near-integer-limit.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.lastindexof +description: > + Elements are found in an array-like object + whose "length" property is near the integer limit. +info: | + Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) +---*/ + +var el = {}; +var elIndex = Number.MAX_SAFE_INTEGER - 3; +var fromIndex = Number.MAX_SAFE_INTEGER - 1; +var arrayLike = { + length: Number.MAX_SAFE_INTEGER, +}; +arrayLike[elIndex] = el; +var res = SendableArray.prototype.lastIndexOf.call(arrayLike, el, fromIndex); +assert.sameValue(res, elIndex); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/length-zero-returns-minus-one.js b/test/sendable/builtins/Array/prototype/lastIndexOf/length-zero-returns-minus-one.js new file mode 100644 index 00000000000..7dc7fe0f12b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/length-zero-returns-minus-one.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Returns -1 if length is 0. +info: | + Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + 3. If len is 0, return -1. +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error("Length should be checked before ToInteger(fromIndex)."); + }, +}; +assert.sameValue([].lastIndexOf(1), -1); +assert.sameValue([].lastIndexOf(2, fromIndex), -1); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/length.js b/test/sendable/builtins/Array/prototype/lastIndexOf/length.js new file mode 100644 index 00000000000..a0ea9c1d078 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/length.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + The "length" property of Array.prototype.lastIndexOf +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.lastIndexOf, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/name.js b/test/sendable/builtins/Array/prototype/lastIndexOf/name.js new file mode 100644 index 00000000000..23a09b46af4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.prototype.lastIndexOf.name is "lastIndexOf". +info: | + Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + 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(SendableArray.prototype.lastIndexOf, "name", { + value: "lastIndexOf", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/not-a-constructor.js b/test/sendable/builtins/Array/prototype/lastIndexOf/not-a-constructor.js new file mode 100644 index 00000000000..32219b33fdc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/not-a-constructor.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.lastIndexOf 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(SendableArray.prototype.lastIndexOf), + false, + 'isConstructor(SendableArray.prototype.lastIndexOf) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.lastIndexOf(); +}); + diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/prop-desc.js b/test/sendable/builtins/Array/prototype/lastIndexOf/prop-desc.js new file mode 100644 index 00000000000..a3549475b3a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + "lastIndexOf" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.lastIndexOf, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "lastIndexOf", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/lastIndexOf/resizable-buffer.js b/test/sendable/builtins/Array/prototype/lastIndexOf/resizable-buffer.js new file mode 100644 index 00000000000..9248ecd8059 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/lastIndexOf/resizable-buffer.js @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.lastindexof +description: > + Array.p.lastIndexOf behaves correctly on TypedArrays backed by resizable + buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2)); + } + // Orig. array: [0, 0, 1, 1] + // [0, 0, 1, 1] << fixedLength + // [1, 1] << fixedLengthWithOffset + // [0, 0, 1, 1, ...] << lengthTracking + // [1, 1, ...] << lengthTrackingWithOffset + + // If fixedLength is a BigInt array, they all are BigInt Arrays. + let n0 = MayNeedBigInt(fixedLength, 0); + let n1 = MayNeedBigInt(fixedLength, 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n0), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n0, 1), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n0, 2), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n0, -2), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n0, -3), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n1, 1), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n1, -2), 2); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n1, -3), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, undefined), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLengthWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLengthWithOffset, n1), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLengthWithOffset, n1, -2), 0); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLengthWithOffset, n1, -1), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLengthWithOffset, undefined), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n0), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n0, 2), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n0, -3), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n1, 1), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n1, 2), 2); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n1, -3), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, undefined), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, n1), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, n1, 1), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, n1, -2), 0); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, n1, -1), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, undefined), -1); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 0, 1] + // [0, 0, 1, ...] << lengthTracking + // [1, ...] << lengthTrackingWithOffset + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n1), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLengthWithOffset, n1), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n0), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, undefined), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, n1), 0); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, undefined), -1); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n0), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLengthWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n0), 0); + // Shrink to zero. + rab.resize(0); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n0), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLengthWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n0), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, undefined), -1); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2)); + } + // Orig. array: [0, 0, 1, 1, 2, 2] + // [0, 0, 1, 1] << fixedLength + // [1, 1] << fixedLengthWithOffset + // [0, 0, 1, 1, 2, 2, ...] << lengthTracking + // [1, 1, 2, 2, ...] << lengthTrackingWithOffset + let n2 = MayNeedBigInt(fixedLength, 2); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n1), 3); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, n2), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLength, undefined), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLengthWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLengthWithOffset, n1), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLengthWithOffset, n2), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(fixedLengthWithOffset, undefined), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n1), 3); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, n2), 5); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTracking, undefined), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, n0), -1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, n1), 1); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, n2), 3); + assert.sameValue(SendableArray.prototype.lastIndexOf.call(lengthTrackingWithOffset, undefined), -1); +} -- Gitee From fdd88148bf75961dbafa6a70ef6e0ab993545f63 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 30 Dec 2024 09:51:41 +0800 Subject: [PATCH 49/93] TypedArray Signed-off-by: zhuzhihui7 --- .../prototype/byteLength/detached-buffer.js | 2 +- .../builtins/Function/15.3.2.1-10-6gs.js | 4 +- .../builtins/Function/15.3.2.1-11-1-s.js | 4 +- .../builtins/Function/15.3.2.1-11-1.js | 4 +- .../builtins/Function/15.3.2.1-11-2-s.js | 4 +- .../builtins/Function/15.3.2.1-11-3-s.js | 4 +- .../builtins/Function/15.3.2.1-11-3.js | 4 +- .../builtins/Function/15.3.2.1-11-4-s.js | 4 +- .../builtins/Function/15.3.2.1-11-5-s.js | 4 +- .../builtins/Function/15.3.2.1-11-5.js | 4 +- .../builtins/Function/15.3.2.1-11-6-s.js | 4 +- .../builtins/Function/15.3.2.1-11-7-s.js | 4 +- .../builtins/Function/15.3.2.1-11-8-s.js | 4 +- .../builtins/Function/15.3.2.1-11-9-s.js | 4 +- .../builtins/Function/15.3.5.4_2-10gs.js | 4 +- .../builtins/Function/15.3.5.4_2-15gs.js | 2 +- .../builtins/Function/15.3.5.4_2-16gs.js | 2 +- .../builtins/Function/15.3.5.4_2-17gs.js | 2 +- .../builtins/Function/15.3.5.4_2-18gs.js | 2 +- .../builtins/Function/15.3.5.4_2-19gs.js | 2 +- .../builtins/Function/15.3.5.4_2-1gs.js | 2 +- .../builtins/Function/15.3.5.4_2-20gs.js | 2 +- .../builtins/Function/15.3.5.4_2-21gs.js | 4 +- .../builtins/Function/15.3.5.4_2-22gs.js | 4 +- .../builtins/Function/15.3.5.4_2-23gs.js | 4 +- .../builtins/Function/15.3.5.4_2-24gs.js | 4 +- .../builtins/Function/15.3.5.4_2-25gs.js | 4 +- .../builtins/Function/15.3.5.4_2-26gs.js | 4 +- .../builtins/Function/15.3.5.4_2-27gs.js | 4 +- .../builtins/Function/15.3.5.4_2-28gs.js | 4 +- .../builtins/Function/15.3.5.4_2-29gs.js | 4 +- .../builtins/Function/15.3.5.4_2-2gs.js | 2 +- .../builtins/Function/15.3.5.4_2-30gs.js | 4 +- .../builtins/Function/15.3.5.4_2-31gs.js | 4 +- .../builtins/Function/15.3.5.4_2-32gs.js | 4 +- .../builtins/Function/15.3.5.4_2-33gs.js | 4 +- .../builtins/Function/15.3.5.4_2-34gs.js | 4 +- .../builtins/Function/15.3.5.4_2-35gs.js | 4 +- .../builtins/Function/15.3.5.4_2-36gs.js | 4 +- .../builtins/Function/15.3.5.4_2-37gs.js | 4 +- .../builtins/Function/15.3.5.4_2-38gs.js | 4 +- .../builtins/Function/15.3.5.4_2-39gs.js | 4 +- .../builtins/Function/15.3.5.4_2-3gs.js | 2 +- .../builtins/Function/15.3.5.4_2-40gs.js | 4 +- .../builtins/Function/15.3.5.4_2-41gs.js | 4 +- .../builtins/Function/15.3.5.4_2-42gs.js | 4 +- .../builtins/Function/15.3.5.4_2-43gs.js | 4 +- .../builtins/Function/15.3.5.4_2-44gs.js | 4 +- .../builtins/Function/15.3.5.4_2-45gs.js | 4 +- .../builtins/Function/15.3.5.4_2-46gs.js | 4 +- .../builtins/Function/15.3.5.4_2-47gs.js | 4 +- .../builtins/Function/15.3.5.4_2-4gs.js | 2 +- .../builtins/Function/15.3.5.4_2-58gs.js | 4 +- .../builtins/Function/15.3.5.4_2-59gs.js | 4 +- .../builtins/Function/15.3.5.4_2-5gs.js | 2 +- .../builtins/Function/15.3.5.4_2-60gs.js | 2 +- .../builtins/Function/15.3.5.4_2-61gs.js | 2 +- .../builtins/Function/15.3.5.4_2-62gs.js | 2 +- .../builtins/Function/15.3.5.4_2-63gs.js | 2 +- .../builtins/Function/15.3.5.4_2-64gs.js | 2 +- .../builtins/Function/15.3.5.4_2-65gs.js | 2 +- .../builtins/Function/15.3.5.4_2-66gs.js | 2 +- .../builtins/Function/15.3.5.4_2-67gs.js | 2 +- .../builtins/Function/15.3.5.4_2-68gs.js | 2 +- .../builtins/Function/15.3.5.4_2-69gs.js | 2 +- .../builtins/Function/15.3.5.4_2-6gs.js | 2 +- .../builtins/Function/15.3.5.4_2-70gs.js | 2 +- .../builtins/Function/15.3.5.4_2-71gs.js | 2 +- .../builtins/Function/15.3.5.4_2-72gs.js | 2 +- .../builtins/Function/15.3.5.4_2-73gs.js | 2 +- .../builtins/Function/15.3.5.4_2-74gs.js | 2 +- .../builtins/Function/15.3.5.4_2-77gs.js | 4 +- .../builtins/Function/15.3.5.4_2-78gs.js | 4 +- .../builtins/Function/15.3.5.4_2-79gs.js | 2 +- .../builtins/Function/15.3.5.4_2-7gs.js | 4 +- .../builtins/Function/15.3.5.4_2-80gs.js | 2 +- .../builtins/Function/15.3.5.4_2-81gs.js | 2 +- .../builtins/Function/15.3.5.4_2-82gs.js | 2 +- .../builtins/Function/15.3.5.4_2-83gs.js | 2 +- .../builtins/Function/15.3.5.4_2-84gs.js | 2 +- .../builtins/Function/15.3.5.4_2-85gs.js | 2 +- .../builtins/Function/15.3.5.4_2-86gs.js | 2 +- .../builtins/Function/15.3.5.4_2-87gs.js | 2 +- .../builtins/Function/15.3.5.4_2-88gs.js | 2 +- .../builtins/Function/15.3.5.4_2-89gs.js | 2 +- .../builtins/Function/15.3.5.4_2-8gs.js | 4 +- .../builtins/Function/15.3.5.4_2-90gs.js | 2 +- .../builtins/Function/15.3.5.4_2-91gs.js | 2 +- .../builtins/Function/15.3.5.4_2-92gs.js | 2 +- .../builtins/Function/15.3.5.4_2-93gs.js | 2 +- .../builtins/Function/15.3.5.4_2-94gs.js | 2 +- .../builtins/Function/15.3.5.4_2-95gs.js | 4 +- .../builtins/Function/15.3.5.4_2-96gs.js | 2 +- .../builtins/Function/15.3.5.4_2-97gs.js | 2 +- .../builtins/Function/15.3.5.4_2-9gs.js | 4 +- .../builtins/Function/S10.1.1_A1_T3.js | 6 +- .../builtins/Function/S15.3.1_A1_T1.js | 12 +- .../builtins/Function/S15.3.2.1_A1_T1.js | 10 +- .../builtins/Function/S15.3.2.1_A1_T10.js | 10 +- .../builtins/Function/S15.3.2.1_A1_T11.js | 10 +- .../builtins/Function/S15.3.2.1_A1_T12.js | 10 +- .../builtins/Function/S15.3.2.1_A1_T13.js | 8 +- .../builtins/Function/S15.3.2.1_A1_T2.js | 10 +- .../builtins/Function/S15.3.2.1_A1_T3.js | 10 +- .../builtins/Function/S15.3.2.1_A1_T4.js | 10 +- .../builtins/Function/S15.3.2.1_A1_T5.js | 10 +- .../builtins/Function/S15.3.2.1_A1_T6.js | 10 +- .../builtins/Function/S15.3.2.1_A1_T7.js | 10 +- .../builtins/Function/S15.3.2.1_A1_T8.js | 10 +- .../builtins/Function/S15.3.2.1_A1_T9.js | 10 +- .../builtins/Function/S15.3.2.1_A2_T1.js | 4 +- .../builtins/Function/S15.3.2.1_A2_T2.js | 4 +- .../builtins/Function/S15.3.2.1_A2_T3.js | 4 +- .../builtins/Function/S15.3.2.1_A2_T4.js | 4 +- .../builtins/Function/S15.3.2.1_A2_T5.js | 4 +- .../builtins/Function/S15.3.2.1_A2_T6.js | 4 +- .../builtins/Function/S15.3.2.1_A3_T1.js | 8 +- .../builtins/Function/S15.3.2.1_A3_T10.js | 8 +- .../builtins/Function/S15.3.2.1_A3_T11.js | 10 +- .../builtins/Function/S15.3.2.1_A3_T12.js | 10 +- .../builtins/Function/S15.3.2.1_A3_T13.js | 10 +- .../builtins/Function/S15.3.2.1_A3_T14.js | 10 +- .../builtins/Function/S15.3.2.1_A3_T15.js | 10 +- .../builtins/Function/S15.3.2.1_A3_T2.js | 10 +- .../builtins/Function/S15.3.2.1_A3_T3.js | 8 +- .../builtins/Function/S15.3.2.1_A3_T4.js | 10 +- .../builtins/Function/S15.3.2.1_A3_T5.js | 10 +- .../builtins/Function/S15.3.2.1_A3_T6.js | 8 +- .../builtins/Function/S15.3.2.1_A3_T7.js | 10 +- .../builtins/Function/S15.3.2.1_A3_T8.js | 10 +- .../builtins/Function/S15.3.2.1_A3_T9.js | 8 +- test/sendable/builtins/Function/S15.3.2_A1.js | 8 +- test/sendable/builtins/Function/S15.3.3_A1.js | 4 +- .../builtins/Function/S15.3.3_A2_T1.js | 10 +- .../builtins/Function/S15.3.3_A2_T2.js | 10 +- test/sendable/builtins/Function/S15.3.3_A3.js | 8 +- .../builtins/Function/S15.3.5_A1_T1.js | 10 +- .../builtins/Function/S15.3.5_A1_T2.js | 10 +- .../builtins/Function/S15.3.5_A2_T1.js | 6 +- .../builtins/Function/S15.3.5_A2_T2.js | 6 +- .../builtins/Function/S15.3.5_A3_T1.js | 4 +- .../builtins/Function/S15.3.5_A3_T2.js | 4 +- test/sendable/builtins/Function/S15.3_A1.js | 8 +- .../sendable/builtins/Function/S15.3_A2_T1.js | 6 +- .../sendable/builtins/Function/S15.3_A2_T2.js | 6 +- .../sendable/builtins/Function/S15.3_A3_T1.js | 8 +- .../sendable/builtins/Function/S15.3_A3_T2.js | 6 +- .../sendable/builtins/Function/S15.3_A3_T3.js | 6 +- .../sendable/builtins/Function/S15.3_A3_T4.js | 4 +- .../sendable/builtins/Function/S15.3_A3_T5.js | 8 +- .../sendable/builtins/Function/S15.3_A3_T6.js | 6 +- .../StrictFunction_reservedwords_with.js | 6 +- .../StrictFunction_restricted-properties.js | 6 +- .../Function/call-bind-this-realm-undef.js | 2 +- .../Function/call-bind-this-realm-value.js | 2 +- .../builtins/Function/instance-name.js | 14 +- .../Function/internals/Call/class-ctor.js | 2 +- .../base-ctor-revoked-proxy-realm.js | 6 +- .../Construct/base-ctor-revoked-proxy.js | 6 +- .../builtins/Function/is-a-constructor.js | 6 +- .../builtins/Function/length/15.3.3.2-1.js | 4 +- .../Function/length/S15.3.5.1_A1_T1.js | 4 +- .../Function/length/S15.3.5.1_A1_T2.js | 4 +- .../Function/length/S15.3.5.1_A1_T3.js | 4 +- .../Function/length/S15.3.5.1_A2_T1.js | 4 +- .../Function/length/S15.3.5.1_A2_T2.js | 4 +- .../Function/length/S15.3.5.1_A2_T3.js | 4 +- .../Function/length/S15.3.5.1_A3_T1.js | 4 +- .../Function/length/S15.3.5.1_A3_T2.js | 4 +- .../Function/length/S15.3.5.1_A3_T3.js | 4 +- .../Function/length/S15.3.5.1_A4_T1.js | 4 +- .../Function/length/S15.3.5.1_A4_T2.js | 4 +- .../Function/length/S15.3.5.1_A4_T3.js | 4 +- .../Function/private-identifiers-not-empty.js | 6 +- test/sendable/builtins/Function/prop-desc.js | 4 +- .../builtins/Function/property-order.js | 4 +- .../proto-from-ctor-realm-prototype.js | 14 +- .../Function/proto-from-ctor-realm.js | 14 +- .../Function/prototype/S15.3.3.1_A1.js | 14 +- .../Function/prototype/S15.3.3.1_A2.js | 10 +- .../Function/prototype/S15.3.3.1_A3.js | 12 +- .../builtins/Function/prototype/S15.3.4_A1.js | 10 +- .../Function/prototype/S15.3.4_A2_T1.js | 8 +- .../Function/prototype/S15.3.4_A2_T2.js | 8 +- .../Function/prototype/S15.3.4_A2_T3.js | 6 +- .../Function/prototype/S15.3.4_A3_T1.js | 8 +- .../Function/prototype/S15.3.4_A3_T2.js | 6 +- .../builtins/Function/prototype/S15.3.4_A4.js | 16 +- .../builtins/Function/prototype/S15.3.4_A5.js | 8 +- .../Function/prototype/S15.3.5.2_A1_T1.js | 4 +- .../Function/prototype/S15.3.5.2_A1_T2.js | 4 +- .../prototype/Symbol.hasInstance/length.js | 8 +- .../prototype/Symbol.hasInstance/name.js | 2 +- .../prototype/Symbol.hasInstance/prop-desc.js | 6 +- .../this-val-bound-target.js | 4 +- .../this-val-not-callable.js | 4 +- .../Function/prototype/apply/S15.3.4.3_A12.js | 8 +- .../prototype/apply/S15.3.4.3_A1_T1.js | 4 +- .../prototype/apply/S15.3.4.3_A1_T2.js | 4 +- .../prototype/apply/S15.3.4.3_A3_T1.js | 2 +- .../prototype/apply/S15.3.4.3_A3_T2.js | 2 +- .../prototype/apply/S15.3.4.3_A3_T3.js | 2 +- .../prototype/apply/S15.3.4.3_A3_T4.js | 2 +- .../prototype/apply/S15.3.4.3_A3_T5.js | 2 +- .../prototype/apply/S15.3.4.3_A3_T7.js | 2 +- .../prototype/apply/S15.3.4.3_A3_T9.js | 2 +- .../prototype/apply/S15.3.4.3_A5_T1.js | 2 +- .../prototype/apply/S15.3.4.3_A5_T2.js | 2 +- .../prototype/apply/S15.3.4.3_A5_T7.js | 2 +- .../prototype/apply/S15.3.4.3_A5_T8.js | 6 +- .../prototype/apply/S15.3.4.3_A7_T1.js | 2 +- .../prototype/apply/S15.3.4.3_A7_T10.js | 2 +- .../prototype/apply/S15.3.4.3_A7_T2.js | 2 +- .../prototype/apply/S15.3.4.3_A7_T3.js | 2 +- .../prototype/apply/S15.3.4.3_A7_T4.js | 2 +- .../prototype/apply/S15.3.4.3_A7_T5.js | 2 +- .../prototype/apply/S15.3.4.3_A7_T6.js | 2 +- .../prototype/apply/S15.3.4.3_A7_T7.js | 2 +- .../prototype/apply/S15.3.4.3_A7_T8.js | 2 +- .../prototype/apply/S15.3.4.3_A7_T9.js | 2 +- .../prototype/apply/S15.3.4.3_A8_T3.js | 8 +- .../prototype/apply/S15.3.4.3_A8_T4.js | 8 +- .../prototype/apply/S15.3.4.3_A8_T5.js | 8 +- .../prototype/apply/S15.3.4.3_A8_T6.js | 8 +- .../apply/argarray-not-object-realm.js | 4 +- .../prototype/apply/argarray-not-object.js | 2 +- .../prototype/apply/get-index-abrupt.js | 2 +- .../prototype/apply/get-length-abrupt.js | 2 +- .../Function/prototype/apply/length.js | 8 +- .../builtins/Function/prototype/apply/name.js | 10 +- .../prototype/apply/not-a-constructor.js | 12 +- .../prototype/apply/resizable-buffer.js | 2 +- .../apply/this-not-callable-realm.js | 4 +- .../prototype/apply/this-not-callable.js | 10 +- .../Function/prototype/bind/15.3.4.5-0-1.js | 4 +- .../Function/prototype/bind/15.3.4.5-10-1.js | 6 +- .../Function/prototype/bind/15.3.4.5-11-1.js | 6 +- .../Function/prototype/bind/15.3.4.5-16-1.js | 2 +- .../Function/prototype/bind/15.3.4.5-16-2.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-1.js | 6 +- .../Function/prototype/bind/15.3.4.5-2-10.js | 4 +- .../Function/prototype/bind/15.3.4.5-2-11.js | 4 +- .../Function/prototype/bind/15.3.4.5-2-12.js | 4 +- .../Function/prototype/bind/15.3.4.5-2-13.js | 4 +- .../Function/prototype/bind/15.3.4.5-2-14.js | 4 +- .../Function/prototype/bind/15.3.4.5-2-15.js | 4 +- .../Function/prototype/bind/15.3.4.5-2-16.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-2.js | 4 +- .../Function/prototype/bind/15.3.4.5-2-3.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-4.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-5.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-6.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-7.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-8.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-9.js | 2 +- .../Function/prototype/bind/15.3.4.5-20-2.js | 2 +- .../Function/prototype/bind/15.3.4.5-20-3.js | 2 +- .../Function/prototype/bind/15.3.4.5-21-2.js | 2 +- .../Function/prototype/bind/15.3.4.5-21-3.js | 2 +- .../Function/prototype/bind/15.3.4.5-3-1.js | 2 +- .../Function/prototype/bind/15.3.4.5-6-1.js | 2 +- .../Function/prototype/bind/15.3.4.5-6-10.js | 4 +- .../Function/prototype/bind/15.3.4.5-6-11.js | 4 +- .../Function/prototype/bind/15.3.4.5-6-12.js | 2 +- .../Function/prototype/bind/15.3.4.5-6-2.js | 4 +- .../Function/prototype/bind/15.3.4.5-6-3.js | 4 +- .../Function/prototype/bind/15.3.4.5-6-4.js | 4 +- .../Function/prototype/bind/15.3.4.5-6-5.js | 2 +- .../Function/prototype/bind/15.3.4.5-6-6.js | 4 +- .../Function/prototype/bind/15.3.4.5-6-7.js | 4 +- .../Function/prototype/bind/15.3.4.5-6-8.js | 4 +- .../Function/prototype/bind/15.3.4.5-6-9.js | 2 +- .../Function/prototype/bind/15.3.4.5-8-1.js | 2 +- .../Function/prototype/bind/15.3.4.5-8-2.js | 6 +- .../Function/prototype/bind/15.3.4.5-9-1.js | 4 +- .../Function/prototype/bind/15.3.4.5-9-2.js | 4 +- .../Function/prototype/bind/15.3.4.5.1-4-1.js | 4 +- .../prototype/bind/15.3.4.5.1-4-10.js | 2 +- .../prototype/bind/15.3.4.5.1-4-11.js | 2 +- .../prototype/bind/15.3.4.5.1-4-12.js | 2 +- .../prototype/bind/15.3.4.5.1-4-13.js | 2 +- .../prototype/bind/15.3.4.5.1-4-14.js | 2 +- .../prototype/bind/15.3.4.5.1-4-15.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-2.js | 4 +- .../Function/prototype/bind/15.3.4.5.1-4-3.js | 4 +- .../Function/prototype/bind/15.3.4.5.1-4-4.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-5.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-6.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-7.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-8.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-9.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-1.js | 4 +- .../prototype/bind/15.3.4.5.2-4-10.js | 2 +- .../prototype/bind/15.3.4.5.2-4-11.js | 2 +- .../prototype/bind/15.3.4.5.2-4-12.js | 2 +- .../prototype/bind/15.3.4.5.2-4-13.js | 2 +- .../prototype/bind/15.3.4.5.2-4-14.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-2.js | 4 +- .../Function/prototype/bind/15.3.4.5.2-4-3.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-4.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-5.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-6.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-7.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-8.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-9.js | 2 +- .../BoundFunction_restricted-properties.js | 8 +- .../Function/prototype/bind/S15.3.4.5_A13.js | 4 +- .../Function/prototype/bind/S15.3.4.5_A14.js | 4 +- .../Function/prototype/bind/S15.3.4.5_A15.js | 4 +- .../Function/prototype/bind/S15.3.4.5_A16.js | 4 +- .../Function/prototype/bind/S15.3.4.5_A3.js | 6 +- .../Function/prototype/bind/S15.3.4.5_A4.js | 4 +- .../Function/prototype/bind/S15.3.4.5_A5.js | 4 +- .../prototype/bind/get-fn-realm-recursive.js | 16 +- .../Function/prototype/bind/get-fn-realm.js | 12 +- .../bind/instance-length-default-value.js | 6 +- .../bind/instance-length-exceeds-int32.js | 4 +- .../bind/instance-length-prop-desc.js | 6 +- .../bind/instance-length-remaining-args.js | 4 +- .../bind/instance-length-tointeger.js | 4 +- .../prototype/bind/instance-name-chained.js | 2 +- .../bind/instance-name-non-string.js | 2 +- .../Function/prototype/bind/instance-name.js | 2 +- .../Function/prototype/bind/length.js | 6 +- .../builtins/Function/prototype/bind/name.js | 10 +- .../prototype/bind/not-a-constructor.js | 10 +- .../prototype/bind/proto-from-ctor-realm.js | 4 +- .../Function/prototype/call/S15.3.4.4_A10.js | 16 +- .../Function/prototype/call/S15.3.4.4_A11.js | 14 +- .../Function/prototype/call/S15.3.4.4_A12.js | 8 +- .../Function/prototype/call/S15.3.4.4_A13.js | 4 +- .../Function/prototype/call/S15.3.4.4_A14.js | 4 +- .../Function/prototype/call/S15.3.4.4_A15.js | 4 +- .../Function/prototype/call/S15.3.4.4_A16.js | 4 +- .../prototype/call/S15.3.4.4_A1_T1.js | 4 +- .../prototype/call/S15.3.4.4_A1_T2.js | 4 +- .../prototype/call/S15.3.4.4_A2_T1.js | 12 +- .../prototype/call/S15.3.4.4_A2_T2.js | 4 +- .../prototype/call/S15.3.4.4_A3_T1.js | 2 +- .../prototype/call/S15.3.4.4_A3_T2.js | 2 +- .../prototype/call/S15.3.4.4_A3_T3.js | 2 +- .../prototype/call/S15.3.4.4_A3_T4.js | 2 +- .../prototype/call/S15.3.4.4_A3_T5.js | 2 +- .../prototype/call/S15.3.4.4_A3_T7.js | 2 +- .../prototype/call/S15.3.4.4_A3_T9.js | 2 +- .../prototype/call/S15.3.4.4_A5_T1.js | 2 +- .../prototype/call/S15.3.4.4_A5_T2.js | 2 +- .../prototype/call/S15.3.4.4_A5_T7.js | 2 +- .../prototype/call/S15.3.4.4_A5_T8.js | 6 +- .../prototype/call/S15.3.4.4_A6_T1.js | 2 +- .../prototype/call/S15.3.4.4_A6_T10.js | 2 +- .../prototype/call/S15.3.4.4_A6_T2.js | 2 +- .../prototype/call/S15.3.4.4_A6_T3.js | 2 +- .../prototype/call/S15.3.4.4_A6_T4.js | 2 +- .../prototype/call/S15.3.4.4_A6_T5.js | 2 +- .../prototype/call/S15.3.4.4_A6_T6.js | 2 +- .../prototype/call/S15.3.4.4_A6_T7.js | 2 +- .../prototype/call/S15.3.4.4_A6_T8.js | 2 +- .../prototype/call/S15.3.4.4_A6_T9.js | 2 +- .../prototype/call/S15.3.4.4_A7_T3.js | 8 +- .../prototype/call/S15.3.4.4_A7_T4.js | 8 +- .../prototype/call/S15.3.4.4_A7_T5.js | 8 +- .../prototype/call/S15.3.4.4_A7_T6.js | 8 +- .../Function/prototype/call/S15.3.4.4_A9.js | 16 +- .../builtins/Function/prototype/call/name.js | 10 +- .../prototype/call/not-a-constructor.js | 14 +- .../prototype/constructor/S15.3.4.1_A1_T1.js | 12 +- .../builtins/Function/prototype/length.js | 8 +- .../builtins/Function/prototype/name.js | 8 +- .../Function/prototype/property-order.js | 4 +- .../restricted-property-arguments.js | 22 +- .../prototype/restricted-property-caller.js | 22 +- .../prototype/toString/AsyncFunction.js | 10 +- .../prototype/toString/AsyncGenerator.js | 4 +- .../Function/prototype/toString/Function.js | 6 +- .../prototype/toString/GeneratorFunction.js | 8 +- .../prototype/toString/S15.3.4.2_A10.js | 16 +- .../prototype/toString/S15.3.4.2_A11.js | 10 +- .../prototype/toString/S15.3.4.2_A12.js | 6 +- .../prototype/toString/S15.3.4.2_A13.js | 4 +- .../prototype/toString/S15.3.4.2_A14.js | 4 +- .../prototype/toString/S15.3.4.2_A16.js | 2 +- .../prototype/toString/S15.3.4.2_A6.js | 8 +- .../prototype/toString/S15.3.4.2_A8.js | 14 +- .../prototype/toString/S15.3.4.2_A9.js | 16 +- .../prototype/toString/arrow-function.js | 8 +- .../toString/async-arrow-function.js | 8 +- .../toString/async-function-declaration.js | 4 +- .../toString/async-function-expression.js | 6 +- .../toString/async-generator-declaration.js | 4 +- .../toString/async-generator-expression.js | 6 +- ...enerator-method-class-expression-static.js | 8 +- ...async-generator-method-class-expression.js | 8 +- ...generator-method-class-statement-static.js | 8 +- .../async-generator-method-class-statement.js | 8 +- .../toString/async-generator-method-object.js | 8 +- .../async-method-class-expression-static.js | 8 +- .../toString/async-method-class-expression.js | 8 +- .../async-method-class-statement-static.js | 8 +- .../toString/async-method-class-statement.js | 8 +- .../prototype/toString/async-method-object.js | 8 +- .../prototype/toString/bound-function.js | 8 +- .../toString/built-in-function-object.js | 14 +- .../class-declaration-complex-heritage.js | 4 +- .../class-declaration-explicit-ctor.js | 4 +- .../class-declaration-implicit-ctor.js | 8 +- .../class-expression-explicit-ctor.js | 4 +- .../class-expression-implicit-ctor.js | 8 +- ...n-declaration-non-simple-parameter-list.js | 4 +- .../toString/function-declaration.js | 4 +- .../prototype/toString/function-expression.js | 6 +- .../generator-function-declaration.js | 4 +- .../toString/generator-function-expression.js | 6 +- .../prototype/toString/generator-method.js | 8 +- .../getter-class-expression-static.js | 8 +- .../toString/getter-class-expression.js | 8 +- .../toString/getter-class-statement-static.js | 8 +- .../toString/getter-class-statement.js | 8 +- .../prototype/toString/getter-object.js | 8 +- .../line-terminator-normalisation-CR-LF.js | 6 +- .../line-terminator-normalisation-CR.js | 6 +- .../line-terminator-normalisation-LF.js | 6 +- .../method-class-expression-static.js | 8 +- .../toString/method-class-expression.js | 8 +- .../toString/method-class-statement-static.js | 8 +- .../toString/method-class-statement.js | 8 +- .../toString/method-computed-property-name.js | 6 +- .../prototype/toString/method-object.js | 4 +- .../Function/prototype/toString/name.js | 10 +- .../prototype/toString/not-a-constructor.js | 12 +- .../private-method-class-expression.js | 4 +- .../private-method-class-statement.js | 4 +- .../private-static-method-class-expression.js | 4 +- .../private-static-method-class-statement.js | 4 +- .../toString/proxy-arrow-function.js | 10 +- .../toString/proxy-async-function.js | 10 +- .../proxy-async-generator-function.js | 10 +- ...proxy-async-generator-method-definition.js | 8 +- .../toString/proxy-async-method-definition.js | 8 +- .../toString/proxy-bound-function.js | 10 +- .../prototype/toString/proxy-class.js | 8 +- .../toString/proxy-function-expression.js | 10 +- .../toString/proxy-generator-function.js | 10 +- .../toString/proxy-method-definition.js | 8 +- .../toString/proxy-non-callable-throws.js | 2 +- .../setter-class-expression-static.js | 8 +- .../toString/setter-class-expression.js | 8 +- .../toString/setter-class-statement-static.js | 8 +- .../toString/setter-class-statement.js | 8 +- .../prototype/toString/setter-object.js | 8 +- .../toString/symbol-named-builtins.js | 6 +- .../Function/prototype/toString/unicode.js | 6 +- .../TypedArray/Symbol.species/length.js | 45 ++ .../TypedArray/Symbol.species/name.js | 42 ++ .../TypedArray/Symbol.species/prop-desc.js | 32 ++ .../TypedArray/Symbol.species/result.js | 31 + .../TypedArray/from/arylk-get-length-error.js | 39 ++ .../TypedArray/from/arylk-to-length-error.js | 39 ++ .../from/from-array-mapper-detaches-result.js | 49 ++ ...array-mapper-makes-result-out-of-bounds.js | 49 ++ ...rray-into-itself-mapper-detaches-result.js | 49 ++ ...tself-mapper-makes-result-out-of-bounds.js | 49 ++ .../from-typedarray-mapper-detaches-result.js | 49 ++ ...array-mapper-makes-result-out-of-bounds.js | 49 ++ .../TypedArray/from/invoked-as-func.js | 34 ++ .../TypedArray/from/invoked-as-method.js | 37 ++ .../TypedArray/from/iter-access-error.js | 43 ++ .../TypedArray/from/iter-invoke-error.js | 43 ++ .../TypedArray/from/iter-next-error.js | 42 ++ .../TypedArray/from/iter-next-value-error.js | 51 ++ .../iterated-array-changed-by-tonumber.js | 49 ++ .../builtins/TypedArray/from/length.js | 44 ++ .../TypedArray/from/mapfn-is-not-callable.js | 70 +++ .../sendable/builtins/TypedArray/from/name.js | 40 ++ .../TypedArray/from/not-a-constructor.js | 41 ++ .../builtins/TypedArray/from/prop-desc.js | 32 ++ .../from/this-is-not-constructor.js | 35 ++ test/sendable/builtins/TypedArray/invoked.js | 79 +++ test/sendable/builtins/TypedArray/length.js | 41 ++ test/sendable/builtins/TypedArray/name.js | 39 ++ .../builtins/TypedArray/of/invoked-as-func.js | 35 ++ .../TypedArray/of/invoked-as-method.js | 37 ++ .../sendable/builtins/TypedArray/of/length.js | 44 ++ test/sendable/builtins/TypedArray/of/name.js | 40 ++ .../TypedArray/of/not-a-constructor.js | 41 ++ .../builtins/TypedArray/of/prop-desc.js | 32 ++ ...ith-out-of-bounds-and-in-bounds-indices.js | 69 +++ .../TypedArray/of/this-is-not-constructor.js | 35 ++ .../out-of-bounds-behaves-like-detached.js | 33 ++ .../TypedArray/out-of-bounds-get-and-set.js | 67 +++ .../builtins/TypedArray/out-of-bounds-has.js | 53 ++ .../sendable/builtins/TypedArray/prototype.js | 33 ++ .../TypedArray/prototype/Symbol.iterator.js | 36 ++ .../Symbol.iterator/not-a-constructor.js | 45 ++ .../BigInt/detached-buffer.js | 34 ++ .../BigInt/invoked-as-accessor.js | 33 ++ .../BigInt/invoked-as-func.js | 34 ++ .../Symbol.toStringTag/BigInt/length.js | 45 ++ .../Symbol.toStringTag/BigInt/name.js | 42 ++ .../Symbol.toStringTag/BigInt/prop-desc.js | 41 ++ .../BigInt/return-typedarrayname.js | 34 ++ .../this-has-no-typedarrayname-internal.js | 42 ++ .../BigInt/this-is-not-object.js | 40 ++ .../Symbol.toStringTag/detached-buffer.js | 34 ++ .../Symbol.toStringTag/invoked-as-accessor.js | 33 ++ .../Symbol.toStringTag/invoked-as-func.js | 34 ++ .../prototype/Symbol.toStringTag/length.js | 45 ++ .../prototype/Symbol.toStringTag/name.js | 42 ++ .../prototype/Symbol.toStringTag/prop-desc.js | 41 ++ .../return-typedarrayname.js | 34 ++ .../this-has-no-typedarrayname-internal.js | 42 ++ .../Symbol.toStringTag/this-is-not-object.js | 40 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../prototype/at/coerced-index-resize.js | 53 ++ .../prototype/at/index-argument-tointeger.js | 48 ++ ...-non-numeric-argument-tointeger-invalid.js | 41 ++ .../index-non-numeric-argument-tointeger.js | 48 ++ .../TypedArray/prototype/at/length.js | 39 ++ .../builtins/TypedArray/prototype/at/name.js | 43 ++ .../TypedArray/prototype/at/prop-desc.js | 37 ++ .../prototype/at/resizable-buffer.js | 76 +++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../prototype/at/return-abrupt-from-this.js | 53 ++ .../at/returns-item-relative-index.js | 50 ++ .../TypedArray/prototype/at/returns-item.js | 51 ++ ...ns-undefined-for-holes-in-sparse-arrays.js | 63 ++ ...eturns-undefined-for-out-of-range-index.js | 41 ++ .../buffer/BigInt/detached-buffer.js | 34 ++ .../prototype/buffer/BigInt/return-buffer.js | 35 ++ .../prototype/buffer/detached-buffer.js | 34 ++ .../prototype/buffer/invoked-as-accessor.js | 36 ++ .../prototype/buffer/invoked-as-func.js | 38 ++ .../TypedArray/prototype/buffer/length.js | 45 ++ .../TypedArray/prototype/buffer/name.js | 42 ++ .../TypedArray/prototype/buffer/prop-desc.js | 37 ++ .../prototype/buffer/return-buffer.js | 35 ++ .../this-has-no-typedarrayname-internal.js | 54 ++ .../buffer/this-inherits-typedarray.js | 46 ++ .../prototype/buffer/this-is-not-object.js | 61 ++ .../byteLength/BigInt/detached-buffer.js | 34 ++ .../BigInt/resizable-array-buffer-auto.js | 73 +++ .../BigInt/resizable-array-buffer-fixed.js | 59 ++ .../byteLength/BigInt/return-bytelength.js | 37 ++ .../prototype/byteLength/detached-buffer.js | 34 ++ .../byteLength/invoked-as-accessor.js | 36 ++ .../prototype/byteLength/invoked-as-func.js | 38 ++ .../TypedArray/prototype/byteLength/length.js | 45 ++ .../TypedArray/prototype/byteLength/name.js | 42 ++ .../prototype/byteLength/prop-desc.js | 37 ++ .../byteLength/resizable-array-buffer-auto.js | 73 +++ .../resizable-array-buffer-fixed.js | 59 ++ .../byteLength/resizable-buffer-assorted.js | 49 ++ .../byteLength/resized-out-of-bounds-1.js | 51 ++ .../byteLength/resized-out-of-bounds-2.js | 51 ++ .../prototype/byteLength/return-bytelength.js | 37 ++ .../this-has-no-typedarrayname-internal.js | 54 ++ .../byteLength/this-is-not-object.js | 61 ++ .../byteOffset/BigInt/detached-buffer.js | 35 ++ .../BigInt/resizable-array-buffer-auto.js | 69 +++ .../BigInt/resizable-array-buffer-fixed.js | 59 ++ .../byteOffset/BigInt/return-byteoffset.js | 44 ++ .../prototype/byteOffset/detached-buffer.js | 35 ++ .../byteOffset/invoked-as-accessor.js | 36 ++ .../prototype/byteOffset/invoked-as-func.js | 38 ++ .../TypedArray/prototype/byteOffset/length.js | 45 ++ .../TypedArray/prototype/byteOffset/name.js | 42 ++ .../prototype/byteOffset/prop-desc.js | 37 ++ .../byteOffset/resizable-array-buffer-auto.js | 69 +++ .../resizable-array-buffer-fixed.js | 59 ++ .../byteOffset/resized-out-of-bounds.js | 51 ++ .../prototype/byteOffset/return-byteoffset.js | 44 ++ .../this-has-no-typedarrayname-internal.js | 54 ++ .../byteOffset/this-is-not-object.js | 61 ++ .../TypedArray/prototype/constructor.js | 35 ++ .../copyWithin/BigInt/coerced-values-end.js | 90 +++ .../copyWithin/BigInt/coerced-values-start.js | 105 ++++ .../BigInt/coerced-values-target.js | 105 ++++ .../copyWithin/BigInt/detached-buffer.js | 47 ++ .../BigInt/get-length-ignores-length-prop.js | 62 ++ .../copyWithin/BigInt/negative-end.js | 108 ++++ .../BigInt/negative-out-of-bounds-end.js | 124 ++++ .../BigInt/negative-out-of-bounds-start.js | 106 ++++ .../BigInt/negative-out-of-bounds-target.js | 74 +++ .../copyWithin/BigInt/negative-start.js | 90 +++ .../copyWithin/BigInt/negative-target.js | 66 +++ .../BigInt/non-negative-out-of-bounds-end.js | 67 +++ ...negative-out-of-bounds-target-and-start.js | 87 +++ .../BigInt/non-negative-target-and-start.js | 63 ++ .../non-negative-target-start-and-end.js | 86 +++ .../return-abrupt-from-end-is-symbol.js | 49 ++ .../BigInt/return-abrupt-from-end.js | 52 ++ .../return-abrupt-from-start-is-symbol.js | 48 ++ .../BigInt/return-abrupt-from-start.js | 58 ++ .../return-abrupt-from-target-is-symbol.js | 48 ++ .../BigInt/return-abrupt-from-target.js | 52 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../copyWithin/BigInt/return-this.js | 49 ++ .../copyWithin/BigInt/undefined-end.js | 58 ++ .../prototype/copyWithin/bit-precision.js | 56 ++ .../prototype/copyWithin/byteoffset.js | 46 ++ .../coerced-target-start-end-shrink.js | 92 +++ .../copyWithin/coerced-target-start-grow.js | 67 +++ .../coerced-values-end-detached-prototype.js | 53 ++ .../copyWithin/coerced-values-end-detached.js | 51 ++ .../copyWithin/coerced-values-end.js | 90 +++ .../coerced-values-start-detached.js | 51 ++ .../copyWithin/coerced-values-start.js | 105 ++++ .../copyWithin/coerced-values-target.js | 113 ++++ .../prototype/copyWithin/detached-buffer.js | 47 ++ .../get-length-ignores-length-prop.js | 62 ++ .../prototype/copyWithin/invoked-as-func.js | 42 ++ .../prototype/copyWithin/invoked-as-method.js | 42 ++ .../TypedArray/prototype/copyWithin/length.js | 43 ++ .../TypedArray/prototype/copyWithin/name.js | 40 ++ .../prototype/copyWithin/negative-end.js | 108 ++++ .../copyWithin/negative-out-of-bounds-end.js | 124 ++++ .../negative-out-of-bounds-start.js | 106 ++++ .../negative-out-of-bounds-target.js | 74 +++ .../prototype/copyWithin/negative-start.js | 90 +++ .../prototype/copyWithin/negative-target.js | 66 +++ .../non-negative-out-of-bounds-end.js | 67 +++ ...negative-out-of-bounds-target-and-start.js | 87 +++ .../non-negative-target-and-start.js | 63 ++ .../non-negative-target-start-and-end.js | 86 +++ .../prototype/copyWithin/not-a-constructor.js | 45 ++ .../prototype/copyWithin/prop-desc.js | 34 ++ .../prototype/copyWithin/resizable-buffer.js | 191 +++++++ .../return-abrupt-from-end-is-symbol.js | 49 ++ .../copyWithin/return-abrupt-from-end.js | 52 ++ .../return-abrupt-from-start-is-symbol.js | 48 ++ .../copyWithin/return-abrupt-from-start.js | 58 ++ .../return-abrupt-from-target-is-symbol.js | 48 ++ .../copyWithin/return-abrupt-from-target.js | 52 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../prototype/copyWithin/return-this.js | 49 ++ .../copyWithin/this-is-not-object.js | 63 ++ .../this-is-not-typedarray-instance.js | 55 ++ .../prototype/copyWithin/undefined-end.js | 58 ++ .../entries/BigInt/detached-buffer.js | 40 ++ .../entries/BigInt/iter-prototype.js | 36 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../prototype/entries/BigInt/return-itor.js | 47 ++ .../prototype/entries/detached-buffer.js | 40 ++ .../prototype/entries/invoked-as-func.js | 45 ++ .../prototype/entries/invoked-as-method.js | 45 ++ .../prototype/entries/iter-prototype.js | 36 ++ .../TypedArray/prototype/entries/length.js | 43 ++ .../TypedArray/prototype/entries/name.js | 40 ++ .../prototype/entries/not-a-constructor.js | 45 ++ .../TypedArray/prototype/entries/prop-desc.js | 34 ++ .../resizable-buffer-grow-mid-iteration.js | 121 ++++ .../resizable-buffer-shrink-mid-iteration.js | 80 +++ .../prototype/entries/resizable-buffer.js | 188 ++++++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../prototype/entries/return-itor.js | 49 ++ .../prototype/entries/this-is-not-object.js | 65 +++ .../this-is-not-typedarray-instance.js | 57 ++ .../callbackfn-arguments-with-thisarg.js | 69 +++ .../callbackfn-arguments-without-thisarg.js | 67 +++ .../every/BigInt/callbackfn-detachbuffer.js | 54 ++ ...lbackfn-no-interaction-over-non-integer.js | 54 ++ .../BigInt/callbackfn-not-callable-throws.js | 82 +++ .../BigInt/callbackfn-not-called-on-empty.js | 49 ++ ...lbackfn-return-does-not-change-instance.js | 51 ++ .../every/BigInt/callbackfn-returns-abrupt.js | 48 ++ ...callbackfn-set-value-during-interaction.js | 71 +++ .../prototype/every/BigInt/callbackfn-this.js | 72 +++ .../prototype/every/BigInt/detached-buffer.js | 45 ++ .../get-length-uses-internal-arraylength.js | 60 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../returns-false-if-any-cb-returns-false.js | 59 ++ .../returns-true-if-every-cb-returns-true.js | 59 ++ .../every/BigInt/values-are-not-cached.js | 54 ++ .../callbackfn-arguments-with-thisarg.js | 69 +++ .../callbackfn-arguments-without-thisarg.js | 67 +++ .../every/callbackfn-detachbuffer.js | 54 ++ ...lbackfn-no-interaction-over-non-integer.js | 54 ++ .../every/callbackfn-not-callable-throws.js | 82 +++ .../every/callbackfn-not-called-on-empty.js | 49 ++ .../prototype/every/callbackfn-resize.js | 86 +++ ...lbackfn-return-does-not-change-instance.js | 51 ++ .../every/callbackfn-returns-abrupt.js | 48 ++ ...callbackfn-set-value-during-interaction.js | 71 +++ .../prototype/every/callbackfn-this.js | 72 +++ .../prototype/every/detached-buffer.js | 45 ++ .../get-length-uses-internal-arraylength.js | 60 ++ .../prototype/every/invoked-as-func.js | 42 ++ .../prototype/every/invoked-as-method.js | 42 ++ .../TypedArray/prototype/every/length.js | 43 ++ .../TypedArray/prototype/every/name.js | 40 ++ .../prototype/every/not-a-constructor.js | 45 ++ .../TypedArray/prototype/every/prop-desc.js | 34 ++ .../resizable-buffer-grow-mid-iteration.js | 95 ++++ .../resizable-buffer-shrink-mid-iteration.js | 95 ++++ .../prototype/every/resizable-buffer.js | 134 +++++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../returns-false-if-any-cb-returns-false.js | 59 ++ .../returns-true-if-every-cb-returns-true.js | 59 ++ .../prototype/every/this-is-not-object.js | 64 +++ .../every/this-is-not-typedarray-instance.js | 56 ++ .../prototype/every/values-are-not-cached.js | 54 ++ .../prototype/fill/BigInt/coerced-indexes.js | 117 ++++ .../prototype/fill/BigInt/detached-buffer.js | 47 ++ .../BigInt/fill-values-conversion-once.js | 41 ++ .../fill-values-custom-start-and-end.js | 55 ++ .../BigInt/fill-values-non-numeric-throw.js | 80 +++ .../fill/BigInt/fill-values-non-numeric.js | 96 ++++ .../fill/BigInt/fill-values-relative-end.js | 66 +++ .../fill/BigInt/fill-values-relative-start.js | 64 +++ .../fill/BigInt/fill-values-symbol-throws.js | 71 +++ .../prototype/fill/BigInt/fill-values.js | 57 ++ .../BigInt/get-length-ignores-length-prop.js | 64 +++ .../return-abrupt-from-end-as-symbol.js | 51 ++ .../fill/BigInt/return-abrupt-from-end.js | 55 ++ .../BigInt/return-abrupt-from-set-value.js | 74 +++ .../return-abrupt-from-start-as-symbol.js | 50 ++ .../fill/BigInt/return-abrupt-from-start.js | 54 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../prototype/fill/BigInt/return-this.js | 33 ++ ...nt-indices-computed-from-initial-length.js | 63 ++ .../prototype/fill/coerced-end-detach.js | 41 ++ .../prototype/fill/coerced-indexes.js | 117 ++++ .../prototype/fill/coerced-start-detach.js | 42 ++ .../prototype/fill/coerced-value-detach.js | 42 ++ .../fill/coerced-value-start-end-resize.js | 71 +++ .../prototype/fill/detached-buffer.js | 47 ++ .../fill/fill-values-conversion-once.js | 40 ++ ...es-conversion-operations-consistent-nan.js | 114 ++++ .../fill/fill-values-conversion-operations.js | 69 +++ .../fill/fill-values-custom-start-and-end.js | 55 ++ .../prototype/fill/fill-values-non-numeric.js | 100 ++++ .../fill/fill-values-relative-end.js | 66 +++ .../fill/fill-values-relative-start.js | 64 +++ .../fill/fill-values-symbol-throws.js | 71 +++ .../TypedArray/prototype/fill/fill-values.js | 57 ++ .../fill/get-length-ignores-length-prop.js | 64 +++ .../prototype/fill/invoked-as-func.js | 42 ++ .../prototype/fill/invoked-as-method.js | 42 ++ .../TypedArray/prototype/fill/length.js | 43 ++ .../TypedArray/prototype/fill/name.js | 40 ++ .../prototype/fill/not-a-constructor.js | 45 ++ .../TypedArray/prototype/fill/prop-desc.js | 34 ++ .../prototype/fill/resizable-buffer.js | 192 +++++++ .../fill/return-abrupt-from-end-as-symbol.js | 51 ++ .../prototype/fill/return-abrupt-from-end.js | 55 ++ .../fill/return-abrupt-from-set-value.js | 74 +++ .../return-abrupt-from-start-as-symbol.js | 50 ++ .../fill/return-abrupt-from-start.js | 54 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../TypedArray/prototype/fill/return-this.js | 33 ++ .../prototype/fill/this-is-not-object.js | 63 ++ .../fill/this-is-not-typedarray-instance.js | 55 ++ .../filter/BigInt/arraylength-internal.js | 52 ++ .../callbackfn-arguments-with-thisarg.js | 59 ++ .../callbackfn-arguments-without-thisarg.js | 57 ++ .../BigInt/callbackfn-called-before-ctor.js | 52 ++ .../callbackfn-called-before-species.js | 52 ++ .../filter/BigInt/callbackfn-detachbuffer.js | 49 ++ ...allbackfn-no-iteration-over-non-integer.js | 51 ++ .../BigInt/callbackfn-not-callable-throws.js | 71 +++ .../BigInt/callbackfn-not-called-on-empty.js | 40 ++ ...lbackfn-return-does-not-change-instance.js | 36 ++ .../BigInt/callbackfn-returns-abrupt.js | 40 ++ .../callbackfn-set-value-during-iteration.js | 60 ++ .../filter/BigInt/callbackfn-this.js | 61 ++ .../filter/BigInt/detached-buffer.js | 45 ++ .../BigInt/result-does-not-share-buffer.js | 40 ++ .../result-empty-callbackfn-returns-false.js | 49 ++ .../result-full-callbackfn-returns-true.js | 51 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../speciesctor-destination-resizable.js | 53 ++ .../BigInt/speciesctor-get-ctor-abrupt.js | 56 ++ .../BigInt/speciesctor-get-ctor-inherited.js | 77 +++ .../speciesctor-get-ctor-returns-throws.js | 78 +++ .../filter/BigInt/speciesctor-get-ctor.js | 67 +++ .../BigInt/speciesctor-get-species-abrupt.js | 58 ++ ...ctor-get-species-custom-ctor-invocation.js | 72 +++ ...tor-length-throws-resizable-arraybuffer.js | 55 ++ ...r-get-species-custom-ctor-length-throws.js | 54 ++ ...ciesctor-get-species-custom-ctor-length.js | 59 ++ ...es-custom-ctor-returns-another-instance.js | 67 +++ ...ciesctor-get-species-custom-ctor-throws.js | 59 ++ .../speciesctor-get-species-custom-ctor.js | 69 +++ .../speciesctor-get-species-returns-throws.js | 79 +++ ...peciesctor-get-species-use-default-ctor.js | 67 +++ .../filter/BigInt/speciesctor-get-species.js | 59 ++ .../filter/BigInt/values-are-not-cached.js | 44 ++ .../prototype/filter/BigInt/values-are-set.js | 43 ++ .../prototype/filter/arraylength-internal.js | 52 ++ .../callbackfn-arguments-with-thisarg.js | 59 ++ .../callbackfn-arguments-without-thisarg.js | 57 ++ .../filter/callbackfn-called-before-ctor.js | 52 ++ .../callbackfn-called-before-species.js | 52 ++ .../filter/callbackfn-detachbuffer.js | 46 ++ ...allbackfn-no-iteration-over-non-integer.js | 51 ++ .../filter/callbackfn-not-callable-throws.js | 71 +++ .../filter/callbackfn-not-called-on-empty.js | 40 ++ .../prototype/filter/callbackfn-resize.js | 89 +++ ...lbackfn-return-does-not-change-instance.js | 36 ++ .../filter/callbackfn-returns-abrupt.js | 40 ++ .../callbackfn-set-value-during-iteration.js | 60 ++ .../prototype/filter/callbackfn-this.js | 61 ++ .../prototype/filter/detached-buffer.js | 45 ++ .../prototype/filter/invoked-as-func.js | 43 ++ .../prototype/filter/invoked-as-method.js | 43 ++ .../TypedArray/prototype/filter/length.js | 43 ++ .../TypedArray/prototype/filter/name.js | 40 ++ .../prototype/filter/not-a-constructor.js | 45 ++ .../TypedArray/prototype/filter/prop-desc.js | 34 ++ .../resizable-buffer-grow-mid-iteration.js | 96 ++++ .../resizable-buffer-shrink-mid-iteration.js | 96 ++++ .../prototype/filter/resizable-buffer.js | 132 +++++ .../filter/result-does-not-share-buffer.js | 40 ++ .../result-empty-callbackfn-returns-false.js | 49 ++ .../result-full-callbackfn-returns-true.js | 51 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../speciesctor-destination-resizable.js | 53 ++ .../filter/speciesctor-get-ctor-abrupt.js | 56 ++ .../filter/speciesctor-get-ctor-inherited.js | 77 +++ .../speciesctor-get-ctor-returns-throws.js | 78 +++ .../prototype/filter/speciesctor-get-ctor.js | 67 +++ .../filter/speciesctor-get-species-abrupt.js | 58 ++ ...ctor-get-species-custom-ctor-invocation.js | 72 +++ ...tor-length-throws-resizable-arraybuffer.js | 55 ++ ...r-get-species-custom-ctor-length-throws.js | 54 ++ ...ciesctor-get-species-custom-ctor-length.js | 59 ++ ...es-custom-ctor-returns-another-instance.js | 67 +++ ...ciesctor-get-species-custom-ctor-throws.js | 59 ++ .../speciesctor-get-species-custom-ctor.js | 69 +++ .../speciesctor-get-species-returns-throws.js | 79 +++ ...peciesctor-get-species-use-default-ctor.js | 67 +++ .../filter/speciesctor-get-species.js | 59 ++ .../prototype/filter/this-is-not-object.js | 66 +++ .../filter/this-is-not-typedarray-instance.js | 58 ++ .../prototype/filter/values-are-not-cached.js | 44 ++ .../prototype/filter/values-are-set.js | 43 ++ .../prototype/find/BigInt/detached-buffer.js | 45 ++ .../BigInt/get-length-ignores-length-prop.js | 67 +++ .../BigInt/predicate-call-changes-value.js | 91 +++ .../find/BigInt/predicate-call-parameters.js | 75 +++ .../BigInt/predicate-call-this-non-strict.js | 72 +++ .../find/BigInt/predicate-call-this-strict.js | 66 +++ .../predicate-is-not-callable-throws.js | 79 +++ .../BigInt/predicate-may-detach-buffer.js | 70 +++ .../predicate-not-called-on-empty-array.js | 62 ++ .../return-abrupt-from-predicate-call.js | 53 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ ...rn-found-value-predicate-result-is-true.js | 78 +++ ...efined-if-predicate-returns-false-value.js | 73 +++ .../prototype/find/callbackfn-resize.js | 86 +++ .../prototype/find/detached-buffer.js | 45 ++ .../find/get-length-ignores-length-prop.js | 67 +++ .../prototype/find/invoked-as-func.js | 42 ++ .../prototype/find/invoked-as-method.js | 42 ++ .../TypedArray/prototype/find/length.js | 43 ++ .../TypedArray/prototype/find/name.js | 40 ++ .../prototype/find/not-a-constructor.js | 45 ++ .../find/predicate-call-changes-value.js | 91 +++ .../find/predicate-call-parameters.js | 75 +++ .../find/predicate-call-this-non-strict.js | 72 +++ .../find/predicate-call-this-strict.js | 66 +++ .../find/predicate-is-not-callable-throws.js | 79 +++ .../find/predicate-may-detach-buffer.js | 70 +++ .../predicate-not-called-on-empty-array.js | 62 ++ .../TypedArray/prototype/find/prop-desc.js | 34 ++ .../resizable-buffer-grow-mid-iteration.js | 96 ++++ .../resizable-buffer-shrink-mid-iteration.js | 97 ++++ .../prototype/find/resizable-buffer.js | 115 ++++ .../find/return-abrupt-from-predicate-call.js | 53 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ ...rn-found-value-predicate-result-is-true.js | 78 +++ ...efined-if-predicate-returns-false-value.js | 73 +++ .../prototype/find/this-is-not-object.js | 64 +++ .../find/this-is-not-typedarray-instance.js | 56 ++ .../findIndex/BigInt/detached-buffer.js | 45 ++ .../BigInt/get-length-ignores-length-prop.js | 65 +++ .../BigInt/predicate-call-changes-value.js | 80 +++ .../BigInt/predicate-call-parameters.js | 73 +++ .../BigInt/predicate-call-this-non-strict.js | 70 +++ .../BigInt/predicate-call-this-strict.js | 64 +++ .../predicate-is-not-callable-throws.js | 77 +++ .../BigInt/predicate-may-detach-buffer.js | 60 ++ .../predicate-not-called-on-empty-array.js | 61 ++ .../return-abrupt-from-predicate-call.js | 51 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../return-index-predicate-result-is-true.js | 78 +++ ...ve-one-if-predicate-returns-false-value.js | 71 +++ .../prototype/findIndex/callbackfn-resize.js | 86 +++ .../prototype/findIndex/detached-buffer.js | 45 ++ .../get-length-ignores-length-prop.js | 65 +++ .../prototype/findIndex/invoked-as-func.js | 42 ++ .../prototype/findIndex/invoked-as-method.js | 42 ++ .../TypedArray/prototype/findIndex/length.js | 43 ++ .../TypedArray/prototype/findIndex/name.js | 40 ++ .../prototype/findIndex/not-a-constructor.js | 45 ++ .../findIndex/predicate-call-changes-value.js | 80 +++ .../findIndex/predicate-call-parameters.js | 73 +++ .../predicate-call-this-non-strict.js | 70 +++ .../findIndex/predicate-call-this-strict.js | 64 +++ .../predicate-is-not-callable-throws.js | 77 +++ .../findIndex/predicate-may-detach-buffer.js | 58 ++ .../predicate-not-called-on-empty-array.js | 61 ++ .../prototype/findIndex/prop-desc.js | 34 ++ .../resizable-buffer-grow-mid-iteration.js | 96 ++++ .../resizable-buffer-shrink-mid-iteration.js | 96 ++++ .../prototype/findIndex/resizable-buffer.js | 114 ++++ .../return-abrupt-from-predicate-call.js | 51 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../return-index-predicate-result-is-true.js | 78 +++ ...ve-one-if-predicate-returns-false-value.js | 71 +++ .../prototype/findIndex/this-is-not-object.js | 64 +++ .../this-is-not-typedarray-instance.js | 56 ++ .../findLast/BigInt/detached-buffer.js | 43 ++ .../BigInt/get-length-ignores-length-prop.js | 56 ++ .../BigInt/predicate-call-changes-value.js | 79 +++ .../BigInt/predicate-call-parameters.js | 62 ++ .../BigInt/predicate-call-this-non-strict.js | 58 ++ .../BigInt/predicate-call-this-strict.js | 52 ++ .../predicate-is-not-callable-throws.js | 68 +++ .../BigInt/predicate-may-detach-buffer.js | 52 ++ .../predicate-not-called-on-empty-array.js | 50 ++ .../return-abrupt-from-predicate-call.js | 41 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ ...rn-found-value-predicate-result-is-true.js | 66 +++ ...efined-if-predicate-returns-false-value.js | 62 ++ .../prototype/findLast/callbackfn-resize.js | 86 +++ .../prototype/findLast/detached-buffer.js | 43 ++ .../get-length-ignores-length-prop.js | 55 ++ .../prototype/findLast/invoked-as-func.js | 40 ++ .../prototype/findLast/invoked-as-method.js | 40 ++ .../TypedArray/prototype/findLast/length.js | 44 ++ .../TypedArray/prototype/findLast/name.js | 41 ++ .../prototype/findLast/not-a-constructor.js | 45 ++ .../findLast/predicate-call-changes-value.js | 79 +++ .../findLast/predicate-call-parameters.js | 62 ++ .../predicate-call-this-non-strict.js | 58 ++ .../findLast/predicate-call-this-strict.js | 52 ++ .../predicate-is-not-callable-throws.js | 68 +++ .../findLast/predicate-may-detach-buffer.js | 52 ++ .../predicate-not-called-on-empty-array.js | 50 ++ .../prototype/findLast/prop-desc.js | 34 ++ .../resizable-buffer-grow-mid-iteration.js | 95 ++++ .../resizable-buffer-shrink-mid-iteration.js | 96 ++++ .../prototype/findLast/resizable-buffer.js | 115 ++++ .../return-abrupt-from-predicate-call.js | 41 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ ...rn-found-value-predicate-result-is-true.js | 66 +++ ...efined-if-predicate-returns-false-value.js | 62 ++ .../prototype/findLast/this-is-not-object.js | 62 ++ .../this-is-not-typedarray-instance.js | 54 ++ .../findLastIndex/BigInt/detached-buffer.js | 45 ++ .../BigInt/get-length-ignores-length-prop.js | 56 ++ .../BigInt/predicate-call-changes-value.js | 71 +++ .../BigInt/predicate-call-parameters.js | 63 ++ .../BigInt/predicate-call-this-non-strict.js | 60 ++ .../BigInt/predicate-call-this-strict.js | 54 ++ .../predicate-is-not-callable-throws.js | 68 +++ .../BigInt/predicate-may-detach-buffer.js | 50 ++ .../predicate-not-called-on-empty-array.js | 52 ++ .../return-abrupt-from-predicate-call.js | 42 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../return-index-predicate-result-is-true.js | 69 +++ ...ve-one-if-predicate-returns-false-value.js | 63 ++ .../findLastIndex/callbackfn-resize.js | 86 +++ .../findLastIndex/detached-buffer.js | 45 ++ .../get-length-ignores-length-prop.js | 56 ++ .../findLastIndex/invoked-as-func.js | 42 ++ .../findLastIndex/invoked-as-method.js | 42 ++ .../prototype/findLastIndex/length.js | 44 ++ .../prototype/findLastIndex/name.js | 41 ++ .../findLastIndex/not-a-constructor.js | 45 ++ .../predicate-call-changes-value.js | 71 +++ .../predicate-call-parameters.js | 63 ++ .../predicate-call-this-non-strict.js | 60 ++ .../predicate-call-this-strict.js | 54 ++ .../predicate-is-not-callable-throws.js | 68 +++ .../predicate-may-detach-buffer.js | 50 ++ .../predicate-not-called-on-empty-array.js | 52 ++ .../prototype/findLastIndex/prop-desc.js | 34 ++ .../resizable-buffer-grow-mid-iteration.js | 95 ++++ .../resizable-buffer-shrink-mid-iteration.js | 109 ++++ .../findLastIndex/resizable-buffer.js | 114 ++++ .../return-abrupt-from-predicate-call.js | 42 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../return-index-predicate-result-is-true.js | 69 +++ ...ve-one-if-predicate-returns-false-value.js | 63 ++ .../findLastIndex/this-is-not-object.js | 64 +++ .../this-is-not-typedarray-instance.js | 56 ++ .../forEach/BigInt/arraylength-internal.js | 60 ++ .../callbackfn-arguments-with-thisarg.js | 68 +++ .../callbackfn-arguments-without-thisarg.js | 66 +++ .../forEach/BigInt/callbackfn-detachbuffer.js | 53 ++ .../BigInt/callbackfn-is-not-callable.js | 67 +++ ...lbackfn-no-interaction-over-non-integer.js | 53 ++ .../BigInt/callbackfn-not-called-on-empty.js | 49 ++ ...lbackfn-return-does-not-change-instance.js | 43 ++ .../BigInt/callbackfn-returns-abrupt.js | 49 ++ ...callbackfn-set-value-during-interaction.js | 59 ++ .../forEach/BigInt/callbackfn-this.js | 70 +++ .../forEach/BigInt/detached-buffer.js | 45 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../forEach/BigInt/returns-undefined.js | 46 ++ .../forEach/BigInt/values-are-not-cached.js | 43 ++ .../prototype/forEach/arraylength-internal.js | 60 ++ .../callbackfn-arguments-with-thisarg.js | 68 +++ .../callbackfn-arguments-without-thisarg.js | 66 +++ .../forEach/callbackfn-detachbuffer.js | 53 ++ .../forEach/callbackfn-is-not-callable.js | 67 +++ ...lbackfn-no-interaction-over-non-integer.js | 53 ++ .../forEach/callbackfn-not-called-on-empty.js | 49 ++ .../prototype/forEach/callbackfn-resize.js | 84 +++ ...lbackfn-return-does-not-change-instance.js | 43 ++ .../forEach/callbackfn-returns-abrupt.js | 49 ++ ...callbackfn-set-value-during-interaction.js | 59 ++ .../prototype/forEach/callbackfn-this.js | 70 +++ .../prototype/forEach/detached-buffer.js | 45 ++ .../prototype/forEach/invoked-as-func.js | 42 ++ .../prototype/forEach/invoked-as-method.js | 42 ++ .../TypedArray/prototype/forEach/length.js | 43 ++ .../TypedArray/prototype/forEach/name.js | 40 ++ .../prototype/forEach/not-a-constructor.js | 45 ++ .../TypedArray/prototype/forEach/prop-desc.js | 34 ++ .../resizable-buffer-grow-mid-iteration.js | 96 ++++ .../resizable-buffer-shrink-mid-iteration.js | 96 ++++ .../prototype/forEach/resizable-buffer.js | 157 +++++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../prototype/forEach/returns-undefined.js | 46 ++ .../prototype/forEach/this-is-not-object.js | 64 +++ .../this-is-not-typedarray-instance.js | 56 ++ .../forEach/values-are-not-cached.js | 43 ++ ...during-fromIndex-returns-false-for-zero.js | 59 ++ ...ng-fromIndex-returns-true-for-undefined.js | 60 ++ .../includes/BigInt/detached-buffer.js | 41 ++ ...x-equal-or-greater-length-returns-false.js | 48 ++ .../includes/BigInt/fromIndex-infinity.js | 56 ++ .../includes/BigInt/fromIndex-minus-zero.js | 46 ++ .../get-length-uses-internal-arraylength.js | 45 ++ .../BigInt/length-zero-returns-false.js | 51 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ ...eturn-abrupt-tointeger-fromindex-symbol.js | 45 ++ .../return-abrupt-tointeger-fromindex.js | 49 ++ .../BigInt/search-found-returns-true.js | 56 ++ .../BigInt/search-not-found-returns-false.js | 54 ++ .../includes/BigInt/tointeger-fromindex.js | 77 +++ .../coerced-searchelement-fromindex-resize.js | 97 ++++ ...during-fromIndex-returns-false-for-zero.js | 60 ++ ...ng-fromIndex-returns-true-for-undefined.js | 60 ++ .../prototype/includes/detached-buffer.js | 41 ++ ...x-equal-or-greater-length-returns-false.js | 48 ++ .../prototype/includes/fromIndex-infinity.js | 56 ++ .../includes/fromIndex-minus-zero.js | 46 ++ .../get-length-uses-internal-arraylength.js | 45 ++ ...ed-against-initial-length-out-of-bounds.js | 63 ++ .../index-compared-against-initial-length.js | 59 ++ .../prototype/includes/invoked-as-func.js | 42 ++ .../prototype/includes/invoked-as-method.js | 42 ++ .../includes/length-zero-returns-false.js | 51 ++ .../TypedArray/prototype/includes/length.js | 43 ++ .../TypedArray/prototype/includes/name.js | 40 ++ .../prototype/includes/not-a-constructor.js | 45 ++ .../prototype/includes/prop-desc.js | 34 ++ .../resizable-buffer-special-float-values.js | 34 ++ .../prototype/includes/resizable-buffer.js | 149 +++++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ ...eturn-abrupt-tointeger-fromindex-symbol.js | 45 ++ .../return-abrupt-tointeger-fromindex.js | 49 ++ .../prototype/includes/samevaluezero.js | 56 ++ .../includes/search-found-returns-true.js | 56 ++ .../search-not-found-returns-false.js | 54 ++ .../includes/searchelement-not-integer.js | 42 ++ .../prototype/includes/this-is-not-object.js | 63 ++ .../this-is-not-typedarray-instance.js | 55 ++ .../prototype/includes/tointeger-fromindex.js | 77 +++ ...omIndex-returns-minus-one-for-undefined.js | 62 ++ ...ng-fromIndex-returns-minus-one-for-zero.js | 62 ++ .../indexOf/BigInt/detached-buffer.js | 41 ++ ...ual-or-greater-length-returns-minus-one.js | 43 ++ .../indexOf/BigInt/fromIndex-infinity.js | 52 ++ .../indexOf/BigInt/fromIndex-minus-zero.js | 43 ++ .../get-length-uses-internal-arraylength.js | 45 ++ .../BigInt/length-zero-returns-minus-one.js | 50 ++ .../prototype/indexOf/BigInt/no-arg.js | 42 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ ...eturn-abrupt-tointeger-fromindex-symbol.js | 45 ++ .../return-abrupt-tointeger-fromindex.js | 49 ++ .../BigInt/search-found-returns-index.js | 59 ++ .../search-not-found-returns-minus-one.js | 51 ++ .../indexOf/BigInt/tointeger-fromindex.js | 70 +++ .../coerced-searchelement-fromindex-grow.js | 60 ++ .../coerced-searchelement-fromindex-shrink.js | 72 +++ ...omIndex-returns-minus-one-for-undefined.js | 62 ++ ...ng-fromIndex-returns-minus-one-for-zero.js | 62 ++ .../prototype/indexOf/detached-buffer.js | 41 ++ ...ual-or-greater-length-returns-minus-one.js | 43 ++ .../prototype/indexOf/fromIndex-infinity.js | 52 ++ .../prototype/indexOf/fromIndex-minus-zero.js | 43 ++ .../get-length-uses-internal-arraylength.js | 45 ++ .../prototype/indexOf/invoked-as-func.js | 42 ++ .../prototype/indexOf/invoked-as-method.js | 42 ++ .../indexOf/length-zero-returns-minus-one.js | 50 ++ .../TypedArray/prototype/indexOf/length.js | 43 ++ .../TypedArray/prototype/indexOf/name.js | 40 ++ .../TypedArray/prototype/indexOf/no-arg.js | 42 ++ .../prototype/indexOf/not-a-constructor.js | 45 ++ .../TypedArray/prototype/indexOf/prop-desc.js | 34 ++ .../resizable-buffer-special-float-values.js | 38 ++ .../prototype/indexOf/resizable-buffer.js | 149 +++++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ ...eturn-abrupt-tointeger-fromindex-symbol.js | 45 ++ .../return-abrupt-tointeger-fromindex.js | 49 ++ .../indexOf/search-found-returns-index.js | 59 ++ .../search-not-found-returns-minus-one.js | 51 ++ .../prototype/indexOf/strict-comparison.js | 54 ++ .../prototype/indexOf/this-is-not-object.js | 63 ++ .../this-is-not-typedarray-instance.js | 55 ++ .../prototype/indexOf/tointeger-fromindex.js | 70 +++ ...sult-from-tostring-on-each-simple-value.js | 91 +++ ...r-during-fromIndex-returns-single-comma.js | 55 ++ .../prototype/join/BigInt/detached-buffer.js | 46 ++ .../BigInt/empty-instance-empty-string.js | 42 ++ .../get-length-uses-internal-arraylength.js | 58 ++ ...sult-from-tostring-on-each-simple-value.js | 50 ++ .../return-abrupt-from-separator-symbol.js | 45 ++ .../BigInt/return-abrupt-from-separator.js | 49 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../prototype/join/coerced-separator-grow.js | 50 ++ .../join/coerced-separator-shrink.js | 54 ++ ...sult-from-tostring-on-each-simple-value.js | 91 +++ ...ator-result-from-tostring-on-each-value.js | 148 +++++ ...r-during-fromIndex-returns-single-comma.js | 55 ++ .../prototype/join/detached-buffer.js | 46 ++ .../join/empty-instance-empty-string.js | 42 ++ .../get-length-uses-internal-arraylength.js | 58 ++ .../prototype/join/invoked-as-func.js | 42 ++ .../prototype/join/invoked-as-method.js | 42 ++ .../TypedArray/prototype/join/length.js | 43 ++ .../TypedArray/prototype/join/name.js | 40 ++ .../prototype/join/not-a-constructor.js | 45 ++ .../TypedArray/prototype/join/prop-desc.js | 34 ++ .../prototype/join/resizable-buffer.js | 110 ++++ ...sult-from-tostring-on-each-simple-value.js | 50 ++ .../result-from-tostring-on-each-value.js | 57 ++ .../return-abrupt-from-separator-symbol.js | 45 ++ .../join/return-abrupt-from-separator.js | 49 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../separator-tostring-once-after-resized.js | 51 ++ .../prototype/join/this-is-not-object.js | 63 ++ .../join/this-is-not-typedarray-instance.js | 55 ++ .../prototype/keys/BigInt/detached-buffer.js | 40 ++ .../prototype/keys/BigInt/iter-prototype.js | 36 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../prototype/keys/BigInt/return-itor.js | 49 ++ .../prototype/keys/detached-buffer.js | 40 ++ .../prototype/keys/invoked-as-func.js | 43 ++ .../prototype/keys/invoked-as-method.js | 43 ++ .../prototype/keys/iter-prototype.js | 36 ++ .../TypedArray/prototype/keys/length.js | 43 ++ .../TypedArray/prototype/keys/name.js | 40 ++ .../prototype/keys/not-a-constructor.js | 45 ++ .../TypedArray/prototype/keys/prop-desc.js | 34 ++ .../resizable-buffer-grow-mid-iteration.js | 72 +++ .../resizable-buffer-shrink-mid-iteration.js | 65 +++ .../prototype/keys/resizable-buffer.js | 153 +++++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../TypedArray/prototype/keys/return-itor.js | 49 ++ .../prototype/keys/this-is-not-object.js | 65 +++ .../keys/this-is-not-typedarray-instance.js | 57 ++ ...omIndex-returns-minus-one-for-undefined.js | 59 ++ ...ng-fromIndex-returns-minus-one-for-zero.js | 59 ++ .../lastIndexOf/BigInt/detached-buffer.js | 41 ++ .../lastIndexOf/BigInt/fromIndex-infinity.js | 45 ++ .../BigInt/fromIndex-minus-zero.js | 43 ++ .../get-length-uses-internal-arraylength.js | 45 ++ .../BigInt/length-zero-returns-minus-one.js | 50 ++ .../prototype/lastIndexOf/BigInt/no-arg.js | 42 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ ...eturn-abrupt-tointeger-fromindex-symbol.js | 45 ++ .../return-abrupt-tointeger-fromindex.js | 49 ++ .../BigInt/search-found-returns-index.js | 70 +++ .../search-not-found-returns-minus-one.js | 55 ++ .../lastIndexOf/BigInt/tointeger-fromindex.js | 70 +++ .../lastIndexOf/coerced-position-grow.js | 62 ++ .../lastIndexOf/coerced-position-shrink.js | 72 +++ ...omIndex-returns-minus-one-for-undefined.js | 59 ++ ...ng-fromIndex-returns-minus-one-for-zero.js | 59 ++ .../prototype/lastIndexOf/detached-buffer.js | 41 ++ .../lastIndexOf/fromIndex-infinity.js | 45 ++ .../lastIndexOf/fromIndex-minus-zero.js | 43 ++ .../get-length-uses-internal-arraylength.js | 45 ++ .../prototype/lastIndexOf/invoked-as-func.js | 42 ++ .../lastIndexOf/invoked-as-method.js | 42 ++ .../length-zero-returns-minus-one.js | 50 ++ .../prototype/lastIndexOf/length.js | 43 ++ .../TypedArray/prototype/lastIndexOf/name.js | 40 ++ .../prototype/lastIndexOf/no-arg.js | 42 ++ .../lastIndexOf/not-a-constructor.js | 45 ++ .../prototype/lastIndexOf/prop-desc.js | 34 ++ .../resizable-buffer-special-float-values.js | 38 ++ .../prototype/lastIndexOf/resizable-buffer.js | 153 +++++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ ...eturn-abrupt-tointeger-fromindex-symbol.js | 45 ++ .../return-abrupt-tointeger-fromindex.js | 49 ++ .../lastIndexOf/search-found-returns-index.js | 70 +++ .../search-not-found-returns-minus-one.js | 55 ++ .../lastIndexOf/strict-comparison.js | 54 ++ .../lastIndexOf/this-is-not-object.js | 63 ++ .../this-is-not-typedarray-instance.js | 55 ++ .../lastIndexOf/tointeger-fromindex.js | 70 +++ .../length/BigInt/detached-buffer.js | 34 ++ .../BigInt/resizable-array-buffer-auto.js | 73 +++ .../BigInt/resizable-array-buffer-fixed.js | 59 ++ .../prototype/length/BigInt/return-length.js | 41 ++ .../prototype/length/detached-buffer.js | 34 ++ .../prototype/length/invoked-as-accessor.js | 36 ++ .../prototype/length/invoked-as-func.js | 36 ++ .../TypedArray/prototype/length/length.js | 45 ++ .../TypedArray/prototype/length/name.js | 42 ++ .../TypedArray/prototype/length/prop-desc.js | 37 ++ .../length/resizable-array-buffer-auto.js | 73 +++ .../length/resizable-array-buffer-fixed.js | 59 ++ .../length/resizable-buffer-assorted.js | 49 ++ .../length/resized-out-of-bounds-1.js | 51 ++ .../length/resized-out-of-bounds-2.js | 53 ++ .../prototype/length/return-length.js | 41 ++ .../this-has-no-typedarrayname-internal.js | 54 ++ .../prototype/length/this-is-not-object.js | 62 ++ .../map/BigInt/arraylength-internal.js | 58 ++ .../callbackfn-arguments-with-thisarg.js | 61 ++ .../callbackfn-arguments-without-thisarg.js | 59 ++ .../map/BigInt/callbackfn-detachbuffer.js | 46 ++ .../map/BigInt/callbackfn-is-not-callable.js | 60 ++ ...interaction-over-non-integer-properties.js | 53 ++ .../BigInt/callbackfn-not-called-on-empty.js | 41 ++ ...llbackfn-return-affects-returned-object.js | 44 ++ ...lbackfn-return-does-not-change-instance.js | 38 ++ ...rn-does-not-copy-non-integer-properties.js | 55 ++ .../map/BigInt/callbackfn-returns-abrupt.js | 35 ++ ...callbackfn-set-value-during-interaction.js | 55 ++ .../prototype/map/BigInt/callbackfn-this.js | 63 ++ .../prototype/map/BigInt/detached-buffer.js | 45 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ ...return-new-typedarray-from-empty-length.js | 51 ++ ...urn-new-typedarray-from-positive-length.js | 47 ++ .../speciesctor-destination-resizable.js | 53 ++ .../map/BigInt/speciesctor-get-ctor-abrupt.js | 58 ++ .../BigInt/speciesctor-get-ctor-inherited.js | 77 +++ .../speciesctor-get-ctor-returns-throws.js | 78 +++ .../map/BigInt/speciesctor-get-ctor.js | 67 +++ .../BigInt/speciesctor-get-species-abrupt.js | 58 ++ ...ctor-get-species-custom-ctor-invocation.js | 72 +++ ...tor-length-throws-resizable-arraybuffer.js | 56 ++ ...r-get-species-custom-ctor-length-throws.js | 54 ++ ...ciesctor-get-species-custom-ctor-length.js | 59 ++ ...es-custom-ctor-returns-another-instance.js | 67 +++ ...ciesctor-get-species-custom-ctor-throws.js | 59 ++ .../speciesctor-get-species-custom-ctor.js | 69 +++ .../speciesctor-get-species-returns-throws.js | 79 +++ ...peciesctor-get-species-use-default-ctor.js | 67 +++ .../map/BigInt/speciesctor-get-species.js | 59 ++ .../map/BigInt/values-are-not-cached.js | 40 ++ .../prototype/map/arraylength-internal.js | 58 ++ .../map/callbackfn-arguments-with-thisarg.js | 61 ++ .../callbackfn-arguments-without-thisarg.js | 59 ++ .../prototype/map/callbackfn-detachbuffer.js | 46 ++ .../map/callbackfn-is-not-callable.js | 60 ++ ...interaction-over-non-integer-properties.js | 53 ++ .../map/callbackfn-not-called-on-empty.js | 41 ++ .../prototype/map/callbackfn-resize.js | 89 +++ ...llbackfn-return-affects-returned-object.js | 44 ++ ...lbackfn-return-does-not-change-instance.js | 38 ++ ...rn-does-not-copy-non-integer-properties.js | 55 ++ .../map/callbackfn-returns-abrupt.js | 35 ++ ...callbackfn-set-value-during-interaction.js | 55 ++ .../prototype/map/callbackfn-this.js | 63 ++ .../prototype/map/detached-buffer.js | 45 ++ .../prototype/map/invoked-as-func.js | 43 ++ .../prototype/map/invoked-as-method.js | 43 ++ .../TypedArray/prototype/map/length.js | 43 ++ .../builtins/TypedArray/prototype/map/name.js | 40 ++ .../prototype/map/not-a-constructor.js | 45 ++ .../TypedArray/prototype/map/prop-desc.js | 34 ++ .../resizable-buffer-grow-mid-iteration.js | 95 ++++ .../resizable-buffer-shrink-mid-iteration.js | 101 ++++ .../prototype/map/resizable-buffer.js | 170 ++++++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ ...ray-conversion-operation-consistent-nan.js | 84 +++ ...urn-new-typedarray-conversion-operation.js | 73 +++ ...return-new-typedarray-from-empty-length.js | 51 ++ ...urn-new-typedarray-from-positive-length.js | 47 ++ .../map/speciesctor-destination-resizable.js | 53 ++ .../map/speciesctor-get-ctor-abrupt.js | 58 ++ .../map/speciesctor-get-ctor-inherited.js | 77 +++ .../speciesctor-get-ctor-returns-throws.js | 78 +++ .../prototype/map/speciesctor-get-ctor.js | 67 +++ .../map/speciesctor-get-species-abrupt.js | 58 ++ ...ctor-get-species-custom-ctor-invocation.js | 72 +++ ...tor-length-throws-resizable-arraybuffer.js | 56 ++ ...r-get-species-custom-ctor-length-throws.js | 54 ++ ...ciesctor-get-species-custom-ctor-length.js | 59 ++ ...es-custom-ctor-returns-another-instance.js | 67 +++ ...ciesctor-get-species-custom-ctor-throws.js | 59 ++ .../speciesctor-get-species-custom-ctor.js | 69 +++ .../speciesctor-get-species-returns-throws.js | 79 +++ ...peciesctor-get-species-use-default-ctor.js | 67 +++ .../prototype/map/speciesctor-get-species.js | 59 ++ .../map/speciesctor-resizable-buffer-grow.js | 97 ++++ .../speciesctor-resizable-buffer-shrink.js | 94 +++ .../prototype/map/this-is-not-object.js | 64 +++ .../map/this-is-not-typedarray-instance.js | 56 ++ .../prototype/map/values-are-not-cached.js | 40 ++ ...callbackfn-arguments-custom-accumulator.js | 71 +++ ...allbackfn-arguments-default-accumulator.js | 72 +++ .../reduce/BigInt/callbackfn-detachbuffer.js | 55 ++ .../callbackfn-is-not-callable-throws.js | 80 +++ ...o-iteration-over-non-integer-properties.js | 61 ++ .../BigInt/callbackfn-not-called-on-empty.js | 52 ++ ...lbackfn-return-does-not-change-instance.js | 34 ++ .../BigInt/callbackfn-returns-abrupt.js | 56 ++ .../callbackfn-set-value-during-iteration.js | 61 ++ .../reduce/BigInt/callbackfn-this.js | 57 ++ .../reduce/BigInt/detached-buffer.js | 45 ++ .../empty-instance-return-initialvalue.js | 54 ++ ...ty-instance-with-no-initialvalue-throws.js | 47 ++ .../get-length-uses-internal-arraylength.js | 59 ++ .../result-is-last-callbackfn-return.js | 72 +++ .../reduce/BigInt/result-of-any-type.js | 80 +++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../return-first-value-without-callbackfn.js | 55 ++ .../reduce/BigInt/values-are-not-cached.js | 54 ++ ...callbackfn-arguments-custom-accumulator.js | 71 +++ ...allbackfn-arguments-default-accumulator.js | 72 +++ .../reduce/callbackfn-detachbuffer.js | 55 ++ .../callbackfn-is-not-callable-throws.js | 80 +++ ...o-iteration-over-non-integer-properties.js | 61 ++ .../reduce/callbackfn-not-called-on-empty.js | 52 ++ .../prototype/reduce/callbackfn-resize.js | 88 +++ ...lbackfn-return-does-not-change-instance.js | 34 ++ .../reduce/callbackfn-returns-abrupt.js | 56 ++ .../callbackfn-set-value-during-iteration.js | 61 ++ .../prototype/reduce/callbackfn-this.js | 57 ++ .../prototype/reduce/detached-buffer.js | 45 ++ .../empty-instance-return-initialvalue.js | 54 ++ ...ty-instance-with-no-initialvalue-throws.js | 47 ++ .../get-length-uses-internal-arraylength.js | 59 ++ .../prototype/reduce/invoked-as-func.js | 43 ++ .../prototype/reduce/invoked-as-method.js | 43 ++ .../TypedArray/prototype/reduce/length.js | 43 ++ .../TypedArray/prototype/reduce/name.js | 40 ++ .../prototype/reduce/not-a-constructor.js | 45 ++ .../TypedArray/prototype/reduce/prop-desc.js | 34 ++ .../resizable-buffer-grow-mid-iteration.js | 96 ++++ .../resizable-buffer-shrink-mid-iteration.js | 95 ++++ .../prototype/reduce/resizable-buffer.js | 157 +++++ .../result-is-last-callbackfn-return.js | 72 +++ .../prototype/reduce/result-of-any-type.js | 80 +++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../return-first-value-without-callbackfn.js | 55 ++ .../prototype/reduce/this-is-not-object.js | 64 +++ .../reduce/this-is-not-typedarray-instance.js | 56 ++ .../prototype/reduce/values-are-not-cached.js | 54 ++ ...callbackfn-arguments-custom-accumulator.js | 72 +++ ...allbackfn-arguments-default-accumulator.js | 75 +++ .../BigInt/callbackfn-detachbuffer.js | 55 ++ .../callbackfn-is-not-callable-throws.js | 80 +++ ...o-iteration-over-non-integer-properties.js | 62 ++ .../BigInt/callbackfn-not-called-on-empty.js | 53 ++ ...lbackfn-return-does-not-change-instance.js | 34 ++ .../BigInt/callbackfn-returns-abrupt.js | 56 ++ .../callbackfn-set-value-during-iteration.js | 61 ++ .../reduceRight/BigInt/callbackfn-this.js | 58 ++ .../reduceRight/BigInt/detached-buffer.js | 45 ++ .../empty-instance-return-initialvalue.js | 55 ++ ...ty-instance-with-no-initialvalue-throws.js | 47 ++ .../get-length-uses-internal-arraylength.js | 59 ++ .../result-is-last-callbackfn-return.js | 74 +++ .../reduceRight/BigInt/result-of-any-type.js | 82 +++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../return-first-value-without-callbackfn.js | 56 ++ .../BigInt/values-are-not-cached.js | 55 ++ ...callbackfn-arguments-custom-accumulator.js | 72 +++ ...allbackfn-arguments-default-accumulator.js | 75 +++ .../reduceRight/callbackfn-detachbuffer.js | 55 ++ .../callbackfn-is-not-callable-throws.js | 80 +++ ...o-iteration-over-non-integer-properties.js | 62 ++ .../callbackfn-not-called-on-empty.js | 53 ++ .../reduceRight/callbackfn-resize.js | 88 +++ ...lbackfn-return-does-not-change-instance.js | 34 ++ .../reduceRight/callbackfn-returns-abrupt.js | 56 ++ .../callbackfn-set-value-during-iteration.js | 61 ++ .../prototype/reduceRight/callbackfn-this.js | 58 ++ .../prototype/reduceRight/detached-buffer.js | 45 ++ .../empty-instance-return-initialvalue.js | 55 ++ ...ty-instance-with-no-initialvalue-throws.js | 47 ++ .../get-length-uses-internal-arraylength.js | 59 ++ .../prototype/reduceRight/invoked-as-func.js | 43 ++ .../reduceRight/invoked-as-method.js | 43 ++ .../prototype/reduceRight/length.js | 43 ++ .../TypedArray/prototype/reduceRight/name.js | 40 ++ .../reduceRight/not-a-constructor.js | 45 ++ .../prototype/reduceRight/prop-desc.js | 34 ++ .../resizable-buffer-grow-mid-iteration.js | 97 ++++ .../resizable-buffer-shrink-mid-iteration.js | 113 ++++ .../prototype/reduceRight/resizable-buffer.js | 158 ++++++ .../result-is-last-callbackfn-return.js | 74 +++ .../reduceRight/result-of-any-type.js | 82 +++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../return-first-value-without-callbackfn.js | 56 ++ .../reduceRight/this-is-not-object.js | 64 +++ .../this-is-not-typedarray-instance.js | 56 ++ .../reduceRight/values-are-not-cached.js | 55 ++ ...resizable-and-fixed-have-same-prototype.js | 31 + .../reverse/BigInt/detached-buffer.js | 41 ++ .../get-length-uses-internal-arraylength.js | 55 ++ .../preserves-non-numeric-properties.js | 48 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../reverse/BigInt/returns-original-object.js | 52 ++ .../prototype/reverse/BigInt/reverts.js | 70 +++ .../prototype/reverse/detached-buffer.js | 41 ++ .../get-length-uses-internal-arraylength.js | 55 ++ .../prototype/reverse/invoked-as-func.js | 43 ++ .../prototype/reverse/invoked-as-method.js | 43 ++ .../TypedArray/prototype/reverse/length.js | 43 ++ .../TypedArray/prototype/reverse/name.js | 40 ++ .../prototype/reverse/not-a-constructor.js | 45 ++ .../preserves-non-numeric-properties.js | 48 ++ .../TypedArray/prototype/reverse/prop-desc.js | 34 ++ .../prototype/reverse/resizable-buffer.js | 177 ++++++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../reverse/returns-original-object.js | 52 ++ .../TypedArray/prototype/reverse/reverts.js | 70 +++ .../prototype/reverse/this-is-not-object.js | 63 ++ .../this-is-not-typedarray-instance.js | 55 ++ ...rray-arg-negative-integer-offset-throws.js | 48 ++ .../set/BigInt/array-arg-offset-tointeger.js | 108 ++++ .../BigInt/array-arg-primitive-toobject.js | 62 ++ ...y-arg-return-abrupt-from-src-get-length.js | 46 ++ ...ay-arg-return-abrupt-from-src-get-value.js | 61 ++ ...rg-return-abrupt-from-src-length-symbol.js | 43 ++ ...array-arg-return-abrupt-from-src-length.js | 59 ++ ...n-abrupt-from-src-tonumber-value-symbol.js | 57 ++ ...g-return-abrupt-from-src-tonumber-value.js | 61 ++ ...urn-abrupt-from-tointeger-offset-symbol.js | 40 ++ ...arg-return-abrupt-from-tointeger-offset.js | 54 ++ ...-arg-return-abrupt-from-toobject-offset.js | 43 ++ .../BigInt/array-arg-set-values-in-order.js | 85 +++ .../set/BigInt/array-arg-set-values.js | 76 +++ ...arg-src-tonumber-value-type-conversions.js | 62 ++ .../array-arg-src-values-are-not-cached.js | 60 ++ .../array-arg-target-arraylength-internal.js | 54 ++ ...fer-detached-on-tointeger-offset-throws.js | 52 ++ .../array-arg-targetbuffer-detached-throws.js | 56 ++ .../prototype/set/BigInt/bigint-tobigint64.js | 101 ++++ .../set/BigInt/bigint-tobiguint64.js | 100 ++++ .../prototype/set/BigInt/boolean-tobigint.js | 59 ++ .../prototype/set/BigInt/null-tobigint.js | 60 ++ .../prototype/set/BigInt/number-tobigint.js | 85 +++ .../set/BigInt/src-typedarray-big.js | 51 ++ .../BigInt/src-typedarray-not-big-throws.js | 50 ++ .../set/BigInt/string-nan-tobigint.js | 63 ++ .../prototype/set/BigInt/string-tobigint.js | 79 +++ .../prototype/set/BigInt/symbol-tobigint.js | 63 ++ ...rray-arg-negative-integer-offset-throws.js | 46 ++ .../BigInt/typedarray-arg-offset-tointeger.js | 106 ++++ ...urn-abrupt-from-tointeger-offset-symbol.js | 39 ++ ...arg-return-abrupt-from-tointeger-offset.js | 53 ++ ...g-set-values-diff-buffer-other-type-sab.js | 115 ++++ ...y-arg-set-values-diff-buffer-other-type.js | 61 ++ ...rg-set-values-diff-buffer-same-type-sab.js | 116 ++++ ...ay-arg-set-values-diff-buffer-same-type.js | 63 ++ ...et-values-same-buffer-same-type-resized.js | 58 ++ ...rg-set-values-same-buffer-same-type-sab.js | 60 ++ ...ay-arg-set-values-same-buffer-same-type.js | 66 +++ ...typedarray-arg-src-arraylength-internal.js | 54 ++ .../typedarray-arg-src-byteoffset-internal.js | 58 ++ ...-greather-than-target-throws-rangeerror.js | 64 +++ ...detached-during-tointeger-offset-throws.js | 52 ++ ...edarray-arg-target-arraylength-internal.js | 55 ++ ...pedarray-arg-target-byteoffset-internal.js | 57 ++ .../typedarray-arg-target-out-of-bounds.js | 56 ++ ...detached-during-tointeger-offset-throws.js | 52 ++ .../set/BigInt/undefined-tobigint.js | 60 ++ ...rray-arg-negative-integer-offset-throws.js | 48 ++ .../set/array-arg-offset-tointeger.js | 108 ++++ .../set/array-arg-primitive-toobject.js | 59 ++ ...y-arg-return-abrupt-from-src-get-length.js | 46 ++ ...ay-arg-return-abrupt-from-src-get-value.js | 61 ++ ...rg-return-abrupt-from-src-length-symbol.js | 43 ++ ...array-arg-return-abrupt-from-src-length.js | 59 ++ ...n-abrupt-from-src-tonumber-value-symbol.js | 57 ++ ...g-return-abrupt-from-src-tonumber-value.js | 61 ++ ...urn-abrupt-from-tointeger-offset-symbol.js | 40 ++ ...arg-return-abrupt-from-tointeger-offset.js | 54 ++ ...-arg-return-abrupt-from-toobject-offset.js | 43 ++ .../set/array-arg-set-values-in-order.js | 85 +++ .../prototype/set/array-arg-set-values.js | 76 +++ ...rray-arg-src-tonumber-value-conversions.js | 44 ++ ...arg-src-tonumber-value-type-conversions.js | 62 ++ .../array-arg-src-values-are-not-cached.js | 60 ++ .../array-arg-target-arraylength-internal.js | 54 ++ ...ffer-detached-on-get-src-value-no-throw.js | 49 ++ ...fer-detached-on-tointeger-offset-throws.js | 52 ++ .../array-arg-targetbuffer-detached-throws.js | 56 ++ ...g-value-conversion-resizes-array-buffer.js | 78 +++ .../TypedArray/prototype/set/bit-precision.js | 48 ++ .../prototype/set/invoked-as-func.js | 34 ++ .../prototype/set/invoked-as-method.js | 34 ++ .../TypedArray/prototype/set/length.js | 43 ++ .../builtins/TypedArray/prototype/set/name.js | 40 ++ .../prototype/set/not-a-constructor.js | 45 ++ .../TypedArray/prototype/set/prop-desc.js | 34 ++ .../set/src-typedarray-big-throws.js | 50 ++ .../set/target-grow-mid-iteration.js | 125 ++++ .../set/target-grow-source-length-getter.js | 76 +++ .../set/target-shrink-mid-iteration.js | 111 ++++ .../set/target-shrink-source-length-getter.js | 159 ++++++ .../set/this-backed-by-resizable-buffer.js | 537 ++++++++++++++++++ .../prototype/set/this-is-not-object.js | 88 +++ .../set/this-is-not-typedarray-instance.js | 69 +++ ...rray-arg-negative-integer-offset-throws.js | 46 ++ .../set/typedarray-arg-offset-tointeger.js | 106 ++++ ...urn-abrupt-from-tointeger-offset-symbol.js | 39 ++ ...arg-return-abrupt-from-tointeger-offset.js | 53 ++ ...-diff-buffer-other-type-conversions-sab.js | 62 ++ ...lues-diff-buffer-other-type-conversions.js | 51 ++ ...g-set-values-diff-buffer-other-type-sab.js | 118 ++++ ...y-arg-set-values-diff-buffer-other-type.js | 61 ++ ...rg-set-values-diff-buffer-same-type-sab.js | 119 ++++ ...ay-arg-set-values-diff-buffer-same-type.js | 63 ++ ...y-arg-set-values-same-buffer-other-type.js | 73 +++ ...et-values-same-buffer-same-type-resized.js | 58 ++ ...rg-set-values-same-buffer-same-type-sab.js | 62 ++ ...ay-arg-set-values-same-buffer-same-type.js | 66 +++ ...typedarray-arg-src-arraylength-internal.js | 54 ++ ...rray-arg-src-backed-by-resizable-buffer.js | 241 ++++++++ .../typedarray-arg-src-byteoffset-internal.js | 58 ++ ...-greather-than-target-throws-rangeerror.js | 64 +++ ...detached-during-tointeger-offset-throws.js | 52 ++ ...edarray-arg-target-arraylength-internal.js | 55 ++ ...pedarray-arg-target-byteoffset-internal.js | 57 ++ .../typedarray-arg-target-out-of-bounds.js | 56 ++ ...detached-during-tointeger-offset-throws.js | 52 ++ .../slice/BigInt/arraylength-internal.js | 51 ++ ...hed-buffer-custom-ctor-other-targettype.js | 65 +++ ...ched-buffer-custom-ctor-same-targettype.js | 64 +++ .../slice/BigInt/detached-buffer-get-ctor.js | 63 ++ ...ciesctor-get-species-custom-ctor-throws.js | 64 +++ ...zero-count-custom-ctor-other-targettype.js | 58 ++ ...-zero-count-custom-ctor-same-targettype.js | 62 ++ .../prototype/slice/BigInt/detached-buffer.js | 46 ++ .../prototype/slice/BigInt/infinity.js | 42 ++ .../prototype/slice/BigInt/minus-zero.js | 44 ++ ...esult-does-not-copy-ordinary-properties.js | 35 ++ .../BigInt/results-with-different-length.js | 66 +++ .../slice/BigInt/results-with-empty-length.js | 65 +++ .../slice/BigInt/results-with-same-length.js | 45 ++ .../BigInt/return-abrupt-from-end-symbol.js | 38 ++ .../slice/BigInt/return-abrupt-from-end.js | 52 ++ .../BigInt/return-abrupt-from-start-symbol.js | 37 ++ .../slice/BigInt/return-abrupt-from-start.js | 51 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../set-values-from-different-ctor-type.js | 60 ++ .../speciesctor-destination-resizable.js | 53 ++ .../BigInt/speciesctor-get-ctor-abrupt.js | 54 ++ .../BigInt/speciesctor-get-ctor-inherited.js | 75 +++ .../speciesctor-get-ctor-returns-throws.js | 76 +++ .../slice/BigInt/speciesctor-get-ctor.js | 67 +++ .../BigInt/speciesctor-get-species-abrupt.js | 58 ++ ...ctor-get-species-custom-ctor-invocation.js | 72 +++ ...tor-length-throws-resizable-arraybuffer.js | 56 ++ ...r-get-species-custom-ctor-length-throws.js | 54 ++ ...ciesctor-get-species-custom-ctor-length.js | 59 ++ ...es-custom-ctor-returns-another-instance.js | 66 +++ ...ciesctor-get-species-custom-ctor-throws.js | 60 ++ .../speciesctor-get-species-custom-ctor.js | 67 +++ .../speciesctor-get-species-returns-throws.js | 79 +++ ...peciesctor-get-species-use-default-ctor.js | 67 +++ .../slice/BigInt/speciesctor-get-species.js | 59 ++ .../prototype/slice/BigInt/tointeger-end.js | 61 ++ .../prototype/slice/BigInt/tointeger-start.js | 61 ++ .../prototype/slice/arraylength-internal.js | 51 ++ .../prototype/slice/bit-precision.js | 52 ++ .../prototype/slice/coerced-start-end-grow.js | 67 +++ .../slice/coerced-start-end-shrink.js | 98 ++++ ...hed-buffer-custom-ctor-other-targettype.js | 51 ++ ...ched-buffer-custom-ctor-same-targettype.js | 48 ++ .../slice/detached-buffer-get-ctor.js | 47 ++ ...ciesctor-get-species-custom-ctor-throws.js | 64 +++ ...zero-count-custom-ctor-other-targettype.js | 58 ++ ...-zero-count-custom-ctor-same-targettype.js | 55 ++ .../prototype/slice/detached-buffer.js | 46 ++ .../TypedArray/prototype/slice/infinity.js | 42 ++ .../prototype/slice/invoked-as-func.js | 43 ++ .../prototype/slice/invoked-as-method.js | 43 ++ .../TypedArray/prototype/slice/length.js | 43 ++ .../TypedArray/prototype/slice/minus-zero.js | 44 ++ .../TypedArray/prototype/slice/name.js | 40 ++ .../prototype/slice/not-a-constructor.js | 45 ++ .../TypedArray/prototype/slice/prop-desc.js | 34 ++ .../prototype/slice/resizable-buffer.js | 156 +++++ ...esult-does-not-copy-ordinary-properties.js | 35 ++ .../slice/results-with-different-length.js | 66 +++ .../slice/results-with-empty-length.js | 65 +++ .../slice/results-with-same-length.js | 45 ++ .../slice/return-abrupt-from-end-symbol.js | 38 ++ .../prototype/slice/return-abrupt-from-end.js | 52 ++ .../slice/return-abrupt-from-start-symbol.js | 37 ++ .../slice/return-abrupt-from-start.js | 51 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../set-values-from-different-ctor-type.js | 60 ++ .../speciesctor-destination-resizable.js | 53 ++ .../slice/speciesctor-get-ctor-abrupt.js | 54 ++ .../slice/speciesctor-get-ctor-inherited.js | 75 +++ .../speciesctor-get-ctor-returns-throws.js | 76 +++ .../prototype/slice/speciesctor-get-ctor.js | 67 +++ .../slice/speciesctor-get-species-abrupt.js | 58 ++ ...ctor-get-species-custom-ctor-invocation.js | 72 +++ ...tor-length-throws-resizable-arraybuffer.js | 56 ++ ...r-get-species-custom-ctor-length-throws.js | 54 ++ ...ciesctor-get-species-custom-ctor-length.js | 59 ++ ...es-custom-ctor-returns-another-instance.js | 66 +++ ...ciesctor-get-species-custom-ctor-throws.js | 60 ++ .../speciesctor-get-species-custom-ctor.js | 67 +++ .../speciesctor-get-species-returns-throws.js | 79 +++ ...peciesctor-get-species-use-default-ctor.js | 67 +++ .../slice/speciesctor-get-species.js | 59 ++ .../prototype/slice/speciesctor-resize.js | 141 +++++ .../prototype/slice/this-is-not-object.js | 65 +++ .../slice/this-is-not-typedarray-instance.js | 57 ++ .../prototype/slice/tointeger-end.js | 61 ++ .../prototype/slice/tointeger-start.js | 61 ++ .../callbackfn-arguments-with-thisarg.js | 70 +++ .../callbackfn-arguments-without-thisarg.js | 68 +++ .../some/BigInt/callbackfn-detachbuffer.js | 54 ++ ...lbackfn-no-interaction-over-non-integer.js | 53 ++ .../BigInt/callbackfn-not-callable-throws.js | 82 +++ .../BigInt/callbackfn-not-called-on-empty.js | 49 ++ ...lbackfn-return-does-not-change-instance.js | 51 ++ .../some/BigInt/callbackfn-returns-abrupt.js | 48 ++ ...callbackfn-set-value-during-interaction.js | 69 +++ .../prototype/some/BigInt/callbackfn-this.js | 70 +++ .../prototype/some/BigInt/detached-buffer.js | 45 ++ .../get-length-uses-internal-arraylength.js | 59 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ ...returns-false-if-every-cb-returns-false.js | 56 ++ .../returns-true-if-any-cb-returns-true.js | 72 +++ .../some/BigInt/values-are-not-cached.js | 53 ++ .../some/callbackfn-arguments-with-thisarg.js | 70 +++ .../callbackfn-arguments-without-thisarg.js | 68 +++ .../prototype/some/callbackfn-detachbuffer.js | 54 ++ ...lbackfn-no-interaction-over-non-integer.js | 53 ++ .../some/callbackfn-not-callable-throws.js | 82 +++ .../some/callbackfn-not-called-on-empty.js | 49 ++ .../prototype/some/callbackfn-resize.js | 86 +++ ...lbackfn-return-does-not-change-instance.js | 51 ++ .../some/callbackfn-returns-abrupt.js | 48 ++ ...callbackfn-set-value-during-interaction.js | 69 +++ .../prototype/some/callbackfn-this.js | 70 +++ .../prototype/some/detached-buffer.js | 45 ++ .../get-length-uses-internal-arraylength.js | 59 ++ .../prototype/some/invoked-as-func.js | 42 ++ .../prototype/some/invoked-as-method.js | 42 ++ .../TypedArray/prototype/some/length.js | 43 ++ .../TypedArray/prototype/some/name.js | 40 ++ .../prototype/some/not-a-constructor.js | 45 ++ .../TypedArray/prototype/some/prop-desc.js | 34 ++ .../resizable-buffer-grow-mid-iteration.js | 96 ++++ .../resizable-buffer-shrink-mid-iteration.js | 95 ++++ .../prototype/some/resizable-buffer.js | 127 +++++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ ...returns-false-if-every-cb-returns-false.js | 56 ++ .../returns-true-if-any-cb-returns-true.js | 72 +++ .../prototype/some/this-is-not-object.js | 64 +++ .../some/this-is-not-typedarray-instance.js | 56 ++ .../prototype/some/values-are-not-cached.js | 53 ++ .../sort/BigInt/arraylength-internal.js | 52 ++ .../sort/BigInt/comparefn-call-throws.js | 55 ++ .../prototype/sort/BigInt/comparefn-calls.js | 55 ++ .../sort/BigInt/comparefn-is-undefined.js | 36 ++ .../comparefn-nonfunction-call-throws.js | 68 +++ .../prototype/sort/BigInt/detached-buffer.js | 44 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../sort/BigInt/return-same-instance.js | 38 ++ .../BigInt/sortcompare-with-no-tostring.js | 44 ++ .../prototype/sort/BigInt/sorted-values.js | 44 ++ .../prototype/sort/arraylength-internal.js | 52 ++ .../prototype/sort/comparefn-call-throws.js | 55 ++ .../prototype/sort/comparefn-calls.js | 55 ++ .../prototype/sort/comparefn-grow.js | 83 +++ .../prototype/sort/comparefn-is-undefined.js | 36 ++ .../sort/comparefn-nonfunction-call-throws.js | 68 +++ .../sort/comparefn-resizable-buffer.js | 218 +++++++ .../prototype/sort/comparefn-shrink.js | 85 +++ .../prototype/sort/detached-buffer.js | 44 ++ .../prototype/sort/invoked-as-func.js | 48 ++ .../prototype/sort/invoked-as-method.js | 48 ++ .../TypedArray/prototype/sort/length.js | 43 ++ .../TypedArray/prototype/sort/name.js | 40 ++ .../prototype/sort/not-a-constructor.js | 45 ++ .../TypedArray/prototype/sort/prop-desc.js | 34 ++ .../resizable-buffer-default-comparator.js | 194 +++++++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../prototype/sort/return-same-instance.js | 38 ++ .../prototype/sort/sort-tonumber.js | 46 ++ .../sort/sortcompare-with-no-tostring.js | 44 ++ .../prototype/sort/sorted-values-nan.js | 51 ++ .../prototype/sort/sorted-values.js | 70 +++ .../TypedArray/prototype/sort/stability.js | 58 ++ .../prototype/sort/this-is-not-object.js | 64 +++ .../sort/this-is-not-typedarray-instance.js | 56 ++ .../subarray/BigInt/detached-buffer.js | 78 +++ .../prototype/subarray/BigInt/infinity.js | 44 ++ .../prototype/subarray/BigInt/minus-zero.js | 44 ++ ...esult-does-not-copy-ordinary-properties.js | 40 ++ .../result-is-new-instance-from-same-ctor.js | 44 ++ ...sult-is-new-instance-with-shared-buffer.js | 48 ++ .../BigInt/results-with-different-length.js | 71 +++ .../BigInt/results-with-empty-length.js | 70 +++ .../BigInt/results-with-same-length.js | 50 ++ .../BigInt/return-abrupt-from-begin-symbol.js | 37 ++ .../BigInt/return-abrupt-from-begin.js | 51 ++ .../BigInt/return-abrupt-from-end-symbol.js | 38 ++ .../subarray/BigInt/return-abrupt-from-end.js | 52 ++ .../BigInt/speciesctor-get-ctor-abrupt.js | 53 ++ .../BigInt/speciesctor-get-ctor-inherited.js | 74 +++ .../speciesctor-get-ctor-returns-throws.js | 75 +++ .../subarray/BigInt/speciesctor-get-ctor.js | 66 +++ .../BigInt/speciesctor-get-species-abrupt.js | 57 ++ ...ctor-get-species-custom-ctor-invocation.js | 74 +++ ...es-custom-ctor-returns-another-instance.js | 65 +++ ...ciesctor-get-species-custom-ctor-throws.js | 59 ++ .../speciesctor-get-species-custom-ctor.js | 66 +++ .../speciesctor-get-species-returns-throws.js | 78 +++ ...peciesctor-get-species-use-default-ctor.js | 66 +++ .../BigInt/speciesctor-get-species.js | 58 ++ .../subarray/BigInt/tointeger-begin.js | 61 ++ .../subarray/BigInt/tointeger-end.js | 61 ++ .../subarray/coerced-begin-end-grow.js | 118 ++++ .../subarray/coerced-begin-end-shrink.js | 204 +++++++ .../prototype/subarray/detached-buffer.js | 78 +++ .../TypedArray/prototype/subarray/infinity.js | 44 ++ .../prototype/subarray/invoked-as-func.js | 37 ++ .../prototype/subarray/invoked-as-method.js | 37 ++ .../TypedArray/prototype/subarray/length.js | 43 ++ .../prototype/subarray/minus-zero.js | 44 ++ .../TypedArray/prototype/subarray/name.js | 40 ++ .../prototype/subarray/not-a-constructor.js | 45 ++ .../prototype/subarray/prop-desc.js | 34 ++ .../prototype/subarray/resizable-buffer.js | 184 ++++++ .../result-byteOffset-from-out-of-bounds.js | 61 ++ ...esult-does-not-copy-ordinary-properties.js | 40 ++ .../result-is-new-instance-from-same-ctor.js | 44 ++ ...sult-is-new-instance-with-shared-buffer.js | 48 ++ .../subarray/results-with-different-length.js | 71 +++ .../subarray/results-with-empty-length.js | 70 +++ .../subarray/results-with-same-length.js | 50 ++ .../return-abrupt-from-begin-symbol.js | 37 ++ .../subarray/return-abrupt-from-begin.js | 51 ++ .../subarray/return-abrupt-from-end-symbol.js | 38 ++ .../subarray/return-abrupt-from-end.js | 52 ++ .../subarray/speciesctor-get-ctor-abrupt.js | 53 ++ .../speciesctor-get-ctor-inherited.js | 74 +++ .../speciesctor-get-ctor-returns-throws.js | 75 +++ .../subarray/speciesctor-get-ctor.js | 66 +++ .../speciesctor-get-species-abrupt.js | 57 ++ ...ctor-get-species-custom-ctor-invocation.js | 74 +++ ...es-custom-ctor-returns-another-instance.js | 65 +++ ...ciesctor-get-species-custom-ctor-throws.js | 59 ++ .../speciesctor-get-species-custom-ctor.js | 66 +++ .../speciesctor-get-species-returns-throws.js | 78 +++ ...peciesctor-get-species-use-default-ctor.js | 66 +++ .../subarray/speciesctor-get-species.js | 58 ++ .../prototype/subarray/this-is-not-object.js | 60 ++ .../this-is-not-typedarray-instance.js | 52 ++ .../prototype/subarray/tointeger-begin.js | 61 ++ .../prototype/subarray/tointeger-end.js | 61 ++ .../calls-tolocalestring-from-each-value.js | 65 +++ .../BigInt/calls-tostring-from-each-value.js | 71 +++ .../BigInt/calls-valueof-from-each-value.js | 68 +++ .../toLocaleString/BigInt/detached-buffer.js | 41 ++ .../empty-instance-returns-empty-string.js | 39 ++ .../get-length-uses-internal-arraylength.js | 55 ++ ...abrupt-from-firstelement-tolocalestring.js | 54 ++ ...eturn-abrupt-from-firstelement-tostring.js | 66 +++ ...return-abrupt-from-firstelement-valueof.js | 67 +++ ...-abrupt-from-nextelement-tolocalestring.js | 57 ++ ...return-abrupt-from-nextelement-tostring.js | 68 +++ .../return-abrupt-from-nextelement-valueof.js | 69 +++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../toLocaleString/BigInt/return-result.js | 58 ++ .../calls-tolocalestring-from-each-value.js | 66 +++ .../calls-tostring-from-each-value.js | 71 +++ .../calls-valueof-from-each-value.js | 69 +++ .../toLocaleString/detached-buffer.js | 41 ++ .../empty-instance-returns-empty-string.js | 39 ++ .../get-length-uses-internal-arraylength.js | 55 ++ .../toLocaleString/invoked-as-func.js | 44 ++ .../toLocaleString/invoked-as-method.js | 44 ++ .../prototype/toLocaleString/length.js | 43 ++ .../prototype/toLocaleString/name.js | 40 ++ .../toLocaleString/not-a-constructor.js | 45 ++ .../prototype/toLocaleString/prop-desc.js | 34 ++ .../toLocaleString/resizable-buffer.js | 126 ++++ ...abrupt-from-firstelement-tolocalestring.js | 56 ++ ...eturn-abrupt-from-firstelement-tostring.js | 68 +++ ...return-abrupt-from-firstelement-valueof.js | 69 +++ ...-abrupt-from-nextelement-tolocalestring.js | 59 ++ ...return-abrupt-from-nextelement-tostring.js | 70 +++ .../return-abrupt-from-nextelement-valueof.js | 71 +++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../prototype/toLocaleString/return-result.js | 60 ++ .../toLocaleString/this-is-not-object.js | 63 ++ .../this-is-not-typedarray-instance.js | 55 ++ .../user-provided-tolocalestring-grow.js | 94 +++ .../user-provided-tolocalestring-shrink.js | 95 ++++ .../prototype/toReversed/ignores-species.js | 53 ++ .../prototype/toReversed/immutable.js | 30 + .../toReversed/length-property-ignored.js | 62 ++ .../prototype/toReversed/metadata/length.js | 42 ++ .../prototype/toReversed/metadata/name.js | 40 ++ .../metadata/property-descriptor.js | 37 ++ .../prototype/toReversed/not-a-constructor.js | 45 ++ .../toReversed/this-value-invalid.js | 56 ++ .../toSorted/comparefn-not-a-function.js | 39 ++ .../toSorted/comparefn-stop-after-error.js | 45 ++ .../prototype/toSorted/ignores-species.js | 53 ++ .../prototype/toSorted/immutable.js | 30 + .../toSorted/length-property-ignored.js | 63 ++ .../prototype/toSorted/metadata/length.js | 42 ++ .../prototype/toSorted/metadata/name.js | 40 ++ .../toSorted/metadata/property-descriptor.js | 37 ++ .../prototype/toSorted/not-a-constructor.js | 45 ++ .../prototype/toSorted/this-value-invalid.js | 56 ++ .../builtins/TypedArray/prototype/toString.js | 42 ++ .../toString/BigInt/detached-buffer.js | 45 ++ .../prototype/toString/detached-buffer.js | 45 ++ .../prototype/toString/not-a-constructor.js | 45 ++ .../values/BigInt/detached-buffer.js | 40 ++ .../prototype/values/BigInt/iter-prototype.js | 36 ++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../prototype/values/BigInt/return-itor.js | 47 ++ .../prototype/values/detached-buffer.js | 40 ++ .../prototype/values/invoked-as-func.js | 43 ++ .../prototype/values/invoked-as-method.js | 43 ++ .../prototype/values/iter-prototype.js | 36 ++ .../TypedArray/prototype/values/length.js | 43 ++ .../values/make-in-bounds-after-exhausted.js | 67 +++ .../make-out-of-bounds-after-exhausted.js | 61 ++ .../TypedArray/prototype/values/name.js | 40 ++ .../prototype/values/not-a-constructor.js | 45 ++ .../TypedArray/prototype/values/prop-desc.js | 34 ++ .../resizable-buffer-grow-mid-iteration.js | 72 +++ .../resizable-buffer-shrink-mid-iteration.js | 64 +++ .../prototype/values/resizable-buffer.js | 161 ++++++ .../return-abrupt-from-this-out-of-bounds.js | 72 +++ .../prototype/values/return-itor.js | 49 ++ .../prototype/values/this-is-not-object.js | 65 +++ .../values/this-is-not-typedarray-instance.js | 57 ++ .../with/BigInt/early-type-coercion-bigint.js | 43 ++ .../prototype/with/early-type-coercion.js | 43 ++ .../prototype/with/ignores-species.js | 53 ++ .../TypedArray/prototype/with/immutable.js | 31 + .../with/index-bigger-or-eq-than-length.js | 52 ++ .../prototype/with/index-casted-to-number.js | 41 ++ .../prototype/with/index-negative.js | 40 ++ .../with/index-smaller-than-minus-length.js | 52 ++ .../index-validated-against-current-length.js | 70 +++ .../prototype/with/length-property-ignored.js | 62 ++ .../prototype/with/metadata/length.js | 42 ++ .../prototype/with/metadata/name.js | 40 ++ .../with/metadata/property-descriptor.js | 37 ++ .../prototype/with/not-a-constructor.js | 45 ++ .../prototype/with/this-value-invalid.js | 47 ++ .../resizable-buffer-length-tracking-1.js | 70 +++ .../resizable-buffer-length-tracking-2.js | 90 +++ 1874 files changed, 85755 insertions(+), 1180 deletions(-) create mode 100644 test/sendable/builtins/TypedArray/Symbol.species/length.js create mode 100644 test/sendable/builtins/TypedArray/Symbol.species/name.js create mode 100644 test/sendable/builtins/TypedArray/Symbol.species/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/Symbol.species/result.js create mode 100644 test/sendable/builtins/TypedArray/from/arylk-get-length-error.js create mode 100644 test/sendable/builtins/TypedArray/from/arylk-to-length-error.js create mode 100644 test/sendable/builtins/TypedArray/from/from-array-mapper-detaches-result.js create mode 100644 test/sendable/builtins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js create mode 100644 test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/from/from-typedarray-mapper-detaches-result.js create mode 100644 test/sendable/builtins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/from/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/from/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/from/iter-access-error.js create mode 100644 test/sendable/builtins/TypedArray/from/iter-invoke-error.js create mode 100644 test/sendable/builtins/TypedArray/from/iter-next-error.js create mode 100644 test/sendable/builtins/TypedArray/from/iter-next-value-error.js create mode 100644 test/sendable/builtins/TypedArray/from/iterated-array-changed-by-tonumber.js create mode 100644 test/sendable/builtins/TypedArray/from/length.js create mode 100644 test/sendable/builtins/TypedArray/from/mapfn-is-not-callable.js create mode 100644 test/sendable/builtins/TypedArray/from/name.js create mode 100644 test/sendable/builtins/TypedArray/from/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/from/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/from/this-is-not-constructor.js create mode 100644 test/sendable/builtins/TypedArray/invoked.js create mode 100644 test/sendable/builtins/TypedArray/length.js create mode 100644 test/sendable/builtins/TypedArray/name.js create mode 100644 test/sendable/builtins/TypedArray/of/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/of/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/of/length.js create mode 100644 test/sendable/builtins/TypedArray/of/name.js create mode 100644 test/sendable/builtins/TypedArray/of/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/of/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js create mode 100644 test/sendable/builtins/TypedArray/of/this-is-not-constructor.js create mode 100644 test/sendable/builtins/TypedArray/out-of-bounds-behaves-like-detached.js create mode 100644 test/sendable/builtins/TypedArray/out-of-bounds-get-and-set.js create mode 100644 test/sendable/builtins/TypedArray/out-of-bounds-has.js create mode 100644 test/sendable/builtins/TypedArray/prototype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.iterator.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/coerced-index-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/returns-item.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js create mode 100644 test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js create mode 100644 test/sendable/builtins/TypedArray/prototype/buffer/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/buffer/BigInt/return-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/buffer/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/buffer/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/buffer/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/buffer/this-inherits-typedarray.js create mode 100644 test/sendable/builtins/TypedArray/prototype/buffer/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/resizable-buffer-assorted.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-1.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-2.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/return-bytelength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteLength/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/resized-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/byteOffset/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-target.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-end-shrink.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-grow.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/BigInt/iter-prototype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-itor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/return-itor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/BigInt/values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/coerced-indexes.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/coerced-value-start-end-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/fill-values.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/return-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-destination-resizable.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-set.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/returns-undefined.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/coerced-searchelement-fromindex-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer-special-float-values.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/no-arg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-grow.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-shrink.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer-special-float-values.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/coerced-separator-grow.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/coerced-separator-shrink.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/separator-tostring-once-after-resized.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/BigInt/iter-prototype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-itor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/return-itor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-grow.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-shrink.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer-special-float-values.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/BigInt/return-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/resizable-buffer-assorted.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-1.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-2.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/return-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/length/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-destination-resizable.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/BigInt/values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-grow.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-shrink.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/resizable-and-fixed-have-same-prototype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/BigInt/returns-original-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/BigInt/reverts.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/reverts.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobigint64.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobiguint64.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/boolean-tobigint.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/null-tobigint.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/number-tobigint.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-big.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/string-tobigint.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/symbol-tobigint.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/BigInt/undefined-tobigint.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/array-arg-value-conversion-resizes-array-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/bit-precision.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/target-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/target-grow-source-length-getter.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/target-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/target-shrink-source-length-getter.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/this-backed-by-resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-backed-by-resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/infinity.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/minus-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-different-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-same-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-destination-resizable.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-grow.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-shrink.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/infinity.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/speciesctor-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/BigInt/values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-calls.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-same-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/BigInt/sorted-values.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/comparefn-grow.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/comparefn-resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/comparefn-shrink.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/resizable-buffer-default-comparator.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/stability.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/infinity.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/minus-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-grow.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-shrink.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/infinity.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js create mode 100644 test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-result.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-grow.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-shrink.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toReversed/metadata/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toReversed/metadata/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toReversed/metadata/property-descriptor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toReversed/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toSorted/metadata/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toSorted/metadata/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toSorted/metadata/property-descriptor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toSorted/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toString.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toString/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/toString/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/BigInt/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/BigInt/iter-prototype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/BigInt/return-itor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/invoked-as-func.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/invoked-as-method.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/prop-desc.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/resizable-buffer.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/return-itor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/this-is-not-object.js create mode 100644 test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/ignores-species.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/immutable.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/index-negative.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/index-validated-against-current-length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/metadata/length.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/metadata/name.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/metadata/property-descriptor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/not-a-constructor.js create mode 100644 test/sendable/builtins/TypedArray/prototype/with/this-value-invalid.js create mode 100644 test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-1.js create mode 100644 test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-2.js diff --git a/test/sendable/builtins/ArrayBuffer/prototype/byteLength/detached-buffer.js b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/detached-buffer.js index 535e262aeff..ff4589294d6 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/byteLength/detached-buffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/detached-buffer.js @@ -21,7 +21,7 @@ info: | ... If IsDetachedBuffer(buffer) is true, return 0. ... -includes: [detachSendableArrayBuffer.js] +includes: [detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality] ---*/ diff --git a/test/sendable/builtins/Function/15.3.2.1-10-6gs.js b/test/sendable/builtins/Function/15.3.2.1-10-6gs.js index 8e9abb9b84f..996c931654b 100644 --- a/test/sendable/builtins/Function/15.3.2.1-10-6gs.js +++ b/test/sendable/builtins/Function/15.3.2.1-10-6gs.js @@ -17,11 +17,11 @@ es5id: 15.3.2.1-10-6gs description: > Strict Mode - SyntaxError is thrown if a function using the - Function constructor has two identical parameters in (local) + SendableFunction constructor has two identical parameters in (local) strict mode flags: [noStrict] ---*/ assert.throws(SyntaxError, function() { - new Function('param_1', 'param_2', 'param_1', '"use strict";return 0;'); + new SendableFunction('param_1', 'param_2', 'param_1', '"use strict";return 0;'); }); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-1-s.js b/test/sendable/builtins/Function/15.3.2.1-11-1-s.js index 437ed92face..475df6132a4 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-1-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-1-s.js @@ -16,12 +16,12 @@ /*--- es5id: 15.3.2.1-11-1-s description: > - Duplicate seperate parameter name in Function constructor throws + Duplicate seperate parameter name in SendableFunction constructor throws SyntaxError in strict mode flags: [noStrict] ---*/ assert.throws(SyntaxError, function() { - Function('a', 'a', '"use strict";'); + SendableFunction('a', 'a', '"use strict";'); }); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-1.js b/test/sendable/builtins/Function/15.3.2.1-11-1.js index 19d64655410..515c4e56ae6 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-1.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-1.js @@ -16,8 +16,8 @@ /*--- es5id: 15.3.2.1-11-1 description: > - Duplicate separate parameter name in Function constructor allowed + Duplicate separate parameter name in SendableFunction constructor allowed if body not strict ---*/ -Function('a', 'a', 'return;'); +SendableFunction('a', 'a', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-2-s.js b/test/sendable/builtins/Function/15.3.2.1-11-2-s.js index 769b19b5d6c..5e4ac676a34 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-2-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-2-s.js @@ -16,9 +16,9 @@ /*--- es5id: 15.3.2.1-11-2-s description: > - Duplicate seperate parameter name in Function constructor called + Duplicate seperate parameter name in SendableFunction constructor called from strict mode allowed if body not strict flags: [onlyStrict] ---*/ -Function('a', 'a', 'return;'); +SendableFunction('a', 'a', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-3-s.js b/test/sendable/builtins/Function/15.3.2.1-11-3-s.js index fad3d6e2963..387b0a80fb1 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-3-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-3-s.js @@ -16,12 +16,12 @@ /*--- es5id: 15.3.2.1-11-3-s description: > - Function constructor having a formal parameter named 'eval' throws + SendableFunction constructor having a formal parameter named 'eval' throws SyntaxError if function body is strict mode flags: [noStrict] ---*/ assert.throws(SyntaxError, function() { - Function('eval', '"use strict";'); + SendableFunction('eval', '"use strict";'); }); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-3.js b/test/sendable/builtins/Function/15.3.2.1-11-3.js index 928e1975517..d81abd0cb8e 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-3.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-3.js @@ -16,8 +16,8 @@ /*--- es5id: 15.3.2.1-11-3 description: > - Function constructor may have a formal parameter named 'eval' if + SendableFunction constructor may have a formal parameter named 'eval' if body is not strict mode ---*/ -Function('eval', 'return;'); +SendableFunction('eval', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-4-s.js b/test/sendable/builtins/Function/15.3.2.1-11-4-s.js index 8fbf0ae6d3a..4daa72d207f 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-4-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-4-s.js @@ -16,10 +16,10 @@ /*--- es5id: 15.3.2.1-11-4-s description: > - Function constructor call from strict code with formal parameter + SendableFunction constructor call from strict code with formal parameter named 'eval' does not throws SyntaxError if function body is not strict mode flags: [onlyStrict] ---*/ -Function('eval', 'return;'); +SendableFunction('eval', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-5-s.js b/test/sendable/builtins/Function/15.3.2.1-11-5-s.js index 671cad03e10..37c559cdf39 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-5-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-5-s.js @@ -16,12 +16,12 @@ /*--- es5id: 15.3.2.1-11-5-s description: > - Duplicate combined parameter name in Function constructor throws + Duplicate combined parameter name in SendableFunction constructor throws SyntaxError in strict mode flags: [noStrict] ---*/ assert.throws(SyntaxError, function() { - Function('a,a', '"use strict";'); + SendableFunction('a,a', '"use strict";'); }); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-5.js b/test/sendable/builtins/Function/15.3.2.1-11-5.js index 0ab9756233c..e875b622c0d 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-5.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-5.js @@ -16,8 +16,8 @@ /*--- es5id: 15.3.2.1-11-5 description: > - Duplicate combined parameter name in Function constructor allowed + Duplicate combined parameter name in SendableFunction constructor allowed if body is not strict ---*/ -Function('a,a', 'return;'); +SendableFunction('a,a', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-6-s.js b/test/sendable/builtins/Function/15.3.2.1-11-6-s.js index 58269091a80..96e0514ee85 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-6-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-6-s.js @@ -16,9 +16,9 @@ /*--- es5id: 15.3.2.1-11-6-s description: > - Duplicate combined parameter name allowed in Function constructor + Duplicate combined parameter name allowed in SendableFunction constructor called in strict mode if body not strict flags: [onlyStrict] ---*/ -Function('a,a', 'return a;'); +SendableFunction('a,a', 'return a;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-7-s.js b/test/sendable/builtins/Function/15.3.2.1-11-7-s.js index 5116d1e20d2..5422ae71f30 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-7-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-7-s.js @@ -16,10 +16,10 @@ /*--- es5id: 15.3.2.1-11-7-s description: > - Function constructor call from strict code with formal parameter + SendableFunction constructor call from strict code with formal parameter named arguments does not throws SyntaxError if function body is not strict mode flags: [onlyStrict] ---*/ -Function('arguments', 'return;'); +SendableFunction('arguments', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-8-s.js b/test/sendable/builtins/Function/15.3.2.1-11-8-s.js index b1e3ce31871..daebfc797e2 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-8-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-8-s.js @@ -17,10 +17,10 @@ es5id: 15.3.2.1-11-8-s description: > Strict Mode - SyntaxError is not thrown if a function is created - using a Function constructor that has two identical parameters, + using a SendableFunction constructor that has two identical parameters, which are separated by a unique parameter name and there is no explicit 'use strict' in the function constructor's body flags: [onlyStrict] ---*/ -var foo = new Function("baz", "qux", "baz", "return 0;"); +var foo = new SendableFunction("baz", "qux", "baz", "return 0;"); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-9-s.js b/test/sendable/builtins/Function/15.3.2.1-11-9-s.js index 53433667212..28b559fb0cc 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-9-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-9-s.js @@ -17,9 +17,9 @@ es5id: 15.3.2.1-11-9-s description: > Strict Mode - No SyntaxError is thrown if a function is created using - the Function constructor that has three identical parameters and + the SendableFunction constructor that has three identical parameters and there is no explicit 'use strict' in the function constructor's body ---*/ -var foo = new Function("baz", "baz", "baz", "return 0;"); +var foo = new SendableFunction("baz", "baz", "baz", "return 0;"); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-10gs.js b/test/sendable/builtins/Function/15.3.5.4_2-10gs.js index f8212123f2c..77139c3d26c 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-10gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-10gs.js @@ -17,12 +17,12 @@ es5id: 15.3.5.4_2-10gs description: > Strict mode - checking access to strict function caller from - non-strict function (New'ed Function constructor includes strict + non-strict function (New'ed SendableFunction constructor includes strict directive prologue) flags: [noStrict] ---*/ -var f = new Function("\"use strict\";\ngNonStrict();"); +var f = new SendableFunction("\"use strict\";\ngNonStrict();"); assert.throws(TypeError, function() { f(); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-15gs.js b/test/sendable/builtins/Function/15.3.5.4_2-15gs.js index 1a76949f5d3..3f16a253826 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-15gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-15gs.js @@ -17,7 +17,7 @@ es5id: 15.3.5.4_2-15gs description: > Strict mode - checking access to strict function caller from - strict function (New'ed object from FunctionDeclaration defined + strict function (New'ed object from SendableFunctionDeclaration defined within strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-16gs.js b/test/sendable/builtins/Function/15.3.5.4_2-16gs.js index 1f6de6d1e3d..441117146db 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-16gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-16gs.js @@ -17,7 +17,7 @@ es5id: 15.3.5.4_2-16gs description: > Strict mode - checking access to strict function caller from - non-strict function (New'ed object from FunctionDeclaration + non-strict function (New'ed object from SendableFunctionDeclaration includes strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-17gs.js b/test/sendable/builtins/Function/15.3.5.4_2-17gs.js index 3cfb5ea4824..72e0e12d944 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-17gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-17gs.js @@ -17,7 +17,7 @@ es5id: 15.3.5.4_2-17gs description: > Strict mode - checking access to strict function caller from - strict function (New'ed object from FunctionExpression defined + strict function (New'ed object from SendableFunctionExpression defined within strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-18gs.js b/test/sendable/builtins/Function/15.3.5.4_2-18gs.js index dddc254e808..6d99b7b7801 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-18gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-18gs.js @@ -17,7 +17,7 @@ es5id: 15.3.5.4_2-18gs description: > Strict mode - checking access to strict function caller from - non-strict function (New'ed object from FunctionExpression + non-strict function (New'ed object from SendableFunctionExpression includes strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-19gs.js b/test/sendable/builtins/Function/15.3.5.4_2-19gs.js index 53718553676..880c5ab3fe4 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-19gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-19gs.js @@ -17,7 +17,7 @@ es5id: 15.3.5.4_2-19gs description: > Strict mode - checking access to strict function caller from - strict function (New'ed object from Anonymous FunctionExpression + strict function (New'ed object from Anonymous SendableFunctionExpression defined within strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-1gs.js b/test/sendable/builtins/Function/15.3.5.4_2-1gs.js index 5d2177672d9..85e12031f46 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-1gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-1gs.js @@ -17,7 +17,7 @@ es5id: 15.3.5.4_2-1gs description: > Strict mode - checking access to strict function caller from - strict function (FunctionDeclaration defined within strict mode) + strict function (SendableFunctionDeclaration defined within strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-20gs.js b/test/sendable/builtins/Function/15.3.5.4_2-20gs.js index 187de4b3fa2..7fe07a90b10 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-20gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-20gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-20gs description: > Strict mode - checking access to strict function caller from non-strict function (New'ed object from Anonymous - FunctionExpression includes strict directive prologue) + SendableFunctionExpression includes strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-21gs.js b/test/sendable/builtins/Function/15.3.5.4_2-21gs.js index 27454203de7..9eba0fe62c7 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-21gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-21gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-21gs description: > Strict mode - checking access to strict function caller from - strict function (FunctionDeclaration defined within a - FunctionDeclaration inside strict mode) + strict function (SendableFunctionDeclaration defined within a + SendableFunctionDeclaration inside strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-22gs.js b/test/sendable/builtins/Function/15.3.5.4_2-22gs.js index f72eebc1e20..0d45f6eebde 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-22gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-22gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-22gs description: > Strict mode - checking access to strict function caller from - strict function (FunctionExpression defined within a - FunctionDeclaration inside strict mode) + strict function (SendableFunctionExpression defined within a + SendableFunctionDeclaration inside strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-23gs.js b/test/sendable/builtins/Function/15.3.5.4_2-23gs.js index b8c21755221..55969351c8b 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-23gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-23gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-23gs description: > Strict mode - checking access to strict function caller from - strict function (Anonymous FunctionExpression defined within a - FunctionDeclaration inside strict mode) + strict function (Anonymous SendableFunctionExpression defined within a + SendableFunctionDeclaration inside strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-24gs.js b/test/sendable/builtins/Function/15.3.5.4_2-24gs.js index d2d6ecbc67d..914bd41fcaa 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-24gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-24gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-24gs description: > Strict mode - checking access to strict function caller from - strict function (FunctionDeclaration defined within a - FunctionExpression inside strict mode) + strict function (SendableFunctionDeclaration defined within a + SendableFunctionExpression inside strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-25gs.js b/test/sendable/builtins/Function/15.3.5.4_2-25gs.js index 2ea861faa7d..adccfd02bf4 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-25gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-25gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-25gs description: > Strict mode - checking access to strict function caller from - strict function (FunctionExpression defined within a - FunctionExpression inside strict mode) + strict function (SendableFunctionExpression defined within a + SendableFunctionExpression inside strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-26gs.js b/test/sendable/builtins/Function/15.3.5.4_2-26gs.js index 3735a3c96b8..3d7f8b754bb 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-26gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-26gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-26gs description: > Strict mode - checking access to strict function caller from - strict function (Anonymous FunctionExpression defined within a - FunctionExpression inside strict mode) + strict function (Anonymous SendableFunctionExpression defined within a + SendableFunctionExpression inside strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-27gs.js b/test/sendable/builtins/Function/15.3.5.4_2-27gs.js index c5b0a34f2f4..7feab02a048 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-27gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-27gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-27gs description: > Strict mode - checking access to strict function caller from - strict function (FunctionDeclaration defined within an Anonymous - FunctionExpression inside strict mode) + strict function (SendableFunctionDeclaration defined within an Anonymous + SendableFunctionExpression inside strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-28gs.js b/test/sendable/builtins/Function/15.3.5.4_2-28gs.js index d09b02533e0..96ff99a8c5d 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-28gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-28gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-28gs description: > Strict mode - checking access to strict function caller from - strict function (FunctionExpression defined within an Anonymous - FunctionExpression inside strict mode) + strict function (SendableFunctionExpression defined within an Anonymous + SendableFunctionExpression inside strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-29gs.js b/test/sendable/builtins/Function/15.3.5.4_2-29gs.js index 8dcbd2a475e..a2a8cab9b53 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-29gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-29gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-29gs description: > Strict mode - checking access to strict function caller from - strict function (Anonymous FunctionExpression defined within an - Anonymous FunctionExpression inside strict mode) + strict function (Anonymous SendableFunctionExpression defined within an + Anonymous SendableFunctionExpression inside strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-2gs.js b/test/sendable/builtins/Function/15.3.5.4_2-2gs.js index 0d809de4169..8203af2a33d 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-2gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-2gs.js @@ -17,7 +17,7 @@ es5id: 15.3.5.4_2-2gs description: > Strict mode - checking access to strict function caller from - non-strict function (FunctionDeclaration includes strict directive + non-strict function (SendableFunctionDeclaration includes strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-30gs.js b/test/sendable/builtins/Function/15.3.5.4_2-30gs.js index e2b758616b8..f354e7ec79d 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-30gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-30gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-30gs description: > Strict mode - checking access to strict function caller from - non-strict function (FunctionDeclaration defined within a - FunctionDeclaration with a strict directive prologue) + non-strict function (SendableFunctionDeclaration defined within a + SendableFunctionDeclaration with a strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-31gs.js b/test/sendable/builtins/Function/15.3.5.4_2-31gs.js index 0288c2cdc26..e768f6ec190 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-31gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-31gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-31gs description: > Strict mode - checking access to strict function caller from - non-strict function (FunctionExpression defined within a - FunctionDeclaration with a strict directive prologue) + non-strict function (SendableFunctionExpression defined within a + SendableFunctionDeclaration with a strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-32gs.js b/test/sendable/builtins/Function/15.3.5.4_2-32gs.js index e24e40d25d4..32fd49e57b6 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-32gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-32gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-32gs description: > Strict mode - checking access to strict function caller from - non-strict function (Anonymous FunctionExpression defined within a - FunctionDeclaration with a strict directive prologue) + non-strict function (Anonymous SendableFunctionExpression defined within a + SendableFunctionDeclaration with a strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-33gs.js b/test/sendable/builtins/Function/15.3.5.4_2-33gs.js index 6384c8e0a2f..e901d869bca 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-33gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-33gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-33gs description: > Strict mode - checking access to strict function caller from - non-strict function (FunctionDeclaration defined within a - FunctionExpression with a strict directive prologue) + non-strict function (SendableFunctionDeclaration defined within a + SendableFunctionExpression with a strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-34gs.js b/test/sendable/builtins/Function/15.3.5.4_2-34gs.js index 73447b0663e..460e760094f 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-34gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-34gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-34gs description: > Strict mode - checking access to strict function caller from - non-strict function (FunctionExpression defined within a - FunctionExpression with a strict directive prologue) + non-strict function (SendableFunctionExpression defined within a + SendableFunctionExpression with a strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-35gs.js b/test/sendable/builtins/Function/15.3.5.4_2-35gs.js index 46a5b1cddd7..896b7c9b369 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-35gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-35gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-35gs description: > Strict mode - checking access to strict function caller from - non-strict function (Anonymous FunctionExpression defined within a - FunctionExpression with a strict directive prologue) + non-strict function (Anonymous SendableFunctionExpression defined within a + SendableFunctionExpression with a strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-36gs.js b/test/sendable/builtins/Function/15.3.5.4_2-36gs.js index a5fae7fd85d..a02e9919e8c 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-36gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-36gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-36gs description: > Strict mode - checking access to strict function caller from - non-strict function (FunctionDeclaration defined within an - Anonymous FunctionExpression with a strict directive prologue) + non-strict function (SendableFunctionDeclaration defined within an + Anonymous SendableFunctionExpression with a strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-37gs.js b/test/sendable/builtins/Function/15.3.5.4_2-37gs.js index e1cbdde3c88..306c18a510e 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-37gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-37gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-37gs description: > Strict mode - checking access to strict function caller from - non-strict function (FunctionExpression defined within an - Anonymous FunctionExpression with a strict directive prologue) + non-strict function (SendableFunctionExpression defined within an + Anonymous SendableFunctionExpression with a strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-38gs.js b/test/sendable/builtins/Function/15.3.5.4_2-38gs.js index ef8d91ab284..92aa7b36f2b 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-38gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-38gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-38gs description: > Strict mode - checking access to strict function caller from - non-strict function (Anonymous FunctionExpression defined within - an Anonymous FunctionExpression with a strict directive prologue) + non-strict function (Anonymous SendableFunctionExpression defined within + an Anonymous SendableFunctionExpression with a strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-39gs.js b/test/sendable/builtins/Function/15.3.5.4_2-39gs.js index 4d603b8509c..9b1bed8de87 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-39gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-39gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-39gs description: > Strict mode - checking access to strict function caller from - non-strict function (FunctionDeclaration with a strict directive - prologue defined within a FunctionDeclaration) + non-strict function (SendableFunctionDeclaration with a strict directive + prologue defined within a SendableFunctionDeclaration) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-3gs.js b/test/sendable/builtins/Function/15.3.5.4_2-3gs.js index 7ba8133098e..f59443b5003 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-3gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-3gs.js @@ -17,7 +17,7 @@ es5id: 15.3.5.4_2-3gs description: > Strict mode - checking access to strict function caller from - strict function (FunctionExpression defined within strict mode) + strict function (SendableFunctionExpression defined within strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-40gs.js b/test/sendable/builtins/Function/15.3.5.4_2-40gs.js index 8940ef1009a..3e8e4b2ac29 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-40gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-40gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-40gs description: > Strict mode - checking access to strict function caller from - non-strict function (FunctionExpression with a strict directive - prologue defined within a FunctionDeclaration) + non-strict function (SendableFunctionExpression with a strict directive + prologue defined within a SendableFunctionDeclaration) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-41gs.js b/test/sendable/builtins/Function/15.3.5.4_2-41gs.js index 08a87518af6..6d1858316b6 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-41gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-41gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-41gs description: > Strict mode - checking access to strict function caller from - non-strict function (Anonymous FunctionExpression with a strict - directive prologue defined within a FunctionDeclaration) + non-strict function (Anonymous SendableFunctionExpression with a strict + directive prologue defined within a SendableFunctionDeclaration) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-42gs.js b/test/sendable/builtins/Function/15.3.5.4_2-42gs.js index adc81b147c7..d9896796422 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-42gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-42gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-42gs description: > Strict mode - checking access to strict function caller from - non-strict function (FunctionDeclaration with a strict directive - prologue defined within a FunctionExpression) + non-strict function (SendableFunctionDeclaration with a strict directive + prologue defined within a SendableFunctionExpression) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-43gs.js b/test/sendable/builtins/Function/15.3.5.4_2-43gs.js index 956e09d3815..7240c6f92c1 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-43gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-43gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-43gs description: > Strict mode - checking access to strict function caller from - non-strict function (FunctionExpression with a strict directive - prologue defined within a FunctionExpression) + non-strict function (SendableFunctionExpression with a strict directive + prologue defined within a SendableFunctionExpression) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-44gs.js b/test/sendable/builtins/Function/15.3.5.4_2-44gs.js index a91502f0aae..ebd56a7cade 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-44gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-44gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-44gs description: > Strict mode - checking access to strict function caller from - non-strict function (Anonymous FunctionExpression with a strict - directive prologue defined within a FunctionExpression) + non-strict function (Anonymous SendableFunctionExpression with a strict + directive prologue defined within a SendableFunctionExpression) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-45gs.js b/test/sendable/builtins/Function/15.3.5.4_2-45gs.js index c2af6a025d6..4bccf899c9e 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-45gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-45gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-45gs description: > Strict mode - checking access to strict function caller from - non-strict function (FunctionDeclaration with a strict directive - prologue defined within an Anonymous FunctionExpression) + non-strict function (SendableFunctionDeclaration with a strict directive + prologue defined within an Anonymous SendableFunctionExpression) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-46gs.js b/test/sendable/builtins/Function/15.3.5.4_2-46gs.js index 58f30f5e458..e7de5b03166 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-46gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-46gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-46gs description: > Strict mode - checking access to strict function caller from - non-strict function (FunctionExpression with a strict directive - prologue defined within an Anonymous FunctionExpression) + non-strict function (SendableFunctionExpression with a strict directive + prologue defined within an Anonymous SendableFunctionExpression) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-47gs.js b/test/sendable/builtins/Function/15.3.5.4_2-47gs.js index f3d98c25875..47b16bbcc4c 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-47gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-47gs.js @@ -17,8 +17,8 @@ es5id: 15.3.5.4_2-47gs description: > Strict mode - checking access to strict function caller from - non-strict function (Anonymous FunctionExpression with a strict - directive prologue defined within an Anonymous FunctionExpression) + non-strict function (Anonymous SendableFunctionExpression with a strict + directive prologue defined within an Anonymous SendableFunctionExpression) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-4gs.js b/test/sendable/builtins/Function/15.3.5.4_2-4gs.js index c9d9b959074..bdda0120fb8 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-4gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-4gs.js @@ -17,7 +17,7 @@ es5id: 15.3.5.4_2-4gs description: > Strict mode - checking access to strict function caller from - non-strict function (FunctionExpression includes strict directive + non-strict function (SendableFunctionExpression includes strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-58gs.js b/test/sendable/builtins/Function/15.3.5.4_2-58gs.js index e5e3af2d275..4844e877a14 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-58gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-58gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-58gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - non-strict Function constructor) + non-strict SendableFunction constructor) flags: [noStrict] ---*/ @@ -28,7 +28,7 @@ function f() { }; assert.throws(TypeError, function() { - Function("return f();")(); + SendableFunction("return f();")(); }); function gNonStrict() { diff --git a/test/sendable/builtins/Function/15.3.5.4_2-59gs.js b/test/sendable/builtins/Function/15.3.5.4_2-59gs.js index f4e71cbaf21..05ec7ab6f0f 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-59gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-59gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-59gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - non-strict new'ed Function constructor) + non-strict new'ed SendableFunction constructor) flags: [noStrict] ---*/ @@ -28,7 +28,7 @@ function f() { }; assert.throws(TypeError, function() { - new Function("return f();")(); + new SendableFunction("return f();")(); }); function gNonStrict() { diff --git a/test/sendable/builtins/Function/15.3.5.4_2-5gs.js b/test/sendable/builtins/Function/15.3.5.4_2-5gs.js index 5d3cad2be21..3185bb138c4 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-5gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-5gs.js @@ -17,7 +17,7 @@ es5id: 15.3.5.4_2-5gs description: > Strict mode - checking access to strict function caller from - strict function (Anonymous FunctionExpression defined within + strict function (Anonymous SendableFunctionExpression defined within strict mode) flags: [onlyStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-60gs.js b/test/sendable/builtins/Function/15.3.5.4_2-60gs.js index f8ca12ecf95..d6759b89b39 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-60gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-60gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-60gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.apply()) + SendableFunction.prototype.apply()) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-61gs.js b/test/sendable/builtins/Function/15.3.5.4_2-61gs.js index 2f600d7f05b..4faf12ae8d7 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-61gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-61gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-61gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.apply(null)) + SendableFunction.prototype.apply(null)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-62gs.js b/test/sendable/builtins/Function/15.3.5.4_2-62gs.js index 1e775795d2a..321782ac146 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-62gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-62gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-62gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.apply(undefined)) + SendableFunction.prototype.apply(undefined)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-63gs.js b/test/sendable/builtins/Function/15.3.5.4_2-63gs.js index 40a4c113ddc..6c81dfcc1a9 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-63gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-63gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-63gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.apply(someObject)) + SendableFunction.prototype.apply(someObject)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-64gs.js b/test/sendable/builtins/Function/15.3.5.4_2-64gs.js index 29ffd395f54..df5fa7c7fc6 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-64gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-64gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-64gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.apply(globalObject)) + SendableFunction.prototype.apply(globalObject)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-65gs.js b/test/sendable/builtins/Function/15.3.5.4_2-65gs.js index 04733ef3490..17cb9bf019d 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-65gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-65gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-65gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.call()) + SendableFunction.prototype.call()) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-66gs.js b/test/sendable/builtins/Function/15.3.5.4_2-66gs.js index c5107450bb5..4b3d90e914a 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-66gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-66gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-66gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.call(null)) + SendableFunction.prototype.call(null)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-67gs.js b/test/sendable/builtins/Function/15.3.5.4_2-67gs.js index 9c8647ed28d..76b5e85efbf 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-67gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-67gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-67gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.call(undefined)) + SendableFunction.prototype.call(undefined)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-68gs.js b/test/sendable/builtins/Function/15.3.5.4_2-68gs.js index 04583758b98..cd30ecfad39 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-68gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-68gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-68gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.call(someObject)) + SendableFunction.prototype.call(someObject)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-69gs.js b/test/sendable/builtins/Function/15.3.5.4_2-69gs.js index e53269fb92f..6c92945a091 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-69gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-69gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-69gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.call(globalObject)) + SendableFunction.prototype.call(globalObject)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-6gs.js b/test/sendable/builtins/Function/15.3.5.4_2-6gs.js index d89a3191c50..1d9fa47e862 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-6gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-6gs.js @@ -17,7 +17,7 @@ es5id: 15.3.5.4_2-6gs description: > Strict mode - checking access to strict function caller from - non-strict function (Anonymous FunctionExpression includes strict + non-strict function (Anonymous SendableFunctionExpression includes strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-70gs.js b/test/sendable/builtins/Function/15.3.5.4_2-70gs.js index fee98a3af9f..912cbc0cb98 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-70gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-70gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-70gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.bind()()) + SendableFunction.prototype.bind()()) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-71gs.js b/test/sendable/builtins/Function/15.3.5.4_2-71gs.js index 40015883f56..6111b650a62 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-71gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-71gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-71gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.bind(null)()) + SendableFunction.prototype.bind(null)()) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-72gs.js b/test/sendable/builtins/Function/15.3.5.4_2-72gs.js index 3d8e7f1b1c3..b9653d0bb00 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-72gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-72gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-72gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.bind(undefined)()) + SendableFunction.prototype.bind(undefined)()) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-73gs.js b/test/sendable/builtins/Function/15.3.5.4_2-73gs.js index 5de97e99067..cb5825fb85b 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-73gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-73gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-73gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.bind(someObject)()) + SendableFunction.prototype.bind(someObject)()) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-74gs.js b/test/sendable/builtins/Function/15.3.5.4_2-74gs.js index d7a3d5aff60..5bf5d1b7843 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-74gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-74gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-74gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - Function.prototype.bind(globalObject)()) + SendableFunction.prototype.bind(globalObject)()) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-77gs.js b/test/sendable/builtins/Function/15.3.5.4_2-77gs.js index 4485a13dda4..162036a0f2a 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-77gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-77gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-77gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function constructor) + strict SendableFunction constructor) flags: [noStrict] features: [caller] ---*/ @@ -28,7 +28,7 @@ function f() { }; (function() { "use strict"; - Function("return f();")(); + SendableFunction("return f();")(); })(); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-78gs.js b/test/sendable/builtins/Function/15.3.5.4_2-78gs.js index 36233be49af..25be1b68882 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-78gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-78gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-78gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict new'ed Function constructor) + strict new'ed SendableFunction constructor) flags: [noStrict] features: [caller] ---*/ @@ -28,7 +28,7 @@ function f() { }; (function() { "use strict"; - return new Function("return f();")(); + return new SendableFunction("return f();")(); })(); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-79gs.js b/test/sendable/builtins/Function/15.3.5.4_2-79gs.js index 1e3afffd175..fd17a638db6 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-79gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-79gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-79gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.apply()) + strict SendableFunction.prototype.apply()) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-7gs.js b/test/sendable/builtins/Function/15.3.5.4_2-7gs.js index aa2ac8cd558..a872119618e 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-7gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-7gs.js @@ -17,11 +17,11 @@ es5id: 15.3.5.4_2-7gs description: > Strict mode - checking access to non-strict function caller from - strict function (Function constructor defined within strict mode) + strict function (SendableFunction constructor defined within strict mode) flags: [onlyStrict] ---*/ -var f = Function("return gNonStrict();"); +var f = SendableFunction("return gNonStrict();"); assert.throws(TypeError, function() { f(); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-80gs.js b/test/sendable/builtins/Function/15.3.5.4_2-80gs.js index 567f3078fe4..a7d7f3ba8ca 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-80gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-80gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-80gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.apply(null)) + strict SendableFunction.prototype.apply(null)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-81gs.js b/test/sendable/builtins/Function/15.3.5.4_2-81gs.js index 5e983d78eaa..609e2ef6630 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-81gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-81gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-81gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.apply(undefined)) + strict SendableFunction.prototype.apply(undefined)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-82gs.js b/test/sendable/builtins/Function/15.3.5.4_2-82gs.js index cb627253d1c..3d5d9349299 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-82gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-82gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-82gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.apply(someObject)) + strict SendableFunction.prototype.apply(someObject)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-83gs.js b/test/sendable/builtins/Function/15.3.5.4_2-83gs.js index 7e84c1baf20..e46da42ad98 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-83gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-83gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-83gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.apply(globalObject)) + strict SendableFunction.prototype.apply(globalObject)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-84gs.js b/test/sendable/builtins/Function/15.3.5.4_2-84gs.js index 12d73cd7a14..8d0a6b08743 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-84gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-84gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-84gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.call()) + strict SendableFunction.prototype.call()) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-85gs.js b/test/sendable/builtins/Function/15.3.5.4_2-85gs.js index e80189024d8..35c269f8bd0 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-85gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-85gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-85gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.call(null)) + strict SendableFunction.prototype.call(null)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-86gs.js b/test/sendable/builtins/Function/15.3.5.4_2-86gs.js index e3bf6747bb5..ac1a2a99cff 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-86gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-86gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-86gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.call(undefined)) + strict SendableFunction.prototype.call(undefined)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-87gs.js b/test/sendable/builtins/Function/15.3.5.4_2-87gs.js index a9607b31ee9..501d19da4d9 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-87gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-87gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-87gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.call(someObject)) + strict SendableFunction.prototype.call(someObject)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-88gs.js b/test/sendable/builtins/Function/15.3.5.4_2-88gs.js index 7e06d5fbf02..c06b1822abb 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-88gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-88gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-88gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.call(globalObject)) + strict SendableFunction.prototype.call(globalObject)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-89gs.js b/test/sendable/builtins/Function/15.3.5.4_2-89gs.js index 3fc16cb8c8f..4aaec6f7e57 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-89gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-89gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-89gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.bind()()) + strict SendableFunction.prototype.bind()()) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-8gs.js b/test/sendable/builtins/Function/15.3.5.4_2-8gs.js index ccaa1f28765..718b9d43336 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-8gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-8gs.js @@ -17,12 +17,12 @@ es5id: 15.3.5.4_2-8gs description: > Strict mode - checking access to strict function caller from - non-strict function (Function constructor includes strict + non-strict function (SendableFunction constructor includes strict directive prologue) flags: [noStrict] ---*/ -var f = Function("\"use strict\";\ngNonStrict();"); +var f = SendableFunction("\"use strict\";\ngNonStrict();"); assert.throws(TypeError, function() { f(); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-90gs.js b/test/sendable/builtins/Function/15.3.5.4_2-90gs.js index 3729c54c750..f2204e7ce9c 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-90gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-90gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-90gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.bind(null)()) + strict SendableFunction.prototype.bind(null)()) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-91gs.js b/test/sendable/builtins/Function/15.3.5.4_2-91gs.js index b3580b3f687..fae7b3935c1 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-91gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-91gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-91gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.bind(undefined)()) + strict SendableFunction.prototype.bind(undefined)()) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-92gs.js b/test/sendable/builtins/Function/15.3.5.4_2-92gs.js index b166d801684..a6999f77f54 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-92gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-92gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-92gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.bind(someObject)()) + strict SendableFunction.prototype.bind(someObject)()) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-93gs.js b/test/sendable/builtins/Function/15.3.5.4_2-93gs.js index de03042fffc..1b3a3dc2b2e 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-93gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-93gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-93gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict Function.prototype.bind(globalObject)()) + strict SendableFunction.prototype.bind(globalObject)()) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-94gs.js b/test/sendable/builtins/Function/15.3.5.4_2-94gs.js index a816af828a1..50edf804fc8 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-94gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-94gs.js @@ -17,7 +17,7 @@ es5id: 15.3.5.4_2-94gs description: > Strict mode - checking access to strict function caller from - non-strict function expression (FunctionDeclaration includes + non-strict function expression (SendableFunctionDeclaration includes strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-95gs.js b/test/sendable/builtins/Function/15.3.5.4_2-95gs.js index 1e3fdc02a48..f0bc503587e 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-95gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-95gs.js @@ -17,12 +17,12 @@ es5id: 15.3.5.4_2-95gs description: > Strict mode - checking access to strict function caller from - non-strict, constructor-based function (FunctionDeclaration + non-strict, constructor-based function (SendableFunctionDeclaration includes strict directive prologue) flags: [noStrict] ---*/ -var gNonStrict = Function("return gNonStrict.caller || gNonStrict.caller.throwTypeError;"); +var gNonStrict = SendableFunction("return gNonStrict.caller || gNonStrict.caller.throwTypeError;"); function f() { "use strict"; diff --git a/test/sendable/builtins/Function/15.3.5.4_2-96gs.js b/test/sendable/builtins/Function/15.3.5.4_2-96gs.js index e6709fdf586..6eead365daf 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-96gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-96gs.js @@ -17,7 +17,7 @@ es5id: 15.3.5.4_2-96gs description: > Strict mode - checking access to strict function caller from - non-strict property (FunctionDeclaration includes strict directive + non-strict property (SendableFunctionDeclaration includes strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-97gs.js b/test/sendable/builtins/Function/15.3.5.4_2-97gs.js index 8dd7945eff6..79395366306 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-97gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-97gs.js @@ -17,7 +17,7 @@ es5id: 15.3.5.4_2-97gs description: > Strict mode - checking access to strict function caller from bound - non-strict function (FunctionDeclaration includes strict directive + non-strict function (SendableFunctionDeclaration includes strict directive prologue) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-9gs.js b/test/sendable/builtins/Function/15.3.5.4_2-9gs.js index 57d79876d77..7a7640ce704 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-9gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-9gs.js @@ -17,12 +17,12 @@ es5id: 15.3.5.4_2-9gs description: > Strict mode - checking access to non-strict function caller from - strict function (New'ed Function constructor defined within strict + strict function (New'ed SendableFunction constructor defined within strict mode) flags: [onlyStrict] ---*/ -var f = new Function("return gNonStrict();"); +var f = new SendableFunction("return gNonStrict();"); assert.throws(TypeError, function() { f(); diff --git a/test/sendable/builtins/Function/S10.1.1_A1_T3.js b/test/sendable/builtins/Function/S10.1.1_A1_T3.js index 8220904627b..77690f01832 100644 --- a/test/sendable/builtins/Function/S10.1.1_A1_T3.js +++ b/test/sendable/builtins/Function/S10.1.1_A1_T3.js @@ -15,11 +15,11 @@ /*--- info: | - Program functions are defined in source text by a FunctionDeclaration or created dynamically either - by using a FunctionExpression or by using the built-in Function object as a constructor + Program functions are defined in source text by a SendableFunctionDeclaration or created dynamically either + by using a SendableFunctionExpression or by using the built-in SendableFunction object as a constructor es5id: 10.1.1_A1_T3 description: > - Creating function dynamically by using the built-in Function + Creating function dynamically by using the built-in SendableFunction object as a constructor ---*/ diff --git a/test/sendable/builtins/Function/S15.3.1_A1_T1.js b/test/sendable/builtins/Function/S15.3.1_A1_T1.js index 87fea80bcf4..db0d1bd6e4c 100644 --- a/test/sendable/builtins/Function/S15.3.1_A1_T1.js +++ b/test/sendable/builtins/Function/S15.3.1_A1_T1.js @@ -15,20 +15,20 @@ /*--- info: | - The function call Function(…) is equivalent to the object creation expression - new Function(…) with the same arguments. + The function call SendableFunction(…) is equivalent to the object creation expression + new SendableFunction(…) with the same arguments. es5id: 15.3.1_A1_T1 description: Create simple functions and check returned values ---*/ -var f = Function("return arguments[0];"); +var f = SendableFunction("return arguments[0];"); -assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); assert.sameValue(f(1), 1, 'f(1) must return 1'); -var g = new Function("return arguments[0];"); +var g = new SendableFunction("return arguments[0];"); -assert(g instanceof Function, 'The result of evaluating (g instanceof Function) is expected to be true'); +assert(g instanceof SendableFunction, 'The result of evaluating (g instanceof SendableFunction) is expected to be true'); assert.sameValue(g("A"), "A", 'g("A") must return "A"'); assert.sameValue(g("A"), f("A"), 'g("A") must return the same value returned by f("A")'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T1.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T1.js index 0fa5fc7bab5..036827638e1 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T1.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T1.js @@ -15,11 +15,11 @@ /*--- info: | - When the Function constructor is called with one argument then body be that argument and the following steps are taken: + When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception - iii) If body is not parsable as FunctionBody then throw a SyntaxError exception - iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T1 @@ -33,8 +33,8 @@ var body = { } try { - var f = new Function(body); - throw new Test262Error('#1: When the Function constructor is called with one argument then body be that argument the following step are taken: call ToString(body)'); + var f = new SendableFunction(body); + throw new Test262Error('#1: When the SendableFunction constructor is called with one argument then body be that argument the following step are taken: call ToString(body)'); } catch (e) { assert.sameValue(e, 7, 'The value of e is expected to be 7'); } diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T10.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T10.js index 4f3bf9fc4cf..a282520f0d5 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T10.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T10.js @@ -15,11 +15,11 @@ /*--- info: | - When the Function constructor is called with one argument then body be that argument and the following steps are taken: + When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception - iii) If body is not parsable as FunctionBody then throw a SyntaxError exception - iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T10 @@ -27,10 +27,10 @@ description: Value of the function constructor argument is "null" ---*/ try { - var f = new Function(null); + var f = new SendableFunction(null); } catch (e) { throw new Test262Error('#1: test fails with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T11.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T11.js index 81fb402ed10..c69a6d7ee81 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T11.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T11.js @@ -15,11 +15,11 @@ /*--- info: | - When the Function constructor is called with one argument then body be that argument and the following steps are taken: + When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception - iii) If body is not parsable as FunctionBody then throw a SyntaxError exception - iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T11 @@ -27,10 +27,10 @@ description: Value of the function constructor argument is "undefined" ---*/ try { - var f = new Function(undefined); + var f = new SendableFunction(undefined); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T12.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T12.js index 0d985c857f1..42c16d8bbd9 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T12.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T12.js @@ -15,11 +15,11 @@ /*--- info: | - When the Function constructor is called with one argument then body be that argument and the following steps are taken: + When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception - iii) If body is not parsable as FunctionBody then throw a SyntaxError exception - iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T12 @@ -27,10 +27,10 @@ description: Value of the function constructor argument is "void 0" ---*/ try { - var f = new Function(void 0); + var f = new SendableFunction(void 0); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T13.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T13.js index d95a49b0ea0..201f2c77bdb 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T13.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T13.js @@ -15,11 +15,11 @@ /*--- info: | - When the Function constructor is called with one argument then body be that argument and the following steps are taken: + When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception - iii) If body is not parsable as FunctionBody then throw a SyntaxError exception - iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T13 @@ -27,7 +27,7 @@ description: Value of the function constructor argument is "{}" ---*/ try { - var f = new Function({}); + var f = new SendableFunction({}); throw new Test262Error('#1: test failed with error ' + e); } catch (e) { assert( diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T2.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T2.js index aec17534493..3b3e7c137ee 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T2.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T2.js @@ -15,11 +15,11 @@ /*--- info: | - When the Function constructor is called with one argument then body be that argument and the following steps are taken: + When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception - iii) If body is not parsable as FunctionBody then throw a SyntaxError exception - iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T2 @@ -35,10 +35,10 @@ var body = { }; try { - var f = new Function(body); + var f = new SendableFunction(body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), 1, 'f() must return 1'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T3.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T3.js index 6ddd1c5c99b..2d401bc09c9 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T3.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T3.js @@ -15,11 +15,11 @@ /*--- info: | - When the Function constructor is called with one argument then body be that argument and the following steps are taken: + When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception - iii) If body is not parsable as FunctionBody then throw a SyntaxError exception - iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T3 @@ -27,10 +27,10 @@ description: Value of the function constructor argument is 1 ---*/ try { - var f = new Function(1); + var f = new SendableFunction(1); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T4.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T4.js index 0179a8b11a6..349682f243e 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T4.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T4.js @@ -15,11 +15,11 @@ /*--- info: | - When the Function constructor is called with one argument then body be that argument and the following steps are taken: + When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception - iii) If body is not parsable as FunctionBody then throw a SyntaxError exception - iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T4 @@ -29,12 +29,12 @@ description: > ---*/ try { - var f = new Function(x); + var f = new SendableFunction(x); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); var x; diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T5.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T5.js index 54f6b032568..3c503ce1f8a 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T5.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T5.js @@ -15,11 +15,11 @@ /*--- info: | - When the Function constructor is called with one argument then body be that argument and the following steps are taken: + When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception - iii) If body is not parsable as FunctionBody then throw a SyntaxError exception - iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T5 @@ -31,10 +31,10 @@ description: > var body = Object("return \'A\'"); try { - var f = new Function(body); + var f = new SendableFunction(body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), "\u0041", 'f() must return "u0041"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T6.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T6.js index 1e0df1316cb..161f61aa7b8 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T6.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T6.js @@ -15,11 +15,11 @@ /*--- info: | - When the Function constructor is called with one argument then body be that argument and the following steps are taken: + When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception - iii) If body is not parsable as FunctionBody then throw a SyntaxError exception - iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T6 @@ -29,10 +29,10 @@ description: > ---*/ try { - var f = new Function("return true;"); + var f = new SendableFunction("return true;"); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert(f(), 'f() must return true'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T7.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T7.js index 2641c8a8192..7fe77c5e88b 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T7.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T7.js @@ -15,11 +15,11 @@ /*--- info: | - When the Function constructor is called with one argument then body be that argument and the following steps are taken: + When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception - iii) If body is not parsable as FunctionBody then throw a SyntaxError exception - iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T7 @@ -29,10 +29,10 @@ description: Value of the function constructor argument is "Object(1)" var body = new Object(1); try { - var f = new Function(body); + var f = new SendableFunction(body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T8.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T8.js index 2bdb4c73664..cd95bd15372 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T8.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T8.js @@ -15,11 +15,11 @@ /*--- info: | - When the Function constructor is called with one argument then body be that argument and the following steps are taken: + When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception - iii) If body is not parsable as FunctionBody then throw a SyntaxError exception - iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T8 @@ -29,8 +29,8 @@ description: Value of the function constructor argument is "var 1=1;" var body = "var 1=1;"; try { - var f = new Function(body); - throw new Test262Error('#1: If body is not parsable as FunctionBody then throw a SyntaxError exception'); + var f = new SendableFunction(body); + throw new Test262Error('#1: If body is not parsable as SendableFunctionBody then throw a SyntaxError exception'); } catch (e) { assert( e instanceof SyntaxError, diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T9.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T9.js index be9d46a4e5d..ffade3d3ef6 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T9.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T9.js @@ -15,11 +15,11 @@ /*--- info: | - When the Function constructor is called with one argument then body be that argument and the following steps are taken: + When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception - iii) If body is not parsable as FunctionBody then throw a SyntaxError exception - iv) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody. + iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T9 @@ -28,7 +28,7 @@ description: > arguments[0];" ---*/ -var f = new Function("return arguments[0];"); +var f = new SendableFunction("return arguments[0];"); -assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); assert.sameValue(f("A"), "A", 'f("A") must return "A"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T1.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T1.js index 156a1a79301..c9b55e7aa17 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A2_T1.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T1.js @@ -24,10 +24,10 @@ description: > ---*/ try { - var f = Function("arg1", "arg2", "arg3", "return arg1+arg2+arg3;"); + var f = SendableFunction("arg1", "arg2", "arg3", "return arg1+arg2+arg3;"); } catch (e) { throw new Test262Error('#1: test failed'); } -assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); assert.sameValue(f(1, 2, 3), 6, 'f(1, 2, 3) must return 6'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T2.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T2.js index 3591163ab75..f155d32ccd1 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A2_T2.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T2.js @@ -24,10 +24,10 @@ description: > ---*/ try { - var f = Function("arg1, arg2", "arg3", "return arg1+arg2+arg3;"); + var f = SendableFunction("arg1, arg2", "arg3", "return arg1+arg2+arg3;"); } catch (e) { throw new Test262Error('#1: test failed'); } -assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); assert.sameValue(f("AB", "BA", 1), "ABBA1", 'f(AB, BA, 1) must return "ABBA1"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T3.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T3.js index a7798eda702..ae6d79a0f35 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A2_T3.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T3.js @@ -24,10 +24,10 @@ description: > ---*/ try { - var f = Function("arg1, arg2, arg3", "return arg1+arg2+arg3;"); + var f = SendableFunction("arg1, arg2, arg3", "return arg1+arg2+arg3;"); } catch (e) { throw new Test262Error('#1: test failed'); } -assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); assert.sameValue(f(1, 1, "ABBA"), "2ABBA", 'f(1, 1, ABBA) must return "2ABBA"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T4.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T4.js index cb9803294b5..bcb20ed891e 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A2_T4.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T4.js @@ -32,10 +32,10 @@ var p = { }; try { - var f = Function(p, p, p, "return arg1+arg2+arg3;"); + var f = SendableFunction(p, p, p, "return arg1+arg2+arg3;"); } catch (e) { throw new Test262Error('#1: test failed'); } -assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); assert.sameValue(f(4, "2", "QUESTION"), "42QUESTION", 'f(4, 2, QUESTION) must return "42QUESTION"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T5.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T5.js index 72b1c0cc831..51cc4dccf4d 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A2_T5.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T5.js @@ -32,10 +32,10 @@ var p = { }; try { - var f = Function(p + "," + p, p, "return arg1+arg2+arg3;"); + var f = SendableFunction(p + "," + p, p, "return arg1+arg2+arg3;"); } catch (e) { throw new Test262Error('#1: test failed'); } -assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); assert.sameValue(f("", 1, 2), "12", 'f(, 1, 2) must return "12"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T6.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T6.js index c1a8b578bec..b4e77f4c6d2 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A2_T6.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T6.js @@ -32,10 +32,10 @@ var p = { }; try { - var f = Function(p + "," + p + "," + p, "return arg1+arg2+arg3;"); + var f = SendableFunction(p + "," + p + "," + p, "return arg1+arg2+arg3;"); } catch (e) { throw new Test262Error('#1: test failed'); } -assert(f instanceof Function, 'The result of evaluating (f instanceof Function) is expected to be true'); +assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); assert.sameValue(f("", 1, p), "1arg4", 'f(, 1, {toString: function() {return "arg" + (++i)}}) must return "1arg4"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T1.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T1.js index 01cee6d75f0..7a2605aa505 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T1.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T1.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T1 @@ -43,7 +43,7 @@ var body = { }; try { - var f = new Function(p, body); + var f = new SendableFunction(p, body); throw new Test262Error('#1: test failed'); } catch (e) { assert.sameValue(e, 1, 'The value of e is expected to be 1'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T10.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T10.js index fe4e55bf5d1..6f511dc3963 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T10.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T10.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T10 @@ -38,7 +38,7 @@ var p = { }; try { - var f = new Function(p, body); + var f = new SendableFunction(p, body); throw new Test262Error('#1: If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception'); } catch (e) { assert( diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T11.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T11.js index eb10b2dd887..4e9a356be07 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T11.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T11.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T11 @@ -33,10 +33,10 @@ description: > var p = "a,b,c"; try { - var f = new Function(p, void 0); + var f = new SendableFunction(p, void 0); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T12.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T12.js index 7daf65b866b..5a6196d4fdf 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T12.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T12.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T12 @@ -33,10 +33,10 @@ description: > var p = "a,b,c"; try { - var f = new Function(p, undefined); + var f = new SendableFunction(p, undefined); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T13.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T13.js index c60ae2aaa9c..1224b345a40 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T13.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T13.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T13 @@ -31,10 +31,10 @@ description: Values of the function constructor arguments are "a,b,c" and "null" var p = "a,b,c"; try { - var f = new Function(p, null); + var f = new SendableFunction(p, null); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T14.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T14.js index b2980b58186..c17fd741697 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T14.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T14.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T14 @@ -33,12 +33,12 @@ description: > var p = "a,b,c"; try { - var f = new Function(p, body); + var f = new SendableFunction(p, body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); var body; diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T15.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T15.js index 58fe26587d0..954077a485a 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T15.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T15.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T15 @@ -31,10 +31,10 @@ description: > ---*/ try { - var f = new Function("", ""); + var f = new SendableFunction("", ""); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T2.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T2.js index ec3fd64d9c9..9f4011af8b7 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T2.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T2.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T2 @@ -38,10 +38,10 @@ var p = { var body = "return a;"; try { - var f = new Function(p, body); + var f = new SendableFunction(p, body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(42), 42, 'f(42) must return 42'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T3.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T3.js index 45c9be817f7..d38b9091160 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T3.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T3.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T3 @@ -44,7 +44,7 @@ var body = { }; try { - var f = new Function(p, body); + var f = new SendableFunction(p, body); throw new Test262Error('#1: test failed'); } catch (e) { assert.sameValue(e, "body", 'The value of e is expected to be "body"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T4.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T4.js index a86ac076c2c..e7a133c89e4 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T4.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T4.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T4 @@ -33,12 +33,12 @@ description: > var body = "return 1.1;"; try { - var f = new Function(p, body); + var f = new SendableFunction(p, body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), 1.1, 'f() must return 1.1'); var p; diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T5.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T5.js index e3d4994f21d..12d02b65758 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T5.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T5.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T5 @@ -33,10 +33,10 @@ description: > var body = "return \"A\";"; try { - var f = new Function(void 0, body); + var f = new SendableFunction(void 0, body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), '\u0041', 'f() must return "u0041"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T6.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T6.js index 48b0336796f..d7b3ccd34d7 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T6.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T6.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T6 @@ -33,7 +33,7 @@ description: > var body = "return true;"; try { - var f = new Function(null, body); + var f = new SendableFunction(null, body); throw new Test262Error('#1: If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception'); } catch (e) { assert( diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T7.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T7.js index 59be1d7b977..11b86b39c8e 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T7.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T7.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T7 @@ -35,10 +35,10 @@ var body = "return a;"; var p = Object("a"); try { - var f = new Function(p, body); + var f = new SendableFunction(p, body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(1), 1, 'f(1) must return 1'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T8.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T8.js index 47940b7500d..017d36aa068 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T8.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T8.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T8 @@ -33,10 +33,10 @@ description: > var body = "return this;"; try { - var f = new Function(undefined, body); + var f = new SendableFunction(undefined, body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.sameValue(f(), this, 'f() must return this'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T9.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T9.js index d358f33f93d..9d795ccd535 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T9.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T9.js @@ -15,13 +15,13 @@ /*--- info: | - When the Function constructor is called with arguments p, body the following steps are taken: + When the SendableFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception - v) If body is not parsable as FunctionBody then throw a SyntaxError exception - vi) Create a new Function object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a FunctionBody + v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception + vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T9 @@ -34,7 +34,7 @@ var body = "return this;"; var p = "1,1"; try { - var f = new Function(p, body); + var f = new SendableFunction(p, body); throw new Test262Error('#1: If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception'); } catch (e) { assert( diff --git a/test/sendable/builtins/Function/S15.3.2_A1.js b/test/sendable/builtins/Function/S15.3.2_A1.js index 6513f67e172..79827877c52 100644 --- a/test/sendable/builtins/Function/S15.3.2_A1.js +++ b/test/sendable/builtins/Function/S15.3.2_A1.js @@ -15,15 +15,15 @@ /*--- info: | - When Function is called as part of a new expression, it is a constructor: + When SendableFunction is called as part of a new expression, it is a constructor: it initialises the newly created object es5id: 15.3.2_A1 description: > Checking the constuctor of the object that is created as a new - Function + SendableFunction ---*/ -var f = new Function; +var f = new SendableFunction; -assert.sameValue(f.constructor, Function, 'The value of f.constructor is expected to equal the value of Function'); +assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); assert.notSameValue(f, undefined, 'The value of f is expected to not equal ``undefined``'); diff --git a/test/sendable/builtins/Function/S15.3.3_A1.js b/test/sendable/builtins/Function/S15.3.3_A1.js index 2075957060a..f32bd0d0446 100644 --- a/test/sendable/builtins/Function/S15.3.3_A1.js +++ b/test/sendable/builtins/Function/S15.3.3_A1.js @@ -14,8 +14,8 @@ */ /*--- -info: The Function constructor has the property "prototype" +info: The SendableFunction constructor has the property "prototype" es5id: 15.3.3_A1 description: Checking existence of the property "prototype" ---*/ -assert(Function.hasOwnProperty("prototype"), 'Function.hasOwnProperty("prototype") must return true'); +assert(SendableFunction.hasOwnProperty("prototype"), 'SendableFunction.hasOwnProperty("prototype") must return true'); diff --git a/test/sendable/builtins/Function/S15.3.3_A2_T1.js b/test/sendable/builtins/Function/S15.3.3_A2_T1.js index 4ce15eb77ed..543448e5194 100644 --- a/test/sendable/builtins/Function/S15.3.3_A2_T1.js +++ b/test/sendable/builtins/Function/S15.3.3_A2_T1.js @@ -15,12 +15,12 @@ /*--- info: | - The value of the internal [[Prototype]] property of the Function constructor - is the Function prototype object + The value of the internal [[Prototype]] property of the SendableFunction constructor + is the SendableFunction prototype object es5id: 15.3.3_A2_T1 -description: Checking prototype of Function +description: Checking prototype of SendableFunction ---*/ assert( - Function.prototype.isPrototypeOf(Function), - 'Function.prototype.isPrototypeOf(Function) must return true' + SendableFunction.prototype.isPrototypeOf(SendableFunction), + 'SendableFunction.prototype.isPrototypeOf(SendableFunction) must return true' ); diff --git a/test/sendable/builtins/Function/S15.3.3_A2_T2.js b/test/sendable/builtins/Function/S15.3.3_A2_T2.js index f7e2fecda49..3b9edaa2b19 100644 --- a/test/sendable/builtins/Function/S15.3.3_A2_T2.js +++ b/test/sendable/builtins/Function/S15.3.3_A2_T2.js @@ -15,12 +15,12 @@ /*--- info: | - The value of the internal [[Prototype]] property of the Function constructor - is the Function prototype object + The value of the internal [[Prototype]] property of the SendableFunction constructor + is the SendableFunction prototype object es5id: 15.3.3_A2_T2 -description: Add new property to Function.prototype and check it +description: Add new property to SendableFunction.prototype and check it ---*/ -Function.prototype.indicator = 1; +SendableFunction.prototype.indicator = 1; -assert.sameValue(Function.indicator, 1, 'The value of Function.indicator is expected to be 1'); +assert.sameValue(SendableFunction.indicator, 1, 'The value of SendableFunction.indicator is expected to be 1'); diff --git a/test/sendable/builtins/Function/S15.3.3_A3.js b/test/sendable/builtins/Function/S15.3.3_A3.js index a07ea56e8bf..76765cc9961 100644 --- a/test/sendable/builtins/Function/S15.3.3_A3.js +++ b/test/sendable/builtins/Function/S15.3.3_A3.js @@ -14,9 +14,9 @@ */ /*--- -info: Function constructor has length property whose value is 1 +info: SendableFunction constructor has length property whose value is 1 es5id: 15.3.3_A3 -description: Checking Function.length property +description: Checking SendableFunction.length property ---*/ -assert(Function.hasOwnProperty("length"), 'Function.hasOwnProperty("length") must return true'); -assert.sameValue(Function.length, 1, 'The value of Function.length is expected to be 1'); +assert(SendableFunction.hasOwnProperty("length"), 'SendableFunction.hasOwnProperty("length") must return true'); +assert.sameValue(SendableFunction.length, 1, 'The value of SendableFunction.length is expected to be 1'); diff --git a/test/sendable/builtins/Function/S15.3.5_A1_T1.js b/test/sendable/builtins/Function/S15.3.5_A1_T1.js index f91f2aaaf18..e040c973810 100644 --- a/test/sendable/builtins/Function/S15.3.5_A1_T1.js +++ b/test/sendable/builtins/Function/S15.3.5_A1_T1.js @@ -14,15 +14,15 @@ */ /*--- -info: The value of the [[Class]] property is "Function" +info: The value of the [[Class]] property is "SendableFunction" es5id: 15.3.5_A1_T1 -description: For testing use variable f = new Function +description: For testing use variable f = new SendableFunction ---*/ -var f = new Function; +var f = new SendableFunction; assert.sameValue( Object.prototype.toString.call(f), - "[object Function]", - 'Object.prototype.toString.call(new Function) must return "[object Function]"' + "[object SendableFunction]", + 'Object.prototype.toString.call(new SendableFunction) must return "[object SendableFunction]"' ); diff --git a/test/sendable/builtins/Function/S15.3.5_A1_T2.js b/test/sendable/builtins/Function/S15.3.5_A1_T2.js index 7eddc7c5973..89c5db8eddd 100644 --- a/test/sendable/builtins/Function/S15.3.5_A1_T2.js +++ b/test/sendable/builtins/Function/S15.3.5_A1_T2.js @@ -14,15 +14,15 @@ */ /*--- -info: The value of the [[Class]] property is "Function" +info: The value of the [[Class]] property is "SendableFunction" es5id: 15.3.5_A1_T2 -description: For testing use variable f = Function() +description: For testing use variable f = SendableFunction() ---*/ -var f = Function(); +var f = SendableFunction(); assert.sameValue( Object.prototype.toString.call(f), - "[object Function]", - 'Object.prototype.toString.call(Function()) must return "[object Function]"' + "[object SendableFunction]", + 'Object.prototype.toString.call(SendableFunction()) must return "[object SendableFunction]"' ); diff --git a/test/sendable/builtins/Function/S15.3.5_A2_T1.js b/test/sendable/builtins/Function/S15.3.5_A2_T1.js index b93ea5b7b96..d3f637a6b28 100644 --- a/test/sendable/builtins/Function/S15.3.5_A2_T1.js +++ b/test/sendable/builtins/Function/S15.3.5_A2_T1.js @@ -16,12 +16,12 @@ /*--- info: Every function instance has a [[Call]] property es5id: 15.3.5_A2_T1 -description: For testing call Function("var x =1; this.y=2;return \"OK\";")() +description: For testing call SendableFunction("var x =1; this.y=2;return \"OK\";")() ---*/ assert.sameValue( - Function("var x =1; this.y=2;return \"OK\";")(), + SendableFunction("var x =1; this.y=2;return \"OK\";")(), "OK", - 'Function("var x =1; this.y=2;return "OK";")() must return "OK"' + 'SendableFunction("var x =1; this.y=2;return "OK";")() must return "OK"' ); assert.sameValue(typeof x, "undefined", 'The value of `typeof x` is expected to be "undefined"'); diff --git a/test/sendable/builtins/Function/S15.3.5_A2_T2.js b/test/sendable/builtins/Function/S15.3.5_A2_T2.js index a4ee27beb26..4b0257098dd 100644 --- a/test/sendable/builtins/Function/S15.3.5_A2_T2.js +++ b/test/sendable/builtins/Function/S15.3.5_A2_T2.js @@ -17,13 +17,13 @@ info: Every function instance has a [[Call]] property es5id: 15.3.5_A2_T2 description: > - For testing call (new Function("arg1,arg2","var x =arg1; + For testing call (new SendableFunction("arg1,arg2","var x =arg1; this.y=arg2;return arg1+arg2;"))("1",2) ---*/ assert.sameValue( - (new Function("arg1,arg2", "var x =arg1; this.y=arg2;return arg1+arg2;"))("1", 2), + (new SendableFunction("arg1,arg2", "var x =arg1; this.y=arg2;return arg1+arg2;"))("1", 2), "12", - 'new Function("arg1,arg2", "var x =arg1; this.y=arg2;return arg1+arg2;")(1, 2) must return "12"' + 'new SendableFunction("arg1,arg2", "var x =arg1; this.y=arg2;return arg1+arg2;")(1, 2) must return "12"' ); assert.sameValue(typeof x, "undefined", 'The value of `typeof x` is expected to be "undefined"'); diff --git a/test/sendable/builtins/Function/S15.3.5_A3_T1.js b/test/sendable/builtins/Function/S15.3.5_A3_T1.js index b4a7adc6db6..bded8798aa0 100644 --- a/test/sendable/builtins/Function/S15.3.5_A3_T1.js +++ b/test/sendable/builtins/Function/S15.3.5_A3_T1.js @@ -16,10 +16,10 @@ /*--- info: every function instance has a [[Construct]] property es5id: 15.3.5_A3_T1 -description: As constructor use Function("var x =1; this.y=2;return \"OK\";") +description: As constructor use SendableFunction("var x =1; this.y=2;return \"OK\";") ---*/ -var FACTORY = Function("var x =1; this.y=2;return \"OK\";"); +var FACTORY = SendableFunction("var x =1; this.y=2;return \"OK\";"); var obj = new FACTORY; assert.sameValue(typeof obj, "object", 'The value of `typeof obj` is expected to be "object"'); diff --git a/test/sendable/builtins/Function/S15.3.5_A3_T2.js b/test/sendable/builtins/Function/S15.3.5_A3_T2.js index e62997cf593..21b6c83a750 100644 --- a/test/sendable/builtins/Function/S15.3.5_A3_T2.js +++ b/test/sendable/builtins/Function/S15.3.5_A3_T2.js @@ -17,11 +17,11 @@ info: every function instance has a [[Construct]] property es5id: 15.3.5_A3_T2 description: > - As constructor use new Function("arg1,arg2","var x =1; + As constructor use new SendableFunction("arg1,arg2","var x =1; this.y=arg1+arg2;return \"OK\";") ---*/ -var FACTORY = new Function("arg1,arg2", "var x =1; this.y=arg1+arg2;return \"OK\";"); +var FACTORY = new SendableFunction("arg1,arg2", "var x =1; this.y=arg1+arg2;return \"OK\";"); var obj = new FACTORY("1", 2); assert.sameValue(typeof obj, "object", 'The value of `typeof obj` is expected to be "object"'); diff --git a/test/sendable/builtins/Function/S15.3_A1.js b/test/sendable/builtins/Function/S15.3_A1.js index 253c26818b3..51f0908cd94 100644 --- a/test/sendable/builtins/Function/S15.3_A1.js +++ b/test/sendable/builtins/Function/S15.3_A1.js @@ -14,13 +14,13 @@ */ /*--- -info: Function is the property of global +info: SendableFunction is the property of global es5id: 15.3_A1 -description: Compare Function with this.Function +description: Compare SendableFunction with this.SendableFunction ---*/ -var obj = Function; +var obj = SendableFunction; -var thisobj = this.Function; +var thisobj = this.SendableFunction; assert.sameValue(obj, thisobj, 'The value of obj is expected to equal the value of thisobj'); diff --git a/test/sendable/builtins/Function/S15.3_A2_T1.js b/test/sendable/builtins/Function/S15.3_A2_T1.js index 485d1dca6a5..a883f93a55e 100644 --- a/test/sendable/builtins/Function/S15.3_A2_T1.js +++ b/test/sendable/builtins/Function/S15.3_A2_T1.js @@ -15,15 +15,15 @@ /*--- info: | - Since applying the "call" method to Function constructor themself leads + Since applying the "call" method to SendableFunction constructor themself leads to creating a new function instance, the second argument must be a valid function body es5id: 15.3_A2_T1 -description: Checking if executing "Function.call(this, "var x / = 1;")" fails +description: Checking if executing "SendableFunction.call(this, "var x / = 1;")" fails ---*/ try { - Function.call(this, "var x / = 1;"); + SendableFunction.call(this, "var x / = 1;"); } catch (e) { assert( e instanceof SyntaxError, diff --git a/test/sendable/builtins/Function/S15.3_A2_T2.js b/test/sendable/builtins/Function/S15.3_A2_T2.js index 5fca2f5a276..7e71a0180fe 100644 --- a/test/sendable/builtins/Function/S15.3_A2_T2.js +++ b/test/sendable/builtins/Function/S15.3_A2_T2.js @@ -15,15 +15,15 @@ /*--- info: | - Since applying the "call" method to Function constructor themself leads + Since applying the "call" method to SendableFunction constructor themself leads to creating a new function instance, the second argument must be a valid function body es5id: 15.3_A2_T2 -description: Checking if executing "Function.call(this, "var #x = 1;")" fails +description: Checking if executing "SendableFunction.call(this, "var #x = 1;")" fails ---*/ try { - Function.call(this, "var #x = 1;"); + SendableFunction.call(this, "var #x = 1;"); } catch (e) { assert( e instanceof SyntaxError, diff --git a/test/sendable/builtins/Function/S15.3_A3_T1.js b/test/sendable/builtins/Function/S15.3_A3_T1.js index f4ca7c1cf0a..61483e38dce 100644 --- a/test/sendable/builtins/Function/S15.3_A3_T1.js +++ b/test/sendable/builtins/Function/S15.3_A3_T1.js @@ -15,25 +15,25 @@ /*--- info: | - Since when call is used for Function constructor themself new function instance creates + Since when call is used for SendableFunction constructor themself new function instance creates and then first argument(thisArg) should be ignored es5id: 15.3_A3_T1 description: First argument is object ---*/ -var f = Function.call(mars, "return name;"); +var f = SendableFunction.call(mars, "return name;"); var mars = { name: "mars", color: "red", number: 4 }; -var f = Function.call(mars, "this.godname=\"ares\"; return this.color;"); +var f = SendableFunction.call(mars, "this.godname=\"ares\"; return this.color;"); var about_mars = f(); assert.sameValue(about_mars, undefined); if (this.godname !== "ares" && mars.godname === undefined) { - throw new Test262Error('#3: When applied to the Function object itself, thisArg should be ignored'); + throw new Test262Error('#3: When applied to the SendableFunction object itself, thisArg should be ignored'); } diff --git a/test/sendable/builtins/Function/S15.3_A3_T2.js b/test/sendable/builtins/Function/S15.3_A3_T2.js index 3ade114b93b..5c8a30ce622 100644 --- a/test/sendable/builtins/Function/S15.3_A3_T2.js +++ b/test/sendable/builtins/Function/S15.3_A3_T2.js @@ -15,7 +15,7 @@ /*--- info: | - Since when call is used for Function constructor themself new function instance creates + Since when call is used for SendableFunction constructor themself new function instance creates and then first argument(thisArg) should be ignored es5id: 15.3_A3_T2 description: First argument is string and null @@ -24,10 +24,10 @@ description: First argument is string and null this.color = "red"; var planet = "mars"; -var f = Function.call("blablastring", "return this.color;"); +var f = SendableFunction.call("blablastring", "return this.color;"); assert.sameValue(f(), "red", 'f() must return "red"'); -var g = Function.call(null, "return this.planet;"); +var g = SendableFunction.call(null, "return this.planet;"); assert.sameValue(g(), "mars", 'g() must return "mars"'); diff --git a/test/sendable/builtins/Function/S15.3_A3_T3.js b/test/sendable/builtins/Function/S15.3_A3_T3.js index e1973116335..0b8fa17d588 100644 --- a/test/sendable/builtins/Function/S15.3_A3_T3.js +++ b/test/sendable/builtins/Function/S15.3_A3_T3.js @@ -15,14 +15,14 @@ /*--- info: | - Since when call is used for Function constructor themself new function instance creates + Since when call is used for SendableFunction constructor themself new function instance creates and then first argument(thisArg) should be ignored es5id: 15.3_A3_T3 description: First argument is this, and this don`t have needed variable ---*/ -var f = Function.call(this, "return planet;"); -var g = Function.call(this, "return color;"); +var f = SendableFunction.call(this, "return planet;"); +var g = SendableFunction.call(this, "return color;"); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3_A3_T4.js b/test/sendable/builtins/Function/S15.3_A3_T4.js index 572bb78f713..fbee7178852 100644 --- a/test/sendable/builtins/Function/S15.3_A3_T4.js +++ b/test/sendable/builtins/Function/S15.3_A3_T4.js @@ -15,13 +15,13 @@ /*--- info: | - Since when call is used for Function constructor themself new function instance creates + Since when call is used for SendableFunction constructor themself new function instance creates and then first argument(thisArg) should be ignored es5id: 15.3_A3_T4 description: First argument is this, and this have needed variable ---*/ -var f = Function.call(this, "return planet;"); +var f = SendableFunction.call(this, "return planet;"); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3_A3_T5.js b/test/sendable/builtins/Function/S15.3_A3_T5.js index b4e10b98dfe..9e76f477e3e 100644 --- a/test/sendable/builtins/Function/S15.3_A3_T5.js +++ b/test/sendable/builtins/Function/S15.3_A3_T5.js @@ -15,16 +15,16 @@ /*--- info: | - Since when call is used for Function constructor themself new function instance creates + Since when call is used for SendableFunction constructor themself new function instance creates and then first argument(thisArg) should be ignored es5id: 15.3_A3_T5 description: > First argument is this, and this don`t have needed variable. - Function return this.var_name + SendableFunction return this.var_name ---*/ -var f = Function.call(this, "return this.planet;"); -var g = Function.call(this, "return this.color;"); +var f = SendableFunction.call(this, "return this.planet;"); +var g = SendableFunction.call(this, "return this.color;"); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3_A3_T6.js b/test/sendable/builtins/Function/S15.3_A3_T6.js index 0b6863138b2..08516f7c024 100644 --- a/test/sendable/builtins/Function/S15.3_A3_T6.js +++ b/test/sendable/builtins/Function/S15.3_A3_T6.js @@ -15,15 +15,15 @@ /*--- info: | - Since when call is used for Function constructor themself new function instance creates + Since when call is used for SendableFunction constructor themself new function instance creates and then first argument(thisArg) should be ignored es5id: 15.3_A3_T6 description: > - First argument is this, and this have needed variable. Function + First argument is this, and this have needed variable. SendableFunction return this.var_name ---*/ -var f = Function.call(this, "return this.planet;"); +var f = SendableFunction.call(this, "return this.planet;"); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/StrictFunction_reservedwords_with.js b/test/sendable/builtins/Function/StrictFunction_reservedwords_with.js index b649b9d6b0b..a32c512bc23 100644 --- a/test/sendable/builtins/Function/StrictFunction_reservedwords_with.js +++ b/test/sendable/builtins/Function/StrictFunction_reservedwords_with.js @@ -17,7 +17,7 @@ esid: sec-createdynamicfunction description: Strictfunction shouldn't have the reserved word "with" info: | - CreateDynamicFunction ( constructor, newTarget, kind, args ) + CreateDynamicSendableFunction ( constructor, newTarget, kind, args ) ... 20 Perform the following substeps in an implementation-dependent order, possibly interleaving parsing and error detection: @@ -30,5 +30,5 @@ info: | ---*/ assert.throws(SyntaxError, function() { - new Function("'use strict'; with ({}) {}"); -}, '`new Function("\'use strict\'; with ({}) {}")` throws a SyntaxError exception'); + new SendableFunction("'use strict'; with ({}) {}"); +}, '`new SendableFunction("\'use strict\'; with ({}) {}")` throws a SyntaxError exception'); diff --git a/test/sendable/builtins/Function/StrictFunction_restricted-properties.js b/test/sendable/builtins/Function/StrictFunction_restricted-properties.js index 40101c85382..16e477e3893 100644 --- a/test/sendable/builtins/Function/StrictFunction_restricted-properties.js +++ b/test/sendable/builtins/Function/StrictFunction_restricted-properties.js @@ -15,10 +15,10 @@ /*--- description: > - ECMAScript Function objects defined using syntactic constructors + ECMAScript SendableFunction objects defined using syntactic constructors in strict mode code do not have own properties "caller" or "arguments" other than those that are created by applying the - AddRestrictedFunctionProperties abstract operation to the function. + AddRestrictedSendableFunctionProperties abstract operation to the function. flags: [onlyStrict] es6id: 16.1 ---*/ @@ -41,7 +41,7 @@ assert.throws(TypeError, function() { func.arguments = {}; }, 'func.arguments = {} throws a TypeError exception'); -var newfunc = new Function('"use strict"'); +var newfunc = new SendableFunction('"use strict"'); assert.sameValue(newfunc.hasOwnProperty('caller'), false, 'newfunc.hasOwnProperty(\'caller\') must return false'); assert.sameValue(newfunc.hasOwnProperty('arguments'), false, 'newfunc.hasOwnProperty(\'arguments\') must return false'); diff --git a/test/sendable/builtins/Function/call-bind-this-realm-undef.js b/test/sendable/builtins/Function/call-bind-this-realm-undef.js index c437a87b1b6..6797e84f42b 100644 --- a/test/sendable/builtins/Function/call-bind-this-realm-undef.js +++ b/test/sendable/builtins/Function/call-bind-this-realm-undef.js @@ -35,7 +35,7 @@ features: [cross-realm] ---*/ var other = $262.createRealm().global; -var func = new other.Function('return this;'); +var func = new other.SendableFunction('return this;'); var subject; assert.sameValue(func(), other, 'implicit undefined'); diff --git a/test/sendable/builtins/Function/call-bind-this-realm-value.js b/test/sendable/builtins/Function/call-bind-this-realm-value.js index cb0d8d88029..fd48b529747 100644 --- a/test/sendable/builtins/Function/call-bind-this-realm-value.js +++ b/test/sendable/builtins/Function/call-bind-this-realm-value.js @@ -36,7 +36,7 @@ features: [cross-realm] ---*/ var other = $262.createRealm().global; -var func = new other.Function('return this;'); +var func = new other.SendableFunction('return this;'); var subject; subject = func.call(true); diff --git a/test/sendable/builtins/Function/instance-name.js b/test/sendable/builtins/Function/instance-name.js index 6e21a6b7938..89200bb3ccd 100644 --- a/test/sendable/builtins/Function/instance-name.js +++ b/test/sendable/builtins/Function/instance-name.js @@ -18,17 +18,17 @@ es6id: 19.2.1.1 description: Assignment of function `name` attribute info: | [...] - 3. Return CreateDynamicFunction(C, NewTarget, "normal", args). + 3. Return CreateDynamicSendableFunction(C, NewTarget, "normal", args). ES6 19.2.1.1.1 - RuntimeSemantics: CreateDynamicFunction(constructor, newTarget, kind, args) + RuntimeSemantics: CreateDynamicSendableFunction(constructor, newTarget, kind, args) [...] - 29. Perform SetFunctionName(F, "anonymous"). + 29. Perform SetSendableFunctionName(F, "anonymous"). includes: [propertyHelper.js] ---*/ -assert.sameValue(Function().name, 'anonymous'); -verifyNotEnumerable(Function(), 'name'); -verifyNotWritable(Function(), 'name'); -verifyConfigurable(Function(), 'name'); +assert.sameValue(SendableFunction().name, 'anonymous'); +verifyNotEnumerable(SendableFunction(), 'name'); +verifyNotWritable(SendableFunction(), 'name'); +verifyConfigurable(SendableFunction(), 'name'); diff --git a/test/sendable/builtins/Function/internals/Call/class-ctor.js b/test/sendable/builtins/Function/internals/Call/class-ctor.js index c0ee0b4e583..272a20192cb 100644 --- a/test/sendable/builtins/Function/internals/Call/class-ctor.js +++ b/test/sendable/builtins/Function/internals/Call/class-ctor.js @@ -18,7 +18,7 @@ esid: sec-ecmascript-function-objects-call-thisargument-argumentslist description: Error when invoking a class constructor info: | [...] - 2. If F's [[FunctionKind]] internal slot is "classConstructor", throw a + 2. If F's [[SendableFunctionKind]] internal slot is "classConstructor", throw a TypeError exception. features: [class] ---*/ diff --git a/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js b/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js index 29a337f7784..ce16655db59 100644 --- a/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js +++ b/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js @@ -37,14 +37,14 @@ info: | [...] 3. Let proto be ? Get(constructor, "prototype"). 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). + a. Let realm be ? GetSendableFunctionRealm(constructor). - 7.3.22 GetFunctionRealm + 7.3.22 GetSendableFunctionRealm [...] 2. If obj has a [[Realm]] internal slot, then [...] - 3. If obj is a Bound Function exotic object, then + 3. If obj is a Bound SendableFunction exotic object, then [...] 4. If obj is a Proxy exotic object, then a. If the value of the [[ProxyHandler]] internal slot of obj is null, diff --git a/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy.js b/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy.js index d24aafdc78d..5e25d5ca690 100644 --- a/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy.js +++ b/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy.js @@ -35,14 +35,14 @@ info: | [...] 3. Let proto be ? Get(constructor, "prototype"). 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). + a. Let realm be ? GetSendableFunctionRealm(constructor). - 7.3.22 GetFunctionRealm + 7.3.22 GetSendableFunctionRealm [...] 2. If obj has a [[Realm]] internal slot, then [...] - 3. If obj is a Bound Function exotic object, then + 3. If obj is a Bound SendableFunction exotic object, then [...] 4. If obj is a Proxy exotic object, then a. If the value of the [[ProxyHandler]] internal slot of obj is null, diff --git a/test/sendable/builtins/Function/is-a-constructor.js b/test/sendable/builtins/Function/is-a-constructor.js index aa6495748bb..3201196d805 100644 --- a/test/sendable/builtins/Function/is-a-constructor.js +++ b/test/sendable/builtins/Function/is-a-constructor.js @@ -16,7 +16,7 @@ /*--- esid: sec-ecmascript-standard-built-in-objects description: > - The Function constructor implements [[Construct]] + The SendableFunction constructor implements [[Construct]] info: | IsConstructor ( argument ) @@ -31,6 +31,6 @@ includes: [isConstructor.js] features: [Reflect.construct] ---*/ -assert.sameValue(isConstructor(Function), true, 'isConstructor(Function) must return true'); -new Function(); +assert.sameValue(isConstructor(SendableFunction), true, 'isConstructor(SendableFunction) must return true'); +new SendableFunction(); diff --git a/test/sendable/builtins/Function/length/15.3.3.2-1.js b/test/sendable/builtins/Function/length/15.3.3.2-1.js index ff7801fa56b..6dae554a6f4 100644 --- a/test/sendable/builtins/Function/length/15.3.3.2-1.js +++ b/test/sendable/builtins/Function/length/15.3.3.2-1.js @@ -15,10 +15,10 @@ /*--- es5id: 15.3.3.2-1 -description: Function.length - data property with value 1 +description: SendableFunction.length - data property with value 1 ---*/ -var desc = Object.getOwnPropertyDescriptor(Function, "length"); +var desc = Object.getOwnPropertyDescriptor(SendableFunction, "length"); assert.sameValue(desc.value, 1, 'desc.value'); assert.sameValue(desc.writable, false, 'desc.writable'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T1.js b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T1.js index 01813613fef..8ec8bb559b3 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T1.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T1.js @@ -18,10 +18,10 @@ info: | The value of the length property is usually an integer that indicates the 'typical' number of arguments expected by the function es5id: 15.3.5.1_A1_T1 -description: Checking length property of Function("arg1,arg2,arg3", null) +description: Checking length property of SendableFunction("arg1,arg2,arg3", null) ---*/ -var f = new Function("arg1,arg2,arg3", null); +var f = new SendableFunction("arg1,arg2,arg3", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); assert.sameValue(f.length, 3, 'The value of f.length is expected to be 3'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T2.js b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T2.js index 921f1c2c114..68c1f4abf6c 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T2.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T2.js @@ -19,11 +19,11 @@ info: | 'typical' number of arguments expected by the function es5id: 15.3.5.1_A1_T2 description: > - Checking length property of Function("arg1,arg2,arg3","arg4,arg5", + Checking length property of SendableFunction("arg1,arg2,arg3","arg4,arg5", null) ---*/ -var f = Function("arg1,arg2,arg3", "arg4,arg5", null); +var f = SendableFunction("arg1,arg2,arg3", "arg4,arg5", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); assert.sameValue(f.length, 5, 'The value of f.length is expected to be 5'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T3.js b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T3.js index 4a1aeac6178..4fa866ec129 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T3.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T3.js @@ -20,10 +20,10 @@ info: | es5id: 15.3.5.1_A1_T3 description: > Checking length property of - Function("arg1,arg2,arg3","arg1,arg2","arg3", null) + SendableFunction("arg1,arg2,arg3","arg1,arg2","arg3", null) ---*/ -var f = new Function("arg1,arg2,arg3", "arg1,arg2", "arg3", null); +var f = new SendableFunction("arg1,arg2,arg3", "arg1,arg2", "arg3", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); assert.sameValue(f.length, 6, 'The value of f.length is expected to be 6'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T1.js b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T1.js index 9a268cb0049..f04611aded4 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T1.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T1.js @@ -18,10 +18,10 @@ info: the length property does not have the attributes { DontDelete } es5id: 15.3.5.1_A2_T1 description: > Checking if deleting the length property of - Function("arg1,arg2,arg3", null) succeeds + SendableFunction("arg1,arg2,arg3", null) succeeds ---*/ -var f = new Function("arg1,arg2,arg3", null); +var f = new SendableFunction("arg1,arg2,arg3", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); assert(delete f.length, 'The value of delete f.length is expected to be true'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T2.js b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T2.js index 48c8ec75b51..1d20bc8444b 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T2.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T2.js @@ -18,10 +18,10 @@ info: the length property does not have the attributes { DontDelete } es5id: 15.3.5.1_A2_T2 description: > Checking if deleting the length property of - Function("arg1,arg2,arg3","arg4,arg5", null) succeeds + SendableFunction("arg1,arg2,arg3","arg4,arg5", null) succeeds ---*/ -var f = Function("arg1,arg2,arg3", "arg4,arg5", null); +var f = SendableFunction("arg1,arg2,arg3", "arg4,arg5", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T3.js b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T3.js index fe44fa81543..a3df8795023 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T3.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T3.js @@ -18,10 +18,10 @@ info: the length property does not have the attributes { DontDelete } es5id: 15.3.5.1_A2_T3 description: > Checking if deleting the length property of - Function("arg1,arg2,arg3","arg1,arg2","arg3", null) succeeds + SendableFunction("arg1,arg2,arg3","arg1,arg2","arg3", null) succeeds ---*/ -var f = new Function("arg1,arg2,arg3", "arg1,arg2", "arg3", null); +var f = new SendableFunction("arg1,arg2,arg3", "arg1,arg2", "arg3", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T1.js b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T1.js index e33b1c4680d..aecb2f13029 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T1.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T1.js @@ -18,11 +18,11 @@ info: the length property has the attributes { ReadOnly } es5id: 15.3.5.1_A3_T1 description: > Checking if varying the length property of - Function("arg1,arg2,arg3","arg4,arg5", null) fails + SendableFunction("arg1,arg2,arg3","arg4,arg5", null) fails includes: [propertyHelper.js] ---*/ -var f = new Function("arg1,arg2,arg3", "arg4,arg5", null); +var f = new SendableFunction("arg1,arg2,arg3", "arg4,arg5", null); assert(f.hasOwnProperty('length')); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T2.js b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T2.js index f0312736588..760eeddd457 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T2.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T2.js @@ -18,11 +18,11 @@ info: the length property has the attributes { ReadOnly } es5id: 15.3.5.1_A3_T2 description: > Checking if varying the length property of - Function("arg1,arg2,arg3", null) fails + SendableFunction("arg1,arg2,arg3", null) fails includes: [propertyHelper.js] ---*/ -var f = Function("arg1,arg2,arg3", null); +var f = SendableFunction("arg1,arg2,arg3", null); assert(f.hasOwnProperty('length')); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T3.js b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T3.js index ebcb9f895f2..fd39127657f 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T3.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T3.js @@ -18,11 +18,11 @@ info: the length property has the attributes { ReadOnly } es5id: 15.3.5.1_A3_T3 description: > Checking if varying the length property of - Function("arg1,arg2,arg3","arg1,arg2","arg3", null) fails + SendableFunction("arg1,arg2,arg3","arg1,arg2","arg3", null) fails includes: [propertyHelper.js] ---*/ -var f = new Function("arg1,arg2,arg3", "arg1,arg2", "arg3", null); +var f = new SendableFunction("arg1,arg2,arg3", "arg1,arg2", "arg3", null); assert(f.hasOwnProperty('length')); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T1.js b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T1.js index 7246f359698..7e58753a29f 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T1.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T1.js @@ -18,10 +18,10 @@ info: the length property has the attributes { DontEnum } es5id: 15.3.5.1_A4_T1 description: > Checking if enumerating the length property of - Function("arg1,arg2,arg3", null) fails + SendableFunction("arg1,arg2,arg3", null) fails ---*/ -var f = new Function("arg1,arg2,arg3", null); +var f = new SendableFunction("arg1,arg2,arg3", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T2.js b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T2.js index c38142697e2..55c6dd8d517 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T2.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T2.js @@ -18,10 +18,10 @@ info: the length property has the attributes { DontEnum } es5id: 15.3.5.1_A4_T2 description: > Checking if enumerating the length property of - Function("arg1,arg2,arg3","arg4,arg5", null) fails + SendableFunction("arg1,arg2,arg3","arg4,arg5", null) fails ---*/ -var f = Function("arg1,arg2,arg3", "arg5,arg4", null); +var f = SendableFunction("arg1,arg2,arg3", "arg5,arg4", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T3.js b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T3.js index 422fff19761..cc943436834 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T3.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T3.js @@ -18,10 +18,10 @@ info: the length property has the attributes { DontEnum } es5id: 15.3.5.1_A4_T3 description: > Checking if enumerating the length property of - Function("arg1,arg2,arg3","arg1,arg2","arg3", null) fails + SendableFunction("arg1,arg2,arg3","arg1,arg2","arg3", null) fails ---*/ -var f = new Function("arg1,arg2,arg3", "arg1,arg2", "arg3", null); +var f = new SendableFunction("arg1,arg2,arg3", "arg1,arg2", "arg3", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); diff --git a/test/sendable/builtins/Function/private-identifiers-not-empty.js b/test/sendable/builtins/Function/private-identifiers-not-empty.js index e30bc5a09b7..f705564ecc7 100644 --- a/test/sendable/builtins/Function/private-identifiers-not-empty.js +++ b/test/sendable/builtins/Function/private-identifiers-not-empty.js @@ -15,9 +15,9 @@ /*--- esid: sec-createdynamicfunction -description: CreateDynamicFunction throws SyntaxError if there is some invalid private identifier on its body +description: CreateDynamicSendableFunction throws SyntaxError if there is some invalid private identifier on its body info: | - CreateDynamicFunction(constructor, newTarget, kind, args) + CreateDynamicSendableFunction(constructor, newTarget, kind, args) ... 29. Let privateIdentifiers be an empty List. 30. If AllPrivateIdentifiersValid of body with the argument privateIdentifiers is false, throw a SyntaxError exception. @@ -28,6 +28,6 @@ features: [class-fields-private] assert.throws(SyntaxError, function() { let o = {}; - new Function("o.#f"); + new SendableFunction("o.#f"); }, 'It should be a SyntaxError if AllPrivateIdentifiersValid returns false to dynamic function body'); diff --git a/test/sendable/builtins/Function/prop-desc.js b/test/sendable/builtins/Function/prop-desc.js index 84b558744f0..2f9d5e1bef2 100644 --- a/test/sendable/builtins/Function/prop-desc.js +++ b/test/sendable/builtins/Function/prop-desc.js @@ -15,7 +15,7 @@ /*--- esid: sec-constructor-properties-of-the-global-object-function -description: Property descriptor for Function +description: Property descriptor for SendableFunction info: | Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, @@ -23,7 +23,7 @@ info: | includes: [propertyHelper.js] ---*/ -verifyProperty(this, "Function", { +verifyProperty(this, "SendableFunction", { writable: true, enumerable: false, configurable: true diff --git a/test/sendable/builtins/Function/property-order.js b/test/sendable/builtins/Function/property-order.js index 1cda42da1b1..e9a4c207da6 100644 --- a/test/sendable/builtins/Function/property-order.js +++ b/test/sendable/builtins/Function/property-order.js @@ -15,12 +15,12 @@ /*--- esid: sec-createbuiltinfunction -description: Function constructor property order +description: SendableFunction constructor property order info: | Set order: "length", "name", ... ---*/ -var propNames = Object.getOwnPropertyNames(Function); +var propNames = Object.getOwnPropertyNames(SendableFunction); var lengthIndex = propNames.indexOf("length"); var nameIndex = propNames.indexOf("name"); diff --git a/test/sendable/builtins/Function/proto-from-ctor-realm-prototype.js b/test/sendable/builtins/Function/proto-from-ctor-realm-prototype.js index bab8537e418..ccfdc82c517 100644 --- a/test/sendable/builtins/Function/proto-from-ctor-realm-prototype.js +++ b/test/sendable/builtins/Function/proto-from-ctor-realm-prototype.js @@ -19,18 +19,18 @@ description: > While default [[Prototype]] value derives from realm of the newTarget, "prototype" object inherits from %Object.prototype% of constructor's realm. info: | - Function ( p1, p2, … , pn, body ) + SendableFunction ( p1, p2, … , pn, body ) [...] - 3. Return ? CreateDynamicFunction(C, NewTarget, normal, args). + 3. Return ? CreateDynamicSendableFunction(C, NewTarget, normal, args). - CreateDynamicFunction ( constructor, newTarget, kind, args ) + CreateDynamicSendableFunction ( constructor, newTarget, kind, args ) [...] 18. Let proto be ? GetPrototypeFromConstructor(newTarget, fallbackProto). 19. Let realmF be the current Realm Record. 20. Let scope be realmF.[[GlobalEnv]]. - 21. Let F be ! OrdinaryFunctionCreate(proto, parameters, body, non-lexical-this, scope). + 21. Let F be ! OrdinarySendableFunctionCreate(proto, parameters, body, non-lexical-this, scope). [...] 25. Else if kind is normal, perform MakeConstructor(F). [...] @@ -51,11 +51,11 @@ var realmA = $262.createRealm().global; realmA.calls = 0; var realmB = $262.createRealm().global; -var newTarget = new realmB.Function(); +var newTarget = new realmB.SendableFunction(); newTarget.prototype = null; -var fn = Reflect.construct(realmA.Function, ["calls += 1;"], newTarget); -assert.sameValue(Object.getPrototypeOf(fn), realmB.Function.prototype); +var fn = Reflect.construct(realmA.SendableFunction, ["calls += 1;"], newTarget); +assert.sameValue(Object.getPrototypeOf(fn), realmB.SendableFunction.prototype); assert.sameValue(Object.getPrototypeOf(fn.prototype), realmA.Object.prototype); assert(new fn() instanceof realmA.Object); diff --git a/test/sendable/builtins/Function/proto-from-ctor-realm.js b/test/sendable/builtins/Function/proto-from-ctor-realm.js index 476af90c574..4e7c6086e15 100644 --- a/test/sendable/builtins/Function/proto-from-ctor-realm.js +++ b/test/sendable/builtins/Function/proto-from-ctor-realm.js @@ -18,14 +18,14 @@ esid: sec-function-p1-p2-pn-body description: Default [[Prototype]] value derived from realm of the newTarget info: | [...] - 5. Return ? CreateDynamicFunction(C, NewTarget, "normal", args). + 5. Return ? CreateDynamicSendableFunction(C, NewTarget, "normal", args). - 19.2.1.1.1 Runtime Semantics: CreateDynamicFunction + 19.2.1.1.1 Runtime Semantics: CreateDynamicSendableFunction [...] 2. If kind is "normal", then [...] - c. Let fallbackProto be "%FunctionPrototype%". + c. Let fallbackProto be "%SendableFunctionPrototype%". [...] 22. Let proto be ? GetPrototypeFromConstructor(newTarget, fallbackProto). [...] @@ -35,16 +35,16 @@ info: | [...] 3. Let proto be ? Get(constructor, "prototype"). 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). + a. Let realm be ? GetSendableFunctionRealm(constructor). b. Let proto be realm's intrinsic object named intrinsicDefaultProto. [...] features: [cross-realm, Reflect] ---*/ var other = $262.createRealm().global; -var C = new other.Function(); +var C = new other.SendableFunction(); C.prototype = null; -var o = Reflect.construct(Function, [], C); +var o = Reflect.construct(SendableFunction, [], C); -assert.sameValue(Object.getPrototypeOf(o), other.Function.prototype); +assert.sameValue(Object.getPrototypeOf(o), other.SendableFunction.prototype); diff --git a/test/sendable/builtins/Function/prototype/S15.3.3.1_A1.js b/test/sendable/builtins/Function/prototype/S15.3.3.1_A1.js index efedc5e99f2..929224844dc 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.3.1_A1.js +++ b/test/sendable/builtins/Function/prototype/S15.3.3.1_A1.js @@ -14,24 +14,24 @@ */ /*--- -info: The Function.prototype property has the attribute ReadOnly +info: The SendableFunction.prototype property has the attribute ReadOnly es5id: 15.3.3.1_A1 -description: Checking if varying the Function.prototype property fails +description: Checking if varying the SendableFunction.prototype property fails includes: [propertyHelper.js] ---*/ -var obj = Function.prototype; +var obj = SendableFunction.prototype; -verifyNotWritable(Function, "prototype", null, function() { +verifyNotWritable(SendableFunction, "prototype", null, function() { return "shifted"; }); -assert.sameValue(Function.prototype, obj, 'The value of Function.prototype is expected to equal the value of obj'); +assert.sameValue(SendableFunction.prototype, obj, 'The value of SendableFunction.prototype is expected to equal the value of obj'); try { - assert.sameValue(Function.prototype(), undefined, 'Function.prototype() returns undefined'); + assert.sameValue(SendableFunction.prototype(), undefined, 'SendableFunction.prototype() returns undefined'); } catch (e) { - throw new Test262Error('#2.1: the Function.prototype property has the attributes ReadOnly: ' + e); + throw new Test262Error('#2.1: the SendableFunction.prototype property has the attributes ReadOnly: ' + e); } // TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/S15.3.3.1_A2.js b/test/sendable/builtins/Function/prototype/S15.3.3.1_A2.js index e1f0a0099ea..8bda1ebc1b7 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.3.1_A2.js +++ b/test/sendable/builtins/Function/prototype/S15.3.3.1_A2.js @@ -14,19 +14,19 @@ */ /*--- -info: The Function.prototype property has the attribute DontEnum +info: The SendableFunction.prototype property has the attribute DontEnum es5id: 15.3.3.1_A2 -description: Checking if enumerating the Function.prototype property fails +description: Checking if enumerating the SendableFunction.prototype property fails ---*/ assert( - !Function.propertyIsEnumerable('prototype'), - 'The value of !Function.propertyIsEnumerable(\'prototype\') is expected to be true' + !SendableFunction.propertyIsEnumerable('prototype'), + 'The value of !SendableFunction.propertyIsEnumerable(\'prototype\') is expected to be true' ); // CHECK#2 var count = 0; -for (var p in Function) { +for (var p in SendableFunction) { if (p === "prototype") { count++; } diff --git a/test/sendable/builtins/Function/prototype/S15.3.3.1_A3.js b/test/sendable/builtins/Function/prototype/S15.3.3.1_A3.js index dc0885faecc..21fe6badd95 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.3.1_A3.js +++ b/test/sendable/builtins/Function/prototype/S15.3.3.1_A3.js @@ -14,16 +14,16 @@ */ /*--- -info: The Function.prototype property has the attribute DontDelete +info: The SendableFunction.prototype property has the attribute DontDelete es5id: 15.3.3.1_A3 -description: Checking if deleting the Function.prototype property fails +description: Checking if deleting the SendableFunction.prototype property fails includes: [propertyHelper.js] ---*/ -verifyNotConfigurable(Function, "prototype"); +verifyNotConfigurable(SendableFunction, "prototype"); try { - assert.sameValue(delete Function.prototype, false); + assert.sameValue(delete SendableFunction.prototype, false); } catch (e) { if (e instanceof Test262Error) { throw e; @@ -31,8 +31,8 @@ try { assert(e instanceof TypeError); } -if (!(Function.hasOwnProperty('prototype'))) { - throw new Test262Error('#2: the Function.prototype property has the attributes DontDelete.'); +if (!(SendableFunction.hasOwnProperty('prototype'))) { + throw new Test262Error('#2: the SendableFunction.prototype property has the attributes DontDelete.'); } // TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A1.js b/test/sendable/builtins/Function/prototype/S15.3.4_A1.js index fb146e1c57c..d2dc6b92e18 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A1.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A1.js @@ -15,13 +15,13 @@ /*--- info: | - The Function prototype object is itself a Function object (its [[Class]] - is "Function") + The SendableFunction prototype object is itself a SendableFunction object (its [[Class]] + is "SendableFunction") es5id: 15.3.4_A1 description: Object.prototype.toString returns [object+[[Class]]+] ---*/ assert.sameValue( - Object.prototype.toString.call(Function.prototype), - "[object Function]", - 'Object.prototype.toString.call(Function.prototype) must return "[object Function]"' + Object.prototype.toString.call(SendableFunction.prototype), + "[object SendableFunction]", + 'Object.prototype.toString.call(SendableFunction.prototype) must return "[object SendableFunction]"' ); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T1.js b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T1.js index 9021a3f5734..2ba62df56d1 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T1.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T1.js @@ -15,14 +15,14 @@ /*--- info: | - The Function prototype object is itself a Function object that, when + The SendableFunction prototype object is itself a SendableFunction object that, when invoked, accepts any arguments and returns undefined es5id: 15.3.4_A2_T1 -description: Call Function.prototype() +description: Call SendableFunction.prototype() ---*/ try { - assert.sameValue(Function.prototype(), undefined, 'Function.prototype() returns undefined'); + assert.sameValue(SendableFunction.prototype(), undefined, 'SendableFunction.prototype() returns undefined'); } catch (e) { - throw new Test262Error('#1.1: The Function prototype object is itself a Function object that, when invoked, accepts any arguments and returns undefined: ' + e); + throw new Test262Error('#1.1: The SendableFunction prototype object is itself a SendableFunction object that, when invoked, accepts any arguments and returns undefined: ' + e); } diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T2.js b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T2.js index 2e04ed7a48d..e5cd8c048ab 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T2.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T2.js @@ -15,14 +15,14 @@ /*--- info: | - The Function prototype object is itself a Function object that, when + The SendableFunction prototype object is itself a SendableFunction object that, when invoked, accepts any arguments and returns undefined es5id: 15.3.4_A2_T2 -description: Call Function.prototype(null,void 0) +description: Call SendableFunction.prototype(null,void 0) ---*/ try { - assert.sameValue(Function.prototype(null, void 0), undefined, 'Function.prototype(null, void 0) returns undefined'); + assert.sameValue(SendableFunction.prototype(null, void 0), undefined, 'SendableFunction.prototype(null, void 0) returns undefined'); } catch (e) { - throw new Test262Error('#1.1: The Function prototype object is itself a Function object that, when invoked, accepts any arguments and returns undefined: ' + e); + throw new Test262Error('#1.1: The SendableFunction prototype object is itself a SendableFunction object that, when invoked, accepts any arguments and returns undefined: ' + e); } diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T3.js b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T3.js index 9fc9baa8a74..c6626a79db3 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T3.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T3.js @@ -15,11 +15,11 @@ /*--- info: | - The Function prototype object is itself a Function object that, when + The SendableFunction prototype object is itself a SendableFunction object that, when invoked, accepts any arguments and returns undefined es5id: 15.3.4_A2_T3 -description: Call Function.prototype(x), where x is undefined variable +description: Call SendableFunction.prototype(x), where x is undefined variable ---*/ var x; -assert.sameValue(Function.prototype(x), undefined, 'Function.prototype(x) returns undefined'); +assert.sameValue(SendableFunction.prototype(x), undefined, 'SendableFunction.prototype(x) returns undefined'); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A3_T1.js b/test/sendable/builtins/Function/prototype/S15.3.4_A3_T1.js index dedca7113ac..57de7b03fdc 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A3_T1.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A3_T1.js @@ -15,13 +15,13 @@ /*--- info: | - The value of the internal [[Prototype]] property of the Function + The value of the internal [[Prototype]] property of the SendableFunction prototype object is the Object prototype object (15.3.4) es5id: 15.3.4_A3_T1 -description: Checking prototype of Function.prototype +description: Checking prototype of SendableFunction.prototype ---*/ assert.sameValue( - Object.getPrototypeOf(Function.prototype), + Object.getPrototypeOf(SendableFunction.prototype), Object.prototype, - 'Object.getPrototypeOf(Function.prototype) returns Object.prototype' + 'Object.getPrototypeOf(SendableFunction.prototype) returns Object.prototype' ); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A3_T2.js b/test/sendable/builtins/Function/prototype/S15.3.4_A3_T2.js index 82595b1a157..1524f73e9c5 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A3_T2.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A3_T2.js @@ -15,14 +15,14 @@ /*--- info: | - The value of the internal [[Prototype]] property of the Function + The value of the internal [[Prototype]] property of the SendableFunction prototype object is the Object prototype object (15.3.2.1) es5id: 15.3.4_A3_T2 description: > Add new property to Object.prototype and check it at - Function.prototype + SendableFunction.prototype ---*/ Object.prototype.indicator = 1; -assert.sameValue(Function.prototype.indicator, 1, 'The value of Function.prototype.indicator is expected to be 1'); +assert.sameValue(SendableFunction.prototype.indicator, 1, 'The value of SendableFunction.prototype.indicator is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A4.js b/test/sendable/builtins/Function/prototype/S15.3.4_A4.js index 8835b4ec007..579c5c632db 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A4.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A4.js @@ -15,26 +15,26 @@ /*--- info: | - The Function prototype object does not have a valueOf property of its + The SendableFunction prototype object does not have a valueOf property of its own. however, it inherits the valueOf property from the Object prototype Object es5id: 15.3.4_A4 -description: Checking valueOf property at Function.prototype +description: Checking valueOf property at SendableFunction.prototype ---*/ assert.sameValue( - Function.prototype.hasOwnProperty("valueOf"), + SendableFunction.prototype.hasOwnProperty("valueOf"), false, - 'Function.prototype.hasOwnProperty("valueOf") must return false' + 'SendableFunction.prototype.hasOwnProperty("valueOf") must return false' ); assert.notSameValue( - typeof Function.prototype.valueOf, + typeof SendableFunction.prototype.valueOf, "undefined", - 'The value of typeof Function.prototype.valueOf is not "undefined"' + 'The value of typeof SendableFunction.prototype.valueOf is not "undefined"' ); assert.sameValue( - Function.prototype.valueOf, + SendableFunction.prototype.valueOf, Object.prototype.valueOf, - 'The value of Function.prototype.valueOf is expected to equal the value of Object.prototype.valueOf' + 'The value of SendableFunction.prototype.valueOf is expected to equal the value of Object.prototype.valueOf' ); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A5.js b/test/sendable/builtins/Function/prototype/S15.3.4_A5.js index a631100fa4c..006fd0e3af2 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A5.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A5.js @@ -15,12 +15,12 @@ /*--- info: | - The Function prototype object is itself a Function object without + The SendableFunction prototype object is itself a SendableFunction object without [[Construct]] property es5id: 15.3.4_A5 -description: Checking if creating "new Function.prototype object" fails +description: Checking if creating "new SendableFunction.prototype object" fails ---*/ assert.throws(TypeError, function() { - new Function.prototype; -}, '`new Function.prototype` throws a TypeError exception'); + new SendableFunction.prototype; +}, '`new SendableFunction.prototype` throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T1.js b/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T1.js index de83518aaef..b8925ac836c 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T1.js +++ b/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T1.js @@ -17,12 +17,12 @@ info: the prototype property has the attributes { DontDelete } es5id: 15.3.5.2_A1_T1 description: > - Checking if deleting the prototype property of Function("", null) + Checking if deleting the prototype property of SendableFunction("", null) fails includes: [propertyHelper.js] ---*/ -var f = new Function("", null); +var f = new SendableFunction("", null); assert(f.hasOwnProperty('prototype')); diff --git a/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T2.js b/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T2.js index e559f435daf..b551276c9f3 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T2.js +++ b/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T2.js @@ -17,12 +17,12 @@ info: the prototype property has the attributes { DontDelete } es5id: 15.3.5.2_A1_T2 description: > - Checking if deleting the prototype property of Function(void 0, + Checking if deleting the prototype property of SendableFunction(void 0, "") fails includes: [propertyHelper.js] ---*/ -var f = Function(void 0, ""); +var f = SendableFunction(void 0, ""); assert(f.hasOwnProperty('prototype')); diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/length.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/length.js index d804649b003..65bdbe2dc05 100644 --- a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/length.js +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/length.js @@ -15,24 +15,24 @@ /*--- es6id: 19.2.3.6 -description: Function.prototye[Symbol.hasInstance] `length` property +description: SendableFunction.prototye[Symbol.hasInstance] `length` property info: | ES6 Section 17: - Every built-in Function object, including constructors, has a length + Every built-in SendableFunction 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. [...] - Unless otherwise specified, the length property of a built-in Function + Unless otherwise specified, the length property of a built-in SendableFunction object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. features: [Symbol.hasInstance] includes: [propertyHelper.js] ---*/ -verifyProperty(Function.prototype[Symbol.hasInstance], "length", { +verifyProperty(SendableFunction.prototype[Symbol.hasInstance], "length", { value: 1, writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/name.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/name.js index 297b0da6261..28b0830de03 100644 --- a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/name.js +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/name.js @@ -23,7 +23,7 @@ features: [Symbol.hasInstance] includes: [propertyHelper.js] ---*/ -verifyProperty(Function.prototype[Symbol.hasInstance], "name", { +verifyProperty(SendableFunction.prototype[Symbol.hasInstance], "name", { value: "[Symbol.hasInstance]", writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/prop-desc.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/prop-desc.js index 0975f0b9b34..37b64d10a0b 100644 --- a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/prop-desc.js +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/prop-desc.js @@ -15,7 +15,7 @@ /*--- es6id: 19.2.3.6 -description: Function.prototype[Symbol.hasInstance] property descriptor +description: SendableFunction.prototype[Symbol.hasInstance] property descriptor info: | This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. @@ -23,9 +23,9 @@ features: [Symbol.hasInstance] includes: [propertyHelper.js] ---*/ -assert.sameValue(typeof Function.prototype[Symbol.hasInstance], 'function'); +assert.sameValue(typeof SendableFunction.prototype[Symbol.hasInstance], 'function'); -verifyProperty(Function.prototype, Symbol.hasInstance, { +verifyProperty(SendableFunction.prototype, Symbol.hasInstance, { writable: false, enumerable: false, configurable: false, diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-bound-target.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-bound-target.js index 40d1a8ed767..3264fd04f54 100644 --- a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-bound-target.js +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-bound-target.js @@ -23,8 +23,8 @@ info: | 7.3.19 OrdinaryHasInstance (C, O) 1. If IsCallable(C) is false, return false. - 2. If C has a [[BoundTargetFunction]] internal slot, then - a. Let BC be the value of C’s [[BoundTargetFunction]] internal slot. + 2. If C has a [[BoundTargetSendableFunction]] internal slot, then + a. Let BC be the value of C’s [[BoundTargetSendableFunction]] internal slot. b. Return InstanceofOperator(O,BC) (see 12.9.4). features: [Symbol.hasInstance] ---*/ diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-not-callable.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-not-callable.js index 8451d480b91..dedcc118b1f 100644 --- a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-not-callable.js +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-not-callable.js @@ -26,5 +26,5 @@ info: | features: [Symbol.hasInstance] ---*/ -assert.sameValue(Function.prototype[Symbol.hasInstance].call(), false); -assert.sameValue(Function.prototype[Symbol.hasInstance].call({}), false); +assert.sameValue(SendableFunction.prototype[Symbol.hasInstance].call(), false); +assert.sameValue(SendableFunction.prototype[Symbol.hasInstance].call({}), false); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A12.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A12.js index 840ca137a16..ad23e82773f 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A12.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A12.js @@ -14,14 +14,14 @@ */ /*--- -info: Function.prototype.apply has not prototype property +info: SendableFunction.prototype.apply has not prototype property es5id: 15.3.4.3_A12 description: > Checking if obtaining the prototype property of - Function.prototype.apply fails + SendableFunction.prototype.apply fails ---*/ assert.sameValue( - Function.prototype.apply.prototype, + SendableFunction.prototype.apply.prototype, undefined, - 'The value of Function.prototype.apply.prototype is expected to equal undefined' + 'The value of SendableFunction.prototype.apply.prototype is expected to equal undefined' ); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T1.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T1.js index 387405345d1..7627abbc830 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T1.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T1.js @@ -21,10 +21,10 @@ info: | es5id: 15.3.4.3_A1_T1 description: > Calling "apply" method of the object that does not have a [[Call]] - property. Prototype of the object is Function() + property. Prototype of the object is SendableFunction() ---*/ -var proto = Function(); +var proto = SendableFunction(); function FACTORY() {} diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T2.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T2.js index 9291b120437..5d828800b7f 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T2.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T2.js @@ -21,12 +21,12 @@ info: | es5id: 15.3.4.3_A1_T2 description: > Calling "apply" method of the object that does not have a [[Call]] - property. Prototype of the object is Function.prototype + property. Prototype of the object is SendableFunction.prototype ---*/ function FACTORY() {} -FACTORY.prototype = Function.prototype; +FACTORY.prototype = SendableFunction.prototype; var obj = new FACTORY; diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T1.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T1.js index b1af286b5dd..4c78ace7174 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T1.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T1.js @@ -21,6 +21,6 @@ es5id: 15.3.4.3_A3_T1 description: Not any arguments at apply function ---*/ -Function("this.field=\"strawberry\"").apply(); +SendableFunction("this.field=\"strawberry\"").apply(); assert.sameValue(this["field"], "strawberry", 'The value of this["field"] is expected to be "strawberry"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T2.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T2.js index 9b55195ef24..8d9300e8852 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T2.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T2.js @@ -21,6 +21,6 @@ es5id: 15.3.4.3_A3_T2 description: Argument at apply function is null ---*/ -Function("this.field=\"green\"").apply(null); +SendableFunction("this.field=\"green\"").apply(null); assert.sameValue(this["field"], "green", 'The value of this["field"] is expected to be "green"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T3.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T3.js index 859d51dd0e0..239bddec543 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T3.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T3.js @@ -21,6 +21,6 @@ es5id: 15.3.4.3_A3_T3 description: Argument at apply function is void 0 ---*/ -Function("this.field=\"battle\"").apply(void 0); +SendableFunction("this.field=\"battle\"").apply(void 0); assert.sameValue(this["field"], "battle", 'The value of this["field"] is expected to be "battle"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T4.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T4.js index 51c10685275..133c86ac8a2 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T4.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T4.js @@ -21,6 +21,6 @@ es5id: 15.3.4.3_A3_T4 description: Argument at apply function is undefined ---*/ -Function("this.field=\"oil\"").apply(undefined); +SendableFunction("this.field=\"oil\"").apply(undefined); assert.sameValue(this["field"], "oil", 'The value of this["field"] is expected to be "oil"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T5.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T5.js index 1d1cf5498d2..459558b8eb5 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T5.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T5.js @@ -24,7 +24,7 @@ description: > ---*/ function FACTORY() { - Function("this.feat=\"in da haus\"").apply(); + SendableFunction("this.feat=\"in da haus\"").apply(); } var obj = new FACTORY; diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T7.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T7.js index 149adf35e36..68127fc51b2 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T7.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T7.js @@ -24,7 +24,7 @@ description: > ---*/ (function FACTORY() { - Function("this.feat=\"in da haus\"").apply(void 0); + SendableFunction("this.feat=\"in da haus\"").apply(void 0); })(); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T9.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T9.js index a12c2068b21..b4b2c00c199 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T9.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T9.js @@ -21,6 +21,6 @@ es5id: 15.3.4.3_A3_T9 description: Checking by using eval, argument at apply function is void 0 ---*/ -eval(" Function(\"this.feat=1\").apply(void 0) "); +eval(" SendableFunction(\"this.feat=1\").apply(void 0) "); assert.sameValue(this["feat"], 1, 'The value of this["feat"] is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T1.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T1.js index af6756ca8d5..703e2a2121f 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T1.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T1.js @@ -23,7 +23,7 @@ description: thisArg is number var obj = 1; -var retobj = Function("this.touched= true; return this;").apply(obj); +var retobj = SendableFunction("this.touched= true; return this;").apply(obj); assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T2.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T2.js index 56ff45dcee1..1ff977fe572 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T2.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T2.js @@ -23,7 +23,7 @@ description: thisArg is boolean true var obj = true; -var retobj = new Function("this.touched= true; return this;").apply(obj); +var retobj = new SendableFunction("this.touched= true; return this;").apply(obj); assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T7.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T7.js index 168808525a7..27823401637 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T7.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T7.js @@ -23,6 +23,6 @@ description: thisArg is new Number() var obj = new Number(1); -Function("this.touched= true;").apply(obj); +SendableFunction("this.touched= true;").apply(obj); assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T8.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T8.js index 2f40c529d7e..b1b1e9257f6 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T8.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T8.js @@ -18,11 +18,11 @@ info: | If thisArg is not null(defined) the called function is passed ToObject(thisArg) as the this value es5id: 15.3.4.3_A5_T8 -description: thisArg is Function() +description: thisArg is SendableFunction() ---*/ -var obj = Function(); +var obj = SendableFunction(); -new Function("this.touched= true; return this;").apply(obj); +new SendableFunction("this.touched= true; return this;").apply(obj); assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T1.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T1.js index 4f64215f192..5222a65583e 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T1.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T1.js @@ -21,6 +21,6 @@ es5id: 15.3.4.3_A7_T1 description: argSendableArray is (null,[1]) ---*/ -Function("a1,a2,a3", "this.shifted=a1;").apply(null, [1]); +SendableFunction("a1,a2,a3", "this.shifted=a1;").apply(null, [1]); assert.sameValue(this["shifted"], 1, 'The value of this["shifted"] is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T10.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T10.js index 468299ba6e3..3aadcd546d8 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T10.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T10.js @@ -26,7 +26,7 @@ description: > var obj = {}; (function() { - Function("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(obj, arguments); + SendableFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(obj, arguments); })("", 4, 2); assert.sameValue(obj["shifted"], "42", 'The value of obj["shifted"] is expected to be "42"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T2.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T2.js index 387ab015189..d1a1d7dda91 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T2.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T2.js @@ -21,6 +21,6 @@ es5id: 15.3.4.3_A7_T2 description: argSendableArray is (null,[1,2,3]) ---*/ -new Function("a1,a2", "a3", "this.shifted=a2;").apply(null, [1, 2, 3]); +new SendableFunction("a1,a2", "a3", "this.shifted=a2;").apply(null, [1, 2, 3]); assert.sameValue(this["shifted"], 2, 'The value of this["shifted"] is expected to be 2'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T3.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T3.js index 1965aec6a4a..041d05146cf 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T3.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T3.js @@ -31,7 +31,7 @@ var p = { var obj = {}; -Function(p, "a2,a3", "this.shifted=a1;").apply(obj, new SendableArray("nine", "inch", "nails")); +SendableFunction(p, "a2,a3", "this.shifted=a1;").apply(obj, new SendableArray("nine", "inch", "nails")); assert.sameValue(obj["shifted"], "nine", 'The value of obj["shifted"] is expected to be "nine"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T4.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T4.js index 615ce29b630..09d7cd7d661 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T4.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T4.js @@ -33,7 +33,7 @@ var p = { var obj = {}; -new Function(p, p, p, "this.shifted=a3;").apply(obj, (function() { +new SendableFunction(p, p, p, "this.shifted=a3;").apply(obj, (function() { return arguments; })("a", "b", "c")); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T5.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T5.js index 28b4f7534f8..6f7fcc25bc8 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T5.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T5.js @@ -22,7 +22,7 @@ description: argSendableArray is (null, arguments), inside function declaration ---*/ function FACTORY() { - Function("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(null, arguments); + SendableFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(null, arguments); } var obj = new FACTORY("", 1, 2); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T6.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T6.js index ecde945b892..63ff0c3da9f 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T6.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T6.js @@ -22,7 +22,7 @@ description: argSendableArray is (this, arguments), inside function declaration ---*/ function FACTORY() { - Function("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(this, arguments); + SendableFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(this, arguments); } var obj = new FACTORY("", 4, 2); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T7.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T7.js index d432dc90ba5..0666369a19e 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T7.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T7.js @@ -24,7 +24,7 @@ description: > ---*/ (function() { - Function("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(null, arguments); + SendableFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(null, arguments); })("", 1, 2); assert.sameValue(this["shifted"], "12", 'The value of this["shifted"] is expected to be "12"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T8.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T8.js index 0630f32c591..8ee8d1fdb25 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T8.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T8.js @@ -24,7 +24,7 @@ description: > ---*/ (function() { - Function("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(this, arguments); + SendableFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(this, arguments); })("", 4, 2); assert.sameValue(this["shifted"], "42", 'The value of this["shifted"] is expected to be "42"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T9.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T9.js index 692cac53f7f..a5a541e7b87 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T9.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T9.js @@ -25,7 +25,7 @@ description: > function FACTORY() { var obj = {}; - Function("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(obj, arguments); + SendableFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(obj, arguments); return obj; } diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T3.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T3.js index 0d145b7db60..ad0c2715028 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T3.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T3.js @@ -14,14 +14,14 @@ */ /*--- -info: Function.prototype.apply can`t be used as [[Construct]] caller +info: SendableFunction.prototype.apply can`t be used as [[Construct]] caller es5id: 15.3.4.3_A8_T3 -description: Checking if creating "new Function.apply" fails +description: Checking if creating "new SendableFunction.apply" fails ---*/ try { - var obj = new Function.apply; - throw new Test262Error('#1: Function.prototype.apply can\'t be used as [[Construct]] caller'); + var obj = new SendableFunction.apply; + throw new Test262Error('#1: SendableFunction.prototype.apply can\'t be used as [[Construct]] caller'); } catch (e) { assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); } diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T4.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T4.js index ce5a5cd430e..35bb1738c3f 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T4.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T4.js @@ -14,14 +14,14 @@ */ /*--- -info: Function.prototype.apply can`t be used as [[Construct]] caller +info: SendableFunction.prototype.apply can`t be used as [[Construct]] caller es5id: 15.3.4.3_A8_T4 -description: Checking if creating "new (Function("this.p1=1").apply)" fails +description: Checking if creating "new (SendableFunction("this.p1=1").apply)" fails ---*/ try { - var obj = new(Function("this.p1=1").apply); - throw new Test262Error('#1: Function.prototype.apply can\'t be used as [[Construct]] caller'); + var obj = new(SendableFunction("this.p1=1").apply); + throw new Test262Error('#1: SendableFunction.prototype.apply can\'t be used as [[Construct]] caller'); } catch (e) { assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); } diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T5.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T5.js index 07ca7192eda..6831f8c9718 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T5.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T5.js @@ -14,15 +14,15 @@ */ /*--- -info: Function.prototype.apply can`t be used as [[Construct]] caller +info: SendableFunction.prototype.apply can`t be used as [[Construct]] caller es5id: 15.3.4.3_A8_T5 -description: Checking if creating "new Function("this.p1=1").apply" fails +description: Checking if creating "new SendableFunction("this.p1=1").apply" fails ---*/ try { - var FACTORY = Function("this.p1=1").apply; + var FACTORY = SendableFunction("this.p1=1").apply; var obj = new FACTORY(); - throw new Test262Error('#1: Function.prototype.apply can\'t be used as [[Construct]] caller'); + throw new Test262Error('#1: SendableFunction.prototype.apply can\'t be used as [[Construct]] caller'); } catch (e) { assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); } diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T6.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T6.js index 0dbc687d3bc..ace9d9c89a2 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T6.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T6.js @@ -14,17 +14,17 @@ */ /*--- -info: Function.prototype.apply can`t be used as [[Construct]] caller +info: SendableFunction.prototype.apply can`t be used as [[Construct]] caller es5id: 15.3.4.3_A8_T6 description: > - Checking if creating "new (Function("function + Checking if creating "new (SendableFunction("function f(){this.p1=1;};return f").apply())" fails ---*/ try { - var obj = new(Function("function f(){this.p1=1;};return f").apply()); + var obj = new(SendableFunction("function f(){this.p1=1;};return f").apply()); } catch (e) { - throw new Test262Error('#1: Function.prototype.apply can\'t be used as [[Construct]] caller'); + throw new Test262Error('#1: SendableFunction.prototype.apply can\'t be used as [[Construct]] caller'); } assert.sameValue(obj.p1, 1, 'The value of obj.p1 is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/apply/argarray-not-object-realm.js b/test/sendable/builtins/Function/prototype/apply/argarray-not-object-realm.js index 6600186c41d..f2af1ac906d 100644 --- a/test/sendable/builtins/Function/prototype/apply/argarray-not-object-realm.js +++ b/test/sendable/builtins/Function/prototype/apply/argarray-not-object-realm.js @@ -19,7 +19,7 @@ description: > Throws a TypeError exception if argSendableArray is not an object (honoring the Realm of the current execution context) info: | - Function.prototype.apply ( thisArg, argSendableArray ) + SendableFunction.prototype.apply ( thisArg, argSendableArray ) [...] 4. Let argList be ? CreateListFromSendableArrayLike(argSendableArray). @@ -32,7 +32,7 @@ features: [cross-realm] ---*/ var other = $262.createRealm().global; -var fn = new other.Function(); +var fn = new other.SendableFunction(); assert.throws(other.TypeError, function() { fn.apply(null, false); diff --git a/test/sendable/builtins/Function/prototype/apply/argarray-not-object.js b/test/sendable/builtins/Function/prototype/apply/argarray-not-object.js index 20c649cb119..076bc3ca45e 100644 --- a/test/sendable/builtins/Function/prototype/apply/argarray-not-object.js +++ b/test/sendable/builtins/Function/prototype/apply/argarray-not-object.js @@ -18,7 +18,7 @@ esid: sec-function.prototype.apply description: > Throws a TypeError exception if argSendableArray is not an object info: | - Function.prototype.apply ( thisArg, argSendableArray ) + SendableFunction.prototype.apply ( thisArg, argSendableArray ) [...] 4. Let argList be ? CreateListFromSendableArrayLike(argSendableArray). diff --git a/test/sendable/builtins/Function/prototype/apply/get-index-abrupt.js b/test/sendable/builtins/Function/prototype/apply/get-index-abrupt.js index 6d25de25fc2..f489e50f771 100644 --- a/test/sendable/builtins/Function/prototype/apply/get-index-abrupt.js +++ b/test/sendable/builtins/Function/prototype/apply/get-index-abrupt.js @@ -18,7 +18,7 @@ esid: sec-function.prototype.apply description: > Return abrupt completion from Get(obj, indexName) info: | - Function.prototype.apply ( thisArg, argSendableArray ) + SendableFunction.prototype.apply ( thisArg, argSendableArray ) [...] 4. Let argList be ? CreateListFromSendableArrayLike(argSendableArray). diff --git a/test/sendable/builtins/Function/prototype/apply/get-length-abrupt.js b/test/sendable/builtins/Function/prototype/apply/get-length-abrupt.js index c6ec68a57b7..1bc4b9e77a8 100644 --- a/test/sendable/builtins/Function/prototype/apply/get-length-abrupt.js +++ b/test/sendable/builtins/Function/prototype/apply/get-length-abrupt.js @@ -18,7 +18,7 @@ esid: sec-function.prototype.apply description: > Return abrupt completion from Get(obj, "length") info: | - Function.prototype.apply ( thisArg, argSendableArray ) + SendableFunction.prototype.apply ( thisArg, argSendableArray ) [...] 4. Let argList be ? CreateListFromSendableArrayLike(argSendableArray). diff --git a/test/sendable/builtins/Function/prototype/apply/length.js b/test/sendable/builtins/Function/prototype/apply/length.js index 020dea5c732..c72fa29156a 100644 --- a/test/sendable/builtins/Function/prototype/apply/length.js +++ b/test/sendable/builtins/Function/prototype/apply/length.js @@ -16,22 +16,22 @@ /*--- esid: sec-function.prototype.apply description: > - Function.prototype.apply.length is 2. + SendableFunction.prototype.apply.length is 2. info: | ECMAScript Standard Built-in Objects ... - Every built-in Function object, including constructors, has a length + Every built-in SendableFunction 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. ... - Unless otherwise specified, the length property of a built-in Function + Unless otherwise specified, the length property of a built-in SendableFunction object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. includes: [propertyHelper.js] ---*/ -verifyProperty(Function.prototype.apply, 'length', { +verifyProperty(SendableFunction.prototype.apply, 'length', { value: 2, writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/apply/name.js b/test/sendable/builtins/Function/prototype/apply/name.js index 88f8b7c0b13..631b2478e42 100644 --- a/test/sendable/builtins/Function/prototype/apply/name.js +++ b/test/sendable/builtins/Function/prototype/apply/name.js @@ -16,22 +16,22 @@ /*--- es6id: 19.2.3.1 description: > - Function.prototype.apply.name is "apply". + SendableFunction.prototype.apply.name is "apply". info: | - Function.prototype.apply ( thisArg, argSendableArray ) + SendableFunction.prototype.apply ( thisArg, argSendableArray ) 17 ECMAScript Standard Built-in Objects: - Every built-in Function object, including constructors, that is not + Every built-in SendableFunction 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 + Unless otherwise specified, the name property of a built-in SendableFunction object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. includes: [propertyHelper.js] ---*/ -verifyProperty(Function.prototype.apply, "name", { +verifyProperty(SendableFunction.prototype.apply, "name", { value: "apply", writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/apply/not-a-constructor.js b/test/sendable/builtins/Function/prototype/apply/not-a-constructor.js index e9952136613..e6acd8e94c9 100644 --- a/test/sendable/builtins/Function/prototype/apply/not-a-constructor.js +++ b/test/sendable/builtins/Function/prototype/apply/not-a-constructor.js @@ -16,9 +16,9 @@ /*--- esid: sec-ecmascript-standard-built-in-objects description: > - Function.prototype.apply does not implement [[Construct]], is not new-able + SendableFunction.prototype.apply does not implement [[Construct]], is not new-able info: | - ECMAScript Function Objects + ECMAScript SendableFunction Objects Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method unless otherwise specified in @@ -34,15 +34,15 @@ features: [Reflect.construct, arrow-function] ---*/ assert.sameValue( - isConstructor(Function.prototype.apply), + isConstructor(SendableFunction.prototype.apply), false, - 'isConstructor(Function.prototype.apply) must return false' + 'isConstructor(SendableFunction.prototype.apply) must return false' ); assert.throws(TypeError, () => { - new Function.prototype.apply; + new SendableFunction.prototype.apply; }); assert.throws(TypeError, () => { - new Function.prototype.apply(); + new SendableFunction.prototype.apply(); }); diff --git a/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js b/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js index 266d69e18ae..04e62faa4a9 100644 --- a/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js +++ b/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js @@ -16,7 +16,7 @@ /*--- esid: sec-function.prototype.apply description: > - Function.p.apply behaves correctly when the argument array is a + SendableFunction.p.apply behaves correctly when the argument array is a TypedSendableArray backed by resizable buffer includes: [compareSendableArray.js, resizableSendableSendableArrayBufferUtils.js] features: [resizable-arraybuffer] diff --git a/test/sendable/builtins/Function/prototype/apply/this-not-callable-realm.js b/test/sendable/builtins/Function/prototype/apply/this-not-callable-realm.js index b11dfa4586f..e55190836fb 100644 --- a/test/sendable/builtins/Function/prototype/apply/this-not-callable-realm.js +++ b/test/sendable/builtins/Function/prototype/apply/this-not-callable-realm.js @@ -19,7 +19,7 @@ description: > Throws a TypeError exception if this value is not callable (honoring the Realm of the current execution context) info: | - Function.prototype.apply ( thisArg, argSendableArray ) + SendableFunction.prototype.apply ( thisArg, argSendableArray ) 1. Let func be the this value. 2. If IsCallable(func) is false, throw a TypeError exception. @@ -27,7 +27,7 @@ features: [cross-realm] ---*/ var other = $262.createRealm().global; -var otherApply = other.Function.prototype.apply; +var otherApply = other.SendableFunction.prototype.apply; assert.throws(other.TypeError, function() { otherApply.call(undefined, {}, []); diff --git a/test/sendable/builtins/Function/prototype/apply/this-not-callable.js b/test/sendable/builtins/Function/prototype/apply/this-not-callable.js index 6aaf676909d..4444fde0477 100644 --- a/test/sendable/builtins/Function/prototype/apply/this-not-callable.js +++ b/test/sendable/builtins/Function/prototype/apply/this-not-callable.js @@ -18,24 +18,24 @@ esid: sec-function.prototype.apply description: > Throws a TypeError exception if this value is not callable info: | - Function.prototype.apply ( thisArg, argSendableArray ) + SendableFunction.prototype.apply ( thisArg, argSendableArray ) 1. Let func be the this value. 2. If IsCallable(func) is false, throw a TypeError exception. ---*/ assert.throws(TypeError, function() { - Function.prototype.apply.call(undefined, {}, []); + SendableFunction.prototype.apply.call(undefined, {}, []); }); assert.throws(TypeError, function() { - Function.prototype.apply.call(null, {}, []); + SendableFunction.prototype.apply.call(null, {}, []); }); assert.throws(TypeError, function() { - Function.prototype.apply.call({}, {}, []); + SendableFunction.prototype.apply.call({}, {}, []); }); assert.throws(TypeError, function() { - Function.prototype.apply.call(/re/, {}, []); + SendableFunction.prototype.apply.call(/re/, {}, []); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-0-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-0-1.js index 8577560848b..c337b08b570 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-0-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-0-1.js @@ -15,9 +15,9 @@ /*--- es5id: 15.3.4.5-0-1 -description: Function.prototype.bind must exist as a function +description: SendableFunction.prototype.bind must exist as a function ---*/ -var f = Function.prototype.bind; +var f = SendableFunction.prototype.bind; assert.sameValue(typeof(f), "function", 'typeof(f)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-10-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-10-1.js index 44cd726a41d..2c0ff6816f2 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-10-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-10-1.js @@ -16,12 +16,12 @@ /*--- es5id: 15.3.4.5-10-1 description: > - Function.prototype.bind - internal property [[Class]] of 'F' is - set as Function + SendableFunction.prototype.bind - internal property [[Class]] of 'F' is + set as SendableFunction ---*/ var foo = function() {}; var obj = foo.bind({}); -assert.sameValue(Object.prototype.toString.call(obj), "[object Function]", 'Object.prototype.toString.call(obj)'); +assert.sameValue(Object.prototype.toString.call(obj), "[object SendableFunction]", 'Object.prototype.toString.call(obj)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-11-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-11-1.js index b01b5759179..0a86be15fb1 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-11-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-11-1.js @@ -16,13 +16,13 @@ /*--- es5id: 15.3.4.5-11-1 description: > - Function.prototype.bind - internal property [[Prototype]] of 'F' - is set as Function.prototype + SendableFunction.prototype.bind - internal property [[Prototype]] of 'F' + is set as SendableFunction.prototype ---*/ var foo = function() {}; -Function.prototype.property = 12; +SendableFunction.prototype.property = 12; var obj = foo.bind({}); assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-1.js index f283f8c0ce8..7c0b11a00dd 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-1.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-16-1 -description: Function.prototype.bind, [[Extensible]] of the bound fn is true +description: SendableFunction.prototype.bind, [[Extensible]] of the bound fn is true ---*/ function foo() {} diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-2.js index 5dd4bbf35db..337c933c1e7 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-2.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-16-2 description: > - Function.prototype.bind - The [[Extensible]] attribute of internal + SendableFunction.prototype.bind - The [[Extensible]] attribute of internal property in F set as true ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-1.js index bb4ebebab40..53845bd637e 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-1.js @@ -19,11 +19,11 @@ info: | is not callable. es5id: 15.3.4.5-2-1 description: > - Function.prototype.bind throws TypeError if the Target is not - callable (but an instance of Function) + SendableFunction.prototype.bind throws TypeError if the Target is not + callable (but an instance of SendableFunction) ---*/ -foo.prototype = Function.prototype; +foo.prototype = SendableFunction.prototype; // dummy function function foo() {} var f = new foo(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-10.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-10.js index aed0247153f..9f7a6a965ab 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-10.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-10.js @@ -15,10 +15,10 @@ /*--- es5id: 15.3.4.5-2-10 -description: Function.prototype.bind throws TypeError if 'Target' is undefined +description: SendableFunction.prototype.bind throws TypeError if 'Target' is undefined ---*/ assert.throws(TypeError, function() { - Function.prototype.bind.call(undefined); + SendableFunction.prototype.bind.call(undefined); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-11.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-11.js index c2becf76f65..174633518f2 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-11.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-11.js @@ -15,10 +15,10 @@ /*--- es5id: 15.3.4.5-2-11 -description: Function.prototype.bind throws TypeError if 'Target' is NULL +description: SendableFunction.prototype.bind throws TypeError if 'Target' is NULL ---*/ assert.throws(TypeError, function() { - Function.prototype.bind.call(null); + SendableFunction.prototype.bind.call(null); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-12.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-12.js index 970f6ade351..1c1256b78f8 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-12.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-12.js @@ -15,10 +15,10 @@ /*--- es5id: 15.3.4.5-2-12 -description: Function.prototype.bind throws TypeError if 'Target' is a boolean +description: SendableFunction.prototype.bind throws TypeError if 'Target' is a boolean ---*/ assert.throws(TypeError, function() { - Function.prototype.bind.call(true); + SendableFunction.prototype.bind.call(true); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-13.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-13.js index 8e71bcfedce..c3bf0745bd2 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-13.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-13.js @@ -15,10 +15,10 @@ /*--- es5id: 15.3.4.5-2-13 -description: Function.prototype.bind throws TypeError if 'Target' is a number +description: SendableFunction.prototype.bind throws TypeError if 'Target' is a number ---*/ assert.throws(TypeError, function() { - Function.prototype.bind.call(5); + SendableFunction.prototype.bind.call(5); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-14.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-14.js index a13ca954963..3fa82bb9b77 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-14.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-14.js @@ -15,10 +15,10 @@ /*--- es5id: 15.3.4.5-2-14 -description: Function.prototype.bind throws TypeError if 'Target' is a string +description: SendableFunction.prototype.bind throws TypeError if 'Target' is a string ---*/ assert.throws(TypeError, function() { - Function.prototype.bind.call("abc"); + SendableFunction.prototype.bind.call("abc"); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-15.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-15.js index 0741d2cc2dc..57175acd834 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-15.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-15.js @@ -16,11 +16,11 @@ /*--- es5id: 15.3.4.5-2-15 description: > - Function.prototype.bind throws TypeError if 'Target' is Object + SendableFunction.prototype.bind throws TypeError if 'Target' is Object without Call internal method ---*/ assert.throws(TypeError, function() { - Function.prototype.bind.call({}); + SendableFunction.prototype.bind.call({}); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-16.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-16.js index 2a3e56c08ed..82845a643c2 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-16.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-16.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-2-16 -description: Function.prototype.bind - 'Target' is a function +description: SendableFunction.prototype.bind - 'Target' is a function ---*/ function testFunc() {} diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-2.js index 5cf00e0de81..ec4679cc677 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-2.js @@ -19,14 +19,14 @@ info: | is not callable. es5id: 15.3.4.5-2-2 description: > - Function.prototype.bind throws TypeError if the Target is not + SendableFunction.prototype.bind throws TypeError if the Target is not callable (bind attached to object) ---*/ // dummy function function foo() {} var f = new foo(); -f.bind = Function.prototype.bind; +f.bind = SendableFunction.prototype.bind; assert.throws(TypeError, function() { f.bind(); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-3.js index 69f4fc90131..a50f1cfb3f0 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-3.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-3.js @@ -18,7 +18,7 @@ info: | 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target is not callable. es5id: 15.3.4.5-2-3 -description: Function.prototype.bind allows Target to be a constructor (Number) +description: SendableFunction.prototype.bind allows Target to be a constructor (Number) ---*/ var bnc = Number.bind(null); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-4.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-4.js index 48ca298511f..5ef8e1a9b51 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-4.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-4.js @@ -18,7 +18,7 @@ info: | 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target is not callable. es5id: 15.3.4.5-2-4 -description: Function.prototype.bind allows Target to be a constructor (String) +description: SendableFunction.prototype.bind allows Target to be a constructor (String) ---*/ var bsc = String.bind(null); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-5.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-5.js index 699eb768063..d2ae35f3ddc 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-5.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-5.js @@ -18,7 +18,7 @@ info: | 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target is not callable. es5id: 15.3.4.5-2-5 -description: Function.prototype.bind allows Target to be a constructor (Boolean) +description: SendableFunction.prototype.bind allows Target to be a constructor (Boolean) ---*/ var bbc = Boolean.bind(null); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-6.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-6.js index b391ac10d1e..3fe6357e5e9 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-6.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-6.js @@ -18,7 +18,7 @@ info: | 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target is not callable. es5id: 15.3.4.5-2-6 -description: Function.prototype.bind allows Target to be a constructor (Object) +description: SendableFunction.prototype.bind allows Target to be a constructor (Object) ---*/ var boc = Object.bind(null); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-7.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-7.js index 4efe884855d..3451a5581af 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-7.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-7.js @@ -19,7 +19,7 @@ info: | is not callable. es5id: 15.3.4.5-2-7 description: > - Function.prototype.bind throws TypeError if the Target is not + SendableFunction.prototype.bind throws TypeError if the Target is not callable (JSON) ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-8.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-8.js index 892b211dec6..ff272f9686d 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-8.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-8.js @@ -18,7 +18,7 @@ info: | 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target is not callable. es5id: 15.3.4.5-2-8 -description: Function.prototype.bind allows Target to be a constructor (SendableArray) +description: SendableFunction.prototype.bind allows Target to be a constructor (SendableArray) ---*/ var bac = SendableArray.bind(null); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-9.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-9.js index e0c3a964968..41203e13de7 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-9.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-9.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-2-9 -description: Function.prototype.bind allows Target to be a constructor (Date) +description: SendableFunction.prototype.bind allows Target to be a constructor (Date) ---*/ var bdc = Date.bind(null); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-2.js index 520c7a0a84d..c6942da530a 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-2.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-20-2 description: > - Function.prototype.bind - [[Get]] attribute of 'caller' property + SendableFunction.prototype.bind - [[Get]] attribute of 'caller' property in 'F' is thrower ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-3.js index 209a92d2304..b2cbd6439a3 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-3.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-3.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-20-3 description: > - Function.prototype.bind - [[Set]] attribute of 'caller' property + SendableFunction.prototype.bind - [[Set]] attribute of 'caller' property in 'F' is thrower ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-2.js index 91c39073b5c..8415170c4b8 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-2.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-21-2 description: > - Function.prototype.bind - [[Get]] attribute of 'arguments' + SendableFunction.prototype.bind - [[Get]] attribute of 'arguments' property in 'F' is thrower ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-3.js index b8d87880529..bc4051cb4b1 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-3.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-3.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-21-3 description: > - Function.prototype.bind - [[Set]] attribute of 'arguments' + SendableFunction.prototype.bind - [[Set]] attribute of 'arguments' property in 'F' is thrower ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-3-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-3-1.js index 6b76d0886a5..ef002bb7857 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-3-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-3-1.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-3-1 -description: Function.prototype.bind - each arg is defined in A in list order +description: SendableFunction.prototype.bind - each arg is defined in A in list order ---*/ var foo = function(x, y) { diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-1.js index af659c714c5..57c7e6b021f 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-1.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-6-1 -description: Function.prototype.bind - F can get own data property +description: SendableFunction.prototype.bind - F can get own data property ---*/ var foo = function() {}; diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-10.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-10.js index a4a5f697dbb..ef1694d18c8 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-10.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-10.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-6-10 description: > - Function.prototype.bind - F can get own accessor property without + SendableFunction.prototype.bind - F can get own accessor property without a get function that overrides an inherited accessor property ---*/ @@ -24,7 +24,7 @@ var foo = function() {}; var obj = foo.bind({}); -Object.defineProperty(Function.prototype, "property", { +Object.defineProperty(SendableFunction.prototype, "property", { get: function() { return 3; }, diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-11.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-11.js index 92359e51756..a7294c7f635 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-11.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-11.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-6-11 description: > - Function.prototype.bind - F can get inherited accessor property + SendableFunction.prototype.bind - F can get inherited accessor property without a get function ---*/ @@ -24,7 +24,7 @@ var foo = function() {}; var obj = foo.bind({}); -Object.defineProperty(Function.prototype, "property", { +Object.defineProperty(SendableFunction.prototype, "property", { set: function() {}, configurable: true }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-12.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-12.js index 12fef88c5db..1092afb4326 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-12.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-12.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-6-12 -description: Function.prototype.bind - F cannot get property which doesn't exist +description: SendableFunction.prototype.bind - F cannot get property which doesn't exist ---*/ var foo = function() {}; diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-2.js index 55d0f14d886..ebf8b9df2c7 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-2.js @@ -15,13 +15,13 @@ /*--- es5id: 15.3.4.5-6-2 -description: Function.prototype.bind - F can get inherited data property +description: SendableFunction.prototype.bind - F can get inherited data property ---*/ var foo = function() {}; var obj = foo.bind({}); -Function.prototype.property = 12; +SendableFunction.prototype.property = 12; assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-3.js index 684fe12f903..8fa95e5b4a2 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-3.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-3.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-6-3 description: > - Function.prototype.bind - F can get own data property that + SendableFunction.prototype.bind - F can get own data property that overrides an inherited data property ---*/ @@ -24,7 +24,7 @@ var foo = function() {}; var obj = foo.bind({}); -Function.prototype.property = 3; +SendableFunction.prototype.property = 3; obj.property = 12; assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-4.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-4.js index daa0e9a8066..eb0e23a0630 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-4.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-4.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-6-4 description: > - Function.prototype.bind - F can get own data property that + SendableFunction.prototype.bind - F can get own data property that overrides an inherited accessor property ---*/ @@ -24,7 +24,7 @@ var foo = function() {}; var obj = foo.bind({}); -Object.defineProperty(Function.prototype, "property", { +Object.defineProperty(SendableFunction.prototype, "property", { get: function() { return 3; }, diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-5.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-5.js index 7605b8c9f0b..6c100038072 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-5.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-5.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-6-5 -description: Function.prototype.bind - F can get own accessor property +description: SendableFunction.prototype.bind - F can get own accessor property ---*/ var foo = function() {}; diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-6.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-6.js index 51b233bcd59..3e62dd4d345 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-6.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-6.js @@ -15,14 +15,14 @@ /*--- es5id: 15.3.4.5-6-6 -description: Function.prototype.bind - F can get inherited accessor property +description: SendableFunction.prototype.bind - F can get inherited accessor property ---*/ var foo = function() {}; var obj = foo.bind({}); -Object.defineProperty(Function.prototype, "property", { +Object.defineProperty(SendableFunction.prototype, "property", { get: function() { return 12; }, diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-7.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-7.js index 0ccfe3d61a8..a6e30152ab5 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-7.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-7.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-6-7 description: > - Function.prototype.bind - F can get own accessor property that + SendableFunction.prototype.bind - F can get own accessor property that overrides an inherited data property ---*/ @@ -24,7 +24,7 @@ var foo = function() {}; var obj = foo.bind({}); -Function.prototype.property = 3; +SendableFunction.prototype.property = 3; Object.defineProperty(obj, "property", { get: function() { return 12; diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-8.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-8.js index f44887ded4c..620a23eb59d 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-8.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-8.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-6-8 description: > - Function.prototype.bind - F can get own accessor property that + SendableFunction.prototype.bind - F can get own accessor property that overrides an inherited accessor property ---*/ @@ -24,7 +24,7 @@ var foo = function() {}; var obj = foo.bind({}); -Object.defineProperty(Function.prototype, "property", { +Object.defineProperty(SendableFunction.prototype, "property", { get: function() { return 3; }, diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-9.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-9.js index ec883ad4734..8c074775673 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-9.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-9.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-6-9 description: > - Function.prototype.bind - F can get own accessor property without + SendableFunction.prototype.bind - F can get own accessor property without a get function ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-1.js index 1f31be4a698..9d6e57832d6 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-1.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-8-1 -description: Function.prototype.bind, type of bound function must be 'function' +description: SendableFunction.prototype.bind, type of bound function must be 'function' ---*/ function foo() {} diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-2.js index 2e2a1800b51..1fe10224438 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-2.js @@ -16,8 +16,8 @@ /*--- es5id: 15.3.4.5-8-2 description: > - Function.prototype.bind, [[Class]] of bound function must be - 'Function' + SendableFunction.prototype.bind, [[Class]] of bound function must be + 'SendableFunction' ---*/ function foo() {} @@ -26,4 +26,4 @@ var o = {}; var bf = foo.bind(o); var s = Object.prototype.toString.call(bf); -assert.sameValue(s, '[object Function]', 's'); +assert.sameValue(s, '[object SendableFunction]', 's'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-1.js index 99781a23ef2..2c34e888212 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-1.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-9-1 -description: Function.prototype.bind, [[Prototype]] is Function.prototype +description: SendableFunction.prototype.bind, [[Prototype]] is SendableFunction.prototype ---*/ function foo() {} @@ -23,4 +23,4 @@ var o = {}; var bf = foo.bind(o); -assert(Function.prototype.isPrototypeOf(bf), 'Function.prototype.isPrototypeOf(bf) !== true'); +assert(SendableFunction.prototype.isPrototypeOf(bf), 'SendableFunction.prototype.isPrototypeOf(bf) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-2.js index d059c52fb22..14448fad882 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-2.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-9-2 description: > - Function.prototype.bind, [[Prototype]] is Function.prototype + SendableFunction.prototype.bind, [[Prototype]] is SendableFunction.prototype (using getPrototypeOf) ---*/ @@ -25,4 +25,4 @@ var o = {}; var bf = foo.bind(o); -assert.sameValue(Object.getPrototypeOf(bf), Function.prototype, 'Object.getPrototypeOf(bf)'); +assert.sameValue(Object.getPrototypeOf(bf), SendableFunction.prototype, 'Object.getPrototypeOf(bf)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-1.js index b548d8f3463..ed3cc4cb5dc 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-1.js @@ -18,13 +18,13 @@ es5id: 15.3.4.5.1-4-1 description: > [[Call]] - 'F''s [[BoundArgs]] is used as the former part of arguments of calling the [[Call]] internal method of 'F''s - [[TargetFunction]] when 'F' is called + [[TargetSendableFunction]] when 'F' is called ---*/ var func = function(x, y, z) { return x + y + z; }; -var newFunc = Function.prototype.bind.call(func, {}, "a", "b", "c"); +var newFunc = SendableFunction.prototype.bind.call(func, {}, "a", "b", "c"); assert.sameValue(newFunc(), "abc", 'newFunc()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-10.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-10.js index cb4d268dd73..226d72d47bd 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-10.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-10.js @@ -28,6 +28,6 @@ var func = function(x) { return this === obj && typeof x === "undefined"; }; -var newFunc = Function.prototype.bind.call(func, obj); +var newFunc = SendableFunction.prototype.bind.call(func, obj); assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-11.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-11.js index b09975505fb..aa34a0c13d6 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-11.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-11.js @@ -28,6 +28,6 @@ var func = function(x) { return this === obj && x === 1 && arguments[0] === 1 && arguments.length === 1 && this.prop === "abc"; }; -var newFunc = Function.prototype.bind.call(func, obj); +var newFunc = SendableFunction.prototype.bind.call(func, obj); assert(newFunc(1), 'newFunc(1) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-12.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-12.js index 005e2ef740f..4aac5e2b5a8 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-12.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-12.js @@ -29,6 +29,6 @@ var func = function(x) { arguments[0] === 1 && arguments.length === 2 && this.prop === "abc"; }; -var newFunc = Function.prototype.bind.call(func, obj); +var newFunc = SendableFunction.prototype.bind.call(func, obj); assert(newFunc(1, 2), 'newFunc(1, 2) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-13.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-13.js index 1bb1b37c9c5..15a0a4ce045 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-13.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-13.js @@ -29,6 +29,6 @@ var func = function(x) { arguments[0] === 1 && arguments.length === 1 && this.prop === "abc"; }; -var newFunc = Function.prototype.bind.call(func, obj, 1); +var newFunc = SendableFunction.prototype.bind.call(func, obj, 1); assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-14.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-14.js index 6ca0cd8741a..fba6b5eaf53 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-14.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-14.js @@ -29,6 +29,6 @@ var func = function(x) { arguments[0] === 1 && arguments.length === 2 && this.prop === "abc"; }; -var newFunc = Function.prototype.bind.call(func, obj, 1); +var newFunc = SendableFunction.prototype.bind.call(func, obj, 1); assert(newFunc(2), 'newFunc(2) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-15.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-15.js index 1a34914977e..be0b5c512c0 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-15.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-15.js @@ -29,6 +29,6 @@ var func = function(x) { arguments[0] === 1 && arguments.length === 2 && this.prop === "abc"; }; -var newFunc = Function.prototype.bind.call(func, obj, 1, 2); +var newFunc = SendableFunction.prototype.bind.call(func, obj, 1, 2); assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-2.js index 8cedefc44cb..1a0428bfb4e 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-2.js @@ -17,7 +17,7 @@ es5id: 15.3.4.5.1-4-2 description: > [[Call]] - 'F''s [[BoundThis]] is used as the 'this' value of - calling the [[Call]] internal method of 'F''s [[TargetFunction]] + calling the [[Call]] internal method of 'F''s [[TargetSendableFunction]] when 'F' is called ---*/ @@ -29,6 +29,6 @@ var func = function() { return this; }; -var newFunc = Function.prototype.bind.call(func, obj); +var newFunc = SendableFunction.prototype.bind.call(func, obj); assert.sameValue(newFunc(), obj, 'newFunc()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-3.js index a02eb0ac7bf..9f2bc452d65 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-3.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-3.js @@ -18,13 +18,13 @@ es5id: 15.3.4.5.1-4-3 description: > [[Call]] - the provided arguments is used as the latter part of arguments of calling the [[Call]] internal method of 'F''s - [[TargetFunction]] when 'F' is called + [[TargetSendableFunction]] when 'F' is called ---*/ var func = function(x, y, z) { return z; }; -var newFunc = Function.prototype.bind.call(func, {}, "a", "b"); +var newFunc = SendableFunction.prototype.bind.call(func, {}, "a", "b"); assert.sameValue(newFunc("c"), "c", 'newFunc("c")'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-4.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-4.js index b60afd86ed5..5a7b27ee3d1 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-4.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-4.js @@ -25,6 +25,6 @@ var func = function() { return arguments.length === 0; }; -var newFunc = Function.prototype.bind.call(func); +var newFunc = SendableFunction.prototype.bind.call(func); assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-5.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-5.js index e38dff04012..cc0efd44a3d 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-5.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-5.js @@ -25,6 +25,6 @@ var func = function() { return arguments[0] === 1; }; -var newFunc = Function.prototype.bind.call(func); +var newFunc = SendableFunction.prototype.bind.call(func); assert(newFunc(1), 'newFunc(1) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-6.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-6.js index f753d148dbd..f5c80b195e6 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-6.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-6.js @@ -28,6 +28,6 @@ var func = function() { return this === obj && arguments.length === 0; }; -var newFunc = Function.prototype.bind.call(func, obj); +var newFunc = SendableFunction.prototype.bind.call(func, obj); assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-7.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-7.js index 2d01229782e..52bcc702a10 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-7.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-7.js @@ -28,6 +28,6 @@ var func = function() { return this === obj && arguments[0] === 1; }; -var newFunc = Function.prototype.bind.call(func, obj, 1); +var newFunc = SendableFunction.prototype.bind.call(func, obj, 1); assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-8.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-8.js index f9f31984a91..8d374cb5b97 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-8.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-8.js @@ -28,6 +28,6 @@ var func = function() { return this === obj && arguments[0] === 1; }; -var newFunc = Function.prototype.bind.call(func, obj); +var newFunc = SendableFunction.prototype.bind.call(func, obj); assert(newFunc(1), 'newFunc(1) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-9.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-9.js index dde2f8e31eb..0b9212e9f87 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-9.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-9.js @@ -28,6 +28,6 @@ var func = function() { return this === obj && arguments[0] === 1 && arguments[1] === 2; }; -var newFunc = Function.prototype.bind.call(func, obj, 1); +var newFunc = SendableFunction.prototype.bind.call(func, obj, 1); assert(newFunc(2), 'newFunc(2) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-1.js index 278a45dc1fb..db3f3a5ec86 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-1.js @@ -18,7 +18,7 @@ es5id: 15.3.4.5.2-4-1 description: > [[Construct]] - 'F''s [[BoundArgs]] is used as the former part of arguments of calling the [[Construct]] internal method of 'F''s - [[TargetFunction]] when 'F' is called as constructor + [[TargetSendableFunction]] when 'F' is called as constructor ---*/ var func = function(x, y, z) { @@ -28,7 +28,7 @@ var func = function(x, y, z) { return objResult; }; -var NewFunc = Function.prototype.bind.call(func, {}, "a", "b", "c"); +var NewFunc = SendableFunction.prototype.bind.call(func, {}, "a", "b", "c"); var newInstance = new NewFunc(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-10.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-10.js index 2afb0d978a1..dae1190307c 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-10.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-10.js @@ -24,7 +24,7 @@ var func = function(x) { return new Boolean(arguments.length === 1 && x === 1 && arguments[0] === 1); }; -var NewFunc = Function.prototype.bind.call(func, {}); +var NewFunc = SendableFunction.prototype.bind.call(func, {}); var newInstance = new NewFunc(1); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-11.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-11.js index b0f92a3ce22..8ddc2f094b9 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-11.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-11.js @@ -24,7 +24,7 @@ var func = function(x) { return new Boolean(arguments.length === 2 && x === 1 && arguments[1] === 2 && arguments[0] === 1); }; -var NewFunc = Function.prototype.bind.call(func, {}); +var NewFunc = SendableFunction.prototype.bind.call(func, {}); var newInstance = new NewFunc(1, 2); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-12.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-12.js index 01bd24050e9..b42c1d15fc2 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-12.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-12.js @@ -24,7 +24,7 @@ var func = function(x) { return new Boolean(arguments.length === 1 && x === 1 && arguments[0] === 1); }; -var NewFunc = Function.prototype.bind.call(func, {}, 1); +var NewFunc = SendableFunction.prototype.bind.call(func, {}, 1); var newInstance = new NewFunc(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-13.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-13.js index 80d174ce88b..233ba2654b5 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-13.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-13.js @@ -24,7 +24,7 @@ var func = function(x) { return new Boolean(arguments.length === 2 && x === 1 && arguments[1] === 2 && arguments[0] === 1); }; -var NewFunc = Function.prototype.bind.call(func, {}, 1); +var NewFunc = SendableFunction.prototype.bind.call(func, {}, 1); var newInstance = new NewFunc(2); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-14.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-14.js index 013b7b02101..585f78423d5 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-14.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-14.js @@ -24,7 +24,7 @@ var func = function(x) { return new Boolean(arguments.length === 2 && x === 1 && arguments[1] === 2 && arguments[0] === 1); }; -var NewFunc = Function.prototype.bind.call(func, {}, 1, 2); +var NewFunc = SendableFunction.prototype.bind.call(func, {}, 1, 2); var newInstance = new NewFunc(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-2.js index 7cd139932ba..ffe4862dbae 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-2.js @@ -18,7 +18,7 @@ es5id: 15.3.4.5.2-4-2 description: > [[Construct]] - the provided arguments is used as the latter part of arguments of calling the [[Construct]] internal method of 'F''s - [[TargetFunction]] when 'F' is called as constructor + [[TargetSendableFunction]] when 'F' is called as constructor ---*/ var func = function(x, y, z) { @@ -28,7 +28,7 @@ var func = function(x, y, z) { return objResult; }; -var NewFunc = Function.prototype.bind.call(func, {}); +var NewFunc = SendableFunction.prototype.bind.call(func, {}); var newInstance = new NewFunc("a", "b", "c"); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-3.js index e599ecbeae3..4daccdf2821 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-3.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-3.js @@ -25,7 +25,7 @@ var func = function() { return new Boolean(arguments.length === 0); }; -var NewFunc = Function.prototype.bind.call(func); +var NewFunc = SendableFunction.prototype.bind.call(func); var newInstance = new NewFunc(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-4.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-4.js index cd4f3fd9c7c..94b2693722a 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-4.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-4.js @@ -25,7 +25,7 @@ var func = function() { return new Boolean(arguments[0] === 1 && arguments.length === 1); }; -var NewFunc = Function.prototype.bind.call(func); +var NewFunc = SendableFunction.prototype.bind.call(func); var newInstance = new NewFunc(1); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-5.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-5.js index 4d56686e9f6..35beaf51107 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-5.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-5.js @@ -30,7 +30,7 @@ var func = function() { this.verifyThis === "verifyThis"); }; -var NewFunc = Function.prototype.bind.call(func, obj); +var NewFunc = SendableFunction.prototype.bind.call(func, obj); var newInstance = new NewFunc(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-6.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-6.js index b85d9c48635..d9c82e4dccc 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-6.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-6.js @@ -24,7 +24,7 @@ var func = function() { return new Boolean(arguments.length === 1 && arguments[0] === 1); }; -var NewFunc = Function.prototype.bind.call(func, {}, 1); +var NewFunc = SendableFunction.prototype.bind.call(func, {}, 1); var newInstance = new NewFunc(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-7.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-7.js index a6b7134d47f..1bbabd83c91 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-7.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-7.js @@ -24,7 +24,7 @@ var func = function() { return new Boolean(arguments.length === 1 && arguments[0] === 1); }; -var NewFunc = Function.prototype.bind.call(func, {}); +var NewFunc = SendableFunction.prototype.bind.call(func, {}); var newInstance = new NewFunc(1); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-8.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-8.js index 95d2908bd3e..0efcee1c626 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-8.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-8.js @@ -24,7 +24,7 @@ var func = function() { return new Boolean(arguments.length === 2 && arguments[0] === 1 && arguments[1] === 2); }; -var NewFunc = Function.prototype.bind.call(func, {}, 1); +var NewFunc = SendableFunction.prototype.bind.call(func, {}, 1); var newInstance = new NewFunc(2); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-9.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-9.js index 7a6032ba088..f6e7123affb 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-9.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-9.js @@ -24,7 +24,7 @@ var func = function(x) { return new Boolean(arguments.length === 0 && typeof x === "undefined"); }; -var NewFunc = Function.prototype.bind.call(func, {}); +var NewFunc = SendableFunction.prototype.bind.call(func, {}); var newInstance = new NewFunc(); diff --git a/test/sendable/builtins/Function/prototype/bind/BoundFunction_restricted-properties.js b/test/sendable/builtins/Function/prototype/bind/BoundFunction_restricted-properties.js index 4e405be4756..c3dadc7282e 100644 --- a/test/sendable/builtins/Function/prototype/bind/BoundFunction_restricted-properties.js +++ b/test/sendable/builtins/Function/prototype/bind/BoundFunction_restricted-properties.js @@ -15,17 +15,17 @@ /*--- description: > - Functions created using Function.prototype.bind() do not have own + SendableFunctions created using SendableFunction.prototype.bind() do not have own properties "caller" or "arguments", but inherit them from - %FunctionPrototype%. + %SendableFunctionPrototype%. es6id: 16.1 ---*/ function target() {} var bound = target.bind(null); -assert.sameValue(bound.hasOwnProperty('caller'), false, 'Functions created using Function.prototype.bind() do not have own property "caller"'); -assert.sameValue(bound.hasOwnProperty('arguments'), false, 'Functions created using Function.prototype.bind() do not have own property "arguments"'); +assert.sameValue(bound.hasOwnProperty('caller'), false, 'SendableFunctions created using SendableFunction.prototype.bind() do not have own property "caller"'); +assert.sameValue(bound.hasOwnProperty('arguments'), false, 'SendableFunctions created using SendableFunction.prototype.bind() do not have own property "arguments"'); assert.throws(TypeError, function() { return bound.caller; diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A13.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A13.js index fbd72df4017..c61ea80082c 100644 --- a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A13.js +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A13.js @@ -19,5 +19,5 @@ description: If IsCallable(func) is false, then throw a TypeError exception. ---*/ assert.throws(TypeError, function() { - Function.prototype.bind.call(undefined, {}); -}, 'Function.prototype.bind.call(undefined, {}) throws a TypeError exception'); + SendableFunction.prototype.bind.call(undefined, {}); +}, 'SendableFunction.prototype.bind.call(undefined, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A14.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A14.js index bb460354743..da9dc855604 100644 --- a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A14.js +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A14.js @@ -19,5 +19,5 @@ description: If IsCallable(func) is false, then throw a TypeError exception. ---*/ assert.throws(TypeError, function() { - Function.prototype.bind.call(null, {}); -}, 'Function.prototype.bind.call(null, {}) throws a TypeError exception'); + SendableFunction.prototype.bind.call(null, {}); +}, 'SendableFunction.prototype.bind.call(null, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A15.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A15.js index d4ced3fb93d..550b2c3810f 100644 --- a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A15.js +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A15.js @@ -19,5 +19,5 @@ description: If IsCallable(func) is false, then throw a TypeError exception. ---*/ assert.throws(TypeError, function() { - Function.prototype.bind.call({}, {}); -}, 'Function.prototype.bind.call({}, {}) throws a TypeError exception'); + SendableFunction.prototype.bind.call({}, {}); +}, 'SendableFunction.prototype.bind.call({}, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A16.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A16.js index e168e5350af..c6ba142580d 100644 --- a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A16.js +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A16.js @@ -24,10 +24,10 @@ description: > var re = (/x/); if (typeof re === 'function') { - Function.prototype.bind.call(re, undefined); + SendableFunction.prototype.bind.call(re, undefined); } else { try { - Function.prototype.bind.call(re, undefined); + SendableFunction.prototype.bind.call(re, undefined); throw new Test262Error('#1: If IsCallable(func) is false, ' + 'then (bind should) throw a TypeError exception'); } catch (e) { diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A3.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A3.js index 5e170ca34ca..691b17d1a24 100644 --- a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A3.js +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A3.js @@ -15,9 +15,9 @@ /*--- es5id: 15.3.4.5_A3 -description: Function.prototype.bind must exist +description: SendableFunction.prototype.bind must exist ---*/ assert( - 'bind' in Function.prototype, - 'The result of evaluating (\'bind\' in Function.prototype) is expected to be true' + 'bind' in SendableFunction.prototype, + 'The result of evaluating (\'bind\' in SendableFunction.prototype) is expected to be true' ); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A4.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A4.js index 47739305ac4..caf999f0594 100644 --- a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A4.js +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A4.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5_A4 description: > - Function.prototype.bind call the original's internal [[Call]] + SendableFunction.prototype.bind call the original's internal [[Call]] method rather than its .apply method. ---*/ @@ -24,6 +24,6 @@ function foo() {} var b = foo.bind(33, 44); foo.apply = function() { - throw new Test262Error("Function.prototype.bind called original's .apply method"); + throw new Test262Error("SendableFunction.prototype.bind called original's .apply method"); }; b(55, 66); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A5.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A5.js index bbb3c367396..72f7f3478e0 100644 --- a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A5.js +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A5.js @@ -16,12 +16,12 @@ /*--- es5id: 15.3.4.5_A5 description: > - Function.prototype.bind must curry [[Construct]] as well as + SendableFunction.prototype.bind must curry [[Construct]] as well as [[Call]]. ---*/ function construct(f, args) { - var bound = Function.prototype.bind.apply(f, [null].concat(args)); + var bound = SendableFunction.prototype.bind.apply(f, [null].concat(args)); return new bound(); } var d = construct(Date, [1957, 4, 27]); diff --git a/test/sendable/builtins/Function/prototype/bind/get-fn-realm-recursive.js b/test/sendable/builtins/Function/prototype/bind/get-fn-realm-recursive.js index 5cef5269a75..c1dd7d9da9c 100644 --- a/test/sendable/builtins/Function/prototype/bind/get-fn-realm-recursive.js +++ b/test/sendable/builtins/Function/prototype/bind/get-fn-realm-recursive.js @@ -17,7 +17,7 @@ esid: sec-getfunctionrealm description: > The realm of a bound function exotic object is the realm of its target function. - GetFunctionRealm is called recursively. + GetSendableFunctionRealm is called recursively. info: | Object ( [ value ] ) @@ -35,18 +35,18 @@ info: | [...] 3. Let proto be ? Get(constructor, "prototype"). 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). + a. Let realm be ? GetSendableFunctionRealm(constructor). b. Set proto to realm's intrinsic object named intrinsicDefaultProto. 5. Return proto. - GetFunctionRealm ( obj ) + GetSendableFunctionRealm ( obj ) [...] 2. If obj has a [[Realm]] internal slot, then a. Return obj.[[Realm]]. 3. If obj is a bound function exotic object, then - a. Let target be obj.[[BoundTargetFunction]]. - b. Return ? GetFunctionRealm(target). + a. Let target be obj.[[BoundTargetSendableFunction]]. + b. Return ? GetSendableFunctionRealm(target). features: [cross-realm, Reflect] ---*/ @@ -55,11 +55,11 @@ var realm2 = $262.createRealm().global; var realm3 = $262.createRealm().global; var realm4 = $262.createRealm().global; -var newTarget = new realm1.Function(); +var newTarget = new realm1.SendableFunction(); newTarget.prototype = 1; -var boundNewTarget = realm2.Function.prototype.bind.call(newTarget); -var boundBoundNewTarget = realm3.Function.prototype.bind.call(boundNewTarget); +var boundNewTarget = realm2.SendableFunction.prototype.bind.call(newTarget); +var boundBoundNewTarget = realm3.SendableFunction.prototype.bind.call(boundNewTarget); var object = Reflect.construct(realm4.Object, [], boundBoundNewTarget); assert(object instanceof realm1.Object); diff --git a/test/sendable/builtins/Function/prototype/bind/get-fn-realm.js b/test/sendable/builtins/Function/prototype/bind/get-fn-realm.js index 6e66a773f47..a472c361708 100644 --- a/test/sendable/builtins/Function/prototype/bind/get-fn-realm.js +++ b/test/sendable/builtins/Function/prototype/bind/get-fn-realm.js @@ -39,18 +39,18 @@ info: | [...] 3. Let proto be ? Get(constructor, "prototype"). 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). + a. Let realm be ? GetSendableFunctionRealm(constructor). b. Set proto to realm's intrinsic object named intrinsicDefaultProto. 5. Return proto. - GetFunctionRealm ( obj ) + GetSendableFunctionRealm ( obj ) [...] 2. If obj has a [[Realm]] internal slot, then a. Return obj.[[Realm]]. 3. If obj is a bound function exotic object, then - a. Let target be obj.[[BoundTargetFunction]]. - b. Return ? GetFunctionRealm(target). + a. Let target be obj.[[BoundTargetSendableFunction]]. + b. Return ? GetSendableFunctionRealm(target). features: [cross-realm, Reflect] ---*/ @@ -58,10 +58,10 @@ var realm1 = $262.createRealm().global; var realm2 = $262.createRealm().global; var realm3 = $262.createRealm().global; -var newTarget = new realm1.Function(); +var newTarget = new realm1.SendableFunction(); newTarget.prototype = "str"; -var boundNewTarget = realm2.Function.prototype.bind.call(newTarget); +var boundNewTarget = realm2.SendableFunction.prototype.bind.call(newTarget); var date = Reflect.construct(realm3.Date, [], boundNewTarget); assert(date instanceof realm1.Date); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-default-value.js b/test/sendable/builtins/Function/prototype/bind/instance-length-default-value.js index 1fa41aa956f..58327375f2d 100644 --- a/test/sendable/builtins/Function/prototype/bind/instance-length-default-value.js +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-default-value.js @@ -19,7 +19,7 @@ description: > "length" value of a bound function defaults to 0. Non-own and non-number "length" values of target function are ignored. info: | - Function.prototype.bind ( thisArg, ...args ) + SendableFunction.prototype.bind ( thisArg, ...args ) [...] 5. Let targetHasLength be ? HasOwnProperty(Target, "length"). @@ -30,7 +30,7 @@ info: | i. Set targetLen to ! ToInteger(targetLen). ii. Let L be the larger of 0 and the result of targetLen minus the number of elements of args. 7. Else, let L be 0. - 8. Perform ! SetFunctionLength(F, L). + 8. Perform ! SetSendableFunctionLength(F, L). [...] features: [Symbol] ---*/ @@ -60,5 +60,5 @@ function bar() {} Object.setPrototypeOf(bar, {length: 42}); assert(delete bar.length); -var bound = Function.prototype.bind.call(bar, null, 1); +var bound = SendableFunction.prototype.bind.call(bar, null, 1); assert.sameValue(bound.length, 0, "not own"); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-exceeds-int32.js b/test/sendable/builtins/Function/prototype/bind/instance-length-exceeds-int32.js index a25c3bbe7ce..766306a2350 100644 --- a/test/sendable/builtins/Function/prototype/bind/instance-length-exceeds-int32.js +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-exceeds-int32.js @@ -18,7 +18,7 @@ esid: sec-function.prototype.bind description: > The target function length can exceed 2**31-1. info: | - 19.2.3.2 Function.prototype.bind ( thisArg, ...args ) + 19.2.3.2 SendableFunction.prototype.bind ( thisArg, ...args ) ... 6. If targetHasLength is true, then @@ -28,7 +28,7 @@ info: | i. Let targetLen be ToInteger(targetLen). ii. Let L be the larger of 0 and the result of targetLen minus the number of elements of args. ... - 8. Perform ! SetFunctionLength(F, L). + 8. Perform ! SetSendableFunctionLength(F, L). ... ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-prop-desc.js b/test/sendable/builtins/Function/prototype/bind/instance-length-prop-desc.js index 398da40cf83..12275a456ca 100644 --- a/test/sendable/builtins/Function/prototype/bind/instance-length-prop-desc.js +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-prop-desc.js @@ -18,13 +18,13 @@ esid: sec-function.prototype.bind description: > "length" property of a bound function has correct descriptor. info: | - Function.prototype.bind ( thisArg, ...args ) + SendableFunction.prototype.bind ( thisArg, ...args ) [...] - 8. Perform ! SetFunctionLength(F, L). + 8. Perform ! SetSendableFunctionLength(F, L). [...] - SetFunctionLength ( F, length ) + SetSendableFunctionLength ( F, length ) [...] 4. Return ! DefinePropertyOrThrow(F, "length", PropertyDescriptor { [[Value]]: diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-remaining-args.js b/test/sendable/builtins/Function/prototype/bind/instance-length-remaining-args.js index 0002a9e583f..2aff77dfaae 100644 --- a/test/sendable/builtins/Function/prototype/bind/instance-length-remaining-args.js +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-remaining-args.js @@ -19,7 +19,7 @@ description: > "length" value of a bound function is set to remaining number of arguments expected by target function. Extra arguments are ignored. info: | - Function.prototype.bind ( thisArg, ...args ) + SendableFunction.prototype.bind ( thisArg, ...args ) [...] 5. Let targetHasLength be ? HasOwnProperty(Target, "length"). @@ -30,7 +30,7 @@ info: | i. Set targetLen to ! ToInteger(targetLen). ii. Let L be the larger of 0 and the result of targetLen minus the number of elements of args. 7. Else, let L be 0. - 8. Perform ! SetFunctionLength(F, L). + 8. Perform ! SetSendableFunctionLength(F, L). [...] ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-tointeger.js b/test/sendable/builtins/Function/prototype/bind/instance-length-tointeger.js index 788c3b92ffe..b1af39dca99 100644 --- a/test/sendable/builtins/Function/prototype/bind/instance-length-tointeger.js +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-tointeger.js @@ -19,7 +19,7 @@ description: > "length" value of a bound function is non-negative integer. ToInteger is performed on "length" value of target function. info: | - Function.prototype.bind ( thisArg, ...args ) + SendableFunction.prototype.bind ( thisArg, ...args ) [...] 5. Let targetHasLength be ? HasOwnProperty(Target, "length"). @@ -33,7 +33,7 @@ info: | 2. Assert: targetLenAsInt is finite. 3. Let argCount be the number of elements in args. 4. Set L to max(targetLenAsInt - argCount, 0). - 7. Perform ! SetFunctionLength(F, L). + 7. Perform ! SetSendableFunctionLength(F, L). [...] ToInteger ( argument ) diff --git a/test/sendable/builtins/Function/prototype/bind/instance-name-chained.js b/test/sendable/builtins/Function/prototype/bind/instance-name-chained.js index 214eff322b1..dac93146392 100644 --- a/test/sendable/builtins/Function/prototype/bind/instance-name-chained.js +++ b/test/sendable/builtins/Function/prototype/bind/instance-name-chained.js @@ -21,7 +21,7 @@ info: | 12. Let targetName be Get(Target, "name"). 13. ReturnIfAbrupt(targetName). 14. If Type(targetName) is not String, let targetName be the empty string. - 15. Perform SetFunctionName(F, targetName, "bound"). + 15. Perform SetSendableFunctionName(F, targetName, "bound"). includes: [propertyHelper.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/instance-name-non-string.js b/test/sendable/builtins/Function/prototype/bind/instance-name-non-string.js index 8ca121d6950..58d05bcdcc9 100644 --- a/test/sendable/builtins/Function/prototype/bind/instance-name-non-string.js +++ b/test/sendable/builtins/Function/prototype/bind/instance-name-non-string.js @@ -21,7 +21,7 @@ info: | 12. Let targetName be Get(Target, "name"). 13. ReturnIfAbrupt(targetName). 14. If Type(targetName) is not String, let targetName be the empty string. - 15. Perform SetFunctionName(F, targetName, "bound"). + 15. Perform SetSendableFunctionName(F, targetName, "bound"). includes: [propertyHelper.js] features: [Symbol] ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/instance-name.js b/test/sendable/builtins/Function/prototype/bind/instance-name.js index a9ba76452b3..436d58709be 100644 --- a/test/sendable/builtins/Function/prototype/bind/instance-name.js +++ b/test/sendable/builtins/Function/prototype/bind/instance-name.js @@ -20,7 +20,7 @@ info: | 12. Let targetName be Get(Target, "name"). 13. ReturnIfAbrupt(targetName). 14. If Type(targetName) is not String, let targetName be the empty string. - 15. Perform SetFunctionName(F, targetName, "bound"). + 15. Perform SetSendableFunctionName(F, targetName, "bound"). includes: [propertyHelper.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/length.js b/test/sendable/builtins/Function/prototype/bind/length.js index 4c537fdfa64..e41d580eac2 100644 --- a/test/sendable/builtins/Function/prototype/bind/length.js +++ b/test/sendable/builtins/Function/prototype/bind/length.js @@ -16,9 +16,9 @@ /*--- esid: sec-function.prototype.bind description: > - Function.prototype.bind.length is 1. + SendableFunction.prototype.bind.length is 1. info: | - Function.prototype.bind ( thisArg, ...args ) + SendableFunction.prototype.bind ( thisArg, ...args ) ECMAScript Standard Built-in Objects @@ -33,7 +33,7 @@ info: | includes: [propertyHelper.js] ---*/ -verifyProperty(Function.prototype.bind, "length", { +verifyProperty(SendableFunction.prototype.bind, "length", { value: 1, writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/bind/name.js b/test/sendable/builtins/Function/prototype/bind/name.js index c5dcb7c40e4..12d8cfdeae5 100644 --- a/test/sendable/builtins/Function/prototype/bind/name.js +++ b/test/sendable/builtins/Function/prototype/bind/name.js @@ -16,22 +16,22 @@ /*--- es6id: 19.2.3.2 description: > - Function.prototype.bind.name is "bind". + SendableFunction.prototype.bind.name is "bind". info: | - Function.prototype.bind ( thisArg , ...args) + SendableFunction.prototype.bind ( thisArg , ...args) 17 ECMAScript Standard Built-in Objects: - Every built-in Function object, including constructors, that is not + Every built-in SendableFunction 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 + Unless otherwise specified, the name property of a built-in SendableFunction object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. includes: [propertyHelper.js] ---*/ -verifyProperty(Function.prototype.bind, "name", { +verifyProperty(SendableFunction.prototype.bind, "name", { value: "bind", writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/bind/not-a-constructor.js b/test/sendable/builtins/Function/prototype/bind/not-a-constructor.js index d5d4480ffd5..1b63d874d00 100644 --- a/test/sendable/builtins/Function/prototype/bind/not-a-constructor.js +++ b/test/sendable/builtins/Function/prototype/bind/not-a-constructor.js @@ -16,9 +16,9 @@ /*--- esid: sec-ecmascript-standard-built-in-objects description: > - Function.prototype.bind does not implement [[Construct]], is not new-able + SendableFunction.prototype.bind does not implement [[Construct]], is not new-able info: | - ECMAScript Function Objects + ECMAScript SendableFunction Objects Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method unless otherwise specified in @@ -34,12 +34,12 @@ features: [Reflect.construct, arrow-function] ---*/ assert.sameValue( - isConstructor(Function.prototype.bind), + isConstructor(SendableFunction.prototype.bind), false, - 'isConstructor(Function.prototype.bind) must return false' + 'isConstructor(SendableFunction.prototype.bind) must return false' ); assert.throws(TypeError, () => { - new Function.prototype.bind(); + new SendableFunction.prototype.bind(); }); diff --git a/test/sendable/builtins/Function/prototype/bind/proto-from-ctor-realm.js b/test/sendable/builtins/Function/prototype/bind/proto-from-ctor-realm.js index d10b135143b..ddbfd2c9002 100644 --- a/test/sendable/builtins/Function/prototype/bind/proto-from-ctor-realm.js +++ b/test/sendable/builtins/Function/prototype/bind/proto-from-ctor-realm.js @@ -25,14 +25,14 @@ info: | [...] 3. Let proto be ? Get(constructor, "prototype"). 4. If Type(proto) is not Object, then - a. Let realm be ? GetFunctionRealm(constructor). + a. Let realm be ? GetSendableFunctionRealm(constructor). b. Let proto be realm's intrinsic object named intrinsicDefaultProto. [...] features: [cross-realm, Reflect] ---*/ var other = $262.createRealm().global; -var C = new other.Function(); +var C = new other.SendableFunction(); C.prototype = null; var D = function() {}.bind(); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A10.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A10.js index 7902645d802..20b25aa5e74 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A10.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A10.js @@ -14,28 +14,28 @@ */ /*--- -info: The Function.prototype.call.length property has the attribute ReadOnly +info: The SendableFunction.prototype.call.length property has the attribute ReadOnly es5id: 15.3.4.4_A10 description: > - Checking if varying the Function.prototype.call.length property + Checking if varying the SendableFunction.prototype.call.length property fails includes: [propertyHelper.js] ---*/ assert( - Function.prototype.call.hasOwnProperty('length'), - 'Function.prototype.call.hasOwnProperty(\'length\') must return true' + SendableFunction.prototype.call.hasOwnProperty('length'), + 'SendableFunction.prototype.call.hasOwnProperty(\'length\') must return true' ); -var obj = Function.prototype.call.length; +var obj = SendableFunction.prototype.call.length; -verifyNotWritable(Function.prototype.call, "length", null, function() { +verifyNotWritable(SendableFunction.prototype.call, "length", null, function() { return "shifted"; }); assert.sameValue( - Function.prototype.call.length, + SendableFunction.prototype.call.length, obj, - 'The value of Function.prototype.call.length is expected to equal the value of obj' + 'The value of SendableFunction.prototype.call.length is expected to equal the value of obj' ); // TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A11.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A11.js index de83c69a007..4a421e5bd9c 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A11.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A11.js @@ -14,24 +14,24 @@ */ /*--- -info: The Function.prototype.call.length property has the attribute DontEnum +info: The SendableFunction.prototype.call.length property has the attribute DontEnum es5id: 15.3.4.4_A11 description: > - Checking if enumerating the Function.prototype.call.length + Checking if enumerating the SendableFunction.prototype.call.length property fails ---*/ assert( - Function.prototype.call.hasOwnProperty('length'), - 'Function.prototype.call.hasOwnProperty(\'length\') must return true' + SendableFunction.prototype.call.hasOwnProperty('length'), + 'SendableFunction.prototype.call.hasOwnProperty(\'length\') must return true' ); assert( - !Function.prototype.call.propertyIsEnumerable('length'), - 'The value of !Function.prototype.call.propertyIsEnumerable(\'length\') is expected to be true' + !SendableFunction.prototype.call.propertyIsEnumerable('length'), + 'The value of !SendableFunction.prototype.call.propertyIsEnumerable(\'length\') is expected to be true' ); // CHECK#2 -for (var p in Function.prototype.call) { +for (var p in SendableFunction.prototype.call) { assert.notSameValue(p, "length", 'The value of p is not "length"'); } diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A12.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A12.js index b6f25a2ee4b..8d8f232f253 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A12.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A12.js @@ -14,14 +14,14 @@ */ /*--- -info: Function.prototype.call has not prototype property +info: SendableFunction.prototype.call has not prototype property es5id: 15.3.4.4_A12 description: > Checking if obtaining the prototype property of - Function.prototype.call fails + SendableFunction.prototype.call fails ---*/ assert.sameValue( - Function.prototype.call.prototype, + SendableFunction.prototype.call.prototype, undefined, - 'The value of Function.prototype.call.prototype is expected to equal undefined' + 'The value of SendableFunction.prototype.call.prototype is expected to equal undefined' ); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A13.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A13.js index 5be30476cb7..a89b5d8c0a1 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A13.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A13.js @@ -19,5 +19,5 @@ description: If IsCallable(func) is false, then throw a TypeError exception. ---*/ assert.throws(TypeError, function() { - Function.prototype.call.call(undefined, {}); -}, 'Function.prototype.call.call(undefined, {}) throws a TypeError exception'); + SendableFunction.prototype.call.call(undefined, {}); +}, 'SendableFunction.prototype.call.call(undefined, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A14.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A14.js index 1b9dad5a51c..fea28e2a587 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A14.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A14.js @@ -19,5 +19,5 @@ description: If IsCallable(func) is false, then throw a TypeError exception. ---*/ assert.throws(TypeError, function() { - Function.prototype.call.call(null, {}); -}, 'Function.prototype.call.call(null, {}) throws a TypeError exception'); + SendableFunction.prototype.call.call(null, {}); +}, 'SendableFunction.prototype.call.call(null, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A15.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A15.js index 4bc68486bd3..05e6bcc43e8 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A15.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A15.js @@ -19,5 +19,5 @@ description: If IsCallable(func) is false, then throw a TypeError exception. ---*/ assert.throws(TypeError, function() { - Function.prototype.call.call({}, {}); -}, 'Function.prototype.call.call({}, {}) throws a TypeError exception'); + SendableFunction.prototype.call.call({}, {}); +}, 'SendableFunction.prototype.call.call({}, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A16.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A16.js index 96793333d0a..1d3ad67eb74 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A16.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A16.js @@ -24,10 +24,10 @@ description: > var re = (/x/); if (typeof re === 'function') { - Function.prototype.call.call(re, undefined, 'x'); + SendableFunction.prototype.call.call(re, undefined, 'x'); } else { try { - Function.prototype.bind.call(re, undefined); + SendableFunction.prototype.bind.call(re, undefined); throw new Test262Error('#1: If IsCallable(func) is false, ' + 'then (bind should) throw a TypeError exception'); } catch (e) { diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T1.js index 98d9e2a9bd6..b299d3c3931 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T1.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T1.js @@ -21,10 +21,10 @@ info: | es5id: 15.3.4.4_A1_T1 description: > Call "call" method of the object that does not have a [[Call]] - property. Prototype of the object is Function() + property. Prototype of the object is SendableFunction() ---*/ -var proto = Function(); +var proto = SendableFunction(); function FACTORY() {} diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T2.js index d6c36099f41..e8f8ee2c6bc 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T2.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T2.js @@ -21,12 +21,12 @@ info: | es5id: 15.3.4.4_A1_T2 description: > Calling "call" method of the object that does not have a [[Call]] - property. Prototype of the object is Function.prototype + property. Prototype of the object is SendableFunction.prototype ---*/ function FACTORY() {} -FACTORY.prototype = Function.prototype; +FACTORY.prototype = SendableFunction.prototype; var obj = new FACTORY; diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T1.js index 6c2f2783086..68362aee9cc 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T1.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T1.js @@ -16,18 +16,18 @@ /*--- info: The length property of the call method is 1 es5id: 15.3.4.4_A2_T1 -description: Checking Function.prototype.call.length +description: Checking SendableFunction.prototype.call.length ---*/ assert.sameValue( - typeof Function.prototype.call, + typeof SendableFunction.prototype.call, "function", - 'The value of `typeof Function.prototype.call` is expected to be "function"' + 'The value of `typeof SendableFunction.prototype.call` is expected to be "function"' ); assert.notSameValue( - typeof Function.prototype.call.length, + typeof SendableFunction.prototype.call.length, "undefined", - 'The value of typeof Function.prototype.call.length is not "undefined"' + 'The value of typeof SendableFunction.prototype.call.length is not "undefined"' ); -assert.sameValue(Function.prototype.call.length, 1, 'The value of Function.prototype.call.length is expected to be 1'); +assert.sameValue(SendableFunction.prototype.call.length, 1, 'The value of SendableFunction.prototype.call.length is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T2.js index 82ab51d9ddb..d0c1c60ee33 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T2.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T2.js @@ -16,10 +16,10 @@ /*--- info: The length property of the call method is 1 es5id: 15.3.4.4_A2_T2 -description: Checking f.call.length, where f is new Function +description: Checking f.call.length, where f is new SendableFunction ---*/ -var f = new Function; +var f = new SendableFunction; assert.sameValue(typeof f.call, "function", 'The value of `typeof f.call` is expected to be "function"'); assert.notSameValue(typeof f.call.length, "undefined", 'The value of typeof f.call.length is not "undefined"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T1.js index 0c9c5555236..0a5cd917e26 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T1.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T1.js @@ -21,6 +21,6 @@ es5id: 15.3.4.4_A3_T1 description: Not any arguments at call function ---*/ -Function("this.field=\"strawberry\"").call(); +SendableFunction("this.field=\"strawberry\"").call(); assert.sameValue(this["field"], "strawberry", 'The value of this["field"] is expected to be "strawberry"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T2.js index f21fa54f827..ff6d3f91680 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T2.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T2.js @@ -21,6 +21,6 @@ es5id: 15.3.4.4_A3_T2 description: Argument at call function is null ---*/ -Function("this.field=\"green\"").call(null); +SendableFunction("this.field=\"green\"").call(null); assert.sameValue(this["field"], "green", 'The value of this["field"] is expected to be "green"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T3.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T3.js index 33e6d74da99..3deb6e0cef5 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T3.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T3.js @@ -21,6 +21,6 @@ es5id: 15.3.4.4_A3_T3 description: Argument at call function is void 0 ---*/ -Function("this.field=\"battle\"").call(void 0); +SendableFunction("this.field=\"battle\"").call(void 0); assert.sameValue(this["field"], "battle", 'The value of this["field"] is expected to be "battle"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T4.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T4.js index 5bae83bbf38..b2c3b3e9cf6 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T4.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T4.js @@ -21,6 +21,6 @@ es5id: 15.3.4.4_A3_T4 description: Argument at call function is undefined ---*/ -Function("this.field=\"oil\"").call(undefined); +SendableFunction("this.field=\"oil\"").call(undefined); assert.sameValue(this["field"], "oil", 'The value of this["field"] is expected to be "oil"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T5.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T5.js index c3f5cdf5fbc..dfcaad534fa 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T5.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T5.js @@ -24,7 +24,7 @@ description: > ---*/ function FACTORY() { - Function("this.feat=\"in da haus\"").call(); + SendableFunction("this.feat=\"in da haus\"").call(); } var obj = new FACTORY; diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T7.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T7.js index 3929e5c66a9..1540b6be204 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T7.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T7.js @@ -24,7 +24,7 @@ description: > ---*/ (function FACTORY() { - Function("this.feat=\"in da haus\"").call(void 0); + SendableFunction("this.feat=\"in da haus\"").call(void 0); })(); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T9.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T9.js index f80eb61f42a..85943ef6f22 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T9.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T9.js @@ -21,7 +21,7 @@ es5id: 15.3.4.4_A3_T9 description: Checking by using eval, argument at call function is void 0 ---*/ -eval(" Function(\"this.feat=1\").call(void 0) "); +eval(" SendableFunction(\"this.feat=1\").call(void 0) "); assert.sameValue(this["feat"], 1, 'The value of this["feat"] is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T1.js index 1511c7518ae..7c30d4d6bac 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T1.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T1.js @@ -23,7 +23,7 @@ description: thisArg is number var obj = 1; -var retobj = Function("this.touched= true; return this;").call(obj); +var retobj = SendableFunction("this.touched= true; return this;").call(obj); assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T2.js index e19886d5cc5..147a0923206 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T2.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T2.js @@ -23,7 +23,7 @@ description: thisArg is boolean true var obj = true; -var retobj = new Function("this.touched= true; return this;").call(obj); +var retobj = new SendableFunction("this.touched= true; return this;").call(obj); assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T7.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T7.js index e016a938b27..f4823951d5a 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T7.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T7.js @@ -23,6 +23,6 @@ description: thisArg is new Number() var obj = new Number(1); -Function("this.touched= true;").call(obj); +SendableFunction("this.touched= true;").call(obj); assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T8.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T8.js index 00dad7d2275..bebcd193c41 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T8.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T8.js @@ -18,11 +18,11 @@ info: | If thisArg is not null(defined) the called function is passed ToObject(thisArg) as the this value es5id: 15.3.4.4_A5_T8 -description: thisArg is Function() +description: thisArg is SendableFunction() ---*/ -var obj = Function(); +var obj = SendableFunction(); -new Function("this.touched= true; return this;").call(obj); +new SendableFunction("this.touched= true; return this;").call(obj); assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T1.js index aed8860f9a3..4d1f38e8788 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T1.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T1.js @@ -21,7 +21,7 @@ es5id: 15.3.4.4_A6_T1 description: Argunemts of call function is (null,[1]) ---*/ -Function("a1,a2,a3", "this.shifted=a1;").call(null, [1]); +SendableFunction("a1,a2,a3", "this.shifted=a1;").call(null, [1]); assert.sameValue( this["shifted"].constructor, diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T10.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T10.js index b15f1c286f9..a52b50c0094 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T10.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T10.js @@ -26,7 +26,7 @@ description: > var obj = {}; (function() { - Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(obj, arguments, "", "2"); + SendableFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(obj, arguments, "", "2"); })("", 4, 2, "a"); assert.sameValue(obj["shifted"], "42", 'The value of obj["shifted"] is expected to be "42"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T2.js index f624f6d08ee..36521ba0686 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T2.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T2.js @@ -21,7 +21,7 @@ es5id: 15.3.4.4_A6_T2 description: Argunemts of call function is (null,[3,2,1]) ---*/ -new Function("a1,a2", "a3", "this.shifted=a1;").call(null, [3, 2, 1]); +new SendableFunction("a1,a2", "a3", "this.shifted=a1;").call(null, [3, 2, 1]); assert.sameValue(this["shifted"].length, 3); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T3.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T3.js index e03d0d0aa4a..14bc8526fa1 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T3.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T3.js @@ -33,7 +33,7 @@ var p = { var obj = {}; -Function(p, "a2,a3", "this.shifted=a1;").call(obj, new SendableArray("nine", "inch", "nails")); +SendableFunction(p, "a2,a3", "this.shifted=a1;").call(obj, new SendableArray("nine", "inch", "nails")); assert.sameValue(obj["shifted"].length, 3); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T4.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T4.js index 53a716d4790..a7544bf6677 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T4.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T4.js @@ -33,7 +33,7 @@ var p = { var obj = {}; -new Function(p, p, p, "this.shifted=a3+a2+a1.length;").call(obj, (function() { +new SendableFunction(p, p, p, "this.shifted=a3+a2+a1.length;").call(obj, (function() { return arguments; })("a", "b", "c", "d"), "", 2); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T5.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T5.js index a9574735ba3..3a522a21cc5 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T5.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T5.js @@ -24,7 +24,7 @@ description: > ---*/ function FACTORY() { - Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(null, arguments, "", 2); + SendableFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(null, arguments, "", 2); } var obj = new FACTORY("", 1, 2, "A"); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T6.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T6.js index 32dbb42d262..23993272ba9 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T6.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T6.js @@ -24,7 +24,7 @@ description: > ---*/ function FACTORY() { - Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(this, arguments, "", 2); + SendableFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(this, arguments, "", 2); } var obj = new FACTORY("", 4, 2, "A"); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T7.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T7.js index 8d99956457d..a1480cc640b 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T7.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T7.js @@ -24,7 +24,7 @@ description: > ---*/ (function() { - Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(null, arguments, "", 2); + SendableFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(null, arguments, "", 2); })("", 1, 2, true); assert.sameValue(this["shifted"], "42", 'The value of this["shifted"] is expected to be "42"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T8.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T8.js index 6ff5b478680..37ef900b7e3 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T8.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T8.js @@ -24,7 +24,7 @@ description: > ---*/ (function() { - Function("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(this, arguments, "", 2); + SendableFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(this, arguments, "", 2); })("", 4, 2, null); assert.sameValue(this["shifted"], "42", 'The value of this["shifted"] is expected to be "42"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T9.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T9.js index f564c9e27b3..8f07652f97b 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T9.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T9.js @@ -25,7 +25,7 @@ description: > function FACTORY() { var obj = {}; - Function("a1,a2,a3", "this.shifted=a1+a2.length+a3;").call(obj, "", arguments, 2); + SendableFunction("a1,a2,a3", "this.shifted=a1+a2.length+a3;").call(obj, "", arguments, 2); return obj; } diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T3.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T3.js index 3e039104d7c..ea4c1fd77be 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T3.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T3.js @@ -14,14 +14,14 @@ */ /*--- -info: Function.prototype.call can't be used as [[Construct]] caller +info: SendableFunction.prototype.call can't be used as [[Construct]] caller es5id: 15.3.4.4_A7_T3 -description: Checking if creating "new Function.call" fails +description: Checking if creating "new SendableFunction.call" fails ---*/ try { - var obj = new Function.call; - throw new Test262Error('#1: Function.prototype.call can\'t be used as [[Construct]] caller'); + var obj = new SendableFunction.call; + throw new Test262Error('#1: SendableFunction.prototype.call can\'t be used as [[Construct]] caller'); } catch (e) { assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); } diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T4.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T4.js index c42f547cb43..68882db40b6 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T4.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T4.js @@ -14,14 +14,14 @@ */ /*--- -info: Function.prototype.call can't be used as [[Construct]] caller +info: SendableFunction.prototype.call can't be used as [[Construct]] caller es5id: 15.3.4.4_A7_T4 -description: Checking if creating "new (Function("this.p1=1").call)" fails +description: Checking if creating "new (SendableFunction("this.p1=1").call)" fails ---*/ try { - var obj = new(Function("this.p1=1").call); - throw new Test262Error('#1: Function.prototype.call can\'t be used as [[Construct]] caller'); + var obj = new(SendableFunction("this.p1=1").call); + throw new Test262Error('#1: SendableFunction.prototype.call can\'t be used as [[Construct]] caller'); } catch (e) { assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); } diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T5.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T5.js index bd401c1103c..7afd04b23f6 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T5.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T5.js @@ -14,15 +14,15 @@ */ /*--- -info: Function.prototype.call can't be used as [[Construct]] caller +info: SendableFunction.prototype.call can't be used as [[Construct]] caller es5id: 15.3.4.4_A7_T5 -description: Checking if creating "new Function("this.p1=1").call" fails +description: Checking if creating "new SendableFunction("this.p1=1").call" fails ---*/ try { - var FACTORY = Function("this.p1=1").call; + var FACTORY = SendableFunction("this.p1=1").call; var obj = new FACTORY(); - throw new Test262Error('#1: Function.prototype.call can\'t be used as [[Construct]] caller'); + throw new Test262Error('#1: SendableFunction.prototype.call can\'t be used as [[Construct]] caller'); } catch (e) { assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); } diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T6.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T6.js index f885cd733bb..717b74f921f 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T6.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T6.js @@ -14,17 +14,17 @@ */ /*--- -info: Function.prototype.call can't be used as [[Construct]] caller +info: SendableFunction.prototype.call can't be used as [[Construct]] caller es5id: 15.3.4.4_A7_T6 description: > - Checking if creating "new (Function("function + Checking if creating "new (SendableFunction("function f(){this.p1=1;};return f").call())" fails ---*/ try { - var obj = new(Function("function f(){this.p1=1;};return f").call()); + var obj = new(SendableFunction("function f(){this.p1=1;};return f").call()); } catch (e) { - throw new Test262Error('#1: Function.prototype.call can\'t be used as [[Construct]] caller'); + throw new Test262Error('#1: SendableFunction.prototype.call can\'t be used as [[Construct]] caller'); } assert.sameValue(obj.p1, 1, 'The value of obj.p1 is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A9.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A9.js index 76800583568..4b391924b61 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A9.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A9.js @@ -15,26 +15,26 @@ /*--- info: | - The Function.prototype.call.length property does not have the attribute + The SendableFunction.prototype.call.length property does not have the attribute DontDelete es5id: 15.3.4.4_A9 description: > - Checking if deleting the Function.prototype.call.length property + Checking if deleting the SendableFunction.prototype.call.length property fails ---*/ assert( - Function.prototype.call.hasOwnProperty('length'), - 'Function.prototype.call.hasOwnProperty(\'length\') must return true' + SendableFunction.prototype.call.hasOwnProperty('length'), + 'SendableFunction.prototype.call.hasOwnProperty(\'length\') must return true' ); assert( - delete Function.prototype.call.length, - 'The value of delete Function.prototype.call.length is expected to be true' + delete SendableFunction.prototype.call.length, + 'The value of delete SendableFunction.prototype.call.length is expected to be true' ); assert( - !Function.prototype.call.hasOwnProperty('length'), - 'The value of !Function.prototype.call.hasOwnProperty(\'length\') is expected to be true' + !SendableFunction.prototype.call.hasOwnProperty('length'), + 'The value of !SendableFunction.prototype.call.hasOwnProperty(\'length\') is expected to be true' ); // TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/call/name.js b/test/sendable/builtins/Function/prototype/call/name.js index b1674bba801..6298599dcce 100644 --- a/test/sendable/builtins/Function/prototype/call/name.js +++ b/test/sendable/builtins/Function/prototype/call/name.js @@ -16,22 +16,22 @@ /*--- es6id: 19.2.3.3 description: > - Function.prototype.call.name is "call". + SendableFunction.prototype.call.name is "call". info: | - Function.prototype.call (thisArg , ...args) + SendableFunction.prototype.call (thisArg , ...args) 17 ECMAScript Standard Built-in Objects: - Every built-in Function object, including constructors, that is not + Every built-in SendableFunction 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 + Unless otherwise specified, the name property of a built-in SendableFunction object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. includes: [propertyHelper.js] ---*/ -verifyProperty(Function.prototype.call, "name", { +verifyProperty(SendableFunction.prototype.call, "name", { value: "call", writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/call/not-a-constructor.js b/test/sendable/builtins/Function/prototype/call/not-a-constructor.js index 4c079494dc4..b71522a7377 100644 --- a/test/sendable/builtins/Function/prototype/call/not-a-constructor.js +++ b/test/sendable/builtins/Function/prototype/call/not-a-constructor.js @@ -16,9 +16,9 @@ /*--- esid: sec-ecmascript-standard-built-in-objects description: > - Function.prototype.call does not implement [[Construct]], is not new-able + SendableFunction.prototype.call does not implement [[Construct]], is not new-able info: | - ECMAScript Function Objects + ECMAScript SendableFunction Objects Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method unless otherwise specified in @@ -34,20 +34,20 @@ features: [Reflect.construct, arrow-function] ---*/ assert.sameValue( - isConstructor(Function.prototype.call), + isConstructor(SendableFunction.prototype.call), false, - 'isConstructor(Function.prototype.call) must return false' + 'isConstructor(SendableFunction.prototype.call) must return false' ); assert.throws(TypeError, () => { - new Function.prototype.call(); + new SendableFunction.prototype.call(); }); assert.throws(TypeError, () => { - new Function.prototype.call; + new SendableFunction.prototype.call; }); -var call = Function.prototype.call; +var call = SendableFunction.prototype.call; assert.throws(TypeError, () => { new call; }, '`new call()` throws TypeError'); diff --git a/test/sendable/builtins/Function/prototype/constructor/S15.3.4.1_A1_T1.js b/test/sendable/builtins/Function/prototype/constructor/S15.3.4.1_A1_T1.js index 118d99055c7..0d6fd7c54a6 100644 --- a/test/sendable/builtins/Function/prototype/constructor/S15.3.4.1_A1_T1.js +++ b/test/sendable/builtins/Function/prototype/constructor/S15.3.4.1_A1_T1.js @@ -15,13 +15,13 @@ /*--- info: | - The initial value of Function.prototype.constructor is the built-in - Function constructor + The initial value of SendableFunction.prototype.constructor is the built-in + SendableFunction constructor es5id: 15.3.4.1_A1_T1 -description: Checking Function.prototype.constructor +description: Checking SendableFunction.prototype.constructor ---*/ assert.sameValue( - Function.prototype.constructor, - Function, - 'The value of Function.prototype.constructor is expected to equal the value of Function' + SendableFunction.prototype.constructor, + SendableFunction, + 'The value of SendableFunction.prototype.constructor is expected to equal the value of SendableFunction' ); diff --git a/test/sendable/builtins/Function/prototype/length.js b/test/sendable/builtins/Function/prototype/length.js index 718239bc4a6..0c93b88f05d 100644 --- a/test/sendable/builtins/Function/prototype/length.js +++ b/test/sendable/builtins/Function/prototype/length.js @@ -16,11 +16,11 @@ /*--- esid: sec-properties-of-the-function-prototype-object description: > - Function.prototype.length is 0. + SendableFunction.prototype.length is 0. info: | - Properties of the Function Prototype Object + Properties of the SendableFunction Prototype Object - The Function prototype object: + The SendableFunction prototype object: [...] * has a "length" property whose value is 0. @@ -32,7 +32,7 @@ info: | includes: [propertyHelper.js] ---*/ -verifyProperty(Function.prototype, "length", { +verifyProperty(SendableFunction.prototype, "length", { value: 0, writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/name.js b/test/sendable/builtins/Function/prototype/name.js index f24b6936fa5..8fea713ee4d 100644 --- a/test/sendable/builtins/Function/prototype/name.js +++ b/test/sendable/builtins/Function/prototype/name.js @@ -15,20 +15,20 @@ /*--- es6id: 19.2.3 -description: FunctionPrototype `name` property +description: SendableFunctionPrototype `name` property info: | - The value of the name property of the Function prototype object is the + The value of the name property of the SendableFunction prototype object is the empty String. ES6 Section 17: - Unless otherwise specified, the name property of a built-in Function + Unless otherwise specified, the name property of a built-in SendableFunction object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. includes: [propertyHelper.js] ---*/ -verifyProperty(Function.prototype, "name", { +verifyProperty(SendableFunction.prototype, "name", { value: "", writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/property-order.js b/test/sendable/builtins/Function/prototype/property-order.js index c389b0b2fb1..6b57af1990c 100644 --- a/test/sendable/builtins/Function/prototype/property-order.js +++ b/test/sendable/builtins/Function/prototype/property-order.js @@ -15,12 +15,12 @@ /*--- esid: sec-createbuiltinfunction -description: Function constructor property order +description: SendableFunction constructor property order info: | Set order: "length", "name", ... ---*/ -var propNames = Object.getOwnPropertyNames(Function.prototype); +var propNames = Object.getOwnPropertyNames(SendableFunction.prototype); var lengthIndex = propNames.indexOf("length"); var nameIndex = propNames.indexOf("name"); diff --git a/test/sendable/builtins/Function/prototype/restricted-property-arguments.js b/test/sendable/builtins/Function/prototype/restricted-property-arguments.js index 7a6b831ac1d..7c2af3d92eb 100644 --- a/test/sendable/builtins/Function/prototype/restricted-property-arguments.js +++ b/test/sendable/builtins/Function/prototype/restricted-property-arguments.js @@ -14,26 +14,26 @@ */ /*--- -description: Intrinsic %FunctionPrototype% has poisoned own property "arguments" +description: Intrinsic %SendableFunctionPrototype% has poisoned own property "arguments" includes: [propertyHelper.js] es6id: 8.2.2 S12, 9.2.7 ---*/ -var FunctionPrototype = Function.prototype; +var SendableFunctionPrototype = SendableFunction.prototype; -assert.sameValue(FunctionPrototype.hasOwnProperty('arguments'), true, 'The result of %FunctionPrototype%.hasOwnProperty("arguments") is true'); -var descriptor = Object.getOwnPropertyDescriptor(FunctionPrototype, 'arguments'); -assert.sameValue(typeof descriptor.get, 'function', '%FunctionPrototype%.arguments is an accessor property'); -assert.sameValue(typeof descriptor.set, 'function', '%FunctionPrototype%.arguments is an accessor property'); -assert.sameValue(descriptor.get, descriptor.set, '%FunctionPrototype%.arguments getter/setter are both %ThrowTypeError%'); +assert.sameValue(SendableFunctionPrototype.hasOwnProperty('arguments'), true, 'The result of %SendableFunctionPrototype%.hasOwnProperty("arguments") is true'); +var descriptor = Object.getOwnPropertyDescriptor(SendableFunctionPrototype, 'arguments'); +assert.sameValue(typeof descriptor.get, 'function', '%SendableFunctionPrototype%.arguments is an accessor property'); +assert.sameValue(typeof descriptor.set, 'function', '%SendableFunctionPrototype%.arguments is an accessor property'); +assert.sameValue(descriptor.get, descriptor.set, '%SendableFunctionPrototype%.arguments getter/setter are both %ThrowTypeError%'); assert.throws(TypeError, function() { - return FunctionPrototype.arguments; + return SendableFunctionPrototype.arguments; }); assert.throws(TypeError, function() { - FunctionPrototype.arguments = {}; + SendableFunctionPrototype.arguments = {}; }); -verifyNotEnumerable(FunctionPrototype, 'arguments'); -verifyConfigurable(FunctionPrototype, 'arguments'); +verifyNotEnumerable(SendableFunctionPrototype, 'arguments'); +verifyConfigurable(SendableFunctionPrototype, 'arguments'); diff --git a/test/sendable/builtins/Function/prototype/restricted-property-caller.js b/test/sendable/builtins/Function/prototype/restricted-property-caller.js index 496632d7289..9308403b168 100644 --- a/test/sendable/builtins/Function/prototype/restricted-property-caller.js +++ b/test/sendable/builtins/Function/prototype/restricted-property-caller.js @@ -14,27 +14,27 @@ */ /*--- -description: Intrinsic %FunctionPrototype% has poisoned own property "caller" +description: Intrinsic %SendableFunctionPrototype% has poisoned own property "caller" includes: [propertyHelper.js] es6id: 8.2.2 S12, 9.2.7 ---*/ -var FunctionPrototype = Function.prototype; +var SendableFunctionPrototype = SendableFunction.prototype; -assert.sameValue(FunctionPrototype.hasOwnProperty('caller'), true, 'The result of %FunctionPrototype%.hasOwnProperty("caller") is true'); +assert.sameValue(SendableFunctionPrototype.hasOwnProperty('caller'), true, 'The result of %SendableFunctionPrototype%.hasOwnProperty("caller") is true'); -var descriptor = Object.getOwnPropertyDescriptor(FunctionPrototype, 'caller'); -assert.sameValue(typeof descriptor.get, 'function', '%FunctionPrototype%.caller is an accessor property'); -assert.sameValue(typeof descriptor.set, 'function', '%FunctionPrototype%.caller is an accessor property'); -assert.sameValue(descriptor.get, descriptor.set, '%FunctionPrototype%.caller getter/setter are both %ThrowTypeError%'); +var descriptor = Object.getOwnPropertyDescriptor(SendableFunctionPrototype, 'caller'); +assert.sameValue(typeof descriptor.get, 'function', '%SendableFunctionPrototype%.caller is an accessor property'); +assert.sameValue(typeof descriptor.set, 'function', '%SendableFunctionPrototype%.caller is an accessor property'); +assert.sameValue(descriptor.get, descriptor.set, '%SendableFunctionPrototype%.caller getter/setter are both %ThrowTypeError%'); assert.throws(TypeError, function() { - return FunctionPrototype.caller; + return SendableFunctionPrototype.caller; }); assert.throws(TypeError, function() { - FunctionPrototype.caller = {}; + SendableFunctionPrototype.caller = {}; }); -verifyNotEnumerable(FunctionPrototype, 'caller'); -verifyConfigurable(FunctionPrototype, 'caller'); +verifyNotEnumerable(SendableFunctionPrototype, 'caller'); +verifyConfigurable(SendableFunctionPrototype, 'caller'); diff --git a/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js b/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js index a6c3aff3d18..0ca3d2c51df 100644 --- a/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js +++ b/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js @@ -17,12 +17,12 @@ author: Brian Terlson esid: sec-function.prototype.tostring description: > - Function.prototype.toString on an async function created with the - AsyncFunction constructor. + SendableFunction.prototype.toString on an async function created with the + AsyncSendableFunction constructor. features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ async function f() {} -var AsyncFunction = f.constructor; -var g = /* before */AsyncFunction("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */; -assertToStringOrNativeFunction(g, "async function anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); +var AsyncSendableFunction = f.constructor; +var g = /* before */AsyncSendableFunction("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */; +assertToStringOrNativeSendableFunction(g, "async function anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js b/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js index 6e554d2ad23..d08ae8ea889 100644 --- a/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js +++ b/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js @@ -16,7 +16,7 @@ /*--- esid: sec-function.prototype.tostring description: > - Function.prototype.toString on an async generator created with the + SendableFunction.prototype.toString on an async generator created with the AsyncGenerator constructor. features: [async-iteration] includes: [nativeFunctionMatcher.js] @@ -26,4 +26,4 @@ async function* f() {} var AsyncGenerator = f.constructor; var g = /* before */AsyncGenerator("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */; -assertToStringOrNativeFunction(g, "async function* anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); +assertToStringOrNativeSendableFunction(g, "async function* anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/Function.js b/test/sendable/builtins/Function/prototype/toString/Function.js index 3cf79ce1061..fb6065ca258 100644 --- a/test/sendable/builtins/Function/prototype/toString/Function.js +++ b/test/sendable/builtins/Function/prototype/toString/Function.js @@ -15,10 +15,10 @@ /*--- esid: sec-createdynamicfunction -description: Function.prototype.toString on a function created with the Function constructor +description: SendableFunction.prototype.toString on a function created with the SendableFunction constructor includes: [nativeFunctionMatcher.js] ---*/ -let f = /* before */Function("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */; +let f = /* before */SendableFunction("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */; -assertToStringOrNativeFunction(f, "function anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); +assertToStringOrNativeSendableFunction(f, "function anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js b/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js index 849087e1ad1..33ac062e88f 100644 --- a/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js +++ b/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js @@ -15,12 +15,12 @@ /*--- esid: sec-createdynamicfunction -description: Function.prototype.toString on a generator function created with the GeneratorFunction constructor +description: SendableFunction.prototype.toString on a generator function created with the GeneratorSendableFunction constructor features: [generators] includes: [nativeFunctionMatcher.js] ---*/ -let GeneratorFunction = Object.getPrototypeOf(function*(){}).constructor; -let g = /* before */GeneratorFunction("a", " /* a */ b, c /* b */ //", "/* c */ yield yield; /* d */ //")/* after */; +let GeneratorSendableFunction = Object.getPrototypeOf(function*(){}).constructor; +let g = /* before */GeneratorSendableFunction("a", " /* a */ b, c /* b */ //", "/* c */ yield yield; /* d */ //")/* after */; -assertToStringOrNativeFunction(g, "function* anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ yield yield; /* d */ //\n}"); +assertToStringOrNativeSendableFunction(g, "function* anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ yield yield; /* d */ //\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A10.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A10.js index 1b6c6d4806e..f22e9c421f5 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A10.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A10.js @@ -14,26 +14,26 @@ */ /*--- -info: The Function.prototype.toString.length property has the attribute ReadOnly +info: The SendableFunction.prototype.toString.length property has the attribute ReadOnly es5id: 15.3.4.2_A10 description: > - Checking if varying the Function.prototype.toString.length + Checking if varying the SendableFunction.prototype.toString.length property fails includes: [propertyHelper.js] ---*/ assert( - Function.prototype.toString.hasOwnProperty('length'), - 'Function.prototype.toString.hasOwnProperty(\'length\') must return true' + SendableFunction.prototype.toString.hasOwnProperty('length'), + 'SendableFunction.prototype.toString.hasOwnProperty(\'length\') must return true' ); -var obj = Function.prototype.toString.length; +var obj = SendableFunction.prototype.toString.length; -verifyNotWritable(Function.prototype.toString, "length", null, function(){return "shifted";}); +verifyNotWritable(SendableFunction.prototype.toString, "length", null, function(){return "shifted";}); assert.sameValue( - Function.prototype.toString.length, + SendableFunction.prototype.toString.length, obj, - 'The value of Function.prototype.toString.length is expected to equal the value of obj' + 'The value of SendableFunction.prototype.toString.length is expected to equal the value of obj' ); // TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A11.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A11.js index 23ceb4a008a..26df4969c4b 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A11.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A11.js @@ -16,15 +16,15 @@ /*--- info: The length property of the toString method is 0 es5id: 15.3.4.2_A11 -description: Checking Function.prototype.toString.length +description: Checking SendableFunction.prototype.toString.length ---*/ assert( - Function.prototype.toString.hasOwnProperty("length"), - 'Function.prototype.toString.hasOwnProperty("length") must return true' + SendableFunction.prototype.toString.hasOwnProperty("length"), + 'SendableFunction.prototype.toString.hasOwnProperty("length") must return true' ); assert.sameValue( - Function.prototype.toString.length, + SendableFunction.prototype.toString.length, 0, - 'The value of Function.prototype.toString.length is expected to be 0' + 'The value of SendableFunction.prototype.toString.length is expected to be 0' ); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A12.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A12.js index 204c83033ab..f8995c9a9b0 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A12.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A12.js @@ -16,10 +16,10 @@ /*--- es5id: 15.3.4.2_A12 description: > - The Function.prototype.toString function is not generic; it throws + The SendableFunction.prototype.toString function is not generic; it throws a TypeError exception if its this value is not a callable object. ---*/ assert.throws(TypeError, function() { - Function.prototype.toString.call(undefined); -}, 'Function.prototype.toString.call(undefined) throws a TypeError exception'); + SendableFunction.prototype.toString.call(undefined); +}, 'SendableFunction.prototype.toString.call(undefined) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A13.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A13.js index 244df4c7b1a..47b5c7139e0 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A13.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A13.js @@ -21,5 +21,5 @@ description: > ---*/ assert.throws(TypeError, function() { - Function.prototype.toString.call(null); -}, 'Function.prototype.toString.call(null) throws a TypeError exception'); + SendableFunction.prototype.toString.call(null); +}, 'SendableFunction.prototype.toString.call(null) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A14.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A14.js index 43634e466b3..df1ea91d016 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A14.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A14.js @@ -21,5 +21,5 @@ description: > ---*/ assert.throws(TypeError, function() { - Function.prototype.toString.call({}); -}, 'Function.prototype.toString.call({}) throws a TypeError exception'); + SendableFunction.prototype.toString.call({}); +}, 'SendableFunction.prototype.toString.call({}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A16.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A16.js index be7bb91595a..51301992382 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A16.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A16.js @@ -24,7 +24,7 @@ description: > bound to that object. ---*/ -var obj = {toString: Function.prototype.toString}; +var obj = {toString: SendableFunction.prototype.toString}; assert.throws(TypeError, function() { String(obj); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A6.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A6.js index db288297b10..69e7aeb2614 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A6.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A6.js @@ -14,14 +14,14 @@ */ /*--- -info: Function.prototype.toString has not prototype property +info: SendableFunction.prototype.toString has not prototype property es5id: 15.3.4.2_A6 description: > Checking if obtaining the prototype property of - Function.prototype.toString fails + SendableFunction.prototype.toString fails ---*/ assert.sameValue( - Function.prototype.toString.prototype, + SendableFunction.prototype.toString.prototype, undefined, - 'The value of Function.prototype.toString.prototype is expected to equal undefined' + 'The value of SendableFunction.prototype.toString.prototype is expected to equal undefined' ); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A8.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A8.js index fec5857e673..34918843f36 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A8.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A8.js @@ -14,24 +14,24 @@ */ /*--- -info: The Function.prototype.toString.length property has the attribute DontEnum +info: The SendableFunction.prototype.toString.length property has the attribute DontEnum es5id: 15.3.4.2_A8 description: > - Checking if enumerating the Function.prototype.toString.length + Checking if enumerating the SendableFunction.prototype.toString.length property fails ---*/ assert( - Function.prototype.toString.hasOwnProperty('length'), - 'Function.prototype.toString.hasOwnProperty(\'length\') must return true' + SendableFunction.prototype.toString.hasOwnProperty('length'), + 'SendableFunction.prototype.toString.hasOwnProperty(\'length\') must return true' ); assert( - !Function.prototype.toString.propertyIsEnumerable('length'), - 'The value of !Function.prototype.toString.propertyIsEnumerable(\'length\') is expected to be true' + !SendableFunction.prototype.toString.propertyIsEnumerable('length'), + 'The value of !SendableFunction.prototype.toString.propertyIsEnumerable(\'length\') is expected to be true' ); // CHECK#2 -for (var p in Function.prototype.toString){ +for (var p in SendableFunction.prototype.toString){ assert.notSameValue(p, "length", 'The value of p is not "length"'); } diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A9.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A9.js index 06ba3da9c76..eefa4012c23 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A9.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A9.js @@ -15,26 +15,26 @@ /*--- info: | - The Function.prototype.toString.length property does not have the + The SendableFunction.prototype.toString.length property does not have the attribute DontDelete es5id: 15.3.4.2_A9 description: > - Checking if deleting the Function.prototype.toString.length + Checking if deleting the SendableFunction.prototype.toString.length property fails ---*/ assert( - Function.prototype.toString.hasOwnProperty('length'), - 'Function.prototype.toString.hasOwnProperty(\'length\') must return true' + SendableFunction.prototype.toString.hasOwnProperty('length'), + 'SendableFunction.prototype.toString.hasOwnProperty(\'length\') must return true' ); assert( - delete Function.prototype.toString.length, - 'The value of delete Function.prototype.toString.length is expected to be true' + delete SendableFunction.prototype.toString.length, + 'The value of delete SendableFunction.prototype.toString.length is expected to be true' ); assert( - !Function.prototype.toString.hasOwnProperty('length'), - 'The value of !Function.prototype.toString.hasOwnProperty(\'length\') is expected to be true' + !SendableFunction.prototype.toString.hasOwnProperty('length'), + 'The value of !SendableFunction.prototype.toString.hasOwnProperty(\'length\') is expected to be true' ); // TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/toString/arrow-function.js b/test/sendable/builtins/Function/prototype/toString/arrow-function.js index 1c22e83b551..deb76af65c2 100644 --- a/test/sendable/builtins/Function/prototype/toString/arrow-function.js +++ b/test/sendable/builtins/Function/prototype/toString/arrow-function.js @@ -15,7 +15,7 @@ /*--- esid: sec-arrow-function-definitions-runtime-semantics-evaluation -description: Function.prototype.toString on an arrow function +description: SendableFunction.prototype.toString on an arrow function includes: [nativeFunctionMatcher.js] ---*/ @@ -23,6 +23,6 @@ let f = /* before */( /* a */ a /* b */ , /* c */ b /* d */ ) /* e */ => /* f */ let g = /* before */( /* a */ ) /* b */ => /* c */ 0/* after */; let h = /* before */a /* a */ => /* b */ 0/* after */; -assertToStringOrNativeFunction(f, "( /* a */ a /* b */ , /* c */ b /* d */ ) /* e */ => /* f */ { /* g */ ; /* h */ }"); -assertToStringOrNativeFunction(g, "( /* a */ ) /* b */ => /* c */ 0"); -assertToStringOrNativeFunction(h, "a /* a */ => /* b */ 0"); +assertToStringOrNativeSendableFunction(f, "( /* a */ a /* b */ , /* c */ b /* d */ ) /* e */ => /* f */ { /* g */ ; /* h */ }"); +assertToStringOrNativeSendableFunction(g, "( /* a */ ) /* b */ => /* c */ 0"); +assertToStringOrNativeSendableFunction(h, "a /* a */ => /* b */ 0"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js b/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js index 5356c2b1d33..072a9bb66f3 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js +++ b/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js @@ -15,7 +15,7 @@ /*--- esid: sec-async-arrow-function-definitions-runtime-semantics-evaluation -description: Function.prototype.toString on an async arrow function +description: SendableFunction.prototype.toString on an async arrow function features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ @@ -24,6 +24,6 @@ let f = /* before */async /* a */ ( /* b */ a /* c */ , /* d */ b /* e */ ) /* f let g = /* before */async /* a */ ( /* b */ ) /* c */ => /* d */ 0/* after */; let h = /* before */async /* a */ a /* b */ => /* c */ 0/* after */; -assertToStringOrNativeFunction(f, "async /* a */ ( /* b */ a /* c */ , /* d */ b /* e */ ) /* f */ => /* g */ { /* h */ ; /* i */ }"); -assertToStringOrNativeFunction(g, "async /* a */ ( /* b */ ) /* c */ => /* d */ 0"); -assertToStringOrNativeFunction(h, "async /* a */ a /* b */ => /* c */ 0"); +assertToStringOrNativeSendableFunction(f, "async /* a */ ( /* b */ a /* c */ , /* d */ b /* e */ ) /* f */ => /* g */ { /* h */ ; /* i */ }"); +assertToStringOrNativeSendableFunction(g, "async /* a */ ( /* b */ ) /* c */ => /* d */ 0"); +assertToStringOrNativeSendableFunction(h, "async /* a */ a /* b */ => /* c */ 0"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js b/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js index 50527c064da..c6cd40fa9de 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js +++ b/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js @@ -16,11 +16,11 @@ /*--- author: Brian Terlson esid: sec-function.prototype.tostring -description: Function.prototype.toString on an async function declaration +description: SendableFunction.prototype.toString on an async function declaration features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ /* before */async function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */ -assertToStringOrNativeFunction(f, "async function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); +assertToStringOrNativeSendableFunction(f, "async function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-function-expression.js b/test/sendable/builtins/Function/prototype/toString/async-function-expression.js index 5ad4affda6c..71e0e7109e9 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-function-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/async-function-expression.js @@ -16,7 +16,7 @@ /*--- author: Brian Terlson esid: sec-function.prototype.tostring -description: Function.prototype.toString on an async function expression +description: SendableFunction.prototype.toString on an async function expression features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ @@ -24,5 +24,5 @@ includes: [nativeFunctionMatcher.js] let f = /* before */async function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */; let g = /* before */async function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }/* after */; -assertToStringOrNativeFunction(f, "async function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); -assertToStringOrNativeFunction(g, "async function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }"); +assertToStringOrNativeSendableFunction(f, "async function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); +assertToStringOrNativeSendableFunction(g, "async function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js b/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js index bdb65aa6cf9..e666c778d15 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js @@ -15,11 +15,11 @@ /*--- esid: sec-function.prototype.tostring -description: Function.prototype.toString on an async generator declaration +description: SendableFunction.prototype.toString on an async generator declaration features: [async-iteration] includes: [nativeFunctionMatcher.js] ---*/ /* before */async /* a */ function /* b */ * /* c */ f /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }/* after */ -assertToStringOrNativeFunction(f, "async /* a */ function /* b */ * /* c */ f /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }"); +assertToStringOrNativeSendableFunction(f, "async /* a */ function /* b */ * /* c */ f /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js b/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js index e248714d8bb..d24a553705f 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: Function.prototype.toString on an async generator expression +description: SendableFunction.prototype.toString on an async generator expression features: [async-iteration] includes: [nativeFunctionMatcher.js] ---*/ @@ -23,5 +23,5 @@ includes: [nativeFunctionMatcher.js] let f = /* before */async /* a */ function /* b */ * /* c */ F /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }/* after */; let g = /* before */async /* a */ function /* b */ * /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }/* after */; -assertToStringOrNativeFunction(f, "async /* a */ function /* b */ * /* c */ F /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }"); -assertToStringOrNativeFunction(g, "async /* a */ function /* b */ * /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); +assertToStringOrNativeSendableFunction(f, "async /* a */ function /* b */ * /* c */ F /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }"); +assertToStringOrNativeSendableFunction(g, "async /* a */ function /* b */ * /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js index 845bc72a3c3..725d81b8f69 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: Function.prototype.toString on an async generator method +description: SendableFunction.prototype.toString on an async generator method features: [async-iteration] includes: [nativeFunctionMatcher.js] ---*/ @@ -25,6 +25,6 @@ let f = class { static /* before */async /* a */ * /* b */ f /* c */ ( /* d */ ) let g = class { static /* before */async /* a */ * /* b */ [ /* c */ "g" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.g; let h = class { static /* before */async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.h; -assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js index 8ac58e44c94..3ddaddc9234 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: Function.prototype.toString on an async generator method +description: SendableFunction.prototype.toString on an async generator method features: [async-iteration] includes: [nativeFunctionMatcher.js] ---*/ @@ -25,6 +25,6 @@ let f = class { /* before */async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e * let g = class { /* before */async /* a */ * /* b */ [ /* c */ "g" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.prototype.g; let h = class { /* before */async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.prototype.h; -assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js index f22f4f2fffd..893f2bf2ce7 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: Function.prototype.toString on an async generator method +description: SendableFunction.prototype.toString on an async generator method features: [async-iteration] includes: [nativeFunctionMatcher.js] ---*/ @@ -29,6 +29,6 @@ let f = F.f; let g = G.g; let h = H.h; -assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js index e0a70d8fad3..ef50dbbe7a6 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: Function.prototype.toString on an async generator method +description: SendableFunction.prototype.toString on an async generator method features: [async-iteration] includes: [nativeFunctionMatcher.js] ---*/ @@ -29,6 +29,6 @@ let f = F.prototype.f; let g = G.prototype.g; let h = H.prototype.h; -assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js index add0a6a937b..2f71bea1f3d 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: Function.prototype.toString on an async generator method +description: SendableFunction.prototype.toString on an async generator method features: [async-iteration] includes: [nativeFunctionMatcher.js] ---*/ @@ -25,6 +25,6 @@ let f = { /* before */async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* let g = { /* before */async /* a */ * /* b */ [ /* c */ "g" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.g; let h = { /* before */async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.h; -assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js index 3d90442ffe0..bc45404f684 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: Function.prototype.toString on an async method +description: SendableFunction.prototype.toString on an async method features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ @@ -25,6 +25,6 @@ let f = class { static /* before */async f /* a */ ( /* b */ ) /* c */ { /* d */ let g = class { static /* before */async /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.g; let h = class { static /* before */async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.h; -assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeSendableFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js index 5320e5efaec..e3dce4a0335 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: Function.prototype.toString on an async method +description: SendableFunction.prototype.toString on an async method features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ @@ -25,6 +25,6 @@ let f = class { /* before */async f /* a */ ( /* b */ ) /* c */ { /* d */ }/* af let g = class { /* before */async /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.prototype.g; let h = class { /* before */async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.prototype.h; -assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeSendableFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js index b918aff1806..12b9e90675d 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: Function.prototype.toString on an async method +description: SendableFunction.prototype.toString on an async method features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ @@ -29,6 +29,6 @@ let f = F.f; let g = G.g; let h = H.h; -assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeSendableFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js index 97710963040..50531701ff8 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: Function.prototype.toString on an async method +description: SendableFunction.prototype.toString on an async method features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ @@ -29,6 +29,6 @@ let f = F.prototype.f; let g = G.prototype.g; let h = H.prototype.h; -assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeSendableFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-object.js b/test/sendable/builtins/Function/prototype/toString/async-method-object.js index 3b4cc2f902b..b7d07940258 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-object.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-object.js @@ -16,7 +16,7 @@ /*--- author: Brian Terlson esid: sec-function.prototype.tostring -description: Function.prototype.toString on an async method +description: SendableFunction.prototype.toString on an async method features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ @@ -26,6 +26,6 @@ let f = { /* before */async f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ let g = { /* before */async /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.g; let h = { /* before */async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.h; -assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeSendableFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/bound-function.js b/test/sendable/builtins/Function/prototype/toString/bound-function.js index be892b19a3e..a097d6f89ac 100644 --- a/test/sendable/builtins/Function/prototype/toString/bound-function.js +++ b/test/sendable/builtins/Function/prototype/toString/bound-function.js @@ -16,14 +16,14 @@ /*--- esid: sec-function.prototype.tostring description: > - toString bound function does not throw (bound Function Expression) + toString bound function does not throw (bound SendableFunction Expression) info: | ... - If func is a Bound Function exotic object or a built-in Function object, + If func is a Bound SendableFunction exotic object or a built-in SendableFunction object, then return an implementation-dependent String source code representation - of func. The representation must have the syntax of a NativeFunction + of func. The representation must have the syntax of a NativeSendableFunction ... includes: [nativeFunctionMatcher.js] ---*/ -assertNativeFunction(function() {}.bind({})); +assertNativeSendableFunction(function() {}.bind({})); diff --git a/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js b/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js index 83990abb2d1..2a38c83e0ac 100644 --- a/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js +++ b/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js @@ -16,16 +16,16 @@ /*--- esid: sec-function.prototype.tostring description: > - toString of built-in Function object + toString of built-in SendableFunction object info: | ... - If func is a built-in Function object, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeFunction. + If func is a built-in SendableFunction object, then return an implementation-dependent String source code representation of func. + The representation must have the syntax of a NativeSendableFunction. ... - NativeFunction: - function NativeFunctionAccessor_opt IdentifierName_opt ( FormalParameters ) { [ native code ] } - NativeFunctionAccessor : + NativeSendableFunction: + function NativeSendableFunctionAccessor_opt IdentifierName_opt ( FormalParameters ) { [ native code ] } + NativeSendableFunctionAccessor : get set @@ -41,7 +41,7 @@ function visit(ns, path) { visited.push(ns); if (typeof ns === 'function') { - assertNativeFunction(ns, path); + assertNativeSendableFunction(ns, path); } if (typeof ns !== 'function' && (typeof ns !== 'object' || ns === null)) { return; diff --git a/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js b/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js index 7d5ec1398e5..a61a87e33f2 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js +++ b/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js @@ -15,10 +15,10 @@ /*--- esid: sec-runtime-semantics-bindingclassdeclarationevaluation -description: Function.prototype.toString on a class declaration (with complex heritage) +description: SendableFunction.prototype.toString on a class declaration (with complex heritage) includes: [nativeFunctionMatcher.js] ---*/ /* before */class /* a */ A /* b */ extends /* c */ class /* d */ B /* e */ { /* f */ } /* g */ { /* h */ }/* after */ -assertToStringOrNativeFunction(A, "class /* a */ A /* b */ extends /* c */ class /* d */ B /* e */ { /* f */ } /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(A, "class /* a */ A /* b */ extends /* c */ class /* d */ B /* e */ { /* f */ } /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js index 02458c67ee2..b9bf3bc0701 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js +++ b/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js @@ -15,12 +15,12 @@ /*--- esid: sec-runtime-semantics-bindingclassdeclarationevaluation -description: Function.prototype.toString on a class declaration (explicit constructor) +description: SendableFunction.prototype.toString on a class declaration (explicit constructor) includes: [nativeFunctionMatcher.js] ---*/ /* before */class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }/* after */ -assertToStringOrNativeFunction(A, "class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }"); +assertToStringOrNativeSendableFunction(A, "class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }"); function B(){} diff --git a/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js index c15583e1732..d99c3af6e77 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js +++ b/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js @@ -15,7 +15,7 @@ /*--- esid: sec-runtime-semantics-bindingclassdeclarationevaluation -description: Function.prototype.toString on a class declaration (implicit constructor) +description: SendableFunction.prototype.toString on a class declaration (implicit constructor) includes: [nativeFunctionMatcher.js] ---*/ @@ -23,6 +23,6 @@ includes: [nativeFunctionMatcher.js] /* before */class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }/* after */ /* before */class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }/* after */ -assertToStringOrNativeFunction(A, "class /* a */ A /* b */ { /* c */ }"); -assertToStringOrNativeFunction(B, "class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }"); -assertToStringOrNativeFunction(C, "class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }"); +assertToStringOrNativeSendableFunction(A, "class /* a */ A /* b */ { /* c */ }"); +assertToStringOrNativeSendableFunction(B, "class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }"); +assertToStringOrNativeSendableFunction(C, "class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js index 170c40409af..1cb8c7623c9 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js +++ b/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js @@ -15,12 +15,12 @@ /*--- esid: sec-class-definitions-runtime-semantics-evaluation -description: Function.prototype.toString on a class expression (explicit constructor) +description: SendableFunction.prototype.toString on a class expression (explicit constructor) includes: [nativeFunctionMatcher.js] ---*/ let A = /* before */class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }/* after */; -assertToStringOrNativeFunction(A, "class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }"); +assertToStringOrNativeSendableFunction(A, "class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }"); function B(){} diff --git a/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js index ece2fb2b183..fc5771ea04b 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js +++ b/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js @@ -15,7 +15,7 @@ /*--- esid: sec-class-definitions-runtime-semantics-evaluation -description: Function.prototype.toString on a class expression (implicit constructor) +description: SendableFunction.prototype.toString on a class expression (implicit constructor) includes: [nativeFunctionMatcher.js] ---*/ @@ -23,6 +23,6 @@ let A = /* before */class /* a */ A /* b */ { /* c */ }/* after */; let B = /* before */class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }/* after */; let C = /* before */class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }/* after */; -assertToStringOrNativeFunction(A, "class /* a */ A /* b */ { /* c */ }"); -assertToStringOrNativeFunction(B, "class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }"); -assertToStringOrNativeFunction(C, "class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }"); +assertToStringOrNativeSendableFunction(A, "class /* a */ A /* b */ { /* c */ }"); +assertToStringOrNativeSendableFunction(B, "class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }"); +assertToStringOrNativeSendableFunction(C, "class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js b/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js index bcd3806a1df..9e1c730144d 100644 --- a/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js +++ b/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js @@ -15,10 +15,10 @@ /*--- esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject -description: Function.prototype.toString on a function with a non-simple parameter list +description: SendableFunction.prototype.toString on a function with a non-simple parameter list includes: [nativeFunctionMatcher.js] ---*/ /* before */function /* a */ f /* b */ ( /* c */ a /* d */ = /* e */ 0 /* f */ , /* g */ { /* h */ b /* i */ = /* j */ 0 /* k */ } /* l */ ) /* m */ { /* n */ }/* after */ -assertToStringOrNativeFunction(f, "function /* a */ f /* b */ ( /* c */ a /* d */ = /* e */ 0 /* f */ , /* g */ { /* h */ b /* i */ = /* j */ 0 /* k */ } /* l */ ) /* m */ { /* n */ }"); +assertToStringOrNativeSendableFunction(f, "function /* a */ f /* b */ ( /* c */ a /* d */ = /* e */ 0 /* f */ , /* g */ { /* h */ b /* i */ = /* j */ 0 /* k */ } /* l */ ) /* m */ { /* n */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/function-declaration.js b/test/sendable/builtins/Function/prototype/toString/function-declaration.js index e80738aacd5..a630ac13dae 100644 --- a/test/sendable/builtins/Function/prototype/toString/function-declaration.js +++ b/test/sendable/builtins/Function/prototype/toString/function-declaration.js @@ -15,10 +15,10 @@ /*--- esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject -description: Function.prototype.toString on a function declaration +description: SendableFunction.prototype.toString on a function declaration includes: [nativeFunctionMatcher.js] ---*/ /* before */function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */ -assertToStringOrNativeFunction(f, "function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); +assertToStringOrNativeSendableFunction(f, "function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/function-expression.js b/test/sendable/builtins/Function/prototype/toString/function-expression.js index 28fb8addd24..6628b2899a1 100644 --- a/test/sendable/builtins/Function/prototype/toString/function-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/function-expression.js @@ -15,12 +15,12 @@ /*--- esid: sec-function-definitions-runtime-semantics-evaluation -description: Function.prototype.toString on a function expression +description: SendableFunction.prototype.toString on a function expression includes: [nativeFunctionMatcher.js] ---*/ let f = /* before */function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */; let g = /* before */function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }/* after */; -assertToStringOrNativeFunction(f, "function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); -assertToStringOrNativeFunction(g, "function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }"); +assertToStringOrNativeSendableFunction(f, "function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); +assertToStringOrNativeSendableFunction(g, "function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js b/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js index 0fc5084304a..1f23db308ed 100644 --- a/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js +++ b/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js @@ -15,10 +15,10 @@ /*--- esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject -description: Function.prototype.toString on a generator function declaration +description: SendableFunction.prototype.toString on a generator function declaration includes: [nativeFunctionMatcher.js] ---*/ /* before */function /* a */ * /* b */ g /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }/* after */ -assertToStringOrNativeFunction(g, "function /* a */ * /* b */ g /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); +assertToStringOrNativeSendableFunction(g, "function /* a */ * /* b */ g /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js b/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js index 29b97c739ea..b3b627f1e6f 100644 --- a/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js @@ -15,12 +15,12 @@ /*--- esid: sec-generator-function-definitions-runtime-semantics-evaluation -description: Function.prototype.toString on a generator function expression +description: SendableFunction.prototype.toString on a generator function expression includes: [nativeFunctionMatcher.js] ---*/ let f = /* before */function /* a */ * /* b */ F /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }/* after */ let g = /* before */function /* a */ * /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */ -assertToStringOrNativeFunction(f, "function /* a */ * /* b */ F /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); -assertToStringOrNativeFunction(g, "function /* a */ * /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); +assertToStringOrNativeSendableFunction(f, "function /* a */ * /* b */ F /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); +assertToStringOrNativeSendableFunction(g, "function /* a */ * /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/generator-method.js b/test/sendable/builtins/Function/prototype/toString/generator-method.js index 39e85cfe50f..a64cd002de7 100644 --- a/test/sendable/builtins/Function/prototype/toString/generator-method.js +++ b/test/sendable/builtins/Function/prototype/toString/generator-method.js @@ -15,7 +15,7 @@ /*--- esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation -description: Function.prototype.toString on a generator method +description: SendableFunction.prototype.toString on a generator method includes: [nativeFunctionMatcher.js] ---*/ @@ -24,6 +24,6 @@ let f = { /* before */* /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }/* afte let g = { /* before */* /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.g; let h = { /* before */* /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.h; -assertToStringOrNativeFunction(f, "* /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); -assertToStringOrNativeFunction(g, "* /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeFunction(h, "* /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(f, "* /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeSendableFunction(g, "* /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(h, "* /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js index cbdc698209a..31ca38b87a7 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: Function.prototype.toString on a getter (class; static) +description: SendableFunction.prototype.toString on a getter (class; static) includes: [nativeFunctionMatcher.js] ---*/ @@ -24,6 +24,6 @@ let f = Object.getOwnPropertyDescriptor(class { static /* before */get /* a */ f let g = Object.getOwnPropertyDescriptor(class { static /* before */get /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }, "g").get; let h = Object.getOwnPropertyDescriptor(class { static /* before */get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }, "h").get; -assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); -assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeSendableFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js b/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js index bcd8d183c18..615fad5f410 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: Function.prototype.toString on a getter (class) +description: SendableFunction.prototype.toString on a getter (class) includes: [nativeFunctionMatcher.js] ---*/ @@ -24,6 +24,6 @@ let f = Object.getOwnPropertyDescriptor(class { /* before */get /* a */ f /* b * let g = Object.getOwnPropertyDescriptor(class { /* before */get /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.prototype, "g").get; let h = Object.getOwnPropertyDescriptor(class { /* before */get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.prototype, "h").get; -assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); -assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeSendableFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js index 82a11c80740..4557b844bbf 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: Function.prototype.toString on a getter (class; static) +description: SendableFunction.prototype.toString on a getter (class; static) includes: [nativeFunctionMatcher.js] ---*/ @@ -28,6 +28,6 @@ let f = Object.getOwnPropertyDescriptor(F, "f").get; let g = Object.getOwnPropertyDescriptor(G, "g").get; let h = Object.getOwnPropertyDescriptor(H, "h").get; -assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); -assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeSendableFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js b/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js index 877aa6ba2e7..84bc383066e 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: Function.prototype.toString on a getter (class) +description: SendableFunction.prototype.toString on a getter (class) includes: [nativeFunctionMatcher.js] ---*/ @@ -28,6 +28,6 @@ let f = Object.getOwnPropertyDescriptor(F.prototype, "f").get; let g = Object.getOwnPropertyDescriptor(G.prototype, "g").get; let h = Object.getOwnPropertyDescriptor(H.prototype, "h").get; -assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); -assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeSendableFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-object.js b/test/sendable/builtins/Function/prototype/toString/getter-object.js index cc9522e36b0..201f3fbb487 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-object.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-object.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: Function.prototype.toString on a getter (object) +description: SendableFunction.prototype.toString on a getter (object) includes: [nativeFunctionMatcher.js] ---*/ @@ -24,6 +24,6 @@ let f = Object.getOwnPropertyDescriptor({ /* before */get /* a */ f /* b */ ( /* let g = Object.getOwnPropertyDescriptor({ /* before */get /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }, "g").get; let h = Object.getOwnPropertyDescriptor({ /* before */get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }, "h").get; -assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); -assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeSendableFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeSendableFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js index 298627e49ad..1ce45115b40 100644 --- a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js +++ b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js @@ -15,9 +15,9 @@ /*--- esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject -description: Function.prototype.toString line terminator normalisation (CR-LF) +description: SendableFunction.prototype.toString line terminator normalisation (CR-LF) info: | - Function.prototype.toString should not normalise line terminator sequences to Line Feed characters. + SendableFunction.prototype.toString should not normalise line terminator sequences to Line Feed characters. This file uses (Carriage Return, Line Feed) sequences as line terminators. includes: [nativeFunctionMatcher.js] ---*/ @@ -46,4 +46,4 @@ y } // after -assertToStringOrNativeFunction(f, "function\r\n// a\r\nf\r\n// b\r\n(\r\n// c\r\nx\r\n// d\r\n,\r\n// e\r\ny\r\n// f\r\n)\r\n// g\r\n{\r\n// h\r\n;\r\n// i\r\n;\r\n// j\r\n}"); +assertToStringOrNativeSendableFunction(f, "function\r\n// a\r\nf\r\n// b\r\n(\r\n// c\r\nx\r\n// d\r\n,\r\n// e\r\ny\r\n// f\r\n)\r\n// g\r\n{\r\n// h\r\n;\r\n// i\r\n;\r\n// j\r\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js index 492c0436e89..71427c8f081 100644 --- a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js +++ b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js @@ -15,9 +15,9 @@ /*--- esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject -description: Function.prototype.toString line terminator normalisation (CR) +description: SendableFunction.prototype.toString line terminator normalisation (CR) info: | - Function.prototype.toString should not normalise line terminator sequences to Line Feed characters. + SendableFunction.prototype.toString should not normalise line terminator sequences to Line Feed characters. This file uses Carriage Return characters as line terminators. includes: [nativeFunctionMatcher.js] ---*/ @@ -46,4 +46,4 @@ y } // after -assertToStringOrNativeFunction(f, "function\r// a\rf\r// b\r(\r// c\rx\r// d\r,\r// e\ry\r// f\r)\r// g\r{\r// h\r;\r// i\r;\r// j\r}"); +assertToStringOrNativeSendableFunction(f, "function\r// a\rf\r// b\r(\r// c\rx\r// d\r,\r// e\ry\r// f\r)\r// g\r{\r// h\r;\r// i\r;\r// j\r}"); diff --git a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js index 986d050e75d..8c96684075c 100644 --- a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js +++ b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js @@ -15,9 +15,9 @@ /*--- esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject -description: Function.prototype.toString line terminator normalisation (LF) +description: SendableFunction.prototype.toString line terminator normalisation (LF) info: | - Function.prototype.toString should not normalise line terminator sequences to Line Feed characters. + SendableFunction.prototype.toString should not normalise line terminator sequences to Line Feed characters. This file uses Line Feed characters as line terminators. includes: [nativeFunctionMatcher.js] ---*/ @@ -46,4 +46,4 @@ y } // after -assertToStringOrNativeFunction(f, "function\n// a\nf\n// b\n(\n// c\nx\n// d\n,\n// e\ny\n// f\n)\n// g\n{\n// h\n;\n// i\n;\n// j\n}"); +assertToStringOrNativeSendableFunction(f, "function\n// a\nf\n// b\n(\n// c\nx\n// d\n,\n// e\ny\n// f\n)\n// g\n{\n// h\n;\n// i\n;\n// j\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js index 08d5bb75859..28bd68d129a 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-runtime-semantics-definemethod -description: Function.prototype.toString on a method (class; static) +description: SendableFunction.prototype.toString on a method (class; static) includes: [nativeFunctionMatcher.js] ---*/ @@ -24,6 +24,6 @@ let f = class { static /* before */f /* a */ ( /* b */ ) /* c */ { /* d */ }/* a let g = class { static /* before */[ /* a */ "g" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.g; let h = class { static /* before */[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.h; -assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeSendableFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/method-class-expression.js index ce8d5470f61..2b93150acdf 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/method-class-expression.js @@ -15,7 +15,7 @@ /*--- esid: sec-runtime-semantics-definemethod -description: Function.prototype.toString on a method (class) +description: SendableFunction.prototype.toString on a method (class) includes: [nativeFunctionMatcher.js] ---*/ @@ -24,6 +24,6 @@ let f = class { /* before */f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ let g = class { /* before */[ /* a */ "g" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.prototype.g; let h = class { /* before */[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.prototype.h; -assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeSendableFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js index 69202c5d409..1a77c2ab615 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-runtime-semantics-definemethod -description: Function.prototype.toString on a method (class; static) +description: SendableFunction.prototype.toString on a method (class; static) includes: [nativeFunctionMatcher.js] ---*/ @@ -28,6 +28,6 @@ let f = F.f; let g = G.g; let h = H.h; -assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeSendableFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/method-class-statement.js index 8f6d3b1ca29..89386f3fc9d 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/method-class-statement.js @@ -15,7 +15,7 @@ /*--- esid: sec-runtime-semantics-definemethod -description: Function.prototype.toString on a method (class) +description: SendableFunction.prototype.toString on a method (class) includes: [nativeFunctionMatcher.js] ---*/ @@ -28,6 +28,6 @@ let f = F.prototype.f; let g = G.prototype.g; let h = H.prototype.h; -assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeSendableFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js b/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js index df8e7ad32a0..bae6cdd7421 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js +++ b/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js @@ -15,12 +15,12 @@ /*--- esid: sec-runtime-semantics-definemethod -description: Function.prototype.toString on a method (object) +description: SendableFunction.prototype.toString on a method (object) includes: [nativeFunctionMatcher.js] ---*/ let f = { /* before */[ /* a */ "f" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.f; let g = { [ { a(){} }.a ](){ } }["a(){}"]; -assertToStringOrNativeFunction(f, "[ /* a */ \"f\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(g, "[ { a(){} }.a ](){ }"); +assertToStringOrNativeSendableFunction(f, "[ /* a */ \"f\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(g, "[ { a(){} }.a ](){ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-object.js b/test/sendable/builtins/Function/prototype/toString/method-object.js index db2de062d38..17395bfb0ac 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-object.js +++ b/test/sendable/builtins/Function/prototype/toString/method-object.js @@ -15,10 +15,10 @@ /*--- esid: sec-runtime-semantics-definemethod -description: Function.prototype.toString on a method (object) +description: SendableFunction.prototype.toString on a method (object) includes: [nativeFunctionMatcher.js] ---*/ let f = { /* before */f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ }.f; -assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeSendableFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/name.js b/test/sendable/builtins/Function/prototype/toString/name.js index a62b977e277..4fdf9d7faa3 100644 --- a/test/sendable/builtins/Function/prototype/toString/name.js +++ b/test/sendable/builtins/Function/prototype/toString/name.js @@ -16,22 +16,22 @@ /*--- esid: sec-function.prototype.tostring description: > - Function.prototype.toString.name is "toString". + SendableFunction.prototype.toString.name is "toString". info: | - Function.prototype.toString ( ) + SendableFunction.prototype.toString ( ) 17 ECMAScript Standard Built-in Objects: - Every built-in Function object, including constructors, that is not + Every built-in SendableFunction 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 + Unless otherwise specified, the name property of a built-in SendableFunction object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. includes: [propertyHelper.js] ---*/ -verifyProperty(Function.prototype.toString, "name", { +verifyProperty(SendableFunction.prototype.toString, "name", { value: "toString", writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/toString/not-a-constructor.js b/test/sendable/builtins/Function/prototype/toString/not-a-constructor.js index 85bfa4d7020..929c36826fd 100644 --- a/test/sendable/builtins/Function/prototype/toString/not-a-constructor.js +++ b/test/sendable/builtins/Function/prototype/toString/not-a-constructor.js @@ -16,9 +16,9 @@ /*--- esid: sec-ecmascript-standard-built-in-objects description: > - Function.prototype.toString does not implement [[Construct]], is not new-able + SendableFunction.prototype.toString does not implement [[Construct]], is not new-able info: | - ECMAScript Function Objects + ECMAScript SendableFunction Objects Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method unless otherwise specified in @@ -34,16 +34,16 @@ features: [Reflect.construct, arrow-function] ---*/ assert.sameValue( - isConstructor(Function.prototype.toString), + isConstructor(SendableFunction.prototype.toString), false, - 'isConstructor(Function.prototype.toString) must return false' + 'isConstructor(SendableFunction.prototype.toString) must return false' ); assert.throws(TypeError, () => { - new Function.prototype.toString(); + new SendableFunction.prototype.toString(); }); -var toString = Function.prototype.toString; +var toString = SendableFunction.prototype.toString; assert.throws(TypeError, () => { new toString; }); diff --git a/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js index a630d2ecfa6..432157f9287 100644 --- a/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js @@ -14,7 +14,7 @@ */ /*--- -description: Function.prototype.toString on a private method +description: SendableFunction.prototype.toString on a private method features: [class-methods-private] includes: [nativeFunctionMatcher.js] ---*/ @@ -22,7 +22,7 @@ includes: [nativeFunctionMatcher.js] let c = new (class { /* before */#f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ assert(expected) { - assertToStringOrNativeFunction(this.#f, expected); + assertToStringOrNativeSendableFunction(this.#f, expected); } }); diff --git a/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js index 09f82858240..33773bf7843 100644 --- a/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js @@ -14,7 +14,7 @@ */ /*--- -description: Function.prototype.toString on a private method +description: SendableFunction.prototype.toString on a private method features: [class-methods-private] includes: [nativeFunctionMatcher.js] ---*/ @@ -22,7 +22,7 @@ includes: [nativeFunctionMatcher.js] class C { /* before */#f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ assert(expected) { - assertToStringOrNativeFunction(this.#f, expected); + assertToStringOrNativeSendableFunction(this.#f, expected); } } diff --git a/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js index 147df7f3dc7..150c6d88a61 100644 --- a/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js @@ -14,7 +14,7 @@ */ /*--- -description: Function.prototype.toString on a static private method +description: SendableFunction.prototype.toString on a static private method features: [class-static-methods-private] includes: [nativeFunctionMatcher.js] ---*/ @@ -22,7 +22,7 @@ includes: [nativeFunctionMatcher.js] let C = class { /* before */static #f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ static assert(expected) { - assertToStringOrNativeFunction(this.#f, expected); + assertToStringOrNativeSendableFunction(this.#f, expected); } }; diff --git a/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js index b2ba3a7aedf..fcf4045bab8 100644 --- a/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js @@ -14,7 +14,7 @@ */ /*--- -description: Function.prototype.toString on a static private method +description: SendableFunction.prototype.toString on a static private method features: [class-static-methods-private] includes: [nativeFunctionMatcher.js] ---*/ @@ -22,7 +22,7 @@ includes: [nativeFunctionMatcher.js] class C { /* before */static #f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ static assert(expected) { - assertToStringOrNativeFunction(this.#f, expected); + assertToStringOrNativeSendableFunction(this.#f, expected); } } diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js index f083c626f1c..8e15552a143 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js @@ -16,20 +16,20 @@ /*--- esid: sec-function.prototype.tostring description: > - toString of Proxy for function target does not throw (Arrow Function) + toString of Proxy for function target does not throw (Arrow SendableFunction) info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeFunction. + The representation must have the syntax of a NativeSendableFunction. ... - NativeFunction: + NativeSendableFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [arrow-function, Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeFunction(new Proxy(() => {}, {})); -assertNativeFunction(new Proxy(() => {}, { apply() {} }).apply); +assertNativeSendableFunction(new Proxy(() => {}, {})); +assertNativeSendableFunction(new Proxy(() => {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js index 52116dd0d0a..9c9bb22ed05 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js @@ -16,20 +16,20 @@ /*--- esid: sec-function.prototype.tostring description: > - toString of Proxy for function target does not throw (Async Function Expression) + toString of Proxy for function target does not throw (Async SendableFunction Expression) info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeFunction. + The representation must have the syntax of a NativeSendableFunction. ... - NativeFunction: + NativeSendableFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [async-functions, Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeFunction(new Proxy(async function() {}, {})); -assertNativeFunction(new Proxy(async function() {}, { apply() {} }).apply); +assertNativeSendableFunction(new Proxy(async function() {}, {})); +assertNativeSendableFunction(new Proxy(async function() {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js index 100cb345a40..1428e6807ea 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js @@ -16,20 +16,20 @@ /*--- esid: sec-function.prototype.tostring description: > - toString of Proxy for function target does not throw (Async Generator Function Expression) + toString of Proxy for function target does not throw (Async Generator SendableFunction Expression) info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeFunction. + The representation must have the syntax of a NativeSendableFunction. ... - NativeFunction: + NativeSendableFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [async-iteration, Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeFunction(new Proxy(async function * () {}, {})); -assertNativeFunction(new Proxy(async function * () {}, { apply() {} }).apply); +assertNativeSendableFunction(new Proxy(async function * () {}, {})); +assertNativeSendableFunction(new Proxy(async function * () {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-method-definition.js b/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-method-definition.js index 08c8fc77392..3f9a6ac5efe 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-method-definition.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-method-definition.js @@ -21,15 +21,15 @@ info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeFunction. + The representation must have the syntax of a NativeSendableFunction. ... - NativeFunction: + NativeSendableFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [async-iteration, Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeFunction(new Proxy({ async * method() {} }.method, {})); -assertNativeFunction(new Proxy({ async * method() {} }.method, { apply() {} }).apply); +assertNativeSendableFunction(new Proxy({ async * method() {} }.method, {})); +assertNativeSendableFunction(new Proxy({ async * method() {} }.method, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-async-method-definition.js b/test/sendable/builtins/Function/prototype/toString/proxy-async-method-definition.js index 0222908cb62..a683fdfba92 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-async-method-definition.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-async-method-definition.js @@ -21,15 +21,15 @@ info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeFunction. + The representation must have the syntax of a NativeSendableFunction. ... - NativeFunction: + NativeSendableFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [async-functions, Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeFunction(new Proxy({ async method() {} }.method, {})); -assertNativeFunction(new Proxy({ async method() {} }.method, { apply() {} }).apply); +assertNativeSendableFunction(new Proxy({ async method() {} }.method, {})); +assertNativeSendableFunction(new Proxy({ async method() {} }.method, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js index 56269712a95..0fcf7f5ada9 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js @@ -16,20 +16,20 @@ /*--- esid: sec-function.prototype.tostring description: > - toString of Proxy for function target does not throw (bound Function Expression) + toString of Proxy for function target does not throw (bound SendableFunction Expression) info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeFunction. + The representation must have the syntax of a NativeSendableFunction. ... - NativeFunction: + NativeSendableFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeFunction(new Proxy(function() {}.bind({}), {})); -assertNativeFunction(new Proxy(function() {}.bind({}), { apply() {} }).apply); +assertNativeSendableFunction(new Proxy(function() {}.bind({}), {})); +assertNativeSendableFunction(new Proxy(function() {}.bind({}), { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-class.js b/test/sendable/builtins/Function/prototype/toString/proxy-class.js index b038ec8f373..e53a3f71b81 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-class.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-class.js @@ -21,15 +21,15 @@ info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeFunction. + The representation must have the syntax of a NativeSendableFunction. ... - NativeFunction: + NativeSendableFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [class, Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeFunction(new Proxy(class {}, {})); -assertNativeFunction(new Proxy(class {}, { apply() {} }).apply); +assertNativeSendableFunction(new Proxy(class {}, {})); +assertNativeSendableFunction(new Proxy(class {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js b/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js index 1acd12f5d2c..02b929b7d37 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js @@ -16,20 +16,20 @@ /*--- esid: sec-function.prototype.tostring description: > - toString of Proxy for function target does not throw (Function Expression) + toString of Proxy for function target does not throw (SendableFunction Expression) info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeFunction. + The representation must have the syntax of a NativeSendableFunction. ... - NativeFunction: + NativeSendableFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeFunction(new Proxy(function() {}, {})); -assertNativeFunction(new Proxy(function() {}, { apply() {} }).apply); +assertNativeSendableFunction(new Proxy(function() {}, {})); +assertNativeSendableFunction(new Proxy(function() {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js index 41d5e1516cf..347beeff575 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js @@ -16,20 +16,20 @@ /*--- esid: sec-function.prototype.tostring description: > - toString of Proxy for function target does not throw (Generator Function Expression) + toString of Proxy for function target does not throw (Generator SendableFunction Expression) info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeFunction. + The representation must have the syntax of a NativeSendableFunction. ... - NativeFunction: + NativeSendableFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [generators, Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeFunction(new Proxy(function * () {}, {})); -assertNativeFunction(new Proxy(function * () {}, { apply() {} }).apply); +assertNativeSendableFunction(new Proxy(function * () {}, {})); +assertNativeSendableFunction(new Proxy(function * () {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-method-definition.js b/test/sendable/builtins/Function/prototype/toString/proxy-method-definition.js index 5e26b894340..c9389d81642 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-method-definition.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-method-definition.js @@ -21,15 +21,15 @@ info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeFunction. + The representation must have the syntax of a NativeSendableFunction. ... - NativeFunction: + NativeSendableFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeFunction(new Proxy({ method() {} }.method, {})); -assertNativeFunction(new Proxy({ method() {} }.method, { apply() {} }).apply); +assertNativeSendableFunction(new Proxy({ method() {} }.method, {})); +assertNativeSendableFunction(new Proxy({ method() {} }.method, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-non-callable-throws.js b/test/sendable/builtins/Function/prototype/toString/proxy-non-callable-throws.js index a13d57f87d1..df2a79f2ed3 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-non-callable-throws.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-non-callable-throws.js @@ -25,5 +25,5 @@ features: [Proxy] ---*/ assert.throws(TypeError, function() { - Function.prototype.toString.call(new Proxy({}, {})); + SendableFunction.prototype.toString.call(new Proxy({}, {})); }); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js index c78825bfc01..22021d429ca 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: Function.prototype.toString on a setter (class; static) +description: SendableFunction.prototype.toString on a setter (class; static) includes: [nativeFunctionMatcher.js] ---*/ @@ -24,6 +24,6 @@ let f = Object.getOwnPropertyDescriptor(class { static /* before */set /* a */ f let g = Object.getOwnPropertyDescriptor(class { static /* before */set /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }, "g").set; let h = Object.getOwnPropertyDescriptor(class { static /* before */set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }, "h").set; -assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js b/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js index ec8518c3808..78eb4513b53 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: Function.prototype.toString on a setter (class) +description: SendableFunction.prototype.toString on a setter (class) includes: [nativeFunctionMatcher.js] ---*/ @@ -24,6 +24,6 @@ let f = Object.getOwnPropertyDescriptor(class { /* before */set /* a */ f /* b * let g = Object.getOwnPropertyDescriptor(class { /* before */set /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }.prototype, "g").set; let h = Object.getOwnPropertyDescriptor(class { /* before */set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }.prototype, "h").set; -assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js index 2edc358744e..0244ebdf852 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: Function.prototype.toString on a setter (class; static) +description: SendableFunction.prototype.toString on a setter (class; static) includes: [nativeFunctionMatcher.js] ---*/ @@ -28,6 +28,6 @@ let f = Object.getOwnPropertyDescriptor(F, "f").set; let g = Object.getOwnPropertyDescriptor(G, "g").set; let h = Object.getOwnPropertyDescriptor(H, "h").set; -assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js b/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js index ca66f7f257f..4ee4096718a 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: Function.prototype.toString on a setter (class) +description: SendableFunction.prototype.toString on a setter (class) includes: [nativeFunctionMatcher.js] ---*/ @@ -28,6 +28,6 @@ let f = Object.getOwnPropertyDescriptor(F.prototype, "f").set; let g = Object.getOwnPropertyDescriptor(G.prototype, "g").set; let h = Object.getOwnPropertyDescriptor(H.prototype, "h").set; -assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-object.js b/test/sendable/builtins/Function/prototype/toString/setter-object.js index 18742d81a4d..aae9fb335e7 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-object.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-object.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: Function.prototype.toString on a setter (object) +description: SendableFunction.prototype.toString on a setter (object) includes: [nativeFunctionMatcher.js] ---*/ @@ -24,6 +24,6 @@ let f = Object.getOwnPropertyDescriptor({ /* before */set /* a */ f /* b */ ( /* let g = Object.getOwnPropertyDescriptor({ /* before */set /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }, "g").set; let h = Object.getOwnPropertyDescriptor({ /* before */set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }, "h").set; -assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeSendableFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeSendableFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js b/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js index 15f95f2afe8..d8b14bdbad2 100644 --- a/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js +++ b/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js @@ -15,9 +15,9 @@ /*--- esid: sec-function.prototype.tostring -description: Function.prototype.toString on symbol-named built-ins +description: SendableFunction.prototype.toString on symbol-named built-ins includes: [nativeFunctionMatcher.js] ---*/ -assertNativeFunction(RegExp.prototype[Symbol.match]); -assertNativeFunction(Object.getOwnPropertyDescriptor(RegExp, Symbol.species).get); +assertNativeSendableFunction(RegExp.prototype[Symbol.match]); +assertNativeSendableFunction(Object.getOwnPropertyDescriptor(RegExp, Symbol.species).get); diff --git a/test/sendable/builtins/Function/prototype/toString/unicode.js b/test/sendable/builtins/Function/prototype/toString/unicode.js index 8352ec14615..15ce27b98cf 100644 --- a/test/sendable/builtins/Function/prototype/toString/unicode.js +++ b/test/sendable/builtins/Function/prototype/toString/unicode.js @@ -15,13 +15,13 @@ /*--- esid: sec-function.prototype.tostring -description: Function.prototype.toString on a function with Unicode escape sequences +description: SendableFunction.prototype.toString on a function with Unicode escape sequences info: | - Function.prototype.toString returns a slice of the source text before + SendableFunction.prototype.toString returns a slice of the source text before any potential Unicode escape sequence substitution in identifiers includes: [nativeFunctionMatcher.js] ---*/ function \u0061(\u{62}, \u0063) { \u0062 = \u{00063}; return b; } -assertToStringOrNativeFunction(a, "function \\u0061(\\u{62}, \\u0063) { \\u0062 = \\u{00063}; return b; }"); +assertToStringOrNativeSendableFunction(a, "function \\u0061(\\u{62}, \\u0063) { \\u0062 = \\u{00063}; return b; }"); diff --git a/test/sendable/builtins/TypedArray/Symbol.species/length.js b/test/sendable/builtins/TypedArray/Symbol.species/length.js new file mode 100644 index 00000000000..acec196f159 --- /dev/null +++ b/test/sendable/builtins/TypedArray/Symbol.species/length.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 22.2.2.4 +description: > + get %SendableTypedArray% [ @@species ].length is 0. +info: | + get %SendableTypedArray% [ @@species ] + + 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, testTypedArray.js] +features: [Symbol.species] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray, Symbol.species); + +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/Symbol.species/name.js b/test/sendable/builtins/TypedArray/Symbol.species/name.js new file mode 100644 index 00000000000..bfdf652f57e --- /dev/null +++ b/test/sendable/builtins/TypedArray/Symbol.species/name.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 22.2.2.4 +description: > + get %SendableTypedArray% [ @@species ].name is "get [Symbol.species]". +info: | + get %SendableTypedArray% [ @@species ] + + 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, testTypedArray.js] +features: [Symbol.species] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray, Symbol.species); + +verifyProperty(desc.get, "name", { + value: "get [Symbol.species]", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/Symbol.species/prop-desc.js b/test/sendable/builtins/TypedArray/Symbol.species/prop-desc.js new file mode 100644 index 00000000000..d2f3ef68af9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/Symbol.species/prop-desc.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 22.2.2.4 +description: > + @@species property of SendableTypedArray +info: | + 22.2.2.4 get %SendableTypedArray% [ @@species ] + + %SendableTypedArray%[@@species] is an accessor property whose set accessor function + is undefined. +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray, Symbol.species); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, 'function'); diff --git a/test/sendable/builtins/TypedArray/Symbol.species/result.js b/test/sendable/builtins/TypedArray/Symbol.species/result.js new file mode 100644 index 00000000000..0cb5e612c3f --- /dev/null +++ b/test/sendable/builtins/TypedArray/Symbol.species/result.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 22.2.2.4 +description: > + @@species property returns the `this` value +info: | + 22.2.2.4 get %SendableTypedArray% [ @@species ] + + 1. Return the this value. +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +var value = {}; +var getter = Object.getOwnPropertyDescriptor(SendableTypedArray, Symbol.species).get; + +assert.sameValue(getter.call(value), value); diff --git a/test/sendable/builtins/TypedArray/from/arylk-get-length-error.js b/test/sendable/builtins/TypedArray/from/arylk-get-length-error.js new file mode 100644 index 00000000000..5a005139da5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/arylk-get-length-error.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: Returns error produced by accessing array-like's length +info: | + 22.2.2.1 %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 7. Let len be ? ToLength(? Get(arrayLike, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var arrayLike = {}; + +Object.defineProperty(arrayLike, "length", { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + SendableTypedArray.from(arrayLike); +}); diff --git a/test/sendable/builtins/TypedArray/from/arylk-to-length-error.js b/test/sendable/builtins/TypedArray/from/arylk-to-length-error.js new file mode 100644 index 00000000000..579fba082bc --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/arylk-to-length-error.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: Returns error produced by interpreting length property as a length +info: | + 22.2.2.1 %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 7. Let len be ? ToLength(? Get(arrayLike, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var arrayLike = { length: {} }; + +arrayLike.length = { + valueOf: function() { + throw new Test262Error(); + } +}; + +assert.throws(Test262Error, function() { + SendableTypedArray.from(arrayLike); +}); diff --git a/test/sendable/builtins/TypedArray/from/from-array-mapper-detaches-result.js b/test/sendable/builtins/TypedArray/from/from-array-mapper-detaches-result.js new file mode 100644 index 00000000000..8995f237874 --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/from-array-mapper-detaches-result.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: > + If the mapper function detaches the result typed array, .from performs Set operation which ignores out-of-bounds indices. +info: | + %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 12. Repeat, while k < len, + ... + c. If mapping is true, then + i. Let mappedValue be ? Call(mapfn, thisArg, « kValue, 𝔽(k) »). + ... + e. Perform ? Set(targetObj, Pk, mappedValue, true). + ... +includes: [detachArrayBuffer.js] +features: [TypedArray] +---*/ + +let ab = new ArrayBuffer(3); +let target = new Int8Array(ab); +let values = [0, 1, 2]; + +let result = Int32Array.from.call(function() { + return target; +}, values, v => { + if (v === 1) { + $DETACHBUFFER(ab); + } + return v + 10; +}); + +assert.sameValue(result, target); +assert.sameValue(result.length, 0); diff --git a/test/sendable/builtins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js b/test/sendable/builtins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js new file mode 100644 index 00000000000..0e87da3ae19 --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: > + If the mapper function makes result typed array out-of-bounds, .from performs Set operation which ignores out-of-bounds indices. +info: | + %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 12. Repeat, while k < len, + ... + c. If mapping is true, then + i. Let mappedValue be ? Call(mapfn, thisArg, « kValue, 𝔽(k) »). + ... + e. Perform ? Set(targetObj, Pk, mappedValue, true). + ... +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let target = new Int8Array(rab); +let values = [0, 1, 2]; + +let result = Int32Array.from.call(function() { + return target; +}, values, v => { + if (v === 1) { + rab.resize(1); + } + return v + 10; +}); + +assert.sameValue(result, target); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], 10); diff --git a/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js b/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js new file mode 100644 index 00000000000..68aa5183dda --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: > + If the mapper function detaches the result typed array, .from performs Set operation which ignores out-of-bounds indices. +info: | + %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 12. Repeat, while k < len, + ... + c. If mapping is true, then + i. Let mappedValue be ? Call(mapfn, thisArg, « kValue, 𝔽(k) »). + ... + e. Perform ? Set(targetObj, Pk, mappedValue, true). + ... +includes: [detachArrayBuffer.js] +features: [TypedArray] +---*/ + +let ab = new ArrayBuffer(3); +let target = new Int8Array(ab); +target.set([0, 1, 2]); + +let result = Int32Array.from.call(function() { + return target; +}, target, v => { + if (v === 1) { + $DETACHBUFFER(ab); + } + return v + 10; +}); + +assert.sameValue(result, target); +assert.sameValue(result.length, 0); diff --git a/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js b/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js new file mode 100644 index 00000000000..24acc9a4e4f --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: > + If the mapper function makes result typed array out-of-bounds, .from performs Set operation which ignores out-of-bounds indices. +info: | + %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 12. Repeat, while k < len, + ... + c. If mapping is true, then + i. Let mappedValue be ? Call(mapfn, thisArg, « kValue, 𝔽(k) »). + ... + e. Perform ? Set(targetObj, Pk, mappedValue, true). + ... +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let target = new Int8Array(rab); +target.set([0, 1, 2]); + +let result = Int32Array.from.call(function() { + return target; +}, target, v => { + if (v === 1) { + rab.resize(1); + } + return v + 10; +}); + +assert.sameValue(result, target); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], 10); diff --git a/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-detaches-result.js b/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-detaches-result.js new file mode 100644 index 00000000000..7b2935995d0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-detaches-result.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: > + If the mapper function detaches the result typed array, .from performs Set operation which ignores out-of-bounds indices. +info: | + %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 12. Repeat, while k < len, + ... + c. If mapping is true, then + i. Let mappedValue be ? Call(mapfn, thisArg, « kValue, 𝔽(k) »). + ... + e. Perform ? Set(targetObj, Pk, mappedValue, true). + ... +includes: [detachArrayBuffer.js] +features: [TypedArray] +---*/ + +let ab = new ArrayBuffer(3); +let target = new Int8Array(ab); +let values = new Int8Array([0, 1, 2]); + +let result = Int32Array.from.call(function() { + return target; +}, values, v => { + if (v === 1) { + $DETACHBUFFER(ab); + } + return v + 10; +}); + +assert.sameValue(result, target); +assert.sameValue(result.length, 0); diff --git a/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js b/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js new file mode 100644 index 00000000000..2b8006c4da7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: > + If the mapper function makes result typed array out-of-bounds, .from performs Set operation which ignores out-of-bounds indices. +info: | + %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 12. Repeat, while k < len, + ... + c. If mapping is true, then + i. Let mappedValue be ? Call(mapfn, thisArg, « kValue, 𝔽(k) »). + ... + e. Perform ? Set(targetObj, Pk, mappedValue, true). + ... +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let target = new Int8Array(rab); +let values = new Int8Array([0, 1, 2]); + +let result = Int32Array.from.call(function() { + return target; +}, values, v => { + if (v === 1) { + rab.resize(1); + } + return v + 10; +}); + +assert.sameValue(result, target); +assert.sameValue(result.length, 1); +assert.sameValue(result[0], 10); diff --git a/test/sendable/builtins/TypedArray/from/invoked-as-func.js b/test/sendable/builtins/TypedArray/from/invoked-as-func.js new file mode 100644 index 00000000000..40a7dd7b195 --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/invoked-as-func.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: > + "from" cannot be invoked as a function +info: | + 22.2.2.1 %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + 1. Let C be the this value. + 2. If IsConstructor(C) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var from = SendableTypedArray.from; + +assert.throws(TypeError, function() { + from([]); +}); diff --git a/test/sendable/builtins/TypedArray/from/invoked-as-method.js b/test/sendable/builtins/TypedArray/from/invoked-as-method.js new file mode 100644 index 00000000000..7014e7cd0fb --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/invoked-as-method.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: > + "from" cannot be invoked as a method of %SendableTypedArray% +info: | + 22.2.2.1 %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 8. Let targetObj be ? SendableTypedArrayCreate(C, «len»). + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +assert.throws(TypeError, function() { + SendableTypedArray.from([]); +}); diff --git a/test/sendable/builtins/TypedArray/from/iter-access-error.js b/test/sendable/builtins/TypedArray/from/iter-access-error.js new file mode 100644 index 00000000000..e5edb6fd1da --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/iter-access-error.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: Returns error produced by accessing @@iterator +info: | + 22.2.2.1 %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 6. Let arrayLike be ? IterableToArrayLike(source). + ... + + 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items ) + + 1. Let usingIterator be ? GetMethod(items, @@iterator). + ... +includes: [testTypedArray.js] +features: [Symbol.iterator, TypedArray] +---*/ + +var iter = {}; +Object.defineProperty(iter, Symbol.iterator, { + get: function() { + throw new Test262Error(); + } +}); + +assert.throws(Test262Error, function() { + SendableTypedArray.from(iter); +}); diff --git a/test/sendable/builtins/TypedArray/from/iter-invoke-error.js b/test/sendable/builtins/TypedArray/from/iter-invoke-error.js new file mode 100644 index 00000000000..60fdc9c9029 --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/iter-invoke-error.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: Returns error produced by invoking @@iterator +info: | + 22.2.2.1 %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 6. Let arrayLike be ? IterableToArrayLike(source). + ... + + 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items ) + + 1. Let usingIterator be ? GetMethod(items, @@iterator). + 2. If usingIterator is not undefined, then + a. Let iterator be ? GetIterator(items, usingIterator). + ... +includes: [testTypedArray.js] +features: [Symbol.iterator, TypedArray] +---*/ + +var iter = {}; +iter[Symbol.iterator] = function() { + throw new Test262Error(); +}; + +assert.throws(Test262Error, function() { + SendableTypedArray.from(iter); +}); diff --git a/test/sendable/builtins/TypedArray/from/iter-next-error.js b/test/sendable/builtins/TypedArray/from/iter-next-error.js new file mode 100644 index 00000000000..319051f84cb --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/iter-next-error.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: Returns error produced by advancing the iterator +info: | + 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items ) + + 2. If usingIterator is not undefined, then + ... + d. Repeat, while next is not false + i. Let next be ? IteratorStep(iterator). + ... +includes: [testTypedArray.js] +features: [Symbol.iterator, TypedArray] +---*/ + +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + SendableTypedArray.from(iter); +}); diff --git a/test/sendable/builtins/TypedArray/from/iter-next-value-error.js b/test/sendable/builtins/TypedArray/from/iter-next-value-error.js new file mode 100644 index 00000000000..2d3e8ed4ee9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/iter-next-value-error.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: Returns error produced by accessing iterated value +info: | + 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items ) + + 2. If usingIterator is not undefined, then + ... + d. Repeat, while next is not false + ... + ii. If next is not false, then + 1. Let nextValue be ? IteratorValue(next). + ... +includes: [testTypedArray.js] +features: [Symbol.iterator, TypedArray] +---*/ + +var iter = {}; +iter[Symbol.iterator] = function() { + return { + next: function() { + var result = {}; + Object.defineProperty(result, 'value', { + get: function() { + throw new Test262Error(); + } + }); + + return result; + } + }; +}; + +assert.throws(Test262Error, function() { + SendableTypedArray.from(iter); +}); diff --git a/test/sendable/builtins/TypedArray/from/iterated-array-changed-by-tonumber.js b/test/sendable/builtins/TypedArray/from/iterated-array-changed-by-tonumber.js new file mode 100644 index 00000000000..e253d8ac9b5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/iterated-array-changed-by-tonumber.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: > + Modifications to input array after iteration are handled correctly. +info: | + %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 6. If usingIterator is not undefined, then + a. Let values be ? IteratorToList(? GetIteratorFromMethod(source, usingIterator)). + b. Let len be the number of elements in values. + ... + e. Repeat, while k < len, + ... + vi. Perform ? Set(targetObj, Pk, mappedValue, true). + ... +features: [TypedArray] +---*/ + +let values = [0, { + valueOf() { + // Removes all array elements. Caller must have saved all elements. + values.length = 0; + return 100; + } +}, 2]; + +// `from` called with array which uses the built-in array iterator. +let ta = Int32Array.from(values); + +assert.sameValue(ta.length, 3); +assert.sameValue(ta[0], 0); +assert.sameValue(ta[1], 100); +assert.sameValue(ta[2], 2); diff --git a/test/sendable/builtins/TypedArray/from/length.js b/test/sendable/builtins/TypedArray/from/length.js new file mode 100644 index 00000000000..cc3ff257fcf --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/length.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: > + %SendableTypedArray%.from.length is 1. +info: | + %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.from, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/from/mapfn-is-not-callable.js b/test/sendable/builtins/TypedArray/from/mapfn-is-not-callable.js new file mode 100644 index 00000000000..19f160043af --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/mapfn-is-not-callable.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: Throw a TypeError exception is mapfn is not callable +info: | + 22.2.2.1 %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + ... + 3. If mapfn was supplied and mapfn is not undefined, then + a. If IsCallable(mapfn) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, Symbol.iterator, TypedArray] +---*/ + +var getIterator = 0; +var arrayLike = {}; +Object.defineProperty(arrayLike, Symbol.iterator, { + get: function() { + getIterator++; + } +}); + +assert.throws(TypeError, function() { + SendableTypedArray.from(arrayLike, null); +}, "mapfn is null"); + +assert.throws(TypeError, function() { + SendableTypedArray.from(arrayLike, 42); +}, "mapfn is a number"); + +assert.throws(TypeError, function() { + SendableTypedArray.from(arrayLike, ""); +}, "mapfn is a string"); + +assert.throws(TypeError, function() { + SendableTypedArray.from(arrayLike, {}); +}, "mapfn is an ordinary object"); + +assert.throws(TypeError, function() { + SendableTypedArray.from(arrayLike, []); +}, "mapfn is an array"); + +assert.throws(TypeError, function() { + SendableTypedArray.from(arrayLike, true); +}, "mapfn is a boolean"); + +var s = Symbol("1"); +assert.throws(TypeError, function() { + SendableTypedArray.from(arrayLike, s); +}, "mapfn is a symbol"); + +assert.sameValue( + getIterator, 0, + "IsCallable(mapfn) check occurs before getting source[@@iterator]" +); diff --git a/test/sendable/builtins/TypedArray/from/name.js b/test/sendable/builtins/TypedArray/from/name.js new file mode 100644 index 00000000000..ae9c438c3a8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 22.2.2.1 +description: > + %SendableTypedArray%.from.name is "from". +info: | + %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.from, "name", { + value: "from", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/from/not-a-constructor.js b/test/sendable/builtins/TypedArray/from/not-a-constructor.js new file mode 100644 index 00000000000..84d8fa6fea5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/not-a-constructor.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.from 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, testTypedArray.js] +features: [Reflect.construct, SendableTypedArray, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableTypedArray.from), false, 'isConstructor(SendableTypedArray.from) must return false'); + +assert.throws(TypeError, () => { + new SendableTypedArray.from([]); +}); + diff --git a/test/sendable/builtins/TypedArray/from/prop-desc.js b/test/sendable/builtins/TypedArray/from/prop-desc.js new file mode 100644 index 00000000000..d02a97e21a3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/prop-desc.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 22.2.2.1 +description: > + "from" property of SendableTypedArray +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray, 'from', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/from/this-is-not-constructor.js b/test/sendable/builtins/TypedArray/from/this-is-not-constructor.js new file mode 100644 index 00000000000..e69b14725f0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/from/this-is-not-constructor.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.from +description: > + Throws a TypeError exception if this is not a constructor +info: | + 22.2.2.1 %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) + + 1. Let C be the this value. + 2. If IsConstructor(C) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var from = SendableTypedArray.from; +var m = { m() {} }.m; + +assert.throws(TypeError, function() { + from.call(m, []); +}); diff --git a/test/sendable/builtins/TypedArray/invoked.js b/test/sendable/builtins/TypedArray/invoked.js new file mode 100644 index 00000000000..412aa012aed --- /dev/null +++ b/test/sendable/builtins/TypedArray/invoked.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray% +description: Throw a TypeError exception if directly invoked. +info: | + 22.2.1.1 %SendableTypedArray% ( ) + + 1. Throw a TypeError Exception + ... + + Note: ES2016 replaces all the references for the %SendableTypedArray% constructor to a + single chapter covering all arguments cases. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +assert.throws(TypeError, function() { + SendableTypedArray(); +}); + +assert.throws(TypeError, function() { + new SendableTypedArray(); +}); + +assert.throws(TypeError, function() { + SendableTypedArray(1); +}); + +assert.throws(TypeError, function() { + new SendableTypedArray(1); +}); + +assert.throws(TypeError, function() { + SendableTypedArray(1.1); +}); + +assert.throws(TypeError, function() { + new SendableTypedArray(1.1); +}); + +assert.throws(TypeError, function() { + SendableTypedArray({}); +}); + +assert.throws(TypeError, function() { + new SendableTypedArray({}); +}); + +var typedArray = new Int8Array(4); +assert.throws(TypeError, function() { + SendableTypedArray(typedArray); +}); + +assert.throws(TypeError, function() { + new SendableTypedArray(typedArray); +}); + +var buffer = new ArrayBuffer(4); +assert.throws(TypeError, function() { + SendableTypedArray(buffer); +}); + +assert.throws(TypeError, function() { + new SendableTypedArray(buffer); +}); diff --git a/test/sendable/builtins/TypedArray/length.js b/test/sendable/builtins/TypedArray/length.js new file mode 100644 index 00000000000..f02d7d81b27 --- /dev/null +++ b/test/sendable/builtins/TypedArray/length.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray% +description: > + SendableTypedArray has a "length" property whose value is 0. +info: | + %SendableTypedArray% ( ) + + The length property of the %SendableTypedArray% constructor function is 0. + + 17 ECMAScript Standard Built-in Objects + + ... + + Unless otherwise specified, the length property of a built-in function + object has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: true }. +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/name.js b/test/sendable/builtins/TypedArray/name.js new file mode 100644 index 00000000000..f76dd7ba092 --- /dev/null +++ b/test/sendable/builtins/TypedArray/name.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray% +description: > + SendableTypedArray has a 'name' property whose value is "SendableTypedArray". +info: | + 22.2.2 Properties of the %SendableTypedArray% Intrinsic Object + + Besides a length property whose value is 3 and a name property whose value is + "SendableTypedArray", %SendableTypedArray% has the following properties: + ... + + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray, "name", { + value: "SendableTypedArray", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/of/invoked-as-func.js b/test/sendable/builtins/TypedArray/of/invoked-as-func.js new file mode 100644 index 00000000000..89389f91ce8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/of/invoked-as-func.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 22.2.2.2 +description: > + "of" cannot be invoked as a function +info: | + 22.2.2.2 %SendableTypedArray%.of ( ...items ) + + ... + 3. Let C be the this value. + 4. If IsConstructor(C) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var of = SendableTypedArray.of; + +assert.throws(TypeError, function() { + of(); +}); diff --git a/test/sendable/builtins/TypedArray/of/invoked-as-method.js b/test/sendable/builtins/TypedArray/of/invoked-as-method.js new file mode 100644 index 00000000000..55c1aae53d5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/of/invoked-as-method.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.of +description: > + "of" cannot be invoked as a method of %SendableTypedArray% +info: | + 22.2.2.2 %SendableTypedArray%.of ( ...items ) + + ... + 5. Let newObj be ? SendableTypedArrayCreate(C, «len»). + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +assert.throws(TypeError, function() { + SendableTypedArray.of(); +}); diff --git a/test/sendable/builtins/TypedArray/of/length.js b/test/sendable/builtins/TypedArray/of/length.js new file mode 100644 index 00000000000..64f92887c4c --- /dev/null +++ b/test/sendable/builtins/TypedArray/of/length.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%-of +description: > + %SendableTypedArray%.of.length is 0. +info: | + %SendableTypedArray%.of ( ...items ) + + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.of, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/of/name.js b/test/sendable/builtins/TypedArray/of/name.js new file mode 100644 index 00000000000..50c2282f64f --- /dev/null +++ b/test/sendable/builtins/TypedArray/of/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 22.2.2.2 +description: > + %SendableTypedArray%.of.name is "of". +info: | + %SendableTypedArray%.of ( ...items ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.of, "name", { + value: "of", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/of/not-a-constructor.js b/test/sendable/builtins/TypedArray/of/not-a-constructor.js new file mode 100644 index 00000000000..183c0692c55 --- /dev/null +++ b/test/sendable/builtins/TypedArray/of/not-a-constructor.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.of 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, testTypedArray.js] +features: [Reflect.construct, SendableTypedArray, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableTypedArray.of), false, 'isConstructor(SendableTypedArray.of) must return false'); + +assert.throws(TypeError, () => { + new SendableTypedArray.of(1, 2, 3, 4); +}); + diff --git a/test/sendable/builtins/TypedArray/of/prop-desc.js b/test/sendable/builtins/TypedArray/of/prop-desc.js new file mode 100644 index 00000000000..9cb9734e559 --- /dev/null +++ b/test/sendable/builtins/TypedArray/of/prop-desc.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 22.2.2.2 +description: > + "of" property of SendableTypedArray +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray, 'of', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js b/test/sendable/builtins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js new file mode 100644 index 00000000000..5601dd3c4ce --- /dev/null +++ b/test/sendable/builtins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.of +description: > + Performs Set operation which ignores out-of-bounds indices. +info: | + %SendableTypedArray%.of ( ...items ) + + ... + 6. Repeat, while k < len, + ... + c. Perform ? Set(newObj, Pk, kValue, true). + ... + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 4}); +let ta = new Int8Array(rab); + +let one = { + valueOf() { + // Shrink buffer. Assignment to `ta[0]` should be ignored. + rab.resize(0); + return 1; + } +}; + +let two = { + valueOf() { + // Grow buffer. All following assignment should succeed. + rab.resize(4); + return 2; + } +}; + +// Typed array is correctly zero initialised. +assert.sameValue(ta.length, 3); +assert.sameValue(ta[0], 0); +assert.sameValue(ta[1], 0); +assert.sameValue(ta[2], 0); + +let result = Int8Array.of.call(function() { + return ta; +}, one, two, 3); + +// Correct result value. +assert.sameValue(result, ta); + +// Values are correctly set. +assert.sameValue(ta.length, 4); +assert.sameValue(ta[0], 0); +assert.sameValue(ta[1], 2); +assert.sameValue(ta[2], 3); +assert.sameValue(ta[3], 0); diff --git a/test/sendable/builtins/TypedArray/of/this-is-not-constructor.js b/test/sendable/builtins/TypedArray/of/this-is-not-constructor.js new file mode 100644 index 00000000000..e60f2e30620 --- /dev/null +++ b/test/sendable/builtins/TypedArray/of/this-is-not-constructor.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.of +description: > + Throws a TypeError exception if this is not a constructor +info: | + 22.2.2.2 %SendableTypedArray%.of ( ...items ) + + ... + 3. Let C be the this value. + 4. If IsConstructor(C) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var m = { m() {} }.m; + +assert.throws(TypeError, function() { + SendableTypedArray.of.call(m, []); +}); diff --git a/test/sendable/builtins/TypedArray/out-of-bounds-behaves-like-detached.js b/test/sendable/builtins/TypedArray/out-of-bounds-behaves-like-detached.js new file mode 100644 index 00000000000..9997bf55059 --- /dev/null +++ b/test/sendable/builtins/TypedArray/out-of-bounds-behaves-like-detached.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-isvalidintegerindex +description: > + SendableTypedArrays backed by resizable buffers that are out-of-bounds behave + as if they were detached +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +const rab = CreateResizableArrayBuffer(16, 40); +const i8a = new Int8Array(rab, 0, 4); +i8a.__proto__ = { 2: 'wrong value' }; +i8a[2] = 10; +assert.sameValue(i8a[2], 10); +assert(2 in i8a); +rab.resize(0); +assert.sameValue(i8a[2], undefined); +assert(!(2 in i8a)); diff --git a/test/sendable/builtins/TypedArray/out-of-bounds-get-and-set.js b/test/sendable/builtins/TypedArray/out-of-bounds-get-and-set.js new file mode 100644 index 00000000000..88ccef49bfa --- /dev/null +++ b/test/sendable/builtins/TypedArray/out-of-bounds-get-and-set.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-isvalidintegerindex +description: > + Getting and setting in-bounds and out-of-bounds indices on SendableTypedArrays backed + by resizable buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 40 * ctor.BYTES_PER_ELEMENT); + const array = new ctor(rab, 0, 4); + // Initial values + for (let i = 0; i < 4; ++i) { + assert.sameValue(Convert(array[i]), 0); + } + // Within-bounds write + for (let i = 0; i < 4; ++i) { + array[i] = MayNeedBigInt(array, i); + } + // Within-bounds read + for (let i = 0; i < 4; ++i) { + assert.sameValue(Convert(array[i]), i, `${ctor} array fails within-bounds read`); + } + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + // OOB read. If the RAB isn't large enough to fit the entire SendableTypedArray, + // the length of the SendableTypedArray is treated as 0. + for (let i = 0; i < 4; ++i) { + assert.sameValue(array[i], undefined); + } + // OOB write (has no effect) + for (let i = 0; i < 4; ++i) { + array[i] = MayNeedBigInt(array, 10); + } + rab.resize(4 * ctor.BYTES_PER_ELEMENT); + // Within-bounds read + for (let i = 0; i < 2; ++i) { + assert.sameValue(array[i], MayNeedBigInt(array, i)); + } + // The shrunk-and-regrown part got zeroed. + for (let i = 2; i < 4; ++i) { + assert.sameValue(array[i], MayNeedBigInt(array, 0)); + } + rab.resize(40 * ctor.BYTES_PER_ELEMENT); + // Within-bounds read + for (let i = 0; i < 2; ++i) { + assert.sameValue(array[i], MayNeedBigInt(array, i)); + } + for (let i = 2; i < 4; ++i) { + assert.sameValue(array[i], MayNeedBigInt(array, 0)); + } +} diff --git a/test/sendable/builtins/TypedArray/out-of-bounds-has.js b/test/sendable/builtins/TypedArray/out-of-bounds-has.js new file mode 100644 index 00000000000..f72d12ddbed --- /dev/null +++ b/test/sendable/builtins/TypedArray/out-of-bounds-has.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-isvalidintegerindex +description: > + In-bound indices are testable with `in` on SendableTypedArrays backed by resizable buffers. +info: | + IsValidIntegerIndex ( O, index ) + ... + 6. Let length be IntegerIndexedObjectLength(O, getBufferByteLength). + 7. If length is out-of-bounds or ℝ(index) < 0 or ℝ(index) ≥ length, return false. + ... +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 40 * ctor.BYTES_PER_ELEMENT); + const array = new ctor(rab, 0, 4); + // Within-bounds read + for (let i = 0; i < 4; ++i) { + assert(i in array); + } + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + // OOB read. If the RAB isn't large enough to fit the entire SendableTypedArray, + // the length of the SendableTypedArray is treated as 0. + for (let i = 0; i < 4; ++i) { + assert(!(i in array)); + } + rab.resize(4 * ctor.BYTES_PER_ELEMENT); + // Within-bounds read + for (let i = 0; i < 4; ++i) { + assert(i in array); + } + rab.resize(40 * ctor.BYTES_PER_ELEMENT); + // Within-bounds read + for (let i = 0; i < 4; ++i) { + assert(i in array); + } +} diff --git a/test/sendable/builtins/TypedArray/prototype.js b/test/sendable/builtins/TypedArray/prototype.js new file mode 100644 index 00000000000..0922616d5d1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray% +description: > + "prototype" property of SendableTypedArray +info: | + 22.2.2.3 %SendableTypedArray%.prototype + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: false }. +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray, 'prototype', { + writable: false, + enumerable: false, + configurable: false, +}); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.iterator.js b/test/sendable/builtins/TypedArray/prototype/Symbol.iterator.js new file mode 100644 index 00000000000..c26005ab17f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.iterator.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype-@@iterator +description: > + Initial state of the Symbol.iterator property +info: | + The initial value of the @@iterator property is the same function object + as the initial value of the %SendableTypedArray%.prototype.values property. + + Per ES6 section 17, the method should exist on the %SendableTypedArray% prototype, and it + should be writable and configurable, but not enumerable. +includes: [propertyHelper.js, testTypedArray.js] +features: [Symbol.iterator] +---*/ + +assert.sameValue(SendableTypedArray.prototype[Symbol.iterator], SendableTypedArray.prototype.values); + +verifyProperty(SendableTypedArray.prototype, Symbol.iterator, { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js new file mode 100644 index 00000000000..3347e2463b3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype[Symbol.iterator] 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, testTypedArray.js] +features: [Reflect.construct, Symbol, Symbol.iterator, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype[Symbol.iterator]), + false, + 'isConstructor(SendableTypedArray.prototype[Symbol.iterator]) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8[Symbol.iterator](); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js new file mode 100644 index 00000000000..098b67e93b6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: The getter method does not throw with a detached buffer +info: | + 22.2.3.32 get %SendableTypedArray%.prototype [ @@toStringTag ] + + ... + 4. Let name be the value of O's [[TypedArrayName]] internal slot. + 5. Assert: name is a String value. + 6. Return name. +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, Symbol.toStringTag, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.sameValue(sample[Symbol.toStringTag], TA.name); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js new file mode 100644 index 00000000000..65f215dff30 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: > + Return undefined if this value does not have a [[TypedArrayName]] internal slot +info: | + 22.2.3.31 get %SendableTypedArray%.prototype [ @@toStringTag ] + + 1. Let O be the this value. + ... + 3. If O does not have a [[TypedArrayName]] internal slot, return undefined. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.toStringTag, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(SendableTypedArrayPrototype[Symbol.toStringTag], undefined); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js new file mode 100644 index 00000000000..25501b1c92a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: If this value is not Object, return undefined. +info: | + 22.2.3.31 get %SendableTypedArray%.prototype [ @@toStringTag ] + + 1. Let O be the this value. + 2. If Type(O) is not Object, return undefined. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.toStringTag, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, Symbol.toStringTag +).get; + +assert.sameValue(getter(), undefined); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js new file mode 100644 index 00000000000..c378c040e5f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: > + get %SendableTypedArray%.prototype [ @@toStringTag ].length is 0. +info: | + get %SendableTypedArray%.prototype [ @@toStringTag ] + + 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, testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.toStringTag] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray.prototype, Symbol.toStringTag); + +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js new file mode 100644 index 00000000000..6f0aa4dc68a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: > + get %SendableTypedArray%.prototype [ @@toStringTag ].name is "get [Symbol.toStringTag]". +info: | + get %SendableTypedArray%.prototype [ @@toStringTag ] + + 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, testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.toStringTag] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray.prototype, Symbol.toStringTag); + +verifyProperty(desc.get, "name", { + value: "get [Symbol.toStringTag]", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js new file mode 100644 index 00000000000..1a51b32cf08 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: > + "@@toStringTag" property of SendableTypedArrayPrototype +info: | + 22.2.3.31 get %SendableTypedArray%.prototype [ @@toStringTag ] + + %SendableTypedArray%.prototype[@@toStringTag] is an accessor property whose set + accessor function is undefined. + ... + + This property has the attributes { [[Enumerable]]: false, [[Configurable]]: + true }. +includes: [propertyHelper.js, testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.toStringTag] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var desc = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, Symbol.toStringTag +); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, 'function'); +verifyNotEnumerable(SendableTypedArrayPrototype, Symbol.toStringTag); +verifyConfigurable(SendableTypedArrayPrototype, Symbol.toStringTag); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js new file mode 100644 index 00000000000..15c66a44ded --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: > + Return value from the [[TypedArrayName]] internal slot +info: | + 22.2.3.32 get %SendableTypedArray%.prototype [ @@toStringTag ] + + ... + 4. Let name be the value of O's [[TypedArrayName]] internal slot. + 5. Assert: name is a String value. + 6. Return name. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.toStringTag, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var ta = new TA(); + assert.sameValue(ta[Symbol.toStringTag], TA.name, "property value"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js new file mode 100644 index 00000000000..431af2abf1e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: > + Return undefined when `this` does not have a [[TypedArrayName]] internal slot +info: | + 22.2.3.32 get %SendableTypedArray%.prototype [ @@toStringTag ] + + 1. Let O be the this value. + ... + 3. If O does not have a [[TypedArrayName]] internal slot, return undefined. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.toStringTag, DataView, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, Symbol.toStringTag +).get; + +assert.sameValue(getter.call({}), undefined); +assert.sameValue(getter.call([]), undefined); +assert.sameValue(getter.call(new ArrayBuffer(8)), undefined); + +var ab = new ArrayBuffer(8); +var dv = new DataView(ab, 0, 1); +assert.sameValue(getter.call(dv), undefined); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js new file mode 100644 index 00000000000..d86993396e4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: Return undefined when `this` is not Object +info: | + 22.2.3.32 get %SendableTypedArray%.prototype [ @@toStringTag ] + + 1. Let O be the this value. + 2. If Type(O) is not Object, return undefined. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, Symbol.toStringTag, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, Symbol.toStringTag +).get; + +assert.sameValue(getter.call(undefined), undefined, "this is undefined"); +assert.sameValue(getter.call(42), undefined, "this is 42"); +assert.sameValue(getter.call("foo"), undefined, "this is a string"); +assert.sameValue(getter.call(true), undefined, "this is true"); +assert.sameValue(getter.call(false), undefined, "this is false"); +assert.sameValue(getter.call(Symbol("s")), undefined, "this is a Symbol"); +assert.sameValue(getter.call(null), undefined, "this is null"); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js new file mode 100644 index 00000000000..37cc807c3b0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: The getter method does not throw with a detached buffer +info: | + 22.2.3.32 get %SendableTypedArray%.prototype [ @@toStringTag ] + + ... + 4. Let name be the value of O's [[TypedArrayName]] internal slot. + 5. Assert: name is a String value. + 6. Return name. +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [Symbol.toStringTag, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.sameValue(sample[Symbol.toStringTag], TA.name); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js new file mode 100644 index 00000000000..b456bc46a59 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: > + Return undefined if this value does not have a [[TypedArrayName]] internal slot +info: | + 22.2.3.31 get %SendableTypedArray%.prototype [ @@toStringTag ] + + 1. Let O be the this value. + ... + 3. If O does not have a [[TypedArrayName]] internal slot, return undefined. + ... +includes: [testTypedArray.js] +features: [Symbol.toStringTag, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(SendableTypedArrayPrototype[Symbol.toStringTag], undefined); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js new file mode 100644 index 00000000000..881f666ccf2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: If this value is not Object, return undefined. +info: | + 22.2.3.31 get %SendableTypedArray%.prototype [ @@toStringTag ] + + 1. Let O be the this value. + 2. If Type(O) is not Object, return undefined. + ... +includes: [testTypedArray.js] +features: [Symbol.toStringTag, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, Symbol.toStringTag +).get; + +assert.sameValue(getter(), undefined); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/length.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/length.js new file mode 100644 index 00000000000..c15512cc3c8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/length.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: > + get %SendableTypedArray%.prototype [ @@toStringTag ].length is 0. +info: | + get %SendableTypedArray%.prototype [ @@toStringTag ] + + 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, testTypedArray.js] +features: [Symbol.toStringTag] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray.prototype, Symbol.toStringTag); + +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/name.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/name.js new file mode 100644 index 00000000000..349b264b81e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/name.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: > + get %SendableTypedArray%.prototype [ @@toStringTag ].name is "get [Symbol.toStringTag]". +info: | + get %SendableTypedArray%.prototype [ @@toStringTag ] + + 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, testTypedArray.js] +features: [Symbol.toStringTag] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray.prototype, Symbol.toStringTag); + +verifyProperty(desc.get, "name", { + value: "get [Symbol.toStringTag]", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js new file mode 100644 index 00000000000..18ceed98895 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: > + "@@toStringTag" property of SendableTypedArrayPrototype +info: | + 22.2.3.31 get %SendableTypedArray%.prototype [ @@toStringTag ] + + %SendableTypedArray%.prototype[@@toStringTag] is an accessor property whose set + accessor function is undefined. + ... + + This property has the attributes { [[Enumerable]]: false, [[Configurable]]: + true }. +includes: [propertyHelper.js, testTypedArray.js] +features: [Symbol.toStringTag] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var desc = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, Symbol.toStringTag +); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, 'function'); +verifyNotEnumerable(SendableTypedArrayPrototype, Symbol.toStringTag); +verifyConfigurable(SendableTypedArrayPrototype, Symbol.toStringTag); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js new file mode 100644 index 00000000000..cf728a44a6d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: > + Return value from the [[TypedArrayName]] internal slot +info: | + 22.2.3.32 get %SendableTypedArray%.prototype [ @@toStringTag ] + + ... + 4. Let name be the value of O's [[TypedArrayName]] internal slot. + 5. Assert: name is a String value. + 6. Return name. +includes: [testTypedArray.js] +features: [Symbol.toStringTag, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var ta = new TA(); + assert.sameValue(ta[Symbol.toStringTag], TA.name, "property value"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js new file mode 100644 index 00000000000..ea29a5ba5b0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: > + Return undefined when `this` does not have a [[TypedArrayName]] internal slot +info: | + 22.2.3.32 get %SendableTypedArray%.prototype [ @@toStringTag ] + + 1. Let O be the this value. + ... + 3. If O does not have a [[TypedArrayName]] internal slot, return undefined. + ... +includes: [testTypedArray.js] +features: [Symbol.toStringTag, DataView, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, Symbol.toStringTag +).get; + +assert.sameValue(getter.call({}), undefined); +assert.sameValue(getter.call([]), undefined); +assert.sameValue(getter.call(new ArrayBuffer(8)), undefined); + +var ab = new ArrayBuffer(8); +var dv = new DataView(ab, 0, 1); +assert.sameValue(getter.call(dv), undefined); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js new file mode 100644 index 00000000000..4aea08e5158 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype-@@tostringtag +description: Return undefined when `this` is not Object +info: | + 22.2.3.32 get %SendableTypedArray%.prototype [ @@toStringTag ] + + 1. Let O be the this value. + 2. If Type(O) is not Object, return undefined. + ... +includes: [testTypedArray.js] +features: [Symbol, Symbol.toStringTag, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, Symbol.toStringTag +).get; + +assert.sameValue(getter.call(undefined), undefined, "this is undefined"); +assert.sameValue(getter.call(42), undefined, "this is 42"); +assert.sameValue(getter.call("foo"), undefined, "this is a string"); +assert.sameValue(getter.call(true), undefined, "this is true"); +assert.sameValue(getter.call(false), undefined, "this is false"); +assert.sameValue(getter.call(Symbol("s")), undefined, "this is a Symbol"); +assert.sameValue(getter.call(null), undefined, "this is null"); diff --git a/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..26694d155da --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, SendableTypedArray.prototype.at, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.at, + 'function', + 'implements SendableTypedArray.prototype.at' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.at(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.at(0); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the at operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.at(0); + throw new Test262Error('at completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/at/coerced-index-resize.js b/test/sendable/builtins/TypedArray/prototype/at/coerced-index-resize.js new file mode 100644 index 00000000000..81da0413f25 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/coerced-index-resize.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: > + SendableTypedArray.p.at behaves correctly on SendableTypedArrays backed by resizable buffers + when the SendableTypedArray is resized during parameter conversion +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function SendableTypedArrayAtHelper(ta, index) { + const result = ta.at(index); + return Convert(result); +} + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2); + return 0; + } + }; + assert.sameValue(SendableTypedArrayAtHelper(fixedLength, evil), undefined); +} + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + let evil = { + valueOf: () => { + rab.resize(2); + return -1; + } + }; + // The SendableTypedArray is *not* out of bounds since it's length-tracking. + assert.sameValue(SendableTypedArrayAtHelper(lengthTracking, evil), undefined); +} diff --git a/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js b/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js new file mode 100644 index 00000000000..8ba990ca4bc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: > + Property type and descriptor. +info: | + %SendableTypedArray%.prototype.at( index ) + + Let relativeIndex be ? ToInteger(index). + +includes: [testTypedArray.js] +features: [TypedArray, TypedArray.prototype.at] +---*/ +assert.sameValue( + typeof SendableTypedArray.prototype.at, + 'function', + 'The value of `typeof SendableTypedArray.prototype.at` is "function"' +); + +testWithSendableTypedArrayConstructors(TA => { + assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"'); + let valueOfCallCount = 0; + let index = { + valueOf() { + valueOfCallCount++; + return 1; + } + }; + + let a = new TA([0,1,2,3]); + + assert.sameValue(a.at(index), 1, 'a.at({valueOf() {valueOfCallCount++; return 1;}}) must return 1'); + assert.sameValue(valueOfCallCount, 1, 'The value of `valueOfCallCount` is 1'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js new file mode 100644 index 00000000000..4e87bc573b7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: > + Property type and descriptor. +info: | + %SendableTypedArray%.prototype.at( index ) + + Let relativeIndex be ? ToInteger(index). + +includes: [testTypedArray.js] +features: [TypedArray, TypedArray.prototype.at] +---*/ +assert.sameValue( + typeof SendableTypedArray.prototype.at, + 'function', + 'The value of `typeof SendableTypedArray.prototype.at` is "function"' +); + +testWithSendableTypedArrayConstructors(TA => { + assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"'); + let a = new TA([0,1,2,3]); + + assert.throws(TypeError, () => { + a.at(Symbol()); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js new file mode 100644 index 00000000000..fc5ef9c5d46 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: > + Property type and descriptor. +info: | + %SendableTypedArray%.prototype.at( index ) + + Let relativeIndex be ? ToInteger(index). + +includes: [testTypedArray.js] +features: [TypedArray, TypedArray.prototype.at] +---*/ +assert.sameValue( + typeof SendableTypedArray.prototype.at, + 'function', + 'The value of `typeof SendableTypedArray.prototype.at` is "function"' +); + +testWithSendableTypedArrayConstructors(TA => { + assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"'); + + let a = new TA([0,1,2,3]); + + assert.sameValue(a.at(false), 0, 'a.at(false) must return 0'); + assert.sameValue(a.at(null), 0, 'a.at(null) must return 0'); + assert.sameValue(a.at(undefined), 0, 'a.at(undefined) must return 0'); + assert.sameValue(a.at(""), 0, 'a.at("") must return 0'); + assert.sameValue(a.at(function() {}), 0, 'a.at(function() {}) must return 0'); + assert.sameValue(a.at([]), 0, 'a.at([]) must return 0'); + + assert.sameValue(a.at(true), 1, 'a.at(true) must return 1'); + assert.sameValue(a.at("1"), 1, 'a.at("1") must return 1'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/at/length.js b/test/sendable/builtins/TypedArray/prototype/at/length.js new file mode 100644 index 00000000000..eceb23ad027 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/length.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: > + SendableTypedArray.prototype.at.length value and descriptor. +info: | + %SendableTypedArray%.prototype.at( index ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray.prototype.at] +---*/ +assert.sameValue( + typeof SendableTypedArray.prototype.at, + 'function', + 'The value of `typeof SendableTypedArray.prototype.at` is "function"' +); + +verifyProperty(SendableTypedArray.prototype.at, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/at/name.js b/test/sendable/builtins/TypedArray/prototype/at/name.js new file mode 100644 index 00000000000..e9b1e0322b7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/name.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: > + %SendableTypedArray%.prototype.at.name value and descriptor. +info: | + %SendableTypedArray%.prototype.at( index ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray.prototype.at] +---*/ +assert.sameValue( + typeof SendableTypedArray.prototype.at, + 'function', + 'The value of `typeof SendableTypedArray.prototype.at` is "function"' +); + +assert.sameValue( + SendableTypedArray.prototype.at.name, 'at', + 'The value of SendableTypedArray.prototype.at.name is "at"' +); + +verifyProperty(SendableTypedArray.prototype.at, 'name', { + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/at/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/at/prop-desc.js new file mode 100644 index 00000000000..0af3b9c230c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/prop-desc.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: > + Property type and descriptor. +info: | + %SendableTypedArray%.prototype.at( index ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray.prototype.at] +---*/ +assert.sameValue( + typeof SendableTypedArray.prototype.at, + 'function', + 'The value of `typeof SendableTypedArray.prototype.at` is "function"' +); + +verifyProperty(SendableTypedArray.prototype, 'at', { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/at/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/at/resizable-buffer.js new file mode 100644 index 00000000000..7ef7e3f8e5e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/resizable-buffer.js @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: > + SendableTypedArray.p.at behaves correctly on SendableTypedArrays backed by resizable buffers +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function SendableTypedArrayAtHelper(ta, index) { + const result = ta.at(index); + return Convert(result); +} + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + let ta_write = new ctor(rab); + for (let i = 0; i < 4; ++i) { + ta_write[i] = MayNeedBigInt(ta_write, i); + } + assert.sameValue(SendableTypedArrayAtHelper(fixedLength, -1), 3); + assert.sameValue(SendableTypedArrayAtHelper(lengthTracking, -1), 3); + assert.sameValue(SendableTypedArrayAtHelper(fixedLengthWithOffset, -1), 3); + assert.sameValue(SendableTypedArrayAtHelper(lengthTrackingWithOffset, -1), 3); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + SendableTypedArrayAtHelper(fixedLength, -1); + }); + assert.throws(TypeError, () => { + SendableTypedArrayAtHelper(fixedLengthWithOffset, -1); + }); + assert.sameValue(SendableTypedArrayAtHelper(lengthTracking, -1), 2); + assert.sameValue(SendableTypedArrayAtHelper(lengthTrackingWithOffset, -1), 2); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + SendableTypedArrayAtHelper(fixedLength, -1); + }); + assert.throws(TypeError, () => { + SendableTypedArrayAtHelper(fixedLengthWithOffset, -1); + }); + assert.throws(TypeError, () => { + SendableTypedArrayAtHelper(lengthTrackingWithOffset, -1); + }); + assert.sameValue(SendableTypedArrayAtHelper(lengthTracking, -1), 0); + + // Grow so that all TAs are back in-bounds. New memory is zeroed. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + assert.sameValue(SendableTypedArrayAtHelper(fixedLength, -1), 0); + assert.sameValue(SendableTypedArrayAtHelper(lengthTracking, -1), 0); + assert.sameValue(SendableTypedArrayAtHelper(fixedLengthWithOffset, -1), 0); + assert.sameValue(SendableTypedArrayAtHelper(lengthTrackingWithOffset, -1), 0); +} diff --git a/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..6e83421c846 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, SendableTypedArray.prototype.at, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.at, + 'function', + 'implements SendableTypedArray.prototype.at' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.at(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.at(0); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the at operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.at(0); + throw new Test262Error('at completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js new file mode 100644 index 00000000000..5db72011090 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: > + Return abrupt from ToObject(this value). +info: | + %SendableTypedArray%.prototype.at( index ) + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + +includes: [testTypedArray.js] +features: [TypedArray,TypedArray.prototype.at] +---*/ +assert.sameValue( + typeof SendableTypedArray.prototype.at, + 'function', + 'The value of `typeof SendableTypedArray.prototype.at` is "function"' +); + +assert.throws(TypeError, () => { + SendableTypedArray.prototype.at.call(undefined); +}); + +assert.throws(TypeError, () => { + SendableTypedArray.prototype.at.call(null); +}); + +testWithSendableTypedArrayConstructors(TA => { + assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"'); + + assert.throws(TypeError, () => { + TA.prototype.at.call(undefined); + }); + + assert.throws(TypeError, () => { + TA.prototype.at.call(null); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js b/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js new file mode 100644 index 00000000000..245eb499752 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: > + Returns the item value at the specified relative index +info: | + %SendableTypedArray%.prototype.at( index ) + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + Let relativeIndex be ? ToInteger(index). + If relativeIndex ≥ 0, then + Let k be relativeIndex. + Else, + Let k be len + relativeIndex. + If k < 0 or k ≥ len, then return undefined. + Return ? Get(O, ! ToString(k)). + +includes: [testTypedArray.js] +features: [TypedArray,TypedArray.prototype.at] +---*/ +assert.sameValue( + typeof SendableTypedArray.prototype.at, + 'function', + 'The value of `typeof SendableTypedArray.prototype.at` is "function"' +); + +testWithSendableTypedArrayConstructors(TA => { + let a = new TA([1, 2, 3, 4, 5]); + assert.sameValue(a.at(0), 1, 'a.at(0) must return 1'); + assert.sameValue(a.at(-1), 5, 'a.at(-1) must return 5'); + assert.sameValue(a.at(-2), 4, 'a.at(-2) must return 4'); + assert.sameValue(a.at(-3), 3, 'a.at(-3) must return 3'); + assert.sameValue(a.at(-4), 2, 'a.at(-4) must return 2'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-item.js b/test/sendable/builtins/TypedArray/prototype/at/returns-item.js new file mode 100644 index 00000000000..afca90519f0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-item.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: > + Returns the item value at the specified index +info: | + %SendableTypedArray%.prototype.at( index ) + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + Let relativeIndex be ? ToInteger(index). + If relativeIndex ≥ 0, then + Let k be relativeIndex. + Else, + Let k be len + relativeIndex. + If k < 0 or k ≥ len, then return undefined. + Return ? Get(O, ! ToString(k)). + +includes: [testTypedArray.js] +features: [TypedArray,TypedArray.prototype.at] +---*/ +assert.sameValue( + typeof SendableTypedArray.prototype.at, + 'function', + 'The value of `typeof SendableTypedArray.prototype.at` is "function"' +); + +testWithSendableTypedArrayConstructors(TA => { + assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"'); + let a = new TA([1, 2, 3, 4]); + + assert.sameValue(a.at(0), 1, 'a.at(0) must return 1'); + assert.sameValue(a.at(1), 2, 'a.at(1) must return 2'); + assert.sameValue(a.at(2), 3, 'a.at(2) must return 3'); + assert.sameValue(a.at(3), 4, 'a.at(3) must return 4'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js new file mode 100644 index 00000000000..6e15814147b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: > + Returns the item value at the specified index, holes are filled in sparse arrays. +info: | + %SendableTypedArray%.prototype.at( index ) + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + Let relativeIndex be ? ToInteger(index). + If relativeIndex ≥ 0, then + Let k be relativeIndex. + Else, + Let k be len + relativeIndex. + If k < 0 or k ≥ len, then return undefined. + Return ? Get(O, ! ToString(k)). + +includes: [testTypedArray.js] +features: [TypedArray, TypedArray.prototype.at] +---*/ +assert.sameValue( + typeof SendableTypedArray.prototype.at, + 'function', + 'The value of `typeof SendableTypedArray.prototype.at` is "function"' +); + +testWithSendableTypedArrayConstructors(TA => { + let a = new TA([0, 1, , 3, 4, , 6]); + let filler = 0; + if (TA.name.startsWith('Float')) { + filler = NaN; + } + assert.sameValue(a.at(0), 0, 'a.at(0) must return 0'); + assert.sameValue(a.at(1), 1, 'a.at(1) must return 1'); + assert.sameValue(a.at(2), filler, 'a.at(2) must return the value of filler'); + assert.sameValue(a.at(3), 3, 'a.at(3) must return 3'); + assert.sameValue(a.at(4), 4, 'a.at(4) must return 4'); + assert.sameValue(a.at(5), filler, 'a.at(5) must return the value of filler'); + assert.sameValue(a.at(6), 6, 'a.at(6) must return 6'); + assert.sameValue(a.at(-0), 0, 'a.at(-0) must return 0'); + assert.sameValue(a.at(-1), 6, 'a.at(-1) must return 6'); + assert.sameValue(a.at(-2), filler, 'a.at(-2) must return the value of filler'); + assert.sameValue(a.at(-3), 4, 'a.at(-3) must return 4'); + assert.sameValue(a.at(-4), 3, 'a.at(-4) must return 3'); + assert.sameValue(a.at(-5), filler, 'a.at(-5) must return the value of filler'); + assert.sameValue(a.at(-6), 1, 'a.at(-6) must return 1'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js new file mode 100644 index 00000000000..005c7f02889 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.at +description: > + Returns undefined if the specified index less than or greater than the available index range. +info: | + %SendableTypedArray%.prototype.at( index ) + + If k < 0 or k ≥ len, then return undefined. + +includes: [testTypedArray.js] +features: [TypedArray,TypedArray.prototype.at] +---*/ +assert.sameValue( + typeof SendableTypedArray.prototype.at, + 'function', + 'The value of `typeof SendableTypedArray.prototype.at` is "function"' +); + +testWithSendableTypedArrayConstructors(TA => { + assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"'); + let a = new TA([]); + + assert.sameValue(a.at(-2), undefined, 'a.at(-2) must return undefined'); // wrap around the end + assert.sameValue(a.at(0), undefined, 'a.at(0) must return undefined'); + assert.sameValue(a.at(1), undefined, 'a.at(1) must return undefined'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/detached-buffer.js new file mode 100644 index 00000000000..bc438dfccf4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/detached-buffer.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.buffer +description: The getter method does not throw with a detached buffer +info: | + 22.2.3.1 get %SendableTypedArray%.prototype.buffer + + ... + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 5. Return buffer. +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(8); + var sample = new TA(buffer, 0, 1); + $DETACHBUFFER(sample.buffer); + assert.sameValue(sample.buffer, buffer); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/return-buffer.js b/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/return-buffer.js new file mode 100644 index 00000000000..7cb8288dd8d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/return-buffer.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.buffer +description: > + Return buffer from [[ViewedArrayBuffer]] internal slot +info: | + 22.2.3.1 get %SendableTypedArray%.prototype.buffer + + ... + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 5. Return buffer. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT); + var ta = new TA(buffer); + + assert.sameValue(ta.buffer, buffer); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js new file mode 100644 index 00000000000..d627f7f7eba --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.buffer +description: The getter method does not throw with a detached buffer +info: | + 22.2.3.1 get %SendableTypedArray%.prototype.buffer + + ... + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 5. Return buffer. +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(8); + var sample = new TA(buffer, 0, 1); + $DETACHBUFFER(sample.buffer); + assert.sameValue(sample.buffer, buffer); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js new file mode 100644 index 00000000000..314b0e1238e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.buffer +description: > + Requires this value to have a [[ViewedArrayBuffer]] internal slot +info: | + 22.2.3.1 get %SendableTypedArray%.prototype.buffer + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.buffer; +}); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js new file mode 100644 index 00000000000..7ecc1c79a5a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.buffer +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.1 get %SendableTypedArray%.prototype.buffer + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, 'buffer' +).get; + +assert.throws(TypeError, function() { + getter(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/length.js b/test/sendable/builtins/TypedArray/prototype/buffer/length.js new file mode 100644 index 00000000000..ad61ba9753e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/buffer/length.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.buffer +description: > + get %SendableTypedArray%.prototype.buffer.length is 0. +info: | + get %SendableTypedArray%.prototype.buffer + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray.prototype, "buffer"); + +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/name.js b/test/sendable/builtins/TypedArray/prototype/buffer/name.js new file mode 100644 index 00000000000..a0ed7446aae --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/buffer/name.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.buffer +description: > + get %SendableTypedArray%.prototype.buffer.name is "get buffer". +info: | + get %SendableTypedArray%.prototype.buffer + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray.prototype, "buffer"); + +verifyProperty(desc.get, "name", { + value: "get buffer", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/buffer/prop-desc.js new file mode 100644 index 00000000000..ff6ebf8dbee --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/buffer/prop-desc.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.buffer +description: > + "buffer" property of SendableTypedArrayPrototype +info: | + %SendableTypedArray%.prototype.buffer is an accessor property whose set accessor + function is undefined. + + Section 17: Every accessor property described in clauses 18 through 26 and in + Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var desc = Object.getOwnPropertyDescriptor(SendableTypedArrayPrototype, "buffer"); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, "function"); + +verifyNotEnumerable(SendableTypedArrayPrototype, "buffer"); +verifyConfigurable(SendableTypedArrayPrototype, "buffer"); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js b/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js new file mode 100644 index 00000000000..89c165b5145 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.buffer +description: > + Return buffer from [[ViewedArrayBuffer]] internal slot +info: | + 22.2.3.1 get %SendableTypedArray%.prototype.buffer + + ... + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 5. Return buffer. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT); + var ta = new TA(buffer); + + assert.sameValue(ta.buffer, buffer); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js new file mode 100644 index 00000000000..7074f46fe09 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.buffer +description: > + Throws a TypeError exception when `this` does not have a [[TypedArrayName]] + internal slot +info: | + 22.2.3.1 get %SendableTypedArray%.prototype.buffer + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [DataView, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, "buffer" +).get; + +assert.throws(TypeError, function() { + getter.call({}); +}); + +assert.throws(TypeError, function() { + getter.call([]); +}); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + getter.call(ab); +}); + +var dv = new DataView(new ArrayBuffer(8), 0); +assert.throws(TypeError, function() { + getter.call(dv); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/this-inherits-typedarray.js b/test/sendable/builtins/TypedArray/prototype/buffer/this-inherits-typedarray.js new file mode 100644 index 00000000000..b759b9d5f49 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/buffer/this-inherits-typedarray.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.buffer +description: > + Throws a TypeError exception when `this` does not have a [[TypedArrayName]] + internal slot, even if its prototype does +info: | + 22.2.3.1 get %SendableTypedArray%.prototype.buffer + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, "buffer" +).get; + +testWithSendableTypedArrayConstructors(TA => { + var typedArray = new TA(5); + var o = {}; + Object.setPrototypeOf(o, typedArray); + assert.throws(TypeError, function() { + getter.call(o); + }, + "Internal slot should not be inherited"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/buffer/this-is-not-object.js new file mode 100644 index 00000000000..f2f2e555c1b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/buffer/this-is-not-object.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.buffer +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.1 get %SendableTypedArray%.prototype.buffer + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, "buffer" +).get; + +assert.throws(TypeError, function() { + getter.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + getter.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + getter.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + getter.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + getter.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + getter.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + getter.call(s); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js new file mode 100644 index 00000000000..e150204f2ab --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: Returns 0 if the instance has a detached buffer +info: | + 22.2.3.2 get %SendableTypedArray%.prototype.byteLength + + ... + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 5. If IsDetachedBuffer(buffer) is true, return 0. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.sameValue(sample.byteLength, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js new file mode 100644 index 00000000000..bbbdb73edfa --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the dynamically-sized SendableTypedArray instance +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE); + var expected = BPE * 3; + + assert.sameValue(array.byteLength, expected); + + try { + ab.resize(BPE * 5); + expected = BPE * 4; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following grow"); + + try { + ab.resize(BPE * 3); + expected = BPE * 2; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following shrink (within bounds)"); + + try { + ab.resize(BPE * 3 - 1); + expected = BPE; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following shrink (partial element)"); + + try { + ab.resize(BPE); + expected = 0; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following shrink (on boundary)"); + + try { + ab.resize(0); + expected = 0; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following shrink (out of bounds)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js new file mode 100644 index 00000000000..77b055c3fb1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the fixed-sized SendableTypedArray instance +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + assert.sameValue(array.byteLength, BPE * 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + assert.sameValue(array.byteLength, BPE * 2, "following grow"); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + assert.sameValue(array.byteLength, BPE * 2, "following shrink (within bounds)"); + + var expected; + try { + ab.resize(BPE * 3 - 1); + expected = 0; + } catch (_) { + expected = BPE * 2; + } + + assert.sameValue(array.byteLength, expected, "following shrink (out of bounds)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js new file mode 100644 index 00000000000..922317d8492 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: > + Return value from [[ByteLength]] internal slot +info: | + 22.2.3.2 get %SendableTypedArray%.prototype.byteLength + + ... + 6. Let size be the value of O's [[ByteLength]] internal slot. + 7. Return size. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var bytesPerElement = TA.BYTES_PER_ELEMENT; + var ta1 = new TA(); + assert.sameValue(ta1.byteLength, 0); + + var ta2 = new TA(42); + assert.sameValue(ta2.byteLength, 42 * bytesPerElement); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js new file mode 100644 index 00000000000..a3ee70c70d5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: Returns 0 if the instance has a detached buffer +info: | + 22.2.3.2 get %SendableTypedArray%.prototype.byteLength + + ... + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 5. If IsDetachedBuffer(buffer) is true, return 0. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.sameValue(sample.byteLength, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js new file mode 100644 index 00000000000..dff0d9cdffc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: > + Requires this value to have a [[ViewedArrayBuffer]] internal slot +info: | + 22.2.3.2 get %SendableTypedArray%.prototype.byteLength + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.byteLength; +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js new file mode 100644 index 00000000000..62885ee8c13 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.2 get %SendableTypedArray%.prototype.byteLength + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, 'byteLength' +).get; + +assert.throws(TypeError, function() { + getter(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/length.js b/test/sendable/builtins/TypedArray/prototype/byteLength/length.js new file mode 100644 index 00000000000..938b4ed59ff --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/length.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: > + get %SendableTypedArray%.prototype.byteLength.length is 0. +info: | + get %SendableTypedArray%.prototype.byteLength + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray.prototype, "byteLength"); + +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/name.js b/test/sendable/builtins/TypedArray/prototype/byteLength/name.js new file mode 100644 index 00000000000..b13912bc5ea --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/name.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: > + get %SendableTypedArray%.prototype.byteLength.name is "get byteLength". +info: | + get %SendableTypedArray%.prototype.byteLength + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray.prototype, "byteLength"); + +verifyProperty(desc.get, "name", { + value: "get byteLength", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/byteLength/prop-desc.js new file mode 100644 index 00000000000..8c38fd25222 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/prop-desc.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: > + "byteLength" property of SendableTypedArrayPrototype +info: | + %SendableTypedArray%.prototype.byteLength is an accessor property whose set accessor + function is undefined. + + Section 17: Every accessor property described in clauses 18 through 26 and in + Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var desc = Object.getOwnPropertyDescriptor(SendableTypedArrayPrototype, "byteLength"); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, "function"); + +verifyNotEnumerable(SendableTypedArrayPrototype, "byteLength"); +verifyConfigurable(SendableTypedArrayPrototype, "byteLength"); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js new file mode 100644 index 00000000000..61f7b893980 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the dynamically-sized SendableTypedArray instance +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE); + var expected = BPE * 3; + + assert.sameValue(array.byteLength, expected); + + try { + ab.resize(BPE * 5); + expected = BPE * 4; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following grow"); + + try { + ab.resize(BPE * 3); + expected = BPE * 2; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following shrink (within bounds)"); + + try { + ab.resize(BPE * 3 - 1); + expected = BPE; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following shrink (partial element)"); + + try { + ab.resize(BPE); + expected = 0; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following shrink (on boundary)"); + + try { + ab.resize(0); + expected = 0; + } catch (_) {} + + assert.sameValue(array.byteLength, expected, "following shrink (out of bounds)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js new file mode 100644 index 00000000000..69d8b8fd33a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the fixed-sized SendableTypedArray instance +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + assert.sameValue(array.byteLength, BPE * 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + assert.sameValue(array.byteLength, BPE * 2, "following grow"); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + assert.sameValue(array.byteLength, BPE * 2, "following shrink (within bounds)"); + + var expected; + try { + ab.resize(BPE * 3 - 1); + expected = 0; + } catch (_) { + expected = BPE * 2; + } + + assert.sameValue(array.byteLength, expected, "following shrink (out of bounds)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-buffer-assorted.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-buffer-assorted.js new file mode 100644 index 00000000000..80be3aedb16 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-buffer-assorted.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: > + SendableTypedArray.p.byteLength behaves correctly on assorted kinds of receivers + backed by resizable buffers +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +const rab = CreateResizableArrayBuffer(40, 80); +for (let ctor of ctors) { + const ta = new ctor(rab, 0, 3); + assert.compareArray(ta.buffer, rab); + assert.sameValue(ta.byteLength, 3 * ctor.BYTES_PER_ELEMENT); + const empty_ta = new ctor(rab, 0, 0); + assert.compareArray(empty_ta.buffer, rab); + assert.sameValue(empty_ta.byteLength, 0); + const ta_with_offset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 3); + assert.compareArray(ta_with_offset.buffer, rab); + assert.sameValue(ta_with_offset.byteLength, 3 * ctor.BYTES_PER_ELEMENT); + const empty_ta_with_offset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 0); + assert.compareArray(empty_ta_with_offset.buffer, rab); + assert.sameValue(empty_ta_with_offset.byteLength, 0); + const length_tracking_ta = new ctor(rab); + assert.compareArray(length_tracking_ta.buffer, rab); + assert.sameValue(length_tracking_ta.byteLength, 40); + const offset = 8; + const length_tracking_ta_with_offset = new ctor(rab, offset); + assert.compareArray(length_tracking_ta_with_offset.buffer, rab); + assert.sameValue(length_tracking_ta_with_offset.byteLength, 40 - offset); + const empty_length_tracking_ta_with_offset = new ctor(rab, 40); + assert.compareArray(empty_length_tracking_ta_with_offset.buffer, rab); + assert.sameValue(empty_length_tracking_ta_with_offset.byteLength, 0); +} diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-1.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-1.js new file mode 100644 index 00000000000..e53a44c8689 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-1.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteLength +description: > + SendableTypedArray.p.byteLength behaves correctly when the underlying resizable buffer + is resized such that the SendableTypedArray becomes out of bounds. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +const rab = CreateResizableArrayBuffer(16, 40); + +// Create TAs which cover the bytes 0-7. +let tas_and_lengths = []; +for (let ctor of ctors) { + const length = 8 / ctor.BYTES_PER_ELEMENT; + tas_and_lengths.push([ + new ctor(rab, 0, length), + length + ]); +} +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.byteLength, length * ta.BYTES_PER_ELEMENT); +} +rab.resize(2); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.byteLength, 0); +} +// Resize the rab so that it just barely covers the needed 8 bytes. +rab.resize(8); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.byteLength, length * ta.BYTES_PER_ELEMENT); +} +rab.resize(40); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.byteLength, length * ta.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-2.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-2.js new file mode 100644 index 00000000000..d1d64451f0e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-2.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteLength +description: > + SendableTypedArray.p.byteLength behaves as expected when the underlying resizable + buffer is resized such that the SendableTypedArray becomes out of bounds. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +const rab = CreateResizableArrayBuffer(20, 40); + +// Create TAs with offset, which cover the bytes 8-15. +let tas_and_lengths = []; +for (let ctor of ctors) { + const length = 8 / ctor.BYTES_PER_ELEMENT; + tas_and_lengths.push([ + new ctor(rab, 8, length), + length + ]); +} +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.byteLength, length * ta.BYTES_PER_ELEMENT); +} +rab.resize(10); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.byteLength, 0); +} +// Resize the rab so that it just barely covers the needed 8 bytes. +rab.resize(16); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.byteLength, length * ta.BYTES_PER_ELEMENT); +} +rab.resize(40); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.byteLength, length * ta.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/return-bytelength.js b/test/sendable/builtins/TypedArray/prototype/byteLength/return-bytelength.js new file mode 100644 index 00000000000..6eee0fdfdc5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/return-bytelength.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: > + Return value from [[ByteLength]] internal slot +info: | + 22.2.3.2 get %SendableTypedArray%.prototype.byteLength + + ... + 6. Let size be the value of O's [[ByteLength]] internal slot. + 7. Return size. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var bytesPerElement = TA.BYTES_PER_ELEMENT; + var ta1 = new TA(); + assert.sameValue(ta1.byteLength, 0); + + var ta2 = new TA(42); + assert.sameValue(ta2.byteLength, 42 * bytesPerElement); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js new file mode 100644 index 00000000000..378633a1100 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: > + Throws a TypeError exception when `this` does not have a [[TypedArrayName]] + internal slot +info: | + 22.2.3.2 get %SendableTypedArray%.prototype.byteLength + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [DataView, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, "byteLength" +).get; + +assert.throws(TypeError, function() { + getter.call({}); +}); + +assert.throws(TypeError, function() { + getter.call([]); +}); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + getter.call(ab); +}); + +var dv = new DataView(new ArrayBuffer(8), 0); +assert.throws(TypeError, function() { + getter.call(dv); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/byteLength/this-is-not-object.js new file mode 100644 index 00000000000..688b4fa29f8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/this-is-not-object.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.bytelength +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.2 get %SendableTypedArray%.prototype.byteLength + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, "byteLength" +).get; + +assert.throws(TypeError, function() { + getter.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + getter.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + getter.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + getter.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + getter.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + getter.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + getter.call(s); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js new file mode 100644 index 00000000000..0e11a7388ed --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: Returns 0 if the instance has a detached buffer +info: | + 22.2.3.3 get %SendableTypedArray%.prototype.byteOffset + + ... + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 5. If IsDetachedBuffer(buffer) is true, return 0. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(128); + var sample = new TA(buffer, 8, 1); + $DETACHBUFFER(sample.buffer); + assert.sameValue(sample.byteOffset, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js new file mode 100644 index 00000000000..7348f7543f4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the dynamically-sized SendableTypedArray instance +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE); + + assert.sameValue(array.byteOffset, BPE); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following grow"); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following shrink (within bounds)"); + + try { + ab.resize(BPE * 3 - 1); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following shrink (partial element)"); + + try { + ab.resize(BPE); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following shrink (on boundary)"); + + var expected = BPE; + try { + ab.resize(0); + expected = 0; + } catch (_) {} + + assert.sameValue(array.byteOffset, expected, "following shrink (out of bounds)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js new file mode 100644 index 00000000000..c825d6681f5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the fixed-sized SendableTypedArray instance +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + assert.sameValue(array.byteOffset, BPE); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following grow"); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following shrink (within bounds)"); + + var expected; + try { + ab.resize(BPE * 3 - 1); + expected = 0; + } catch (_) { + expected = BPE; + } + + assert.sameValue(array.byteOffset, expected, "following shrink (out of bounds)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js new file mode 100644 index 00000000000..b0ac28468ab --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: > + Return value from [[ByteOffset]] internal slot +info: | + 22.2.3.3 get %SendableTypedArray%.prototype.byteOffset + + ... + 6. Let offset be the value of O's [[ByteOffset]] internal slot. + 7. Return size. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var ta1 = new TA(); + assert.sameValue(ta1.byteOffset, 0, "Regular typedArray"); + + var offset = 4 * TA.BYTES_PER_ELEMENT; + + var buffer1 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var ta2 = new TA(buffer1, offset); + assert.sameValue(ta2.byteOffset, offset, "TA(buffer, offset)"); + + var buffer2 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var sample = new TA(buffer2, offset); + var ta3 = new TA(sample); + assert.sameValue(ta3.byteOffset, 0, "TA(typedArray)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js new file mode 100644 index 00000000000..ee6e9f04671 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: Returns 0 if the instance has a detached buffer +info: | + 22.2.3.3 get %SendableTypedArray%.prototype.byteOffset + + ... + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 5. If IsDetachedBuffer(buffer) is true, return 0. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(128); + var sample = new TA(buffer, 8, 1); + $DETACHBUFFER(sample.buffer); + assert.sameValue(sample.byteOffset, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js new file mode 100644 index 00000000000..9c159226ac3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: > + Requires this value to have a [[ViewedArrayBuffer]] internal slot +info: | + 22.2.3.3 get %SendableTypedArray%.prototype.byteOffset + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.byteOffset; +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js new file mode 100644 index 00000000000..180da3b738a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.3 get %SendableTypedArray%.prototype.byteOffset + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, 'byteOffset' +).get; + +assert.throws(TypeError, function() { + getter(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/length.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/length.js new file mode 100644 index 00000000000..45e377411cf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/length.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: > + get %SendableTypedArray%.prototype.byteOffset.length is 0. +info: | + get %SendableTypedArray%.prototype.byteOffset + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray.prototype, "byteOffset"); + +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/name.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/name.js new file mode 100644 index 00000000000..445e4b51254 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/name.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: > + get %SendableTypedArray%.prototype.byteOffset.name is "get byteOffset". +info: | + get %SendableTypedArray%.prototype.byteOffset + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray.prototype, "byteOffset"); + +verifyProperty(desc.get, "name", { + value: "get byteOffset", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/prop-desc.js new file mode 100644 index 00000000000..3b3408a3f28 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/prop-desc.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: > + "byteOffset" property of SendableTypedArrayPrototype +info: | + %SendableTypedArray%.prototype.byteOffset is an accessor property whose set accessor + function is undefined. + + Section 17: Every accessor property described in clauses 18 through 26 and in + Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var desc = Object.getOwnPropertyDescriptor(SendableTypedArrayPrototype, "byteOffset"); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, "function"); + +verifyNotEnumerable(SendableTypedArrayPrototype, "byteOffset"); +verifyConfigurable(SendableTypedArrayPrototype, "byteOffset"); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js new file mode 100644 index 00000000000..77e715a5370 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the dynamically-sized SendableTypedArray instance +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE); + + assert.sameValue(array.byteOffset, BPE); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following grow"); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following shrink (within bounds)"); + + try { + ab.resize(BPE * 3 - 1); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following shrink (partial element)"); + + try { + ab.resize(BPE); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following shrink (on boundary)"); + + var expected = BPE; + try { + ab.resize(0); + expected = 0; + } catch (_) {} + + assert.sameValue(array.byteOffset, expected, "following shrink (out of bounds)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js new file mode 100644 index 00000000000..13042f28f9a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the fixed-sized SendableTypedArray instance +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + assert.sameValue(array.byteOffset, BPE); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following grow"); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + assert.sameValue(array.byteOffset, BPE, "following shrink (within bounds)"); + + var expected; + try { + ab.resize(BPE * 3 - 1); + expected = 0; + } catch (_) { + expected = BPE; + } + + assert.sameValue(array.byteOffset, expected, "following shrink (out of bounds)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/resized-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/resized-out-of-bounds.js new file mode 100644 index 00000000000..ba5338bf20a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/resized-out-of-bounds.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteOffset +description: > + SendableTypedArray.p.byteOffset behaves as expected when the underlying resizable + buffer is resized such that the SendableTypedArray becomes out of bounds. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +const rab = CreateResizableArrayBuffer(20, 40); + +// Create TAs which cover the bytes 8-15. +let tas_and_lengths = []; +for (let ctor of ctors) { + const length = 8 / ctor.BYTES_PER_ELEMENT; + tas_and_lengths.push([ + new ctor(rab, 8, length), + length + ]); +} +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.byteOffset, 8); +} +rab.resize(10); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.byteOffset, 0); +} +// Resize the rab so that it just barely covers the needed 8 bytes. +rab.resize(16); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.byteOffset, 8); +} +rab.resize(40); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.byteOffset, 8); +} diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js new file mode 100644 index 00000000000..ea0b6b951cb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: > + Return value from [[ByteOffset]] internal slot +info: | + 22.2.3.3 get %SendableTypedArray%.prototype.byteOffset + + ... + 6. Let offset be the value of O's [[ByteOffset]] internal slot. + 7. Return size. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var ta1 = new TA(); + assert.sameValue(ta1.byteOffset, 0, "Regular typedArray"); + + var offset = 4 * TA.BYTES_PER_ELEMENT; + + var buffer1 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var ta2 = new TA(buffer1, offset); + assert.sameValue(ta2.byteOffset, offset, "TA(buffer, offset)"); + + var buffer2 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var sample = new TA(buffer2, offset); + var ta3 = new TA(sample); + assert.sameValue(ta3.byteOffset, 0, "TA(typedArray)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js new file mode 100644 index 00000000000..d91b35e4685 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: > + Throws a TypeError exception when `this` does not have a [[TypedArrayName]] + internal slot +info: | + 22.2.3.3 get %SendableTypedArray%.prototype.byteOffset + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [DataView, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, "byteOffset" +).get; + +assert.throws(TypeError, function() { + getter.call({}); +}); + +assert.throws(TypeError, function() { + getter.call([]); +}); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + getter.call(ab); +}); + +var dv = new DataView(new ArrayBuffer(8), 0); +assert.throws(TypeError, function() { + getter.call(dv); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/this-is-not-object.js new file mode 100644 index 00000000000..f61ed59a402 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/this-is-not-object.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.byteoffset +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.3 get %SendableTypedArray%.prototype.byteOffset + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, "byteOffset" +).get; + +assert.throws(TypeError, function() { + getter.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + getter.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + getter.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + getter.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + getter.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + getter.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + getter.call(s); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/constructor.js b/test/sendable/builtins/TypedArray/prototype/constructor.js new file mode 100644 index 00000000000..84e8dd47e03 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/constructor.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.constructor +description: > + Initial state of the constructor property +info: | + The initial value of %SendableTypedArray%.prototype.constructor is the %SendableTypedArray% intrinsic object. + + Per ES6 section 17, the method should exist on the %SendableTypedArray% prototype, and it + should be writable and configurable, but not enumerable. +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray] +---*/ + +assert.sameValue(SendableTypedArray.prototype.constructor, SendableTypedArray); + +verifyProperty(SendableTypedArray.prototype, "constructor", { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js new file mode 100644 index 00000000000..8530f418415 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + end argument is coerced to an integer values. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, null), + [0n, 1n, 2n, 3n] + ), + 'null value coerced to 0' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, NaN), + [0n, 1n, 2n, 3n] + ), + 'NaN value coerced to 0' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, false), + [0n, 1n, 2n, 3n] + ), + 'false value coerced to 0' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, true), + [0n, 0n, 2n, 3n] + ), + 'true value coerced to 1' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, '-2'), + [0n, 0n, 1n, 3n] + ), + 'string "-2" value coerced to integer -2' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, -2.5), + [0n, 0n, 1n, 3n] + ), + 'float -2.5 value coerced to integer -2' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js new file mode 100644 index 00000000000..a959879f08e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js @@ -0,0 +1,105 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + start argument is coerced to an integer value. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 5. Let relativeStart be ? ToInteger(start). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(1, undefined), + [0n, 0n, 1n, 2n] + ), + 'undefined value coerced to 0' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(1, false), + [0n, 0n, 1n, 2n] + ), + 'false value coerced to 0' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(1, NaN), + [0n, 0n, 1n, 2n] + ), + 'NaN value coerced to 0' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(1, null), + [0n, 0n, 1n, 2n] + ), + 'null value coerced to 0' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, true), + [1n, 2n, 3n, 3n] + ), + 'true value coerced to 1' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, '1'), + [1n, 2n, 3n, 3n] + ), + 'string "1" value coerced to 1' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0.5), + [0n, 0n, 1n, 2n] + ), + '0.5 float value coerced to integer 0' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1.5), + [1n, 2n, 3n, 3n] + ), + '1.5 float value coerced to integer 1' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js new file mode 100644 index 00000000000..d4ad9f8492b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js @@ -0,0 +1,105 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + target argument is coerced to an integer value. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 3. Let relativeTarget be ? ToInteger(target). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(undefined, 1), + [1n, 2n, 3n, 3n] + ), + 'undefined value coerced to 0' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(false, 1), + [1n, 2n, 3n, 3n] + ), + 'false value coerced to 0' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(NaN, 1), + [1n, 2n, 3n, 3n] + ), + 'NaN value coerced to 0' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(null, 1), + [1n, 2n, 3n, 3n] + ), + 'null value coerced to 0' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(true, 0), + [0n, 0n, 1n, 2n] + ), + 'true value coerced to 1' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin('1', 0), + [0n, 0n, 1n, 2n] + ), + 'string "1" value coerced to 1' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0.5, 1), + [1n, 2n, 3n, 3n] + ), + '0.5 float value coerced to integer 0' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(1.5, 0), + [0n, 0n, 1n, 2n] + ), + '1.5 float value coerced to integer 1' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js new file mode 100644 index 00000000000..90ec1d0481b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [, end ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.copyWithin(obj, obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js new file mode 100644 index 00000000000..42a88e0ce29 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + Object.defineProperty(TA.prototype, "length", { + get: function() { + throw new Test262Error(); + } + }); + + var sample = new TA(); + Object.defineProperty(sample, "length", { + get: function() { + throw new Test262Error(); + } + }); + + assert.sameValue(sample.copyWithin(0, 0), sample); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-end.js new file mode 100644 index 00000000000..b104fb92b05 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-end.js @@ -0,0 +1,108 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Set values with negative end argument. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let + final be min(relativeEnd, len). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -1), + [1n, 2n, 2n, 3n] + ), + '[0, 1, 2, 3].copyWithin(0, 1, -1) -> [1, 2, 2, 3]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, 0, -1), + [0n, 1n, 0n, 1n, 2n] + ), + '[0, 1, 2, 3, 4].copyWithin(2, 0, -1) -> [0, 1, 0, 1, 2]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, 2, -2), + [0n, 2n, 2n, 3n, 4n] + ), + '[0, 1, 2, 3, 4].copyWithin(1, 2, -2) -> [0, 2, 2, 3, 4]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -1), + [2n, 1n, 2n, 3n] + ), + '[0, 1, 2, 3].copyWithin(0, -2, -1) -> [2, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2, -1), + [0n, 1n, 3n, 3n, 4n] + ), + '[0, 1, 2, 3, 4].copyWithin(2, -2, 1) -> [0, 1, 3, 3, 4]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -1), + [0n, 2n, 2n, 3n] + ), + '[0, 1, 2, 3].copyWithin(-3, -2, -1) -> [0, 2, 2, 3]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3, -1), + [0n, 1n, 2n, 2n, 3n] + ), + '[0, 1, 2, 3, 4].copyWithin(-2, -3, -1) -> [0, 1, 2, 2, 3]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2, -1), + [3n, 1n, 2n, 3n, 4n] + ), + '[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) -> [3, 1, 2, 3, 4]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js new file mode 100644 index 00000000000..35f5cbe0330 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Set values with negative out of bounds end argument. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let + final be min(relativeEnd, len). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -10), + [0n, 1n, 2n, 3n] + ), + '[0, 1, 2, 3].copyWithin(0, 1, -10) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, -Infinity), + [1n, 2n, 3n, 4n, 5n] + ), + '[1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, -2, -10), + [0n, 1n, 2n, 3n] + ), + '[0, 1, 2, 3].copyWithin(0, -2, -10) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -2, -Infinity), + [1n, 2n, 3n, 4n, 5n] + ), + '[1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, -9, -10), + [0n, 1n, 2n, 3n] + ), + '[0, 1, 2, 3].copyWithin(0, -9, -10) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -9, -Infinity), + [1n, 2n, 3n, 4n, 5n] + ), + '[1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(-3, -2, -10), + [0n, 1n, 2n, 3n] + ), + '[0, 1, 2, 3].copyWithin(-3, -2, -10) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-3, -2, -Infinity), + [1n, 2n, 3n, 4n, 5n] + ), + '[1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(-7, -8, -9), + [0n, 1n, 2n, 3n] + ), + '[0, 1, 2, 3].copyWithin(-7, -8, -9) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-7, -8, -Infinity), + [1n, 2n, 3n, 4n, 5n] + ), + '[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) -> [1, 2, 3, 4, 5]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js new file mode 100644 index 00000000000..766be0e29bc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Set values with out of bounds negative start argument. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let + from be min(relativeStart, len). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, -10), + [0n, 1n, 2n, 3n] + ), + '[0, 1, 2, 3]).copyWithin(0, -10) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, -Infinity), + [1n, 2n, 3n, 4n, 5n] + ), + '[1, 2, 3, 4, 5]).copyWithin(0, -Infinity) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -10), + [0n, 1n, 0n, 1n, 2n] + ), + '[0, 1, 2, 3, 4]).copyWithin(2, -2) -> [0, 1, 0, 1, 2]' + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(2, -Infinity), + [1n, 2n, 1n, 2n, 3n] + ), + '[1, 2, 3, 4, 5]).copyWithin(2, -Infinity) -> [1, 2, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(10, -10), + [0n, 1n, 2n, 3n, 4n] + ), + '[0, 1, 2, 3, 4]).copyWithin(10, -10) -> [0, 1, 2, 3, 4]' + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(10, -Infinity), + [1n, 2n, 3n, 4n, 5n] + ), + '[1, 2, 3, 4, 5]).copyWithin(10, -Infinity) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(-9, -10), + [0n, 1n, 2n, 3n] + ), + '[0, 1, 2, 3].copyWithin(-9, -10) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-9, -Infinity), + [1n, 2n, 3n, 4n, 5n] + ), + '[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) -> [1, 2, 3, 4, 5]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js new file mode 100644 index 00000000000..fc9b0d4300e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Set values with out of bounds negative target argument. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let + to be min(relativeTarget, len). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(-10, 0), + [0n, 1n, 2n, 3n] + ), + '[0, 1, 2, 3].copyWithin(-10, 0) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 0), + [1n, 2n, 3n, 4n, 5n] + ), + '[1, 2, 3, 4, 5].copyWithin(-Infinity, 0) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-10, 2), + [2n, 3n, 4n, 3n, 4n] + ), + '[0, 1, 2, 3, 4].copyWithin(-10, 2) -> [2, 3, 4, 3, 4]' + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(-Infinity, 2), + [3n, 4n, 5n, 4n, 5n] + ), + '[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) -> [3, 4, 5, 4, 5]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-start.js new file mode 100644 index 00000000000..7dc156985c1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-start.js @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Set values with negative start argument. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let + from be min(relativeStart, len). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, -1), + [3n, 1n, 2n, 3n] + ), + '[0, 1, 2, 3].copyWithin(0, -1) -> [3, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(2, -2), + [0n, 1n, 3n, 4n, 4n] + ), + '[0, 1, 2, 3, 4].copyWithin(2, -2) -> [0, 1, 3, 4, 4]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(1, -2), + [0n, 3n, 4n, 3n, 4n] + ), + '[0, 1, 2, 3, 4].copyWithin(1, -2) -> [0, 3, 4, 3, 4]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(-1, -2), + [0n, 1n, 2n, 2n] + ), + '[0, 1, 2, 3].copyWithin(-1, -2) -> [ 0, 1, 2, 2 ]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, -3), + [0n, 1n, 2n, 2n, 3n] + ), + '[0, 1, 2, 3, 4].copyWithin(-2, -3) -> [0, 1, 2, 2, 3]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-5, -2), + [3n, 4n, 2n, 3n, 4n] + ), + '[0, 1, 2, 3, 4].copyWithin(-5, -2) -> [3, 4, 2, 3, 4]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-target.js new file mode 100644 index 00000000000..5bc56360e19 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-target.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Set values with negative target argument. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let + to be min(relativeTarget, len). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 0), + [0n, 1n, 2n, 0n] + ), + '[0, 1, 2, 3].copyWithin(-1, 0) -> [0, 1, 2, 0]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n]).copyWithin(-2, 2), + [0n, 1n, 2n, 2n, 3n] + ), + '[0, 1, 2, 3, 4].copyWithin(-2, 2) -> [0, 1, 2, 2, 3]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 2), + [0n, 1n, 2n, 2n] + ), + '[0, 1, 2, 3].copyWithin(-1, 2) -> [0, 1, 2, 2]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js new file mode 100644 index 00000000000..7280d5c6d84 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Max value of end position is the this.length. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 6), + [1n, 2n, 3n, 3n] + ), + '[0, 1, 2, 3].copyWithin(0, 1, 6) -> [1, 2, 3, 3]' + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, 1, Infinity), + [2n, 3n, 4n, 5n, 5n] + ), + '[1, 2, 3, 4, 5].copyWithin(0, 1, Infinity) -> [2, 3, 4, 5, 5]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 6), + [0n, 3n, 4n, 5n, 4n, 5n] + ), + '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6) -> [0, 3, 4, 5, 4, 5]' + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, Infinity), + [1n, 4n, 5n, 4n, 5n] + ), + '[1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) -> [1, 4, 5, 4, 5]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js new file mode 100644 index 00000000000..8260b853cdb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Max values of target and start positions are this.length. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 0), + [0n, 1n, 2n, 3n, 4n, 5n] + ) + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, 0), + [1n, 2n, 3n, 4n, 5n] + ), + '[1, 2, 3, 4, 5].copyWithin(Infinity, 0) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(0, 6), + [0n, 1n, 2n, 3n, 4n, 5n] + ) + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(0, Infinity), + [1n, 2n, 3n, 4n, 5n] + ), + '[1, 2, 3, 4, 5].copyWithin(0, Infinity) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 6), + [0n, 1n, 2n, 3n, 4n, 5n] + ) + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(10, 10), + [0n, 1n, 2n, 3n, 4n, 5n] + ) + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n]).copyWithin(Infinity, Infinity), + [1n, 2n, 3n, 4n, 5n] + ), + '[1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) -> [1, 2, 3, 4, 5]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js new file mode 100644 index 00000000000..ad31d4e7ae1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Copy values with non-negative target and start positions. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 0), + [1n, 2n, 3n, 4n, 5n, 6n] + ) + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 2), + [3n, 4n, 5n, 6n, 5n, 6n] + ) + ); + + assert( + compareArray( + new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(3, 0), + [1n, 2n, 3n, 1n, 2n, 3n] + ) + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 4), + [0n, 4n, 5n, 3n, 4n, 5n] + ) + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js new file mode 100644 index 00000000000..91ee5469c23 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Copy values with non-negative target, start and end positions. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 0), + [0n, 1n, 2n, 3n] + ), + '[0, 1, 2, 3].copyWithin(0, 0, 0) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 2), + [0n, 1n, 2n, 3n] + ), + '[0, 1, 2, 3].copyWithin(0, 0, 2) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 2), + [1n, 1n, 2n, 3n] + ), + '[0, 1, 2, 3].copyWithin(0, 1, 2) -> [1, 1, 2, 3]' + ); + + /* + * 10. If from [0, 0, 1, 3]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(1, 3, 5), + [0n, 3n, 4n, 3n, 4n, 5n] + ), + '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5) -> [0, 3, 4, 3, 4, 5]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js new file mode 100644 index 00000000000..c6fb7952668 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Return abrupt if end is a Symbol. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var s = Symbol(1); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.copyWithin(0, 0, s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js new file mode 100644 index 00000000000..d198c4e58cf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Return abrupt from ToInteger(end). +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var o1 = { + valueOf: function() { + throw new Test262Error(); + } + }; + var sample = new TA(); + assert.throws(Test262Error, function() { + sample.copyWithin(0, 0, o1); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js new file mode 100644 index 00000000000..af4440eaf6f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Return abrupt if start is a Symbol. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 5. Let relativeStart be ? ToInteger(start). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var s = Symbol(1); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.copyWithin(0, s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js new file mode 100644 index 00000000000..493c12e1c74 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Return abrupt from ToInteger(start). +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 5. Let relativeStart be ? ToInteger(start). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var o = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var err = { + valueOf: function() { + throw new Error("ToInteger(start) runs before ToInteger(end)"); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(Test262Error, function() { + sample.copyWithin(0, o, err); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js new file mode 100644 index 00000000000..5d015cccf03 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Return abrupt if target is a Symbol. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 3. Let relativeTarget be ? ToInteger(target). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var s = Symbol(1); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.copyWithin(s, 0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js new file mode 100644 index 00000000000..0fcb91df800 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Return abrupt from ToInteger(target). +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 3. Let relativeTarget be ? ToInteger(target). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var o = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(Test262Error, function() { + sample.copyWithin(o); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..0dadf576a4a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.copyWithin, + 'function', + 'implements SendableTypedArray.prototype.copyWithin' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.copyWithin(0, 0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.copyWithin(0, 0); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the copyWithin operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.copyWithin(0, 0); + throw new Test262Error('copyWithin completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-this.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-this.js new file mode 100644 index 00000000000..8495d347e88 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-this.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Returns `this`. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + 13. Return O. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(); + var result1 = sample1.copyWithin(0, 0); + + assert.sameValue(result1, sample1); + + var sample2 = new TA([1n, 2n, 3n]); + var result2 = sample2.copyWithin(1, 0); + + assert.sameValue(result2, sample2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js new file mode 100644 index 00000000000..65cb9e367ff --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + If `end` is undefined, set final position to `this.length`. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, undefined), + [1n, 2n, 3n, 3n] + ), + '[0, 1, 2, 3].copyWithin(0, 1, undefined) -> [1, 2, 3]' + ); + + assert( + compareArray( + new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1), + [1n, 2n, 3n, 3n] + ), + '[0, 1, 2, 3].copyWithin(0, 1) -> [1, 2, 3, 3]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js new file mode 100644 index 00000000000..31552969c3d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: Preservation of bit-level encoding +info: | + Array.prototype.copyWithin (target, start [ , end ] ) + + 12. Repeat, while count > 0 + [...] + d. If fromPresent is true, then + i. Let fromVal be ? Get(O, fromKey). + ii. Perform ? Set(O, toKey, fromVal, true). +includes: [nans.js, compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +function body(FloatArray) { + var subject = new FloatArray(NaNs.length * 2); + + NaNs.forEach(function(v, i) { + subject[i] = v; + }); + + var originalBytes, copiedBytes; + var length = NaNs.length * FloatArray.BYTES_PER_ELEMENT; + + originalBytes = new Uint8Array( + subject.buffer, + 0, + length + ); + + subject.copyWithin(NaNs.length, 0); + copiedBytes = new Uint8Array( + subject.buffer, + length + ); + + assert(compareArray(originalBytes, copiedBytes)); +} + +testWithSendableTypedArrayConstructors(body, floatArrayConstructors); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js new file mode 100644 index 00000000000..3934bf4eb62 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + copyWithin should respect typedarray's byteOffset +info: | + 22.2.3.5%SendableTypedArray%.prototype.copyWithin ( target, start [ , end ] ) + ... + 17. If count > 0, then + e. Let elementSize be the Element Size value specified in Table 72 for typedArrayName. + f. Let byteOffset be O.[[ByteOffset]]. + g. Let toByteIndex be to × elementSize + byteOffset. + h. Let fromByteIndex be from × elementSize + byteOffset. + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var ta = new TA([0, 1, 2, 3]); + assert.compareArray( + new TA(ta.buffer, TA.BYTES_PER_ELEMENT).copyWithin(2, 0), + [1, 2, 1], + 'copyWithin should respect typedarray\'s byteOffset' + ); + + assert.compareArray( + ta, + [0, 1, 2, 1], + 'underlying arraybuffer should have been updated' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-end-shrink.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-end-shrink.js new file mode 100644 index 00000000000..f736b7bcba1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-end-shrink.js @@ -0,0 +1,92 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-array.prototype.copywithin +description: > + SendableTypedArray.p.copyWithin behaves correctly when argument coercion shrinks the receiver +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 2; + } + }; + assert.throws(TypeError, () => { + fixedLength.copyWithin(evil, 0, 1); + }); + rab.resize(4 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.copyWithin(0, evil, 3); + }); + rab.resize(4 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.copyWithin(0, 1, evil); + }); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i); + } + // [0, 1, 2, 3] + // ^ + // target + // ^ + // start + const evil = { + valueOf: () => { + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + return 2; + } + }; + lengthTracking.copyWithin(evil, 0); + assert.compareArray(ToNumbers(lengthTracking), [ + 0, + 1, + 0 + ]); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i); + } + // [0, 1, 2, 3] + // ^ + // start + // ^ + // target + const evil = { + valueOf: () => { + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + return 2; + } + }; + lengthTracking.copyWithin(0, evil); + assert.compareArray(ToNumbers(lengthTracking), [ + 2, + 1, + 2 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-grow.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-grow.js new file mode 100644 index 00000000000..e9f412cd658 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-grow.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-array.prototype.copywithin +description: > + SendableTypedArray.p.copyWithin behaves correctly when argument coercion shrinks the receiver +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i); + } + const evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + lengthTracking[4] = MayNeedBigInt(lengthTracking, 4); + lengthTracking[5] = MayNeedBigInt(lengthTracking, 5); + return 0; + } + }; + // Orig. array: [0, 1, 2, 3] [4, 5] + // ^ ^ ^ new elements + // target start + lengthTracking.copyWithin(evil, 2); + assert.compareArray(ToNumbers(lengthTracking), [ + 2, + 3, + 2, + 3, + 4, + 5 + ]); + rab.resize(4 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i); + } + + // Orig. array: [0, 1, 2, 3] [4, 5] + // ^ ^ ^ new elements + // start target + lengthTracking.copyWithin(2, evil); + assert.compareArray(ToNumbers(lengthTracking), [ + 0, + 1, + 0, + 1, + 4, + 5 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js new file mode 100644 index 00000000000..1aa9299444e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + SECURITY: end argument is coerced to an integer values + causing array detachment, but the value is still defined + by a prototype +info: | + 22.2.3.5%SendableTypedArray%.prototype.copyWithin ( target, start [ , end ] ) + ... + 8. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). + ... + 10. Let count be min(final - from, len - to). + 11. If count > 0, then + a. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data. + b. Let buffer be O.[[ViewedArrayBuffer]]. + c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var ta; + var array = []; + + function detachAndReturnIndex(){ + $DETACHBUFFER(ta.buffer); + Object.setPrototypeOf(ta, array); + return 101; + } + + array.length = 10000; // big arrays are more likely to cause a crash if they are accessed after they are freed + array.fill(7, 0); + ta = new TA(array); + assert.throws(TypeError, function(){ + ta.copyWithin(0, 100, {valueOf : detachAndReturnIndex}); + }, "should throw TypeError as array is detached"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js new file mode 100644 index 00000000000..bfac54944e3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + SECURITY: end argument is coerced to an integer values + causing array detachment +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin ( target, start [ , end ] ) + + ... + 8. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). + ... + 10. Let count be min(final - from, len - to). + 11. If count > 0, then + a. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data. + b. Let buffer be O.[[ViewedArrayBuffer]]. + c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var ta; + function detachAndReturnIndex(){ + $DETACHBUFFER(ta.buffer); + return 900; + } + + var array = []; + array.length = 10000; // big arrays are more likely to cause a crash if they are accessed after they are freed + array.fill(7, 0); + ta = new TA(array); + assert.throws(TypeError, function(){ + ta.copyWithin(0, 100, {valueOf : detachAndReturnIndex}); + }, "should throw TypeError as array is detached"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js new file mode 100644 index 00000000000..9c75dd44776 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + end argument is coerced to an integer values. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(1, 0, null), + [0, 1, 2, 3] + ), + 'null value coerced to 0' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(1, 0, NaN), + [0, 1, 2, 3] + ), + 'NaN value coerced to 0' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(1, 0, false), + [0, 1, 2, 3] + ), + 'false value coerced to 0' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(1, 0, true), + [0, 0, 2, 3] + ), + 'true value coerced to 1' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(1, 0, '-2'), + [0, 0, 1, 3] + ), + 'string "-2" value coerced to integer -2' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(1, 0, -2.5), + [0, 0, 1, 3] + ), + 'float -2.5 value coerced to integer -2' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js new file mode 100644 index 00000000000..05d2a078dcc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + SECURITY: start argument is coerced to an integer value, which detached + the array +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin ( target, start [ , end ] ) + + ... + 6. Let relativeStart be ? ToInteger(start). + ... + 10. Let count be min(final - from, len - to). + 11. If count > 0, then + a. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data. + b. Let buffer be O.[[ViewedArrayBuffer]]. + c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var ta; + function detachAndReturnIndex(){ + $DETACHBUFFER(ta.buffer); + return 100; + } + + var array = []; + array.length = 10000; // big arrays are more likely to cause a crash if they are accessed after they are freed + array.fill(7, 0); + ta = new TA(array); + assert.throws(TypeError, function(){ + ta.copyWithin(0, {valueOf : detachAndReturnIndex}, 1000); + }, "should throw TypeError as array is detached"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js new file mode 100644 index 00000000000..2b01761b076 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js @@ -0,0 +1,105 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + start argument is coerced to an integer value. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 5. Let relativeStart be ? ToInteger(start). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(1, undefined), + [0, 0, 1, 2] + ), + 'undefined value coerced to 0' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(1, false), + [0, 0, 1, 2] + ), + 'false value coerced to 0' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(1, NaN), + [0, 0, 1, 2] + ), + 'NaN value coerced to 0' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(1, null), + [0, 0, 1, 2] + ), + 'null value coerced to 0' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, true), + [1, 2, 3, 3] + ), + 'true value coerced to 1' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, '1'), + [1, 2, 3, 3] + ), + 'string "1" value coerced to 1' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(1, 0.5), + [0, 0, 1, 2] + ), + '0.5 float value coerced to integer 0' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, 1.5), + [1, 2, 3, 3] + ), + '1.5 float value coerced to integer 1' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js new file mode 100644 index 00000000000..834d3bdbf77 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js @@ -0,0 +1,113 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + target argument is coerced to an integer value. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 3. Let relativeTarget be ? ToInteger(target). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(undefined, 1), + [1, 2, 3, 3] + ), + 'undefined value coerced to 0' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(false, 1), + [1, 2, 3, 3] + ), + 'false value coerced to 0' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(NaN, 1), + [1, 2, 3, 3] + ), + 'NaN value coerced to 0' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(null, 1), + [1, 2, 3, 3] + ), + 'null value coerced to 0' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(true, 0), + [0, 0, 1, 2] + ), + 'true value coerced to 1' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin('1', 0), + [0, 0, 1, 2] + ), + 'string "1" value coerced to 1' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0.5, 1), + [1, 2, 3, 3] + ), + '0.5 float value coerced to integer 0' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(1.5, 0), + [0, 0, 1, 2] + ), + '1.5 float value coerced to integer 1' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin({}, 1), + [1, 2, 3, 3] + ), + 'object value coerced to integer 0' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js new file mode 100644 index 00000000000..c819ba22168 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [, end ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.copyWithin(obj, obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js new file mode 100644 index 00000000000..4164cd326c9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithSendableTypedArrayConstructors(function(TA) { + Object.defineProperty(TA.prototype, "length", { + get: function() { + throw new Test262Error(); + } + }); + + var sample = new TA(); + Object.defineProperty(sample, "length", { + get: function() { + throw new Test262Error(); + } + }); + + assert.sameValue(sample.copyWithin(0, 0), sample); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-func.js new file mode 100644 index 00000000000..7105f735c7a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-func.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [, end ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var copyWithin = SendableTypedArray.prototype.copyWithin; + +assert.sameValue(typeof copyWithin, 'function'); + +assert.throws(TypeError, function() { + copyWithin(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-method.js new file mode 100644 index 00000000000..d4eaed9e298 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-method.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [, end ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.copyWithin, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.copyWithin(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/length.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/length.js new file mode 100644 index 00000000000..a0dfc9ffd50 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + %SendableTypedArray%.prototype.copyWithin.length is 2. +info: | + %SendableTypedArray%.prototype.copyWithin (target, start [, end ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.copyWithin, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/name.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/name.js new file mode 100644 index 00000000000..3ffc98371de --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + %SendableTypedArray%.prototype.copyWithin.name is "copyWithin". +info: | + %SendableTypedArray%.prototype.copyWithin (target, start [, end ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.copyWithin, "name", { + value: "copyWithin", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js new file mode 100644 index 00000000000..fcfade66b14 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js @@ -0,0 +1,108 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Set values with negative end argument. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let + final be min(relativeEnd, len). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, 1, -1), + [1, 2, 2, 3] + ), + '[0, 1, 2, 3].copyWithin(0, 1, -1) -> [1, 2, 2, 3]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4]).copyWithin(2, 0, -1), + [0, 1, 0, 1, 2] + ), + '[0, 1, 2, 3, 4].copyWithin(2, 0, -1) -> [0, 1, 0, 1, 2]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4]).copyWithin(1, 2, -2), + [0, 2, 2, 3, 4] + ), + '[0, 1, 2, 3, 4].copyWithin(1, 2, -2) -> [0, 2, 2, 3, 4]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, -2, -1), + [2, 1, 2, 3] + ), + '[0, 1, 2, 3].copyWithin(0, -2, -1) -> [2, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4]).copyWithin(2, -2, -1), + [0, 1, 3, 3, 4] + ), + '[0, 1, 2, 3, 4].copyWithin(2, -2, 1) -> [0, 1, 3, 3, 4]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(-3, -2, -1), + [0, 2, 2, 3] + ), + '[0, 1, 2, 3].copyWithin(-3, -2, -1) -> [0, 2, 2, 3]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3, -1), + [0, 1, 2, 2, 3] + ), + '[0, 1, 2, 3, 4].copyWithin(-2, -3, -1) -> [0, 1, 2, 2, 3]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2, -1), + [3, 1, 2, 3, 4] + ), + '[0, 1, 2, 3, 4].copyWithin(-5, -2, -1) -> [3, 1, 2, 3, 4]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js new file mode 100644 index 00000000000..8fcda9982d9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Set values with negative out of bounds end argument. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let + final be min(relativeEnd, len). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, 1, -10), + [0, 1, 2, 3] + ), + '[0, 1, 2, 3].copyWithin(0, 1, -10) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, -Infinity), + [1, 2, 3, 4, 5] + ), + '[1, 2, 3, 4, 5].copyWithin(0, 1, -Infinity) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, -2, -10), + [0, 1, 2, 3] + ), + '[0, 1, 2, 3].copyWithin(0, -2, -10) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(0, -2, -Infinity), + [1, 2, 3, 4, 5] + ), + '[1, 2, 3, 4, 5].copyWithin(0, -2, -Infinity) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, -9, -10), + [0, 1, 2, 3] + ), + '[0, 1, 2, 3].copyWithin(0, -9, -10) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(0, -9, -Infinity), + [1, 2, 3, 4, 5] + ), + '[1, 2, 3, 4, 5].copyWithin(0, -9, -Infinity) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(-3, -2, -10), + [0, 1, 2, 3] + ), + '[0, 1, 2, 3].copyWithin(-3, -2, -10) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(-3, -2, -Infinity), + [1, 2, 3, 4, 5] + ), + '[1, 2, 3, 4, 5].copyWithin(-3, -2, -Infinity) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(-7, -8, -9), + [0, 1, 2, 3] + ), + '[0, 1, 2, 3].copyWithin(-7, -8, -9) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(-7, -8, -Infinity), + [1, 2, 3, 4, 5] + ), + '[1, 2, 3, 4, 5].copyWithin(-7, -8, -Infinity) -> [1, 2, 3, 4, 5]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js new file mode 100644 index 00000000000..e1acd2dea12 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Set values with out of bounds negative start argument. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let + from be min(relativeStart, len). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, -10), + [0, 1, 2, 3] + ), + '[0, 1, 2, 3]).copyWithin(0, -10) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(0, -Infinity), + [1, 2, 3, 4, 5] + ), + '[1, 2, 3, 4, 5]).copyWithin(0, -Infinity) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4]).copyWithin(2, -10), + [0, 1, 0, 1, 2] + ), + '[0, 1, 2, 3, 4]).copyWithin(2, -2) -> [0, 1, 0, 1, 2]' + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(2, -Infinity), + [1, 2, 1, 2, 3] + ), + '[1, 2, 3, 4, 5]).copyWithin(2, -Infinity) -> [1, 2, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4]).copyWithin(10, -10), + [0, 1, 2, 3, 4] + ), + '[0, 1, 2, 3, 4]).copyWithin(10, -10) -> [0, 1, 2, 3, 4]' + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(10, -Infinity), + [1, 2, 3, 4, 5] + ), + '[1, 2, 3, 4, 5]).copyWithin(10, -Infinity) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(-9, -10), + [0, 1, 2, 3] + ), + '[0, 1, 2, 3].copyWithin(-9, -10) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(-9, -Infinity), + [1, 2, 3, 4, 5] + ), + '[1, 2, 3, 4, 5].copyWithin(-9, -Infinity) -> [1, 2, 3, 4, 5]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js new file mode 100644 index 00000000000..5c61c2b699c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Set values with out of bounds negative target argument. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let + to be min(relativeTarget, len). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(-10, 0), + [0, 1, 2, 3] + ), + '[0, 1, 2, 3].copyWithin(-10, 0) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 0), + [1, 2, 3, 4, 5] + ), + '[1, 2, 3, 4, 5].copyWithin(-Infinity, 0) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4]).copyWithin(-10, 2), + [2, 3, 4, 3, 4] + ), + '[0, 1, 2, 3, 4].copyWithin(-10, 2) -> [2, 3, 4, 3, 4]' + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(-Infinity, 2), + [3, 4, 5, 4, 5] + ), + '[1, 2, 3, 4, 5].copyWithin(-Infinity, 2) -> [3, 4, 5, 4, 5]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js new file mode 100644 index 00000000000..fa8715c2de4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Set values with negative start argument. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let + from be min(relativeStart, len). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, -1), + [3, 1, 2, 3] + ), + '[0, 1, 2, 3].copyWithin(0, -1) -> [3, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4]).copyWithin(2, -2), + [0, 1, 3, 4, 4] + ), + '[0, 1, 2, 3, 4].copyWithin(2, -2) -> [0, 1, 3, 4, 4]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4]).copyWithin(1, -2), + [0, 3, 4, 3, 4] + ), + '[0, 1, 2, 3, 4].copyWithin(1, -2) -> [0, 3, 4, 3, 4]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(-1, -2), + [0, 1, 2, 2] + ), + '[0, 1, 2, 3].copyWithin(-1, -2) -> [ 0, 1, 2, 2 ]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4]).copyWithin(-2, -3), + [0, 1, 2, 2, 3] + ), + '[0, 1, 2, 3, 4].copyWithin(-2, -3) -> [0, 1, 2, 2, 3]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4]).copyWithin(-5, -2), + [3, 4, 2, 3, 4] + ), + '[0, 1, 2, 3, 4].copyWithin(-5, -2) -> [3, 4, 2, 3, 4]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js new file mode 100644 index 00000000000..623ae0ba34e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Set values with negative target argument. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let + to be min(relativeTarget, len). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(-1, 0), + [0, 1, 2, 0] + ), + '[0, 1, 2, 3].copyWithin(-1, 0) -> [0, 1, 2, 0]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4]).copyWithin(-2, 2), + [0, 1, 2, 2, 3] + ), + '[0, 1, 2, 3, 4].copyWithin(-2, 2) -> [0, 1, 2, 2, 3]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(-1, 2), + [0, 1, 2, 2] + ), + '[0, 1, 2, 3].copyWithin(-1, 2) -> [0, 1, 2, 2]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js new file mode 100644 index 00000000000..f15d5e28c3f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Max value of end position is the this.length. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, 1, 6), + [1, 2, 3, 3] + ), + '[0, 1, 2, 3].copyWithin(0, 1, 6) -> [1, 2, 3, 3]' + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(0, 1, Infinity), + [2, 3, 4, 5, 5] + ), + '[1, 2, 3, 4, 5].copyWithin(0, 1, Infinity) -> [2, 3, 4, 5, 5]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 6), + [0, 3, 4, 5, 4, 5] + ), + '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 6) -> [0, 3, 4, 5, 4, 5]' + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(1, 3, Infinity), + [1, 4, 5, 4, 5] + ), + '[1, 2, 3, 4, 5].copyWithin(1, 3, Infinity) -> [1, 4, 5, 4, 5]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js new file mode 100644 index 00000000000..5a09fc686a4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Max values of target and start positions are this.length. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 0), + [0, 1, 2, 3, 4, 5] + ) + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, 0), + [1, 2, 3, 4, 5] + ), + '[1, 2, 3, 4, 5].copyWithin(Infinity, 0) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4, 5]).copyWithin(0, 6), + [0, 1, 2, 3, 4, 5] + ) + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(0, Infinity), + [1, 2, 3, 4, 5] + ), + '[1, 2, 3, 4, 5].copyWithin(0, Infinity) -> [1, 2, 3, 4, 5]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 6), + [0, 1, 2, 3, 4, 5] + ) + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4, 5]).copyWithin(10, 10), + [0, 1, 2, 3, 4, 5] + ) + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5]).copyWithin(Infinity, Infinity), + [1, 2, 3, 4, 5] + ), + '[1, 2, 3, 4, 5].copyWithin(Infinity, Infinity) -> [1, 2, 3, 4, 5]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js new file mode 100644 index 00000000000..2a74da9da49 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Copy values with non-negative target and start positions. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 0), + [1, 2, 3, 4, 5, 6] + ) + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 2), + [3, 4, 5, 6, 5, 6] + ) + ); + + assert( + compareArray( + new TA([1, 2, 3, 4, 5, 6]).copyWithin(3, 0), + [1, 2, 3, 1, 2, 3] + ) + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 4), + [0, 4, 5, 3, 4, 5] + ) + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js new file mode 100644 index 00000000000..5a7a271c1ba --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Copy values with non-negative target, start and end positions. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, 0, 0), + [0, 1, 2, 3] + ), + '[0, 1, 2, 3].copyWithin(0, 0, 0) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, 0, 2), + [0, 1, 2, 3] + ), + '[0, 1, 2, 3].copyWithin(0, 0, 2) -> [0, 1, 2, 3]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, 1, 2), + [1, 1, 2, 3] + ), + '[0, 1, 2, 3].copyWithin(0, 1, 2) -> [1, 1, 2, 3]' + ); + + /* + * 10. If from [0, 0, 1, 3]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3, 4, 5]).copyWithin(1, 3, 5), + [0, 3, 4, 3, 4, 5] + ), + '[0, 1, 2, 3, 4, 5].copyWithin(1, 3, 5) -> [0, 3, 4, 3, 4, 5]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/not-a-constructor.js new file mode 100644 index 00000000000..43aa1e4468c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.copyWithin 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.copyWithin), + false, + 'isConstructor(SendableTypedArray.prototype.copyWithin) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.copyWithin(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/prop-desc.js new file mode 100644 index 00000000000..89cd9def80a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + "copyWithin" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'copyWithin', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/resizable-buffer.js new file mode 100644 index 00000000000..1b55ce37478 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/resizable-buffer.js @@ -0,0 +1,191 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + SendableTypedArray.p.copyWithin behaves correctly when the receiver is backed by + resizable buffer +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + + // Orig. array: [0, 1, 2, 3] + // [0, 1, 2, 3] << fixedLength + // [2, 3] << fixedLengthWithOffset + // [0, 1, 2, 3, ...] << lengthTracking + // [2, 3, ...] << lengthTrackingWithOffset + + fixedLength.copyWithin(0, 2); + assert.compareArray(ToNumbers(fixedLength), [ + 2, + 3, + 2, + 3 + ]); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + fixedLengthWithOffset.copyWithin(0, 1); + assert.compareArray(ToNumbers(fixedLengthWithOffset), [ + 3, + 3 + ]); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + lengthTracking.copyWithin(0, 2); + assert.compareArray(ToNumbers(lengthTracking), [ + 2, + 3, + 2, + 3 + ]); + lengthTrackingWithOffset.copyWithin(0, 1); + assert.compareArray(ToNumbers(lengthTrackingWithOffset), [ + 3, + 3 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 3; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + + // Orig. array: [0, 1, 2] + // [0, 1, 2, ...] << lengthTracking + // [2, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + fixedLength.copyWithin(0, 1); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.copyWithin(0, 1); + }); + assert.compareArray(ToNumbers(lengthTracking), [ + 0, + 1, + 2 + ]); + lengthTracking.copyWithin(0, 1); + assert.compareArray(ToNumbers(lengthTracking), [ + 1, + 2, + 2 + ]); + lengthTrackingWithOffset.copyWithin(0, 1); + assert.compareArray(ToNumbers(lengthTrackingWithOffset), [2]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + taWrite[0] = MayNeedBigInt(taWrite, 0); + assert.throws(TypeError, () => { + fixedLength.copyWithin(0, 1, 1); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.copyWithin(0, 1, 1); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.copyWithin(0, 1, 1); + }); + assert.compareArray(ToNumbers(lengthTracking), [0]); + lengthTracking.copyWithin(0, 0, 1); + assert.compareArray(ToNumbers(lengthTracking), [0]); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.copyWithin(0, 1, 1); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.copyWithin(0, 1, 1); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.copyWithin(0, 1, 1); + }); + assert.compareArray(ToNumbers(lengthTracking), []); + lengthTracking.copyWithin(0, 0, 1); + assert.compareArray(ToNumbers(lengthTracking), []); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + + // Orig. array: [0, 1, 2, 3, 4, 5] + // [0, 1, 2, 3] << fixedLength + // [2, 3] << fixedLengthWithOffset + // [0, 1, 2, 3, 4, 5, ...] << lengthTracking + // [2, 3, 4, 5, ...] << lengthTrackingWithOffset + + fixedLength.copyWithin(0, 2); + assert.compareArray(ToNumbers(fixedLength), [ + 2, + 3, + 2, + 3 + ]); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + fixedLengthWithOffset.copyWithin(0, 1); + assert.compareArray(ToNumbers(fixedLengthWithOffset), [ + 3, + 3 + ]); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + + // [0, 1, 2, 3, 4, 5, ...] << lengthTracking + // target ^ ^ start + lengthTracking.copyWithin(0, 2); + assert.compareArray(ToNumbers(lengthTracking), [ + 2, + 3, + 4, + 5, + 4, + 5 + ]); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + + // [2, 3, 4, 5, ...] << lengthTrackingWithOffset + // target ^ ^ start + lengthTrackingWithOffset.copyWithin(0, 1); + assert.compareArray(ToNumbers(lengthTrackingWithOffset), [ + 3, + 4, + 5, + 5 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js new file mode 100644 index 00000000000..08292a4c205 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Return abrupt if end is a Symbol. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var s = Symbol(1); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.copyWithin(0, 0, s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js new file mode 100644 index 00000000000..07250c58462 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Return abrupt from ToInteger(end). +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var o1 = { + valueOf: function() { + throw new Test262Error(); + } + }; + var sample = new TA(); + assert.throws(Test262Error, function() { + sample.copyWithin(0, 0, o1); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js new file mode 100644 index 00000000000..70423988af2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Return abrupt if start is a Symbol. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 5. Let relativeStart be ? ToInteger(start). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var s = Symbol(1); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.copyWithin(0, s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js new file mode 100644 index 00000000000..a30d1ee547a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Return abrupt from ToInteger(start). +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 5. Let relativeStart be ? ToInteger(start). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var o = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var err = { + valueOf: function() { + throw new Error("ToInteger(start) runs before ToInteger(end)"); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(Test262Error, function() { + sample.copyWithin(0, o, err); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js new file mode 100644 index 00000000000..4d6ae32b8c1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Return abrupt if target is a Symbol. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 3. Let relativeTarget be ? ToInteger(target). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var s = Symbol(1); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.copyWithin(s, 0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js new file mode 100644 index 00000000000..5c020ad3a23 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Return abrupt from ToInteger(target). +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 3. Let relativeTarget be ? ToInteger(target). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var o = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(Test262Error, function() { + sample.copyWithin(o); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..2b387156859 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.copyWithin, + 'function', + 'implements SendableTypedArray.prototype.copyWithin' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.copyWithin(0, 0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.copyWithin(0, 0); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the copyWithin operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.copyWithin(0, 0); + throw new Test262Error('copyWithin completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js new file mode 100644 index 00000000000..fd9f178684e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Returns `this`. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + 13. Return O. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(); + var result1 = sample1.copyWithin(0, 0); + + assert.sameValue(result1, sample1); + + var sample2 = new TA([1, 2, 3]); + var result2 = sample2.copyWithin(1, 0); + + assert.sameValue(result2, sample2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-object.js new file mode 100644 index 00000000000..a4ff468e198 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-object.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var copyWithin = SendableTypedArray.prototype.copyWithin; + +assert.throws(TypeError, function() { + copyWithin.call(undefined, 0, 0); +}, "this is undefined"); + +assert.throws(TypeError, function() { + copyWithin.call(null, 0, 0); +}, "this is null"); + +assert.throws(TypeError, function() { + copyWithin.call(42, 0, 0); +}, "this is 42"); + +assert.throws(TypeError, function() { + copyWithin.call("1", 0, 0); +}, "this is a string"); + +assert.throws(TypeError, function() { + copyWithin.call(true, 0, 0); +}, "this is true"); + +assert.throws(TypeError, function() { + copyWithin.call(false, 0, 0); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + copyWithin.call(s, 0, 0); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..667d124671e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var copyWithin = SendableTypedArray.prototype.copyWithin; + +assert.throws(TypeError, function() { + copyWithin.call({}, 0, 0); +}, "this is an Object"); + +assert.throws(TypeError, function() { + copyWithin.call([], 0, 0); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + copyWithin.call(ab, 0, 0); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + copyWithin.call(dv, 0, 0); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js new file mode 100644 index 00000000000..a1604a5661d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.copywithin +description: > + If `end` is undefined, set final position to `this.length`. +info: | + 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) + + %SendableTypedArray%.prototype.copyWithin is a distinct function that implements the + same algorithm as Array.prototype.copyWithin as defined in 22.1.3.3 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length" and the actual copying of values in step 12 + must be performed in a manner that preserves the bit-level encoding of the + source data. + + ... + + 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) + + ... + 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, 1, undefined), + [1, 2, 3, 3] + ), + '[0, 1, 2, 3].copyWithin(0, 1, undefined) -> [1, 2, 3]' + ); + + assert( + compareArray( + new TA([0, 1, 2, 3]).copyWithin(0, 1), + [1, 2, 3, 3] + ), + '[0, 1, 2, 3].copyWithin(0, 1) -> [1, 2, 3, 3]' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js new file mode 100644 index 00000000000..3b2baa5e0a9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.entries(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/iter-prototype.js new file mode 100644 index 00000000000..b18f8956c8d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/iter-prototype.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: > + The prototype of the returned iterator is ArrayIteratorPrototype +info: | + 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) + + ... + 3. Return CreateArrayIterator(O, "key+value"). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.iterator, TypedArray] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([0n, 42n, 64n]); + var iter = sample.entries(); + + assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..fa398cc4003 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.entries, + 'function', + 'implements SendableTypedArray.prototype.entries' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.entries(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.entries(); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the entries operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.entries(); + throw new Test262Error('entries completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-itor.js b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-itor.js new file mode 100644 index 00000000000..7f1035c291e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-itor.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: Return an iterator for the entries. +info: | + 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) + + ... + 3. Return CreateArrayIterator(O, "key+value"). +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var typedArray = new TA([0n, 42n, 64n]); + var itor = typedArray.entries(); + + var next = itor.next(); + assert(compareArray(next.value, [0, 0n])); + assert.sameValue(next.done, false); + + next = itor.next(); + assert(compareArray(next.value, [1, 42n])); + assert.sameValue(next.done, false); + + next = itor.next(); + assert(compareArray(next.value, [2, 64n])); + assert.sameValue(next.done, false); + + next = itor.next(); + assert.sameValue(next.value, undefined); + assert.sameValue(next.done, true); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js new file mode 100644 index 00000000000..a39bb1f7c5c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.entries(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-func.js new file mode 100644 index 00000000000..6754771eed1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-func.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Let valid be ValidateSendableTypedArray(O). + 3. ReturnIfAbrupt(valid). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var entries = SendableTypedArray.prototype.entries; + +assert.sameValue(typeof entries, 'function'); + +assert.throws(TypeError, function() { + entries(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-method.js new file mode 100644 index 00000000000..e50c14189d8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-method.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Let valid be ValidateSendableTypedArray(O). + 3. ReturnIfAbrupt(valid). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.entries, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.entries(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js new file mode 100644 index 00000000000..e6e441ee701 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: > + The prototype of the returned iterator is ArrayIteratorPrototype +info: | + 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) + + ... + 3. Return CreateArrayIterator(O, "key+value"). +includes: [testTypedArray.js] +features: [Symbol.iterator, TypedArray] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([0, 42, 64]); + var iter = sample.entries(); + + assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/length.js b/test/sendable/builtins/TypedArray/prototype/entries/length.js new file mode 100644 index 00000000000..f96f4cf7246 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: > + %SendableTypedArray%.prototype.entries.length is 0. +info: | + %SendableTypedArray%.prototype.entries ( ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.entries, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/name.js b/test/sendable/builtins/TypedArray/prototype/entries/name.js new file mode 100644 index 00000000000..a0158942cd6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: > + %SendableTypedArray%.prototype.entries.name is "entries". +info: | + %SendableTypedArray%.prototype.entries ( ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.entries, "name", { + value: "entries", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/entries/not-a-constructor.js new file mode 100644 index 00000000000..b40b212ae17 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.entries 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.entries), + false, + 'isConstructor(SendableTypedArray.prototype.entries) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.entries(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/entries/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/entries/prop-desc.js new file mode 100644 index 00000000000..3a4beff9e88 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: > + "entries" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'entries', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..9cca324076a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,121 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: > + SendableTypedArray.p.entries behaves correctly when receiver is backed by a resizable + buffer and resized mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +// Iterating with entries() (the 4 loops below). +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + // The fixed length array is not affected by resizing. + TestIterationAndResize(fixedLength.entries(), [ + [ + 0, + 0 + ], + [ + 1, + 2 + ], + [ + 2, + 4 + ], + [ + 3, + 6 + ] + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + // The fixed length array is not affected by resizing. + TestIterationAndResize(fixedLengthWithOffset.entries(), [ + [ + 0, + 4 + ], + [ + 1, + 6 + ] + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + TestIterationAndResize(lengthTracking.entries(), [ + [ + 0, + 0 + ], + [ + 1, + 2 + ], + [ + 2, + 4 + ], + [ + 3, + 6 + ], + [ + 4, + 0 + ], + [ + 5, + 0 + ] + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + TestIterationAndResize(lengthTrackingWithOffset.entries(), [ + [ + 0, + 4 + ], + [ + 1, + 6 + ], + [ + 2, + 0 + ], + [ + 3, + 0 + ] + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..5f990c29457 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: > + SendableTypedArray.p.entries behaves correctly when receiver is backed by resizable + buffer that is shrunk mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +// Iterating with entries() (the 4 loops below). +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + + // The fixed length array goes out of bounds when the RAB is resized. + assert.throws(TypeError, () => { + TestIterationAndResize(fixedLength.entries(), null, rab, 2, 3 * ctor.BYTES_PER_ELEMENT); + }); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + + // The fixed length array goes out of bounds when the RAB is resized. + assert.throws(TypeError, () => { + TestIterationAndResize(fixedLengthWithOffset.entries(), null, rab, 1, 3 * ctor.BYTES_PER_ELEMENT); + }); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + TestIterationAndResize(lengthTracking.entries(), [ + [ + 0, + 0 + ], + [ + 1, + 2 + ], + [ + 2, + 4 + ] + ], rab, 2, 3 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + TestIterationAndResize(lengthTrackingWithOffset.entries(), [ + [ + 0, + 4 + ], + [ + 1, + 6 + ] + ], rab, 2, 3 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer.js new file mode 100644 index 00000000000..804aced1fb9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer.js @@ -0,0 +1,188 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + SendableTypedArray.p.values behaves correctly when receiver is backed by resizable + buffer +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function ValuesFromSendableTypedArrayEntries(ta) { + let result = []; + let expectedKey = 0; + for (let [key, value] of ta.entries()) { + assert.sameValue(key, expectedKey, 'SendableTypedArray method .entries should return `expectedKey`.'); + ++expectedKey; + result.push(Number(value)); + } + return result; +} + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + assert.compareArray(ValuesFromSendableTypedArrayEntries(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ValuesFromSendableTypedArrayEntries(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(ValuesFromSendableTypedArrayEntries(lengthTracking), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ValuesFromSendableTypedArrayEntries(lengthTrackingWithOffset), [ + 4, + 6 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + // SendableTypedArray.prototype.{entries, keys, values} throw right away when + // called. Array.prototype.{entries, keys, values} don't throw, but when + // we try to iterate the returned ArrayIterator, that throws. + assert.throws(TypeError, () => { + fixedLength.entries(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.entries(); + }); + + assert.throws(TypeError, () => { + Array.from(fixedLength.entries()); + }); + assert.throws(TypeError, () => { + Array.from(fixedLengthWithOffset.entries()); + }); + assert.compareArray(ValuesFromSendableTypedArrayEntries(lengthTracking), [ + 0, + 2, + 4 + ]); + assert.compareArray(ValuesFromSendableTypedArrayEntries(lengthTrackingWithOffset), [4]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.entries(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.entries(); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.entries(); + }); + + assert.throws(TypeError, () => { + Array.from(fixedLength.entries()); + }); + assert.throws(TypeError, () => { + Array.from(fixedLengthWithOffset.entries()); + }); + assert.throws(TypeError, () => { + Array.from(lengthTrackingWithOffset.entries()); + }); + assert.compareArray(ValuesFromSendableTypedArrayEntries(lengthTracking), [0]); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.entries(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.entries(); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.entries(); + }); + + assert.throws(TypeError, () => { + Array.from(fixedLength.entries()); + }); + assert.throws(TypeError, () => { + Array.from(fixedLengthWithOffset.entries()); + }); + assert.throws(TypeError, () => { + Array.from(lengthTrackingWithOffset.entries()); + }); + assert.compareArray(ValuesFromSendableTypedArrayEntries(lengthTracking), []); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert.compareArray(ValuesFromSendableTypedArrayEntries(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ValuesFromSendableTypedArrayEntries(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(ValuesFromSendableTypedArrayEntries(lengthTracking), [ + 0, + 2, + 4, + 6, + 8, + 10 + ]); + assert.compareArray(ValuesFromSendableTypedArrayEntries(lengthTrackingWithOffset), [ + 4, + 6, + 8, + 10 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..722eff8b822 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.entries, + 'function', + 'implements SendableTypedArray.prototype.entries' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.entries(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.entries(); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the entries operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.entries(); + throw new Test262Error('entries completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js b/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js new file mode 100644 index 00000000000..6ab02ed440b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: Return an iterator for the entries. +info: | + 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) + + ... + 3. Return CreateArrayIterator(O, "key+value"). +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +var sample = [0, 42, 64]; + +testWithSendableTypedArrayConstructors(function(TA) { + var typedArray = new TA(sample); + var itor = typedArray.entries(); + + var next = itor.next(); + assert(compareArray(next.value, [0, 0])); + assert.sameValue(next.done, false); + + next = itor.next(); + assert(compareArray(next.value, [1, 42])); + assert.sameValue(next.done, false); + + next = itor.next(); + assert(compareArray(next.value, [2, 64])); + assert.sameValue(next.done, false); + + next = itor.next(); + assert.sameValue(next.value, undefined); + assert.sameValue(next.done, true); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-object.js new file mode 100644 index 00000000000..edad5e15856 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-object.js @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var entries = SendableTypedArray.prototype.entries; + +assert.throws(TypeError, function() { + entries.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + entries.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + entries.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + entries.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + entries.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + entries.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + entries.call(s); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..3fbce89978e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.entries +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var entries = SendableTypedArray.prototype.entries; + +assert.throws(TypeError, function() { + entries.call({}); +}, "this is an Object"); + +assert.throws(TypeError, function() { + entries.call([]); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + entries.call(ab); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + entries.call(dv); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js new file mode 100644 index 00000000000..6d2245d087a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + thisArg does not affect callbackfn arguments +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + var results = []; + var thisArg = ["test262", 0, "ecma262", 0]; + + sample.every(function() { + results.push(arguments); + return true; + }, thisArg); + + assert.sameValue(results.length, 3, "results.length"); + assert.sameValue(thisArg.length, 4, "thisArg.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42n, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43n, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44n, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js new file mode 100644 index 00000000000..144d262f7d4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + callbackfn arguments +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + var results = []; + + sample.every(function() { + results.push(arguments); + return true; + }); + + assert.sameValue(results.length, 3, "results.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42n, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43n, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44n, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js new file mode 100644 index 00000000000..9455a9860c3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + Instance buffer can be detached during loop +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [detachArrayBuffer.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.every(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + return true; + }); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js new file mode 100644 index 00000000000..3c703c8e98a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + Does not interact over non-integer properties +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7n, 8n]); + + var results = []; + + sample.foo = 42; + sample[Symbol("1")] = 43; + + sample.every(function() { + results.push(arguments); + return true; + }); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0][1], 0, "results[0][1] - key"); + assert.sameValue(results[1][1], 1, "results[1][1] - key"); + + assert.sameValue(results[0][0], 7n, "results[0][0] - value"); + assert.sameValue(results[1][0], 8n, "results[1][0] - value"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js new file mode 100644 index 00000000000..290e9887f16 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: Throws a TypeError if callbackfn is not callable +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 3. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + assert.throws(TypeError, function() { + sample.every(); + }, "no args"); + + assert.throws(TypeError, function() { + sample.every(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.every(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.every("abc"); + }, "string"); + + assert.throws(TypeError, function() { + sample.every(1); + }, "number"); + + assert.throws(TypeError, function() { + sample.every(NaN); + }, "NaN"); + + assert.throws(TypeError, function() { + sample.every(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.every(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.every({}); + }, "{}"); + + assert.throws(TypeError, function() { + sample.every(sample); + }, "same typedArray instance"); + + assert.throws(TypeError, function() { + sample.every(Symbol("1")); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js new file mode 100644 index 00000000000..fd00b13ed25 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + callbackfn is not called on empty instances +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var called = 0; + + new TA().every(function() { + called++; + }); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js new file mode 100644 index 00000000000..07196fda61f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + The callbackfn return does not change the instance +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n]); + + sample.every(function() { + return 43; + }); + + assert.sameValue(sample[0], 40n, "[0] == 40"); + assert.sameValue(sample[1], 41n, "[1] == 41"); + assert.sameValue(sample[2], 42n, "[2] == 42"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js new file mode 100644 index 00000000000..b4d280241ae --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: Returns abrupt from callbackfn +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + assert.throws(Test262Error, function() { + sample.every(function() { + throw new Test262Error(); + }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js new file mode 100644 index 00000000000..7ae098bea5d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Reflect.set, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + var newVal = 0n; + + sample.every(function(val, i) { + if (i > 0) { + assert.sameValue( + sample[i - 1], newVal - 1n, + "get the changed value during the loop" + ); + assert.sameValue( + Reflect.set(sample, 0, 7n), + true, + "re-set a value for sample[0]" + ); + } + assert.sameValue( + Reflect.set(sample, i, newVal), + true, + "set value during iteration" + ); + + newVal++; + + return true; + }); + + assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7"); + assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1"); + assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-this.js new file mode 100644 index 00000000000..e3c950e2917 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-this.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + callbackfn `this` value +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + ... + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var expected = (function() { return this; })(); +var thisArg = {}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var results1 = []; + + sample.every(function() { + results1.push(this); + return true; + }); + + assert.sameValue(results1.length, 3, "results1"); + assert.sameValue(results1[0], expected, "without thisArg - [0]"); + assert.sameValue(results1[1], expected, "without thisArg - [1]"); + assert.sameValue(results1[2], expected, "without thisArg - [2]"); + + var results2 = []; + + sample.every(function() { + results2.push(this); + return true; + }, thisArg); + + assert.sameValue(results2.length, 3, "results2"); + assert.sameValue(results2[0], thisArg, "using thisArg - [0]"); + assert.sameValue(results2[1], thisArg, "using thisArg - [1]"); + assert.sameValue(results2[2], thisArg, "using thisArg - [2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/detached-buffer.js new file mode 100644 index 00000000000..631b8e2ff8a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var callbackfn = function() { + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.every(callbackfn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..83362816d01 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n]); + var calls = 0; + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.every(function() { + calls++; + return true; + }); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert.sameValue(calls, 2, "iterations are not affected by custom length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..7896c2a97a0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.every, + 'function', + 'implements SendableTypedArray.prototype.every' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.every(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.every(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the every operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.every(() => {}); + throw new Test262Error('every completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js new file mode 100644 index 00000000000..250405a9aac --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + Returns false if any callbackfn call returns a coerced false. +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 7. Return true. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(42); + + [ + false, + "", + 0, + -0, + NaN, + undefined, + null + ].forEach(function(val) { + var called = 0; + var result = sample.every(function() { + called++; + if (called === 1) { + return true; + } + return val; + }); + assert.sameValue(called, 2, "callbackfn called until it returned " + val); + assert.sameValue(result, false, "result is false when it returned " + val); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js new file mode 100644 index 00000000000..1a255cc7c4e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + Returns true if every callbackfn returns a coerced true. +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 7. Return true. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var called = 0; + var values = [ + true, + 1, + "test262", + Symbol("1"), + {}, + [], + -1, + Infinity, + -Infinity, + 0.1, + -0.1 + ]; + var sample = new TA(values.length); + var result = sample.every(function() { + called++; + return values.unshift(); + }); + + assert.sameValue(called, sample.length, "callbackfn called for each index"); + assert.sameValue(result, true, "return is true"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/values-are-not-cached.js new file mode 100644 index 00000000000..b8713376c36 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/values-are-not-cached.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + Integer indexed values are not cached before iteration +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + sample.every(function(v, i) { + if (i < sample.length - 1) { + sample[i+1] = 42n; + } + + assert.sameValue( + v, 42n, "method does not cache values before callbackfn calls" + ); + return true; + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js new file mode 100644 index 00000000000..a3536b6e421 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + thisArg does not affect callbackfn arguments +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + var results = []; + var thisArg = ["test262", 0, "ecma262", 0]; + + sample.every(function() { + results.push(arguments); + return true; + }, thisArg); + + assert.sameValue(results.length, 3, "results.length"); + assert.sameValue(thisArg.length, 4, "thisArg.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js new file mode 100644 index 00000000000..c25b59e3153 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + callbackfn arguments +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + var results = []; + + sample.every(function() { + results.push(arguments); + return true; + }); + + assert.sameValue(results.length, 3, "results.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js new file mode 100644 index 00000000000..fd6819e40e0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + Instance buffer can be detached during loop +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 5. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [detachArrayBuffer.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.every(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + return true; + }); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js new file mode 100644 index 00000000000..e931d9fdc75 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + Does not interact over non-integer properties +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7, 8]); + + var results = []; + + sample.foo = 42; + sample[Symbol("1")] = 43; + + sample.every(function() { + results.push(arguments); + return true; + }); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0][1], 0, "results[0][1] - key"); + assert.sameValue(results[1][1], 1, "results[1][1] - key"); + + assert.sameValue(results[0][0], 7, "results[0][0] - value"); + assert.sameValue(results[1][0], 8, "results[1][0] - value"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js new file mode 100644 index 00000000000..378ba78f612 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: Throws a TypeError if callbackfn is not callable +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 3. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + assert.throws(TypeError, function() { + sample.every(); + }, "no args"); + + assert.throws(TypeError, function() { + sample.every(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.every(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.every("abc"); + }, "string"); + + assert.throws(TypeError, function() { + sample.every(1); + }, "number"); + + assert.throws(TypeError, function() { + sample.every(NaN); + }, "NaN"); + + assert.throws(TypeError, function() { + sample.every(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.every(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.every({}); + }, "{}"); + + assert.throws(TypeError, function() { + sample.every(sample); + }, "same typedArray instance"); + + assert.throws(TypeError, function() { + sample.every(Symbol("1")); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js new file mode 100644 index 00000000000..f100e4b138d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + callbackfn is not called on empty instances +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var called = 0; + + new TA().every(function() { + called++; + }); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js new file mode 100644 index 00000000000..f8858f0197e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: Instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var finalElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = sample.every(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + finalElement = undefined; + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + finalElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return true; + }); + + assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)'); + assert.compareArray(indices, [0, 1, 2], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, true, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = sample.every(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return true; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, true, 'result (grow)'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js new file mode 100644 index 00000000000..9148229df1f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + The callbackfn return does not change the instance +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42]); + + sample.every(function() { + return 43; + }); + + assert.sameValue(sample[0], 40, "[0] == 40"); + assert.sameValue(sample[1], 41, "[1] == 41"); + assert.sameValue(sample[2], 42, "[2] == 42"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js new file mode 100644 index 00000000000..23a37da5b66 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: Returns abrupt from callbackfn +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + assert.throws(Test262Error, function() { + sample.every(function() { + throw new Test262Error(); + }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js new file mode 100644 index 00000000000..7a2c6f5588e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [Reflect.set, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + var newVal = 0; + + sample.every(function(val, i) { + if (i > 0) { + assert.sameValue( + sample[i - 1], newVal - 1, + "get the changed value during the loop" + ); + assert.sameValue( + Reflect.set(sample, 0, 7), + true, + "re-set a value for sample[0]" + ); + } + assert.sameValue( + Reflect.set(sample, i, newVal), + true, + "set value during iteration" + ); + + newVal++; + + return true; + }); + + assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7"); + assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1"); + assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js new file mode 100644 index 00000000000..eae584efff3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + callbackfn `this` value +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + ... + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var expected = (function() { return this; })(); +var thisArg = {}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var results1 = []; + + sample.every(function() { + results1.push(this); + return true; + }); + + assert.sameValue(results1.length, 3, "results1"); + assert.sameValue(results1[0], expected, "without thisArg - [0]"); + assert.sameValue(results1[1], expected, "without thisArg - [1]"); + assert.sameValue(results1[2], expected, "without thisArg - [2]"); + + var results2 = []; + + sample.every(function() { + results2.push(this); + return true; + }, thisArg); + + assert.sameValue(results2.length, 3, "results2"); + assert.sameValue(results2[0], thisArg, "using thisArg - [0]"); + assert.sameValue(results2[1], thisArg, "using thisArg - [1]"); + assert.sameValue(results2[2], thisArg, "using thisArg - [2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js new file mode 100644 index 00000000000..5aaeb259d60 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var callbackfn = function() { + throw new Test262Error(); +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.every(callbackfn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..40598c6931e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43]); + var calls = 0; + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.every(function() { + calls++; + return true; + }); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert.sameValue(calls, 2, "iterations are not affected by custom length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/every/invoked-as-func.js new file mode 100644 index 00000000000..c2327c12b9f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/invoked-as-func.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var every = SendableTypedArray.prototype.every; + +assert.sameValue(typeof every, 'function'); + +assert.throws(TypeError, function() { + every(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/every/invoked-as-method.js new file mode 100644 index 00000000000..b033ed67e26 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/invoked-as-method.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.every, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.every(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/length.js b/test/sendable/builtins/TypedArray/prototype/every/length.js new file mode 100644 index 00000000000..a5a87402c56 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + %SendableTypedArray%.prototype.every.length is 1. +info: | + %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.every, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/name.js b/test/sendable/builtins/TypedArray/prototype/every/name.js new file mode 100644 index 00000000000..0fc415b2a09 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + %SendableTypedArray%.prototype.every.name is "every". +info: | + %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.every, "name", { + value: "every", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/every/not-a-constructor.js new file mode 100644 index 00000000000..f8cdb9f0bf3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.every 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.every), + false, + 'isConstructor(SendableTypedArray.prototype.every) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.every(() => {}); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/every/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/every/prop-desc.js new file mode 100644 index 00000000000..1b61c14e22c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + "every" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'every', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..bd91a9f2eed --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + SendableTypedArray.p.every behaves correctly when receiver is backed by resizable + buffer that is grown mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(n) { + // Returns true by default. + return CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(fixedLength.every(ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(fixedLengthWithOffset.every(ResizeMidIteration)); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(lengthTracking.every(ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(lengthTrackingWithOffset.every(ResizeMidIteration)); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..eafb81b374d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + SendableTypedArray.p.every behaves correctly when receiver is backed by resizable + buffer that is shrunk mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(n) { + // Returns true by default. + return CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(fixedLength.every(ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(fixedLengthWithOffset.every(ResizeMidIteration)); + assert.compareArray(values, [ + 4, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(lengthTracking.every(ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2, + 4, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(lengthTrackingWithOffset.every(ResizeMidIteration)); + assert.compareArray(values, [ + 4, + undefined + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer.js new file mode 100644 index 00000000000..cd3a6c291d1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer.js @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + SendableTypedArray.p.every behaves correctly when the receiver is backed by + resizable buffer +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + function div3(n) { + return Number(n) % 3 == 0; + } + function even(n) { + return Number(n) % 2 == 0; + } + function over10(n) { + return Number(n) > 10; + } + assert(!fixedLength.every(div3)); + assert(fixedLength.every(even)); + assert(!fixedLengthWithOffset.every(div3)); + assert(fixedLengthWithOffset.every(even)); + assert(!lengthTracking.every(div3)); + assert(lengthTracking.every(even)); + assert(!lengthTrackingWithOffset.every(div3)); + assert(lengthTrackingWithOffset.every(even)); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + // Calling .every on an out of bounds TA throws. + assert.throws(TypeError, () => { + fixedLength.every(div3); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.every(div3); + }); + + assert(!lengthTracking.every(div3)); + assert(lengthTracking.every(even)); + assert(!lengthTrackingWithOffset.every(div3)); + assert(lengthTrackingWithOffset.every(even)); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + // Calling .every on an out of bounds TA throws. + assert.throws(TypeError, () => { + fixedLength.every(div3); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.every(div3); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.every(div3); + }); + + assert(lengthTracking.every(div3)); + assert(lengthTracking.every(even)); + + // Shrink to zero. + rab.resize(0); + // Calling .every on an out of bounds TA throws. + assert.throws(TypeError, () => { + fixedLength.every(div3); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.every(div3); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.every(div3); + }); + + assert(lengthTracking.every(div3)); + assert(lengthTracking.every(even)); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert(!fixedLength.every(div3)); + assert(fixedLength.every(even)); + assert(!fixedLengthWithOffset.every(div3)); + assert(fixedLengthWithOffset.every(even)); + assert(!lengthTracking.every(div3)); + assert(lengthTracking.every(even)); + assert(!lengthTrackingWithOffset.every(div3)); + assert(lengthTrackingWithOffset.every(even)); +} diff --git a/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..4c2ac392753 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.every, + 'function', + 'implements SendableTypedArray.prototype.every' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.every(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.every(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the every operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.every(() => {}); + throw new Test262Error('every completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js b/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js new file mode 100644 index 00000000000..2b049a41b8d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + Returns false if any callbackfn call returns a coerced false. +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 7. Return true. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(42); + + [ + false, + "", + 0, + -0, + NaN, + undefined, + null + ].forEach(function(val) { + var called = 0; + var result = sample.every(function() { + called++; + if (called === 1) { + return true; + } + return val; + }); + assert.sameValue(called, 2, "callbackfn called until it returned " + val); + assert.sameValue(result, false, "result is false when it returned " + val); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js b/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js new file mode 100644 index 00000000000..10d52fd59e9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + Returns true if every callbackfn returns a coerced true. +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 7. Return true. +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var called = 0; + var values = [ + true, + 1, + "test262", + Symbol("1"), + {}, + [], + -1, + Infinity, + -Infinity, + 0.1, + -0.1 + ]; + var sample = new TA(values.length); + var result = sample.every(function() { + called++; + return values.unshift(); + }); + + assert.sameValue(called, sample.length, "callbackfn called for each index"); + assert.sameValue(result, true, "return is true"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/every/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/every/this-is-not-object.js new file mode 100644 index 00000000000..907ed972042 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/this-is-not-object.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var every = SendableTypedArray.prototype.every; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + every.call(undefined, callbackfn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + every.call(null, callbackfn); +}, "this is null"); + +assert.throws(TypeError, function() { + every.call(42, callbackfn); +}, "this is 42"); + +assert.throws(TypeError, function() { + every.call("1", callbackfn); +}, "this is a string"); + +assert.throws(TypeError, function() { + every.call(true, callbackfn); +}, "this is true"); + +assert.throws(TypeError, function() { + every.call(false, callbackfn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + every.call(s, callbackfn); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..9766fc40796 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var every = SendableTypedArray.prototype.every; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + every.call({}, callbackfn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + every.call([], callbackfn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + every.call(ab, callbackfn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + every.call(dv, callbackfn); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js new file mode 100644 index 00000000000..5d49761829a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.every +description: > + Integer indexed values are not cached before iteration +info: | + 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.every is a distinct function that implements the same + algorithm as Array.prototype.every as defined in 22.1.3.5 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.5 Array.prototype.every ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + sample.every(function(v, i) { + if (i < sample.length - 1) { + sample[i+1] = 42; + } + + assert.sameValue( + v, 42, "method does not cache values before callbackfn calls" + ); + return true; + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/coerced-indexes.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/coerced-indexes.js new file mode 100644 index 00000000000..2732e1b2f54 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/coerced-indexes.js @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills elements from coerced to Integer `start` and `end` values +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 3. Let relativeStart be ? ToInteger(start). + 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be + min(relativeStart, len). + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray(new TA([0n, 0n]).fill(1n, undefined), [1n, 1n]), + '`undefined` start coerced to 0' + ); + + assert( + compareArray(new TA([0n, 0n]).fill(1n, 0, undefined), [1n, 1n]), + 'If end is undefined, let relativeEnd be len' + ); + + assert( + compareArray(new TA([0n, 0n]).fill(1n, null), [1n, 1n]), + '`null` start coerced to 0' + ); + + assert( + compareArray(new TA([0n, 0n]).fill(1n, 0, null), [0n, 0n]), + '`null` end coerced to 0' + ); + + assert( + compareArray(new TA([0n, 0n]).fill(1n, true), [0n, 1n]), + '`true` start coerced to 1' + ); + + assert( + compareArray(new TA([0n, 0n]).fill(1n, 0, true), [1n, 0n]), + '`true` end coerced to 1' + ); + + assert( + compareArray(new TA([0n, 0n]).fill(1n, false), [1n, 1n]), + '`false` start coerced to 0' + ); + + assert( + compareArray(new TA([0n, 0n]).fill(1n, 0, false), [0n, 0n]), + '`false` end coerced to 0' + ); + + assert( + compareArray(new TA([0n, 0n]).fill(1n, NaN), [1n, 1n]), + '`NaN` start coerced to 0' + ); + + assert( + compareArray(new TA([0n, 0n]).fill(1n, 0, NaN), [0n, 0n]), + '`NaN` end coerced to 0' + ); + + assert( + compareArray(new TA([0n, 0n]).fill(1n, '1'), [0n, 1n]), + 'string start coerced' + ); + + assert( + compareArray(new TA([0n, 0n]).fill(1n, 0, '1'), [1n, 0n]), + 'string end coerced' + ); + + assert( + compareArray(new TA([0n, 0n]).fill(1n, 1.5), [0n, 1n]), + 'start as a float number coerced' + ); + + assert( + compareArray(new TA([0n, 0n]).fill(1n, 0, 1.5), [1n, 0n]), + 'end as a float number coerced' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/detached-buffer.js new file mode 100644 index 00000000000..1622d6917c5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/detached-buffer.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.fill(obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js new file mode 100644 index 00000000000..78ed463ecbd --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills all the elements with non numeric values values. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + ... + 3. If O.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array", + let value be ? ToBigInt(value). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + var n = 1n; + sample.fill({ valueOf() { return n++; } }); + + assert.sameValue(n, 2n, "additional unexpected ToBigInt() calls"); + assert.sameValue(sample[0], 1n, "incorrect ToNumber result in index 0"); + assert.sameValue(sample[1], 1n, "incorrect ToNumber result in index 1"); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js new file mode 100644 index 00000000000..313551ae454 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills all the elements from a with a custom start and end indexes. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 3. Let relativeStart be ? ToInteger(start). + 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be + min(relativeStart, len). + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let + final be min(relativeEnd, len). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert(compareArray(new TA([0n, 0n, 0n]).fill(8n, 1, 2), [0n, 8n, 0n])); + assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -3, 4), [0n, 0n, 8n, 8n, 0n])); + assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -2, -1), [0n, 0n, 0n, 8n, 0n])); + assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -1, -3), [0n, 0n, 0n, 0n, 0n])); + assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, 1, 3), [0n, 8n, 8n, 0n, 0n])); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js new file mode 100644 index 00000000000..d76d4c97c2c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills all the elements with non numeric values values. +info: | + %SendableTypedArray%.prototype.fill ( value [ , start [ , end ] ] ) + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value). + Otherwise, set value to ? ToNumber(value). + Let relativeStart be ? ToIntegerOrInfinity(start). + If relativeStart is -Infinity, let k be 0. + Else if relativeStart < 0, let k be max(len + relativeStart, 0). + Else, let k be min(relativeStart, len). + If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + If relativeEnd is -Infinity, let final be 0. + Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). + Else, let final be min(relativeEnd, len). + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + Repeat, while k < final, + Let Pk be ! ToString(F(k)). + Perform ! Set(O, Pk, value, true). + Set k to k + 1. + Return O. + + IntegerIndexedElementSet ( O, index, value ) + + Assert: O is an Integer-Indexed exotic object. + If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). + Otherwise, let numValue be ? ToNumber(value). + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then + Let offset be O.[[ByteOffset]]. + Let arrayTypeName be the String value of O.[[TypedArrayName]]. + Let elementSize be the Element Size value specified in Table 62 for arrayTypeName. + Let indexedPosition be (ℝ(index) × elementSize) + offset. + Let elementType be the Element Type value in Table 62 for arrayTypeName. + Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered). + Return NormalCompletion(undefined). + + +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42n]); + + assert.throws(TypeError, function() { + sample.fill(undefined); + }, "abrupt completion from undefined"); + + assert.throws(TypeError, function() { + sample.fill(null); + }, "abrupt completion from null"); + + assert.throws(SyntaxError, function() { + sample.fill("nonsense"); + }, "abrupt completion from string"); + +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js new file mode 100644 index 00000000000..6f007e2730c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills all the elements with non numeric values values. +info: | + %SendableTypedArray%.prototype.fill ( value [ , start [ , end ] ] ) + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value). + Otherwise, set value to ? ToNumber(value). + Let relativeStart be ? ToIntegerOrInfinity(start). + If relativeStart is -Infinity, let k be 0. + Else if relativeStart < 0, let k be max(len + relativeStart, 0). + Else, let k be min(relativeStart, len). + If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + If relativeEnd is -Infinity, let final be 0. + Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). + Else, let final be min(relativeEnd, len). + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + Repeat, while k < final, + Let Pk be ! ToString(F(k)). + Perform ! Set(O, Pk, value, true). + Set k to k + 1. + Return O. + + IntegerIndexedElementSet ( O, index, value ) + + Assert: O is an Integer-Indexed exotic object. + If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). + Otherwise, let numValue be ? ToNumber(value). + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then + Let offset be O.[[ByteOffset]]. + Let arrayTypeName be the String value of O.[[TypedArrayName]]. + Let elementSize be the Element Size value specified in Table 62 for arrayTypeName. + Let indexedPosition be (ℝ(index) × elementSize) + offset. + Let elementType be the Element Type value in Table 62 for arrayTypeName. + Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered). + Return NormalCompletion(undefined). + +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42n]); + sample.fill(false); + assert.sameValue(sample[0], 0n, "false => 0"); + + sample = new TA([42n]); + sample.fill(true); + assert.sameValue(sample[0], 1n, "true => 1"); + + sample = new TA([42n]); + sample.fill("7"); + assert.sameValue(sample[0], 7n, "string conversion"); + + sample = new TA([42n]); + sample.fill({ + toString: function() { + return "1"; + }, + valueOf: function() { + return 7n; + } + }); + assert.sameValue(sample[0], 7n, "object valueOf conversion before toString"); + + sample = new TA([42n]); + sample.fill({ + toString: function() { + return "7"; + } + }); + assert.sameValue(sample[0], 7n, "object toString when valueOf is absent"); + +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js new file mode 100644 index 00000000000..44df948c75a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills all the elements from a with a custom end index. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let + final be min(relativeEnd, len). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, 1), [8n, 0n, 0n]), + "Fill elements from custom end position" + ); + + assert( + compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, -1), [8n, 8n, 0n]), + "negative end sets final position to max((length + relativeEnd), 0)" + ); + + assert( + compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, 5), [8n, 8n, 8n]), + "end position is never higher than of length" + ); + + assert( + compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, -4), [0n, 0n, 0n]), + "end position is 0 when (len + relativeEnd) < 0" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js new file mode 100644 index 00000000000..a82638dbcbf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills all the elements from a with a custom start index. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be + min(relativeStart, len). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray(new TA([0n, 0n, 0n]).fill(8n, 1), [0n, 8n, 8n]), + "Fill elements from custom start position" + ); + + assert( + compareArray(new TA([0n, 0n, 0n]).fill(8n, 4), [0n, 0n, 0n]), + "start position is never higher than length" + ); + + assert( + compareArray(new TA([0n, 0n, 0n]).fill(8n, -1), [0n, 0n, 8n]), + "start < 0 sets initial position to max((len + relativeStart), 0)" + ); + + assert( + compareArray(new TA([0n, 0n, 0n]).fill(8n, -5), [8n, 8n, 8n]), + "start position is 0 when (len + relativeStart) < 0" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js new file mode 100644 index 00000000000..89ecace68e4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Throws a TypeError if value is a Symbol +info: | + %SendableTypedArray%.prototype.fill ( value [ , start [ , end ] ] ) + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value). + Otherwise, set value to ? ToNumber(value). + Let relativeStart be ? ToIntegerOrInfinity(start). + If relativeStart is -Infinity, let k be 0. + Else if relativeStart < 0, let k be max(len + relativeStart, 0). + Else, let k be min(relativeStart, len). + If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + If relativeEnd is -Infinity, let final be 0. + Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). + Else, let final be min(relativeEnd, len). + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + Repeat, while k < final, + Let Pk be ! ToString(F(k)). + Perform ! Set(O, Pk, value, true). + Set k to k + 1. + Return O. + + IntegerIndexedElementSet ( O, index, value ) + + Assert: O is an Integer-Indexed exotic object. + If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). + Otherwise, let numValue be ? ToNumber(value). + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then + Let offset be O.[[ByteOffset]]. + Let arrayTypeName be the String value of O.[[TypedArrayName]]. + Let elementSize be the Element Size value specified in Table 62 for arrayTypeName. + Let indexedPosition be (ℝ(index) × elementSize) + offset. + Let elementType be the Element Type value in Table 62 for arrayTypeName. + Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered). + Return NormalCompletion(undefined). + + +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var s = Symbol('1'); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(TypeError, function() { + sample.fill(s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values.js new file mode 100644 index 00000000000..740485dff81 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills all the elements with `value` from a default start and index. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 7. Repeat, while k < final + a. Let Pk be ! ToString(k). + b. Perform ? Set(O, Pk, value, true). +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA().fill(8n), + [] + ), + "does not fill an empty instance" + ); + + assert( + compareArray(new TA([0n, 0n, 0n]).fill(8n), [8n, 8n, 8n]), + "Default start and end indexes are 0 and this.length" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js new file mode 100644 index 00000000000..b2556ab5b41 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + Object.defineProperty(TA.prototype, "length", { + get: function() { + throw new Test262Error(); + } + }); + + var sample = new TA(1); + Object.defineProperty(sample, "length", { + get: function() { + throw new Test262Error(); + } + }); + + assert.sameValue(sample.fill(1n, 0), sample); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js new file mode 100644 index 00000000000..e71e46d81b5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Return abrupt if end is a Symbol. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var end = Symbol(1); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.fill(1n, 0, end); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js new file mode 100644 index 00000000000..ac3a0289fed --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Return abrupt from ToInteger(end). +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var end = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(Test262Error, function() { + sample.fill(1n, 0, end); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js new file mode 100644 index 00000000000..685ac549bbd --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Returns abrupt from value set +info: | + %SendableTypedArray%.prototype.fill ( value [ , start [ , end ] ] ) + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value). + Otherwise, set value to ? ToNumber(value). + Let relativeStart be ? ToIntegerOrInfinity(start). + If relativeStart is -Infinity, let k be 0. + Else if relativeStart < 0, let k be max(len + relativeStart, 0). + Else, let k be min(relativeStart, len). + If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + If relativeEnd is -Infinity, let final be 0. + Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). + Else, let final be min(relativeEnd, len). + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + Repeat, while k < final, + Let Pk be ! ToString(F(k)). + Perform ! Set(O, Pk, value, true). + Set k to k + 1. + Return O. + + IntegerIndexedElementSet ( O, index, value ) + + Assert: O is an Integer-Indexed exotic object. + If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). + Otherwise, let numValue be ? ToNumber(value). + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then + Let offset be O.[[ByteOffset]]. + Let arrayTypeName be the String value of O.[[TypedArrayName]]. + Let elementSize be the Element Size value specified in Table 62 for arrayTypeName. + Let indexedPosition be (ℝ(index) × elementSize) + offset. + Let elementType be the Element Type value in Table 62 for arrayTypeName. + Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered). + Return NormalCompletion(undefined). + + +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n]); + var obj = { + valueOf: function() { + throw new Test262Error(); + } + }; + + assert.throws(Test262Error, function() { + sample.fill(obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js new file mode 100644 index 00000000000..ec152106c2a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Return abrupt from ToInteger(start) as a Symbol. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 3. Let relativeStart be ? ToInteger(start). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var start = Symbol(1); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.fill(1n, start); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js new file mode 100644 index 00000000000..8f0e42ffbf8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Return abrupt from ToInteger(start). +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 3. Let relativeStart be ? ToInteger(start). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var start = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(Test262Error, function() { + sample.fill(1n, start); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..d69315a7814 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.fill, + 'function', + 'implements SendableTypedArray.prototype.fill' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.fill(0n); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.fill(0n); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the fill operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.fill(0n); + throw new Test262Error('fill completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-this.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-this.js new file mode 100644 index 00000000000..c38827009aa --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-this.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Returns `this`. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(); + var result1 = sample1.fill(1n); + + assert.sameValue(result1, sample1); + + var sample2 = new TA(42); + var result2 = sample2.fill(7n); + assert.sameValue(result2, sample2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js b/test/sendable/builtins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js new file mode 100644 index 00000000000..c1740c908ef --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Absent start and end parameters are computed from initial length. +info: | + %SendableTypedArray%.prototype.fill ( value [ , start [ , end ] ] ) + + ... + 2. Let taRecord be ? ValidateSendableTypedArray(O, seq-cst). + 3. Let len be SendableTypedArrayLength(taRecord). + ... + 5. Otherwise, set value to ? ToNumber(value). + 6. Let relativeStart be ? ToIntegerOrInfinity(start). + ... + 9. Else, let startIndex be min(relativeStart, len). + 10. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + ... + 13. Else, let endIndex be min(relativeEnd, len). + ... + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(1, {maxByteLength: 4}); +let ta = new Int8Array(rab); + +let value = { + valueOf() { + // Set buffer to maximum byte length. + rab.resize(4); + + // Return the fill value. + return 123; + } +}; + +// Ensure typed array is correctly initialised. +assert.sameValue(ta.length, 1); +assert.sameValue(ta[0], 0); + +ta.fill(value); + +// Ensure typed array has correct length and only the first element was filled. +assert.sameValue(ta.length, 4); +assert.sameValue(ta[0], 123); +assert.sameValue(ta[1], 0); +assert.sameValue(ta[2], 0); +assert.sameValue(ta[3], 0); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js new file mode 100644 index 00000000000..408378872c6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Security Throws a TypeError if end coercion detaches the buffer +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + 9. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len). + 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(10); + + function detachAndReturnIndex(){ + $DETACHBUFFER(sample.buffer); + return 10; + } + + assert.throws(TypeError, function() { + sample.fill(0x77, 0, {valueOf: detachAndReturnIndex}); + }, "Detachment when coercing end should throw TypeError"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js new file mode 100644 index 00000000000..7fca6ae3bbc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js @@ -0,0 +1,117 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills elements from coerced to Integer `start` and `end` values +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 3. Let relativeStart be ? ToInteger(start). + 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be + min(relativeStart, len). + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray(new TA([0, 0]).fill(1, undefined), [1, 1]), + '`undefined` start coerced to 0' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 0, undefined), [1, 1]), + 'If end is undefined, let relativeEnd be len' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, null), [1, 1]), + '`null` start coerced to 0' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 0, null), [0, 0]), + '`null` end coerced to 0' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, true), [0, 1]), + '`true` start coerced to 1' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 0, true), [1, 0]), + '`true` end coerced to 1' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, false), [1, 1]), + '`false` start coerced to 0' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 0, false), [0, 0]), + '`false` end coerced to 0' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, NaN), [1, 1]), + '`NaN` start coerced to 0' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 0, NaN), [0, 0]), + '`NaN` end coerced to 0' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, '1'), [0, 1]), + 'string start coerced' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 0, '1'), [1, 0]), + 'string end coerced' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 1.5), [0, 1]), + 'start as a float number coerced' + ); + + assert( + compareArray(new TA([0, 0]).fill(1, 0, 1.5), [1, 0]), + 'end as a float number coerced' + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js new file mode 100644 index 00000000000..164f5b8c0a7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Security Throws a TypeError if start coercion detaches the buffer +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + 6. Let relativeStart be ? ToInteger(start). + ... + 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(10); + + function detachAndReturnIndex(){ + $DETACHBUFFER(sample.buffer); + return 0; + } + + assert.throws(TypeError, function() { + sample.fill(0x77, {valueOf: detachAndReturnIndex}, 10); + }, "Detachment when coercing start should throw TypeError"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js new file mode 100644 index 00000000000..ecd417abea3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Security Throws a TypeError if value coercion detaches the buffer +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + 5. Otherwise, set value to ? ToNumber(value). + ... + 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(10); + + function detachAndReturnIndex(){ + $DETACHBUFFER(sample.buffer); + return 0x77; + } + + assert.throws(TypeError, function() { + sample.fill({valueOf: detachAndReturnIndex}, 0, 10); + }, "Detachment when coercing value should throw TypeError"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-start-end-resize.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-start-end-resize.js new file mode 100644 index 00000000000..2ba94ef2de1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-start-end-resize.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + SendableTypedArray.p.fill behaves correctly on receivers backed by a resizable + buffer that's resized during argument coercion +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function SendableTypedArrayFillHelper(ta, n, start, end) { + if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) { + ta.fill(BigInt(n), start, end); + } else { + ta.fill(n, start, end); + } +} + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 3; + } + }; + assert.throws(TypeError, () => { + SendableTypedArrayFillHelper(fixedLength, evil, 1, 2); + }); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 1; + } + }; + assert.throws(TypeError, () => { + SendableTypedArrayFillHelper(fixedLength, 3, evil, 2); + }); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 2; + } + }; + assert.throws(TypeError, () => { + SendableTypedArrayFillHelper(fixedLength, 3, 1, evil); + }); +} diff --git a/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js new file mode 100644 index 00000000000..321d6638120 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.fill(obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js new file mode 100644 index 00000000000..0d9a20a703a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills all the elements with non numeric values values. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + ... + 3. Let _value_ be ? ToNumber(_value_). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + var n = 1; + sample.fill({ valueOf() { return n++; } }); + + assert.sameValue(n, 2, "additional unexpected ToNumber() calls"); + assert.sameValue(sample[0], 1, "incorrect ToNumber result in index 0"); + assert.sameValue(sample[1], 1, "incorrect ToNumber result in index 1"); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js new file mode 100644 index 00000000000..82b02658cbd --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + An implementation must always choose either the same encoding for each implementation distinguishable *NaN* value, or an implementation-defined canonical value. +info: | + This test does not compare the actual byte values, instead it simply checks that + the value is some valid NaN encoding. + + --- + + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + #sec-array.prototype.fill + Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 7. Repeat, while k < final + a. Let Pk be ! ToString(k). + b. Perform ? Set(O, Pk, value, true). + ... + + #sec-setvalueinbuffer + SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ , + isLittleEndian ] ) + + 8. Let rawBytes be NumberToRawBytes(type, value, isLittleEndian). + + #sec-numbertorawbytes + NumberToRawBytes( type, value, isLittleEndian ) + + 1. If type is "Float32", then + a. Set rawBytes to a List containing the 4 bytes that are the result + of converting value to IEEE 754-2008 binary32 format using “Round to + nearest, ties to even” rounding mode. If isLittleEndian is false, the + bytes are arranged in big endian order. Otherwise, the bytes are + arranged in little endian order. If value is NaN, rawValue may be set + to any implementation chosen IEEE 754-2008 binary64 format Not-a-Number + encoding. An implementation must always choose either the same encoding + for each implementation distinguishable *NaN* value, or an + implementation-defined canonical value. + 2. Else, if type is "Float64", then + a. Set _rawBytes_ to a List containing the 8 bytes that are the IEEE + 754-2008 binary64 format encoding of _value_. If _isLittleEndian_ is + *false*, the bytes are arranged in big endian order. Otherwise, + the bytes are arranged in little endian order. If _value_ is *NaN*, + _rawValue_ may be set to any implementation chosen IEEE 754-2008 + binary64 format Not-a-Number encoding. An implementation must + always choose either the same encoding for each implementation + distinguishable *NaN* value, or an implementation-defined + canonical value. + ... + + #sec-isnan-number + + NOTE: A reliable way for ECMAScript code to test if a value X is a NaN is + an expression of the form X !== X. The result will be true if and only + if X is a NaN. +includes: [nans.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(FA) { + var precision = floatSendableTypedArrayConstructorPrecision(FA); + var samples = new FA(3); + var controls, idx, aNaN; + + for (idx = 0; idx < NaNs.length; ++idx) { + aNaN = NaNs[idx]; + controls = new Float32Array([aNaN, aNaN, aNaN]); + + samples.fill(aNaN); + + for (var i = 0; i < samples.length; i++) { + var sample = samples[i]; + var control = controls[i]; + + assert( + samples[i] !== samples[i], + `samples (index=${idx}) produces a valid NaN (${precision} precision)` + ); + + assert( + controls[i] !== controls[i], + `controls (index=${idx}) produces a valid NaN (${precision} precision)` + ); + } + } +}, floatArrayConstructors); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations.js new file mode 100644 index 00000000000..7a8f704cc0e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills all the elements with non numeric values values. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 7. Repeat, while k < final + a. Let Pk be ! ToString(k). + b. Perform ? Set(O, Pk, value, true). + ... + + 24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ , + isLittleEndian ] ) + + ... + 8. If type is "Float32", then + ... + 9. Else, if type is "Float64", then + ... + 10. Else, + ... + b. Let convOp be the abstract operation named in the Conversion Operation + column in Table 50 for Element Type type. + c. Let intValue be convOp(value). + d. If intValue ≥ 0, then + ... + e. Else, + ... +includes: [byteConversionValues.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { + var sample = new TA([initial]); + + sample.fill(value); + + assert.sameValue(sample[0], expected, value + " converts to " + expected); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js new file mode 100644 index 00000000000..1208918e6d4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills all the elements from a with a custom start and end indexes. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 3. Let relativeStart be ? ToInteger(start). + 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be + min(relativeStart, len). + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let + final be min(relativeEnd, len). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert(compareArray(new TA([0, 0, 0]).fill(8, 1, 2), [0, 8, 0])); + assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -3, 4), [0, 0, 8, 8, 0])); + assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -2, -1), [0, 0, 0, 8, 0])); + assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -1, -3), [0, 0, 0, 0, 0])); + assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, 1, 3), [0, 8, 8, 0, 0])); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js new file mode 100644 index 00000000000..8612eb99a2d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills all the elements with non numeric values values. +info: | + %SendableTypedArray%.prototype.fill ( value [ , start [ , end ] ] ) + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value). + Otherwise, set value to ? ToNumber(value). + Let relativeStart be ? ToIntegerOrInfinity(start). + If relativeStart is -Infinity, let k be 0. + Else if relativeStart < 0, let k be max(len + relativeStart, 0). + Else, let k be min(relativeStart, len). + If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + If relativeEnd is -Infinity, let final be 0. + Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). + Else, let final be min(relativeEnd, len). + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + Repeat, while k < final, + Let Pk be ! ToString(F(k)). + Perform ! Set(O, Pk, value, true). + Set k to k + 1. + Return O. + + IntegerIndexedElementSet ( O, index, value ) + + Assert: O is an Integer-Indexed exotic object. + If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). + Otherwise, let numValue be ? ToNumber(value). + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then + Let offset be O.[[ByteOffset]]. + Let arrayTypeName be the String value of O.[[TypedArrayName]]. + Let elementSize be the Element Size value specified in Table 62 for arrayTypeName. + Let indexedPosition be (ℝ(index) × elementSize) + offset. + Let elementType be the Element Type value in Table 62 for arrayTypeName. + Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered). + Return NormalCompletion(undefined). + + +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42]); + sample.fill(null); + assert.sameValue(sample[0], 0, "null => 0"); + + sample = new TA([42]); + sample.fill(false); + assert.sameValue(sample[0], 0, "false => 0"); + + sample = new TA([42]); + sample.fill(true); + assert.sameValue(sample[0], 1, "true => 1"); + + sample = new TA([42]); + sample.fill("7"); + assert.sameValue(sample[0], 7, "string conversion"); + + sample = new TA([42]); + sample.fill({ + toString: function() { + return "1"; + }, + valueOf: function() { + return 7; + } + }); + assert.sameValue(sample[0], 7, "object valueOf conversion before toString"); + + sample = new TA([42]); + sample.fill({ + toString: function() { + return "7"; + } + }); + assert.sameValue(sample[0], 7, "object toString when valueOf is absent"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js new file mode 100644 index 00000000000..dc21a923611 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills all the elements from a with a custom end index. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let + final be min(relativeEnd, len). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray(new TA([0, 0, 0]).fill(8, 0, 1), [8, 0, 0]), + "Fill elements from custom end position" + ); + + assert( + compareArray(new TA([0, 0, 0]).fill(8, 0, -1), [8, 8, 0]), + "negative end sets final position to max((length + relativeEnd), 0)" + ); + + assert( + compareArray(new TA([0, 0, 0]).fill(8, 0, 5), [8, 8, 8]), + "end position is never higher than of length" + ); + + assert( + compareArray(new TA([0, 0, 0]).fill(8, 0, -4), [0, 0, 0]), + "end position is 0 when (len + relativeEnd) < 0" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js new file mode 100644 index 00000000000..6cc33510e6d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills all the elements from a with a custom start index. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be + min(relativeStart, len). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray(new TA([0, 0, 0]).fill(8, 1), [0, 8, 8]), + "Fill elements from custom start position" + ); + + assert( + compareArray(new TA([0, 0, 0]).fill(8, 4), [0, 0, 0]), + "start position is never higher than length" + ); + + assert( + compareArray(new TA([0, 0, 0]).fill(8, -1), [0, 0, 8]), + "start < 0 sets initial position to max((len + relativeStart), 0)" + ); + + assert( + compareArray(new TA([0, 0, 0]).fill(8, -5), [8, 8, 8]), + "start position is 0 when (len + relativeStart) < 0" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js new file mode 100644 index 00000000000..0d8224665d0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Throws a TypeError if value is a Symbol +info: | + %SendableTypedArray%.prototype.fill ( value [ , start [ , end ] ] ) + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value). + Otherwise, set value to ? ToNumber(value). + Let relativeStart be ? ToIntegerOrInfinity(start). + If relativeStart is -Infinity, let k be 0. + Else if relativeStart < 0, let k be max(len + relativeStart, 0). + Else, let k be min(relativeStart, len). + If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + If relativeEnd is -Infinity, let final be 0. + Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). + Else, let final be min(relativeEnd, len). + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + Repeat, while k < final, + Let Pk be ! ToString(F(k)). + Perform ! Set(O, Pk, value, true). + Set k to k + 1. + Return O. + + IntegerIndexedElementSet ( O, index, value ) + + Assert: O is an Integer-Indexed exotic object. + If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). + Otherwise, let numValue be ? ToNumber(value). + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then + Let offset be O.[[ByteOffset]]. + Let arrayTypeName be the String value of O.[[TypedArrayName]]. + Let elementSize be the Element Size value specified in Table 62 for arrayTypeName. + Let indexedPosition be (ℝ(index) × elementSize) + offset. + Let elementType be the Element Type value in Table 62 for arrayTypeName. + Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered). + Return NormalCompletion(undefined). + + +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var s = Symbol('1'); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(TypeError, function() { + sample.fill(s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js new file mode 100644 index 00000000000..c11b99174d0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Fills all the elements with `value` from a default start and index. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 7. Repeat, while k < final + a. Let Pk be ! ToString(k). + b. Perform ? Set(O, Pk, value, true). +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + assert( + compareArray( + new TA().fill(8), + [] + ), + "does not fill an empty instance" + ); + + assert( + compareArray(new TA([0, 0, 0]).fill(8), [8, 8, 8]), + "Default start and end indexes are 0 and this.length" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js new file mode 100644 index 00000000000..1e531493927 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithSendableTypedArrayConstructors(function(TA) { + Object.defineProperty(TA.prototype, "length", { + get: function() { + throw new Test262Error(); + } + }); + + var sample = new TA(1); + Object.defineProperty(sample, "length", { + get: function() { + throw new Test262Error(); + } + }); + + assert.sameValue(sample.fill(1, 0), sample); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-func.js new file mode 100644 index 00000000000..a7ebad2bbcf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-func.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var fill = SendableTypedArray.prototype.fill; + +assert.sameValue(typeof fill, 'function'); + +assert.throws(TypeError, function() { + fill(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-method.js new file mode 100644 index 00000000000..6cea364f46a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-method.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.fill, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.fill(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/length.js b/test/sendable/builtins/TypedArray/prototype/fill/length.js new file mode 100644 index 00000000000..c362dc93bd2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + %SendableTypedArray%.prototype.fill.length is 1. +info: | + %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.fill, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/name.js b/test/sendable/builtins/TypedArray/prototype/fill/name.js new file mode 100644 index 00000000000..4a17d9aa518 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + %SendableTypedArray%.prototype.fill.name is "fill". +info: | + %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.fill, "name", { + value: "fill", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/fill/not-a-constructor.js new file mode 100644 index 00000000000..af17fd58ac4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.fill 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.fill), + false, + 'isConstructor(SendableTypedArray.prototype.fill) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.fill(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/fill/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/fill/prop-desc.js new file mode 100644 index 00000000000..eca1ffab353 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + "fill" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'fill', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/fill/resizable-buffer.js new file mode 100644 index 00000000000..223d09adf5a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/resizable-buffer.js @@ -0,0 +1,192 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + SendableTypedArray.p.fill behaves correctly when the receiver is backed by + resizable buffer +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function ReadDataFromBuffer(ab, ctor) { + let result = []; + const ta = new ctor(ab, 0, ab.byteLength / ctor.BYTES_PER_ELEMENT); + for (let item of ta) { + result.push(Number(item)); + } + return result; +} + +function SendableTypedArrayFillHelper(ta, n, start, end) { + if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) { + ta.fill(BigInt(n), start, end); + } else { + ta.fill(n, start, end); + } +} + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 0, + 0, + 0, + 0 + ]); + SendableTypedArrayFillHelper(fixedLength, 1); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 1, + 1, + 1, + 1 + ]); + SendableTypedArrayFillHelper(fixedLengthWithOffset, 2); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 1, + 1, + 2, + 2 + ]); + SendableTypedArrayFillHelper(lengthTracking, 3); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 3, + 3, + 3, + 3 + ]); + SendableTypedArrayFillHelper(lengthTrackingWithOffset, 4); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 3, + 3, + 4, + 4 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => SendableTypedArrayFillHelper(fixedLength, 5)); + assert.throws(TypeError, () => SendableTypedArrayFillHelper(fixedLengthWithOffset, 6)); + + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 3, + 3, + 4 + ]); + SendableTypedArrayFillHelper(lengthTracking, 7); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 7, + 7, + 7 + ]); + SendableTypedArrayFillHelper(lengthTrackingWithOffset, 8); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 7, + 7, + 8 + ]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => SendableTypedArrayFillHelper(fixedLength, 9)); + assert.throws(TypeError, () => SendableTypedArrayFillHelper(fixedLengthWithOffset, 10)); + assert.throws(TypeError, () => SendableTypedArrayFillHelper(lengthTrackingWithOffset, 11)); + + assert.compareArray(ReadDataFromBuffer(rab, ctor), [7]); + SendableTypedArrayFillHelper(lengthTracking, 12); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [12]); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + SendableTypedArrayFillHelper(fixedLength, 13); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 13, + 13, + 13, + 13, + 0, + 0 + ]); + SendableTypedArrayFillHelper(fixedLengthWithOffset, 14); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 13, + 13, + 14, + 14, + 0, + 0 + ]); + SendableTypedArrayFillHelper(lengthTracking, 15); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 15, + 15, + 15, + 15, + 15, + 15 + ]); + SendableTypedArrayFillHelper(lengthTrackingWithOffset, 16); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 15, + 15, + 16, + 16, + 16, + 16 + ]); + + // Filling with non-undefined start & end. + SendableTypedArrayFillHelper(fixedLength, 17, 1, 3); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 15, + 17, + 17, + 16, + 16, + 16 + ]); + SendableTypedArrayFillHelper(fixedLengthWithOffset, 18, 1, 2); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 15, + 17, + 17, + 18, + 16, + 16 + ]); + SendableTypedArrayFillHelper(lengthTracking, 19, 1, 3); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 15, + 19, + 19, + 18, + 16, + 16 + ]); + SendableTypedArrayFillHelper(lengthTrackingWithOffset, 20, 1, 2); + assert.compareArray(ReadDataFromBuffer(rab, ctor), [ + 15, + 19, + 19, + 20, + 16, + 16 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js new file mode 100644 index 00000000000..5d1d04c899c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Return abrupt if end is a Symbol. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var end = Symbol(1); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.fill(1, 0, end); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js new file mode 100644 index 00000000000..b2d56c27085 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Return abrupt from ToInteger(end). +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var end = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(Test262Error, function() { + sample.fill(1, 0, end); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js new file mode 100644 index 00000000000..e76ff3e6003 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Returns abrupt from value set +info: | + %SendableTypedArray%.prototype.fill ( value [ , start [ , end ] ] ) + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If O.[[ContentType]] is BigInt, set value to ? ToBigInt(value). + Otherwise, set value to ? ToNumber(value). + Let relativeStart be ? ToIntegerOrInfinity(start). + If relativeStart is -Infinity, let k be 0. + Else if relativeStart < 0, let k be max(len + relativeStart, 0). + Else, let k be min(relativeStart, len). + If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToIntegerOrInfinity(end). + If relativeEnd is -Infinity, let final be 0. + Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). + Else, let final be min(relativeEnd, len). + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + Repeat, while k < final, + Let Pk be ! ToString(F(k)). + Perform ! Set(O, Pk, value, true). + Set k to k + 1. + Return O. + + IntegerIndexedElementSet ( O, index, value ) + + Assert: O is an Integer-Indexed exotic object. + If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). + Otherwise, let numValue be ? ToNumber(value). + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then + Let offset be O.[[ByteOffset]]. + Let arrayTypeName be the String value of O.[[TypedArrayName]]. + Let elementSize be the Element Size value specified in Table 62 for arrayTypeName. + Let indexedPosition be (ℝ(index) × elementSize) + offset. + Let elementType be the Element Type value in Table 62 for arrayTypeName. + Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered). + Return NormalCompletion(undefined). + + +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42]); + var obj = { + valueOf: function() { + throw new Test262Error(); + } + }; + + assert.throws(Test262Error, function() { + sample.fill(obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js new file mode 100644 index 00000000000..8241f4e81b0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Return abrupt from ToInteger(start) as a Symbol. +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 3. Let relativeStart be ? ToInteger(start). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var start = Symbol(1); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.fill(1, start); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js new file mode 100644 index 00000000000..d58fcd9c448 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Return abrupt from ToInteger(start). +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + %SendableTypedArray%.prototype.fill is a distinct function that implements the same + algorithm as Array.prototype.fill as defined in 22.1.3.6 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. However, such optimization + must not introduce any observable changes in the specified behaviour of the + algorithm. + + ... + + 22.1.3.6 Array.prototype.fill (value [ , start [ , end ] ] ) + + ... + 3. Let relativeStart be ? ToInteger(start). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var start = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(Test262Error, function() { + sample.fill(1, start); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..65543c854d9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.fill, + 'function', + 'implements SendableTypedArray.prototype.fill' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.fill(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.fill(0); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the fill operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.fill(0); + throw new Test262Error('fill completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-this.js b/test/sendable/builtins/TypedArray/prototype/fill/return-this.js new file mode 100644 index 00000000000..5ef376eab78 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-this.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Returns `this`. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(); + var result1 = sample1.fill(1); + + assert.sameValue(result1, sample1); + + var sample2 = new TA(42); + var result2 = sample2.fill(7); + assert.sameValue(result2, sample2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-object.js new file mode 100644 index 00000000000..7c976237b93 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-object.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var fill = SendableTypedArray.prototype.fill; + +assert.throws(TypeError, function() { + fill.call(undefined, 0); +}, "this is undefined"); + +assert.throws(TypeError, function() { + fill.call(null, 0); +}, "this is null"); + +assert.throws(TypeError, function() { + fill.call(42, 0); +}, "this is 42"); + +assert.throws(TypeError, function() { + fill.call("1", 0); +}, "this is a string"); + +assert.throws(TypeError, function() { + fill.call(true, 0); +}, "this is true"); + +assert.throws(TypeError, function() { + fill.call(false, 0); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + fill.call(s, 0); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..f8d6b7f18b4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.fill +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var fill = SendableTypedArray.prototype.fill; + +assert.throws(TypeError, function() { + fill.call({}, 0); +}, "this is an Object"); + +assert.throws(TypeError, function() { + fill.call([], 0); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + fill.call(ab, 0); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + fill.call(dv, 0); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js new file mode 100644 index 00000000000..8c858da49ea --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: Uses internal ArrayLength instead of length property +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 3. Let len be the value of O's [[ArrayLength]] internal slot. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(4); + var calls = 0; + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.filter(function() { + calls++; + }); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert.sameValue(calls, 4, "interactions are not affected by custom length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js new file mode 100644 index 00000000000..973f27a7cbc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + thisArg does not affect callbackfn arguments +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + var results = []; + var thisArg = ["test262", 0, "ecma262", 0]; + + sample.filter(function() { + results.push(arguments); + }, thisArg); + + assert.sameValue(results.length, 3, "results.length"); + assert.sameValue(thisArg.length, 4, "thisArg.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42n, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43n, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44n, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js new file mode 100644 index 00000000000..e2b24944778 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + callbackfn arguments +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + var results = []; + + sample.filter(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 3, "results.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42n, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43n, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44n, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js new file mode 100644 index 00000000000..b605532d76d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: callbackfn is called for each item before SendableTypedArraySpeciesCreate +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var length = 42; + var sample = new TA(length); + var calls = 0; + var before = false; + + sample.constructor = {}; + Object.defineProperty(sample, "constructor", { + get: function() { + before = calls === length; + } + }); + + sample.filter(function() { + calls++; + }); + + assert.sameValue(calls, 42, "callbackfn called for each item"); + assert.sameValue(before, true, "all callbackfn called before"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js new file mode 100644 index 00000000000..8b80a9b48b0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: callbackfn is called for each item before SendableTypedArraySpeciesCreate +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var length = 42; + var sample = new TA(length); + var calls = 0; + var before = false; + + sample.constructor = {}; + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + before = calls === length; + } + }); + + sample.filter(function() { + calls++; + }); + + assert.sameValue(calls, 42, "callbackfn called for each item"); + assert.sameValue(before, true, "all callbackfn called before"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js new file mode 100644 index 00000000000..b45603462c4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Instance buffer can be detached during loop +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + b. Let kValue be ? Get(O, Pk). + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [detachArrayBuffer.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.filter(function() { + var flag = true; + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } else { + flag = false; + } + loops++; + return flag; + }); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js new file mode 100644 index 00000000000..d0d5e7f3c43 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Does not iterate over non-integer properties +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7n, 8n]); + + var results = []; + + sample.foo = 42; + sample[Symbol("1")] = 43; + + sample.filter(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + + assert.sameValue(results[0][0], 7n, "results[0][0] - kValue"); + assert.sameValue(results[1][0], 8n, "results[1][0] - kValue"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js new file mode 100644 index 00000000000..120db9c74b0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: Throws TypeError if callbackfn is not callable +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(4); + + assert.throws(TypeError, function() { + sample.filter(); + }, "no arg"); + + assert.throws(TypeError, function() { + sample.filter(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.filter(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.filter(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.filter(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.filter({}); + }, "{}"); + + assert.throws(TypeError, function() { + sample.filter([]); + }, "[]"); + + assert.throws(TypeError, function() { + sample.filter(1); + }, "Number"); + + assert.throws(TypeError, function() { + sample.filter(Symbol("")); + }, "symbol"); + + assert.throws(TypeError, function() { + sample.filter(""); + }, "string"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js new file mode 100644 index 00000000000..99ed7b24b0b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + callbackfn is not called on empty instances +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var called = 0; + + new TA().filter(function() { + called++; + }); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js new file mode 100644 index 00000000000..0ed2fda2cfe --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + The callbackfn return does not change the instance +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(3); + + sample1[1] = 1n; + + sample1.filter(function() { + return 42; + }); + + assert.sameValue(sample1[0], 0n, "[0] == 0"); + assert.sameValue(sample1[1], 1n, "[1] == 1"); + assert.sameValue(sample1[2], 0n, "[2] == 0"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js new file mode 100644 index 00000000000..a16300c5437 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Returns abrupt from callbackfn +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + assert.throws(Test262Error, function() { + sample.filter(function() { + throw new Test262Error(); + }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js new file mode 100644 index 00000000000..c1963371ed0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Reflect.set, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + var newVal = 0n; + + sample.filter(function(val, i) { + if (i > 0) { + assert.sameValue( + sample[i - 1], newVal - 1n, + "get the changed value during the loop" + ); + assert.sameValue( + Reflect.set(sample, 0, 7n), + true, + "re-set a value for sample[0]" + ); + } + assert.sameValue( + Reflect.set(sample, i, newVal), + true, + "set value during interaction" + ); + + newVal++; + }); + + assert.sameValue(sample[0], 7n, "changed values after interaction [0] == 7"); + assert.sameValue(sample[1], 1n, "changed values after interaction [1] == 1"); + assert.sameValue(sample[2], 2n, "changed values after interaction [2] == 2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-this.js new file mode 100644 index 00000000000..91caa1206d5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-this.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + callbackfn `this` value +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var expected = (function() { return this; })(); +var thisArg = {}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var results1 = []; + + sample.filter(function() { + results1.push(this); + }); + + assert.sameValue(results1.length, 3, "results1"); + assert.sameValue(results1[0], expected, "without thisArg - [0]"); + assert.sameValue(results1[1], expected, "without thisArg - [1]"); + assert.sameValue(results1[2], expected, "without thisArg - [2]"); + + var results2 = []; + + sample.filter(function() { + results2.push(this); + }, thisArg); + + assert.sameValue(results2.length, 3, "results2"); + assert.sameValue(results2[0], thisArg, "using thisArg - [0]"); + assert.sameValue(results2[1], thisArg, "using thisArg - [1]"); + assert.sameValue(results2[2], thisArg, "using thisArg - [2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/detached-buffer.js new file mode 100644 index 00000000000..a2c7a056cdf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var callbackfn = function() { + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.filter(callbackfn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js new file mode 100644 index 00000000000..fd8cca4f4ec --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Return does not share buffer +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + 13. Return A. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n]); + var result; + + result = sample.filter(function() { return true; }); + assert.notSameValue(result.buffer, sample.buffer); + + result = sample.filter(function() { return false; }); + assert.notSameValue(result.buffer, sample.buffer); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js new file mode 100644 index 00000000000..b2a3fe71be9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Returns empty if every callbackfn returns boolean false +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 12. For each element e of kept + a. Perform ! Set(A, ! ToString(n), e, true). + b. Increment n by 1. + 13. Return A. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + [ + false, + "", + 0, + -0, + NaN, + undefined, + null + ].forEach(function(val) { + var result = sample.filter(function() { + return val; + }); + assert.sameValue(result.length, 0, val); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js new file mode 100644 index 00000000000..1e6d9d8fa16 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Returns full length result if every callbackfn returns boolean false +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 12. For each element e of kept + a. Perform ! Set(A, ! ToString(n), e, true). + b. Increment n by 1. + 13. Return A. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n]); + + [ + true, + 1, + "test262", + Symbol("1"), + {}, + [], + -1, + Infinity, + -Infinity, + 0.1, + -0.1 + ].forEach(function(val) { + var result = sample.filter(function() { return val; }); + assert(compareArray(result, sample), val); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..7fcfeffcde9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.filter, + 'function', + 'implements SendableTypedArray.prototype.filter' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.filter(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.filter(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the filter operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.filter(() => {}); + throw new Test262Error('filter completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-destination-resizable.js new file mode 100644 index 00000000000..beff337f9d6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-destination-resizable.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Throws a TypeError if new typedArray's length < count +info: | + 23.2.3.10 %SendableTypedArray%.prototype.filter ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 23.2.4.1 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + 23.2.4.2 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); + const ta = new TA(rab1); + const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); + const lengthTracking = new TA(rab2); + rab2.resize(0); + ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; + assert.throws(TypeError, function() { + ta.filter(() => true); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js new file mode 100644 index 00000000000..e8c63dabdab --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: Return abrupt from SpeciesConstructor's get Constructor +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + Object.defineProperty(sample, "constructor", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.filter(function() { + return true; + }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js new file mode 100644 index 00000000000..2b4b7a5e980 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: get inherited constructor on SpeciesConstructor +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + var calls = 0; + var result; + + Object.defineProperty(TA.prototype, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.filter(function() { + return true; + }); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + undefined, + "used defaultCtor but still checks the inherited .constructor" + ); + + calls = 6; + result.constructor; + assert.sameValue( + calls, + 7, + "result.constructor triggers the inherited accessor property" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js new file mode 100644 index 00000000000..493f66ac532 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Throws if O.constructor returns a non-Object and non-undefined value +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + 4. If Type(C) is not Object, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var callbackfn = function() { return true; }; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + sample.constructor = 42; + assert.throws(TypeError, function() { + sample.filter(callbackfn); + }, "42"); + + sample.constructor = "1"; + assert.throws(TypeError, function() { + sample.filter(callbackfn); + }, "string"); + + sample.constructor = null; + assert.throws(TypeError, function() { + sample.filter(callbackfn); + }, "null"); + + sample.constructor = NaN; + assert.throws(TypeError, function() { + sample.filter(callbackfn); + }, "NaN"); + + sample.constructor = false; + assert.throws(TypeError, function() { + sample.filter(callbackfn); + }, "false"); + + sample.constructor = Symbol("1"); + assert.throws(TypeError, function() { + sample.filter(callbackfn); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js new file mode 100644 index 00000000000..500b7260f16 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: get constructor on SpeciesConstructor +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + var calls = 0; + var result; + + Object.defineProperty(sample, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.filter(function() { return true; }); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + TA, + "use defaultCtor on an undefined return - .constructor check" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js new file mode 100644 index 00000000000..e6dd9b316aa --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Returns abrupt from get @@species on found constructor +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.filter(function() { return true; }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js new file mode 100644 index 00000000000..4fbd31986be --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Verify arguments on custom @@species construct call +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 42n, 42n]); + var result, ctorThis; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(count) { + result = arguments; + ctorThis = this; + return new TA(count); + }; + + sample.filter(function(v) { return v === 42n; }); + + assert.sameValue(result.length, 1, "called with 1 argument"); + assert.sameValue(result[0], 2, "[0] is the new captured length"); + + assert( + ctorThis instanceof sample.constructor[Symbol.species], + "`this` value in the @@species fn is an instance of the function itself" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js new file mode 100644 index 00000000000..6628ccff37e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Throws a TypeError if new typedArray's length < count +info: | + 23.2.3.10 %SendableTypedArray%.prototype.filter ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 23.2.4.1 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + 23.2.4.2 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + const rab = new ArrayBuffer(10, {maxByteLength: 20}); + const lengthTracking = new TA(rab); + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return lengthTracking; + }; + rab.resize(0); + assert.throws(TypeError, function() { + sample.filter(() => { return true; }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js new file mode 100644 index 00000000000..7b7b6cbb1b7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Throws a TypeError if new typedArray's length < captured +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return new TA(); + }; + + assert.throws(TypeError, function() { + sample.filter(function() { return true; }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js new file mode 100644 index 00000000000..7713e4351f4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Does not throw a TypeError if new typedArray's length >= captured +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var customCount, result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return new TA(customCount); + }; + + customCount = 2; + result = sample.filter(function() { return true; }); + assert.sameValue(result.length, customCount, "length == count"); + + customCount = 5; + result = sample.filter(function() { return true; }); + assert.sameValue(result.length, customCount, "length > count"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js new file mode 100644 index 00000000000..be812bd84ac --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Custom @@species constructor may return a different SendableTypedArray +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n]); + var otherTA = TA === BigInt64Array ? BigUint64Array : BigInt64Array; + var other = new otherTA([1n, 0n, 1n]); + var result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return other; + }; + + result = sample.filter(function() {}); + + assert.sameValue(result, other, "returned another typedarray"); + assert(compareArray(result, [1n, 0n, 1n]), "the returned object is preserved"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js new file mode 100644 index 00000000000..995fea92819 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Custom @@species constructor throws if it does not return a compatible object +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + sample.constructor[Symbol.species] = Array; + + assert.throws(TypeError, function() { + sample.filter(function() {}); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js new file mode 100644 index 00000000000..c63ff4d07b9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Use custom @@species constructor if available +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n]); + var calls = 0; + var other, result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(captured) { + calls++; + other = new TA(captured); + return other; + }; + + result = sample.filter(function() { return true; }); + + assert.sameValue(calls, 1, "ctor called once"); + assert.sameValue(result, other, "return is instance of custom constructor"); + assert(compareArray(result, [40n, 41n, 42n]), "values are set on the new obj"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js new file mode 100644 index 00000000000..134982a97f1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Throws if returned @@species is not a constructor, null or undefined. +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + 7. If IsConstructor(S) is true, return S. + 8. Throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + sample.constructor[Symbol.species] = 0; + assert.throws(TypeError, function() { + sample.filter(function() {}); + }, "0"); + + sample.constructor[Symbol.species] = "string"; + assert.throws(TypeError, function() { + sample.filter(function() {}); + }, "string"); + + sample.constructor[Symbol.species] = {}; + assert.throws(TypeError, function() { + sample.filter(function() {}); + }, "{}"); + + sample.constructor[Symbol.species] = NaN; + assert.throws(TypeError, function() { + sample.filter(function() {}); + }, "NaN"); + + sample.constructor[Symbol.species] = false; + assert.throws(TypeError, function() { + sample.filter(function() {}); + }, "false"); + + sample.constructor[Symbol.species] = true; + assert.throws(TypeError, function() { + sample.filter(function() {}); + }, "true"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js new file mode 100644 index 00000000000..3fed50402ac --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Use defaultConstructor if @@species is either undefined or null +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var result; + + sample.constructor = {}; + + result = sample.filter(function() {}); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "undefined @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "undefined @@species - ctor check"); + + sample.constructor[Symbol.species] = null; + result = sample.filter(function() {}); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "null @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "null @@species - ctor check"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js new file mode 100644 index 00000000000..413f2b1bc8f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + get @@species from found constructor +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var calls = 0; + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + calls++; + } + }); + + sample.filter(function() {}); + + assert.sameValue(calls, 1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js new file mode 100644 index 00000000000..9a51f64361f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Integer indexed values are not cached before interaction +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + sample.filter(function(v, i) { + if (i < sample.length - 1) { + sample[i+1] = 42n; + } + + assert.sameValue( + v, 42n, "method does not cache values before callbackfn calls" + ); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-set.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-set.js new file mode 100644 index 00000000000..50b56244b26 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-set.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Returned instance with filtered values set on it +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 12. For each element e of kept + a. Perform ! Set(A, ! ToString(n), e, true). + b. Increment n by 1. + 13. Return A. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([41n, 1n, 42n, 7n]); + var result; + + result = sample.filter(function() { return true; }); + assert(compareArray(result, [41n, 1n, 42n, 7n]), "values are set #1"); + + result = sample.filter(function(v) { + return v > 40n; + }); + assert(compareArray(result, [41n, 42n]), "values are set #2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js new file mode 100644 index 00000000000..3166fdd6cbc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: Uses internal ArrayLength instead of length property +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 3. Let len be the value of O's [[ArrayLength]] internal slot. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(4); + var calls = 0; + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.filter(function() { + calls++; + }); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert.sameValue(calls, 4, "interactions are not affected by custom length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js new file mode 100644 index 00000000000..0fc165341fe --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + thisArg does not affect callbackfn arguments +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + var results = []; + var thisArg = ["test262", 0, "ecma262", 0]; + + sample.filter(function() { + results.push(arguments); + }, thisArg); + + assert.sameValue(results.length, 3, "results.length"); + assert.sameValue(thisArg.length, 4, "thisArg.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js new file mode 100644 index 00000000000..6de9a6d1310 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + callbackfn arguments +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + var results = []; + + sample.filter(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 3, "results.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js new file mode 100644 index 00000000000..8083916e7d4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: callbackfn is called for each item before SendableTypedArraySpeciesCreate +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var length = 42; + var sample = new TA(length); + var calls = 0; + var before = false; + + sample.constructor = {}; + Object.defineProperty(sample, "constructor", { + get: function() { + before = calls === length; + } + }); + + sample.filter(function() { + calls++; + }); + + assert.sameValue(calls, 42, "callbackfn called for each item"); + assert.sameValue(before, true, "all callbackfn called before"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js new file mode 100644 index 00000000000..d9171bcca1d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: callbackfn is called for each item before SendableTypedArraySpeciesCreate +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var length = 42; + var sample = new TA(length); + var calls = 0; + var before = false; + + sample.constructor = {}; + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + before = calls === length; + } + }); + + sample.filter(function() { + calls++; + }); + + assert.sameValue(calls, 42, "callbackfn called for each item"); + assert.sameValue(before, true, "all callbackfn called before"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js new file mode 100644 index 00000000000..740bfcd5368 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Instance buffer can be detached during loop +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + b. Let kValue be ? Get(O, Pk). + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [detachArrayBuffer.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.filter(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + return true; + }); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js new file mode 100644 index 00000000000..26587ac6dbc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Does not iterate over non-integer properties +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7, 8]); + + var results = []; + + sample.foo = 42; + sample[Symbol("1")] = 43; + + sample.filter(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + + assert.sameValue(results[0][0], 7, "results[0][0] - kValue"); + assert.sameValue(results[1][0], 8, "results[1][0] - kValue"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js new file mode 100644 index 00000000000..2df1f29e3ef --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: Throws TypeError if callbackfn is not callable +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(4); + + assert.throws(TypeError, function() { + sample.filter(); + }, "no arg"); + + assert.throws(TypeError, function() { + sample.filter(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.filter(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.filter(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.filter(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.filter({}); + }, "{}"); + + assert.throws(TypeError, function() { + sample.filter([]); + }, "[]"); + + assert.throws(TypeError, function() { + sample.filter(1); + }, "Number"); + + assert.throws(TypeError, function() { + sample.filter(Symbol("")); + }, "symbol"); + + assert.throws(TypeError, function() { + sample.filter(""); + }, "string"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js new file mode 100644 index 00000000000..2031d39f728 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + callbackfn is not called on empty instances +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var called = 0; + + new TA().filter(function() { + called++; + }); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js new file mode 100644 index 00000000000..691e14c8c5b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: Instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var NaNvalue = isFloatSendableTypedArrayConstructor(TA) ? NaN : 0; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var finalElement, finalResult, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = sample.filter(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + finalElement = undefined; + finalResult = NaNvalue; + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + finalElement = 0; + finalResult = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return true; + }); + + assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)'); + assert.compareArray(indices, [0, 1, 2], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.compareArray(result, [0, 0, finalResult], 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = sample.filter(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return true; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.compareArray(result, expectedElements, 'result (grow)'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js new file mode 100644 index 00000000000..2b117a3082e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + The callbackfn return does not change the instance +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(3); + + sample1[1] = 1; + + sample1.filter(function() { + return 42; + }); + + assert.sameValue(sample1[0], 0, "[0] == 0"); + assert.sameValue(sample1[1], 1, "[1] == 1"); + assert.sameValue(sample1[2], 0, "[2] == 0"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js new file mode 100644 index 00000000000..ee1a8effa9e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Returns abrupt from callbackfn +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + assert.throws(Test262Error, function() { + sample.filter(function() { + throw new Test262Error(); + }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js new file mode 100644 index 00000000000..40da97c20eb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [Reflect.set, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + var newVal = 0; + + sample.filter(function(val, i) { + if (i > 0) { + assert.sameValue( + sample[i - 1], newVal - 1, + "get the changed value during the loop" + ); + assert.sameValue( + Reflect.set(sample, 0, 7), + true, + "re-set a value for sample[0]" + ); + } + assert.sameValue( + Reflect.set(sample, i, newVal), + true, + "set value during interaction" + ); + + newVal++; + }); + + assert.sameValue(sample[0], 7, "changed values after interaction [0] == 7"); + assert.sameValue(sample[1], 1, "changed values after interaction [1] == 1"); + assert.sameValue(sample[2], 2, "changed values after interaction [2] == 2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js new file mode 100644 index 00000000000..1bab8d1d53c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + callbackfn `this` value +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var expected = (function() { return this; })(); +var thisArg = {}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var results1 = []; + + sample.filter(function() { + results1.push(this); + }); + + assert.sameValue(results1.length, 3, "results1"); + assert.sameValue(results1[0], expected, "without thisArg - [0]"); + assert.sameValue(results1[1], expected, "without thisArg - [1]"); + assert.sameValue(results1[2], expected, "without thisArg - [2]"); + + var results2 = []; + + sample.filter(function() { + results2.push(this); + }, thisArg); + + assert.sameValue(results2.length, 3, "results2"); + assert.sameValue(results2[0], thisArg, "using thisArg - [0]"); + assert.sameValue(results2[1], thisArg, "using thisArg - [1]"); + assert.sameValue(results2[2], thisArg, "using thisArg - [2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js new file mode 100644 index 00000000000..92b375ac8c7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var callbackfn = function() { + throw new Test262Error(); +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.filter(callbackfn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-func.js new file mode 100644 index 00000000000..15e72e14c23 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-func.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + 1. Let O be the this value. + 2. Let valid be ValidateSendableTypedArray(O). + 3. ReturnIfAbrupt(valid). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var filter = SendableTypedArray.prototype.filter; + +assert.sameValue(typeof filter, 'function'); + +assert.throws(TypeError, function() { + filter(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-method.js new file mode 100644 index 00000000000..8dbc8ffa504 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-method.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + 1. Let O be the this value. + 2. Let valid be ValidateSendableTypedArray(O). + 3. ReturnIfAbrupt(valid). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.filter, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.filter(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/length.js b/test/sendable/builtins/TypedArray/prototype/filter/length.js new file mode 100644 index 00000000000..5a8940078c1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + %SendableTypedArray%.prototype.filter.length is 1. +info: | + %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.filter, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/name.js b/test/sendable/builtins/TypedArray/prototype/filter/name.js new file mode 100644 index 00000000000..64841d0b0e8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + %SendableTypedArray%.prototype.filter.name is "filter". +info: | + %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.filter, "name", { + value: "filter", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/filter/not-a-constructor.js new file mode 100644 index 00000000000..1f525e94918 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.filter 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.filter), + false, + 'isConstructor(SendableTypedArray.prototype.filter) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.filter(() => {}); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/filter/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/filter/prop-desc.js new file mode 100644 index 00000000000..bf870f3a798 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + "filter" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'filter', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..bb6186c9242 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + SendableTypedArray.p.filter behaves correctly on SendableTypedArrays backed by resizable + buffers that grow mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(fixedLength.filter(ResizeMidIteration)), []); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(fixedLengthWithOffset.filter(ResizeMidIteration)), []); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(lengthTracking.filter(ResizeMidIteration)), []); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(lengthTrackingWithOffset.filter(ResizeMidIteration)), []); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..9ccb8bb19f5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + SendableTypedArray.p.filter behaves correctly on SendableTypedArrays backed by resizable + buffers that are shrunk mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(fixedLength.filter(ResizeMidIteration)),[]); + assert.compareArray(values, [ + 0, + 2, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(fixedLengthWithOffset.filter(ResizeMidIteration)),[]); + assert.compareArray(values, [ + 4, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(lengthTracking.filter(ResizeMidIteration)),[]); + assert.compareArray(values, [ + 0, + 2, + 4, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.compareArray(ToNumbers(lengthTrackingWithOffset.filter(ResizeMidIteration)),[]); + assert.compareArray(values, [ + 4, + undefined + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer.js new file mode 100644 index 00000000000..c220cb33a28 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer.js @@ -0,0 +1,132 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + SendableTypedArray.p.filter behaves correctly on SendableTypedArrays backed by resizable + buffers +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + + // Orig. array: [0, 1, 2, 3] + // [0, 1, 2, 3] << fixedLength + // [2, 3] << fixedLengthWithOffset + // [0, 1, 2, 3, ...] << lengthTracking + // [2, 3, ...] << lengthTrackingWithOffset + + function isEven(n) { + return n != undefined && Number(n) % 2 == 0; + } + assert.compareArray(ToNumbers(fixedLength.filter(isEven)), [ + 0, + 2 + ]); + assert.compareArray(ToNumbers(fixedLengthWithOffset.filter(isEven)), [2]); + assert.compareArray(ToNumbers(lengthTracking.filter(isEven)), [ + 0, + 2 + ]); + assert.compareArray(ToNumbers(lengthTrackingWithOffset.filter(isEven)), [2]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 1, 2] + // [0, 1, 2, ...] << lengthTracking + // [2, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + fixedLength.filter(isEven); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.filter(isEven); + }); + + assert.compareArray(ToNumbers(lengthTracking.filter(isEven)), [ + 0, + 2 + ]); + assert.compareArray(ToNumbers(lengthTrackingWithOffset.filter(isEven)), [2]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.filter(isEven); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.filter(isEven); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.filter(isEven); + }); + + assert.compareArray(ToNumbers(lengthTracking.filter(isEven)), [0]); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.filter(isEven); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.filter(isEven); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.filter(isEven); + }); + + assert.compareArray(ToNumbers(lengthTracking.filter(isEven)), []); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + + // Orig. array: [0, 1, 2, 3, 4, 5] + // [0, 1, 2, 3] << fixedLength + // [2, 3] << fixedLengthWithOffset + // [0, 1, 2, 3, 4, 5, ...] << lengthTracking + // [2, 3, 4, 5, ...] << lengthTrackingWithOffset + + assert.compareArray(ToNumbers(fixedLength.filter(isEven)), [ + 0, + 2 + ]); + assert.compareArray(ToNumbers(fixedLengthWithOffset.filter(isEven)), [2]); + assert.compareArray(ToNumbers(lengthTracking.filter(isEven)), [ + 0, + 2, + 4 + ]); + assert.compareArray(ToNumbers(lengthTrackingWithOffset.filter(isEven)), [ + 2, + 4 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js new file mode 100644 index 00000000000..edfdbed14dc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Return does not share buffer +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + 13. Return A. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42]); + var result; + + result = sample.filter(function() { return true; }); + assert.notSameValue(result.buffer, sample.buffer); + + result = sample.filter(function() { return false; }); + assert.notSameValue(result.buffer, sample.buffer); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js b/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js new file mode 100644 index 00000000000..1206a308906 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Returns empty if every callbackfn returns boolean false +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 12. For each element e of kept + a. Perform ! Set(A, ! ToString(n), e, true). + b. Increment n by 1. + 13. Return A. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + [ + false, + "", + 0, + -0, + NaN, + undefined, + null + ].forEach(function(val) { + var result = sample.filter(function() { + return val; + }); + assert.sameValue(result.length, 0, val); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js b/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js new file mode 100644 index 00000000000..b6b4b812b71 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Returns full length result if every callbackfn returns boolean false +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 12. For each element e of kept + a. Perform ! Set(A, ! ToString(n), e, true). + b. Increment n by 1. + 13. Return A. +includes: [testTypedArray.js, compareArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42]); + + [ + true, + 1, + "test262", + Symbol("1"), + {}, + [], + -1, + Infinity, + -Infinity, + 0.1, + -0.1 + ].forEach(function(val) { + var result = sample.filter(function() { return val; }); + assert(compareArray(result, sample), val); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..2582a726fdb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.filter, + 'function', + 'implements SendableTypedArray.prototype.filter' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.filter(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.filter(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the filter operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.filter(() => {}); + throw new Test262Error('filter completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js new file mode 100644 index 00000000000..dad29c24b9d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Throws a TypeError if new typedArray's length < count +info: | + 23.2.3.10 %SendableTypedArray%.prototype.filter ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 23.2.4.1 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + 23.2.4.2 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); + const ta = new TA(rab1); + const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); + const lengthTracking = new TA(rab2); + rab2.resize(0); + ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; + assert.throws(TypeError, function() { + ta.filter(() => true); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js new file mode 100644 index 00000000000..8a845a7dd17 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: Return abrupt from SpeciesConstructor's get Constructor +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + Object.defineProperty(sample, "constructor", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.filter(function() { + return true; + }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js new file mode 100644 index 00000000000..a6430c7fbe3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: get inherited constructor on SpeciesConstructor +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + var calls = 0; + var result; + + Object.defineProperty(TA.prototype, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.filter(function() { + return true; + }); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + undefined, + "used defaultCtor but still checks the inherited .constructor" + ); + + calls = 6; + result.constructor; + assert.sameValue( + calls, + 7, + "result.constructor triggers the inherited accessor property" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js new file mode 100644 index 00000000000..b6379888ea6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Throws if O.constructor returns a non-Object and non-undefined value +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + 4. If Type(C) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var callbackfn = function() { return true; }; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + sample.constructor = 42; + assert.throws(TypeError, function() { + sample.filter(callbackfn); + }, "42"); + + sample.constructor = "1"; + assert.throws(TypeError, function() { + sample.filter(callbackfn); + }, "string"); + + sample.constructor = null; + assert.throws(TypeError, function() { + sample.filter(callbackfn); + }, "null"); + + sample.constructor = NaN; + assert.throws(TypeError, function() { + sample.filter(callbackfn); + }, "NaN"); + + sample.constructor = false; + assert.throws(TypeError, function() { + sample.filter(callbackfn); + }, "false"); + + sample.constructor = Symbol("1"); + assert.throws(TypeError, function() { + sample.filter(callbackfn); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js new file mode 100644 index 00000000000..eea4d32b8cd --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: get constructor on SpeciesConstructor +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + var calls = 0; + var result; + + Object.defineProperty(sample, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.filter(function() { return true; }); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + TA, + "use defaultCtor on an undefined return - .constructor check" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js new file mode 100644 index 00000000000..79e606c1513 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Returns abrupt from get @@species on found constructor +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.filter(function() { return true; }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js new file mode 100644 index 00000000000..746b2dd9e50 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Verify arguments on custom @@species construct call +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 42, 42]); + var result, ctorThis; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(count) { + result = arguments; + ctorThis = this; + return new TA(count); + }; + + sample.filter(function(v) { return v === 42; }); + + assert.sameValue(result.length, 1, "called with 1 argument"); + assert.sameValue(result[0], 2, "[0] is the new captured length"); + + assert( + ctorThis instanceof sample.constructor[Symbol.species], + "`this` value in the @@species fn is an instance of the function itself" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js new file mode 100644 index 00000000000..0992779f9ad --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Throws a TypeError if new typedArray's length < count +info: | + 23.2.3.10 %SendableTypedArray%.prototype.filter ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 23.2.4.1 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + 23.2.4.2 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + const rab = new ArrayBuffer(10, {maxByteLength: 20}); + const lengthTracking = new TA(rab); + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return lengthTracking; + }; + rab.resize(0); + assert.throws(TypeError, function() { + sample.filter(() => { return true; }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js new file mode 100644 index 00000000000..0c0437e4df1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Throws a TypeError if new typedArray's length < captured +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return new TA(); + }; + + assert.throws(TypeError, function() { + sample.filter(function() { return true; }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js new file mode 100644 index 00000000000..c45d1063ee2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Does not throw a TypeError if new typedArray's length >= captured +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var customCount, result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return new TA(customCount); + }; + + customCount = 2; + result = sample.filter(function() { return true; }); + assert.sameValue(result.length, customCount, "length == count"); + + customCount = 5; + result = sample.filter(function() { return true; }); + assert.sameValue(result.length, customCount, "length > count"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js new file mode 100644 index 00000000000..e9d3f7202b5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Custom @@species constructor may return a different SendableTypedArray +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testTypedArray.js, compareArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40]); + var otherTA = TA === Int8Array ? Int16Array : Int8Array; + var other = new otherTA([1, 0, 1]); + var result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return other; + }; + + result = sample.filter(function() {}); + + assert.sameValue(result, other, "returned another typedarray"); + assert(compareArray(result, [1, 0, 1]), "the returned object is preserved"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js new file mode 100644 index 00000000000..b76efe4858e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Custom @@species constructor throws if it does not return a compatible object +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + sample.constructor[Symbol.species] = Array; + + assert.throws(TypeError, function() { + sample.filter(function() {}); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js new file mode 100644 index 00000000000..ec50aa09a15 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Use custom @@species constructor if available +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testTypedArray.js, compareArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42]); + var calls = 0; + var other, result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(captured) { + calls++; + other = new TA(captured); + return other; + }; + + result = sample.filter(function() { return true; }); + + assert.sameValue(calls, 1, "ctor called once"); + assert.sameValue(result, other, "return is instance of custom constructor"); + assert(compareArray(result, [40, 41, 42]), "values are set on the new obj"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js new file mode 100644 index 00000000000..57f6ec4e468 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Throws if returned @@species is not a constructor, null or undefined. +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + 7. If IsConstructor(S) is true, return S. + 8. Throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + sample.constructor[Symbol.species] = 0; + assert.throws(TypeError, function() { + sample.filter(function() {}); + }, "0"); + + sample.constructor[Symbol.species] = "string"; + assert.throws(TypeError, function() { + sample.filter(function() {}); + }, "string"); + + sample.constructor[Symbol.species] = {}; + assert.throws(TypeError, function() { + sample.filter(function() {}); + }, "{}"); + + sample.constructor[Symbol.species] = NaN; + assert.throws(TypeError, function() { + sample.filter(function() {}); + }, "NaN"); + + sample.constructor[Symbol.species] = false; + assert.throws(TypeError, function() { + sample.filter(function() {}); + }, "false"); + + sample.constructor[Symbol.species] = true; + assert.throws(TypeError, function() { + sample.filter(function() {}); + }, "true"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js new file mode 100644 index 00000000000..7aa068cfa9d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Use defaultConstructor if @@species is either undefined or null +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var result; + + sample.constructor = {}; + + result = sample.filter(function() {}); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "undefined @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "undefined @@species - ctor check"); + + sample.constructor[Symbol.species] = null; + result = sample.filter(function() {}); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "null @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "null @@species - ctor check"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js new file mode 100644 index 00000000000..7297407e58b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + get @@species from found constructor +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var calls = 0; + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + calls++; + } + }); + + sample.filter(function() {}); + + assert.sameValue(calls, 1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-object.js new file mode 100644 index 00000000000..6b9f671644b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-object.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var filter = SendableTypedArray.prototype.filter; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + filter.call(undefined, callbackfn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + filter.call(null, callbackfn); +}, "this is null"); + +assert.throws(TypeError, function() { + filter.call(42, callbackfn); +}, "this is 42"); + +assert.throws(TypeError, function() { + filter.call("1", callbackfn); +}, "this is a string"); + +assert.throws(TypeError, function() { + filter.call(true, callbackfn); +}, "this is true"); + +assert.throws(TypeError, function() { + filter.call(false, callbackfn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + filter.call(s, callbackfn); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..985b664dd3e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var filter = SendableTypedArray.prototype.filter; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + filter.call({}, callbackfn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + filter.call([], callbackfn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + filter.call(ab, callbackfn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + filter.call(dv, callbackfn); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js new file mode 100644 index 00000000000..8692ce8849a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Integer indexed values are not cached before interaction +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 9. Repeat, while k < len + ... + c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + sample.filter(function(v, i) { + if (i < sample.length - 1) { + sample[i+1] = 42; + } + + assert.sameValue( + v, 42, "method does not cache values before callbackfn calls" + ); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js b/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js new file mode 100644 index 00000000000..7331443a9ed --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.filter +description: > + Returned instance with filtered values set on it +info: | + 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) + + ... + 12. For each element e of kept + a. Perform ! Set(A, ! ToString(n), e, true). + b. Increment n by 1. + 13. Return A. +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([41, 1, 42, 7]); + var result; + + result = sample.filter(function() { return true; }); + assert(compareArray(result, [41, 1, 42, 7]), "values are set #1"); + + result = sample.filter(function(v) { + return v > 40; + }); + assert(compareArray(result, [41, 42]), "values are set #2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/detached-buffer.js new file mode 100644 index 00000000000..41b83ba2ff8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.find(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js new file mode 100644 index 00000000000..feadbbbd360 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + [[Get]] of "length" uses [[ArrayLength]] +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + Object.defineProperty(TA.prototype, "length", { + get: function() { + throw new Test262Error(); + } + }); + + var sample = new TA([42n]); + + Object.defineProperty(sample, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true + }); + + assert.sameValue( + sample.find(function() { return true; }), + 42n + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js new file mode 100644 index 00000000000..b3d555206a1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Change values during predicate call +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + 5. Let k be 0. + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var arr = [1n, 2n, 3n]; + var sample; + var result; + + sample = new TA(3); + sample.find(function(val, i) { + sample[i] = arr[i]; + + assert.sameValue(val, 0n, "value is not mapped to instance"); + }); + assert(compareArray(sample, arr), "values set during each predicate call"); + + sample = new TA(arr); + result = sample.find(function(val, i) { + if ( i === 0 ) { + sample[2] = 7n; + } + return val === 7n; + }); + assert.sameValue(result, 7n, "value found"); + + sample = new TA(arr); + result = sample.find(function(val, i) { + if ( i === 0 ) { + sample[2] = 7n; + } + return val === 3n; + }); + assert.sameValue(result, undefined, "value not found"); + + sample = new TA(arr); + result = sample.find(function(val, i) { + if ( i > 0 ) { + sample[0] = 7n; + } + return val === 7n; + }); + assert.sameValue(result, undefined, "value not found - changed after call"); + + sample = new TA(arr); + result = sample.find(function() { + sample[0] = 7n; + return true; + }); + assert.sameValue(result, 1n, "find() returns previous found value"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js new file mode 100644 index 00000000000..e484e85db27 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + 5. Let k be 0. + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39n, 2n, 62n]); + var results = []; + var result; + + sample.foo = "bar"; // Ignores non integer index properties + + sample.find(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 3, "predicate is called for each index"); + + result = results[0]; + assert.sameValue(result[0], 39n, "results[0][0] === 39, value"); + assert.sameValue(result[1], 0, "results[0][1] === 0, index"); + assert.sameValue(result[2], sample, "results[0][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[0].length === 3 arguments"); + + result = results[1]; + assert.sameValue(result[0], 2n, "results[1][0] === 2, value"); + assert.sameValue(result[1], 1, "results[1][1] === 1, index"); + assert.sameValue(result[2], sample, "results[1][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[1].length === 3 arguments"); + + result = results[2]; + assert.sameValue(result[0], 62n, "results[2][0] === 62, value"); + assert.sameValue(result[1], 2, "results[2][1] === 2, index"); + assert.sameValue(result[2], sample, "results[2][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[2].length === 3 arguments"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js new file mode 100644 index 00000000000..e34462edb6c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Verify predicate this on non-strict mode +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +flags: [noStrict] +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var T = this; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.find(function() { + result = this; + }); + + assert.sameValue(result, T, "without thisArg, predicate this is the global"); + + result = null; + sample.find(function() { + result = this; + }, undefined); + + assert.sameValue(result, T, "predicate this is the global when thisArg is undefined"); + + var o = {}; + result = null; + sample.find(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-strict.js new file mode 100644 index 00000000000..91d6266450f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-strict.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Verify predicate this on strict mode +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +flags: [onlyStrict] +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.find(function() { + result = this; + }); + + assert.sameValue( + result, + undefined, + "without thisArg, predicate this is undefined" + ); + + var o = {}; + sample.find(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js new file mode 100644 index 00000000000..1b78d29092a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Throws a TypeError exception if predicate is not callable. +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 3. If IsCallable(predicate) is false, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.find({}); + }, "object"); + + assert.throws(TypeError, function() { + sample.find(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.find(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.find(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.find(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.find(1); + }, "number"); + + assert.throws(TypeError, function() { + sample.find(""); + }, "string"); + + assert.throws(TypeError, function() { + sample.find([]); + }, "array"); + + assert.throws(TypeError, function() { + sample.find(/./); + }, "regexp"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js new file mode 100644 index 00000000000..58d543f206d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Predicate may detach the buffer +info: | + %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 + + ... + + However, such optimization must not introduce any observable changes in the + specified behaviour of the algorithm and must take into account the + possibility that calls to predicate may cause the this value to become + detached. + + + Array.prototype.find ( predicate[ , thisArg ] ) + + Let O be ? ToObject(this value). + Let len be ? LengthOfArrayLike(O). + If IsCallable(predicate) is false, throw a TypeError exception. + Let k be 0. + Repeat, while k < len, + Let Pk be ! ToString(𝔽(k)). + Let kValue be ? Get(O, Pk). + Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + If testResult is true, return kValue. + Set k to k + 1. + Return undefined. + + IntegerIndexedElementGet ( O, index ) + + ... + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + If IsDetachedBuffer(buffer) is true, return undefined. + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.find(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + }); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js new file mode 100644 index 00000000000..dc78e2eaed4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Predicate is not called on empty instances +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + var called = false; + + var result = sample.find(function() { + called = true; + return true; + }); + + assert.sameValue( + called, + false, + "empty instance does not call predicate" + ); + assert.sameValue( + result, + undefined, + "find returns undefined when predicate is not called" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js new file mode 100644 index 00000000000..f9ddbfe6e00 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Return abrupt from predicate call. +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + var predicate = function() { + throw new Test262Error(); + }; + + assert.throws(Test262Error, function() { + sample.find(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..b6adea0bb90 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.find, + 'function', + 'implements SendableTypedArray.prototype.find' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.find(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.find(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the find operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.find(() => {}); + throw new Test262Error('find completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js new file mode 100644 index 00000000000..e9f4d621d94 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Return found value if predicate return a boolean true value. +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + d. If testResult is true, return kValue. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39n, 2n, 62n]); + var called, result; + + called = 0; + result = sample.find(function() { + called++; + return true; + }); + assert.sameValue(result, 39n, "returned true on sample[0]"); + assert.sameValue(called, 1, "predicate was called once"); + + called = 0; + result = sample.find(function(val) { + called++; + return val === 62n; + }); + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, 62n, "returned true on sample[3]"); + + result = sample.find(function() { return "string"; }); + assert.sameValue(result, 39n, "ToBoolean(string)"); + + result = sample.find(function() { return {}; }); + assert.sameValue(result, 39n, "ToBoolean(object)"); + + result = sample.find(function() { return Symbol(""); }); + assert.sameValue(result, 39n, "ToBoolean(symbol)"); + + result = sample.find(function() { return 1; }); + assert.sameValue(result, 39n, "ToBoolean(number)"); + + result = sample.find(function() { return -1; }); + assert.sameValue(result, 39n, "ToBoolean(negative number)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js new file mode 100644 index 00000000000..469bc2ff6c1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Return undefined if predicate always returns a boolean false value. +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... + 7. Return undefined. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + var called = 0; + + var result = sample.find(function() { + called++; + return false; + }); + + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, undefined); + + result = sample.find(function() { return ""; }); + assert.sameValue(result, undefined, "ToBoolean(empty string)"); + + result = sample.find(function() { return undefined; }); + assert.sameValue(result, undefined, "ToBoolean(undefined)"); + + result = sample.find(function() { return null; }); + assert.sameValue(result, undefined, "ToBoolean(null)"); + + result = sample.find(function() { return 0; }); + assert.sameValue(result, undefined, "ToBoolean(0)"); + + result = sample.find(function() { return -0; }); + assert.sameValue(result, undefined, "ToBoolean(-0)"); + + result = sample.find(function() { return NaN; }); + assert.sameValue(result, undefined, "ToBoolean(NaN)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js new file mode 100644 index 00000000000..941770effb8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: Instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var finalElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = sample.find(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + finalElement = undefined; + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + finalElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)'); + assert.compareArray(indices, [0, 1, 2], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, undefined, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = sample.find(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, undefined, 'result (grow)'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js new file mode 100644 index 00000000000..21ef474d589 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.find(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js new file mode 100644 index 00000000000..2666bf1a106 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + [[Get]] of "length" uses [[ArrayLength]] +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithSendableTypedArrayConstructors(function(TA) { + Object.defineProperty(TA.prototype, "length", { + get: function() { + throw new Test262Error(); + } + }); + + var sample = new TA([42]); + + Object.defineProperty(sample, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true + }); + + assert.sameValue( + sample.find(function() { return true; }), + 42 + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/find/invoked-as-func.js new file mode 100644 index 00000000000..94bc8089e39 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/invoked-as-func.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var find = SendableTypedArray.prototype.find; + +assert.sameValue(typeof find, 'function'); + +assert.throws(TypeError, function() { + find(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/find/invoked-as-method.js new file mode 100644 index 00000000000..4d4e2295147 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/invoked-as-method.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.find, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.find(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/length.js b/test/sendable/builtins/TypedArray/prototype/find/length.js new file mode 100644 index 00000000000..1e6b6eda97a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + %SendableTypedArray%.prototype.find.length is 1. +info: | + %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.find, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/name.js b/test/sendable/builtins/TypedArray/prototype/find/name.js new file mode 100644 index 00000000000..145f9880690 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + %SendableTypedArray%.prototype.find.name is "find". +info: | + %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.find, "name", { + value: "find", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/find/not-a-constructor.js new file mode 100644 index 00000000000..dbffa5df825 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.find 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.find), + false, + 'isConstructor(SendableTypedArray.prototype.find) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.find(() => {}); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js new file mode 100644 index 00000000000..b4fcf8eeab5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Change values during predicate call +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + 5. Let k be 0. + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var arr = [1, 2, 3]; + var sample; + var result; + + sample = new TA(3); + sample.find(function(val, i) { + sample[i] = arr[i]; + + assert.sameValue(val, 0, "value is not mapped to instance"); + }); + assert(compareArray(sample, arr), "values set during each predicate call"); + + sample = new TA(arr); + result = sample.find(function(val, i) { + if ( i === 0 ) { + sample[2] = 7; + } + return val === 7; + }); + assert.sameValue(result, 7, "value found"); + + sample = new TA(arr); + result = sample.find(function(val, i) { + if ( i === 0 ) { + sample[2] = 7; + } + return val === 3; + }); + assert.sameValue(result, undefined, "value not found"); + + sample = new TA(arr); + result = sample.find(function(val, i) { + if ( i > 0 ) { + sample[0] = 7; + } + return val === 7; + }); + assert.sameValue(result, undefined, "value not found - changed after call"); + + sample = new TA(arr); + result = sample.find(function() { + sample[0] = 7; + return true; + }); + assert.sameValue(result, 1, "find() returns previous found value"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js new file mode 100644 index 00000000000..54ae928585d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + 5. Let k be 0. + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39, 2, 62]); + var results = []; + var result; + + sample.foo = "bar"; // Ignores non integer index properties + + sample.find(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 3, "predicate is called for each index"); + + result = results[0]; + assert.sameValue(result[0], 39, "results[0][0] === 39, value"); + assert.sameValue(result[1], 0, "results[0][1] === 0, index"); + assert.sameValue(result[2], sample, "results[0][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[0].length === 3 arguments"); + + result = results[1]; + assert.sameValue(result[0], 2, "results[1][0] === 2, value"); + assert.sameValue(result[1], 1, "results[1][1] === 1, index"); + assert.sameValue(result[2], sample, "results[1][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[1].length === 3 arguments"); + + result = results[2]; + assert.sameValue(result[0], 62, "results[2][0] === 62, value"); + assert.sameValue(result[1], 2, "results[2][1] === 2, index"); + assert.sameValue(result[2], sample, "results[2][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[2].length === 3 arguments"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js new file mode 100644 index 00000000000..f60e49b230b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Verify predicate this on non-strict mode +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +flags: [noStrict] +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var T = this; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.find(function() { + result = this; + }); + + assert.sameValue(result, T, "without thisArg, predicate this is the global"); + + result = null; + sample.find(function() { + result = this; + }, undefined); + + assert.sameValue(result, T, "predicate this is the global when thisArg is undefined"); + + var o = {}; + result = null; + sample.find(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js new file mode 100644 index 00000000000..ba041a4d18d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Verify predicate this on strict mode +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +flags: [onlyStrict] +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.find(function() { + result = this; + }); + + assert.sameValue( + result, + undefined, + "without thisArg, predicate this is undefined" + ); + + var o = {}; + sample.find(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js new file mode 100644 index 00000000000..1bb8dad2c6c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Throws a TypeError exception if predicate is not callable. +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 3. If IsCallable(predicate) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.find({}); + }, "object"); + + assert.throws(TypeError, function() { + sample.find(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.find(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.find(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.find(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.find(1); + }, "number"); + + assert.throws(TypeError, function() { + sample.find(""); + }, "string"); + + assert.throws(TypeError, function() { + sample.find([]); + }, "array"); + + assert.throws(TypeError, function() { + sample.find(/./); + }, "regexp"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js new file mode 100644 index 00000000000..e6f3a4daa1c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Predicate may detach the buffer +info: | + %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 + + ... + + However, such optimization must not introduce any observable changes in the + specified behaviour of the algorithm and must take into account the + possibility that calls to predicate may cause the this value to become + detached. + + + Array.prototype.find ( predicate[ , thisArg ] ) + + Let O be ? ToObject(this value). + Let len be ? LengthOfArrayLike(O). + If IsCallable(predicate) is false, throw a TypeError exception. + Let k be 0. + Repeat, while k < len, + Let Pk be ! ToString(F(k)). + Let kValue be ? Get(O, Pk). + Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, F(k), O »)). + If testResult is true, return kValue. + Set k to k + 1. + Return undefined. + + IntegerIndexedElementGet ( O, index ) + + ... + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + If IsDetachedBuffer(buffer) is true, return undefined. + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.find(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + }); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js new file mode 100644 index 00000000000..87107d2da39 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Predicate is not called on empty instances +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + var called = false; + + var result = sample.find(function() { + called = true; + return true; + }); + + assert.sameValue( + called, + false, + "empty instance does not call predicate" + ); + assert.sameValue( + result, + undefined, + "find returns undefined when predicate is not called" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/find/prop-desc.js new file mode 100644 index 00000000000..8c018a55e94 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + "find" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'find', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..5e573f739e8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + SendableTypedArray.p.find behaves correctly when receiver is backed by resizable + buffer that is grown mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLength.find(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLengthWithOffset.find(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTracking.find(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTrackingWithOffset.find(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..11902e66c15 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + SendableTypedArray.p.find behaves correctly when receiver is backed by resizable + buffer that is shrunk mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLength.find(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 0, + 2, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLengthWithOffset.find(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 4, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTracking.find(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 0, + 2, + 4, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTrackingWithOffset.find(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 4, + undefined + ]); +} + diff --git a/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer.js new file mode 100644 index 00000000000..1ad8c26825a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer.js @@ -0,0 +1,115 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + SendableTypedArray.p.find behaves correctly when receiver is backed by resizable + buffer +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + function isTwoOrFour(n) { + return n == 2 || n == 4; + } + assert.sameValue(Number(fixedLength.find(isTwoOrFour)), 2); + assert.sameValue(Number(fixedLengthWithOffset.find(isTwoOrFour)), 4); + assert.sameValue(Number(lengthTracking.find(isTwoOrFour)), 2); + assert.sameValue(Number(lengthTrackingWithOffset.find(isTwoOrFour)), 4); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + fixedLength.find(isTwoOrFour); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.find(isTwoOrFour); + }); + + assert.sameValue(Number(lengthTracking.find(isTwoOrFour)), 2); + assert.sameValue(Number(lengthTrackingWithOffset.find(isTwoOrFour)), 4); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.find(isTwoOrFour); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.find(isTwoOrFour); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.find(isTwoOrFour); + }); + + assert.sameValue(lengthTracking.find(isTwoOrFour), undefined); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.find(isTwoOrFour); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.find(isTwoOrFour); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.find(isTwoOrFour); + }); + + assert.sameValue(lengthTracking.find(isTwoOrFour), undefined); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 0); + } + taWrite[4] = MayNeedBigInt(taWrite, 2); + taWrite[5] = MayNeedBigInt(taWrite, 4); + + // Orig. array: [0, 0, 0, 0, 2, 4] + // [0, 0, 0, 0] << fixedLength + // [0, 0] << fixedLengthWithOffset + // [0, 0, 0, 0, 2, 4, ...] << lengthTracking + // [0, 0, 2, 4, ...] << lengthTrackingWithOffset + + assert.sameValue(fixedLength.find(isTwoOrFour), undefined); + assert.sameValue(fixedLengthWithOffset.find(isTwoOrFour), undefined); + assert.sameValue(Number(lengthTracking.find(isTwoOrFour)), 2); + assert.sameValue(Number(lengthTrackingWithOffset.find(isTwoOrFour)), 2); +} diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js new file mode 100644 index 00000000000..fcc56365cd9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Return abrupt from predicate call. +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + var predicate = function() { + throw new Test262Error(); + }; + + assert.throws(Test262Error, function() { + sample.find(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..46751f4dd67 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.find, + 'function', + 'implements SendableTypedArray.prototype.find' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.find(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.find(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the find operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.find(() => {}); + throw new Test262Error('find completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js new file mode 100644 index 00000000000..34d67846986 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Return found value if predicate return a boolean true value. +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + d. If testResult is true, return kValue. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39, 2, 62]); + var called, result; + + called = 0; + result = sample.find(function() { + called++; + return true; + }); + assert.sameValue(result, 39, "returned true on sample[0]"); + assert.sameValue(called, 1, "predicate was called once"); + + called = 0; + result = sample.find(function(val) { + called++; + return val === 62; + }); + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, 62, "returned true on sample[3]"); + + result = sample.find(function() { return "string"; }); + assert.sameValue(result, 39, "ToBoolean(string)"); + + result = sample.find(function() { return {}; }); + assert.sameValue(result, 39, "ToBoolean(object)"); + + result = sample.find(function() { return Symbol(""); }); + assert.sameValue(result, 39, "ToBoolean(symbol)"); + + result = sample.find(function() { return 1; }); + assert.sameValue(result, 39, "ToBoolean(number)"); + + result = sample.find(function() { return -1; }); + assert.sameValue(result, 39, "ToBoolean(negative number)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js new file mode 100644 index 00000000000..f6d07db5357 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Return undefined if predicate always returns a boolean false value. +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.find is a distinct function that implements the same + algorithm as Array.prototype.find as defined in 22.1.3.8 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". The implementation of the algorithm may be optimized with + the knowledge that the this value is an object that has a fixed length and + whose integer indexed properties are not sparse. + + ... + + 22.1.3.8 Array.prototype.find ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... + 7. Return undefined. +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + var called = 0; + + var result = sample.find(function() { + called++; + return false; + }); + + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, undefined); + + result = sample.find(function() { return ""; }); + assert.sameValue(result, undefined, "ToBoolean(empty string)"); + + result = sample.find(function() { return undefined; }); + assert.sameValue(result, undefined, "ToBoolean(undefined)"); + + result = sample.find(function() { return null; }); + assert.sameValue(result, undefined, "ToBoolean(null)"); + + result = sample.find(function() { return 0; }); + assert.sameValue(result, undefined, "ToBoolean(0)"); + + result = sample.find(function() { return -0; }); + assert.sameValue(result, undefined, "ToBoolean(-0)"); + + result = sample.find(function() { return NaN; }); + assert.sameValue(result, undefined, "ToBoolean(NaN)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/find/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/find/this-is-not-object.js new file mode 100644 index 00000000000..98778eba08b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/this-is-not-object.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var find = SendableTypedArray.prototype.find; +var predicate = function() {}; + +assert.throws(TypeError, function() { + find.call(undefined, predicate); +}, "this is undefined"); + +assert.throws(TypeError, function() { + find.call(null, predicate); +}, "this is null"); + +assert.throws(TypeError, function() { + find.call(42, predicate); +}, "this is 42"); + +assert.throws(TypeError, function() { + find.call("1", predicate); +}, "this is a string"); + +assert.throws(TypeError, function() { + find.call(true, predicate); +}, "this is true"); + +assert.throws(TypeError, function() { + find.call(false, predicate); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + find.call(s, predicate); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..e7c49dba7a9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.find +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var find = SendableTypedArray.prototype.find; +var predicate = function() {}; + +assert.throws(TypeError, function() { + find.call({}, predicate); +}, "this is an Object"); + +assert.throws(TypeError, function() { + find.call([], predicate); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + find.call(ab, predicate); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + find.call(dv, predicate); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js new file mode 100644 index 00000000000..4ec9effba72 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.findIndex(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js new file mode 100644 index 00000000000..a880836a31a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + [[Get]] of "length" uses [[ArrayLength]] +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + Object.defineProperty(TA.prototype, "length", { + get: function() { + throw new Test262Error(); + } + }); + + var sample = new TA([42n]); + + Object.defineProperty(sample, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true + }); + + assert.sameValue( + sample.findIndex(function() { return true; }), + 0 + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js new file mode 100644 index 00000000000..80b4b59d1d0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Change values during predicate call +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var arr = [10n, 20n, 30n]; + var sample; + var result; + + sample = new TA(3); + sample.findIndex(function(val, i) { + sample[i] = arr[i]; + + assert.sameValue(val, 0n, "value is not mapped to instance"); + }); + assert(compareArray(sample, arr), "values set during each predicate call"); + + sample = new TA(arr); + result = sample.findIndex(function(val, i) { + if ( i === 0 ) { + sample[2] = 7n; + } + return val === 7n; + }); + assert.sameValue(result, 2, "value found"); + + sample = new TA(arr); + result = sample.findIndex(function(val, i) { + if ( i === 0 ) { + sample[2] = 7n; + } + return val === 30n; + }); + assert.sameValue(result, -1, "value not found"); + + sample = new TA(arr); + result = sample.findIndex(function(val, i) { + if ( i > 0 ) { + sample[0] = 7n; + } + return val === 7n; + }); + assert.sameValue(result, -1, "value not found - changed after call"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js new file mode 100644 index 00000000000..b1607095437 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + 5. Let k be 0. + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39n, 2n, 62n]); + var results = []; + var result; + + sample.foo = "bar"; // Ignores non integer index properties + + sample.findIndex(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 3, "predicate is called for each index"); + + result = results[0]; + assert.sameValue(result[0], 39n, "results[0][0] === 39, value"); + assert.sameValue(result[1], 0, "results[0][1] === 0, index"); + assert.sameValue(result[2], sample, "results[0][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[0].length === 3, arguments"); + + result = results[1]; + assert.sameValue(result[0], 2n, "results[1][0] === 2, value"); + assert.sameValue(result[1], 1, "results[1][1] === 1, index"); + assert.sameValue(result[2], sample, "results[1][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[1].length === 3, arguments"); + + result = results[2]; + assert.sameValue(result[0], 62n, "results[2][0] === 62, value"); + assert.sameValue(result[1], 2, "results[2][1] === 2, index"); + assert.sameValue(result[2], sample, "results[2][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[2].length === 3, arguments"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js new file mode 100644 index 00000000000..8be0de2b156 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Verify predicate this on non-strict mode +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + 5. Let k be 0. + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +flags: [noStrict] +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var T = this; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.findIndex(function() { + result = this; + }); + + assert.sameValue(result, T, "without thisArg, predicate this is the global"); + + result = null; + sample.findIndex(function() { + result = this; + }, undefined); + + assert.sameValue(result, T, "predicate this is the global when thisArg is undefined"); + + var o = {}; + result = null; + sample.findIndex(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict.js new file mode 100644 index 00000000000..cd94c7a5b59 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + 5. Let k be 0. + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +flags: [onlyStrict] +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.findIndex(function() { + result = this; + }); + + assert.sameValue( + result, + undefined, + "without thisArg, predicate this is undefined" + ); + + var o = {}; + sample.findIndex(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js new file mode 100644 index 00000000000..a59f5211ba3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Throws a TypeError exception if predicate is not callable. +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 3. If IsCallable(predicate) is false, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.findIndex({}); + }, "{}"); + + assert.throws(TypeError, function() { + sample.findIndex(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.findIndex(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.findIndex(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.findIndex(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.findIndex(1); + }, "1"); + + assert.throws(TypeError, function() { + sample.findIndex(""); + }, "string"); + + assert.throws(TypeError, function() { + sample.findIndex([]); + }, "[]"); + + assert.throws(TypeError, function() { + sample.findIndex(/./); + }, "/./"); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js new file mode 100644 index 00000000000..75aa30a1315 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Predicate may detach the buffer +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + b. Let kValue be ? Get(O, Pk). + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... + + 9.4.5.8 IntegerIndexedElementGet ( O, index ) + + ... + 3. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var loops = 0; + + sample.findIndex(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + }); + assert.sameValue(loops, 2, "predicate is called once"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js new file mode 100644 index 00000000000..2a575a032dd --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Predicate is not called on an empty instance +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... + 7. Return -1. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + var called = false; + + var predicate = function() { + called = true; + return true; + }; + + var result = sample.findIndex(predicate); + + assert.sameValue( + called, false, + "does not call predicate" + ); + assert.sameValue( + result, -1, + "returns -1 on an empty instance" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js new file mode 100644 index 00000000000..94393730393 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Return abrupt from predicate call. +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 5. Let k be 0. + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + assert.throws(Test262Error, function() { + sample.findIndex(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..fe1d5a76c1c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.findIndex, + 'function', + 'implements SendableTypedArray.prototype.findIndex' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.findIndex(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.findIndex(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the findIndex operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.findIndex(() => {}); + throw new Test262Error('findIndex completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js new file mode 100644 index 00000000000..6f605ba52be --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Return index if predicate return a boolean true value. +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 5. Let k be 0. + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + d. If testResult is true, return k. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39n, 3n, 9n]); + var called = 0; + + var result = sample.findIndex(function() { + called++; + return true; + }); + + assert.sameValue(result, 0, "returned true on sample[0]"); + assert.sameValue(called, 1, "predicate was called once"); + + called = 0; + result = sample.findIndex(function(val) { + called++; + return val === 9n; + }); + + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, 2, "returned true on sample[3]"); + + result = sample.findIndex(function() { return "string"; }); + assert.sameValue(result, 0, "ToBoolean(string)"); + + result = sample.findIndex(function() { return {}; }); + assert.sameValue(result, 0, "ToBoolean(object)"); + + result = sample.findIndex(function() { return Symbol(""); }); + assert.sameValue(result, 0, "ToBoolean(symbol)"); + + result = sample.findIndex(function() { return 1; }); + assert.sameValue(result, 0, "ToBoolean(number)"); + + result = sample.findIndex(function() { return -1; }); + assert.sameValue(result, 0, "ToBoolean(negative number)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js new file mode 100644 index 00000000000..cf9e67e14c3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Return -1 if predicate always returns a boolean false value. +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... + 7. Return -1. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1n, 2n, 3n]); + var called = 0; + + var result = sample.findIndex(function() { + called++; + return false; + }); + + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, -1, "result is -1 when predicate returns are false"); + + result = sample.findIndex(function() { return ""; }); + assert.sameValue(result, -1, "ToBoolean(string)"); + + result = sample.findIndex(function() { return undefined; }); + assert.sameValue(result, -1, "ToBoolean(undefined)"); + + result = sample.findIndex(function() { return null; }); + assert.sameValue(result, -1, "ToBoolean(null)"); + + result = sample.findIndex(function() { return 0; }); + assert.sameValue(result, -1, "ToBoolean(0)"); + + result = sample.findIndex(function() { return -0; }); + assert.sameValue(result, -1, "ToBoolean(-0)"); + + result = sample.findIndex(function() { return NaN; }); + assert.sameValue(result, -1, "ToBoolean(NaN)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js new file mode 100644 index 00000000000..94cdcfdec1c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: Instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var finalElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = sample.findIndex(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + finalElement = undefined; + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + finalElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)'); + assert.compareArray(indices, [0, 1, 2], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, -1, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = sample.findIndex(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, -1, 'result (grow)'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js new file mode 100644 index 00000000000..b3b77ec226c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.findIndex(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js new file mode 100644 index 00000000000..bb50b80ea8f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + [[Get]] of "length" uses [[ArrayLength]] +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithSendableTypedArrayConstructors(function(TA) { + Object.defineProperty(TA.prototype, "length", { + get: function() { + throw new Test262Error(); + } + }); + + var sample = new TA([42]); + + Object.defineProperty(sample, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true + }); + + assert.sameValue( + sample.findIndex(function() { return true; }), + 0 + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-func.js new file mode 100644 index 00000000000..91a16bd3ed6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-func.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var findIndex = SendableTypedArray.prototype.findIndex; + +assert.sameValue(typeof findIndex, 'function'); + +assert.throws(TypeError, function() { + findIndex(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-method.js new file mode 100644 index 00000000000..7ca5a9a14c9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-method.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.findIndex, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.findIndex(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/length.js b/test/sendable/builtins/TypedArray/prototype/findIndex/length.js new file mode 100644 index 00000000000..5d65b315706 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + %SendableTypedArray%.prototype.findIndex.length is 1. +info: | + %SendableTypedArray%.prototype.findIndex (predicate [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.findIndex, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/name.js b/test/sendable/builtins/TypedArray/prototype/findIndex/name.js new file mode 100644 index 00000000000..521c0475429 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + %SendableTypedArray%.prototype.findIndex.name is "findIndex". +info: | + %SendableTypedArray%.prototype.findIndex (predicate [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.findIndex, "name", { + value: "findIndex", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/findIndex/not-a-constructor.js new file mode 100644 index 00000000000..74a7f939795 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.findIndex 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.findIndex), + false, + 'isConstructor(SendableTypedArray.prototype.findIndex) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.findIndex(() => {}); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js new file mode 100644 index 00000000000..0de62a3d336 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Change values during predicate call +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var arr = [10, 20, 30]; + var sample; + var result; + + sample = new TA(3); + sample.findIndex(function(val, i) { + sample[i] = arr[i]; + + assert.sameValue(val, 0, "value is not mapped to instance"); + }); + assert(compareArray(sample, arr), "values set during each predicate call"); + + sample = new TA(arr); + result = sample.findIndex(function(val, i) { + if ( i === 0 ) { + sample[2] = 7; + } + return val === 7; + }); + assert.sameValue(result, 2, "value found"); + + sample = new TA(arr); + result = sample.findIndex(function(val, i) { + if ( i === 0 ) { + sample[2] = 7; + } + return val === 30; + }); + assert.sameValue(result, -1, "value not found"); + + sample = new TA(arr); + result = sample.findIndex(function(val, i) { + if ( i > 0 ) { + sample[0] = 7; + } + return val === 7; + }); + assert.sameValue(result, -1, "value not found - changed after call"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js new file mode 100644 index 00000000000..22d57b8b04f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + 5. Let k be 0. + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39, 2, 62]); + var results = []; + var result; + + sample.foo = "bar"; // Ignores non integer index properties + + sample.findIndex(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 3, "predicate is called for each index"); + + result = results[0]; + assert.sameValue(result[0], 39, "results[0][0] === 39, value"); + assert.sameValue(result[1], 0, "results[0][1] === 0, index"); + assert.sameValue(result[2], sample, "results[0][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[0].length === 3, arguments"); + + result = results[1]; + assert.sameValue(result[0], 2, "results[1][0] === 2, value"); + assert.sameValue(result[1], 1, "results[1][1] === 1, index"); + assert.sameValue(result[2], sample, "results[1][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[1].length === 3, arguments"); + + result = results[2]; + assert.sameValue(result[0], 62, "results[2][0] === 62, value"); + assert.sameValue(result[1], 2, "results[2][1] === 2, index"); + assert.sameValue(result[2], sample, "results[2][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[2].length === 3, arguments"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js new file mode 100644 index 00000000000..3ed551ab8c8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Verify predicate this on non-strict mode +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + 5. Let k be 0. + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +flags: [noStrict] +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var T = this; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.findIndex(function() { + result = this; + }); + + assert.sameValue(result, T, "without thisArg, predicate this is the global"); + + result = null; + sample.findIndex(function() { + result = this; + }, undefined); + + assert.sameValue(result, T, "predicate this is the global when thisArg is undefined"); + + var o = {}; + result = null; + sample.findIndex(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js new file mode 100644 index 00000000000..58e6e43ef7b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + 5. Let k be 0. + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +flags: [onlyStrict] +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.findIndex(function() { + result = this; + }); + + assert.sameValue( + result, + undefined, + "without thisArg, predicate this is undefined" + ); + + var o = {}; + sample.findIndex(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js new file mode 100644 index 00000000000..23cd2c79ba8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Throws a TypeError exception if predicate is not callable. +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 3. If IsCallable(predicate) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.findIndex({}); + }, "{}"); + + assert.throws(TypeError, function() { + sample.findIndex(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.findIndex(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.findIndex(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.findIndex(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.findIndex(1); + }, "1"); + + assert.throws(TypeError, function() { + sample.findIndex(""); + }, "string"); + + assert.throws(TypeError, function() { + sample.findIndex([]); + }, "[]"); + + assert.throws(TypeError, function() { + sample.findIndex(/./); + }, "/./"); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js new file mode 100644 index 00000000000..b460c8d90a7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Predicate may detach the buffer +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + Repeat, while k < len, + Let Pk be ! ToString(F(k)). + Let kValue be ? Get(O, Pk). + Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, F(k), O »)). + ... + + IntegerIndexedElementGet ( O, index ) + + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + If IsDetachedBuffer(buffer) is true, return undefined. + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var loops = 0; + + sample.findIndex(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + }); + assert.sameValue(loops, 2, "predicate is called once"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js new file mode 100644 index 00000000000..d275eed6f86 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Predicate is not called on an empty instance +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... + 7. Return -1. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + var called = false; + + var predicate = function() { + called = true; + return true; + }; + + var result = sample.findIndex(predicate); + + assert.sameValue( + called, false, + "does not call predicate" + ); + assert.sameValue( + result, -1, + "returns -1 on an empty instance" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/findIndex/prop-desc.js new file mode 100644 index 00000000000..fcefd8e511e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + "findIndex" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'findIndex', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..cc47e995f7f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + SendableTypedArray.p.findIndex behaves correctly when receiver is backed by resizable + buffer that is grown mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLength.findIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLengthWithOffset.findIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTracking.findIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTrackingWithOffset.findIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..269f6aa9e17 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + SendableTypedArray.p.findIndex behaves correctly when receiver is backed by resizable + buffer that is shrunk mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLength.findIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 0, + 2, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLengthWithOffset.findIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 4, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTracking.findIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 0, + 2, + 4, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTrackingWithOffset.findIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 4, + undefined + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer.js new file mode 100644 index 00000000000..e06a115e1a7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer.js @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + SendableTypedArray.p.findIndex behaves correctly when receiver is backed by resizable + buffer +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + function isTwoOrFour(n) { + return n == 2 || n == 4; + } + assert.sameValue(fixedLength.findIndex(isTwoOrFour), 1); + assert.sameValue(fixedLengthWithOffset.findIndex(isTwoOrFour), 0); + assert.sameValue(lengthTracking.findIndex(isTwoOrFour), 1); + assert.sameValue(lengthTrackingWithOffset.findIndex(isTwoOrFour), 0); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + fixedLength.findIndex(isTwoOrFour); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.findIndex(isTwoOrFour); + }); + + assert.sameValue(lengthTracking.findIndex(isTwoOrFour), 1); + assert.sameValue(lengthTrackingWithOffset.findIndex(isTwoOrFour), 0); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.findIndex(isTwoOrFour); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.findIndex(isTwoOrFour); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.findIndex(isTwoOrFour); + }); + assert.sameValue(lengthTracking.findIndex(isTwoOrFour), -1); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.findIndex(isTwoOrFour); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.findIndex(isTwoOrFour); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.findIndex(isTwoOrFour); + }); + + assert.sameValue(lengthTracking.findIndex(isTwoOrFour), -1); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 0); + } + taWrite[4] = MayNeedBigInt(taWrite, 2); + taWrite[5] = MayNeedBigInt(taWrite, 4); + + // Orig. array: [0, 0, 0, 0, 2, 4] + // [0, 0, 0, 0] << fixedLength + // [0, 0] << fixedLengthWithOffset + // [0, 0, 0, 0, 2, 4, ...] << lengthTracking + // [0, 0, 2, 4, ...] << lengthTrackingWithOffset + + assert.sameValue(fixedLength.findIndex(isTwoOrFour), -1); + assert.sameValue(fixedLengthWithOffset.findIndex(isTwoOrFour), -1); + assert.sameValue(lengthTracking.findIndex(isTwoOrFour), 4); + assert.sameValue(lengthTrackingWithOffset.findIndex(isTwoOrFour), 2); +} diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js new file mode 100644 index 00000000000..3e13533d6b9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Return abrupt from predicate call. +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 5. Let k be 0. + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + assert.throws(Test262Error, function() { + sample.findIndex(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..e1837d03c6b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.findIndex, + 'function', + 'implements SendableTypedArray.prototype.findIndex' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.findIndex(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.findIndex(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the findIndex operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.findIndex(() => {}); + throw new Test262Error('findIndex completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js new file mode 100644 index 00000000000..b4fc005f254 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Return index if predicate return a boolean true value. +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 5. Let k be 0. + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + d. If testResult is true, return k. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39, 3, 9]); + var called = 0; + + var result = sample.findIndex(function() { + called++; + return true; + }); + + assert.sameValue(result, 0, "returned true on sample[0]"); + assert.sameValue(called, 1, "predicate was called once"); + + called = 0; + result = sample.findIndex(function(val) { + called++; + return val === 9; + }); + + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, 2, "returned true on sample[3]"); + + result = sample.findIndex(function() { return "string"; }); + assert.sameValue(result, 0, "ToBoolean(string)"); + + result = sample.findIndex(function() { return {}; }); + assert.sameValue(result, 0, "ToBoolean(object)"); + + result = sample.findIndex(function() { return Symbol(""); }); + assert.sameValue(result, 0, "ToBoolean(symbol)"); + + result = sample.findIndex(function() { return 1; }); + assert.sameValue(result, 0, "ToBoolean(number)"); + + result = sample.findIndex(function() { return -1; }); + assert.sameValue(result, 0, "ToBoolean(negative number)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js new file mode 100644 index 00000000000..618515daae1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Return -1 if predicate always returns a boolean false value. +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + %SendableTypedArray%.prototype.findIndex is a distinct function that implements the + same algorithm as Array.prototype.findIndex as defined in 22.1.3.9 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + ... + + 22.1.3.9 Array.prototype.findIndex ( predicate[ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). + ... + 7. Return -1. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1, 2, 3]); + var called = 0; + + var result = sample.findIndex(function() { + called++; + return false; + }); + + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, -1, "result is -1 when predicate returns are false"); + + result = sample.findIndex(function() { return ""; }); + assert.sameValue(result, -1, "ToBoolean(string)"); + + result = sample.findIndex(function() { return undefined; }); + assert.sameValue(result, -1, "ToBoolean(undefined)"); + + result = sample.findIndex(function() { return null; }); + assert.sameValue(result, -1, "ToBoolean(null)"); + + result = sample.findIndex(function() { return 0; }); + assert.sameValue(result, -1, "ToBoolean(0)"); + + result = sample.findIndex(function() { return -0; }); + assert.sameValue(result, -1, "ToBoolean(-0)"); + + result = sample.findIndex(function() { return NaN; }); + assert.sameValue(result, -1, "ToBoolean(NaN)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-object.js new file mode 100644 index 00000000000..bd3bffcb7a0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-object.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var findIndex = SendableTypedArray.prototype.findIndex; +var predicate = function() {}; + +assert.throws(TypeError, function() { + findIndex.call(undefined, predicate); +}, "this is undefined"); + +assert.throws(TypeError, function() { + findIndex.call(null, predicate); +}, "this is null"); + +assert.throws(TypeError, function() { + findIndex.call(42, predicate); +}, "this is 42"); + +assert.throws(TypeError, function() { + findIndex.call("1", predicate); +}, "this is a string"); + +assert.throws(TypeError, function() { + findIndex.call(true, predicate); +}, "this is true"); + +assert.throws(TypeError, function() { + findIndex.call(false, predicate); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + findIndex.call(s, predicate); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..21d80bdc6be --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findindex +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var findIndex = SendableTypedArray.prototype.findIndex; +var predicate = function() {}; + +assert.throws(TypeError, function() { + findIndex.call({}, predicate); +}, "this is an Object"); + +assert.throws(TypeError, function() { + findIndex.call([], predicate); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + findIndex.call(ab, predicate); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + findIndex.call(dv, predicate); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/detached-buffer.js new file mode 100644 index 00000000000..b7b23d57876 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/detached-buffer.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: Throws a TypeError if this has a detached buffer +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 2. Perform ? ValidateSendableTypedArray(O). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.findLast(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js new file mode 100644 index 00000000000..445f77fada9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + [[Get]] of "length" uses [[ArrayLength]] +info: | + 22.2.3.10 %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + ... + 3. Let len be O.[[ArrayLength]]. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + Object.defineProperty(TA.prototype, "length", { + get: function() { + throw new Test262Error(); + } + }); + + var sample = new TA([42n]); + + Object.defineProperty(sample, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true + }); + + assert.sameValue( + sample.findLast(function() { return true; }), + 42n + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js new file mode 100644 index 00000000000..d025d7c55bf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Change values during predicate call +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + ... + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var arr = [1n, 2n, 3n]; + var sample; + var result; + + sample = new TA(3); + sample.findLast(function(val, i) { + sample[i] = arr[i]; + + assert.sameValue(val, 0n, "value is not mapped to instance"); + }); + assert(compareArray(sample, arr), "values set during each predicate call"); + + sample = new TA(arr); + result = sample.findLast(function(val, i) { + if ( i === 2 ) { + sample[0] = 7n; + } + return val === 7n; + }); + assert.sameValue(result, 7n, "value found"); + + sample = new TA(arr); + result = sample.findLast(function(val, i) { + if ( i === 2 ) { + sample[0] = 7n; + } + return val === 1n; + }); + assert.sameValue(result, undefined, "value not found"); + + sample = new TA(arr); + result = sample.findLast(function(val, i) { + if ( i < 2 ) { + sample[2] = 7n; + } + return val === 7n; + }); + assert.sameValue(result, undefined, "value not found - changed after call"); + + sample = new TA(arr); + result = sample.findLast(function() { + sample[2] = 7n; + return true; + }); + assert.sameValue(result, 3n, "findLast() returns previous found value"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js new file mode 100644 index 00000000000..9ed6b6f543f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39n, 2n, 62n]); + var results = []; + var result; + + sample.foo = "bar"; // Ignores non integer index properties + + sample.findLast(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 3, "predicate is called for each index"); + + result = results[0]; + assert.sameValue(result[0], 62n, "results[0][0] === 62, value"); + assert.sameValue(result[1], 2, "results[0][1] === 2, index"); + assert.sameValue(result[2], sample, "results[0][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[0].length === 3 arguments"); + + result = results[1]; + assert.sameValue(result[0], 2n, "results[1][0] === 2, value"); + assert.sameValue(result[1], 1, "results[1][1] === 1, index"); + assert.sameValue(result[2], sample, "results[1][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[1].length === 3 arguments"); + + result = results[2]; + assert.sameValue(result[0], 39n, "results[2][0] === 39, value"); + assert.sameValue(result[1], 0, "results[2][1] === 0, index"); + assert.sameValue(result[2], sample, "results[2][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[2].length === 3 arguments"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js new file mode 100644 index 00000000000..68c8c7127fb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Verify predicate this on non-strict mode +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 6. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +flags: [noStrict] +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +var T = this; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.findLast(function() { + result = this; + }); + + assert.sameValue(result, T, "without thisArg, predicate this is the global"); + + result = null; + sample.findLast(function() { + result = this; + }, undefined); + + assert.sameValue(result, T, "predicate this is the global when thisArg is undefined"); + + var o = {}; + result = null; + sample.findLast(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict.js new file mode 100644 index 00000000000..fbc9b9f23ef --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Verify predicate this on strict mode +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 6. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +flags: [onlyStrict] +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.findLast(function() { + result = this; + }); + + assert.sameValue( + result, + undefined, + "without thisArg, predicate this is undefined" + ); + + var o = {}; + sample.findLast(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js new file mode 100644 index 00000000000..5679e7ea020 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Throws a TypeError exception if predicate is not callable. +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + ... + 4. If IsCallable(predicate) is false, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.findLast({}); + }, "object"); + + assert.throws(TypeError, function() { + sample.findLast(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.findLast(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.findLast(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.findLast(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.findLast(1); + }, "number"); + + assert.throws(TypeError, function() { + sample.findLast(""); + }, "string"); + + assert.throws(TypeError, function() { + sample.findLast([]); + }, "array"); + + assert.throws(TypeError, function() { + sample.findLast(/./); + }, "regexp"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js new file mode 100644 index 00000000000..66c35616d92 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Predicate may detach the buffer +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + ... + + However, such optimization must not introduce any observable changes in the + specified behaviour of the algorithm and must take into account the + possibility that calls to predicate may cause the this value to become + detached. + + IntegerIndexedElementGet ( O, index ) + + ... + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + If IsDetachedBuffer(buffer) is true, return undefined. + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.findLast(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + }); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js new file mode 100644 index 00000000000..66b3a92cee4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Predicate is not called on empty instances +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 6. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + var called = false; + + var result = sample.findLast(function() { + called = true; + return true; + }); + + assert.sameValue( + called, + false, + "empty instance does not call predicate" + ); + assert.sameValue( + result, + undefined, + "findLast returns undefined when predicate is not called" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js new file mode 100644 index 00000000000..bd858d0821e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Return abrupt from predicate call. +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 6. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + var predicate = function() { + throw new Test262Error(); + }; + + assert.throws(Test262Error, function() { + sample.findLast(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..fdd1ac5fe60 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, array-find-from-last, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.findLast, + 'function', + 'implements SendableTypedArray.prototype.findLast' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.findLast(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.findLast(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the findLast operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.findLast(() => {}); + throw new Test262Error('findLast completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js new file mode 100644 index 00000000000..e3ab7cd8431 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Return found value if predicate return a boolean true value. +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 6. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + d. If testResult is true, return kValue. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39n, 2n, 62n]); + var called, result; + + called = 0; + result = sample.findLast(function() { + called++; + return true; + }); + assert.sameValue(result, 62n, "returned true on sample[2]"); + assert.sameValue(called, 1, "predicate was called once"); + + called = 0; + result = sample.findLast(function(val) { + called++; + return val === 39n; + }); + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, 39n, "returned true on sample[0]"); + + result = sample.findLast(function() { return "string"; }); + assert.sameValue(result, 62n, "ToBoolean(string)"); + + result = sample.findLast(function() { return {}; }); + assert.sameValue(result, 62n, "ToBoolean(object)"); + + result = sample.findLast(function() { return Symbol(""); }); + assert.sameValue(result, 62n, "ToBoolean(symbol)"); + + result = sample.findLast(function() { return 1; }); + assert.sameValue(result, 62n, "ToBoolean(number)"); + + result = sample.findLast(function() { return -1; }); + assert.sameValue(result, 62n, "ToBoolean(negative number)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js new file mode 100644 index 00000000000..2282b1ae485 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Return undefined if predicate always returns a boolean false value. +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + ... + 6. 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... + 7. Return undefined. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + var called = 0; + + var result = sample.findLast(function() { + called++; + return false; + }); + + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, undefined); + + result = sample.findLast(function() { return ""; }); + assert.sameValue(result, undefined, "ToBoolean(empty string)"); + + result = sample.findLast(function() { return undefined; }); + assert.sameValue(result, undefined, "ToBoolean(undefined)"); + + result = sample.findLast(function() { return null; }); + assert.sameValue(result, undefined, "ToBoolean(null)"); + + result = sample.findLast(function() { return 0; }); + assert.sameValue(result, undefined, "ToBoolean(0)"); + + result = sample.findLast(function() { return -0; }); + assert.sameValue(result, undefined, "ToBoolean(-0)"); + + result = sample.findLast(function() { return NaN; }); + assert.sameValue(result, undefined, "ToBoolean(NaN)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js new file mode 100644 index 00000000000..9ad2eff84ba --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: Instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var secondElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = sample.findLast(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(BPE); + secondElement = undefined; + expectedElements = [0]; + expectedIndices = [0]; + expectedArrays = [sample]; + } catch (_) { + secondElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [2, 1, 0]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, [0, secondElement, 0], 'elements (shrink)'); + assert.compareArray(indices, [2, 1, 0], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, undefined, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = sample.findLast(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, undefined, 'result (grow)'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js new file mode 100644 index 00000000000..b0db2eb7f08 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: Throws a TypeError if this has a detached buffer +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 2. Perform ? ValidateSendableTypedArray(O). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray, array-find-from-last] +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.findLast(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js new file mode 100644 index 00000000000..a56aff02bbc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + [[Get]] of "length" uses [[ArrayLength]] +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + ... + 3. Let len be O.[[ArrayLength]]. + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithSendableTypedArrayConstructors(function(TA) { + Object.defineProperty(TA.prototype, "length", { + get: function() { + throw new Test262Error(); + } + }); + + var sample = new TA([42]); + + Object.defineProperty(sample, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true + }); + + assert.sameValue( + sample.findLast(function() { return true; }), + 42 + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-func.js new file mode 100644 index 00000000000..05fc6644e2d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-func.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: Throws a TypeError exception when invoked as a function +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 2. Perform ? ValidateSendableTypedArray(O). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +var findLast = SendableTypedArray.prototype.findLast; + +assert.sameValue(typeof findLast, 'function'); + +assert.throws(TypeError, function() { + findLast(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-method.js new file mode 100644 index 00000000000..de76e7ce8ea --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-method.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: Requires a [[TypedArrayName]] internal slot. +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 2. Perform ? ValidateSendableTypedArray(O). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.findLast, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.findLast(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/length.js b/test/sendable/builtins/TypedArray/prototype/findLast/length.js new file mode 100644 index 00000000000..198150ef4ab --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/length.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + %SendableTypedArray%.prototype.findLast.length is 1. +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +assert.sameValue(SendableTypedArray.prototype.findLast.length, 1); + +verifyProperty(SendableTypedArray.prototype.findLast, "length", { + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/name.js b/test/sendable/builtins/TypedArray/prototype/findLast/name.js new file mode 100644 index 00000000000..cf30c441ca9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/name.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + %SendableTypedArray%.prototype.findLast.name is "findLast". +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +assert.sameValue(SendableTypedArray.prototype.findLast.name, "findLast"); + +verifyProperty(SendableTypedArray.prototype.findLast, "name", { + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/findLast/not-a-constructor.js new file mode 100644 index 00000000000..42ae9464c56 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.findLast 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, SendableTypedArray, array-find-from-last] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.findLast), + false, + 'isConstructor(SendableTypedArray.prototype.findLast) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.findLast(() => {}); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js new file mode 100644 index 00000000000..2cecf5cafe7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Change values during predicate call +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... + +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var arr = [1, 2, 3]; + var sample; + var result; + + sample = new TA(3); + sample.findLast(function(val, i) { + sample[i] = arr[i]; + + assert.sameValue(val, 0, "value is not mapped to instance"); + }); + assert(compareArray(sample, arr), "values set during each predicate call"); + + sample = new TA(arr); + result = sample.findLast(function(val, i) { + if ( i === 2 ) { + sample[0] = 7; + } + return val === 7; + }); + assert.sameValue(result, 7, "value found"); + + sample = new TA(arr); + result = sample.findLast(function(val, i) { + if ( i === 2 ) { + sample[0] = 7; + } + return val === 1; + }); + assert.sameValue(result, undefined, "value not found"); + + sample = new TA(arr); + result = sample.findLast(function(val, i) { + if ( i < 2 ) { + sample[2] = 7; + } + return val === 7; + }); + assert.sameValue(result, undefined, "value not found - changed after call"); + + sample = new TA(arr); + result = sample.findLast(function() { + sample[2] = 7; + return true; + }); + assert.sameValue(result, 3, "findLast() returns previous found value"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js new file mode 100644 index 00000000000..3f7d9640a9a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39, 2, 62]); + var results = []; + var result; + + sample.foo = "bar"; // Ignores non integer index properties + + sample.findLast(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 3, "predicate is called for each index"); + + result = results[0]; + assert.sameValue(result[0], 62, "results[0][0] === 62, value"); + assert.sameValue(result[1], 2, "results[0][1] === 2, index"); + assert.sameValue(result[2], sample, "results[0][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[0].length === 3 arguments"); + + result = results[1]; + assert.sameValue(result[0], 2, "results[1][0] === 2, value"); + assert.sameValue(result[1], 1, "results[1][1] === 1, index"); + assert.sameValue(result[2], sample, "results[1][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[1].length === 3 arguments"); + + result = results[2]; + assert.sameValue(result[0], 39, "results[2][0] === 39, value"); + assert.sameValue(result[1], 0, "results[2][1] === 0, index"); + assert.sameValue(result[2], sample, "results[2][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[2].length === 3 arguments"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js new file mode 100644 index 00000000000..6f6ee789c36 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Verify predicate this on non-strict mode +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 6. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +flags: [noStrict] +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +var T = this; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.findLast(function() { + result = this; + }); + + assert.sameValue(result, T, "without thisArg, predicate this is the global"); + + result = null; + sample.findLast(function() { + result = this; + }, undefined); + + assert.sameValue(result, T, "predicate this is the global when thisArg is undefined"); + + var o = {}; + result = null; + sample.findLast(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js new file mode 100644 index 00000000000..c43e4aa2a33 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Verify predicate this on strict mode +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 6. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +flags: [onlyStrict] +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.findLast(function() { + result = this; + }); + + assert.sameValue( + result, + undefined, + "without thisArg, predicate this is undefined" + ); + + var o = {}; + sample.findLast(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js new file mode 100644 index 00000000000..073fd1f7b06 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Throws a TypeError exception if predicate is not callable. +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + ... + 4. If IsCallable(predicate) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.findLast({}); + }, "object"); + + assert.throws(TypeError, function() { + sample.findLast(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.findLast(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.findLast(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.findLast(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.findLast(1); + }, "number"); + + assert.throws(TypeError, function() { + sample.findLast(""); + }, "string"); + + assert.throws(TypeError, function() { + sample.findLast([]); + }, "array"); + + assert.throws(TypeError, function() { + sample.findLast(/./); + }, "regexp"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js new file mode 100644 index 00000000000..d6927603ed3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Predicate may detach the buffer +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + ... + + However, such optimization must not introduce any observable changes in the + specified behaviour of the algorithm and must take into account the + possibility that calls to predicate may cause the this value to become + detached. + + IntegerIndexedElementGet ( O, index ) + + ... + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + If IsDetachedBuffer(buffer) is true, return undefined. + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.findLast(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + }); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js new file mode 100644 index 00000000000..349574268e1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Predicate is not called on empty instances +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 6. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + var called = false; + + var result = sample.findLast(function() { + called = true; + return true; + }); + + assert.sameValue( + called, + false, + "empty instance does not call predicate" + ); + assert.sameValue( + result, + undefined, + "findLast returns undefined when predicate is not called" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/findLast/prop-desc.js new file mode 100644 index 00000000000..06792a0fc5c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findLast +description: > + "findLast" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArray.prototype, "findLast", { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..e0ee9de847e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + SendableTypedArray.p.findLast behaves correctly when receiver is backed by resizable + buffer that is grown mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLength.findLast(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLengthWithOffset.findLast(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + 4 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTracking.findLast(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTrackingWithOffset.findLast(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + 4 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..a45d71ecd68 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + SendableTypedArray.p.findLast behaves correctly when receiver is backed by resizable + buffer that is shrunk mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLength.findLast(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + 4, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLengthWithOffset.findLast(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTracking.findLast(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTrackingWithOffset.findLast(ResizeMidIteration), undefined); + assert.compareArray(values, [ + 6, + 4 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer.js new file mode 100644 index 00000000000..b22c328860a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer.js @@ -0,0 +1,115 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + SendableTypedArray.p.findLast behaves correctly when receiver is backed by resizable + buffer +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + function isTwoOrFour(n) { + return n == 2 || n == 4; + } + assert.sameValue(Number(fixedLength.findLast(isTwoOrFour)), 4); + assert.sameValue(Number(fixedLengthWithOffset.findLast(isTwoOrFour)), 4); + assert.sameValue(Number(lengthTracking.findLast(isTwoOrFour)), 4); + assert.sameValue(Number(lengthTrackingWithOffset.findLast(isTwoOrFour)), 4); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + fixedLength.findLast(isTwoOrFour); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.findLast(isTwoOrFour); + }); + + assert.sameValue(Number(lengthTracking.findLast(isTwoOrFour)), 4); + assert.sameValue(Number(lengthTrackingWithOffset.findLast(isTwoOrFour)), 4); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.findLast(isTwoOrFour); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.findLast(isTwoOrFour); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.findLast(isTwoOrFour); + }); + + assert.sameValue(lengthTracking.findLast(isTwoOrFour), undefined); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.findLast(isTwoOrFour); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.findLast(isTwoOrFour); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.findLast(isTwoOrFour); + }); + + assert.sameValue(lengthTracking.findLast(isTwoOrFour), undefined); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 0); + } + taWrite[4] = MayNeedBigInt(taWrite, 2); + taWrite[5] = MayNeedBigInt(taWrite, 4); + + // Orig. array: [0, 0, 0, 0, 2, 4] + // [0, 0, 0, 0] << fixedLength + // [0, 0] << fixedLengthWithOffset + // [0, 0, 0, 0, 2, 4, ...] << lengthTracking + // [0, 0, 2, 4, ...] << lengthTrackingWithOffset + + assert.sameValue(fixedLength.findLast(isTwoOrFour), undefined); + assert.sameValue(fixedLengthWithOffset.findLast(isTwoOrFour), undefined); + assert.sameValue(Number(lengthTracking.findLast(isTwoOrFour)), 4); + assert.sameValue(Number(lengthTrackingWithOffset.findLast(isTwoOrFour)), 4); +} diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js new file mode 100644 index 00000000000..61b13a96b65 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Return abrupt from predicate call. +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 6. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + var predicate = function() { + throw new Test262Error(); + }; + + assert.throws(Test262Error, function() { + sample.findLast(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..28267652df9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer, array-find-from-last] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.findLast, + 'function', + 'implements SendableTypedArray.prototype.findLast' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.findLast(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.findLast(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the findLast operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.findLast(() => {}); + throw new Test262Error('findLast completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js new file mode 100644 index 00000000000..d3f834148e5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Return found value if predicate return a boolean true value. +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 6. Repeat, while k ≥ 0, + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + d. If testResult is true, return kValue. + ... +includes: [testTypedArray.js] +features: [Symbol, SendableTypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39, 2, 62]); + var called, result; + + called = 0; + result = sample.findLast(function() { + called++; + return true; + }); + assert.sameValue(result, 62, "returned true on sample[2]"); + assert.sameValue(called, 1, "predicate was called once"); + + called = 0; + result = sample.findLast(function(val) { + called++; + return val === 39; + }); + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, 39, "returned true on sample[0]"); + + result = sample.findLast(function() { return "string"; }); + assert.sameValue(result, 62, "ToBoolean(string)"); + + result = sample.findLast(function() { return {}; }); + assert.sameValue(result, 62, "ToBoolean(object)"); + + result = sample.findLast(function() { return Symbol(""); }); + assert.sameValue(result, 62, "ToBoolean(symbol)"); + + result = sample.findLast(function() { return 1; }); + assert.sameValue(result, 62, "ToBoolean(number)"); + + result = sample.findLast(function() { return -1; }); + assert.sameValue(result, 62, "ToBoolean(negative number)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js new file mode 100644 index 00000000000..e142890d616 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Return undefined if predicate always returns a boolean false value. +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + ... + 6. 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... + 7. Return undefined. +includes: [testTypedArray.js] +features: [Symbol, SendableTypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + var called = 0; + + var result = sample.findLast(function() { + called++; + return false; + }); + + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, undefined); + + result = sample.findLast(function() { return ""; }); + assert.sameValue(result, undefined, "ToBoolean(empty string)"); + + result = sample.findLast(function() { return undefined; }); + assert.sameValue(result, undefined, "ToBoolean(undefined)"); + + result = sample.findLast(function() { return null; }); + assert.sameValue(result, undefined, "ToBoolean(null)"); + + result = sample.findLast(function() { return 0; }); + assert.sameValue(result, undefined, "ToBoolean(0)"); + + result = sample.findLast(function() { return -0; }); + assert.sameValue(result, undefined, "ToBoolean(-0)"); + + result = sample.findLast(function() { return NaN; }); + assert.sameValue(result, undefined, "ToBoolean(NaN)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-object.js new file mode 100644 index 00000000000..b401eefa4e3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-object.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: Throws a TypeError exception when `this` is not Object +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 2. Perform ? ValidateSendableTypedArray(O). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, SendableTypedArray, array-find-from-last] +---*/ + +var findLast = SendableTypedArray.prototype.findLast; +var predicate = function() {}; + +assert.throws(TypeError, function() { + findLast.call(undefined, predicate); +}, "this is undefined"); + +assert.throws(TypeError, function() { + findLast.call(null, predicate); +}, "this is null"); + +assert.throws(TypeError, function() { + findLast.call(42, predicate); +}, "this is 42"); + +assert.throws(TypeError, function() { + findLast.call("1", predicate); +}, "this is a string"); + +assert.throws(TypeError, function() { + findLast.call(true, predicate); +}, "this is true"); + +assert.throws(TypeError, function() { + findLast.call(false, predicate); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + findLast.call(s, predicate); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..e0c18a53b49 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlast +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) + + 2. Perform ? ValidateSendableTypedArray(O). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +var findlast = SendableTypedArray.prototype.findlast; +var predicate = function() {}; + +assert.throws(TypeError, function() { + findlast.call({}, predicate); +}, "this is an Object"); + +assert.throws(TypeError, function() { + findlast.call([], predicate); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + findlast.call(ab, predicate); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + findlast.call(dv, predicate); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js new file mode 100644 index 00000000000..4b2fa232e16 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: Throws a TypeError if this has a detached buffer +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.findLastIndex(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js new file mode 100644 index 00000000000..86762ad2892 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + [[Get]] of "length" uses [[ArrayLength]] +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 3. Let len be O.[[ArrayLength]]. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + Object.defineProperty(TA.prototype, "length", { + get: function() { + throw new Test262Error(); + } + }); + + var sample = new TA([42n]); + + Object.defineProperty(sample, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true + }); + + assert.sameValue( + sample.findLastIndex(function() { return true; }), + 0 + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js new file mode 100644 index 00000000000..ac985664793 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Change values during predicate call +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var arr = [10n, 20n, 30n]; + var sample; + var result; + + sample = new TA(3); + sample.findLastIndex(function(val, i) { + sample[i] = arr[i]; + + assert.sameValue(val, 0n, "value is not mapped to instance"); + }); + assert(compareArray(sample, arr), "values set during each predicate call"); + + sample = new TA(arr); + result = sample.findLastIndex(function(val, i) { + if ( i === 2 ) { + sample[0] = 7n; + } + return val === 7n; + }); + assert.sameValue(result, 0, "value found"); + + sample = new TA(arr); + result = sample.findLastIndex(function(val, i) { + if ( i === 2 ) { + sample[0] = 7n; + } + return val === 10n; + }); + assert.sameValue(result, -1, "value not found"); + + sample = new TA(arr); + result = sample.findLastIndex(function(val, i) { + if ( i < 2 ) { + sample[2] = 7n; + } + return val === 7n; + }); + assert.sameValue(result, -1, "value not found - changed after call"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js new file mode 100644 index 00000000000..448e56ca3f7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39n, 2n, 62n]); + var results = []; + var result; + + sample.foo = "bar"; // Ignores non integer index properties + + sample.findLastIndex(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 3, "predicate is called for each index"); + + result = results[0]; + assert.sameValue(result[0], 62n, "results[0][0] === 62, value"); + assert.sameValue(result[1], 2, "results[0][1] === 2, index"); + assert.sameValue(result[2], sample, "results[0][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[0].length === 3, arguments"); + + result = results[1]; + assert.sameValue(result[0], 2n, "results[1][0] === 2, value"); + assert.sameValue(result[1], 1, "results[1][1] === 1, index"); + assert.sameValue(result[2], sample, "results[1][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[1].length === 3, arguments"); + + result = results[2]; + assert.sameValue(result[0], 39n, "results[2][0] === 39, value"); + assert.sameValue(result[1], 0, "results[2][1] === 0, index"); + assert.sameValue(result[2], sample, "results[2][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[2].length === 3, arguments"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js new file mode 100644 index 00000000000..f366e82a6c7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Verify predicate this on non-strict mode +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +flags: [noStrict] +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +var T = this; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.findLastIndex(function() { + result = this; + }); + + assert.sameValue(result, T, "without thisArg, predicate this is the global"); + + result = null; + sample.findLastIndex(function() { + result = this; + }, undefined); + + assert.sameValue(result, T, "predicate this is the global when thisArg is undefined"); + + var o = {}; + result = null; + sample.findLastIndex(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict.js new file mode 100644 index 00000000000..b63f0830a60 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +flags: [onlyStrict] +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.findLastIndex(function() { + result = this; + }); + + assert.sameValue( + result, + undefined, + "without thisArg, predicate this is undefined" + ); + + var o = {}; + sample.findLastIndex(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js new file mode 100644 index 00000000000..d1f5440d7b8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Throws a TypeError exception if predicate is not callable. +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 4. If IsCallable(predicate) is false, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.findLastIndex({}); + }, "{}"); + + assert.throws(TypeError, function() { + sample.findLastIndex(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.findLastIndex(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.findLastIndex(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.findLastIndex(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.findLastIndex(1); + }, "1"); + + assert.throws(TypeError, function() { + sample.findLastIndex(""); + }, "string"); + + assert.throws(TypeError, function() { + sample.findLastIndex([]); + }, "[]"); + + assert.throws(TypeError, function() { + sample.findLastIndex(/./); + }, "/./"); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js new file mode 100644 index 00000000000..fc84c7f0ac3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Predicate may detach the buffer +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 6. Repeat, while k ≥ 0, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ! Get(O, Pk). + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... + + IntegerIndexedElementGet ( O, index ) + + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + If IsDetachedBuffer(buffer) is true, return undefined. + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var loops = 0; + + sample.findLastIndex(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + }); + assert.sameValue(loops, 2, "predicate is called once"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js new file mode 100644 index 00000000000..75f9b06f205 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Predicate is not called on an empty instance +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... + 7. Return -1. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + var called = false; + + var predicate = function() { + called = true; + return true; + }; + + var result = sample.findLastIndex(predicate); + + assert.sameValue( + called, false, + "does not call predicate" + ); + assert.sameValue( + result, -1, + "returns -1 on an empty instance" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js new file mode 100644 index 00000000000..195b6d6d8eb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Return abrupt from predicate call. +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + assert.throws(Test262Error, function() { + sample.findLastIndex(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..a82c66fd0ae --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, array-find-from-last, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.findLastIndex, + 'function', + 'implements SendableTypedArray.prototype.findLastIndex' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.findLastIndex(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.findLastIndex(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the findLastIndex operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.findLastIndex(() => {}); + throw new Test262Error('findLastIndex completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js new file mode 100644 index 00000000000..08a81efcfc6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Return index if predicate return a boolean true value. +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + d. If testResult is true, return 𝔽(k). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39n, 3n, 9n]); + var called = 0; + + var result = sample.findLastIndex(function() { + called++; + return true; + }); + + assert.sameValue(result, 2, "returned true on sample[2]"); + assert.sameValue(called, 1, "predicate was called once"); + + called = 0; + result = sample.findLastIndex(function(val) { + called++; + return val === 39n; + }); + + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, 0, "returned true on sample[0]"); + + result = sample.findLastIndex(function() { return "string"; }); + assert.sameValue(result, 2, "ToBoolean(string)"); + + result = sample.findLastIndex(function() { return {}; }); + assert.sameValue(result, 2, "ToBoolean(object)"); + + result = sample.findLastIndex(function() { return Symbol(""); }); + assert.sameValue(result, 2, "ToBoolean(symbol)"); + + result = sample.findLastIndex(function() { return 1; }); + assert.sameValue(result, 2, "ToBoolean(number)"); + + result = sample.findLastIndex(function() { return -1; }); + assert.sameValue(result, 2, "ToBoolean(negative number)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js new file mode 100644 index 00000000000..f6ec5f0823f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Return -1 if predicate always returns a boolean false value. +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... + 7. Return -1𝔽. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, array-find-from-last] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1n, 2n, 3n]); + var called = 0; + + var result = sample.findLastIndex(function() { + called++; + return false; + }); + + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, -1, "result is -1 when predicate returns are false"); + + result = sample.findLastIndex(function() { return ""; }); + assert.sameValue(result, -1, "ToBoolean(string)"); + + result = sample.findLastIndex(function() { return undefined; }); + assert.sameValue(result, -1, "ToBoolean(undefined)"); + + result = sample.findLastIndex(function() { return null; }); + assert.sameValue(result, -1, "ToBoolean(null)"); + + result = sample.findLastIndex(function() { return 0; }); + assert.sameValue(result, -1, "ToBoolean(0)"); + + result = sample.findLastIndex(function() { return -0; }); + assert.sameValue(result, -1, "ToBoolean(-0)"); + + result = sample.findLastIndex(function() { return NaN; }); + assert.sameValue(result, -1, "ToBoolean(NaN)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js new file mode 100644 index 00000000000..bf5bd4e3d4b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: Instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var secondElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = sample.findLastIndex(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(BPE); + secondElement = undefined; + expectedElements = [0]; + expectedIndices = [0]; + expectedArrays = [sample]; + } catch (_) { + secondElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [2, 1, 0]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, [0, secondElement, 0], 'elements (shrink)'); + assert.compareArray(indices, [2, 1, 0], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, -1, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = sample.findLastIndex(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, -1, 'result (grow)'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js new file mode 100644 index 00000000000..a55cbeec969 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: Throws a TypeError if this has a detached buffer +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray, array-find-from-last] +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.findLastIndex(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js new file mode 100644 index 00000000000..cdfbc279f08 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + [[Get]] of "length" uses [[ArrayLength]] +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 3. Let len be O.[[ArrayLength]]. + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithSendableTypedArrayConstructors(function(TA) { + Object.defineProperty(TA.prototype, "length", { + get: function() { + throw new Test262Error(); + } + }); + + var sample = new TA([42]); + + Object.defineProperty(sample, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true + }); + + assert.sameValue( + sample.findLastIndex(function() { return true; }), + 0 + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-func.js new file mode 100644 index 00000000000..cc099593ccf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-func.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: Throws a TypeError exception when invoked as a function +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +var findLastIndex = SendableTypedArray.prototype.findLastIndex; + +assert.sameValue(typeof findLastIndex, 'function'); + +assert.throws(TypeError, function() { + findLastIndex(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-method.js new file mode 100644 index 00000000000..de880435118 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-method.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: Requires a [[TypedArrayName]] internal slot. +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.findLastIndex, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.findLastIndex(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/length.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/length.js new file mode 100644 index 00000000000..d4c561e014e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/length.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + %SendableTypedArray%.prototype.findLastIndex.length is 1. +info: | + %SendableTypedArray%.prototype.findLastIndex (predicate [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +assert.sameValue(SendableTypedArray.prototype.findLastIndex.length, 1); + +verifyProperty(SendableTypedArray.prototype.findLastIndex, "length", { + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/name.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/name.js new file mode 100644 index 00000000000..15698a146a7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/name.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + %SendableTypedArray%.prototype.findLastIndex.name is "findLastIndex". +info: | + %SendableTypedArray%.prototype.findLastIndex (predicate [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +assert.sameValue(SendableTypedArray.prototype.findLastIndex.name, "findLastIndex"); + +verifyProperty(SendableTypedArray.prototype.findLastIndex, "name", { + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/not-a-constructor.js new file mode 100644 index 00000000000..fe036db5b03 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.findLastIndex 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, SendableTypedArray, array-find-from-last] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.findLastIndex), + false, + 'isConstructor(SendableTypedArray.prototype.findLastIndex) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.findLastIndex(() => {}); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js new file mode 100644 index 00000000000..70b87f9f326 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Change values during predicate call +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var arr = [10, 20, 30]; + var sample; + var result; + + sample = new TA(3); + sample.findLastIndex(function(val, i) { + sample[i] = arr[i]; + + assert.sameValue(val, 0, "value is not mapped to instance"); + }); + assert(compareArray(sample, arr), "values set during each predicate call"); + + sample = new TA(arr); + result = sample.findLastIndex(function(val, i) { + if ( i === 2 ) { + sample[0] = 7; + } + return val === 7; + }); + assert.sameValue(result, 0, "value found"); + + sample = new TA(arr); + result = sample.findLastIndex(function(val, i) { + if ( i === 2 ) { + sample[0] = 7; + } + return val === 10; + }); + assert.sameValue(result, -1, "value not found"); + + sample = new TA(arr); + result = sample.findLastIndex(function(val, i) { + if ( i < 2) { + sample[2] = 7; + } + return val === 7; + }); + assert.sameValue(result, -1, "value not found - changed after call"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js new file mode 100644 index 00000000000..ac04f354b12 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39, 2, 62]); + var results = []; + var result; + + sample.foo = "bar"; // Ignores non integer index properties + + sample.findLastIndex(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 3, "predicate is called for each index"); + + result = results[0]; + assert.sameValue(result[0], 62, "results[0][0] === 62, value"); + assert.sameValue(result[1], 2, "results[0][1] === 2, index"); + assert.sameValue(result[2], sample, "results[0][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[0].length === 3, arguments"); + + result = results[1]; + assert.sameValue(result[0], 2, "results[1][0] === 2, value"); + assert.sameValue(result[1], 1, "results[1][1] === 1, index"); + assert.sameValue(result[2], sample, "results[1][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[1].length === 3, arguments"); + + result = results[2]; + assert.sameValue(result[0], 39, "results[2][0] === 39, value"); + assert.sameValue(result[1], 0, "results[2][1] === 0, index"); + assert.sameValue(result[2], sample, "results[2][2] === sample, instance"); + assert.sameValue(result.length, 3, "results[2].length === 3, arguments"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js new file mode 100644 index 00000000000..98d60bf8de3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Verify predicate this on non-strict mode +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +flags: [noStrict] +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +var T = this; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.findLastIndex(function() { + result = this; + }); + + assert.sameValue(result, T, "without thisArg, predicate this is the global"); + + result = null; + sample.findLastIndex(function() { + result = this; + }, undefined); + + assert.sameValue(result, T, "predicate this is the global when thisArg is undefined"); + + var o = {}; + result = null; + sample.findLastIndex(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js new file mode 100644 index 00000000000..e25ee335434 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +flags: [onlyStrict] +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + var result; + + sample.findLastIndex(function() { + result = this; + }); + + assert.sameValue( + result, + undefined, + "without thisArg, predicate this is undefined" + ); + + var o = {}; + sample.findLastIndex(function() { + result = this; + }, o); + + assert.sameValue(result, o, "thisArg becomes the predicate this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js new file mode 100644 index 00000000000..36924a67059 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Throws a TypeError exception if predicate is not callable. +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 4. If IsCallable(predicate) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.throws(TypeError, function() { + sample.findLastIndex({}); + }, "{}"); + + assert.throws(TypeError, function() { + sample.findLastIndex(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.findLastIndex(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.findLastIndex(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.findLastIndex(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.findLastIndex(1); + }, "1"); + + assert.throws(TypeError, function() { + sample.findLastIndex(""); + }, "string"); + + assert.throws(TypeError, function() { + sample.findLastIndex([]); + }, "[]"); + + assert.throws(TypeError, function() { + sample.findLastIndex(/./); + }, "/./"); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js new file mode 100644 index 00000000000..ea4e512f6e0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Predicate may detach the buffer +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 6. Repeat, while k ≥ 0, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ! Get(O, Pk). + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... + + IntegerIndexedElementGet ( O, index ) + + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + If IsDetachedBuffer(buffer) is true, return undefined. + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var loops = 0; + + sample.findLastIndex(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + }); + assert.sameValue(loops, 2, "predicate is called once"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js new file mode 100644 index 00000000000..c85e35adb60 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Predicate is not called on an empty instance +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... + 7. Return -1. +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + var called = false; + + var predicate = function() { + called = true; + return true; + }; + + var result = sample.findLastIndex(predicate); + + assert.sameValue( + called, false, + "does not call predicate" + ); + assert.sameValue( + result, -1, + "returns -1 on an empty instance" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/prop-desc.js new file mode 100644 index 00000000000..4e14b00a316 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + "findLastIndex" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArray.prototype, "findLastIndex", { + enumerable: false, + writable: true, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..931bf5e6da3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + SendableTypedArray.p.findLastIndex behaves correctly when receiver is backed by resizable + buffer that is grown mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLength.findLastIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLengthWithOffset.findLastIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + 4 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTracking.findLastIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTrackingWithOffset.findLastIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + 4 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..675c3112dd1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + SendableTypedArray.p.findLastIndex behaves correctly when receiver is backed by resizable + buffer that is shrunk mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLength.findLastIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + 4, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(fixedLengthWithOffset.findLastIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTracking.findLastIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 1; + resizeTo = 2 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTracking.findLastIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + undefined, + 2, + 0 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert.sameValue(lengthTrackingWithOffset.findLastIndex(ResizeMidIteration), -1); + assert.compareArray(values, [ + 6, + 4 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer.js new file mode 100644 index 00000000000..749019e5dc1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer.js @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + SendableTypedArray.p.findLastIndex behaves correctly when receiver is backed by resizable + buffer +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + function isTwoOrFour(n) { + return n == 2 || n == 4; + } + assert.sameValue(fixedLength.findLastIndex(isTwoOrFour), 2); + assert.sameValue(fixedLengthWithOffset.findLastIndex(isTwoOrFour), 0); + assert.sameValue(lengthTracking.findLastIndex(isTwoOrFour), 2); + assert.sameValue(lengthTrackingWithOffset.findLastIndex(isTwoOrFour), 0); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + fixedLength.findLastIndex(isTwoOrFour); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.findLastIndex(isTwoOrFour); + }); + + assert.sameValue(lengthTracking.findLastIndex(isTwoOrFour), 2); + assert.sameValue(lengthTrackingWithOffset.findLastIndex(isTwoOrFour), 0); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.findLastIndex(isTwoOrFour); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.findLastIndex(isTwoOrFour); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.findLastIndex(isTwoOrFour); + }); + + assert.sameValue(lengthTracking.findLastIndex(isTwoOrFour), -1); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.findLastIndex(isTwoOrFour); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.findLastIndex(isTwoOrFour); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.findLastIndex(isTwoOrFour); + }); + assert.sameValue(lengthTracking.findLastIndex(isTwoOrFour), -1); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 0); + } + taWrite[4] = MayNeedBigInt(taWrite, 2); + taWrite[5] = MayNeedBigInt(taWrite, 4); + + // Orig. array: [0, 0, 0, 0, 2, 4] + // [0, 0, 0, 0] << fixedLength + // [0, 0] << fixedLengthWithOffset + // [0, 0, 0, 0, 2, 4, ...] << lengthTracking + // [0, 0, 2, 4, ...] << lengthTrackingWithOffset + + assert.sameValue(fixedLength.findLastIndex(isTwoOrFour), -1); + assert.sameValue(fixedLengthWithOffset.findLastIndex(isTwoOrFour), -1); + assert.sameValue(lengthTracking.findLastIndex(isTwoOrFour), 5); + assert.sameValue(lengthTrackingWithOffset.findLastIndex(isTwoOrFour), 3); +} diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js new file mode 100644 index 00000000000..704395a8206 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Return abrupt from predicate call. +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +var predicate = function() { + throw new Test262Error(); +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + assert.throws(Test262Error, function() { + sample.findLastIndex(predicate); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..0cd9a330228 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer, array-find-from-last] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.findLastIndex, + 'function', + 'implements SendableTypedArray.prototype.findLastIndex' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.findLastIndex(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.findLastIndex(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the findLastIndex operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.findLastIndex(() => {}); + throw new Test262Error('findLastIndex completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js new file mode 100644 index 00000000000..1a5cae6d22e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Return index if predicate return a boolean true value. +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + d. If testResult is true, return 𝔽(k). + ... +includes: [testTypedArray.js] +features: [Symbol, SendableTypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([39, 3, 9]); + var called = 0; + + var result = sample.findLastIndex(function() { + called++; + return true; + }); + + assert.sameValue(result, 2, "returned true on sample[2]"); + assert.sameValue(called, 1, "predicate was called once"); + + called = 0; + result = sample.findLastIndex(function(val) { + called++; + return val === 39; + }); + + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, 0, "returned true on sample[0]"); + + result = sample.findLastIndex(function() { return "string"; }); + assert.sameValue(result, 2, "ToBoolean(string)"); + + result = sample.findLastIndex(function() { return {}; }); + assert.sameValue(result, 2, "ToBoolean(object)"); + + result = sample.findLastIndex(function() { return Symbol(""); }); + assert.sameValue(result, 2, "ToBoolean(symbol)"); + + result = sample.findLastIndex(function() { return 1; }); + assert.sameValue(result, 2, "ToBoolean(number)"); + + result = sample.findLastIndex(function() { return -1; }); + assert.sameValue(result, 2, "ToBoolean(negative number)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js new file mode 100644 index 00000000000..99558214c0c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Return -1 if predicate always returns a boolean false value. +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 5. Let k be len - 1. + 6. Repeat, while k ≥ 0 + ... + c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). + ... + 7. Return -1𝔽. +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1, 2, 3]); + var called = 0; + + var result = sample.findLastIndex(function() { + called++; + return false; + }); + + assert.sameValue(called, 3, "predicate was called three times"); + assert.sameValue(result, -1, "result is -1 when predicate returns are false"); + + result = sample.findLastIndex(function() { return ""; }); + assert.sameValue(result, -1, "ToBoolean(string)"); + + result = sample.findLastIndex(function() { return undefined; }); + assert.sameValue(result, -1, "ToBoolean(undefined)"); + + result = sample.findLastIndex(function() { return null; }); + assert.sameValue(result, -1, "ToBoolean(null)"); + + result = sample.findLastIndex(function() { return 0; }); + assert.sameValue(result, -1, "ToBoolean(0)"); + + result = sample.findLastIndex(function() { return -0; }); + assert.sameValue(result, -1, "ToBoolean(-0)"); + + result = sample.findLastIndex(function() { return NaN; }); + assert.sameValue(result, -1, "ToBoolean(NaN)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-object.js new file mode 100644 index 00000000000..b370ea78d22 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-object.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: Throws a TypeError exception when `this` is not Object +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, SendableTypedArray, array-find-from-last] +---*/ + +var findLastIndex = SendableTypedArray.prototype.findLastIndex; +var predicate = function() {}; + +assert.throws(TypeError, function() { + findLastIndex.call(undefined, predicate); +}, "this is undefined"); + +assert.throws(TypeError, function() { + findLastIndex.call(null, predicate); +}, "this is null"); + +assert.throws(TypeError, function() { + findLastIndex.call(42, predicate); +}, "this is 42"); + +assert.throws(TypeError, function() { + findLastIndex.call("1", predicate); +}, "this is a string"); + +assert.throws(TypeError, function() { + findLastIndex.call(true, predicate); +}, "this is true"); + +assert.throws(TypeError, function() { + findLastIndex.call(false, predicate); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + findLastIndex.call(s, predicate); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..307be3c8ce5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.findlastindex +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) + + ... + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray, array-find-from-last] +---*/ + +var findLastIndex = SendableTypedArray.prototype.findLastIndex; +var predicate = function() {}; + +assert.throws(TypeError, function() { + findLastIndex.call({}, predicate); +}, "this is an Object"); + +assert.throws(TypeError, function() { + findLastIndex.call([], predicate); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + findLastIndex.call(ab, predicate); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + findLastIndex.call(dv, predicate); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js new file mode 100644 index 00000000000..e04b79116fc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + [[ArrayLength]] is accessed in place of performing a [[Get]] of "length" +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(42); + var loop = 0; + + Object.defineProperty(sample1, "length", {value: 1}); + + sample1.forEach(function() { + loop++; + }); + + assert.sameValue(loop, 42, "data descriptor"); + + var sample2 = new TA(7); + loop = 0; + + Object.defineProperty(sample2, "length", { + get: function() { + throw new Test262Error( + "Does not return abrupt getting length property" + ); + } + }); + + sample2.forEach(function() { + loop++; + }); + + assert.sameValue(loop, 7, "accessor descriptor"); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js new file mode 100644 index 00000000000..c7515cb8fa9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + thisArg does not affect callbackfn arguments +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" + + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Perform ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + var results = []; + var thisArg = ["test262", 0, "ecma262", 0]; + + sample.forEach(function() { + results.push(arguments); + }, thisArg); + + assert.sameValue(results.length, 3, "results.length"); + assert.sameValue(thisArg.length, 4, "thisArg.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42n, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43n, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44n, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js new file mode 100644 index 00000000000..57377b04532 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + callbackfn arguments +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" + + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Perform ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + var results = []; + + sample.forEach(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 3, "results.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42n, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43n, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44n, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js new file mode 100644 index 00000000000..1db0184bf45 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + Instance buffer can be detached during loop +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" + + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + ... + ii. Perform ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [detachArrayBuffer.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.forEach(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + }); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js new file mode 100644 index 00000000000..f003992dfaf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + callbackfn is not callable +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" + + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + assert.throws(TypeError, function() { + sample.forEach(); + }); + + assert.throws(TypeError, function() { + sample.forEach(undefined); + }); + + assert.throws(TypeError, function() { + sample.forEach(null); + }); + + assert.throws(TypeError, function() { + sample.forEach({}); + }); + + assert.throws(TypeError, function() { + sample.forEach(1); + }); + + assert.throws(TypeError, function() { + sample.forEach(""); + }); + + assert.throws(TypeError, function() { + sample.forEach(false); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js new file mode 100644 index 00000000000..f253db73d62 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + Does not interact over non-integer properties +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + ... + ii. Perform ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7n, 8n]); + + var results = []; + + sample.foo = 42; + sample[Symbol("1")] = 43; + + sample.forEach(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + + assert.sameValue(results[0][0], 7n, "results[0][0] - kValue"); + assert.sameValue(results[1][0], 8n, "results[1][0] - kValue"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js new file mode 100644 index 00000000000..ca8a482dadb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + callbackfn is not called on empty instances +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" + + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + ... + ii. Perform ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var called = 0; + + new TA().forEach(function() { + called++; + }); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js new file mode 100644 index 00000000000..51528130617 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + The callbackfn return does not change the instance +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(3); + + sample1[1] = 1n; + + sample1.forEach(function() { + return 42; + }); + + assert.sameValue(sample1[0], 0n, "[0] == 0"); + assert.sameValue(sample1[1], 1n, "[1] == 1"); + assert.sameValue(sample1[2], 0n, "[2] == 0"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js new file mode 100644 index 00000000000..2059f0e4573 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + Returns abrupt from callbackfn +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" + + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + ... + ii. Perform ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + assert.throws(Test262Error, function() { + sample.forEach(function() { + throw new Test262Error(); + }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js new file mode 100644 index 00000000000..a8991c28f1f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Reflect.set, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + var newVal = 0n; + + sample.forEach(function(val, i) { + if (i > 0) { + assert.sameValue( + sample[i - 1], newVal - 1n, + "get the changed value during the loop" + ); + assert.sameValue( + Reflect.set(sample, 0, 7n), + true, + "re-set a value for sample[0]" + ); + } + assert.sameValue( + Reflect.set(sample, i, newVal), + true, + "set value during iteration" + ); + + newVal++; + }); + + assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7"); + assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1"); + assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js new file mode 100644 index 00000000000..8a8bb51068b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + callbackfn `this` value +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" + + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + ... + ii. Perform ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var expected = (function() { return this; })(); +var thisArg = {}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var results1 = []; + + sample.forEach(function() { + results1.push(this); + }); + + assert.sameValue(results1.length, 3, "results1"); + assert.sameValue(results1[0], expected, "without thisArg - [0]"); + assert.sameValue(results1[1], expected, "without thisArg - [1]"); + assert.sameValue(results1[2], expected, "without thisArg - [2]"); + + var results2 = []; + + sample.forEach(function() { + results2.push(this); + }, thisArg); + + assert.sameValue(results2.length, 3, "results2"); + assert.sameValue(results2[0], thisArg, "using thisArg - [0]"); + assert.sameValue(results2[1], thisArg, "using thisArg - [1]"); + assert.sameValue(results2[2], thisArg, "using thisArg - [2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/detached-buffer.js new file mode 100644 index 00000000000..dbd1ac29df6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var callbackfn = function() { + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.forEach(callbackfn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..c95bf39e4df --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.forEach, + 'function', + 'implements SendableTypedArray.prototype.forEach' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.forEach(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.forEach(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the forEach operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.forEach(() => {}); + throw new Test262Error('forEach completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/returns-undefined.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/returns-undefined.js new file mode 100644 index 00000000000..6967351c7fc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/returns-undefined.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + Returns undefined +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(42); + + var result1 = sample1.forEach(function() { + return 42; + }); + + assert.sameValue(result1, undefined, "result1"); + + var sample2 = new TA(1); + var result2 = sample2.forEach(function() { + return null; + }); + + assert.sameValue(result2, undefined, "result2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js new file mode 100644 index 00000000000..dd96a06b373 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + Integer indexed values are not cached before iteration +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + sample.forEach(function(v, i) { + if (i < sample.length - 1) { + sample[i+1] = 42n; + } + + assert.sameValue( + v, 42n, "method does not cache values before callbackfn calls" + ); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js new file mode 100644 index 00000000000..6c6f7ec7472 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + [[ArrayLength]] is accessed in place of performing a [[Get]] of "length" +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(42); + var loop = 0; + + Object.defineProperty(sample1, "length", {value: 1}); + + sample1.forEach(function() { + loop++; + }); + + assert.sameValue(loop, 42, "data descriptor"); + + var sample2 = new TA(7); + loop = 0; + + Object.defineProperty(sample2, "length", { + get: function() { + throw new Test262Error( + "Does not return abrupt getting length property" + ); + } + }); + + sample2.forEach(function() { + loop++; + }); + + assert.sameValue(loop, 7, "accessor descriptor"); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js new file mode 100644 index 00000000000..aa1c02f2b7e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + thisArg does not affect callbackfn arguments +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" + + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Perform ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + var results = []; + var thisArg = ["test262", 0, "ecma262", 0]; + + sample.forEach(function() { + results.push(arguments); + }, thisArg); + + assert.sameValue(results.length, 3, "results.length"); + assert.sameValue(thisArg.length, 4, "thisArg.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js new file mode 100644 index 00000000000..689fdf3d5d5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + callbackfn arguments +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" + + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Perform ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + var results = []; + + sample.forEach(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 3, "results.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js new file mode 100644 index 00000000000..5f7507dd0f6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + Instance buffer can be detached during loop +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" + + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + ... + ii. Perform ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [detachArrayBuffer.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.forEach(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + }); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js new file mode 100644 index 00000000000..fb9c8b8ca86 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + callbackfn is not callable +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" + + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + assert.throws(TypeError, function() { + sample.forEach(); + }); + + assert.throws(TypeError, function() { + sample.forEach(undefined); + }); + + assert.throws(TypeError, function() { + sample.forEach(null); + }); + + assert.throws(TypeError, function() { + sample.forEach({}); + }); + + assert.throws(TypeError, function() { + sample.forEach(1); + }); + + assert.throws(TypeError, function() { + sample.forEach(""); + }); + + assert.throws(TypeError, function() { + sample.forEach(false); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js new file mode 100644 index 00000000000..70c6dc1d2e5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + Does not interact over non-integer properties +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + ... + ii. Perform ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7, 8]); + + var results = []; + + sample.foo = 42; + sample[Symbol("1")] = 43; + + sample.forEach(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + + assert.sameValue(results[0][0], 7, "results[0][0] - kValue"); + assert.sameValue(results[1][0], 8, "results[1][0] - kValue"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js new file mode 100644 index 00000000000..ba3ec8859d0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + callbackfn is not called on empty instances +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" + + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + ... + ii. Perform ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var called = 0; + + new TA().forEach(function() { + called++; + }); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js new file mode 100644 index 00000000000..5aa77ab33d2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.forEach +description: Instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var finalElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = sample.forEach(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + finalElement = undefined; + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + finalElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + }); + + assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)'); + assert.compareArray(indices, [0, 1, 2], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, undefined, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = sample.forEach(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, undefined, 'result (grow)'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js new file mode 100644 index 00000000000..164b176df71 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + The callbackfn return does not change the instance +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(3); + + sample1[1] = 1; + + sample1.forEach(function() { + return 42; + }); + + assert.sameValue(sample1[0], 0, "[0] == 0"); + assert.sameValue(sample1[1], 1, "[1] == 1"); + assert.sameValue(sample1[2], 0, "[2] == 0"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js new file mode 100644 index 00000000000..917525264a9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + Returns abrupt from callbackfn +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" + + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + ... + ii. Perform ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + assert.throws(Test262Error, function() { + sample.forEach(function() { + throw new Test262Error(); + }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js new file mode 100644 index 00000000000..fccf5a6247d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" +includes: [testTypedArray.js] +features: [Reflect.set, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + var newVal = 0; + + sample.forEach(function(val, i) { + if (i > 0) { + assert.sameValue( + sample[i - 1], newVal - 1, + "get the changed value during the loop" + ); + assert.sameValue( + Reflect.set(sample, 0, 7), + true, + "re-set a value for sample[0]" + ); + } + assert.sameValue( + Reflect.set(sample, i, newVal), + true, + "set value during iteration" + ); + + newVal++; + }); + + assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7"); + assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1"); + assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js new file mode 100644 index 00000000000..f03186c1999 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + callbackfn `this` value +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" + + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + ... + ii. Perform ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var expected = (function() { return this; })(); +var thisArg = {}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var results1 = []; + + sample.forEach(function() { + results1.push(this); + }); + + assert.sameValue(results1.length, 3, "results1"); + assert.sameValue(results1[0], expected, "without thisArg - [0]"); + assert.sameValue(results1[1], expected, "without thisArg - [1]"); + assert.sameValue(results1[2], expected, "without thisArg - [2]"); + + var results2 = []; + + sample.forEach(function() { + results2.push(this); + }, thisArg); + + assert.sameValue(results2.length, 3, "results2"); + assert.sameValue(results2[0], thisArg, "using thisArg - [0]"); + assert.sameValue(results2[1], thisArg, "using thisArg - [1]"); + assert.sameValue(results2[2], thisArg, "using thisArg - [2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js new file mode 100644 index 00000000000..316c4d1244a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var callbackfn = function() { + throw new Test262Error(); +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.forEach(callbackfn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-func.js new file mode 100644 index 00000000000..0801b598a11 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-func.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var forEach = SendableTypedArray.prototype.forEach; + +assert.sameValue(typeof forEach, 'function'); + +assert.throws(TypeError, function() { + forEach(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-method.js new file mode 100644 index 00000000000..20ebddd4c22 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-method.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.forEach, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.forEach(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/length.js b/test/sendable/builtins/TypedArray/prototype/forEach/length.js new file mode 100644 index 00000000000..8130e1ff798 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + %SendableTypedArray%.prototype.forEach.length is 1. +info: | + %SendableTypedArray%.prototype.forEach (callbackfn [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.forEach, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/name.js b/test/sendable/builtins/TypedArray/prototype/forEach/name.js new file mode 100644 index 00000000000..c5a91e1423d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + %SendableTypedArray%.prototype.forEach.name is "forEach". +info: | + %SendableTypedArray%.prototype.forEach (callbackfn [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.forEach, "name", { + value: "forEach", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/forEach/not-a-constructor.js new file mode 100644 index 00000000000..43f40494bc6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.forEach 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.forEach), + false, + 'isConstructor(SendableTypedArray.prototype.forEach) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.forEach(() => {}); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/forEach/prop-desc.js new file mode 100644 index 00000000000..4541148279a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + "forEach" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'forEach', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..f43377101bf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + SendableTypedArray.p.forEach behaves correctly on SendableTypedArrays backed by resizable + buffers that are grown mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + fixedLength.forEach(ResizeMidIteration); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + fixedLengthWithOffset.forEach(ResizeMidIteration); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + lengthTracking.forEach(ResizeMidIteration); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + lengthTrackingWithOffset.forEach(ResizeMidIteration); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..3791c679555 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + SendableTypedArray.p.forEach behaves correctly on SendableTypedArrays backed by resizable + buffers that are shrunk mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + fixedLength.forEach(ResizeMidIteration); + assert.compareArray(values, [ + 0, + 2, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + fixedLengthWithOffset.forEach(ResizeMidIteration); + assert.compareArray(values, [ + 4, + undefined + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + lengthTracking.forEach(ResizeMidIteration); + assert.compareArray(values, [ + 0, + 2, + 4, + undefined + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + lengthTrackingWithOffset.forEach(ResizeMidIteration); + assert.compareArray(values, [ + 4, + undefined + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer.js new file mode 100644 index 00000000000..51d5cbecb87 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer.js @@ -0,0 +1,157 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + SendableTypedArray.p.forEach behaves correctly when on SendableTypedArrays backed by resizable + buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + function Collect(array) { + const forEachValues = []; + array.forEach(n => { + forEachValues.push(n); + }); + return ToNumbers(forEachValues); + } + assert.compareArray(Collect(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(Collect(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(Collect(lengthTracking), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(Collect(lengthTrackingWithOffset), [ + 4, + 6 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + Collect(fixedLength); + }); + assert.throws(TypeError, () => { + Collect(fixedLengthWithOffset); + }); + + assert.compareArray(Collect(lengthTracking), [ + 0, + 2, + 4 + ]); + assert.compareArray(Collect(lengthTrackingWithOffset), [4]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + Collect(fixedLength); + }); + assert.throws(TypeError, () => { + Collect(fixedLengthWithOffset); + }); + assert.throws(TypeError, () => { + Collect(lengthTrackingWithOffset); + }); + + assert.compareArray(Collect(lengthTracking), [0]); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + Collect(fixedLength); + }); + assert.throws(TypeError, () => { + Collect(fixedLengthWithOffset); + }); + assert.throws(TypeError, () => { + Collect(lengthTrackingWithOffset); + }); + + assert.compareArray(Collect(lengthTracking), []); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert.compareArray(Collect(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(Collect(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(Collect(lengthTracking), [ + 0, + 2, + 4, + 6, + 8, + 10 + ]); + assert.compareArray(Collect(lengthTrackingWithOffset), [ + 4, + 6, + 8, + 10 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..93d06f6b49b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.forEach, + 'function', + 'implements SendableTypedArray.prototype.forEach' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.forEach(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.forEach(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the forEach operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.forEach(() => {}); + throw new Test262Error('forEach completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js b/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js new file mode 100644 index 00000000000..e644046c6b3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + Returns undefined +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(42); + + var result1 = sample1.forEach(function() { + return 42; + }); + + assert.sameValue(result1, undefined, "result1"); + + var sample2 = new TA(1); + var result2 = sample2.forEach(function() { + return null; + }); + + assert.sameValue(result2, undefined, "result2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-object.js new file mode 100644 index 00000000000..4d0492fa3da --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-object.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var forEach = SendableTypedArray.prototype.forEach; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + forEach.call(undefined, callbackfn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + forEach.call(null, callbackfn); +}, "this is null"); + +assert.throws(TypeError, function() { + forEach.call(42, callbackfn); +}, "this is 42"); + +assert.throws(TypeError, function() { + forEach.call("1", callbackfn); +}, "this is a string"); + +assert.throws(TypeError, function() { + forEach.call(true, callbackfn); +}, "this is true"); + +assert.throws(TypeError, function() { + forEach.call(false, callbackfn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + forEach.call(s, callbackfn); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..d8d6db1db7b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var forEach = SendableTypedArray.prototype.forEach; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + forEach.call({}, callbackfn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + forEach.call([], callbackfn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + forEach.call(ab, callbackfn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + forEach.call(dv, callbackfn); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js new file mode 100644 index 00000000000..a9b303b89ef --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.foreach +description: > + Integer indexed values are not cached before iteration +info: | + 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.forEach is a distinct function that implements the same + algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length" +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + sample.forEach(function(v, i) { + if (i < sample.length - 1) { + sample[i+1] = 42; + } + + assert.sameValue( + v, 42, "method does not cache values before callbackfn calls" + ); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js new file mode 100644 index 00000000000..55228ffcf4a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Returns -1 if buffer is detached after ValidateSendableTypedArray +info: | + %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.includes are the same as for Array.prototype.includes as defined in 22.1.3.13. + + When the includes method is called with one or two arguments, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If len is 0, return false. + Let n be ? ToIntegerOrInfinity(fromIndex). + Assert: If fromIndex is undefined, then n is 0. + If n is +∞, return false. + Else if n is -∞, set n to 0. + If n ≥ 0, then + Let k be n. + Else, + Let k be len + n. + If k < 0, set k to 0. + Repeat, while k < len, + Let elementK be the result of ! Get(O, ! ToString(F(k))). + If SameValueZero(searchElement, elementK) is true, return true. + Set k to k + 1. + Return false. + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + const sample = new TA(1); + const fromIndex = { + valueOf() { + $DETACHBUFFER(sample.buffer); + return 0; + } + }; + + assert.sameValue(sample.includes(0n, fromIndex), false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js new file mode 100644 index 00000000000..be8172aa8dc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + Returns false if buffer is detached after ValidateSendableTypedArray and searchElement is a value +info: | + %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.includes are the same as for Array.prototype.includes as defined in 22.1.3.13. + + When the includes method is called with one or two arguments, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If len is 0, return false. + Let n be ? ToIntegerOrInfinity(fromIndex). + Assert: If fromIndex is undefined, then n is 0. + If n is +∞, return false. + Else if n is -∞, set n to 0. + If n ≥ 0, then + Let k be n. + Else, + Let k be len + n. + If k < 0, set k to 0. + Repeat, while k < len, + Let elementK be the result of ! Get(O, ! ToString(F(k))). + If SameValueZero(searchElement, elementK) is true, return true. + Set k to k + 1. + Return false. + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + const sample = new TA(1); + const fromIndex = { + valueOf() { + $DETACHBUFFER(sample.buffer); + return 0; + } + }; + + assert.sameValue(sample.includes(undefined, fromIndex), true); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer.js new file mode 100644 index 00000000000..fbdbef7fc4a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.14 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.includes(0n); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js new file mode 100644 index 00000000000..8ef71f9f681 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Return false if fromIndex >= ArrayLength +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + 5. If n ≥ 0, then + a. Let k be n. + ... + 7. Repeat, while k < len + ... + 8. Return false. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA(42); + assert.sameValue(sample.includes(0n, 42), false); + assert.sameValue(sample.includes(0n, 43), false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js new file mode 100644 index 00000000000..0554cbe3d4e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: handle Infinity values for fromIndex +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + 5. If n ≥ 0, then + a. Let k be n. + 6. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 7. Repeat, while k < len + ... + 8. Return false. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 43n, 41n]); + + assert.sameValue( + sample.includes(43n, Infinity), + false, + "includes(43, Infinity)" + ); + assert.sameValue( + sample.includes(43n, -Infinity), + true, + "includes(43, -Infinity)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js new file mode 100644 index 00000000000..7f788c323b8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: -0 fromIndex becomes 0 +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. Let k be n. + ... + 7. Repeat, while k < len + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42n, 43n]); + assert.sameValue(sample.includes(42n, -0), true, "-0 [0]"); + assert.sameValue(sample.includes(43n, -0), true, "-0 [1]"); + assert.sameValue(sample.includes(44n, -0), false, "-0 [2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..f3118895001 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", {value: 0}); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7n]); + + Object.defineProperty(TA.prototype, "length", {value: 0}); + Object.defineProperty(sample, "length", {value: 0}); + + assert.sameValue(sample.includes(7n), true); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js new file mode 100644 index 00000000000..1e13fe4abff --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Returns false if length is 0 +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. If len is 0, return false. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.sameValue(sample.includes(0), false, "returns false"); + assert.sameValue(sample.includes(), false, "returns false - no arg"); + assert.sameValue( + sample.includes(0n, fromIndex), false, + "length is checked before ToInteger(fromIndex)" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..95f343cc479 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.includes, + 'function', + 'implements SendableTypedArray.prototype.includes' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.includes(0n); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.includes(0n); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the includes operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.includes(0n); + throw new Test262Error('includes completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js new file mode 100644 index 00000000000..dfaa231f9b7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Return abrupt from ToInteger(fromIndex) - using symbol +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var fromIndex = Symbol("1"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7n]); + + assert.throws(TypeError, function() { + sample.includes(7n, fromIndex); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js new file mode 100644 index 00000000000..8652f171d32 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Return abrupt from ToInteger(fromIndex) +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7n]); + + assert.throws(Test262Error, function() { + sample.includes(7n, fromIndex); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js new file mode 100644 index 00000000000..eb6e2c2c11b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: returns true for found index +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. Let k be n. + 6. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 42n, 41n]); + assert.sameValue(sample.includes(42n), true, "includes(42)"); + assert.sameValue(sample.includes(43n), true, "includes(43)"); + assert.sameValue(sample.includes(43n, 1), true, "includes(43, 1)"); + assert.sameValue(sample.includes(42n, 1), true, "includes(42, 1)"); + assert.sameValue(sample.includes(42n, 2), true, "includes(42, 2)"); + + assert.sameValue(sample.includes(42n, -4), true, "includes(42, -4)"); + assert.sameValue(sample.includes(42n, -3), true, "includes(42, -3)"); + assert.sameValue(sample.includes(42n, -2), true, "includes(42, -2)"); + assert.sameValue(sample.includes(42n, -5), true, "includes(42, -5)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js new file mode 100644 index 00000000000..5c50e0dc574 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: returns false if the element is not found +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. Let k be n. + 6. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + 8. Return false. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42n, 43n, 42n, 41n]); + assert.sameValue(sample.includes(44n), false, "includes(44)"); + assert.sameValue(sample.includes(43n, 2), false, "includes(43, 2)"); + assert.sameValue(sample.includes(42n, 3), false, "includes(42, 3)"); + assert.sameValue(sample.includes(44n, -4), false, "includes(44, -4)"); + assert.sameValue(sample.includes(44n, -5), false, "includes(44, -5)"); + assert.sameValue(sample.includes(42n, -1), false, "includes(42, -1)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js new file mode 100644 index 00000000000..2cbe65c52ad --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: get the integer value from fromIndex +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + 5. If n ≥ 0, then + a. Let k be n. + ... + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + 8. Return false. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj = { + valueOf: function() { + return 1; + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42n, 43n]); + assert.sameValue(sample.includes(42n, "1"), false, "string [0]"); + assert.sameValue(sample.includes(43n, "1"), true, "string [1]"); + + assert.sameValue(sample.includes(42n, true), false, "true [0]"); + assert.sameValue(sample.includes(43n, true), true, "true [1]"); + + assert.sameValue(sample.includes(42n, false), true, "false [0]"); + assert.sameValue(sample.includes(43n, false), true, "false [1]"); + + assert.sameValue(sample.includes(42n, NaN), true, "NaN [0]"); + assert.sameValue(sample.includes(43n, NaN), true, "NaN [1]"); + + assert.sameValue(sample.includes(42n, null), true, "null [0]"); + assert.sameValue(sample.includes(43n, null), true, "null [1]"); + + assert.sameValue(sample.includes(42n, undefined), true, "undefined [0]"); + assert.sameValue(sample.includes(43n, undefined), true, "undefined [1]"); + + assert.sameValue(sample.includes(42n, null), true, "null [0]"); + assert.sameValue(sample.includes(43n, null), true, "null [1]"); + + assert.sameValue(sample.includes(42n, obj), false, "object [0]"); + assert.sameValue(sample.includes(43n, obj), true, "object [1]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/coerced-searchelement-fromindex-resize.js b/test/sendable/builtins/TypedArray/prototype/includes/coerced-searchelement-fromindex-resize.js new file mode 100644 index 00000000000..1ba12c57467 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/coerced-searchelement-fromindex-resize.js @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + SendableTypedArray.p.includes behaves correctly on SendableTypedArrays backed by resizable + buffers that are resized during argument coercion. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer, Array.prototype.includes] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert(!fixedLength.includes(undefined)); + // The TA is OOB so it includes only "undefined". + assert(fixedLength.includes(undefined, evil)); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + let n0 = MayNeedBigInt(fixedLength, 0); + assert(fixedLength.includes(n0)); + // The TA is OOB so it includes only "undefined". + assert(!fixedLength.includes(n0, evil)); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert(!lengthTracking.includes(undefined)); + // "includes" iterates until the original length and sees "undefined"s. + assert(lengthTracking.includes(undefined, evil)); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, 1); + } + let evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + let n0 = MayNeedBigInt(lengthTracking, 0); + assert(!lengthTracking.includes(n0)); + // The TA grew but we only look at the data until the original length. + assert(!lengthTracking.includes(n0, evil)); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + lengthTracking[0] = MayNeedBigInt(lengthTracking, 1); + let evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return -4; + } + }; + let n1 = MayNeedBigInt(lengthTracking, 1); + assert(lengthTracking.includes(n1, -4)); + // The TA grew but the start index conversion is done based on the original + // length. + assert(lengthTracking.includes(n1, evil)); +} diff --git a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js new file mode 100644 index 00000000000..6da3b3f7005 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + Returns false if buffer is detached after ValidateSendableTypedArray and searchElement is a value +info: | + %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.includes are the same as for Array.prototype.includes as defined in 22.1.3.13. + + When the includes method is called with one or two arguments, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If len is 0, return false. + Let n be ? ToIntegerOrInfinity(fromIndex). + Assert: If fromIndex is undefined, then n is 0. + If n is +∞, return false. + Else if n is -∞, set n to 0. + If n ≥ 0, then + Let k be n. + Else, + Let k be len + n. + If k < 0, set k to 0. + Repeat, while k < len, + Let elementK be the result of ! Get(O, ! ToString(F(k))). + If SameValueZero(searchElement, elementK) is true, return true. + Set k to k + 1. + Return false. + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + const sample = new TA(1); + const fromIndex = { + valueOf() { + $DETACHBUFFER(sample.buffer); + return 0; + } + }; + + assert.sameValue(sample.includes(0, fromIndex), false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js new file mode 100644 index 00000000000..06d32ecc494 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + Returns true if buffer is detached after ValidateSendableTypedArray and searchElement is undefined +info: | + %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.includes are the same as for Array.prototype.includes as defined in 22.1.3.13. + + When the includes method is called with one or two arguments, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If len is 0, return false. + Let n be ? ToIntegerOrInfinity(fromIndex). + Assert: If fromIndex is undefined, then n is 0. + If n is +∞, return false. + Else if n is -∞, set n to 0. + If n ≥ 0, then + Let k be n. + Else, + Let k be len + n. + If k < 0, set k to 0. + Repeat, while k < len, + Let elementK be the result of ! Get(O, ! ToString(F(k))). + If SameValueZero(searchElement, elementK) is true, return true. + Set k to k + 1. + Return false. + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + const sample = new TA(1); + const fromIndex = { + valueOf() { + $DETACHBUFFER(sample.buffer); + return 0; + } + }; + + assert.sameValue(sample.includes(undefined, fromIndex), true); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js new file mode 100644 index 00000000000..f397f9f4d44 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.14 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.includes(0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js new file mode 100644 index 00000000000..2877e3a97a6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Return false if fromIndex >= ArrayLength +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + 5. If n ≥ 0, then + a. Let k be n. + ... + 7. Repeat, while k < len + ... + 8. Return false. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA(42); + assert.sameValue(sample.includes(0, 42), false); + assert.sameValue(sample.includes(0, 43), false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js new file mode 100644 index 00000000000..cf45794c95f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: handle Infinity values for fromIndex +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + 5. If n ≥ 0, then + a. Let k be n. + 6. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 7. Repeat, while k < len + ... + 8. Return false. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 43, 41]); + + assert.sameValue( + sample.includes(43, Infinity), + false, + "includes(43, Infinity)" + ); + assert.sameValue( + sample.includes(43, -Infinity), + true, + "includes(43, -Infinity)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js new file mode 100644 index 00000000000..ce5a3e4b5b9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: -0 fromIndex becomes 0 +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. Let k be n. + ... + 7. Repeat, while k < len + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42, 43]); + assert.sameValue(sample.includes(42, -0), true, "-0 [0]"); + assert.sameValue(sample.includes(43, -0), true, "-0 [1]"); + assert.sameValue(sample.includes(44, -0), false, "-0 [2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..4703754debf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", {value: 0}); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7]); + + Object.defineProperty(TA.prototype, "length", {value: 0}); + Object.defineProperty(sample, "length", {value: 0}); + + assert.sameValue(sample.includes(7), true); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js new file mode 100644 index 00000000000..bf57425bc7b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + Index is compared against the initial length when typed array is made out-of-bounds. +info: | + %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let taRecord be ? ValidateSendableTypedArray(O, seq-cst). + 3. Let len be SendableTypedArrayLength(taRecord). + ... + 5. Let n be ? ToIntegerOrInfinity(fromIndex). + ... + 9. If n ≥ 0, then + a. Let k be n. + ... + 11. Repeat, while k < len, + ... + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(4, {maxByteLength: 20}); + +// Uses byteOffset to make typed array out-of-bounds when shrinking size to zero. +let byteOffset = 1; + +let ta = new Int8Array(rab, byteOffset); + +let index = { + valueOf() { + // Shrink buffer to zero. + rab.resize(0); + + // Index is larger than the initial length. + return 10; + } +}; + +// Typed array is in-bounds. +assert.sameValue(ta.length, 3); + +let result = ta.includes(undefined, index); + +// Typed array is out-of-bounds. +assert.sameValue(ta.length, 0); + +assert.sameValue(result, false); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length.js b/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length.js new file mode 100644 index 00000000000..a9d949936aa --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + Index is compared against the initial length. +info: | + %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let taRecord be ? ValidateSendableTypedArray(O, seq-cst). + 3. Let len be SendableTypedArrayLength(taRecord). + ... + 5. Let n be ? ToIntegerOrInfinity(fromIndex). + ... + 9. If n ≥ 0, then + a. Let k be n. + ... + 11. Repeat, while k < len, + ... + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(4, {maxByteLength: 20}); +let ta = new Int8Array(rab); + +let index = { + valueOf() { + // Shrink buffer to zero. + rab.resize(0); + + // Index is larger than the initial length. + return 10; + } +}; + +// Auto-length is correctly tracked. +assert.sameValue(ta.length, 4); + +let result = ta.includes(undefined, index); + +// Auto-length is correctly set to zero. +assert.sameValue(ta.length, 0); + +assert.sameValue(result, false); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-func.js new file mode 100644 index 00000000000..cf93c0971c2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-func.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.14 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var includes = SendableTypedArray.prototype.includes; + +assert.sameValue(typeof includes, "function"); + +assert.throws(TypeError, function() { + includes(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-method.js new file mode 100644 index 00000000000..f5e2301f8f5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-method.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.14 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.includes, "function"); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.includes(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js new file mode 100644 index 00000000000..404c38dcc1e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Returns false if length is 0 +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. If len is 0, return false. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.sameValue(sample.includes(0), false, "returns false"); + assert.sameValue(sample.includes(), false, "returns false - no arg"); + assert.sameValue( + sample.includes(0, fromIndex), false, + "length is checked before ToInteger(fromIndex)" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/length.js b/test/sendable/builtins/TypedArray/prototype/includes/length.js new file mode 100644 index 00000000000..c6af728665d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + %SendableTypedArray%.prototype.includes.length is 1. +info: | + %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.includes, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/name.js b/test/sendable/builtins/TypedArray/prototype/includes/name.js new file mode 100644 index 00000000000..844ff64545c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + %SendableTypedArray%.prototype.includes.name is "includes". +info: | + %SendableTypedArray%.prototype.includes (searchElement [ , fromIndex ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.includes, "name", { + value: "includes", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/includes/not-a-constructor.js new file mode 100644 index 00000000000..f6b81426d18 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.includes 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.includes), + false, + 'isConstructor(SendableTypedArray.prototype.includes) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.includes(1); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/includes/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/includes/prop-desc.js new file mode 100644 index 00000000000..23187ddaadb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + "includes" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, "includes", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer-special-float-values.js b/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer-special-float-values.js new file mode 100644 index 00000000000..4f8e3f41c38 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer-special-float-values.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + SendableTypedArray.p.includes behaves correctly for special float values when + receiver is a float SendableTypedArray backed by a resizable buffer. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer, Array.prototype.includes] +---*/ + +for (let ctor of floatCtors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + lengthTracking[0] = -Infinity; + lengthTracking[1] = Infinity; + lengthTracking[2] = NaN; + assert(lengthTracking.includes(-Infinity)); + assert(lengthTracking.includes(Infinity)); + assert(lengthTracking.includes(NaN)); +} diff --git a/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer.js new file mode 100644 index 00000000000..c2f20786193 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer.js @@ -0,0 +1,149 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + SendableTypedArray.p.includes behaves correctly on SendableTypedArrays backed by resizable + buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer, Array.prototype.includes] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + // If fixedLength is a BigInt array, they all are BigInt Arrays. + let n2 = MayNeedBigInt(fixedLength, 2); + let n4 = MayNeedBigInt(fixedLength, 4); + + assert(fixedLength.includes(n2)); + assert(!fixedLength.includes(undefined)); + assert(fixedLength.includes(n2, 1)); + assert(!fixedLength.includes(n2, 2)); + assert(fixedLength.includes(n2, -3)); + assert(!fixedLength.includes(n2, -2)); + assert(!fixedLengthWithOffset.includes(n2)); + assert(fixedLengthWithOffset.includes(n4)); + assert(!fixedLengthWithOffset.includes(undefined)); + assert(fixedLengthWithOffset.includes(n4, 0)); + assert(!fixedLengthWithOffset.includes(n4, 1)); + assert(fixedLengthWithOffset.includes(n4, -2)); + assert(!fixedLengthWithOffset.includes(n4, -1)); + assert(lengthTracking.includes(n2)); + assert(!lengthTracking.includes(undefined)); + assert(lengthTracking.includes(n2, 1)); + assert(!lengthTracking.includes(n2, 2)); + assert(lengthTracking.includes(n2, -3)); + assert(!lengthTracking.includes(n2, -2)); + assert(!lengthTrackingWithOffset.includes(n2)); + assert(lengthTrackingWithOffset.includes(n4)); + assert(!lengthTrackingWithOffset.includes(undefined)); + assert(lengthTrackingWithOffset.includes(n4, 0)); + assert(!lengthTrackingWithOffset.includes(n4, 1)); + assert(lengthTrackingWithOffset.includes(n4, -2)); + assert(!lengthTrackingWithOffset.includes(n4, -1)); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + fixedLength.includes(n2); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.includes(n2); + }); + + assert(lengthTracking.includes(n2)); + assert(!lengthTracking.includes(undefined)); + assert(!lengthTrackingWithOffset.includes(n2)); + assert(lengthTrackingWithOffset.includes(n4)); + assert(!lengthTrackingWithOffset.includes(undefined)); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.includes(n2); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.includes(n2); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.includes(n2); + }); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.includes(n2); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.includes(n2); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.includes(n2); + }); + assert(!lengthTracking.includes(n2)); + assert(!lengthTracking.includes(undefined)); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + let n8 = MayNeedBigInt(fixedLength, 8); + + assert(fixedLength.includes(n2)); + assert(!fixedLength.includes(undefined)); + assert(!fixedLength.includes(n8)); + assert(!fixedLengthWithOffset.includes(n2)); + assert(fixedLengthWithOffset.includes(n4)); + assert(!fixedLengthWithOffset.includes(undefined)); + assert(!fixedLengthWithOffset.includes(n8)); + assert(lengthTracking.includes(n2)); + assert(!lengthTracking.includes(undefined)); + assert(lengthTracking.includes(n8)); + assert(!lengthTrackingWithOffset.includes(n2)); + assert(lengthTrackingWithOffset.includes(n4)); + assert(!lengthTrackingWithOffset.includes(undefined)); + assert(lengthTrackingWithOffset.includes(n8)); +} diff --git a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..ce486baea18 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.includes, + 'function', + 'implements SendableTypedArray.prototype.includes' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.includes(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.includes(0); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the includes operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.includes(0); + throw new Test262Error('includes completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js new file mode 100644 index 00000000000..c388075498c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Return abrupt from ToInteger(fromIndex) - using symbol +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var fromIndex = Symbol("1"); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7]); + + assert.throws(TypeError, function() { + sample.includes(7, fromIndex); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js new file mode 100644 index 00000000000..520ab9ade45 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Return abrupt from ToInteger(fromIndex) +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7]); + + assert.throws(Test262Error, function() { + sample.includes(7, fromIndex); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js b/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js new file mode 100644 index 00000000000..4d65547f090 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: search element is compared using SameValueZero +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 0, 1, undefined]); + assert.sameValue(sample.includes(), false, "no arg"); + assert.sameValue(sample.includes(undefined), false, "undefined"); + assert.sameValue(sample.includes("42"), false, "'42'"); + assert.sameValue(sample.includes([42]), false, "[42]"); + assert.sameValue(sample.includes(42.0), true, "42.0"); + assert.sameValue(sample.includes(-0), true, "-0"); + assert.sameValue(sample.includes(true), false, "true"); + assert.sameValue(sample.includes(false), false, "false"); + assert.sameValue(sample.includes(null), false, "null"); + assert.sameValue(sample.includes(""), false, "empty string"); +}); + +testWithSendableTypedArrayConstructors(function(FloatArray) { + var sample = new FloatArray([42, 0, 1, undefined, NaN]); + assert.sameValue(sample.includes(NaN), true, "NaN"); +}, floatArrayConstructors); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js b/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js new file mode 100644 index 00000000000..ed11009c822 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: returns true for found index +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. Let k be n. + 6. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 42, 41]); + assert.sameValue(sample.includes(42), true, "includes(42)"); + assert.sameValue(sample.includes(43), true, "includes(43)"); + assert.sameValue(sample.includes(43, 1), true, "includes(43, 1)"); + assert.sameValue(sample.includes(42, 1), true, "includes(42, 1)"); + assert.sameValue(sample.includes(42, 2), true, "includes(42, 2)"); + + assert.sameValue(sample.includes(42, -4), true, "includes(42, -4)"); + assert.sameValue(sample.includes(42, -3), true, "includes(42, -3)"); + assert.sameValue(sample.includes(42, -2), true, "includes(42, -2)"); + assert.sameValue(sample.includes(42, -5), true, "includes(42, -5)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js new file mode 100644 index 00000000000..10f0507b25e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: returns false if the element is not found +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. Let k be n. + 6. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + 8. Return false. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42, 43, 42, 41]); + assert.sameValue(sample.includes(44), false, "includes(44)"); + assert.sameValue(sample.includes(43, 2), false, "includes(43, 2)"); + assert.sameValue(sample.includes(42, 3), false, "includes(42, 3)"); + assert.sameValue(sample.includes(44, -4), false, "includes(44, -4)"); + assert.sameValue(sample.includes(44, -5), false, "includes(44, -5)"); + assert.sameValue(sample.includes(42, -1), false, "includes(42, -1)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js b/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js new file mode 100644 index 00000000000..b2604e58ec0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Check that search element is not coerced if not an integer +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the same algorithm as Array.prototype.includes as defined in 22.1.3.13 + + 22.1.3.13 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + 8. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(10); + function throwFunc(){ + throw Test262Error() + return 0; + } + + assert.sameValue(sample.includes({valueOf : throwFunc}), false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-object.js new file mode 100644 index 00000000000..5d8d10a64d8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-object.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.14 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var includes = SendableTypedArray.prototype.includes; + +assert.throws(TypeError, function() { + includes.call(undefined, 42); +}, "this is undefined"); + +assert.throws(TypeError, function() { + includes.call(null, 42); +}, "this is null"); + +assert.throws(TypeError, function() { + includes.call(42, 42); +}, "this is 42"); + +assert.throws(TypeError, function() { + includes.call("1", 42); +}, "this is a string"); + +assert.throws(TypeError, function() { + includes.call(true, 42); +}, "this is true"); + +assert.throws(TypeError, function() { + includes.call(false, 42); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + includes.call(s, 42); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..fdc17fd8eac --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.14 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var includes = SendableTypedArray.prototype.includes; + +assert.throws(TypeError, function() { + includes.call({}, 42); +}, "this is an Object"); + +assert.throws(TypeError, function() { + includes.call([], 42); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + includes.call(ab, 42); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + includes.call(dv, 42); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js new file mode 100644 index 00000000000..a0adce1d89b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.includes +description: get the integer value from fromIndex +info: | + 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.includes is a distinct function that implements the + same algorithm as Array.prototype.includes as defined in 22.1.3.11 except that + the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.11 Array.prototype.includes ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + 5. If n ≥ 0, then + a. Let k be n. + ... + 7. Repeat, while k < len + a. Let elementK be the result of ? Get(O, ! ToString(k)). + b. If SameValueZero(searchElement, elementK) is true, return true. + c. Increase k by 1. + 8. Return false. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var obj = { + valueOf: function() { + return 1; + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42, 43]); + assert.sameValue(sample.includes(42, "1"), false, "string [0]"); + assert.sameValue(sample.includes(43, "1"), true, "string [1]"); + + assert.sameValue(sample.includes(42, true), false, "true [0]"); + assert.sameValue(sample.includes(43, true), true, "true [1]"); + + assert.sameValue(sample.includes(42, false), true, "false [0]"); + assert.sameValue(sample.includes(43, false), true, "false [1]"); + + assert.sameValue(sample.includes(42, NaN), true, "NaN [0]"); + assert.sameValue(sample.includes(43, NaN), true, "NaN [1]"); + + assert.sameValue(sample.includes(42, null), true, "null [0]"); + assert.sameValue(sample.includes(43, null), true, "null [1]"); + + assert.sameValue(sample.includes(42, undefined), true, "undefined [0]"); + assert.sameValue(sample.includes(43, undefined), true, "undefined [1]"); + + assert.sameValue(sample.includes(42, null), true, "null [0]"); + assert.sameValue(sample.includes(43, null), true, "null [1]"); + + assert.sameValue(sample.includes(42, obj), false, "object [0]"); + assert.sameValue(sample.includes(43, obj), true, "object [1]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js new file mode 100644 index 00000000000..7cfb35e1c6e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Throws a TypeError if this has a detached buffer +info: | + %SendableTypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.indexOf are the same as for Array.prototype.indexOf as defined in 22.1.3.14. + + When the indexOf method is called with one or two arguments, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If len is 0, return -1F. + Let n be ? ToIntegerOrInfinity(fromIndex). + Assert: If fromIndex is undefined, then n is 0. + If n is +∞, return -1F. + Else if n is -∞, set n to 0. + If n ≥ 0, then + Let k be n. + Else, + Let k be len + n. + If k < 0, set k to 0. + Repeat, while k < len, + Let kPresent be ! HasProperty(O, ! ToString(F(k))). + If kPresent is true, then + Let elementK be ! Get(O, ! ToString(F(k))). + Let same be the result of performing Strict Equality Comparison searchElement === elementK. + If same is true, return F(k). + Set k to k + 1. + Return -1F. + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + const sample = new TA(1); + const fromIndex = { + valueOf() { + $DETACHBUFFER(sample.buffer); + return 0; + } + }; + + assert.sameValue(sample.indexOf(undefined, fromIndex), -1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js new file mode 100644 index 00000000000..05d7df17820 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Throws a TypeError if this has a detached buffer +info: | + %SendableTypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.indexOf are the same as for Array.prototype.indexOf as defined in 22.1.3.14. + + When the indexOf method is called with one or two arguments, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If len is 0, return -1F. + Let n be ? ToIntegerOrInfinity(fromIndex). + Assert: If fromIndex is undefined, then n is 0. + If n is +∞, return -1F. + Else if n is -∞, set n to 0. + If n ≥ 0, then + Let k be n. + Else, + Let k be len + n. + If k < 0, set k to 0. + Repeat, while k < len, + Let kPresent be ! HasProperty(O, ! ToString(F(k))). + If kPresent is true, then + Let elementK be ! Get(O, ! ToString(F(k))). + Let same be the result of performing Strict Equality Comparison searchElement === elementK. + If same is true, return F(k). + Set k to k + 1. + Return -1F. + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + const sample = new TA(1); + const fromIndex = { + valueOf() { + $DETACHBUFFER(sample.buffer); + return 0; + } + }; + + assert.sameValue(sample.indexOf(0n, fromIndex), -1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js new file mode 100644 index 00000000000..b4651067f22 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.indexOf(0n); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js new file mode 100644 index 00000000000..a330a5ae6a3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Return -1 if fromIndex >= ArrayLength +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA(42); + assert.sameValue(sample.indexOf(0n, 42), -1); + assert.sameValue(sample.indexOf(0n, 43), -1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js new file mode 100644 index 00000000000..328d9876a57 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: handle Infinity values for fromIndex +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 6. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be n. + 7. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 8. Repeat, while k < len + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ii. Let same be the result of performing Strict Equality Comparison + searchElement === elementK. + iii. If same is true, return k. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 43n, 41n]); + + assert.sameValue(sample.indexOf(43n, Infinity), -1, "indexOf(43, Infinity)"); + assert.sameValue(sample.indexOf(43n, -Infinity), 1, "indexOf(43, -Infinity)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js new file mode 100644 index 00000000000..59e5f732941 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: -0 fromIndex becomes 0 +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 6. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be n. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42n, 43n]); + assert.sameValue(sample.indexOf(42n, -0), 0, "-0 [0]"); + assert.sameValue(sample.indexOf(43n, -0), 1, "-0 [1]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..0611196ae56 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", {value: 0}); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7n]); + + Object.defineProperty(TA.prototype, "length", {value: 0}); + Object.defineProperty(sample, "length", {value: 0}); + + assert.sameValue(sample.indexOf(7n), 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js new file mode 100644 index 00000000000..b7405d2186e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Returns -1 if length is 0 +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. If len is 0, return -1. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.sameValue(sample.indexOf(0n), -1, "returns -1"); + assert.sameValue( + sample.indexOf(0n, fromIndex), -1, + "length is checked before ToInteger(fromIndex)" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/no-arg.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/no-arg.js new file mode 100644 index 00000000000..994c35bf69d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/no-arg.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: > + If `searchElement` is not supplied, -1 is returned. +info: | + %SendableTypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements + the same algorithm as Array.prototype.indexOf as defined in 22.1.3.14 + except that the this value's [[ArrayLength]] internal slot is accessed + in place of performing a [[Get]] of "length". + + Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + [...] + 10. Return -1. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var ta1 = new TA(); + assert.sameValue(ta1.indexOf(), -1); + + var ta2 = new TA([0n, 1n, 2n]); + assert.sameValue(ta2.indexOf(), -1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..e1a48766331 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.indexOf, + 'function', + 'implements SendableTypedArray.prototype.indexOf' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.indexOf(0n); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.indexOf(0n); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the indexOf operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.indexOf(0n); + throw new Test262Error('indexOf completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js new file mode 100644 index 00000000000..bbe128b6802 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Return abrupt from ToInteger(fromIndex) - using symbol +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var fromIndex = Symbol("1"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(TypeError, function() { + sample.indexOf(7n, fromIndex); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js new file mode 100644 index 00000000000..2160f6e665f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Return abrupt from ToInteger(fromIndex) +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(Test262Error, function() { + sample.indexOf(7n, fromIndex); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js new file mode 100644 index 00000000000..ed86ca48cb0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: returns index for the first found element +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 6. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be n. + 7. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 8. Repeat, while k < len + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ii. Let same be the result of performing Strict Equality Comparison + searchElement === elementK. + iii. If same is true, return k. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 42n, 41n]); + assert.sameValue(sample.indexOf(42n), 0, "indexOf(42)"); + assert.sameValue(sample.indexOf(43n), 1, "indexOf(43)"); + assert.sameValue(sample.indexOf(43n, 1), 1, "indexOf(43, 1)"); + assert.sameValue(sample.indexOf(42n, 1), 2, "indexOf(42, 1)"); + assert.sameValue(sample.indexOf(42n, 2), 2, "indexOf(42, 2)"); + + assert.sameValue(sample.indexOf(42n, -4), 0, "indexOf(42, -4)"); + assert.sameValue(sample.indexOf(42n, -3), 2, "indexOf(42, -3)"); + assert.sameValue(sample.indexOf(42n, -2), 2, "indexOf(42, -2)"); + assert.sameValue(sample.indexOf(42n, -5), 0, "indexOf(42, -5)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js new file mode 100644 index 00000000000..dcf10d88f6b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: returns -1 if the element if not found +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 6. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be n. + 7. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + ... + 9. Return -1. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42n, 43n, 42n, 41n]); + assert.sameValue(sample.indexOf(44n), -1, "indexOf(44)"); + assert.sameValue(sample.indexOf(43n, 2), -1, "indexOf(43, 2)"); + assert.sameValue(sample.indexOf(42n, 3), -1, "indexOf(42, 3)"); + assert.sameValue(sample.indexOf(44n, -4), -1, "indexOf(44, -4)"); + assert.sameValue(sample.indexOf(44n, -5), -1, "indexOf(44, -5)"); + assert.sameValue(sample.indexOf(42n, -1), -1, "indexOf(42, -1)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js new file mode 100644 index 00000000000..96c70fdeda4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Return -1 if fromIndex >= ArrayLength - converted values +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj = { + valueOf: function() { + return 1; + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42n, 43n]); + assert.sameValue(sample.indexOf(42n, "1"), -1, "string [0]"); + assert.sameValue(sample.indexOf(43n, "1"), 1, "string [1]"); + + assert.sameValue(sample.indexOf(42n, true), -1, "true [0]"); + assert.sameValue(sample.indexOf(43n, true), 1, "true [1]"); + + assert.sameValue(sample.indexOf(42n, false), 0, "false [0]"); + assert.sameValue(sample.indexOf(43n, false), 1, "false [1]"); + + assert.sameValue(sample.indexOf(42n, NaN), 0, "NaN [0]"); + assert.sameValue(sample.indexOf(43n, NaN), 1, "NaN [1]"); + + assert.sameValue(sample.indexOf(42n, null), 0, "null [0]"); + assert.sameValue(sample.indexOf(43n, null), 1, "null [1]"); + + assert.sameValue(sample.indexOf(42n, undefined), 0, "undefined [0]"); + assert.sameValue(sample.indexOf(43n, undefined), 1, "undefined [1]"); + + assert.sameValue(sample.indexOf(42n, null), 0, "null [0]"); + assert.sameValue(sample.indexOf(43n, null), 1, "null [1]"); + + assert.sameValue(sample.indexOf(42n, obj), -1, "object [0]"); + assert.sameValue(sample.indexOf(43n, obj), 1, "object [1]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-grow.js b/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-grow.js new file mode 100644 index 00000000000..44c0dae5528 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-grow.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: > + SendableTypedArray.p.indexOf behaves correctly when the backing resizable buffer is + grown during argument coercion. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Growing + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, 1); + } + let evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + let n0 = MayNeedBigInt(lengthTracking, 0); + assert.sameValue(lengthTracking.indexOf(n0), -1); + // The TA grew but we only look at the data until the original length. + assert.sameValue(lengthTracking.indexOf(n0, evil), -1); +} + +// Growing + length-tracking TA, index conversion. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + lengthTracking[0] = MayNeedBigInt(lengthTracking, 1); + let evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return -4; + } + }; + let n1 = MayNeedBigInt(lengthTracking, 1); + assert.sameValue(lengthTracking.indexOf(n1, -4), 0); + // The TA grew but the start index conversion is done based on the original + // length. + assert.sameValue(lengthTracking.indexOf(n1, evil), 0); +} diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-shrink.js b/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-shrink.js new file mode 100644 index 00000000000..1a41a2250f5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-shrink.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: > + SendableTypedArray.p.indexOf behaves correctly when receiver is shrunk + during argument coercion +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Shrinking + fixed-length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + let n0 = MayNeedBigInt(fixedLength, 0); + assert.sameValue(fixedLength.indexOf(n0), 0); + // The TA is OOB so indexOf returns -1. + assert.sameValue(fixedLength.indexOf(n0, evil), -1); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + let n0 = MayNeedBigInt(fixedLength, 0); + assert.sameValue(fixedLength.indexOf(n0), 0); + // The TA is OOB so indexOf returns -1, also for undefined). + assert.sameValue(fixedLength.indexOf(undefined, evil), -1); +} + +// Shrinking + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i); + } + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + let n2 = MayNeedBigInt(lengthTracking, 2); + assert.sameValue(lengthTracking.indexOf(n2), 2); + // 2 no longer found. + assert.sameValue(lengthTracking.indexOf(n2, evil), -1); +} diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js new file mode 100644 index 00000000000..e8cae487be0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Returns -1 if buffer is detached after ValidateSendableTypedArray +info: | + %SendableTypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.indexOf are the same as for Array.prototype.indexOf as defined in 22.1.3.14. + + When the indexOf method is called with one or two arguments, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If len is 0, return -1F. + Let n be ? ToIntegerOrInfinity(fromIndex). + Assert: If fromIndex is undefined, then n is 0. + If n is +∞, return -1F. + Else if n is -∞, set n to 0. + If n ≥ 0, then + Let k be n. + Else, + Let k be len + n. + If k < 0, set k to 0. + Repeat, while k < len, + Let kPresent be ! HasProperty(O, ! ToString(F(k))). + If kPresent is true, then + Let elementK be ! Get(O, ! ToString(F(k))). + Let same be the result of performing Strict Equality Comparison searchElement === elementK. + If same is true, return F(k). + Set k to k + 1. + Return -1F. + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + const sample = new TA(1); + const fromIndex = { + valueOf() { + $DETACHBUFFER(sample.buffer); + return 0; + } + }; + + assert.sameValue(sample.indexOf(undefined, fromIndex), -1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js new file mode 100644 index 00000000000..4dcd64dbb2d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Returns -1 if buffer is detached after ValidateSendableTypedArray +info: | + %SendableTypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.indexOf are the same as for Array.prototype.indexOf as defined in 22.1.3.14. + + When the indexOf method is called with one or two arguments, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If len is 0, return -1F. + Let n be ? ToIntegerOrInfinity(fromIndex). + Assert: If fromIndex is undefined, then n is 0. + If n is +∞, return -1F. + Else if n is -∞, set n to 0. + If n ≥ 0, then + Let k be n. + Else, + Let k be len + n. + If k < 0, set k to 0. + Repeat, while k < len, + Let kPresent be ! HasProperty(O, ! ToString(F(k))). + If kPresent is true, then + Let elementK be ! Get(O, ! ToString(F(k))). + Let same be the result of performing Strict Equality Comparison searchElement === elementK. + If same is true, return F(k). + Set k to k + 1. + Return -1F. + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + const sample = new TA(1); + const fromIndex = { + valueOf() { + $DETACHBUFFER(sample.buffer); + return 0; + } + }; + + assert.sameValue(sample.indexOf(0, fromIndex), -1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js new file mode 100644 index 00000000000..57f4ec5a6c7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.indexOf(0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js new file mode 100644 index 00000000000..17b0d8249f6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Return -1 if fromIndex >= ArrayLength +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA(42); + assert.sameValue(sample.indexOf(0, 42), -1); + assert.sameValue(sample.indexOf(0, 43), -1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js new file mode 100644 index 00000000000..5d9c4b1fd04 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: handle Infinity values for fromIndex +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 6. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be n. + 7. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 8. Repeat, while k < len + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ii. Let same be the result of performing Strict Equality Comparison + searchElement === elementK. + iii. If same is true, return k. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 43, 41]); + + assert.sameValue(sample.indexOf(43, Infinity), -1, "indexOf(43, Infinity)"); + assert.sameValue(sample.indexOf(43, -Infinity), 1, "indexOf(43, -Infinity)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js new file mode 100644 index 00000000000..cb6d86d66ec --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: -0 fromIndex becomes 0 +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 6. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be n. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42, 43]); + assert.sameValue(sample.indexOf(42, -0), 0, "-0 [0]"); + assert.sameValue(sample.indexOf(43, -0), 1, "-0 [1]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..8487b3c2dc8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", {value: 0}); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7]); + + Object.defineProperty(TA.prototype, "length", {value: 0}); + Object.defineProperty(sample, "length", {value: 0}); + + assert.sameValue(sample.indexOf(7), 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-func.js new file mode 100644 index 00000000000..0030e2365db --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-func.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var indexOf = SendableTypedArray.prototype.indexOf; + +assert.sameValue(typeof indexOf, 'function'); + +assert.throws(TypeError, function() { + indexOf(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-method.js new file mode 100644 index 00000000000..35a4331d84e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-method.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.indexOf, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.indexOf(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js new file mode 100644 index 00000000000..633806fa413 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Returns -1 if length is 0 +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. If len is 0, return -1. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.sameValue(sample.indexOf(0), -1, "returns -1"); + assert.sameValue( + sample.indexOf(0, fromIndex), -1, + "length is checked before ToInteger(fromIndex)" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/length.js b/test/sendable/builtins/TypedArray/prototype/indexOf/length.js new file mode 100644 index 00000000000..45be393c678 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: > + %SendableTypedArray%.prototype.indexOf.length is 1. +info: | + %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.indexOf, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/name.js b/test/sendable/builtins/TypedArray/prototype/indexOf/name.js new file mode 100644 index 00000000000..ec50942a0d0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: > + %SendableTypedArray%.prototype.indexOf.name is "indexOf". +info: | + %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.indexOf, "name", { + value: "indexOf", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js b/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js new file mode 100644 index 00000000000..165236be458 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: > + If `searchElement` is not supplied, -1 is returned. +info: | + %SendableTypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements + the same algorithm as Array.prototype.indexOf as defined in 22.1.3.14 + except that the this value's [[ArrayLength]] internal slot is accessed + in place of performing a [[Get]] of "length". + + Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + [...] + 10. Return -1. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var ta1 = new TA(); + assert.sameValue(ta1.indexOf(), -1); + + var ta2 = new TA([0, 1, 2]); + assert.sameValue(ta2.indexOf(), -1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/indexOf/not-a-constructor.js new file mode 100644 index 00000000000..3f3cf08a763 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.indexOf 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.indexOf), + false, + 'isConstructor(SendableTypedArray.prototype.indexOf) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.indexOf(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/indexOf/prop-desc.js new file mode 100644 index 00000000000..de150f2e56d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: > + "indexOf" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'indexOf', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer-special-float-values.js b/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer-special-float-values.js new file mode 100644 index 00000000000..6201b51d69f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer-special-float-values.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: > + SendableTypedArray.p.indexOf behaves correctly for special float values on float + SendableTypedArrays backed by resizable buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer, Array.prototype.includes] +---*/ + +for (let ctor of floatCtors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + lengthTracking[0] = -Infinity; + lengthTracking[1] = -Infinity; + lengthTracking[2] = Infinity; + lengthTracking[3] = Infinity; + lengthTracking[4] = NaN; + lengthTracking[5] = NaN; + assert.sameValue(lengthTracking.indexOf(-Infinity), 0); + assert.sameValue(lengthTracking.indexOf(Infinity), 2); + // NaN is never found. + assert.sameValue(lengthTracking.indexOf(NaN), -1); +} diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer.js new file mode 100644 index 00000000000..89818f6219e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer.js @@ -0,0 +1,149 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: > + SendableTypedArray.p.indexOf behaves correctly on SendableTypedArrays backed by resizable + buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2)); + } + + // Orig. array: [0, 0, 1, 1] + // [0, 0, 1, 1] << fixedLength + // [1, 1] << fixedLengthWithOffset + // [0, 0, 1, 1, ...] << lengthTracking + // [1, 1, ...] << lengthTrackingWithOffset + + // If fixedLength is a BigInt array, they all are BigInt Arrays. + let n0 = MayNeedBigInt(fixedLength, 0); + let n1 = MayNeedBigInt(fixedLength, 1); + + assert.sameValue(fixedLength.indexOf(n0), 0); + assert.sameValue(fixedLength.indexOf(n0, 1), 1); + assert.sameValue(fixedLength.indexOf(n0, 2), -1); + assert.sameValue(fixedLength.indexOf(n0, -2), -1); + assert.sameValue(fixedLength.indexOf(n0, -3), 1); + assert.sameValue(fixedLength.indexOf(n1, 1), 2); + assert.sameValue(fixedLength.indexOf(n1, -3), 2); + assert.sameValue(fixedLength.indexOf(n1, -2), 2); + assert.sameValue(fixedLength.indexOf(undefined), -1); + assert.sameValue(fixedLengthWithOffset.indexOf(n0), -1); + assert.sameValue(fixedLengthWithOffset.indexOf(n1), 0); + assert.sameValue(fixedLengthWithOffset.indexOf(n1, -2), 0); + assert.sameValue(fixedLengthWithOffset.indexOf(n1, -1), 1); + assert.sameValue(fixedLengthWithOffset.indexOf(undefined), -1); + assert.sameValue(lengthTracking.indexOf(n0), 0); + assert.sameValue(lengthTracking.indexOf(n0, 2), -1); + assert.sameValue(lengthTracking.indexOf(n1, -3), 2); + assert.sameValue(lengthTracking.indexOf(undefined), -1); + assert.sameValue(lengthTrackingWithOffset.indexOf(n0), -1); + assert.sameValue(lengthTrackingWithOffset.indexOf(n1), 0); + assert.sameValue(lengthTrackingWithOffset.indexOf(n1, 1), 1); + assert.sameValue(lengthTrackingWithOffset.indexOf(n1, -2), 0); + assert.sameValue(lengthTrackingWithOffset.indexOf(undefined), -1); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 0, 1] + // [0, 0, 1, ...] << lengthTracking + // [1, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + fixedLength.indexOf(n1); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.indexOf(n1); + }); + + assert.sameValue(lengthTracking.indexOf(n1), 2); + assert.sameValue(lengthTracking.indexOf(undefined), -1); + assert.sameValue(lengthTrackingWithOffset.indexOf(n0), -1); + assert.sameValue(lengthTrackingWithOffset.indexOf(n1), 0); + assert.sameValue(lengthTrackingWithOffset.indexOf(undefined), -1); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.indexOf(n0); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.indexOf(n0); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.indexOf(n0); + }); + + assert.sameValue(lengthTracking.indexOf(n0), 0); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.indexOf(n0); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.indexOf(n0); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.indexOf(n0); + }); + + assert.sameValue(lengthTracking.indexOf(n0), -1); + assert.sameValue(lengthTracking.indexOf(undefined), -1); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2)); + } + + // Orig. array: [0, 0, 1, 1, 2, 2] + // [0, 0, 1, 1] << fixedLength + // [1, 1] << fixedLengthWithOffset + // [0, 0, 1, 1, 2, 2, ...] << lengthTracking + // [1, 1, 2, 2, ...] << lengthTrackingWithOffset + + let n2 = MayNeedBigInt(fixedLength, 2); + + assert.sameValue(fixedLength.indexOf(n1), 2); + assert.sameValue(fixedLength.indexOf(n2), -1); + assert.sameValue(fixedLength.indexOf(undefined), -1); + assert.sameValue(fixedLengthWithOffset.indexOf(n0), -1); + assert.sameValue(fixedLengthWithOffset.indexOf(n1), 0); + assert.sameValue(fixedLengthWithOffset.indexOf(n2), -1); + assert.sameValue(fixedLengthWithOffset.indexOf(undefined), -1); + assert.sameValue(lengthTracking.indexOf(n1), 2); + assert.sameValue(lengthTracking.indexOf(n2), 4); + assert.sameValue(lengthTracking.indexOf(undefined), -1); + assert.sameValue(lengthTrackingWithOffset.indexOf(n0), -1); + assert.sameValue(lengthTrackingWithOffset.indexOf(n1), 0); + assert.sameValue(lengthTrackingWithOffset.indexOf(n2), 2); + assert.sameValue(lengthTrackingWithOffset.indexOf(undefined), -1); +} diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..32f5aa2e61d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.indexOf, + 'function', + 'implements SendableTypedArray.prototype.indexOf' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.indexOf(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.indexOf(0); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the indexOf operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.indexOf(0); + throw new Test262Error('indexOf completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js new file mode 100644 index 00000000000..7341b711b21 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Return abrupt from ToInteger(fromIndex) - using symbol +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var fromIndex = Symbol("1"); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(TypeError, function() { + sample.indexOf(7, fromIndex); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js new file mode 100644 index 00000000000..ff8305aa5cc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Return abrupt from ToInteger(fromIndex) +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(Test262Error, function() { + sample.indexOf(7, fromIndex); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js b/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js new file mode 100644 index 00000000000..f062980fa8c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: returns index for the first found element +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 6. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be n. + 7. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + 8. Repeat, while k < len + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ii. Let same be the result of performing Strict Equality Comparison + searchElement === elementK. + iii. If same is true, return k. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 42, 41]); + assert.sameValue(sample.indexOf(42), 0, "indexOf(42)"); + assert.sameValue(sample.indexOf(43), 1, "indexOf(43)"); + assert.sameValue(sample.indexOf(43, 1), 1, "indexOf(43, 1)"); + assert.sameValue(sample.indexOf(42, 1), 2, "indexOf(42, 1)"); + assert.sameValue(sample.indexOf(42, 2), 2, "indexOf(42, 2)"); + + assert.sameValue(sample.indexOf(42, -4), 0, "indexOf(42, -4)"); + assert.sameValue(sample.indexOf(42, -3), 2, "indexOf(42, -3)"); + assert.sameValue(sample.indexOf(42, -2), 2, "indexOf(42, -2)"); + assert.sameValue(sample.indexOf(42, -5), 0, "indexOf(42, -5)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js new file mode 100644 index 00000000000..ee212a0f6e1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: returns -1 if the element if not found +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 6. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be n. + 7. Else n < 0, + a. Let k be len + n. + b. If k < 0, let k be 0. + ... + 9. Return -1. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42, 43, 42, 41]); + assert.sameValue(sample.indexOf(44), -1, "indexOf(44)"); + assert.sameValue(sample.indexOf(43, 2), -1, "indexOf(43, 2)"); + assert.sameValue(sample.indexOf(42, 3), -1, "indexOf(42, 3)"); + assert.sameValue(sample.indexOf(44, -4), -1, "indexOf(44, -4)"); + assert.sameValue(sample.indexOf(44, -5), -1, "indexOf(44, -5)"); + assert.sameValue(sample.indexOf(42, -1), -1, "indexOf(42, -1)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js b/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js new file mode 100644 index 00000000000..a7b9d24ff23 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: search element is compared using strict comparing (===) +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 8. Repeat, while k < len + ... + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ii. Let same be the result of performing Strict Equality Comparison + searchElement === elementK. + iii. If same is true, return k. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 0, 1, undefined, NaN]); + assert.sameValue(sample.indexOf("42"), -1, "'42'"); + assert.sameValue(sample.indexOf([42]), -1, "[42]"); + assert.sameValue(sample.indexOf(42.0), 0, "42.0"); + assert.sameValue(sample.indexOf(-0), 1, "-0"); + assert.sameValue(sample.indexOf(true), -1, "true"); + assert.sameValue(sample.indexOf(false), -1, "false"); + assert.sameValue(sample.indexOf(NaN), -1, "NaN === NaN is false"); + assert.sameValue(sample.indexOf(null), -1, "null"); + assert.sameValue(sample.indexOf(undefined), -1, "undefined"); + assert.sameValue(sample.indexOf(""), -1, "empty string"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-object.js new file mode 100644 index 00000000000..0fabbe89cb9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-object.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var indexOf = SendableTypedArray.prototype.indexOf; + +assert.throws(TypeError, function() { + indexOf.call(undefined, 42); +}, "this is undefined"); + +assert.throws(TypeError, function() { + indexOf.call(null, 42); +}, "this is null"); + +assert.throws(TypeError, function() { + indexOf.call(42, 42); +}, "this is 42"); + +assert.throws(TypeError, function() { + indexOf.call("1", 42); +}, "this is a string"); + +assert.throws(TypeError, function() { + indexOf.call(true, 42); +}, "this is true"); + +assert.throws(TypeError, function() { + indexOf.call(false, 42); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + indexOf.call(s, 42); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..a2ba42b3b58 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var indexOf = SendableTypedArray.prototype.indexOf; + +assert.throws(TypeError, function() { + indexOf.call({}, 42); +}, "this is an Object"); + +assert.throws(TypeError, function() { + indexOf.call([], 42); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + indexOf.call(ab, 42); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + indexOf.call(dv, 42); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js new file mode 100644 index 00000000000..1cdb745f937 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.indexof +description: Return -1 if fromIndex >= ArrayLength - converted values +info: | + 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.indexOf is a distinct function that implements the same + algorithm as Array.prototype.indexOf as defined in 22.1.3.12 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step + produces the value 0.) + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var obj = { + valueOf: function() { + return 1; + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42, 43]); + assert.sameValue(sample.indexOf(42, "1"), -1, "string [0]"); + assert.sameValue(sample.indexOf(43, "1"), 1, "string [1]"); + + assert.sameValue(sample.indexOf(42, true), -1, "true [0]"); + assert.sameValue(sample.indexOf(43, true), 1, "true [1]"); + + assert.sameValue(sample.indexOf(42, false), 0, "false [0]"); + assert.sameValue(sample.indexOf(43, false), 1, "false [1]"); + + assert.sameValue(sample.indexOf(42, NaN), 0, "NaN [0]"); + assert.sameValue(sample.indexOf(43, NaN), 1, "NaN [1]"); + + assert.sameValue(sample.indexOf(42, null), 0, "null [0]"); + assert.sameValue(sample.indexOf(43, null), 1, "null [1]"); + + assert.sameValue(sample.indexOf(42, undefined), 0, "undefined [0]"); + assert.sameValue(sample.indexOf(43, undefined), 1, "undefined [1]"); + + assert.sameValue(sample.indexOf(42, null), 0, "null [0]"); + assert.sameValue(sample.indexOf(43, null), 1, "null [1]"); + + assert.sameValue(sample.indexOf(42, obj), -1, "object [0]"); + assert.sameValue(sample.indexOf(43, obj), 1, "object [1]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js new file mode 100644 index 00000000000..3c82ee013eb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: > + Concatenates the result of toString for each value with custom separator +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + %SendableTypedArray%.prototype.join is a distinct function that implements the same + algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.13 Array.prototype.join (separator) + + ... + 7. If element0 is undefined or null, let R be the empty String; otherwise, let + R be ? ToString(element0). + 8. Let k be 1. + 9. Repeat, while k < len + a. Let S be the String value produced by concatenating R and sep. + b. Let element be ? Get(O, ! ToString(k)). + c. If element is undefined or null, let next be the empty String; otherwise, + let next be ? ToString(element). + d. Let R be a String value produced by concatenating S and next. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1n, 0n, 2n, 3n, 42n, 127n]); + + var result; + + result = sample.join(","); + assert.sameValue(result, "1,0,2,3,42,127"); + + result = sample.join(undefined); + assert.sameValue(result, "1,0,2,3,42,127"); + + result = sample.join(null); + assert.sameValue(result, "1null0null2null3null42null127"); + + result = sample.join(",,"); + assert.sameValue(result, "1,,0,,2,,3,,42,,127"); + + result = sample.join(0); + assert.sameValue(result, "10002030420127"); + + result = sample.join(""); + assert.sameValue(result, "102342127"); + + result = sample.join(" a b c "); + assert.sameValue(result, "1 a b c 0 a b c 2 a b c 3 a b c 42 a b c 127"); + + result = sample.join({}); + assert.sameValue(result, "1[object Object]0[object Object]2[object Object]3[object Object]42[object Object]127"); + + result = sample.join(true); + assert.sameValue(result, "1true0true2true3true42true127"); + + result = sample.join({ toString: function() { return "foo"; }}); + assert.sameValue(result, "1foo0foo2foo3foo42foo127"); + + result = sample.join({ toString: undefined, valueOf: function() { return "bar"; }}); + assert.sameValue(result, "1bar0bar2bar3bar42bar127"); + + result = sample.join(false); + assert.sameValue(result, "1false0false2false3false42false127"); + + result = sample.join(-1); + assert.sameValue(result, "1-10-12-13-142-1127"); + + result = sample.join(-0); + assert.sameValue(result, "10002030420127"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js new file mode 100644 index 00000000000..1d2c98b3860 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Returns single separator if buffer is detached after ValidateSendableTypedArray +info: | + %SendableTypedArray%.prototype.join ( separator ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.join are the same as for Array.prototype.join as defined in 22.1.3.15. + + When the join method is called with one argument separator, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If separator is undefined, let sep be the single-element String ",". + Else, let sep be ? ToString(separator). + Let R be the empty String. + Let k be 0. + Repeat, while k < len, + If k > 0, set R to the string-concatenation of R and sep. + Let element be ! Get(O, ! ToString(𝔽(k))). + If element is undefined or null, let next be the empty String; otherwise, let next be ! ToString(element). + Set R to the string-concatenation of R and next. + Set k to k + 1. + Return R. + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + const sample = new TA([1n,2n,3n]); + const separator = { + toString() { + $DETACHBUFFER(sample.buffer); + return ','; + } + }; + + assert.sameValue(sample.join(separator), ',,'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer.js new file mode 100644 index 00000000000..1018a6dd34b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Throws a TypeError if this has a detached buffer +info: | + %SendableTypedArray%.prototype.join ( separator ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.join are the same as for Array.prototype.join as defined in 22.1.3.15. + + When the join method is called with one argument separator, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + ... + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +let obj = { + toString() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + let sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, () => { + sample.join(obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js new file mode 100644 index 00000000000..8e68d24a9a3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Return the empty String if length is 0 +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + %SendableTypedArray%.prototype.join is a distinct function that implements the same + algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.13 Array.prototype.join (separator) + + ... + 4. Let sep be ? ToString(separator). + 5. If len is zero, return the empty String. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.sameValue(sample.join(), ""); + assert.sameValue(sample.join("test262"), ""); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..b5ce34dd6c5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + %SendableTypedArray%.prototype.join is a distinct function that implements the same + algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.13 Array.prototype.join (separator) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... + 5. If len is zero, return the empty String. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n]); + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + var result = sample.join(); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert.notSameValue(result, "", "result is not affected but custom length 0"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js new file mode 100644 index 00000000000..939303f8115 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Concatenates the result of toString for each simple value +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + %SendableTypedArray%.prototype.join is a distinct function that implements the same + algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.13 Array.prototype.join (separator) + + ... + 7. If element0 is undefined or null, let R be the empty String; otherwise, let + R be ? ToString(element0). + 8. Let k be 1. + 9. Repeat, while k < len + a. Let S be the String value produced by concatenating R and sep. + b. Let element be ? Get(O, ! ToString(k)). + c. If element is undefined or null, let next be the empty String; otherwise, + let next be ? ToString(element). + d. Let R be a String value produced by concatenating S and next. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1n, 0n, 2n, 3n, 42n, 127n]); + + var result = sample.join(); + + assert.sameValue(result, "1,0,2,3,42,127"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js new file mode 100644 index 00000000000..5096dc16c6e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Return abrupt from ToString(Symbol separator) +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + %SendableTypedArray%.prototype.join is a distinct function that implements the same + algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.13 Array.prototype.join (separator) + + ... + 4. Let sep be ? ToString(separator). + 5. If len is zero, return the empty String. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var s = Symbol(""); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.join(s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js new file mode 100644 index 00000000000..16bc41dd79a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Return abrupt from ToString(separator) +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + %SendableTypedArray%.prototype.join is a distinct function that implements the same + algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.13 Array.prototype.join (separator) + + ... + 4. Let sep be ? ToString(separator). + 5. If len is zero, return the empty String. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj = { + toString: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(Test262Error, function() { + sample.join(obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..e104a609469 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.join, + 'function', + 'implements SendableTypedArray.prototype.join' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.join(','); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.join(','); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the join operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.join(','); + throw new Test262Error('join completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-grow.js b/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-grow.js new file mode 100644 index 00000000000..9243b2a965b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-grow.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: > + SendableTypedArray.p.join behaves correctly when the receiver is grown during + argument coercion +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Growing + fixed-length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + toString: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return '.'; + } + }; + assert.sameValue(fixedLength.join(evil), '0.0.0.0'); +} + +// Growing + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + let evil = { + toString: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return '.'; + } + }; + // We iterate 4 elements, since it was the starting length. + assert.sameValue(lengthTracking.join(evil), '0.0.0.0'); +} diff --git a/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-shrink.js b/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-shrink.js new file mode 100644 index 00000000000..2daa9f9bfac --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-shrink.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: > + SendableTypedArray.p.join behaves correctly when the receiver is shrunk during + argument coercion +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Shrinking + fixed-length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + toString: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return '.'; + } + }; + // We iterate 4 elements, since it was the starting length, but the TA is + // OOB right after parameter conversion, so all elements are converted to + // the empty string. + assert.sameValue(fixedLength.join(evil), '...'); +} + +// Shrinking + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + let evil = { + toString: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return '.'; + } + }; + // We iterate 4 elements, since it was the starting length. Elements beyond + // the new length are converted to the empty string. + assert.sameValue(lengthTracking.join(evil), '0.0..'); +} diff --git a/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js new file mode 100644 index 00000000000..1fd649441ce --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: > + Concatenates the result of toString for each value with custom separator +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + %SendableTypedArray%.prototype.join is a distinct function that implements the same + algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.13 Array.prototype.join (separator) + + ... + 7. If element0 is undefined or null, let R be the empty String; otherwise, let + R be ? ToString(element0). + 8. Let k be 1. + 9. Repeat, while k < len + a. Let S be the String value produced by concatenating R and sep. + b. Let element be ? Get(O, ! ToString(k)). + c. If element is undefined or null, let next be the empty String; otherwise, + let next be ? ToString(element). + d. Let R be a String value produced by concatenating S and next. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1, 0, 2, 3, 42, 127]); + + var result; + + result = sample.join(","); + assert.sameValue(result, "1,0,2,3,42,127"); + + result = sample.join(undefined); + assert.sameValue(result, "1,0,2,3,42,127"); + + result = sample.join(null); + assert.sameValue(result, "1null0null2null3null42null127"); + + result = sample.join(",,"); + assert.sameValue(result, "1,,0,,2,,3,,42,,127"); + + result = sample.join(0); + assert.sameValue(result, "10002030420127"); + + result = sample.join(""); + assert.sameValue(result, "102342127"); + + result = sample.join(" a b c "); + assert.sameValue(result, "1 a b c 0 a b c 2 a b c 3 a b c 42 a b c 127"); + + result = sample.join({}); + assert.sameValue(result, "1[object Object]0[object Object]2[object Object]3[object Object]42[object Object]127"); + + result = sample.join(true); + assert.sameValue(result, "1true0true2true3true42true127"); + + result = sample.join({ toString: function() { return "foo"; }}); + assert.sameValue(result, "1foo0foo2foo3foo42foo127"); + + result = sample.join({ toString: undefined, valueOf: function() { return "bar"; }}); + assert.sameValue(result, "1bar0bar2bar3bar42bar127"); + + result = sample.join(false); + assert.sameValue(result, "1false0false2false3false42false127"); + + result = sample.join(-1); + assert.sameValue(result, "1-10-12-13-142-1127"); + + result = sample.join(-0); + assert.sameValue(result, "10002030420127"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js new file mode 100644 index 00000000000..5f9e6265b5d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js @@ -0,0 +1,148 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: > + Concatenates the result of toString for each value with custom separator +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + %SendableTypedArray%.prototype.join is a distinct function that implements the same + algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.13 Array.prototype.join (separator) + + ... + 7. If element0 is undefined or null, let R be the empty String; otherwise, let + R be ? ToString(element0). + 8. Let k be 1. + 9. Repeat, while k < len + a. Let S be the String value produced by concatenating R and sep. + b. Let element be ? Get(O, ! ToString(k)). + c. If element is undefined or null, let next be the empty String; otherwise, + let next be ? ToString(element). + d. Let R be a String value produced by concatenating S and next. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var arr = [-2, Infinity, NaN, -Infinity, 0.6, 9007199254740992]; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(arr); + var result, separator, expected; + + separator = ","; + expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(separator); + result = sample.join(separator); + assert.sameValue(result, expected); + + separator = undefined; + expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(separator); + result = sample.join(separator); + assert.sameValue(result, expected, "using: " + separator); + + separator = null; + expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(separator); + result = sample.join(separator); + assert.sameValue(result, expected, "using: " + separator); + + separator = ",,"; + expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(separator); + result = sample.join(separator); + assert.sameValue(result, expected, "using: " + separator); + + separator = 0; + expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(separator); + result = sample.join(separator); + assert.sameValue(result, expected, "using: " + separator); + + separator = ""; + expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(separator); + result = sample.join(separator); + assert.sameValue(result, expected, "using: " + separator); + + separator = " a b c "; + expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(separator); + result = sample.join(separator); + assert.sameValue(result, expected, "using: " + separator); + + separator = {}; + expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(separator); + result = sample.join(separator); + assert.sameValue(result, expected, "using: " + separator); + + separator = { toString: function() { return "foo"; }}; + expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(separator); + result = sample.join(separator); + assert.sameValue(result, expected, "using: " + separator); + + separator = { toString: undefined, valueOf: function() { return "bar"; }}; + expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(separator); + result = sample.join(separator); + assert.sameValue(result, expected, "using: " + separator); + + separator = true; + expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(separator); + result = sample.join(separator); + assert.sameValue(result, expected, "using: " + separator); + + separator = false; + expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(separator); + result = sample.join(separator); + assert.sameValue(result, expected, "using: " + separator); + + separator = 1; + expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(separator); + result = sample.join(separator); + assert.sameValue(result, expected, "using: " + separator); + + separator = 0; + expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(separator); + result = sample.join(separator); + assert.sameValue(result, expected, "using: " + separator); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js new file mode 100644 index 00000000000..3b6b231fb87 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Returns single separator if buffer is detached after ValidateSendableTypedArray +info: | + %SendableTypedArray%.prototype.join ( separator ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.join are the same as for Array.prototype.join as defined in 22.1.3.15. + + When the join method is called with one argument separator, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If separator is undefined, let sep be the single-element String ",". + Else, let sep be ? ToString(separator). + Let R be the empty String. + Let k be 0. + Repeat, while k < len, + If k > 0, set R to the string-concatenation of R and sep. + Let element be ! Get(O, ! ToString(𝔽(k))). + If element is undefined or null, let next be the empty String; otherwise, let next be ! ToString(element). + Set R to the string-concatenation of R and next. + Set k to k + 1. + Return R. + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + const sample = new TA([1,2,3]); + const separator = { + toString() { + $DETACHBUFFER(sample.buffer); + return ','; + } + }; + + assert.sameValue(sample.join(separator), ',,'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js new file mode 100644 index 00000000000..c51a978b05e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Throws a TypeError if this has a detached buffer +info: | + %SendableTypedArray%.prototype.join ( separator ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.join are the same as for Array.prototype.join as defined in 22.1.3.15. + + When the join method is called with one argument separator, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + ... + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +let obj = { + toString() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + let sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, () => { + sample.join(obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js b/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js new file mode 100644 index 00000000000..8bb52c80205 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Return the empty String if length is 0 +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + %SendableTypedArray%.prototype.join is a distinct function that implements the same + algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.13 Array.prototype.join (separator) + + ... + 4. Let sep be ? ToString(separator). + 5. If len is zero, return the empty String. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.sameValue(sample.join(), ""); + assert.sameValue(sample.join("test262"), ""); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..c0f1dc1078e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + %SendableTypedArray%.prototype.join is a distinct function that implements the same + algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.13 Array.prototype.join (separator) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... + 5. If len is zero, return the empty String. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43]); + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + var result = sample.join(); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert.notSameValue(result, "", "result is not affected but custom length 0"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/join/invoked-as-func.js new file mode 100644 index 00000000000..a43e069d4e0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/invoked-as-func.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.14 %SendableTypedArray%.prototype.join ( separator ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var join = SendableTypedArray.prototype.join; + +assert.sameValue(typeof join, 'function'); + +assert.throws(TypeError, function() { + join(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/join/invoked-as-method.js new file mode 100644 index 00000000000..257e6a1e908 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/invoked-as-method.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.14 %SendableTypedArray%.prototype.join ( separator ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.join, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.join(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/length.js b/test/sendable/builtins/TypedArray/prototype/join/length.js new file mode 100644 index 00000000000..4f851da696f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: > + %SendableTypedArray%.prototype.join.length is 1. +info: | + %SendableTypedArray%.prototype.join ( separator ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.join, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/name.js b/test/sendable/builtins/TypedArray/prototype/join/name.js new file mode 100644 index 00000000000..4ceec17b80c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: > + %SendableTypedArray%.prototype.join.name is "join". +info: | + %SendableTypedArray%.prototype.join ( separator ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.join, "name", { + value: "join", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/join/not-a-constructor.js new file mode 100644 index 00000000000..61b88f4ef3f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.join 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.join), + false, + 'isConstructor(SendableTypedArray.prototype.join) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.join(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/join/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/join/prop-desc.js new file mode 100644 index 00000000000..8daa6292e5f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: > + "join" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'join', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/join/resizable-buffer.js new file mode 100644 index 00000000000..baf541e9b57 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/resizable-buffer.js @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: > + SendableTypedArray.p.join behaves correctly when the receiver is backed by resizable + buffer +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const taWrite = new ctor(rab); + + // Write some data into the array. + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + assert.sameValue(fixedLength.join(), '0,2,4,6'); + assert.sameValue(fixedLengthWithOffset.join(), '4,6'); + assert.sameValue(lengthTracking.join(), '0,2,4,6'); + assert.sameValue(lengthTrackingWithOffset.join(), '4,6'); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + fixedLength.join(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.join(); + }); + + assert.sameValue(lengthTracking.join(), '0,2,4'); + assert.sameValue(lengthTrackingWithOffset.join(), '4'); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.join(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.join(); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.join(); + }); + + assert.sameValue(lengthTracking.join(), '0'); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.join(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.join(); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.join(); + }); + + assert.sameValue(lengthTracking.join(), ''); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert.sameValue(fixedLength.join(), '0,2,4,6'); + assert.sameValue(fixedLengthWithOffset.join(), '4,6'); + assert.sameValue(lengthTracking.join(), '0,2,4,6,8,10'); + assert.sameValue(lengthTrackingWithOffset.join(), '4,6,8,10'); +} diff --git a/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js new file mode 100644 index 00000000000..83095a6eb8c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Concatenates the result of toString for each simple value +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + %SendableTypedArray%.prototype.join is a distinct function that implements the same + algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.13 Array.prototype.join (separator) + + ... + 7. If element0 is undefined or null, let R be the empty String; otherwise, let + R be ? ToString(element0). + 8. Let k be 1. + 9. Repeat, while k < len + a. Let S be the String value produced by concatenating R and sep. + b. Let element be ? Get(O, ! ToString(k)). + c. If element is undefined or null, let next be the empty String; otherwise, + let next be ? ToString(element). + d. Let R be a String value produced by concatenating S and next. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1, 0, 2, 3, 42, 127]); + + var result = sample.join(); + + assert.sameValue(result, "1,0,2,3,42,127"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js new file mode 100644 index 00000000000..681396b6e0c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Concatenates the result of toString for each value +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + %SendableTypedArray%.prototype.join is a distinct function that implements the same + algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.13 Array.prototype.join (separator) + + ... + 7. If element0 is undefined or null, let R be the empty String; otherwise, let + R be ? ToString(element0). + 8. Let k be 1. + 9. Repeat, while k < len + a. Let S be the String value produced by concatenating R and sep. + b. Let element be ? Get(O, ! ToString(k)). + c. If element is undefined or null, let next be the empty String; otherwise, + let next be ? ToString(element). + d. Let R be a String value produced by concatenating S and next. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var arr = [-2, Infinity, NaN, -Infinity, 0.6, 9007199254740992]; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(arr); + + // Use converted values using Array methods as helpers + var expected = arr.map(function(_, i) { + return sample[i].toString(); + }).join(); + + var result = sample.join(); + + assert.sameValue(result, expected); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js new file mode 100644 index 00000000000..29ff4bcc558 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Return abrupt from ToString(Symbol separator) +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + %SendableTypedArray%.prototype.join is a distinct function that implements the same + algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.13 Array.prototype.join (separator) + + ... + 4. Let sep be ? ToString(separator). + 5. If len is zero, return the empty String. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var s = Symbol(""); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.join(s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js new file mode 100644 index 00000000000..1eecd03ab3b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Return abrupt from ToString(separator) +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + %SendableTypedArray%.prototype.join is a distinct function that implements the same + algorithm as Array.prototype.join as defined in 22.1.3.13 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.13 Array.prototype.join (separator) + + ... + 4. Let sep be ? ToString(separator). + 5. If len is zero, return the empty String. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var obj = { + toString: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(Test262Error, function() { + sample.join(obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..b8f158e73be --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.join, + 'function', + 'implements SendableTypedArray.prototype.join' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.join(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.join(0); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the join operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.join(0); + throw new Test262Error('join completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/join/separator-tostring-once-after-resized.js b/test/sendable/builtins/TypedArray/prototype/join/separator-tostring-once-after-resized.js new file mode 100644 index 00000000000..db9f6f05804 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/separator-tostring-once-after-resized.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: > + ToString is called once when the array is resized. +info: | + %SendableTypedArray%.prototype.join ( separator ) + + ... + 2. Let taRecord be ? ValidateSendableTypedArray(O, seq-cst). + 3. Let len be SendableTypedArrayLength(taRecord). + ... + 5. Else, let sep be ? ToString(separator). + ... + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let ta = new Int8Array(rab); + +let callCount = 0; + +let index = { + toString() { + callCount++; + rab.resize(0); + return "-"; + } +}; + +assert.sameValue(callCount, 0); + +let r = ta.join(index); + +assert.sameValue(callCount, 1); +assert.sameValue(r, "--"); diff --git a/test/sendable/builtins/TypedArray/prototype/join/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/join/this-is-not-object.js new file mode 100644 index 00000000000..d445912a0f8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/this-is-not-object.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var join = SendableTypedArray.prototype.join; + +assert.throws(TypeError, function() { + join.call(undefined, ""); +}, "this is undefined"); + +assert.throws(TypeError, function() { + join.call(null, ""); +}, "this is null"); + +assert.throws(TypeError, function() { + join.call(42, ""); +}, "this is 42"); + +assert.throws(TypeError, function() { + join.call("1", ""); +}, "this is a string"); + +assert.throws(TypeError, function() { + join.call(true, ""); +}, "this is true"); + +assert.throws(TypeError, function() { + join.call(false, ""); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + join.call(s, ""); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..c044bfb3aae --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.join +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var join = SendableTypedArray.prototype.join; + +assert.throws(TypeError, function() { + join.call({}, ""); +}, "this is an Object"); + +assert.throws(TypeError, function() { + join.call([], ""); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + join.call(ab, ""); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + join.call(dv, ""); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/detached-buffer.js new file mode 100644 index 00000000000..b3de4b3069e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/detached-buffer.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.16 %SendableTypedArray%.prototype.keys ( ) + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.keys(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/iter-prototype.js new file mode 100644 index 00000000000..01281583456 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/iter-prototype.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: > + The prototype of the returned iterator is ArrayIteratorPrototype +info: | + 22.2.3.16 %SendableTypedArray%.prototype.keys ( ) + + ... + 3. Return CreateArrayIterator(O, "key"). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.iterator, TypedArray] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([0n, 42n, 64n]); + var iter = sample.keys(); + + assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..34945718b04 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.keys, + 'function', + 'implements SendableTypedArray.prototype.keys' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.keys(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.keys(); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the keys operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.keys(); + throw new Test262Error('keys completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-itor.js b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-itor.js new file mode 100644 index 00000000000..acaf48dcdb4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-itor.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: Return an iterator for the keys. +info: | + 22.2.3.16 %SendableTypedArray%.prototype.keys ( ) + + ... + 3. Return CreateArrayIterator(O, "key"). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var sample = [0n, 42n, 64n]; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var typedArray = new TA(sample); + var itor = typedArray.keys(); + + var next = itor.next(); + assert.sameValue(next.value, 0); + assert.sameValue(next.done, false); + + next = itor.next(); + assert.sameValue(next.value, 1); + assert.sameValue(next.done, false); + + next = itor.next(); + assert.sameValue(next.value, 2); + assert.sameValue(next.done, false); + + next = itor.next(); + assert.sameValue(next.value, undefined); + assert.sameValue(next.done, true); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js new file mode 100644 index 00000000000..64cc926873d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.16 %SendableTypedArray%.prototype.keys ( ) + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.keys(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-func.js new file mode 100644 index 00000000000..b38c7b47e09 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-func.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.15 %SendableTypedArray%.prototype.keys ( ) + + 1. Let O be the this value. + 2. Let valid be ValidateSendableTypedArray(O). + 3. ReturnIfAbrupt(valid). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var keys = SendableTypedArray.prototype.keys; + +assert.sameValue(typeof keys, 'function'); + +assert.throws(TypeError, function() { + keys(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-method.js new file mode 100644 index 00000000000..1096a00773d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-method.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.15 %SendableTypedArray%.prototype.keys ( ) + + 1. Let O be the this value. + 2. Let valid be ValidateSendableTypedArray(O). + 3. ReturnIfAbrupt(valid). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.keys, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.keys(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js new file mode 100644 index 00000000000..061b0cdc327 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: > + The prototype of the returned iterator is ArrayIteratorPrototype +info: | + 22.2.3.16 %SendableTypedArray%.prototype.keys ( ) + + ... + 3. Return CreateArrayIterator(O, "key"). +includes: [testTypedArray.js] +features: [Symbol.iterator, TypedArray] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([0, 42, 64]); + var iter = sample.keys(); + + assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/length.js b/test/sendable/builtins/TypedArray/prototype/keys/length.js new file mode 100644 index 00000000000..2888ee4af6f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: > + %SendableTypedArray%.prototype.keys.length is 0. +info: | + %SendableTypedArray%.prototype.keys ( ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.keys, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/name.js b/test/sendable/builtins/TypedArray/prototype/keys/name.js new file mode 100644 index 00000000000..07c2a8dbce1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: > + %SendableTypedArray%.prototype.keys.name is "keys". +info: | + %SendableTypedArray%.prototype.keys ( ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.keys, "name", { + value: "keys", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/keys/not-a-constructor.js new file mode 100644 index 00000000000..1b48fa86650 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.keys 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.keys), + false, + 'isConstructor(SendableTypedArray.prototype.keys) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.keys(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/keys/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/keys/prop-desc.js new file mode 100644 index 00000000000..6386ac813c1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: > + "keys" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'keys', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..0cc6e35d0a1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: > + SendableTypedArray.p.keys behaves correctly when receiver is backed by a resizable + buffer and is grown mid-iteration +features: [resizable-arraybuffer] +includes: [compareArray.js, resizableArrayBufferUtils.js] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + // The fixed length array is not affected by resizing. + TestIterationAndResize(fixedLength.keys(), [ + 0, + 1, + 2, + 3 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + // The fixed length array is not affected by resizing. + TestIterationAndResize(fixedLengthWithOffset.keys(), [ + 0, + 1 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + TestIterationAndResize(lengthTracking.keys(), [ + 0, + 1, + 2, + 3, + 4, + 5 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + TestIterationAndResize(lengthTrackingWithOffset.keys(), [ + 0, + 1, + 2, + 3 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..bcd5e20e6b4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: > + SendableTypedArray.p.keys behaves correctly when receiver is backed by resizable + buffer that is shrunk mid-iteration +features: [resizable-arraybuffer] +includes: [compareArray.js, resizableArrayBufferUtils.js] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + + // The fixed length array goes out of bounds when the RAB is resized. + assert.throws(TypeError, () => { + TestIterationAndResize(fixedLength.keys(), null, rab, 2, 3 * ctor.BYTES_PER_ELEMENT); + }); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + + // The fixed length array goes out of bounds when the RAB is resized. + assert.throws(TypeError, () => { + TestIterationAndResize(fixedLengthWithOffset.keys(), null, rab, 2, 3 * ctor.BYTES_PER_ELEMENT); + }); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + TestIterationAndResize(lengthTracking.keys(), [ + 0, + 1, + 2 + ], rab, 2, 3 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + TestIterationAndResize(lengthTrackingWithOffset.keys(), [ + 0, + 1 + ], rab, 2, 3 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer.js new file mode 100644 index 00000000000..1f04eee0b6a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer.js @@ -0,0 +1,153 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: > + SendableTypedArray.p.keys behaves correctly when receiver is backed by resizable + buffer +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + assert.compareArray(Array.from(fixedLength.keys()), [ + 0, + 1, + 2, + 3 + ]); + assert.compareArray(Array.from(fixedLengthWithOffset.keys()), [ + 0, + 1 + ]); + assert.compareArray(Array.from(lengthTracking.keys()), [ + 0, + 1, + 2, + 3 + ]); + assert.compareArray(Array.from(lengthTrackingWithOffset.keys()), [ + 0, + 1 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + // SendableTypedArray.prototype.{entries, keys, values} throw right away when + // called. Array.prototype.{entries, keys, values} don't throw, but when + // we try to iterate the returned ArrayIterator, that throws. + assert.throws(TypeError, () => { + fixedLength.keys(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.keys(); + }); + + assert.compareArray(Array.from(lengthTracking.keys()), [ + 0, + 1, + 2 + ]); + assert.compareArray(Array.from(lengthTrackingWithOffset.keys()), [0]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.keys(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.keys(); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.keys(); + }); + + assert.compareArray(Array.from(lengthTracking.keys()), [0]); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.keys(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.keys(); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.keys(); + }); + + assert.compareArray(Array.from(lengthTracking.keys()), []); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert.compareArray(Array.from(fixedLength.keys()), [ + 0, + 1, + 2, + 3 + ]); + assert.compareArray(Array.from(fixedLengthWithOffset.keys()), [ + 0, + 1 + ]); + assert.compareArray(Array.from(lengthTracking.keys()), [ + 0, + 1, + 2, + 3, + 4, + 5 + ]); + assert.compareArray(Array.from(lengthTrackingWithOffset.keys()), [ + 0, + 1, + 2, + 3 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..88710e769cc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.keys, + 'function', + 'implements SendableTypedArray.prototype.keys' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.keys(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.keys(); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the keys operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.keys(); + throw new Test262Error('keys completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js b/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js new file mode 100644 index 00000000000..06d1b17a233 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: Return an iterator for the keys. +info: | + 22.2.3.16 %SendableTypedArray%.prototype.keys ( ) + + ... + 3. Return CreateArrayIterator(O, "key"). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var sample = [0, 42, 64]; + +testWithSendableTypedArrayConstructors(function(TA) { + var typedArray = new TA(sample); + var itor = typedArray.keys(); + + var next = itor.next(); + assert.sameValue(next.value, 0); + assert.sameValue(next.done, false); + + next = itor.next(); + assert.sameValue(next.value, 1); + assert.sameValue(next.done, false); + + next = itor.next(); + assert.sameValue(next.value, 2); + assert.sameValue(next.done, false); + + next = itor.next(); + assert.sameValue(next.value, undefined); + assert.sameValue(next.done, true); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-object.js new file mode 100644 index 00000000000..ef48555e15b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-object.js @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.16 %SendableTypedArray%.prototype.keys ( ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var keys = SendableTypedArray.prototype.keys; + +assert.throws(TypeError, function() { + keys.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + keys.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + keys.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + keys.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + keys.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + keys.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + keys.call(s); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..05e482325ed --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.keys +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.16 %SendableTypedArray%.prototype.keys ( ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var keys = SendableTypedArray.prototype.keys; + +assert.throws(TypeError, function() { + keys.call({}); +}, "this is an Object"); + +assert.throws(TypeError, function() { + keys.call([]); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + keys.call(ab); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + keys.call(dv); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js new file mode 100644 index 00000000000..5151147472a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Returns -1 if buffer is detached after ValidateSendableTypedArray +info: | + %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.lastIndexOf are the same as for Array.prototype.lastIndexOf as defined in 22.1.3.17. + + When the lastIndexOf method is called with one or two arguments, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If len is 0, return -1F. + If fromIndex is present, let n be ? ToIntegerOrInfinity(fromIndex); else let n be len - 1. + If n is -∞, return -1F. + If n ≥ 0, then + Let k be min(n, len - 1). + Else, + Let k be len + n. + Repeat, while k ≥ 0, + Let kPresent be ! HasProperty(O, ! ToString(F(k))). + If kPresent is true, then + Let elementK be ! Get(O, ! ToString(F(k))). + Let same be the result of performing Strict Equality Comparison searchElement === elementK. + If same is true, return F(k). + Set k to k - 1. + Return -1F. + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + const sample = new TA(1); + const fromIndex = { + valueOf() { + $DETACHBUFFER(sample.buffer); + return 0; + } + }; + + assert.sameValue(sample.lastIndexOf(undefined, fromIndex), -1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js new file mode 100644 index 00000000000..16680ecd3b0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Returns -1 if buffer is detached after ValidateSendableTypedArray +info: | + %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.lastIndexOf are the same as for Array.prototype.lastIndexOf as defined in 22.1.3.17. + + When the lastIndexOf method is called with one or two arguments, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If len is 0, return -1F. + If fromIndex is present, let n be ? ToIntegerOrInfinity(fromIndex); else let n be len - 1. + If n is -∞, return -1F. + If n ≥ 0, then + Let k be min(n, len - 1). + Else, + Let k be len + n. + Repeat, while k ≥ 0, + Let kPresent be ! HasProperty(O, ! ToString(F(k))). + If kPresent is true, then + Let elementK be ! Get(O, ! ToString(F(k))). + Let same be the result of performing Strict Equality Comparison searchElement === elementK. + If same is true, return F(k). + Set k to k - 1. + Return -1F. + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + const sample = new TA(1); + const fromIndex = { + valueOf() { + $DETACHBUFFER(sample.buffer); + return 0; + } + }; + + assert.sameValue(sample.lastIndexOf(0n, fromIndex), -1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js new file mode 100644 index 00000000000..0fdfdf0fec8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.lastIndexOf(0n); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js new file mode 100644 index 00000000000..997a423b429 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: handle Infinity values for fromIndex +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be min(n, len - 1). + 6. Else n < 0, + a. Let k be len + n. + 7. Repeat, while k ≥ 0 + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 43n, 41n]); + + assert.sameValue(sample.lastIndexOf(43n, Infinity), 2, "lastIndexOf(43, Infinity)"); + assert.sameValue(sample.lastIndexOf(43n, -Infinity), -1, "lastIndexOf(43, -Infinity)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js new file mode 100644 index 00000000000..ea5b2a3da8a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: -0 fromIndex becomes 0 +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be min(n, len - 1). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42n, 43n]); + assert.sameValue(sample.lastIndexOf(42n, -0), 0, "-0 [0]"); + assert.sameValue(sample.lastIndexOf(43n, -0), -1, "-0 [1]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..146b18adb06 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", {value: 0}); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7n]); + + Object.defineProperty(TA.prototype, "length", {value: 0}); + Object.defineProperty(sample, "length", {value: 0}); + + assert.sameValue(sample.lastIndexOf(7n), 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js new file mode 100644 index 00000000000..4629bb26ad5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Returns -1 if length is 0 +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. If len is 0, return -1. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.sameValue(sample.lastIndexOf(0), -1, "returns -1"); + assert.sameValue( + sample.lastIndexOf(0n, fromIndex), -1, + "length is checked before ToInteger(fromIndex)" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js new file mode 100644 index 00000000000..365024746e7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: > + If `searchElement` is not supplied, -1 is returned. +info: | + %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements + the same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.17 + except that the this value's [[ArrayLength]] internal slot is accessed + in place of performing a [[Get]] of "length". + + Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + [...] + 8. Return -1. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var ta1 = new TA(); + assert.sameValue(ta1.lastIndexOf(), -1); + + var ta2 = new TA([0n, 1n, 2n]); + assert.sameValue(ta2.lastIndexOf(), -1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..57ec0d89e4a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.lastIndexOf, + 'function', + 'implements SendableTypedArray.prototype.lastIndexOf' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.lastIndexOf(0n); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.lastIndexOf(0n); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the lastIndexOf operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.lastIndexOf(0n); + throw new Test262Error('lastIndexOf completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js new file mode 100644 index 00000000000..902a4275962 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Return abrupt from ToInteger(fromIndex) - using symbol +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let + n be len-1. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var fromIndex = Symbol("1"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(TypeError, function() { + sample.lastIndexOf(7n, fromIndex); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js new file mode 100644 index 00000000000..37a4fa62415 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Return abrupt from ToInteger(fromIndex) +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let + n be len-1. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(Test262Error, function() { + sample.lastIndexOf(7n, fromIndex); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js new file mode 100644 index 00000000000..3ab67a86557 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: returns index for the first found element +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be min(n, len - 1). + 6. Else n < 0, + a. Let k be len + n. + 7. Repeat, while k ≥ 0 + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ii. Let same be the result of performing Strict Equality Comparison + searchElement === elementK. + iii. If same is true, return k. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 42n, 41n]); + assert.sameValue(sample.lastIndexOf(42n), 2, "lastIndexOf(42)"); + assert.sameValue(sample.lastIndexOf(43n), 1, "lastIndexOf(43)"); + assert.sameValue(sample.lastIndexOf(41n), 3, "lastIndexOf(41)"); + assert.sameValue(sample.lastIndexOf(41n, 3), 3, "lastIndexOf(41, 3)"); + assert.sameValue(sample.lastIndexOf(41n, 4), 3, "lastIndexOf(41, 4)"); + assert.sameValue(sample.lastIndexOf(43n, 1), 1, "lastIndexOf(43, 1)"); + assert.sameValue(sample.lastIndexOf(43n, 2), 1, "lastIndexOf(43, 2)"); + assert.sameValue(sample.lastIndexOf(43n, 3), 1, "lastIndexOf(43, 3)"); + assert.sameValue(sample.lastIndexOf(43n, 4), 1, "lastIndexOf(43, 4)"); + assert.sameValue(sample.lastIndexOf(42n, 0), 0, "lastIndexOf(42, 0)"); + assert.sameValue(sample.lastIndexOf(42n, 1), 0, "lastIndexOf(42, 1)"); + assert.sameValue(sample.lastIndexOf(42n, 2), 2, "lastIndexOf(42, 2)"); + assert.sameValue(sample.lastIndexOf(42n, 3), 2, "lastIndexOf(42, 3)"); + assert.sameValue(sample.lastIndexOf(42n, 4), 2, "lastIndexOf(42, 4)"); + assert.sameValue(sample.lastIndexOf(42n, -4), 0, "lastIndexOf(42, -4)"); + assert.sameValue(sample.lastIndexOf(42n, -3), 0, "lastIndexOf(42, -3)"); + assert.sameValue(sample.lastIndexOf(42n, -2), 2, "lastIndexOf(42, -2)"); + assert.sameValue(sample.lastIndexOf(42n, -1), 2, "lastIndexOf(42, -1)"); + assert.sameValue(sample.lastIndexOf(43n, -3), 1, "lastIndexOf(43, -3)"); + assert.sameValue(sample.lastIndexOf(43n, -2), 1, "lastIndexOf(43, -2)"); + assert.sameValue(sample.lastIndexOf(43n, -1), 1, "lastIndexOf(43, -1)"); + assert.sameValue(sample.lastIndexOf(41n, -1), 3, "lastIndexOf(41, -1)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js new file mode 100644 index 00000000000..f91a2758ee7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: returns -1 if the element if not found +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be min(n, len - 1). + 6. Else n < 0, + a. Let k be len + n. + 7. Repeat, while k ≥ 0 + ... + 8. Return -1. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42n, 43n, 42n, 41n]); + assert.sameValue(sample.lastIndexOf(44n), -1, "lastIndexOf(44)"); + assert.sameValue(sample.lastIndexOf(44n, -4), -1, "lastIndexOf(44, -4)"); + assert.sameValue(sample.lastIndexOf(44n, -5), -1, "lastIndexOf(44, -5)"); + assert.sameValue(sample.lastIndexOf(42n, -5), -1, "lastIndexOf(42, -5)"); + assert.sameValue(sample.lastIndexOf(43n, -4), -1, "lastIndexOf(43, -4)"); + assert.sameValue(sample.lastIndexOf(43n, -5), -1, "lastIndexOf(43, -5)"); + assert.sameValue(sample.lastIndexOf(41n, 0), -1, "lastIndexOf(41, 0)"); + assert.sameValue(sample.lastIndexOf(41n, 1), -1, "lastIndexOf(41, 1)"); + assert.sameValue(sample.lastIndexOf(41n, 2), -1, "lastIndexOf(41, 2)"); + assert.sameValue(sample.lastIndexOf(43n, 0), -1, "lastIndexOf(43, 0)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js new file mode 100644 index 00000000000..f1f380e8afa --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Return -1 if fromIndex >= ArrayLength - converted values +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let + n be len-1. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj = { + valueOf: function() { + return 1; + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42n, 43n]); + assert.sameValue(sample.lastIndexOf(42n, "1"), 0, "string [0]"); + assert.sameValue(sample.lastIndexOf(43n, "1"), 1, "string [1]"); + + assert.sameValue(sample.lastIndexOf(42n, true), 0, "true [0]"); + assert.sameValue(sample.lastIndexOf(43n, true), 1, "true [1]"); + + assert.sameValue(sample.lastIndexOf(42n, false), 0, "false [0]"); + assert.sameValue(sample.lastIndexOf(43n, false), -1, "false [1]"); + + assert.sameValue(sample.lastIndexOf(42n, NaN), 0, "NaN [0]"); + assert.sameValue(sample.lastIndexOf(43n, NaN), -1, "NaN [1]"); + + assert.sameValue(sample.lastIndexOf(42n, null), 0, "null [0]"); + assert.sameValue(sample.lastIndexOf(43n, null), -1, "null [1]"); + + assert.sameValue(sample.lastIndexOf(42n, undefined), 0, "undefined [0]"); + assert.sameValue(sample.lastIndexOf(43n, undefined), -1, "undefined [1]"); + + assert.sameValue(sample.lastIndexOf(42n, null), 0, "null [0]"); + assert.sameValue(sample.lastIndexOf(43n, null), -1, "null [1]"); + + assert.sameValue(sample.lastIndexOf(42n, obj), 0, "object [0]"); + assert.sameValue(sample.lastIndexOf(43n, obj), 1, "object [1]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-grow.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-grow.js new file mode 100644 index 00000000000..f46e7f5641c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-grow.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: > + SendableTypedArray.p.lastIndexOf behaves correctly on SendableTypedArrays backed by resizable + buffers that are grown by argument coercion. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Growing + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, 1); + } + let evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return -1; + } + }; + let n0 = MayNeedBigInt(lengthTracking, 0); + assert.sameValue(lengthTracking.lastIndexOf(n0), -1); + // Because lastIndexOf iterates from the given index downwards, it's not + // possible to test that "we only look at the data until the original + // length" without also testing that the index conversion happening with the + // original length. + assert.sameValue(lengthTracking.lastIndexOf(n0, evil), -1); +} + +// Growing + length-tracking TA, index conversion. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + let evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return -4; + } + }; + let n0 = MayNeedBigInt(lengthTracking, 0); + assert.sameValue(lengthTracking.lastIndexOf(n0, -4), 0); + // The TA grew but the start index conversion is done based on the original + // length. + assert.sameValue(lengthTracking.lastIndexOf(n0, evil), 0); +} diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-shrink.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-shrink.js new file mode 100644 index 00000000000..ce8c2d8a059 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-shrink.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: > + SendableTypedArray.p.lastIndexOf behaves correctly on SendableTypedArrays backed by resizable + buffers that are shrunk by argument coercion. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Shrinking + fixed-length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 2; + } + }; + let n0 = MayNeedBigInt(fixedLength, 0); + assert.sameValue(fixedLength.lastIndexOf(n0), 3); + // The TA is OOB so lastIndexOf returns -1. + assert.sameValue(fixedLength.lastIndexOf(n0, evil), -1); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 2; + } + }; + let n0 = MayNeedBigInt(fixedLength, 0); + assert.sameValue(fixedLength.lastIndexOf(n0), 3); + // The TA is OOB so lastIndexOf returns -1, also for undefined). + assert.sameValue(fixedLength.lastIndexOf(undefined, evil), -1); +} + +// Shrinking + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i); + } + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 2; + } + }; + let n2 = MayNeedBigInt(lengthTracking, 2); + assert.sameValue(lengthTracking.lastIndexOf(n2), 2); + // 2 no longer found. + assert.sameValue(lengthTracking.lastIndexOf(n2, evil), -1); +} diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js new file mode 100644 index 00000000000..035115a672f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Returns -1 if buffer is detached after ValidateSendableTypedArray +info: | + %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.lastIndexOf are the same as for Array.prototype.lastIndexOf as defined in 22.1.3.17. + + When the lastIndexOf method is called with one or two arguments, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If len is 0, return -1F. + If fromIndex is present, let n be ? ToIntegerOrInfinity(fromIndex); else let n be len - 1. + If n is -∞, return -1F. + If n ≥ 0, then + Let k be min(n, len - 1). + Else, + Let k be len + n. + Repeat, while k ≥ 0, + Let kPresent be ! HasProperty(O, ! ToString(F(k))). + If kPresent is true, then + Let elementK be ! Get(O, ! ToString(F(k))). + Let same be the result of performing Strict Equality Comparison searchElement === elementK. + If same is true, return F(k). + Set k to k - 1. + Return -1F. + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + const sample = new TA(1); + const fromIndex = { + valueOf() { + $DETACHBUFFER(sample.buffer); + return 0; + } + }; + + assert.sameValue(sample.lastIndexOf(undefined, fromIndex), -1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js new file mode 100644 index 00000000000..7c80b675362 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Returns -1 if buffer is detached after ValidateSendableTypedArray +info: | + %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + The interpretation and use of the arguments of %SendableTypedArray%.prototype.lastIndexOf are the same as for Array.prototype.lastIndexOf as defined in 22.1.3.17. + + When the lastIndexOf method is called with one or two arguments, the following steps are taken: + + Let O be the this value. + Perform ? ValidateSendableTypedArray(O). + Let len be O.[[ArrayLength]]. + If len is 0, return -1F. + If fromIndex is present, let n be ? ToIntegerOrInfinity(fromIndex); else let n be len - 1. + If n is -∞, return -1F. + If n ≥ 0, then + Let k be min(n, len - 1). + Else, + Let k be len + n. + Repeat, while k ≥ 0, + Let kPresent be ! HasProperty(O, ! ToString(F(k))). + If kPresent is true, then + Let elementK be ! Get(O, ! ToString(F(k))). + Let same be the result of performing Strict Equality Comparison searchElement === elementK. + If same is true, return F(k). + Set k to k - 1. + Return -1F. + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + const sample = new TA(1); + const fromIndex = { + valueOf() { + $DETACHBUFFER(sample.buffer); + return 0; + } + }; + + assert.sameValue(sample.lastIndexOf(0, fromIndex), -1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js new file mode 100644 index 00000000000..ad898b42630 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.lastIndexOf(0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js new file mode 100644 index 00000000000..2600d39a8b2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: handle Infinity values for fromIndex +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be min(n, len - 1). + 6. Else n < 0, + a. Let k be len + n. + 7. Repeat, while k ≥ 0 + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 43, 41]); + + assert.sameValue(sample.lastIndexOf(43, Infinity), 2, "lastIndexOf(43, Infinity)"); + assert.sameValue(sample.lastIndexOf(43, -Infinity), -1, "lastIndexOf(43, -Infinity)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js new file mode 100644 index 00000000000..f2b872503cf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: -0 fromIndex becomes 0 +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be min(n, len - 1). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42, 43]); + assert.sameValue(sample.lastIndexOf(42, -0), 0, "-0 [0]"); + assert.sameValue(sample.lastIndexOf(43, -0), -1, "-0 [1]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..a747895e8b1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +Object.defineProperty(SendableTypedArray.prototype, "length", {value: 0}); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7]); + + Object.defineProperty(TA.prototype, "length", {value: 0}); + Object.defineProperty(sample, "length", {value: 0}); + + assert.sameValue(sample.lastIndexOf(7), 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-func.js new file mode 100644 index 00000000000..e6772141784 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-func.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.16 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var lastIndexOf = SendableTypedArray.prototype.lastIndexOf; + +assert.sameValue(typeof lastIndexOf, 'function'); + +assert.throws(TypeError, function() { + lastIndexOf(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-method.js new file mode 100644 index 00000000000..bdf53f63d0b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-method.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.16 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.lastIndexOf, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.lastIndexOf(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js new file mode 100644 index 00000000000..01588052789 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Returns -1 if length is 0 +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. If len is 0, return -1. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.sameValue(sample.lastIndexOf(0), -1, "returns -1"); + assert.sameValue( + sample.lastIndexOf(0, fromIndex), -1, + "length is checked before ToInteger(fromIndex)" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length.js new file mode 100644 index 00000000000..f6ea5ac88af --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: > + %SendableTypedArray%.prototype.lastIndexOf.length is 1. +info: | + %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.lastIndexOf, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/name.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/name.js new file mode 100644 index 00000000000..d7ffda153d1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: > + %SendableTypedArray%.prototype.lastIndexOf.name is "lastIndexOf". +info: | + %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.lastIndexOf, "name", { + value: "lastIndexOf", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js new file mode 100644 index 00000000000..4f60232f5f6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: > + If `searchElement` is not supplied, -1 is returned. +info: | + %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements + the same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.17 + except that the this value's [[ArrayLength]] internal slot is accessed + in place of performing a [[Get]] of "length". + + Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + [...] + 8. Return -1. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var ta1 = new TA(); + assert.sameValue(ta1.lastIndexOf(), -1); + + var ta2 = new TA([0, 1, 2]); + assert.sameValue(ta2.lastIndexOf(), -1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/not-a-constructor.js new file mode 100644 index 00000000000..ed0ccf1255d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.lastIndexOf 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.lastIndexOf), + false, + 'isConstructor(SendableTypedArray.prototype.lastIndexOf) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.lastIndexOf(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/prop-desc.js new file mode 100644 index 00000000000..0284d6e7c45 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: > + "lastIndexOf" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'lastIndexOf', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer-special-float-values.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer-special-float-values.js new file mode 100644 index 00000000000..41d3ec2ee47 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer-special-float-values.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: > + SendableTypedArray.p.lastIndexOf behaves correctly for special float values on float + SendableTypedArrays backed by resizable buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer, Array.prototype.includes] +---*/ + +for (let ctor of floatCtors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + lengthTracking[0] = -Infinity; + lengthTracking[1] = -Infinity; + lengthTracking[2] = Infinity; + lengthTracking[3] = Infinity; + lengthTracking[4] = NaN; + lengthTracking[5] = NaN; + assert.sameValue(lengthTracking.lastIndexOf(-Infinity), 1); + assert.sameValue(lengthTracking.lastIndexOf(Infinity), 3); + // NaN is never found. + assert.sameValue(lengthTracking.lastIndexOf(NaN), -1); +} diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer.js new file mode 100644 index 00000000000..abe12a2cc55 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer.js @@ -0,0 +1,153 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: > + SendableTypedArray.p.lastIndexOf behaves correctly on SendableTypedArrays backed by resizable + buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2)); + } + + // Orig. array: [0, 0, 1, 1] + // [0, 0, 1, 1] << fixedLength + // [1, 1] << fixedLengthWithOffset + // [0, 0, 1, 1, ...] << lengthTracking + // [1, 1, ...] << lengthTrackingWithOffset + + // If fixedLength is a BigInt array, they all are BigInt Arrays. + let n0 = MayNeedBigInt(fixedLength, 0); + let n1 = MayNeedBigInt(fixedLength, 1); + + assert.sameValue(fixedLength.lastIndexOf(n0), 1); + assert.sameValue(fixedLength.lastIndexOf(n0, 1), 1); + assert.sameValue(fixedLength.lastIndexOf(n0, 2), 1); + assert.sameValue(fixedLength.lastIndexOf(n0, -2), 1); + assert.sameValue(fixedLength.lastIndexOf(n0, -3), 1); + assert.sameValue(fixedLength.lastIndexOf(n1, 1), -1); + assert.sameValue(fixedLength.lastIndexOf(n1, -2), 2); + assert.sameValue(fixedLength.lastIndexOf(n1, -3), -1); + assert.sameValue(fixedLength.lastIndexOf(undefined), -1); + assert.sameValue(fixedLengthWithOffset.lastIndexOf(n0), -1); + assert.sameValue(fixedLengthWithOffset.lastIndexOf(n1), 1); + assert.sameValue(fixedLengthWithOffset.lastIndexOf(n1, -2), 0); + assert.sameValue(fixedLengthWithOffset.lastIndexOf(n1, -1), 1); + assert.sameValue(fixedLengthWithOffset.lastIndexOf(undefined), -1); + assert.sameValue(lengthTracking.lastIndexOf(n0), 1); + assert.sameValue(lengthTracking.lastIndexOf(n0, 2), 1); + assert.sameValue(lengthTracking.lastIndexOf(n0, -3), 1); + assert.sameValue(lengthTracking.lastIndexOf(n1, 1), -1); + assert.sameValue(lengthTracking.lastIndexOf(n1, 2), 2); + assert.sameValue(lengthTracking.lastIndexOf(n1, -3), -1); + assert.sameValue(lengthTracking.lastIndexOf(undefined), -1); + assert.sameValue(lengthTrackingWithOffset.lastIndexOf(n0), -1); + assert.sameValue(lengthTrackingWithOffset.lastIndexOf(n1), 1); + assert.sameValue(lengthTrackingWithOffset.lastIndexOf(n1, 1), 1); + assert.sameValue(lengthTrackingWithOffset.lastIndexOf(n1, -2), 0); + assert.sameValue(lengthTrackingWithOffset.lastIndexOf(n1, -1), 1); + assert.sameValue(lengthTrackingWithOffset.lastIndexOf(undefined), -1); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 0, 1] + // [0, 0, 1, ...] << lengthTracking + // [1, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + fixedLength.lastIndexOf(n1); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.lastIndexOf(n1); + }); + + assert.sameValue(lengthTracking.lastIndexOf(n0), 1); + assert.sameValue(lengthTracking.lastIndexOf(undefined), -1); + assert.sameValue(lengthTrackingWithOffset.lastIndexOf(n0), -1); + assert.sameValue(lengthTrackingWithOffset.lastIndexOf(n1), 0); + assert.sameValue(lengthTrackingWithOffset.lastIndexOf(undefined), -1); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.lastIndexOf(n0); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.lastIndexOf(n0); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.lastIndexOf(n0); + }); + + assert.sameValue(lengthTracking.lastIndexOf(n0), 0); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.lastIndexOf(n0); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.lastIndexOf(n0); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.lastIndexOf(n0); + }); + + assert.sameValue(lengthTracking.lastIndexOf(n0), -1); + assert.sameValue(lengthTracking.lastIndexOf(undefined), -1); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, Math.floor(i / 2)); + } + + // Orig. array: [0, 0, 1, 1, 2, 2] + // [0, 0, 1, 1] << fixedLength + // [1, 1] << fixedLengthWithOffset + // [0, 0, 1, 1, 2, 2, ...] << lengthTracking + // [1, 1, 2, 2, ...] << lengthTrackingWithOffset + + let n2 = MayNeedBigInt(fixedLength, 2); + + assert.sameValue(fixedLength.lastIndexOf(n1), 3); + assert.sameValue(fixedLength.lastIndexOf(n2), -1); + assert.sameValue(fixedLength.lastIndexOf(undefined), -1); + assert.sameValue(fixedLengthWithOffset.lastIndexOf(n0), -1); + assert.sameValue(fixedLengthWithOffset.lastIndexOf(n1), 1); + assert.sameValue(fixedLengthWithOffset.lastIndexOf(n2), -1); + assert.sameValue(fixedLengthWithOffset.lastIndexOf(undefined), -1); + assert.sameValue(lengthTracking.lastIndexOf(n1), 3); + assert.sameValue(lengthTracking.lastIndexOf(n2), 5); + assert.sameValue(lengthTracking.lastIndexOf(undefined), -1); + assert.sameValue(lengthTrackingWithOffset.lastIndexOf(n0), -1); + assert.sameValue(lengthTrackingWithOffset.lastIndexOf(n1), 1); + assert.sameValue(lengthTrackingWithOffset.lastIndexOf(n2), 3); + assert.sameValue(lengthTrackingWithOffset.lastIndexOf(undefined), -1); +} diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..e77f3f9d058 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.lastIndexOf, + 'function', + 'implements SendableTypedArray.prototype.lastIndexOf' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.lastIndexOf(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.lastIndexOf(0); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the lastIndexOf operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.lastIndexOf(0); + throw new Test262Error('lastIndexOf completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js new file mode 100644 index 00000000000..db47e8fd91c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Return abrupt from ToInteger(fromIndex) - using symbol +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let + n be len-1. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var fromIndex = Symbol("1"); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(TypeError, function() { + sample.lastIndexOf(7, fromIndex); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js new file mode 100644 index 00000000000..38d79ad76ba --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Return abrupt from ToInteger(fromIndex) +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let + n be len-1. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var fromIndex = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(Test262Error, function() { + sample.lastIndexOf(7, fromIndex); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js new file mode 100644 index 00000000000..5902f723e28 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: returns index for the first found element +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be min(n, len - 1). + 6. Else n < 0, + a. Let k be len + n. + 7. Repeat, while k ≥ 0 + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ii. Let same be the result of performing Strict Equality Comparison + searchElement === elementK. + iii. If same is true, return k. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 42, 41]); + assert.sameValue(sample.lastIndexOf(42), 2, "lastIndexOf(42)"); + assert.sameValue(sample.lastIndexOf(43), 1, "lastIndexOf(43)"); + assert.sameValue(sample.lastIndexOf(41), 3, "lastIndexOf(41)"); + assert.sameValue(sample.lastIndexOf(41, 3), 3, "lastIndexOf(41, 3)"); + assert.sameValue(sample.lastIndexOf(41, 4), 3, "lastIndexOf(41, 4)"); + assert.sameValue(sample.lastIndexOf(43, 1), 1, "lastIndexOf(43, 1)"); + assert.sameValue(sample.lastIndexOf(43, 2), 1, "lastIndexOf(43, 2)"); + assert.sameValue(sample.lastIndexOf(43, 3), 1, "lastIndexOf(43, 3)"); + assert.sameValue(sample.lastIndexOf(43, 4), 1, "lastIndexOf(43, 4)"); + assert.sameValue(sample.lastIndexOf(42, 0), 0, "lastIndexOf(42, 0)"); + assert.sameValue(sample.lastIndexOf(42, 1), 0, "lastIndexOf(42, 1)"); + assert.sameValue(sample.lastIndexOf(42, 2), 2, "lastIndexOf(42, 2)"); + assert.sameValue(sample.lastIndexOf(42, 3), 2, "lastIndexOf(42, 3)"); + assert.sameValue(sample.lastIndexOf(42, 4), 2, "lastIndexOf(42, 4)"); + assert.sameValue(sample.lastIndexOf(42, -4), 0, "lastIndexOf(42, -4)"); + assert.sameValue(sample.lastIndexOf(42, -3), 0, "lastIndexOf(42, -3)"); + assert.sameValue(sample.lastIndexOf(42, -2), 2, "lastIndexOf(42, -2)"); + assert.sameValue(sample.lastIndexOf(42, -1), 2, "lastIndexOf(42, -1)"); + assert.sameValue(sample.lastIndexOf(43, -3), 1, "lastIndexOf(43, -3)"); + assert.sameValue(sample.lastIndexOf(43, -2), 1, "lastIndexOf(43, -2)"); + assert.sameValue(sample.lastIndexOf(43, -1), 1, "lastIndexOf(43, -1)"); + assert.sameValue(sample.lastIndexOf(41, -1), 3, "lastIndexOf(41, -1)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js new file mode 100644 index 00000000000..961422e9d8d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: returns -1 if the element if not found +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 5. If n ≥ 0, then + a. If n is -0, let k be +0; else let k be min(n, len - 1). + 6. Else n < 0, + a. Let k be len + n. + 7. Repeat, while k ≥ 0 + ... + 8. Return -1. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42, 43, 42, 41]); + assert.sameValue(sample.lastIndexOf(44), -1, "lastIndexOf(44)"); + assert.sameValue(sample.lastIndexOf(44, -4), -1, "lastIndexOf(44, -4)"); + assert.sameValue(sample.lastIndexOf(44, -5), -1, "lastIndexOf(44, -5)"); + assert.sameValue(sample.lastIndexOf(42, -5), -1, "lastIndexOf(42, -5)"); + assert.sameValue(sample.lastIndexOf(43, -4), -1, "lastIndexOf(43, -4)"); + assert.sameValue(sample.lastIndexOf(43, -5), -1, "lastIndexOf(43, -5)"); + assert.sameValue(sample.lastIndexOf(41, 0), -1, "lastIndexOf(41, 0)"); + assert.sameValue(sample.lastIndexOf(41, 1), -1, "lastIndexOf(41, 1)"); + assert.sameValue(sample.lastIndexOf(41, 2), -1, "lastIndexOf(41, 2)"); + assert.sameValue(sample.lastIndexOf(43, 0), -1, "lastIndexOf(43, 0)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js new file mode 100644 index 00000000000..f0940cbad42 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: search element is compared using strict comparing (===) +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 7. Repeat, while k ≥ 0 + ... + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ii. Let same be the result of performing Strict Equality Comparison + searchElement === elementK. + iii. If same is true, return k. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, undefined, NaN, 0, 1]); + assert.sameValue(sample.lastIndexOf("42"), -1, "'42'"); + assert.sameValue(sample.lastIndexOf([42]), -1, "[42]"); + assert.sameValue(sample.lastIndexOf(42.0), 0, "42.0"); + assert.sameValue(sample.lastIndexOf(-0), 3, "-0"); + assert.sameValue(sample.lastIndexOf(true), -1, "true"); + assert.sameValue(sample.lastIndexOf(false), -1, "false"); + assert.sameValue(sample.lastIndexOf(NaN), -1, "NaN === NaN is false"); + assert.sameValue(sample.lastIndexOf(null), -1, "null"); + assert.sameValue(sample.lastIndexOf(undefined), -1, "undefined"); + assert.sameValue(sample.lastIndexOf(""), -1, "empty string"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-object.js new file mode 100644 index 00000000000..64b2c307df1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-object.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var lastIndexOf = SendableTypedArray.prototype.lastIndexOf; + +assert.throws(TypeError, function() { + lastIndexOf.call(undefined, 42); +}, "this is undefined"); + +assert.throws(TypeError, function() { + lastIndexOf.call(null, 42); +}, "this is null"); + +assert.throws(TypeError, function() { + lastIndexOf.call(42, 42); +}, "this is 42"); + +assert.throws(TypeError, function() { + lastIndexOf.call("1", 42); +}, "this is a string"); + +assert.throws(TypeError, function() { + lastIndexOf.call(true, 42); +}, "this is true"); + +assert.throws(TypeError, function() { + lastIndexOf.call(false, 42); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + lastIndexOf.call(s, 42); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..b89c63a4927 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var lastIndexOf = SendableTypedArray.prototype.lastIndexOf; + +assert.throws(TypeError, function() { + lastIndexOf.call({}, 42); +}, "this is an Object"); + +assert.throws(TypeError, function() { + lastIndexOf.call([], 42); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + lastIndexOf.call(ab, 42); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + lastIndexOf.call(dv, 42); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js new file mode 100644 index 00000000000..9cce3182750 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.lastindexof +description: Return -1 if fromIndex >= ArrayLength - converted values +info: | + 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + %SendableTypedArray%.prototype.lastIndexOf is a distinct function that implements the + same algorithm as Array.prototype.lastIndexOf as defined in 22.1.3.15 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) + + ... + 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let + n be len-1. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var obj = { + valueOf: function() { + return 1; + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([42, 43]); + assert.sameValue(sample.lastIndexOf(42, "1"), 0, "string [0]"); + assert.sameValue(sample.lastIndexOf(43, "1"), 1, "string [1]"); + + assert.sameValue(sample.lastIndexOf(42, true), 0, "true [0]"); + assert.sameValue(sample.lastIndexOf(43, true), 1, "true [1]"); + + assert.sameValue(sample.lastIndexOf(42, false), 0, "false [0]"); + assert.sameValue(sample.lastIndexOf(43, false), -1, "false [1]"); + + assert.sameValue(sample.lastIndexOf(42, NaN), 0, "NaN [0]"); + assert.sameValue(sample.lastIndexOf(43, NaN), -1, "NaN [1]"); + + assert.sameValue(sample.lastIndexOf(42, null), 0, "null [0]"); + assert.sameValue(sample.lastIndexOf(43, null), -1, "null [1]"); + + assert.sameValue(sample.lastIndexOf(42, undefined), 0, "undefined [0]"); + assert.sameValue(sample.lastIndexOf(43, undefined), -1, "undefined [1]"); + + assert.sameValue(sample.lastIndexOf(42, null), 0, "null [0]"); + assert.sameValue(sample.lastIndexOf(43, null), -1, "null [1]"); + + assert.sameValue(sample.lastIndexOf(42, obj), 0, "object [0]"); + assert.sameValue(sample.lastIndexOf(43, obj), 1, "object [1]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/length/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/length/BigInt/detached-buffer.js new file mode 100644 index 00000000000..7eee1af7429 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/BigInt/detached-buffer.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: Returns 0 if the instance has a detached buffer +info: | + 22.2.3.18 get %SendableTypedArray%.prototype.length + + ... + 5. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 6. If IsDetachedBuffer(buffer) is true, return 0. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(42); + $DETACHBUFFER(sample.buffer); + assert.sameValue(sample.length, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js new file mode 100644 index 00000000000..835d2a8813f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the dynamically-sized SendableTypedArray instance +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE); + var expected = 3; + + assert.sameValue(array.length, expected, "initial value"); + + try { + ab.resize(BPE * 5); + expected = 4; + } catch (_) {} + + assert.sameValue(array.length, expected, "following grow"); + + try { + ab.resize(BPE * 3); + expected = 2; + } catch (_) {} + + assert.sameValue(array.length, expected, "following shrink (within bounds)"); + + try { + ab.resize(BPE * 3 - 1); + expected = 1; + } catch (_) {} + + assert.sameValue(array.length, expected, "following shrink (partial element)"); + + try { + ab.resize(BPE); + expected = 0; + } catch (_) {} + + assert.sameValue(array.length, expected, "following shrink (on boundary)"); + + try { + ab.resize(0); + expected = 0; + } catch (_) {} + + assert.sameValue(array.length, expected, "following shrink (out of bounds)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js new file mode 100644 index 00000000000..3ac50a1f72f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the fixed-sized SendableTypedArray instance +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + assert.sameValue(array.length, 2, "initial value"); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + assert.sameValue(array.length, 2, "following grow"); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + assert.sameValue(array.length, 2, "following shrink (within bounds)"); + + var expected; + try { + ab.resize(BPE * 3 - 1); + expected = 0; + } catch (_) { + expected = 2; + } + + assert.sameValue(array.length, expected, "following shrink (out of bounds)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/length/BigInt/return-length.js b/test/sendable/builtins/TypedArray/prototype/length/BigInt/return-length.js new file mode 100644 index 00000000000..6af171c4abe --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/BigInt/return-length.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + Return value from the [[ArrayLength]] internal slot +info: | + 22.2.3.18 get %SendableTypedArray%.prototype.length + + ... + 6. Let length be the value of O's [[ArrayLength]] internal slot. + 7. Return length. + + --- + + The current tests on `prop-desc.js` and `length.js` already assert `length` is + not a dynamic property as in regular arrays. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var ta1 = new TA(); + assert.sameValue(ta1.length, 0); + + var ta2 = new TA(42); + assert.sameValue(ta2.length, 42); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js new file mode 100644 index 00000000000..e6ff36b5f84 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: Returns 0 if the instance has a detached buffer +info: | + 22.2.3.18 get %SendableTypedArray%.prototype.length + + ... + 5. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 6. If IsDetachedBuffer(buffer) is true, return 0. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(42); + $DETACHBUFFER(sample.buffer); + assert.sameValue(sample.length, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js new file mode 100644 index 00000000000..ae4057279f7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + Requires this value to have a [[ViewedArrayBuffer]] internal slot +info: | + 22.2.3.17 get %SendableTypedArray%.prototype.length + + 1. Let O be the this value. + ... + 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.length; +}); diff --git a/test/sendable/builtins/TypedArray/prototype/length/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/length/invoked-as-func.js new file mode 100644 index 00000000000..acf987142ba --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/invoked-as-func.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.17 get %SendableTypedArray%.prototype.length + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, 'length' +).get; + +assert.throws(TypeError, function() { + getter(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/length/length.js b/test/sendable/builtins/TypedArray/prototype/length/length.js new file mode 100644 index 00000000000..02afc0877cd --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/length.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + get %SendableTypedArray%.prototype.length.length is 0. +info: | + get %SendableTypedArray%.prototype.length + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray.prototype, "length"); + +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/length/name.js b/test/sendable/builtins/TypedArray/prototype/length/name.js new file mode 100644 index 00000000000..4d31776e89a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/name.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + get %SendableTypedArray%.prototype.length.name is "get length". +info: | + get %SendableTypedArray%.prototype.length + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableTypedArray.prototype, "length"); + +verifyProperty(desc.get, "name", { + value: "get length", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/length/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/length/prop-desc.js new file mode 100644 index 00000000000..660aef816db --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/prop-desc.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + "length" property of SendableTypedArrayPrototype +info: | + %SendableTypedArray%.prototype.length is an accessor property whose set accessor + function is undefined. + + Section 17: Every accessor property described in clauses 18 through 26 and in + Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } +includes: [propertyHelper.js, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var desc = Object.getOwnPropertyDescriptor(SendableTypedArrayPrototype, "length"); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, "function"); + +verifyNotEnumerable(SendableTypedArrayPrototype, "length"); +verifyConfigurable(SendableTypedArrayPrototype, "length"); diff --git a/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js new file mode 100644 index 00000000000..fd9e0fb31fe --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the dynamically-sized SendableTypedArray instance +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE); + var expected = 3; + + assert.sameValue(array.length, expected, "initial value"); + + try { + ab.resize(BPE * 5); + expected = 4; + } catch (_) {} + + assert.sameValue(array.length, expected, "following grow"); + + try { + ab.resize(BPE * 3); + expected = 2; + } catch (_) {} + + assert.sameValue(array.length, expected, "following shrink (within bounds)"); + + try { + ab.resize(BPE * 3 - 1); + expected = 1; + } catch (_) {} + + assert.sameValue(array.length, expected, "following shrink (partial element)"); + + try { + ab.resize(BPE); + expected = 0; + } catch (_) {} + + assert.sameValue(array.length, expected, "following shrink (on boundary)"); + + try { + ab.resize(0); + expected = 0; + } catch (_) {} + + assert.sameValue(array.length, expected, "following shrink (out of bounds)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js new file mode 100644 index 00000000000..0b99164ae24 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: | + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + the fixed-sized SendableTypedArray instance +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + assert.sameValue(array.length, 2, "initial value"); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + assert.sameValue(array.length, 2, "following grow"); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + assert.sameValue(array.length, 2, "following shrink (within bounds)"); + + var expected; + try { + ab.resize(BPE * 3 - 1); + expected = 0; + } catch (_) { + expected = 2; + } + + assert.sameValue(array.length, expected, "following shrink (out of bounds)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/length/resizable-buffer-assorted.js b/test/sendable/builtins/TypedArray/prototype/length/resizable-buffer-assorted.js new file mode 100644 index 00000000000..4831e2d5775 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/resizable-buffer-assorted.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + SendableTypedArray.p.length behaves correctly on SendableTypedArrays backed by resizable + buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +const rab = CreateResizableArrayBuffer(40, 80); +for (let ctor of ctors) { + const ta = new ctor(rab, 0, 3); + assert.compareArray(ta.buffer, rab); + assert.sameValue(ta.length, 3); + const empty_ta = new ctor(rab, 0, 0); + assert.compareArray(empty_ta.buffer, rab); + assert.sameValue(empty_ta.length, 0); + const ta_with_offset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 3); + assert.compareArray(ta_with_offset.buffer, rab); + assert.sameValue(ta_with_offset.length, 3); + const empty_ta_with_offset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 0); + assert.compareArray(empty_ta_with_offset.buffer, rab); + assert.sameValue(empty_ta_with_offset.length, 0); + const length_tracking_ta = new ctor(rab); + assert.compareArray(length_tracking_ta.buffer, rab); + assert.sameValue(length_tracking_ta.length, 40 / ctor.BYTES_PER_ELEMENT); + const offset = 8; + const length_tracking_ta_with_offset = new ctor(rab, offset); + assert.compareArray(length_tracking_ta_with_offset.buffer, rab); + assert.sameValue(length_tracking_ta_with_offset.length, (40 - offset) / ctor.BYTES_PER_ELEMENT); + const empty_length_tracking_ta_with_offset = new ctor(rab, 40); + assert.compareArray(empty_length_tracking_ta_with_offset.buffer, rab); + assert.sameValue(empty_length_tracking_ta_with_offset.length, 0); +} diff --git a/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-1.js b/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-1.js new file mode 100644 index 00000000000..0d4e1f8b36f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-1.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + SendableTypedArray.p.length behaves correctly when the underlying resizable buffer is + resized such that the SendableTypedArray becomes out of bounds. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +const rab = CreateResizableArrayBuffer(16, 40); + +// Create TAs which cover the bytes 0-7. +let tas_and_lengths = []; +for (let ctor of ctors) { + const length = 8 / ctor.BYTES_PER_ELEMENT; + tas_and_lengths.push([ + new ctor(rab, 0, length), + length + ]); +} +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.length, length); +} +rab.resize(2); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.length, 0); +} +// Resize the rab so that it just barely covers the needed 8 bytes. +rab.resize(8); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.length, length); +} +rab.resize(40); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.length, length); +} diff --git a/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-2.js b/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-2.js new file mode 100644 index 00000000000..853f6391616 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-2.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + SendableTypedArray.p.length behaves correctly when the underlying resizable buffer is + resized such that the SendableTypedArray becomes out of bounds. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Like resized-out-of-bounds-1.js but with offsets. + +const rab = CreateResizableArrayBuffer(20, 40); + +// Create TAs with offset, which cover the bytes 8-15. +let tas_and_lengths = []; +for (let ctor of ctors) { + const length = 8 / ctor.BYTES_PER_ELEMENT; + tas_and_lengths.push([ + new ctor(rab, 8, length), + length + ]); +} +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.length, length); +} +rab.resize(10); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.length, 0); +} +// Resize the rab so that it just barely covers the needed 8 bytes. +rab.resize(16); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.length, length); +} +rab.resize(40); +for (let [ta, length] of tas_and_lengths) { + assert.sameValue(ta.length, length); +} diff --git a/test/sendable/builtins/TypedArray/prototype/length/return-length.js b/test/sendable/builtins/TypedArray/prototype/length/return-length.js new file mode 100644 index 00000000000..0f9af41a95a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/return-length.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + Return value from the [[ArrayLength]] internal slot +info: | + 22.2.3.18 get %SendableTypedArray%.prototype.length + + ... + 6. Let length be the value of O's [[ArrayLength]] internal slot. + 7. Return length. + + --- + + The current tests on `prop-desc.js` and `length.js` already assert `length` is + not a dynamic property as in regular arrays. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var ta1 = new TA(); + assert.sameValue(ta1.length, 0); + + var ta2 = new TA(42); + assert.sameValue(ta2.length, 42); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js new file mode 100644 index 00000000000..5852412a6e3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: > + Throws a TypeError exception when `this` does not have a [[TypedArrayName]] + internal slot +info: | + 22.2.3.18 get %SendableTypedArray%.prototype.length + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [DataView, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, "length" +).get; + +assert.throws(TypeError, function() { + getter.call({}); +}); + +assert.throws(TypeError, function() { + getter.call([]); +}); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + getter.call(ab); +}); + +var dv = new DataView(new ArrayBuffer(8), 0); +assert.throws(TypeError, function() { + getter.call(dv); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/length/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/length/this-is-not-object.js new file mode 100644 index 00000000000..4b523f084b4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/length/this-is-not-object.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-%typedarray%.prototype.length +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.18 get %SendableTypedArray%.prototype.length + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; +var getter = Object.getOwnPropertyDescriptor( + SendableTypedArrayPrototype, "length" +).get; + + +assert.throws(TypeError, function() { + getter.call(undefined); +}, "undefined"); + +assert.throws(TypeError, function() { + getter.call(null); +}, "null"); + +assert.throws(TypeError, function() { + getter.call(42); +}, "number"); + +assert.throws(TypeError, function() { + getter.call("1"); +}, "string"); + +assert.throws(TypeError, function() { + getter.call(true); +}, "true"); + +assert.throws(TypeError, function() { + getter.call(false); +}, "false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + getter.call(s); +}, "symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/arraylength-internal.js new file mode 100644 index 00000000000..0b8f91e9d5f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/arraylength-internal.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + [[ArrayLength]] is accessed in place of performing a [[Get]] of "length" +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 3. Let len be the value of O's [[ArrayLength]] internal slot. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(42); + var loop = 0; + + Object.defineProperty(sample1, "length", {value: 1}); + + sample1.map(function() { + loop++; + return 0n; + }); + assert.sameValue(loop, 42, "data descriptor"); + + loop = 0; + var sample2 = new TA(4); + Object.defineProperty(sample2, "length", { + get: function() { + throw new Test262Error( + "Does not return abrupt getting length property" + ); + } + }); + + sample2.map(function() { + loop++; + return 0n; + }); + assert.sameValue(loop, 4, "accessor descriptor"); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js new file mode 100644 index 00000000000..55d9d61495a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + thisArg does not affect callbackfn arguments +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 8. Repeat, while k < len + a. Let Pk be ! ToString(k). + b. Let kValue be ? Get(O, Pk). + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + var results = []; + var thisArg = ["test262", 0, "ecma262", 0]; + + sample.map(function() { + results.push(arguments); + return 0n; + }, thisArg); + + assert.sameValue(results.length, 3, "results.length"); + assert.sameValue(thisArg.length, 4, "thisArg.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42n, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43n, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44n, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js new file mode 100644 index 00000000000..ba41a1e775d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + callbackfn arguments +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 8. Repeat, while k < len + a. Let Pk be ! ToString(k). + b. Let kValue be ? Get(O, Pk). + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + var results = []; + + sample.map(function() { + results.push(arguments); + return 0n; + }); + + assert.sameValue(results.length, 3, "results.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42n, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43n, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44n, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js new file mode 100644 index 00000000000..3af2894a6d5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Instance buffer can be detached during loop +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(O, Pk). + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [detachArrayBuffer.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.map(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + return true; + }); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js new file mode 100644 index 00000000000..4b00af5fcb3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + callbackfn is not callable +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + assert.throws(TypeError, function() { + sample.map(); + }); + + assert.throws(TypeError, function() { + sample.map(undefined); + }); + + assert.throws(TypeError, function() { + sample.map(null); + }); + + assert.throws(TypeError, function() { + sample.map({}); + }); + + assert.throws(TypeError, function() { + sample.map(1); + }); + + assert.throws(TypeError, function() { + sample.map(""); + }); + + assert.throws(TypeError, function() { + sample.map(false); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js new file mode 100644 index 00000000000..f89764b4410 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Does not interact over non-integer properties +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 8. Repeat, while k < len + a. Let Pk be ! ToString(k). + b. Let kValue be ? Get(O, Pk). + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7n, 8n]); + + var results = []; + + sample.foo = 42; + sample[Symbol("1")] = 43; + + sample.map(function() { + results.push(arguments); + return 0n; + }); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + + assert.sameValue(results[0][0], 7n, "results[0][0] - kValue"); + assert.sameValue(results[1][0], 8n, "results[1][0] - kValue"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js new file mode 100644 index 00000000000..55064dfff87 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + callbackfn is not called on empty instances +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 7. Let k be 0. + 8. Repeat, while k < len + ... + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var called = 0; + + new TA().map(function() { + called++; + }); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js new file mode 100644 index 00000000000..ec10d31cff2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + The callbackfn returned values are applied to the new instance +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + 7. Let k be 0. + 8. Repeat, while k < len + ... + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + d. Perform ? Set(A, Pk, mappedValue, true). + ... + 9. Return A. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1n, 2n, 4n]); + var result = sample.map(function(v) { + return v * 3n; + }); + + assert.sameValue(result[0], 3n, "result[0] == 3"); + assert.sameValue(result[1], 6n, "result[1] == 6"); + assert.sameValue(result[2], 12n, "result[2] == 12"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js new file mode 100644 index 00000000000..ee853e6871a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + The callbackfn return does not change the `this` instance +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(3); + + sample1[1] = 1n; + + sample1.map(function() { + return 42n; + }); + + assert.sameValue(sample1[0], 0n, "[0] == 0"); + assert.sameValue(sample1[1], 1n, "[1] == 1"); + assert.sameValue(sample1[2], 0n, "[2] == 0"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js new file mode 100644 index 00000000000..17aa32326fa --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Does not copy non-integer properties to returned value +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 8. Repeat, while k < len + a. Let Pk be ! ToString(k). + b. Let kValue be ? Get(O, Pk). + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7n, 8n]); + var bar = Symbol("1"); + + sample.foo = 42; + sample[bar] = 1; + + var result = sample.map(function() { + return 0n; + }); + + assert.sameValue(result.length, 2, "result.length"); + assert.sameValue( + Object.getOwnPropertyDescriptor(result, "foo"), + undefined, + "foo" + ); + assert.sameValue( + Object.getOwnPropertyDescriptor(result, bar), + undefined, + "bar" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js new file mode 100644 index 00000000000..e2bc748f32c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Returns abrupt from callbackfn +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + assert.throws(Test262Error, function() { + sample.map(function() { + throw new Test262Error(); + }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js new file mode 100644 index 00000000000..2f5b957538c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Reflect.set, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + var newVal = 0n; + + sample.map(function(val, i) { + if (i > 0) { + assert.sameValue( + sample[i - 1], newVal - 1n, + "get the changed value during the loop" + ); + assert.sameValue( + Reflect.set(sample, 0, 7n), + true, + "re-set a value for sample[0]" + ); + } + assert.sameValue( + Reflect.set(sample, i, newVal), + true, + "set value during iteration" + ); + + newVal++; + return 0n; + }); + + assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7"); + assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1"); + assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-this.js new file mode 100644 index 00000000000..7071a3913a3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-this.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + callbackfn `this` value +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 8. Repeat, while k < len + ... + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var expected = (function() { return this; })(); +var thisArg = {}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var results1 = []; + + sample.map(function() { + results1.push(this); + return 0n; + }); + + assert.sameValue(results1.length, 3, "results1"); + assert.sameValue(results1[0], expected, "without thisArg - [0]"); + assert.sameValue(results1[1], expected, "without thisArg - [1]"); + assert.sameValue(results1[2], expected, "without thisArg - [2]"); + + var results2 = []; + + sample.map(function() { + results2.push(this); + return 0n; + }, thisArg); + + assert.sameValue(results2.length, 3, "results2"); + assert.sameValue(results2[0], thisArg, "using thisArg - [0]"); + assert.sameValue(results2[1], thisArg, "using thisArg - [1]"); + assert.sameValue(results2[2], thisArg, "using thisArg - [2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/detached-buffer.js new file mode 100644 index 00000000000..92608dd1cf3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var callbackfn = function() { + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.map(callbackfn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..bc1fcfc6576 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.map, + 'function', + 'implements SendableTypedArray.prototype.map' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.map(() => 0n); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.map(() => 0n); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the map operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.map(() => 0n); + throw new Test262Error('map completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js new file mode 100644 index 00000000000..60ce5c9d714 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Returns a new typedArray instance from the same constructor with the same + length and a new buffer object - testing on an instance with length == 0 +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + 7. Let k be 0. + 8. Repeat, while k < len + ... + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... + 9. Return A. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(0); + + var result = sample.map(function() {}); + + assert.notSameValue(result, sample, "new typedArray object"); + assert.sameValue(result.constructor, TA, "same constructor"); + assert(result instanceof TA, "result is an instance of " + TA.name); + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "result has the same prototype of sample" + ); + assert.sameValue(result.length, 0, "same length"); + assert.notSameValue(result.buffer, sample.buffer, "new buffer"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js new file mode 100644 index 00000000000..8dcc978cba5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Returns a new typedArray instance from the same constructor with the same + length and a new buffer object - testing on an instance with length > 0 +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + 7. Let k be 0. + 8. Repeat, while k < len + ... + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... + 9. Return A. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var result = sample.map(function(v) { + return v; + }); + + assert.notSameValue(result, sample, "new typedArray object"); + assert.sameValue(result.constructor, sample.constructor, "same constructor"); + assert.sameValue(result.length, 3, "same length"); + assert.notSameValue(result.buffer, sample.buffer, "new buffer"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-destination-resizable.js new file mode 100644 index 00000000000..7042ce74221 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-destination-resizable.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Throws a TypeError if new typedArray's length < count +info: | + 22.2.3.22 %SendableTypedArray%.prototype.map ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 23.2.4.1 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + 23.2.4.2 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); + const ta = new TA(rab1); + const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); + const lengthTracking = new TA(rab2); + rab2.resize(0); + ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; + assert.throws(TypeError, function() { + ta.map(() => {}); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js new file mode 100644 index 00000000000..15c36b2cd3f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: Return abrupt from SpeciesConstructor's get Constructor +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + var callCount = 0; + + Object.defineProperty(sample, "constructor", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.map(function() { + callCount++; + }); + }); + assert.sameValue(callCount, 0, "callback should not be called"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js new file mode 100644 index 00000000000..ffb8f9f25e4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: get inherited constructor on SpeciesConstructor +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + var calls = 0; + var result; + + Object.defineProperty(TA.prototype, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.map(function() { + return 0n; + }); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + undefined, + "used defaultCtor but still checks the inherited .constructor" + ); + + calls = 6; + result.constructor; + assert.sameValue( + calls, + 7, + "result.constructor triggers the inherited accessor property" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js new file mode 100644 index 00000000000..3c6c040d26f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Throws if O.constructor returns a non-Object and non-undefined value +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + 4. If Type(C) is not Object, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var callbackfn = function() { return 0n; }; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + sample.constructor = 42; + assert.throws(TypeError, function() { + sample.map(callbackfn); + }, "42"); + + sample.constructor = "1"; + assert.throws(TypeError, function() { + sample.map(callbackfn); + }, "string"); + + sample.constructor = null; + assert.throws(TypeError, function() { + sample.map(callbackfn); + }, "null"); + + sample.constructor = NaN; + assert.throws(TypeError, function() { + sample.map(callbackfn); + }, "NaN"); + + sample.constructor = false; + assert.throws(TypeError, function() { + sample.map(callbackfn); + }, "false"); + + sample.constructor = Symbol("1"); + assert.throws(TypeError, function() { + sample.map(callbackfn); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js new file mode 100644 index 00000000000..2504eeb8471 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: get constructor on SpeciesConstructor +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + var calls = 0; + var result; + + Object.defineProperty(sample, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.map(function() { return 0n; }); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + TA, + "use defaultCtor on an undefined return - .constructor check" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js new file mode 100644 index 00000000000..25ba0b7ee65 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Returns abrupt from get @@species on found constructor +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.map(function() { return 0n; }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js new file mode 100644 index 00000000000..0b9f7183b3f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Verify arguments on custom @@species construct call +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 42n, 42n]); + var result, ctorThis; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(count) { + result = arguments; + ctorThis = this; + return new TA(count); + }; + + sample.map(function(v) { return v === 42n; }); + + assert.sameValue(result.length, 1, "called with 1 argument"); + assert.sameValue(result[0], 3, "[0] is the length"); + + assert( + ctorThis instanceof sample.constructor[Symbol.species], + "`this` value in the @@species fn is an instance of the function itself" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js new file mode 100644 index 00000000000..74d6dff6015 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Throws a TypeError if new typedArray's length < count +info: | + 22.2.3.22 %SendableTypedArray%.prototype.map ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 23.2.4.1 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + 23.2.4.2 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + const sample = new TA(2); + const rab = new ArrayBuffer(10, {maxByteLength: 20}); + const lengthTracking = new TA(rab); + rab.resize(0); + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return lengthTracking; + }; + assert.throws(TypeError, function() { + sample.map(() => {}); + }); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js new file mode 100644 index 00000000000..1d7324193b3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Throws a TypeError if new typedArray's length < len +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return new TA(); + }; + + assert.throws(TypeError, function() { + sample.map(function() { return 0; }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js new file mode 100644 index 00000000000..f9b9befcd6a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Does not throw a TypeError if new typedArray's length >= len +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var customCount, result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return new TA(customCount); + }; + + customCount = 2; + result = sample.map(function() { return 0n; }); + assert.sameValue(result.length, customCount, "length == count"); + + customCount = 5; + result = sample.map(function() { return 0n; }); + assert.sameValue(result.length, customCount, "length > count"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js new file mode 100644 index 00000000000..1314ddfdcd5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Custom @@species constructor may return a different SendableTypedArray +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n]); + var otherTA = TA === BigInt64Array ? BigUint64Array : BigInt64Array; + var other = new otherTA([1n, 0n, 1n]); + var result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return other; + }; + + result = sample.map(function(a) { return a + 7n; }); + + assert.sameValue(result, other, "returned another typedarray"); + assert(compareArray(result, [47n, 0n, 1n]), "values are set on returned typedarray"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js new file mode 100644 index 00000000000..2b13d91fa0a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Custom @@species constructor throws if it does not return a compatible object +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + sample.constructor[Symbol.species] = Array; + + assert.throws(TypeError, function() { + sample.map(function() {}); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js new file mode 100644 index 00000000000..68512ee8f29 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Use custom @@species constructor if available +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n]); + var calls = 0; + var other, result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(len) { + calls++; + other = new TA(len); + return other; + }; + + result = sample.map(function(a) { return a + 7n; }); + + assert.sameValue(calls, 1, "ctor called once"); + assert.sameValue(result, other, "return is instance of custom constructor"); + assert(compareArray(result, [47n, 48n, 49n]), "values are set on the new obj"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js new file mode 100644 index 00000000000..b3c5287e27b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Throws if returned @@species is not a constructor, null or undefined. +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + 7. If IsConstructor(S) is true, return S. + 8. Throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + sample.constructor[Symbol.species] = 0; + assert.throws(TypeError, function() { + sample.map(function() {}); + }, "0"); + + sample.constructor[Symbol.species] = "string"; + assert.throws(TypeError, function() { + sample.map(function() {}); + }, "string"); + + sample.constructor[Symbol.species] = {}; + assert.throws(TypeError, function() { + sample.map(function() {}); + }, "{}"); + + sample.constructor[Symbol.species] = NaN; + assert.throws(TypeError, function() { + sample.map(function() {}); + }, "NaN"); + + sample.constructor[Symbol.species] = false; + assert.throws(TypeError, function() { + sample.map(function() {}); + }, "false"); + + sample.constructor[Symbol.species] = true; + assert.throws(TypeError, function() { + sample.map(function() {}); + }, "true"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js new file mode 100644 index 00000000000..3fe9ae9585c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Use defaultConstructor if @@species is either undefined or null +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var result; + + sample.constructor = {}; + + result = sample.map(function() { return 0n; }); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "undefined @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "undefined @@species - ctor check"); + + sample.constructor[Symbol.species] = null; + result = sample.map(function() { return 0n; }); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "null @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "null @@species - ctor check"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js new file mode 100644 index 00000000000..f08ed05d4fb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + get @@species from found constructor +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var calls = 0; + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + calls++; + } + }); + + sample.map(function() { return 0n; }); + + assert.sameValue(calls, 1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/values-are-not-cached.js new file mode 100644 index 00000000000..69487e241a8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/values-are-not-cached.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + sample.map(function(v, i) { + if (i < sample.length - 1) { + sample[i+1] = 42n; + } + + assert.sameValue( + v, 42n, "method does not cache values before callbackfn calls" + ); + + return 0n; + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js new file mode 100644 index 00000000000..7b9132b7703 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + [[ArrayLength]] is accessed in place of performing a [[Get]] of "length" +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 3. Let len be the value of O's [[ArrayLength]] internal slot. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(42); + var loop = 0; + + Object.defineProperty(sample1, "length", {value: 1}); + + sample1.map(function() { + loop++; + return 0; + }); + assert.sameValue(loop, 42, "data descriptor"); + + loop = 0; + var sample2 = new TA(4); + Object.defineProperty(sample2, "length", { + get: function() { + throw new Test262Error( + "Does not return abrupt getting length property" + ); + } + }); + + sample2.map(function() { + loop++; + return 0; + }); + assert.sameValue(loop, 4, "accessor descriptor"); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js new file mode 100644 index 00000000000..1b234bc4193 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + thisArg does not affect callbackfn arguments +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 8. Repeat, while k < len + a. Let Pk be ! ToString(k). + b. Let kValue be ? Get(O, Pk). + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + var results = []; + var thisArg = ["test262", 0, "ecma262", 0]; + + sample.map(function() { + results.push(arguments); + return 0; + }, thisArg); + + assert.sameValue(results.length, 3, "results.length"); + assert.sameValue(thisArg.length, 4, "thisArg.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js new file mode 100644 index 00000000000..3a823a82b86 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + callbackfn arguments +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 8. Repeat, while k < len + a. Let Pk be ! ToString(k). + b. Let kValue be ? Get(O, Pk). + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + var results = []; + + sample.map(function() { + results.push(arguments); + return 0; + }); + + assert.sameValue(results.length, 3, "results.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js new file mode 100644 index 00000000000..823bea1c46c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Instance buffer can be detached during loop +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 8. Repeat, while k < len + ... + b. Let kValue be ? Get(O, Pk). + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [detachArrayBuffer.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.map(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + return true; + }); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js new file mode 100644 index 00000000000..f887f27aab0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + callbackfn is not callable +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + assert.throws(TypeError, function() { + sample.map(); + }); + + assert.throws(TypeError, function() { + sample.map(undefined); + }); + + assert.throws(TypeError, function() { + sample.map(null); + }); + + assert.throws(TypeError, function() { + sample.map({}); + }); + + assert.throws(TypeError, function() { + sample.map(1); + }); + + assert.throws(TypeError, function() { + sample.map(""); + }); + + assert.throws(TypeError, function() { + sample.map(false); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js new file mode 100644 index 00000000000..9e8e6ff6e37 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Does not interact over non-integer properties +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 8. Repeat, while k < len + a. Let Pk be ! ToString(k). + b. Let kValue be ? Get(O, Pk). + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7, 8]); + + var results = []; + + sample.foo = 42; + sample[Symbol("1")] = 43; + + sample.map(function() { + results.push(arguments); + return 0; + }); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + + assert.sameValue(results[0][0], 7, "results[0][0] - kValue"); + assert.sameValue(results[1][0], 8, "results[1][0] - kValue"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js new file mode 100644 index 00000000000..018dc61866c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + callbackfn is not called on empty instances +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 7. Let k be 0. + 8. Repeat, while k < len + ... + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var called = 0; + + new TA().map(function() { + called++; + }); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js new file mode 100644 index 00000000000..4d0d725c2ee --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: Instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var NaNvalue = isFloatSendableTypedArrayConstructor(TA) ? NaN : 0; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var finalElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = sample.map(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + finalElement = undefined; + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + finalElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + + return index; + }); + + assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)'); + assert.compareArray(indices, [0, 1, 2], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.compareArray(result, [0, 1, 2], 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = sample.map(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + + return index; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.compareArray(result, expectedIndices, 'result (grow)'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js new file mode 100644 index 00000000000..b8ec2c52ee2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + The callbackfn returned values are applied to the new instance +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + 7. Let k be 0. + 8. Repeat, while k < len + ... + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + d. Perform ? Set(A, Pk, mappedValue, true). + ... + 9. Return A. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1, 2, 4]); + var result = sample.map(function(v) { + return v * 3; + }); + + assert.sameValue(result[0], 3, "result[0] == 3"); + assert.sameValue(result[1], 6, "result[1] == 6"); + assert.sameValue(result[2], 12, "result[2] == 12"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js new file mode 100644 index 00000000000..c53af669e83 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + The callbackfn return does not change the `this` instance +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample1 = new TA(3); + + sample1[1] = 1; + + sample1.map(function() { + return 42; + }); + + assert.sameValue(sample1[0], 0, "[0] == 0"); + assert.sameValue(sample1[1], 1, "[1] == 1"); + assert.sameValue(sample1[2], 0, "[2] == 0"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js new file mode 100644 index 00000000000..3e54601b9b7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Does not copy non-integer properties to returned value +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 8. Repeat, while k < len + a. Let Pk be ! ToString(k). + b. Let kValue be ? Get(O, Pk). + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7, 8]); + var bar = Symbol("1"); + + sample.foo = 42; + sample[bar] = 1; + + var result = sample.map(function() { + return 0; + }); + + assert.sameValue(result.length, 2, "result.length"); + assert.sameValue( + Object.getOwnPropertyDescriptor(result, "foo"), + undefined, + "foo" + ); + assert.sameValue( + Object.getOwnPropertyDescriptor(result, bar), + undefined, + "bar" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js new file mode 100644 index 00000000000..749c6184017 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Returns abrupt from callbackfn +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + assert.throws(Test262Error, function() { + sample.map(function() { + throw new Test262Error(); + }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js new file mode 100644 index 00000000000..b10e08f5c3f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) +includes: [testTypedArray.js] +features: [Reflect.set, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + var newVal = 0; + + sample.map(function(val, i) { + if (i > 0) { + assert.sameValue( + sample[i - 1], newVal - 1, + "get the changed value during the loop" + ); + assert.sameValue( + Reflect.set(sample, 0, 7), + true, + "re-set a value for sample[0]" + ); + } + assert.sameValue( + Reflect.set(sample, i, newVal), + true, + "set value during iteration" + ); + + newVal++; + return 0; + }); + + assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7"); + assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1"); + assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js new file mode 100644 index 00000000000..5afea302d14 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + callbackfn `this` value +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 8. Repeat, while k < len + ... + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var expected = (function() { return this; })(); +var thisArg = {}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var results1 = []; + + sample.map(function() { + results1.push(this); + return 0; + }); + + assert.sameValue(results1.length, 3, "results1"); + assert.sameValue(results1[0], expected, "without thisArg - [0]"); + assert.sameValue(results1[1], expected, "without thisArg - [1]"); + assert.sameValue(results1[2], expected, "without thisArg - [2]"); + + var results2 = []; + + sample.map(function() { + results2.push(this); + return 0; + }, thisArg); + + assert.sameValue(results2.length, 3, "results2"); + assert.sameValue(results2[0], thisArg, "using thisArg - [0]"); + assert.sameValue(results2[1], thisArg, "using thisArg - [1]"); + assert.sameValue(results2[2], thisArg, "using thisArg - [2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js new file mode 100644 index 00000000000..334d036185a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var callbackfn = function() { + throw new Test262Error(); +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.map(callbackfn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/map/invoked-as-func.js new file mode 100644 index 00000000000..f9420cd364b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/invoked-as-func.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.18 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + 1. Let O be the this value. + 2. Let valid be ValidateSendableTypedArray(O). + 3. ReturnIfAbrupt(valid). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var map = SendableTypedArray.prototype.map; + +assert.sameValue(typeof map, 'function'); + +assert.throws(TypeError, function() { + map(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/map/invoked-as-method.js new file mode 100644 index 00000000000..d03b2a5bd4e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/invoked-as-method.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.18 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + 1. Let O be the this value. + 2. Let valid be ValidateSendableTypedArray(O). + 3. ReturnIfAbrupt(valid). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.map, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.map(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/length.js b/test/sendable/builtins/TypedArray/prototype/map/length.js new file mode 100644 index 00000000000..f36aded276f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + %SendableTypedArray%.prototype.map.length is 1. +info: | + %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.map, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/name.js b/test/sendable/builtins/TypedArray/prototype/map/name.js new file mode 100644 index 00000000000..4beabce9572 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + %SendableTypedArray%.prototype.map.name is "map". +info: | + %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.map, "name", { + value: "map", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/map/not-a-constructor.js new file mode 100644 index 00000000000..e9a65313f14 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.map 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.map), + false, + 'isConstructor(SendableTypedArray.prototype.map) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.map(() => {}); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/map/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/map/prop-desc.js new file mode 100644 index 00000000000..b1ff03e20cf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + "map" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'map', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..fe5c2841522 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + SendableTypedArray.p.map behaves correctly on SendableTypedArrays backed by resizable buffers + that are grown mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return n; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + fixedLength.map(ResizeMidIteration); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + fixedLengthWithOffset.map(ResizeMidIteration); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + lengthTracking.map(ResizeMidIteration); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + lengthTrackingWithOffset.map(ResizeMidIteration); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..8f96c0bdf25 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + SendableTypedArray.p.map behaves correctly on SendableTypedArrays backed by resizable buffers + that are shrunk mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. This version can deal with the undefined values +// resulting by shrinking rab. +function ShrinkMidIteration(n, ix, ta) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + // We still need to return a valid BigInt / non-BigInt, even if + // n is `undefined`. + if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) { + return 0n; + } + return 0; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + fixedLength.map(ShrinkMidIteration); + assert.compareArray(values, [ + 0, + 2, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + fixedLengthWithOffset.map(ShrinkMidIteration); + assert.compareArray(values, [ + 4, + undefined + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + lengthTracking.map(ShrinkMidIteration); + assert.compareArray(values, [ + 0, + 2, + 4, + undefined + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + lengthTrackingWithOffset.map(ShrinkMidIteration); + assert.compareArray(values, [ + 4, + undefined + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer.js new file mode 100644 index 00000000000..791ede6fc34 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer.js @@ -0,0 +1,170 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + SendableTypedArray.p.map behaves as expected on SendableTypedArrays backed by resizable + buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < taWrite.length; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + function MapGathering(array) { + const values = []; + function GatherValues(n, ix) { + assert.sameValue(ix, values.length); + values.push(n); + if (typeof n == 'bigint') { + return n + 1n; + } + return n + 1; + } + const newValues = array.map(GatherValues); + for (let i = 0; i < values.length; ++i) { + if (typeof values[i] == 'bigint') { + assert.sameValue(values[i] + 1n, newValues[i]); + } else { + assert.sameValue(values[i] + 1, newValues[i]); + } + } + return ToNumbers(values); + } + assert.compareArray(MapGathering(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(MapGathering(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(MapGathering(lengthTracking), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(MapGathering(lengthTrackingWithOffset), [ + 4, + 6 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + MapGathering(fixedLength); + }); + assert.throws(TypeError, () => { + MapGathering(fixedLengthWithOffset); + }); + + assert.compareArray(MapGathering(lengthTracking), [ + 0, + 2, + 4 + ]); + assert.compareArray(MapGathering(lengthTrackingWithOffset), [4]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + MapGathering(fixedLength); + }); + assert.throws(TypeError, () => { + MapGathering(fixedLengthWithOffset); + }); + assert.throws(TypeError, () => { + MapGathering(lengthTrackingWithOffset); + }); + + assert.compareArray(MapGathering(lengthTracking), [0]); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + MapGathering(fixedLength); + }); + assert.throws(TypeError, () => { + MapGathering(fixedLengthWithOffset); + }); + assert.throws(TypeError, () => { + MapGathering(lengthTrackingWithOffset); + }); + + assert.compareArray(MapGathering(lengthTracking), []); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert.compareArray(MapGathering(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(MapGathering(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(MapGathering(lengthTracking), [ + 0, + 2, + 4, + 6, + 8, + 10 + ]); + assert.compareArray(MapGathering(lengthTrackingWithOffset), [ + 4, + 6, + 8, + 10 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..5dd59da357c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.map, + 'function', + 'implements SendableTypedArray.prototype.map' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.map(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.map(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the map operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.map(() => {}); + throw new Test262Error('map completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js new file mode 100644 index 00000000000..d327e7b4206 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js @@ -0,0 +1,84 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: Consistent canonicalization of NaN values +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 8. Repeat, while k < len + ... + d. Perform ? Set(A, Pk, mappedValue, true). + ... + + IntegerIndexedElementSet ( O, index, value ) + + Assert: O is an Integer-Indexed exotic object. + If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). + Otherwise, let numValue be ? ToNumber(value). + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then + Let offset be O.[[ByteOffset]]. + Let arrayTypeName be the String value of O.[[TypedArrayName]]. + Let elementSize be the Element Size value specified in Table 62 for arrayTypeName. + Let indexedPosition be (ℝ(index) × elementSize) + offset. + Let elementType be the Element Type value in Table 62 for arrayTypeName. + Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered). + Return NormalCompletion(undefined). + + 24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ , + isLittleEndian ] ) + + ... + 8. If type is "Float32", then + a. Set rawBytes to a List containing the 4 bytes that are the result + of converting value to IEEE 754-2008 binary32 format using “Round to + nearest, ties to even” rounding mode. If isLittleEndian is false, the + bytes are arranged in big endian order. Otherwise, the bytes are + arranged in little endian order. If value is NaN, rawValue may be set + to any implementation chosen IEEE 754-2008 binary64 format Not-a-Number + encoding. An implementation must always choose the same encoding for + each implementation distinguishable NaN value. + 9. Else, if type is "Float64", then + a. Set rawBytes to a List containing the 8 bytes that are the IEEE + 754-2008 binary64 format encoding of value. If isLittleEndian is false, + the bytes are arranged in big endian order. Otherwise, the bytes are + arranged in little endian order. If value is NaN, rawValue may be set + to any implementation chosen IEEE 754-2008 binary32 format Not-a-Number + encoding. An implementation must always choose the same encoding for + each implementation distinguishable NaN value. + ... +includes: [nans.js, testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +function body(FloatArray) { + var sample = new FloatArray(NaNs); + var sampleBytes, resultBytes; + var i = 0; + + var result = sample.map(function() { + return NaNs[i++]; + }); + + sampleBytes = new Uint8Array(sample.buffer); + resultBytes = new Uint8Array(result.buffer); + + assert(compareArray(sampleBytes, resultBytes)); +} + +testWithSendableTypedArrayConstructors(body, floatArrayConstructors); diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js new file mode 100644 index 00000000000..1c63743dde9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Verify conversion values on returned instance +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 8. Repeat, while k < len + ... + d. Perform ? Set(A, Pk, mappedValue, true). + ... + + IntegerIndexedElementSet ( O, index, value ) + + Assert: O is an Integer-Indexed exotic object. + If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). + Otherwise, let numValue be ? ToNumber(value). + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then + Let offset be O.[[ByteOffset]]. + Let arrayTypeName be the String value of O.[[TypedArrayName]]. + Let elementSize be the Element Size value specified in Table 62 for arrayTypeName. + Let indexedPosition be (ℝ(index) × elementSize) + offset. + Let elementType be the Element Type value in Table 62 for arrayTypeName. + Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered). + Return NormalCompletion(undefined). + + 24.1.1.6 SetValueInBuffer ( arrayBuffer, byteIndex, type, value [ , + isLittleEndian ] ) + + ... + 8. If type is "Float32", then + ... + 9. Else, if type is "Float64", then + ... + 10. Else, + ... + b. Let convOp be the abstract operation named in the Conversion Operation + column in Table 50 for Element Type type. + c. Let intValue be convOp(value). + d. If intValue ≥ 0, then + ... + e. Else, + ... +includes: [byteConversionValues.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { + var sample = new TA([initial]); + + var result = sample.map(function() { + return value; + }); + + assert.sameValue(result[0], expected, value + " converts to " + expected); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js new file mode 100644 index 00000000000..7cc07666f25 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Returns a new typedArray instance from the same constructor with the same + length and a new buffer object - testing on an instance with length == 0 +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + 7. Let k be 0. + 8. Repeat, while k < len + ... + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... + 9. Return A. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(0); + + var result = sample.map(function() {}); + + assert.notSameValue(result, sample, "new typedArray object"); + assert.sameValue(result.constructor, TA, "same constructor"); + assert(result instanceof TA, "result is an instance of " + TA.name); + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "result has the same prototype of sample" + ); + assert.sameValue(result.length, 0, "same length"); + assert.notSameValue(result.buffer, sample.buffer, "new buffer"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js new file mode 100644 index 00000000000..c607c292459 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Returns a new typedArray instance from the same constructor with the same + length and a new buffer object - testing on an instance with length > 0 +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + 7. Let k be 0. + 8. Repeat, while k < len + ... + c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). + ... + 9. Return A. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var result = sample.map(function(v) { + return v; + }); + + assert.notSameValue(result, sample, "new typedArray object"); + assert.sameValue(result.constructor, sample.constructor, "same constructor"); + assert.sameValue(result.length, 3, "same length"); + assert.notSameValue(result.buffer, sample.buffer, "new buffer"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js new file mode 100644 index 00000000000..eddf8d9bec1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Throws a TypeError if new typedArray's length < count +info: | + 22.2.3.22 %SendableTypedArray%.prototype.map ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 23.2.4.1 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + 23.2.4.2 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); + const ta = new TA(rab1); + const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); + const lengthTracking = new TA(rab2); + rab2.resize(0); + ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; + assert.throws(TypeError, function() { + ta.map(() => {}); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js new file mode 100644 index 00000000000..b2411295072 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: Return abrupt from SpeciesConstructor's get Constructor +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + var callCount = 0; + + Object.defineProperty(sample, "constructor", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.map(function() { + callCount++; + }); + }); + assert.sameValue(callCount, 0, "callback should not be called"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js new file mode 100644 index 00000000000..bdec5820ad2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: get inherited constructor on SpeciesConstructor +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + var calls = 0; + var result; + + Object.defineProperty(TA.prototype, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.map(function() { + return 0; + }); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + undefined, + "used defaultCtor but still checks the inherited .constructor" + ); + + calls = 6; + result.constructor; + assert.sameValue( + calls, + 7, + "result.constructor triggers the inherited accessor property" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js new file mode 100644 index 00000000000..d2802dd43b2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Throws if O.constructor returns a non-Object and non-undefined value +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + 4. If Type(C) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var callbackfn = function() { return 0; }; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + sample.constructor = 42; + assert.throws(TypeError, function() { + sample.map(callbackfn); + }, "42"); + + sample.constructor = "1"; + assert.throws(TypeError, function() { + sample.map(callbackfn); + }, "string"); + + sample.constructor = null; + assert.throws(TypeError, function() { + sample.map(callbackfn); + }, "null"); + + sample.constructor = NaN; + assert.throws(TypeError, function() { + sample.map(callbackfn); + }, "NaN"); + + sample.constructor = false; + assert.throws(TypeError, function() { + sample.map(callbackfn); + }, "false"); + + sample.constructor = Symbol("1"); + assert.throws(TypeError, function() { + sample.map(callbackfn); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js new file mode 100644 index 00000000000..84960a0fe81 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: get constructor on SpeciesConstructor +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + var calls = 0; + var result; + + Object.defineProperty(sample, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.map(function() { return 0; }); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + TA, + "use defaultCtor on an undefined return - .constructor check" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js new file mode 100644 index 00000000000..e53ad8beaff --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Returns abrupt from get @@species on found constructor +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.map(function() { return 0; }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js new file mode 100644 index 00000000000..207079120e1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Verify arguments on custom @@species construct call +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 42, 42]); + var result, ctorThis; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(count) { + result = arguments; + ctorThis = this; + return new TA(count); + }; + + sample.map(function(v) { return v === 42; }); + + assert.sameValue(result.length, 1, "called with 1 argument"); + assert.sameValue(result[0], 3, "[0] is the length"); + + assert( + ctorThis instanceof sample.constructor[Symbol.species], + "`this` value in the @@species fn is an instance of the function itself" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js new file mode 100644 index 00000000000..3fd1cf8984d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Throws a TypeError if new typedArray's length < count +info: | + 22.2.3.22 %SendableTypedArray%.prototype.map ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 23.2.4.1 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + 23.2.4.2 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + const sample = new TA(2); + const rab = new ArrayBuffer(10, {maxByteLength: 20}); + const lengthTracking = new TA(rab); + rab.resize(0); + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return lengthTracking; + }; + assert.throws(TypeError, function() { + sample.map(() => {}); + }); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js new file mode 100644 index 00000000000..e218c00f467 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Throws a TypeError if new typedArray's length < len +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return new TA(); + }; + + assert.throws(TypeError, function() { + sample.map(function() { return 0; }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js new file mode 100644 index 00000000000..ed59012a4b0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Does not throw a TypeError if new typedArray's length >= len +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var customCount, result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return new TA(customCount); + }; + + customCount = 2; + result = sample.map(function() { return 0; }); + assert.sameValue(result.length, customCount, "length == count"); + + customCount = 5; + result = sample.map(function() { return 0; }); + assert.sameValue(result.length, customCount, "length > count"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js new file mode 100644 index 00000000000..093968a733e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Custom @@species constructor may return a different SendableTypedArray +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testTypedArray.js, compareArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40]); + var otherTA = TA === Int8Array ? Int16Array : Int8Array; + var other = new otherTA([1, 0, 1]); + var result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return other; + }; + + result = sample.map(function(a) { return a + 7; }); + + assert.sameValue(result, other, "returned another typedarray"); + assert(compareArray(result, [47, 0, 1]), "values are set on returned typedarray"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js new file mode 100644 index 00000000000..45fc82e2a19 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Custom @@species constructor throws if it does not return a compatible object +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + sample.constructor[Symbol.species] = Array; + + assert.throws(TypeError, function() { + sample.map(function() {}); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js new file mode 100644 index 00000000000..48918caaa25 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Use custom @@species constructor if available +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testTypedArray.js, compareArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42]); + var calls = 0; + var other, result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(len) { + calls++; + other = new TA(len); + return other; + }; + + result = sample.map(function(a) { return a + 7; }); + + assert.sameValue(calls, 1, "ctor called once"); + assert.sameValue(result, other, "return is instance of custom constructor"); + assert(compareArray(result, [47, 48, 49]), "values are set on the new obj"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js new file mode 100644 index 00000000000..faacd5cc3d7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Throws if returned @@species is not a constructor, null or undefined. +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + 7. If IsConstructor(S) is true, return S. + 8. Throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + sample.constructor[Symbol.species] = 0; + assert.throws(TypeError, function() { + sample.map(function() {}); + }, "0"); + + sample.constructor[Symbol.species] = "string"; + assert.throws(TypeError, function() { + sample.map(function() {}); + }, "string"); + + sample.constructor[Symbol.species] = {}; + assert.throws(TypeError, function() { + sample.map(function() {}); + }, "{}"); + + sample.constructor[Symbol.species] = NaN; + assert.throws(TypeError, function() { + sample.map(function() {}); + }, "NaN"); + + sample.constructor[Symbol.species] = false; + assert.throws(TypeError, function() { + sample.map(function() {}); + }, "false"); + + sample.constructor[Symbol.species] = true; + assert.throws(TypeError, function() { + sample.map(function() {}); + }, "true"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js new file mode 100644 index 00000000000..1c75b92b1b5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Use defaultConstructor if @@species is either undefined or null +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var result; + + sample.constructor = {}; + + result = sample.map(function() {}); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "undefined @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "undefined @@species - ctor check"); + + sample.constructor[Symbol.species] = null; + result = sample.map(function() {}); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "null @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "null @@species - ctor check"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js new file mode 100644 index 00000000000..7332eb8c7c1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + get @@species from found constructor +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + ... + 6. Let A be ? SendableTypedArraySpeciesCreate(O, « len »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var calls = 0; + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + calls++; + } + }); + + sample.map(function() {}); + + assert.sameValue(calls, 1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-grow.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-grow.js new file mode 100644 index 00000000000..767f845c158 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-grow.js @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + SendableTypedArray.p.map behaves correctly on SendableTypedArrays backed by resizable buffers + that are grown by the species constructor. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Returns a function that collects an appropriate typed array into values. Such +// a result can be used as an argument to .map. +function CollectWithUndefined(values) { + return (n, ix, ta) => { + if (typeof n == 'bigint') { + values.push(Number(n)); + } else { + values.push(n); + } + if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) { + // We still need to return a valid BigInt / non-BigInt, even if + // n is `undefined`. + return 0n; + } + return 0; + } +} + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + let resizeWhenConstructorCalled = false; + class MyArray extends ctor { + constructor(...params) { + super(...params); + if (resizeWhenConstructorCalled) { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + } + } + }; + const fixedLength = new MyArray(rab, 0, 4); + resizeWhenConstructorCalled = true; + const values = []; + fixedLength.map(CollectWithUndefined(values)); + assert.compareArray(values, [ + 0, + 1, + 2, + 3 + ]); + assert.sameValue(rab.byteLength, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + let resizeWhenConstructorCalled = false; + class MyArray extends ctor { + constructor(...params) { + super(...params); + if (resizeWhenConstructorCalled) { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + } + } + } + ; + const lengthTracking = new MyArray(rab); + resizeWhenConstructorCalled = true; + const values = []; + lengthTracking.map(CollectWithUndefined(values)); + assert.compareArray(values, [ + 0, + 1, + 2, + 3 + ]); + assert.sameValue(rab.byteLength, 6 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-shrink.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-shrink.js new file mode 100644 index 00000000000..12963e3fe33 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-shrink.js @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + SendableTypedArray.p.map behaves correctly on SendableTypedArrays backed by resizable buffers + that are shrunk by the species constructor. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Returns a function that collects an appropriate typed array into values. Such +// a result can be used as an argument to .map. +function CollectWithUndefined(values) { + return (n, ix, ta) => { + if (typeof n == 'bigint') { + values.push(Number(n)); + } else { + values.push(n); + } + if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) { + // We still need to return a valid BigInt / non-BigInt, even if + // n is `undefined`. + return 0n; + } + return 0; + } +} + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + let resizeWhenConstructorCalled = false; + class MyArray extends ctor { + constructor(...params) { + super(...params); + if (resizeWhenConstructorCalled) { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + } + } + } + ; + const fixedLength = new MyArray(rab, 0, 4); + resizeWhenConstructorCalled = true; + const values = []; + fixedLength.map(CollectWithUndefined(values)); + assert.compareArray(values, [ + undefined, + undefined, + undefined, + undefined + ]); + assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + let resizeWhenConstructorCalled = false; + class MyArray extends ctor { + constructor(...params) { + super(...params); + if (resizeWhenConstructorCalled) { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + } + } + } + ; + const lengthTracking = new MyArray(rab); + resizeWhenConstructorCalled = true; + const values = []; + lengthTracking.map(CollectWithUndefined(values)); + assert.compareArray(values, [ + 0, + 1, + undefined, + undefined + ]); + assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/TypedArray/prototype/map/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/map/this-is-not-object.js new file mode 100644 index 00000000000..9b808c20b20 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/this-is-not-object.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var map = SendableTypedArray.prototype.map; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + map.call(undefined, callbackfn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + map.call(null, callbackfn); +}, "this is null"); + +assert.throws(TypeError, function() { + map.call(42, callbackfn); +}, "this is 42"); + +assert.throws(TypeError, function() { + map.call("1", callbackfn); +}, "this is a string"); + +assert.throws(TypeError, function() { + map.call(true, callbackfn); +}, "this is true"); + +assert.throws(TypeError, function() { + map.call(false, callbackfn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + map.call(s, callbackfn); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..e6ea40132b6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var map = SendableTypedArray.prototype.map; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + map.call({}, callbackfn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + map.call([], callbackfn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + map.call(ab, callbackfn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + map.call(dv, callbackfn); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js new file mode 100644 index 00000000000..d2a2f93b038 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.map +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + sample.map(function(v, i) { + if (i < sample.length - 1) { + sample[i+1] = 42; + } + + assert.sameValue( + v, 42, "method does not cache values before callbackfn calls" + ); + + return 0; + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js new file mode 100644 index 00000000000..d48cf5da2a9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + callbackfn arguments using custom accumulator +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + var results = []; + + sample.reduce(function(accumulator) { + results.push(arguments); + return accumulator + 1; + }, 7); + + assert.sameValue(results.length, 3, "results.length"); + + assert.sameValue(results[0].length, 4, "results[0].length"); + assert.sameValue(results[0][0], 7, "results[0][0] - accumulator"); + assert.sameValue(results[0][1], 42n, "results[0][1] - kValue"); + assert.sameValue(results[0][2], 0, "results[0][2] - k"); + assert.sameValue(results[0][3], sample, "results[0][3] - this"); + + assert.sameValue(results[1].length, 4, "results[1].length"); + assert.sameValue(results[1][0], 8, "results[1][0] - accumulator"); + assert.sameValue(results[1][1], 43n, "results[1][1] - kValue"); + assert.sameValue(results[1][2], 1, "results[1][2] - k"); + assert.sameValue(results[1][3], sample, "results[1][3] - this"); + + assert.sameValue(results[2].length, 4, "results[2].length"); + assert.sameValue(results[2][0], 9, "results[2][0] - accumulator"); + assert.sameValue(results[2][1], 44n, "results[2][1] - kValue"); + assert.sameValue(results[2][2], 2, "results[2][2] - k"); + assert.sameValue(results[2][3], sample, "results[2][3] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js new file mode 100644 index 00000000000..48894cbe8f1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + callbackfn arguments using default accumulator (value at index 0) +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + a. Let kPresent be false. + b. Repeat, while kPresent is false and k < len + ... + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + var results = []; + + sample.reduce(function(accumulator) { + results.push(arguments); + return accumulator - 1n; + }); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0].length, 4, "results[1].length"); + assert.sameValue(results[0][0], 42n, "results[1][0] - accumulator"); + assert.sameValue(results[0][1], 43n, "results[1][1] - kValue"); + assert.sameValue(results[0][2], 1, "results[1][2] - k"); + assert.sameValue(results[0][3], sample, "results[1][3] - this"); + + assert.sameValue(results[1].length, 4, "results[2].length"); + assert.sameValue(results[1][0], 41n, "results[2][0] - accumulator"); + assert.sameValue(results[1][1], 44n, "results[2][1] - kValue"); + assert.sameValue(results[1][2], 2, "results[2][2] - k"); + assert.sameValue(results[1][3], sample, "results[2][3] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js new file mode 100644 index 00000000000..63ca28cffdd --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Instance buffer can be detached during loop +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [detachArrayBuffer.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.reduce(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + return true; + }, 0); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js new file mode 100644 index 00000000000..1f194d9e398 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Throws TypeError if callbackfn is not callable +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 3. If IsCallable(callbackfn) is false, throw a TypeError exception. + 4. If len is 0 and initialValue is not present, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(TypeError, function() { + sample.reduce(); + }, "no arg"); + + assert.throws(TypeError, function() { + sample.reduce(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.reduce(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.reduce({}); + }, "{}"); + + assert.throws(TypeError, function() { + sample.reduce(1); + }, "1"); + + assert.throws(TypeError, function() { + sample.reduce(NaN); + }, "NaN"); + + assert.throws(TypeError, function() { + sample.reduce(""); + }, "string"); + + assert.throws(TypeError, function() { + sample.reduce(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.reduce(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.reduce(Symbol("")); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js new file mode 100644 index 00000000000..7731c264027 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Does not iterate over non-integer properties +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7n, 8n]); + + var results = []; + + sample.foo = 42; + sample[Symbol("1")] = 43; + + sample.reduce(function() { + results.push(arguments); + }, 0); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0][2], 0, "results[0][2] - k"); + assert.sameValue(results[1][2], 1, "results[1][2] - k"); + + assert.sameValue(results[0][1], 7n, "results[0][1] - kValue"); + assert.sameValue(results[1][1], 8n, "results[1][1] - kValue"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js new file mode 100644 index 00000000000..3390a426634 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + callbackfn is not called on empty instances +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 4. If len is 0 and initialValue is not present, throw a TypeError exception. + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var called = 0; + + new TA().reduce(function() { + called++; + }, undefined); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js new file mode 100644 index 00000000000..8469d8c168d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + The callbackfn return does not change the `this` instance +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([0n, 1n, 0n]); + + sample.reduce(function() { + return 42; + }, 7); + + assert.sameValue(sample[0], 0n, "[0] == 0"); + assert.sameValue(sample[1], 1n, "[1] == 1"); + assert.sameValue(sample[2], 0n, "[2] == 0"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js new file mode 100644 index 00000000000..6ad8524d03f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Returns abrupt from callbackfn +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + assert.throws(Test262Error, function() { + sample.reduce(function() { + throw new Test262Error(); + }); + }); + + assert.throws(Test262Error, function() { + sample.reduce(function() { + throw new Test262Error(); + }, 0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js new file mode 100644 index 00000000000..60d58b6ac76 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Reflect.set, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + var newVal = 0n; + + sample.reduce(function(acc, val, i) { + if (i > 0) { + assert.sameValue( + sample[i - 1], newVal - 1n, + "get the changed value during the loop" + ); + assert.sameValue( + Reflect.set(sample, 0, 7n), + true, + "re-set a value for sample[0]" + ); + } + assert.sameValue( + Reflect.set(sample, i, newVal), + true, + "set value during iteration" + ); + + newVal++; + }, 0); + + assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7"); + assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1"); + assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js new file mode 100644 index 00000000000..455018d64d0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + callbackfn `this` value +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var expected = (function() { return this; })(); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var results = []; + + sample.reduce(function() { + results.push(this); + }, 0); + + assert.sameValue(results.length, 3, "results.length"); + assert.sameValue(results[0], expected, "[0]"); + assert.sameValue(results[1], expected, "[1]"); + assert.sameValue(results[2], expected, "[2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/detached-buffer.js new file mode 100644 index 00000000000..f08a1b399c1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var callbackfn = function() { + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.reduce(callbackfn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js new file mode 100644 index 00000000000..1cce363392c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Returns given initialValue on empty instances without calling callbackfn +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k < len + ... + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Increase k by 1. + ... + 8. Repeat, while k < len + ... + 9. Return accumulator. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var called = false; + var result = new TA().reduce(function() { + called = true; + }, 42); + + assert.sameValue(result, 42); + assert.sameValue(called, false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js new file mode 100644 index 00000000000..e89454ebbcb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + If len is 0 and initialValue is not present, throw a TypeError exception. +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 4. If len is 0 and initialValue is not present, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var called = 0; + + assert.throws(TypeError, function() { + new TA().reduce(function() { + called++; + }); + }); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..68ddd43f826 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n]); + var calls = 0; + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.reduce(function() { + calls++; + }, 0); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert.sameValue(calls, 2, "iterations are not affected by custom length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js new file mode 100644 index 00000000000..863c4c67e65 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Returns last accumulator value +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k < len + ... + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Increase k by 1. + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + 9. Return accumulator. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var calls, result; + + calls = 0; + result = new TA([1n, 2n, 3n]).reduce(function() { + calls++; + + if (calls == 2) { + return 42; + } + }); + assert.sameValue(result, 42, "using default accumulator"); + + calls = 0; + result = new TA([1n, 2n, 3n]).reduce(function() { + calls++; + + if (calls == 3) { + return 7; + } + }, 0); + assert.sameValue(result, 7, "using custom accumulator"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js new file mode 100644 index 00000000000..b9c0c2e8076 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Result can be of any type without any number conversions +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k < len + ... + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Increase k by 1. + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + 9. Return accumulator. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + [ + ["test262", "string"], + ["", "empty string"], + [undefined, "undefined"], + [null, "null"], + [-0, "-0"], + [42, "integer"], + [NaN, "NaN"], + [Infinity, "Infinity"], + [0.6, "float number"], + [true, "true"], + [false, "false"], + [Symbol(""), "symbol"], + [{}, "object"] + ].forEach(function(item) { + var result; + + result = sample.reduce(function() { + return item[0]; + }); + assert.sameValue(result, item[0], item[1] + " - using default accumulator"); + + result = sample.reduce(function() { + return item[0]; + }, 0); + + assert.sameValue(result, item[0], item[1] + " - using custom accumulator"); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..bbbdb91b76c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.reduce, + 'function', + 'implements SendableTypedArray.prototype.reduce' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.reduce(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.reduce(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the reduce operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.reduce(() => {}); + throw new Test262Error('reduce completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js new file mode 100644 index 00000000000..cd22b7102a7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Returns [0] without calling callbackfn if length is 1 and initialValue is not + present. +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k < len + ... + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Increase k by 1. + ... + 8. Repeat, while k < len + ... + 9. Return accumulator. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var called = false; + var result = new TA([42n]).reduce(function() { + called = true; + }); + + assert.sameValue(result, 42n); + assert.sameValue(called, false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js new file mode 100644 index 00000000000..033063000a1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Integer indexed values are not cached before iteration +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + sample.reduce(function(a, v, i) { + if (i < sample.length - 1) { + sample[i+1] = 42n; + } + + assert.sameValue( + v, 42n, "method does not cache values before callbackfn calls" + ); + }, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js new file mode 100644 index 00000000000..7f74bec0ae5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + callbackfn arguments using custom accumulator +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + var results = []; + + sample.reduce(function(accumulator) { + results.push(arguments); + return accumulator + 1; + }, 7); + + assert.sameValue(results.length, 3, "results.length"); + + assert.sameValue(results[0].length, 4, "results[0].length"); + assert.sameValue(results[0][0], 7, "results[0][0] - accumulator"); + assert.sameValue(results[0][1], 42, "results[0][1] - kValue"); + assert.sameValue(results[0][2], 0, "results[0][2] - k"); + assert.sameValue(results[0][3], sample, "results[0][3] - this"); + + assert.sameValue(results[1].length, 4, "results[1].length"); + assert.sameValue(results[1][0], 8, "results[1][0] - accumulator"); + assert.sameValue(results[1][1], 43, "results[1][1] - kValue"); + assert.sameValue(results[1][2], 1, "results[1][2] - k"); + assert.sameValue(results[1][3], sample, "results[1][3] - this"); + + assert.sameValue(results[2].length, 4, "results[2].length"); + assert.sameValue(results[2][0], 9, "results[2][0] - accumulator"); + assert.sameValue(results[2][1], 44, "results[2][1] - kValue"); + assert.sameValue(results[2][2], 2, "results[2][2] - k"); + assert.sameValue(results[2][3], sample, "results[2][3] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js new file mode 100644 index 00000000000..76312163638 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + callbackfn arguments using default accumulator (value at index 0) +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + a. Let kPresent be false. + b. Repeat, while kPresent is false and k < len + ... + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + var results = []; + + sample.reduce(function(accumulator) { + results.push(arguments); + return accumulator - 1; + }); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0].length, 4, "results[1].length"); + assert.sameValue(results[0][0], 42, "results[1][0] - accumulator"); + assert.sameValue(results[0][1], 43, "results[1][1] - kValue"); + assert.sameValue(results[0][2], 1, "results[1][2] - k"); + assert.sameValue(results[0][3], sample, "results[1][3] - this"); + + assert.sameValue(results[1].length, 4, "results[2].length"); + assert.sameValue(results[1][0], 41, "results[2][0] - accumulator"); + assert.sameValue(results[1][1], 44, "results[2][1] - kValue"); + assert.sameValue(results[1][2], 2, "results[2][2] - k"); + assert.sameValue(results[1][3], sample, "results[2][3] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js new file mode 100644 index 00000000000..dbe75c977c6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Instance buffer can be detached during loop +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [detachArrayBuffer.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.reduce(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + return true; + }, 0); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js new file mode 100644 index 00000000000..f6eb00b41d0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Throws TypeError if callbackfn is not callable +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 3. If IsCallable(callbackfn) is false, throw a TypeError exception. + 4. If len is 0 and initialValue is not present, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(TypeError, function() { + sample.reduce(); + }, "no arg"); + + assert.throws(TypeError, function() { + sample.reduce(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.reduce(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.reduce({}); + }, "{}"); + + assert.throws(TypeError, function() { + sample.reduce(1); + }, "1"); + + assert.throws(TypeError, function() { + sample.reduce(NaN); + }, "NaN"); + + assert.throws(TypeError, function() { + sample.reduce(""); + }, "string"); + + assert.throws(TypeError, function() { + sample.reduce(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.reduce(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.reduce(Symbol("")); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js new file mode 100644 index 00000000000..a0847608e47 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Does not iterate over non-integer properties +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7, 8]); + + var results = []; + + sample.foo = 42; + sample[Symbol("1")] = 43; + + sample.reduce(function() { + results.push(arguments); + }, 0); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0][2], 0, "results[0][2] - k"); + assert.sameValue(results[1][2], 1, "results[1][2] - k"); + + assert.sameValue(results[0][1], 7, "results[0][1] - kValue"); + assert.sameValue(results[1][1], 8, "results[1][1] - kValue"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js new file mode 100644 index 00000000000..1565adbdd68 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + callbackfn is not called on empty instances +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 4. If len is 0 and initialValue is not present, throw a TypeError exception. + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var called = 0; + + new TA().reduce(function() { + called++; + }, undefined); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js new file mode 100644 index 00000000000..78c676227ee --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: Instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 3}); + var sample = new TA(buffer); + var finalNext, expectedPrevs, expectedNexts, expectedIndices, expectedArrays; + var prevs, nexts, indices, arrays, result; + + prevs = []; + nexts = []; + indices = []; + arrays = []; + result = sample.reduce(function(prev, next, index, array) { + if (prevs.length === 0) { + try { + buffer.resize(2 * BPE); + finalNext = undefined; + expectedPrevs = [262, 0]; + expectedNexts = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + finalNext = 0; + expectedPrevs = [262, 0, 1]; + expectedNexts = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + prevs.push(prev); + nexts.push(next); + indices.push(index); + arrays.push(array); + return index; + }, 262); + + assert.compareArray(prevs, [262, 0, 1], 'prevs (shrink)'); + assert.compareArray(nexts, [0, 0, finalNext], 'nexts (shrink)'); + assert.compareArray(indices, [0, 1, 2], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, 2, 'result (shrink)'); + + prevs = []; + nexts = []; + indices = []; + arrays = []; + result = sample.reduce(function(prev, next, index, array) { + if (prevs.length === 0) { + try { + buffer.resize(3 * BPE); + } catch (_) {} + } + + prevs.push(prev); + nexts.push(next); + indices.push(index); + arrays.push(array); + return index; + }, 262); + + assert.compareArray(prevs, expectedPrevs, 'prevs (grow)'); + assert.compareArray(nexts, expectedNexts, 'nexts (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, expectedIndices[expectedIndices.length - 1], 'result (grow)'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js new file mode 100644 index 00000000000..c37177a98b8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + The callbackfn return does not change the `this` instance +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([0, 1, 0]); + + sample.reduce(function() { + return 42; + }, 7); + + assert.sameValue(sample[0], 0, "[0] == 0"); + assert.sameValue(sample[1], 1, "[1] == 1"); + assert.sameValue(sample[2], 0, "[2] == 0"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js new file mode 100644 index 00000000000..e7541755e68 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Returns abrupt from callbackfn +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + assert.throws(Test262Error, function() { + sample.reduce(function() { + throw new Test262Error(); + }); + }); + + assert.throws(Test262Error, function() { + sample.reduce(function() { + throw new Test262Error(); + }, 0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js new file mode 100644 index 00000000000..c37a287332c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) +includes: [testTypedArray.js] +features: [Reflect.set, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + var newVal = 0; + + sample.reduce(function(acc, val, i) { + if (i > 0) { + assert.sameValue( + sample[i - 1], newVal - 1, + "get the changed value during the loop" + ); + assert.sameValue( + Reflect.set(sample, 0, 7), + true, + "re-set a value for sample[0]" + ); + } + assert.sameValue( + Reflect.set(sample, i, newVal), + true, + "set value during iteration" + ); + + newVal++; + }, 0); + + assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7"); + assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1"); + assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js new file mode 100644 index 00000000000..ea166720836 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + callbackfn `this` value +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var expected = (function() { return this; })(); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var results = []; + + sample.reduce(function() { + results.push(this); + }, 0); + + assert.sameValue(results.length, 3, "results.length"); + assert.sameValue(results[0], expected, "[0]"); + assert.sameValue(results[1], expected, "[1]"); + assert.sameValue(results[2], expected, "[2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js new file mode 100644 index 00000000000..44e1eb68f43 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var callbackfn = function() { + throw new Test262Error(); +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.reduce(callbackfn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js new file mode 100644 index 00000000000..42311f5d09f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Returns given initialValue on empty instances without calling callbackfn +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k < len + ... + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Increase k by 1. + ... + 8. Repeat, while k < len + ... + 9. Return accumulator. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var called = false; + var result = new TA().reduce(function() { + called = true; + }, 42); + + assert.sameValue(result, 42); + assert.sameValue(called, false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js new file mode 100644 index 00000000000..26fcfe8bf0c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + If len is 0 and initialValue is not present, throw a TypeError exception. +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 4. If len is 0 and initialValue is not present, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var called = 0; + + assert.throws(TypeError, function() { + new TA().reduce(function() { + called++; + }); + }); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..d6a70e09894 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43]); + var calls = 0; + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.reduce(function() { + calls++; + }, 0); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert.sameValue(calls, 2, "iterations are not affected by custom length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-func.js new file mode 100644 index 00000000000..5e1ab17b48f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-func.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.19 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var reduce = SendableTypedArray.prototype.reduce; + +assert.sameValue(typeof reduce, 'function'); + +assert.throws(TypeError, function() { + reduce(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-method.js new file mode 100644 index 00000000000..22c762ec797 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-method.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.19 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.reduce, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.reduce(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/length.js b/test/sendable/builtins/TypedArray/prototype/reduce/length.js new file mode 100644 index 00000000000..9beb5dbf6a8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + %SendableTypedArray%.prototype.reduce.length is 1. +info: | + %SendableTypedArray%.prototype.reduce ( callbackfn [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.reduce, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/name.js b/test/sendable/builtins/TypedArray/prototype/reduce/name.js new file mode 100644 index 00000000000..deb5073cc76 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + %SendableTypedArray%.prototype.reduce.name is "reduce". +info: | + %SendableTypedArray%.prototype.reduce ( callbackfn [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.reduce, "name", { + value: "reduce", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/reduce/not-a-constructor.js new file mode 100644 index 00000000000..93f80de2aeb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.reduce 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.reduce), + false, + 'isConstructor(SendableTypedArray.prototype.reduce) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.reduce(() => {}, []); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/reduce/prop-desc.js new file mode 100644 index 00000000000..454c112f12e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + "reduce" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'reduce', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..3dbb6ea2738 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + SendableTypedArray.p.reduce behaves correctly on SendableTypedArrays backed by resizable + buffers that are grown mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(acc, n) { + // Returns true by default. + return CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + fixedLength.reduce(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + fixedLengthWithOffset.reduce(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + lengthTracking.reduce(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + lengthTrackingWithOffset.reduce(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..404c9fe4d09 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + SendableTypedArray.p.reduce behaves correctly on SendableTypedArrays backed by resizable + buffers that are shrunk mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(acc, n) { + return CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + fixedLength.reduce(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 0, + 2, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + fixedLengthWithOffset.reduce(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 4, + undefined + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + lengthTracking.reduce(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 0, + 2, + 4, + undefined + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + lengthTrackingWithOffset.reduce(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 4, + undefined + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer.js new file mode 100644 index 00000000000..4fbcf4ed2b8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer.js @@ -0,0 +1,157 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + SendableTypedArray.p.reduce behaves correctly on SendableTypedArrays backed by resizable + buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + function ReduceCollecting(array) { + const reduceValues = []; + array.reduce((acc, n) => { + reduceValues.push(n); + }, 'initial value'); + return ToNumbers(reduceValues); + } + assert.compareArray(ReduceCollecting(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ReduceCollecting(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(ReduceCollecting(lengthTracking), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ReduceCollecting(lengthTrackingWithOffset), [ + 4, + 6 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + ReduceCollecting(fixedLength); + }); + assert.throws(TypeError, () => { + ReduceCollecting(fixedLengthWithOffset); + }); + + assert.compareArray(ReduceCollecting(lengthTracking), [ + 0, + 2, + 4 + ]); + assert.compareArray(ReduceCollecting(lengthTrackingWithOffset), [4]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + ReduceCollecting(fixedLength); + }); + assert.throws(TypeError, () => { + ReduceCollecting(fixedLengthWithOffset); + }); + assert.throws(TypeError, () => { + ReduceCollecting(lengthTrackingWithOffset); + }); + + assert.compareArray(ReduceCollecting(lengthTracking), [0]); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + ReduceCollecting(fixedLength); + }); + assert.throws(TypeError, () => { + ReduceCollecting(fixedLengthWithOffset); + }); + assert.throws(TypeError, () => { + ReduceCollecting(lengthTrackingWithOffset); + }); + + assert.compareArray(ReduceCollecting(lengthTracking), []); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert.compareArray(ReduceCollecting(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ReduceCollecting(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(ReduceCollecting(lengthTracking), [ + 0, + 2, + 4, + 6, + 8, + 10 + ]); + assert.compareArray(ReduceCollecting(lengthTrackingWithOffset), [ + 4, + 6, + 8, + 10 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js b/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js new file mode 100644 index 00000000000..156b2d09864 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Returns last accumulator value +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k < len + ... + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Increase k by 1. + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + 9. Return accumulator. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var calls, result; + + calls = 0; + result = new TA([1, 2, 3]).reduce(function() { + calls++; + + if (calls == 2) { + return 42; + } + }); + assert.sameValue(result, 42, "using default accumulator"); + + calls = 0; + result = new TA([1, 2, 3]).reduce(function() { + calls++; + + if (calls == 3) { + return 7; + } + }, 0); + assert.sameValue(result, 7, "using custom accumulator"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js b/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js new file mode 100644 index 00000000000..945394c4bc2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Result can be of any type without any number conversions +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k < len + ... + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Increase k by 1. + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + 9. Return accumulator. +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + [ + ["test262", "string"], + ["", "empty string"], + [undefined, "undefined"], + [null, "null"], + [-0, "-0"], + [42, "integer"], + [NaN, "NaN"], + [Infinity, "Infinity"], + [0.6, "float number"], + [true, "true"], + [false, "false"], + [Symbol(""), "symbol"], + [{}, "object"] + ].forEach(function(item) { + var result; + + result = sample.reduce(function() { + return item[0]; + }); + assert.sameValue(result, item[0], item[1] + " - using default accumulator"); + + result = sample.reduce(function() { + return item[0]; + }, 0); + + assert.sameValue(result, item[0], item[1] + " - using custom accumulator"); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..202518ef358 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.reduce, + 'function', + 'implements SendableTypedArray.prototype.reduce' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.reduce(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.reduce(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the reduce operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.reduce(() => {}); + throw new Test262Error('reduce completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js b/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js new file mode 100644 index 00000000000..f68808bb9de --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Returns [0] without calling callbackfn if length is 1 and initialValue is not + present. +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k < len + ... + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Increase k by 1. + ... + 8. Repeat, while k < len + ... + 9. Return accumulator. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var called = false; + var result = new TA([42]).reduce(function() { + called = true; + }); + + assert.sameValue(result, 42); + assert.sameValue(called, false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-object.js new file mode 100644 index 00000000000..f8e64f6e212 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-object.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var reduce = SendableTypedArray.prototype.reduce; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + reduce.call(undefined, callbackfn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + reduce.call(null, callbackfn); +}, "this is null"); + +assert.throws(TypeError, function() { + reduce.call(42, callbackfn); +}, "this is 42"); + +assert.throws(TypeError, function() { + reduce.call("1", callbackfn); +}, "this is a string"); + +assert.throws(TypeError, function() { + reduce.call(true, callbackfn); +}, "this is true"); + +assert.throws(TypeError, function() { + reduce.call(false, callbackfn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + reduce.call(s, callbackfn); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..e3cdb3ee728 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var reduce = SendableTypedArray.prototype.reduce; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + reduce.call({}, callbackfn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + reduce.call([], callbackfn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + reduce.call(ab, callbackfn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + reduce.call(dv, callbackfn); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js new file mode 100644 index 00000000000..d55708bf0c4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduce +description: > + Integer indexed values are not cached before iteration +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduce is a distinct function that implements the same + algorithm as Array.prototype.reduce as defined in 22.1.3.19 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + sample.reduce(function(a, v, i) { + if (i < sample.length - 1) { + sample[i+1] = 42; + } + + assert.sameValue( + v, 42, "method does not cache values before callbackfn calls" + ); + }, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js new file mode 100644 index 00000000000..6288454260f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + callbackfn arguments using custom accumulator +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + var results = []; + + sample.reduceRight(function(accumulator) { + results.push(arguments); + return accumulator + 1; + }, 7); + + assert.sameValue(results.length, 3, "results.length"); + + assert.sameValue(results[0].length, 4, "results[0].length"); + assert.sameValue(results[0][0], 7, "results[0][0] - accumulator"); + assert.sameValue(results[0][1], 44n, "results[0][1] - kValue"); + assert.sameValue(results[0][2], 2, "results[0][2] - k"); + assert.sameValue(results[0][3], sample, "results[0][3] - this"); + + assert.sameValue(results[1].length, 4, "results[1].length"); + assert.sameValue(results[1][0], 8, "results[1][0] - accumulator"); + assert.sameValue(results[1][1], 43n, "results[1][1] - kValue"); + assert.sameValue(results[1][2], 1, "results[1][2] - k"); + assert.sameValue(results[1][3], sample, "results[1][3] - this"); + + assert.sameValue(results[2].length, 4, "results[2].length"); + assert.sameValue(results[2][0], 9, "results[2][0] - accumulator"); + assert.sameValue(results[2][1], 42n, "results[2][1] - kValue"); + assert.sameValue(results[2][2], 0, "results[2][2] - k"); + assert.sameValue(results[2][3], sample, "results[2][3] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js new file mode 100644 index 00000000000..a78f98a5037 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + callbackfn arguments using default accumulator (value at last index) +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k ≥ 0 + ... + ii. Let kPresent be ? HasProperty(O, Pk). + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Decrease k by 1. + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + var results = []; + + sample.reduceRight(function(accumulator) { + results.push(arguments); + return accumulator + 1n; + }); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0].length, 4, "results[1].length"); + assert.sameValue(results[0][0], 44n, "results[1][0] - accumulator"); + assert.sameValue(results[0][1], 43n, "results[1][1] - kValue"); + assert.sameValue(results[0][2], 1, "results[1][2] - k"); + assert.sameValue(results[0][3], sample, "results[1][3] - this"); + + assert.sameValue(results[1].length, 4, "results[2].length"); + assert.sameValue(results[1][0], 45n, "results[2][0] - accumulator"); + assert.sameValue(results[1][1], 42n, "results[2][1] - kValue"); + assert.sameValue(results[1][2], 0, "results[2][2] - k"); + assert.sameValue(results[1][3], sample, "results[2][3] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js new file mode 100644 index 00000000000..2cab666717c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Instance buffer can be detached during loop +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [detachArrayBuffer.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.reduceRight(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + return true; + }, 0); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js new file mode 100644 index 00000000000..3d0f49e3bb7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Throws TypeError if callbackfn is not callable +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 3. If IsCallable(callbackfn) is false, throw a TypeError exception. + 4. If len is 0 and initialValue is not present, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(TypeError, function() { + sample.reduceRight(); + }, "no arg"); + + assert.throws(TypeError, function() { + sample.reduceRight(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.reduceRight(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.reduceRight({}); + }, "{}"); + + assert.throws(TypeError, function() { + sample.reduceRight(1); + }, "1"); + + assert.throws(TypeError, function() { + sample.reduceRight(NaN); + }, "NaN"); + + assert.throws(TypeError, function() { + sample.reduceRight(""); + }, "string"); + + assert.throws(TypeError, function() { + sample.reduceRight(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.reduceRight(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.reduceRight(Symbol("")); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js new file mode 100644 index 00000000000..93eb4ad7945 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Does not iterate over non-integer properties +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7n, 8n]); + + var results = []; + + sample.foo = 42; + sample[Symbol("1")] = 43; + + sample.reduceRight(function() { + results.push(arguments); + }, 0); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0][2], 1, "results[0][2] - k"); + assert.sameValue(results[1][2], 0, "results[1][2] - k"); + + assert.sameValue(results[0][1], 8n, "results[0][1] - kValue"); + assert.sameValue(results[1][1], 7n, "results[1][1] - kValue"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js new file mode 100644 index 00000000000..55953229b50 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + callbackfn is not called on empty instances +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 4. If len is 0 and initialValue is not present, throw a TypeError exception. + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var called = 0; + + new TA().reduceRight(function() { + called++; + }, undefined); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js new file mode 100644 index 00000000000..b16c7184026 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + The callbackfn return does not change the `this` instance +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([0n, 1n, 0n]); + + sample.reduceRight(function() { + return 42; + }, 7); + + assert.sameValue(sample[0], 0n, "[0] == 0"); + assert.sameValue(sample[1], 1n, "[1] == 1"); + assert.sameValue(sample[2], 0n, "[2] == 0"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js new file mode 100644 index 00000000000..2d9710cb9e6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Returns abrupt from callbackfn +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + assert.throws(Test262Error, function() { + sample.reduceRight(function() { + throw new Test262Error(); + }); + }); + + assert.throws(Test262Error, function() { + sample.reduceRight(function() { + throw new Test262Error(); + }, 0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js new file mode 100644 index 00000000000..5e4af5486dc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Reflect.set, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + var newVal = 0n; + + sample.reduceRight(function(acc, val, i) { + if (i < sample.length - 1) { + assert.sameValue( + sample[i + 1], newVal - 1n, + "get the changed value during the loop" + ); + assert.sameValue( + Reflect.set(sample, 2, 7n), + true, + "re-set a value for sample[2]" + ); + } + assert.sameValue( + Reflect.set(sample, i, newVal), + true, + "set value during iteration" + ); + + newVal++; + }, 0); + + assert.sameValue(sample[0], 2n, "changed values after iteration [0] == 2"); + assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1"); + assert.sameValue(sample[2], 7n, "changed values after iteration [2] == 7"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js new file mode 100644 index 00000000000..e7605677b1b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + callbackfn `this` value +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var expected = (function() { return this; })(); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var results = []; + + sample.reduceRight(function() { + results.push(this); + }, 0); + + assert.sameValue(results.length, 3, "results.length"); + assert.sameValue(results[0], expected, "[0]"); + assert.sameValue(results[1], expected, "[1]"); + assert.sameValue(results[2], expected, "[2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js new file mode 100644 index 00000000000..e8b34e96dd5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var callbackfn = function() { + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.reduceRight(callbackfn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js new file mode 100644 index 00000000000..4a66f5e3df7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Returns given initialValue on empty instances without calling callbackfn +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k ≥ 0 + ... + ii. Let kPresent be ? HasProperty(O, Pk). + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Decrease k by 1. + ... + 8. Repeat, while k ≥ 0 + ... + 9. Return accumulator. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var called = false; + var result = new TA().reduceRight(function() { + called = true; + }, 42); + + assert.sameValue(result, 42); + assert.sameValue(called, false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js new file mode 100644 index 00000000000..51cf39dad56 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + If len is 0 and initialValue is not present, throw a TypeError exception. +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 4. If len is 0 and initialValue is not present, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var called = 0; + + assert.throws(TypeError, function() { + new TA().reduceRight(function() { + called++; + }); + }); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..d989bdd11e4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n]); + var calls = 0; + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.reduceRight(function() { + calls++; + }, 0); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert.sameValue(calls, 2, "iterations are not affected by custom length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js new file mode 100644 index 00000000000..3f54374cd7e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Returns last accumulator value +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k ≥ 0 + ... + ii. Let kPresent be ? HasProperty(O, Pk). + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Decrease k by 1. + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + 9. Return accumulator. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var calls, result; + + calls = 0; + result = new TA([1n, 2n, 3n]).reduceRight(function() { + calls++; + + if (calls == 2) { + return 42; + } + }); + assert.sameValue(result, 42, "using default accumulator"); + + calls = 0; + result = new TA([1n, 2n, 3n]).reduceRight(function() { + calls++; + + if (calls == 3) { + return 7; + } + }, 0); + assert.sameValue(result, 7, "using custom accumulator"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js new file mode 100644 index 00000000000..c28e086ac06 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Result can be of any type without any number conversions +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k ≥ 0 + ... + ii. Let kPresent be ? HasProperty(O, Pk). + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Decrease k by 1. + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + 9. Return accumulator. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + [ + ["test262", "string"], + ["", "empty string"], + [undefined, "undefined"], + [null, "null"], + [-0, "-0"], + [42, "integer"], + [NaN, "NaN"], + [Infinity, "Infinity"], + [0.6, "float number"], + [true, "true"], + [false, "false"], + [Symbol(""), "symbol"], + [{}, "object"] + ].forEach(function(item) { + var result; + + result = sample.reduceRight(function() { + return item[0]; + }); + assert.sameValue(result, item[0], item[1] + " - using default accumulator"); + + result = sample.reduceRight(function() { + return item[0]; + }, 0); + + assert.sameValue(result, item[0], item[1] + " - using custom accumulator"); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..8cbf37062d4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.reduceRight, + 'function', + 'implements SendableTypedArray.prototype.reduceRight' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.reduceRight(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.reduceRight(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the reduceRight operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.reduceRight(() => {}); + throw new Test262Error('reduceRight completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js new file mode 100644 index 00000000000..c371663da8c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Returns [0] without calling callbackfn if length is 1 and initialValue is not + present. +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k ≥ 0 + ... + ii. Let kPresent be ? HasProperty(O, Pk). + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Decrease k by 1. + ... + 8. Repeat, while k ≥ 0 + ... + 9. Return accumulator. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var called = false; + var result = new TA([42n]).reduceRight(function() { + called = true; + }); + + assert.sameValue(result, 42n); + assert.sameValue(called, false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js new file mode 100644 index 00000000000..4d94ed892a6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Integer indexed values are not cached before iteration +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([44n, 43n, 42n]); + + sample.reduceRight(function(a, v, i) { + if (i > 0) { + sample[i-1] = 42n; + } + + assert.sameValue( + v, 42n, "method does not cache values before callbackfn calls" + ); + }, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js new file mode 100644 index 00000000000..f3a2bf2e5e3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + callbackfn arguments using custom accumulator +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + var results = []; + + sample.reduceRight(function(accumulator) { + results.push(arguments); + return accumulator + 1; + }, 7); + + assert.sameValue(results.length, 3, "results.length"); + + assert.sameValue(results[0].length, 4, "results[0].length"); + assert.sameValue(results[0][0], 7, "results[0][0] - accumulator"); + assert.sameValue(results[0][1], 44, "results[0][1] - kValue"); + assert.sameValue(results[0][2], 2, "results[0][2] - k"); + assert.sameValue(results[0][3], sample, "results[0][3] - this"); + + assert.sameValue(results[1].length, 4, "results[1].length"); + assert.sameValue(results[1][0], 8, "results[1][0] - accumulator"); + assert.sameValue(results[1][1], 43, "results[1][1] - kValue"); + assert.sameValue(results[1][2], 1, "results[1][2] - k"); + assert.sameValue(results[1][3], sample, "results[1][3] - this"); + + assert.sameValue(results[2].length, 4, "results[2].length"); + assert.sameValue(results[2][0], 9, "results[2][0] - accumulator"); + assert.sameValue(results[2][1], 42, "results[2][1] - kValue"); + assert.sameValue(results[2][2], 0, "results[2][2] - k"); + assert.sameValue(results[2][3], sample, "results[2][3] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js new file mode 100644 index 00000000000..6d383a11e7c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + callbackfn arguments using default accumulator (value at last index) +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k ≥ 0 + ... + ii. Let kPresent be ? HasProperty(O, Pk). + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Decrease k by 1. + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + var results = []; + + sample.reduceRight(function(accumulator) { + results.push(arguments); + return accumulator + 1; + }); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0].length, 4, "results[1].length"); + assert.sameValue(results[0][0], 44, "results[1][0] - accumulator"); + assert.sameValue(results[0][1], 43, "results[1][1] - kValue"); + assert.sameValue(results[0][2], 1, "results[1][2] - k"); + assert.sameValue(results[0][3], sample, "results[1][3] - this"); + + assert.sameValue(results[1].length, 4, "results[2].length"); + assert.sameValue(results[1][0], 45, "results[2][0] - accumulator"); + assert.sameValue(results[1][1], 42, "results[2][1] - kValue"); + assert.sameValue(results[1][2], 0, "results[2][2] - k"); + assert.sameValue(results[1][3], sample, "results[2][3] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js new file mode 100644 index 00000000000..9063ee6c453 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Instance buffer can be detached during loop +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [detachArrayBuffer.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.reduceRight(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + return true; + }, 0); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js new file mode 100644 index 00000000000..236f2e5f803 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Throws TypeError if callbackfn is not callable +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 3. If IsCallable(callbackfn) is false, throw a TypeError exception. + 4. If len is 0 and initialValue is not present, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + + assert.throws(TypeError, function() { + sample.reduceRight(); + }, "no arg"); + + assert.throws(TypeError, function() { + sample.reduceRight(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.reduceRight(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.reduceRight({}); + }, "{}"); + + assert.throws(TypeError, function() { + sample.reduceRight(1); + }, "1"); + + assert.throws(TypeError, function() { + sample.reduceRight(NaN); + }, "NaN"); + + assert.throws(TypeError, function() { + sample.reduceRight(""); + }, "string"); + + assert.throws(TypeError, function() { + sample.reduceRight(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.reduceRight(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.reduceRight(Symbol("")); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js new file mode 100644 index 00000000000..f1610995d2a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Does not iterate over non-integer properties +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7, 8]); + + var results = []; + + sample.foo = 42; + sample[Symbol("1")] = 43; + + sample.reduceRight(function() { + results.push(arguments); + }, 0); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0][2], 1, "results[0][2] - k"); + assert.sameValue(results[1][2], 0, "results[1][2] - k"); + + assert.sameValue(results[0][1], 8, "results[0][1] - kValue"); + assert.sameValue(results[1][1], 7, "results[1][1] - kValue"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js new file mode 100644 index 00000000000..564fa6d0f11 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + callbackfn is not called on empty instances +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 4. If len is 0 and initialValue is not present, throw a TypeError exception. + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var called = 0; + + new TA().reduceRight(function() { + called++; + }, undefined); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js new file mode 100644 index 00000000000..c8224891c53 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: Instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 3}); + var sample = new TA(buffer); + var secondNext, expectedPrevs, expectedNexts, expectedIndices, expectedArrays; + var prevs, nexts, indices, arrays, result; + + prevs = []; + nexts = []; + indices = []; + arrays = []; + result = sample.reduceRight(function(prev, next, index, array) { + if (prevs.length === 0) { + try { + buffer.resize(BPE); + secondNext = undefined; + expectedPrevs = [262]; + expectedNexts = [0]; + expectedIndices = [0]; + expectedArrays = [sample]; + } catch (_) { + secondNext = 0; + expectedPrevs = [262, 2, 1]; + expectedNexts = [0, 0, 0]; + expectedIndices = [2, 1, 0]; + expectedArrays = [sample, sample, sample]; + } + } + + prevs.push(prev); + nexts.push(next); + indices.push(index); + arrays.push(array); + return index; + }, 262); + + assert.compareArray(prevs, [262, 2, 1], 'prevs (shrink)'); + assert.compareArray(nexts, [0, secondNext, 0], 'nexts (shrink)'); + assert.compareArray(indices, [2, 1, 0], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, 0, 'result (shrink)'); + + prevs = []; + nexts = []; + indices = []; + arrays = []; + result = sample.reduceRight(function(prev, next, index, array) { + if (prevs.length === 0) { + try { + buffer.resize(3 * BPE); + } catch (_) {} + } + + prevs.push(prev); + nexts.push(next); + indices.push(index); + arrays.push(array); + return index; + }, 262); + + assert.compareArray(prevs, expectedPrevs, 'prevs (grow)'); + assert.compareArray(nexts, expectedNexts, 'nexts (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, expectedIndices[expectedIndices.length - 1], 'result (grow)'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js new file mode 100644 index 00000000000..9bf09768df6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + The callbackfn return does not change the `this` instance +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([0, 1, 0]); + + sample.reduceRight(function() { + return 42; + }, 7); + + assert.sameValue(sample[0], 0, "[0] == 0"); + assert.sameValue(sample[1], 1, "[1] == 1"); + assert.sameValue(sample[2], 0, "[2] == 0"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js new file mode 100644 index 00000000000..88d862069d0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Returns abrupt from callbackfn +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k < len + ... + c. If kPresent is true, then + ... + i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, + k, O »). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + assert.throws(Test262Error, function() { + sample.reduceRight(function() { + throw new Test262Error(); + }); + }); + + assert.throws(Test262Error, function() { + sample.reduceRight(function() { + throw new Test262Error(); + }, 0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js new file mode 100644 index 00000000000..13465ebdec8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) +includes: [testTypedArray.js] +features: [Reflect.set, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + var newVal = 0; + + sample.reduceRight(function(acc, val, i) { + if (i < sample.length - 1) { + assert.sameValue( + sample[i + 1], newVal - 1, + "get the changed value during the loop" + ); + assert.sameValue( + Reflect.set(sample, 2, 7), + true, + "re-set a value for sample[2]" + ); + } + assert.sameValue( + Reflect.set(sample, i, newVal), + true, + "set value during iteration" + ); + + newVal++; + }, 0); + + assert.sameValue(sample[0], 2, "changed values after iteration [0] == 2"); + assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1"); + assert.sameValue(sample[2], 7, "changed values after iteration [2] == 7"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js new file mode 100644 index 00000000000..0ef7056f517 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + callbackfn `this` value +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var expected = (function() { return this; })(); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var results = []; + + sample.reduceRight(function() { + results.push(this); + }, 0); + + assert.sameValue(results.length, 3, "results.length"); + assert.sameValue(results[0], expected, "[0]"); + assert.sameValue(results[1], expected, "[1]"); + assert.sameValue(results[2], expected, "[2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js new file mode 100644 index 00000000000..65c382ded61 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var callbackfn = function() { + throw new Test262Error(); +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.reduceRight(callbackfn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js new file mode 100644 index 00000000000..aff35e4dced --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Returns given initialValue on empty instances without calling callbackfn +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k ≥ 0 + ... + ii. Let kPresent be ? HasProperty(O, Pk). + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Decrease k by 1. + ... + 8. Repeat, while k ≥ 0 + ... + 9. Return accumulator. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var called = false; + var result = new TA().reduceRight(function() { + called = true; + }, 42); + + assert.sameValue(result, 42); + assert.sameValue(called, false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js new file mode 100644 index 00000000000..704c6c748ca --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + If len is 0 and initialValue is not present, throw a TypeError exception. +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 4. If len is 0 and initialValue is not present, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var called = 0; + + assert.throws(TypeError, function() { + new TA().reduceRight(function() { + called++; + }); + }); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..3e3cf412001 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43]); + var calls = 0; + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.reduceRight(function() { + calls++; + }, 0); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert.sameValue(calls, 2, "iterations are not affected by custom length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-func.js new file mode 100644 index 00000000000..b4401eb60fd --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-func.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var reduceRight = SendableTypedArray.prototype.reduceRight; + +assert.sameValue(typeof reduceRight, 'function'); + +assert.throws(TypeError, function() { + reduceRight(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-method.js new file mode 100644 index 00000000000..34ce0388ba4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-method.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.20 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.reduceRight, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.reduceRight(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/length.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/length.js new file mode 100644 index 00000000000..ba49d03cbf9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + %SendableTypedArray%.prototype.reduceRight.length is 1. +info: | + %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.reduceRight, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/name.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/name.js new file mode 100644 index 00000000000..5184319caac --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + %SendableTypedArray%.prototype.reduceRight.name is "reduceRight". +info: | + %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.reduceRight, "name", { + value: "reduceRight", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/not-a-constructor.js new file mode 100644 index 00000000000..34f44426ac8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.reduceRight 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.reduceRight), + false, + 'isConstructor(SendableTypedArray.prototype.reduceRight) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.reduceRight(() => {}, []); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/prop-desc.js new file mode 100644 index 00000000000..436630347d8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + "reduceRight" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'reduceRight', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..f8a9381158f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,97 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + SendableTypedArray.p.reduceRight behaves correctly on SendableTypedArrays backed by resizable + buffers that are grown mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(acc, n) { + return CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +// Test for reduceRight. + +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + fixedLength.reduceRight(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + fixedLengthWithOffset.reduceRight(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 4 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + lengthTracking.reduceRight(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + lengthTrackingWithOffset.reduceRight(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 4 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..eee63523134 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,113 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + SendableTypedArray.p.reduceRight behaves correctly on SendableTypedArrays backed by resizable + buffer that is shrunk mid-iteration +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(acc, n) { + return CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +// Tests for reduceRight. + +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + fixedLength.reduceRight(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 4, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + fixedLengthWithOffset.reduceRight(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + undefined + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + // Unaffected by the shrinking, since we've already iterated past the point. + lengthTracking.reduceRight(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 1; + resizeTo = 2 * ctor.BYTES_PER_ELEMENT; + lengthTracking.reduceRight(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + undefined, + 2, + 0 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + // Unaffected by the shrinking, since we've already iterated past the point. + lengthTrackingWithOffset.reduceRight(ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 4 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer.js new file mode 100644 index 00000000000..ee3aab51c21 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer.js @@ -0,0 +1,158 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + SendableTypedArray.p.reduceRight behaves correctly on SendableTypedArrays backed by resizable + buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + function ReduceRightCollecting(array) { + const reduceRightValues = []; + array.reduceRight((acc, n) => { + reduceRightValues.push(n); + }, 'initial value'); + reduceRightValues.reverse(); + return ToNumbers(reduceRightValues); + } + assert.compareArray(ReduceRightCollecting(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ReduceRightCollecting(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(ReduceRightCollecting(lengthTracking), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ReduceRightCollecting(lengthTrackingWithOffset), [ + 4, + 6 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + ReduceRightCollecting(fixedLength); + }); + assert.throws(TypeError, () => { + ReduceRightCollecting(fixedLengthWithOffset); + }); + + assert.compareArray(ReduceRightCollecting(lengthTracking), [ + 0, + 2, + 4 + ]); + assert.compareArray(ReduceRightCollecting(lengthTrackingWithOffset), [4]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + ReduceRightCollecting(fixedLength); + }); + assert.throws(TypeError, () => { + ReduceRightCollecting(fixedLengthWithOffset); + }); + assert.throws(TypeError, () => { + ReduceRightCollecting(lengthTrackingWithOffset); + }); + + assert.compareArray(ReduceRightCollecting(lengthTracking), [0]); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + ReduceRightCollecting(fixedLength); + }); + assert.throws(TypeError, () => { + ReduceRightCollecting(fixedLengthWithOffset); + }); + assert.throws(TypeError, () => { + ReduceRightCollecting(lengthTrackingWithOffset); + }); + + assert.compareArray(ReduceRightCollecting(lengthTracking), []); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert.compareArray(ReduceRightCollecting(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ReduceRightCollecting(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(ReduceRightCollecting(lengthTracking), [ + 0, + 2, + 4, + 6, + 8, + 10 + ]); + assert.compareArray(ReduceRightCollecting(lengthTrackingWithOffset), [ + 4, + 6, + 8, + 10 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js new file mode 100644 index 00000000000..aa57c33bbab --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Returns last accumulator value +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k ≥ 0 + ... + ii. Let kPresent be ? HasProperty(O, Pk). + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Decrease k by 1. + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + 9. Return accumulator. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var calls, result; + + calls = 0; + result = new TA([1, 2, 3]).reduceRight(function() { + calls++; + + if (calls == 2) { + return 42; + } + }); + assert.sameValue(result, 42, "using default accumulator"); + + calls = 0; + result = new TA([1, 2, 3]).reduceRight(function() { + calls++; + + if (calls == 3) { + return 7; + } + }, 0); + assert.sameValue(result, 7, "using custom accumulator"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js new file mode 100644 index 00000000000..138e700768d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Result can be of any type without any number conversions +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k ≥ 0 + ... + ii. Let kPresent be ? HasProperty(O, Pk). + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Decrease k by 1. + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + 9. Return accumulator. +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + [ + ["test262", "string"], + ["", "empty string"], + [undefined, "undefined"], + [null, "null"], + [-0, "-0"], + [42, "integer"], + [NaN, "NaN"], + [Infinity, "Infinity"], + [0.6, "float number"], + [true, "true"], + [false, "false"], + [Symbol(""), "symbol"], + [{}, "object"] + ].forEach(function(item) { + var result; + + result = sample.reduceRight(function() { + return item[0]; + }); + assert.sameValue(result, item[0], item[1] + " - using default accumulator"); + + result = sample.reduceRight(function() { + return item[0]; + }, 0); + + assert.sameValue(result, item[0], item[1] + " - using custom accumulator"); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..cea732df64c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.reduceRight, + 'function', + 'implements SendableTypedArray.prototype.reduceRight' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.reduceRight(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.reduceRight(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the reduceRight operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.reduceRight(() => {}); + throw new Test262Error('reduceRight completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js new file mode 100644 index 00000000000..b04c27990b1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Returns [0] without calling callbackfn if length is 1 and initialValue is not + present. +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 7. Else initialValue is not present, + ... + b. Repeat, while kPresent is false and k ≥ 0 + ... + ii. Let kPresent be ? HasProperty(O, Pk). + iii. If kPresent is true, then + 1. Let accumulator be ? Get(O, Pk). + iv. Decrease k by 1. + ... + 8. Repeat, while k ≥ 0 + ... + 9. Return accumulator. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var called = false; + var result = new TA([42]).reduceRight(function() { + called = true; + }); + + assert.sameValue(result, 42); + assert.sameValue(called, false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-object.js new file mode 100644 index 00000000000..a3e946b6ab3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-object.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var reduceRight = SendableTypedArray.prototype.reduceRight; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + reduceRight.call(undefined, callbackfn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + reduceRight.call(null, callbackfn); +}, "this is null"); + +assert.throws(TypeError, function() { + reduceRight.call(42, callbackfn); +}, "this is 42"); + +assert.throws(TypeError, function() { + reduceRight.call("1", callbackfn); +}, "this is a string"); + +assert.throws(TypeError, function() { + reduceRight.call(true, callbackfn); +}, "this is true"); + +assert.throws(TypeError, function() { + reduceRight.call(false, callbackfn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + reduceRight.call(s, callbackfn); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..3250c2f86a0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var reduceRight = SendableTypedArray.prototype.reduceRight; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + reduceRight.call({}, callbackfn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + reduceRight.call([], callbackfn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + reduceRight.call(ab, callbackfn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + reduceRight.call(dv, callbackfn); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js new file mode 100644 index 00000000000..3c95c446914 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reduceright +description: > + Integer indexed values are not cached before iteration +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + %SendableTypedArray%.prototype.reduceRight is a distinct function that implements the + same algorithm as Array.prototype.reduceRight as defined in 22.1.3.20 except + that the this object's [[ArrayLength]] internal slot is accessed in place of + performing a [[Get]] of "length". + + 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + + ... + 8. Repeat, while k ≥ 0 + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, + kValue, k, O »). + d. Decrease k by 1. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([44, 43, 42]); + + sample.reduceRight(function(a, v, i) { + if (i > 0) { + sample[i-1] = 42; + } + + assert.sameValue( + v, 42, "method does not cache values before callbackfn calls" + ); + }, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/resizable-and-fixed-have-same-prototype.js b/test/sendable/builtins/TypedArray/prototype/resizable-and-fixed-have-same-prototype.js new file mode 100644 index 00000000000..516c3302aa4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/resizable-and-fixed-have-same-prototype.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype +description: > + SendableTypedArrays that are backed by resizable buffers have the same prototypes + as those backed by fixed-length buffers +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +const rab = CreateResizableArrayBuffer(40, 80); +const ab = new ArrayBuffer(80); +for (let ctor of ctors) { + const ta_rab = new ctor(rab, 0, 3); + const ta_ab = new ctor(ab, 0, 3); + assert.sameValue(ta_ab.__proto__, ta_rab.__proto__); +} diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/detached-buffer.js new file mode 100644 index 00000000000..ef4ff1d454b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/detached-buffer.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.reverse(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..c35bd5bbfbe --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) + + %SendableTypedArray%.prototype.reverse is a distinct function that implements the same + algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.21 Array.prototype.reverse ( ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n]); + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.reverse(); + + assert.sameValue(getCalls, 0, "ignores length properties"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js new file mode 100644 index 00000000000..d662e933621 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Preserves non numeric properties +info: | + 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) + + %SendableTypedArray%.prototype.reverse is a distinct function that implements the same + algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.21 Array.prototype.reverse ( ) + + ... + 6. Return O. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample, result; + + sample = new TA(2); + sample.foo = 42; + sample.bar = "bar"; + sample[s] = 1; + result = sample.reverse(); + assert.sameValue(result.foo, 42, "sample.foo === 42"); + assert.sameValue(result.bar, "bar", "sample.bar === 'bar'"); + assert.sameValue(result[s], 1, "sample[s] === 1"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..beed9eb8d88 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.reverse, + 'function', + 'implements SendableTypedArray.prototype.reverse' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.reverse(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.reverse(); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the reverse operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.reverse(); + throw new Test262Error('reverse completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/returns-original-object.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/returns-original-object.js new file mode 100644 index 00000000000..9da7f679b0c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/returns-original-object.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Returns the same object +info: | + 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) + + %SendableTypedArray%.prototype.reverse is a distinct function that implements the same + algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.21 Array.prototype.reverse ( ) + + ... + 6. Return O. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var buffer = new ArrayBuffer(64); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample, result, expectedLength; + + sample = new TA(buffer, 0); + expectedLength = sample.length; + result = sample.reverse(); + assert.sameValue(result, sample, "returns the same object"); + assert.sameValue(sample.buffer, buffer, "keeps the same buffer"); + assert.sameValue(sample.length, expectedLength, "length is preserved"); + + sample = new TA(buffer, 0, 0); + result = sample.reverse(); + assert.sameValue(result, sample, "returns the same object (empty instance)"); + assert.sameValue(sample.buffer, buffer, "keeps the same buffer (empty instance)"); + assert.sameValue(sample.length, 0, "length is preserved (empty instance)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/reverts.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/reverts.js new file mode 100644 index 00000000000..162b1710832 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/reverts.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Reverts values +info: | + 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) + + %SendableTypedArray%.prototype.reverse is a distinct function that implements the same + algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.21 Array.prototype.reverse ( ) + + ... + 6. Return O. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +var buffer = new ArrayBuffer(64); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(buffer, 0, 4); + var other = new TA(buffer, 0, 5); + + sample[0] = 42n; + sample[1] = 43n; + sample[2] = 2n; + sample[3] = 1n; + other[4] = 7n; + + sample.reverse(); + assert( + compareArray(sample, [1n, 2n, 43n, 42n]) + ); + + assert( + compareArray(other, [1n, 2n, 43n, 42n, 7n]) + ); + + sample[0] = 7n; + sample[1] = 17n; + sample[2] = 1n; + sample[3] = 0n; + other[4] = 42n; + + other.reverse(); + assert( + compareArray(other, [42n, 0n, 1n, 17n, 7n]) + ); + + assert( + compareArray(sample, [42n, 0n, 1n, 17n]) + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js new file mode 100644 index 00000000000..56730967c01 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.reverse(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..c2d5577d123 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) + + %SendableTypedArray%.prototype.reverse is a distinct function that implements the same + algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.21 Array.prototype.reverse ( ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43]); + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.reverse(); + + assert.sameValue(getCalls, 0, "ignores length properties"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-func.js new file mode 100644 index 00000000000..b276cb4866c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-func.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reverse ( ) + + ... + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var reverse = SendableTypedArray.prototype.reverse; + +assert.sameValue(typeof reverse, 'function'); + +assert.throws(TypeError, function() { + reverse(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-method.js new file mode 100644 index 00000000000..c993903f9a7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-method.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.21 %SendableTypedArray%.prototype.reverse ( ) + + ... + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.reverse, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.reverse(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/length.js b/test/sendable/builtins/TypedArray/prototype/reverse/length.js new file mode 100644 index 00000000000..3172819ae73 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: > + %SendableTypedArray%.prototype.reverse.length is 0. +info: | + %SendableTypedArray%.prototype.reverse ( ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.reverse, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/name.js b/test/sendable/builtins/TypedArray/prototype/reverse/name.js new file mode 100644 index 00000000000..e7ca1a5a478 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: > + %SendableTypedArray%.prototype.reverse.name is "reverse". +info: | + %SendableTypedArray%.prototype.reverse ( ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.reverse, "name", { + value: "reverse", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/reverse/not-a-constructor.js new file mode 100644 index 00000000000..76f8c2f069b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.reverse 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.reverse), + false, + 'isConstructor(SendableTypedArray.prototype.reverse) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.reverse(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js b/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js new file mode 100644 index 00000000000..d110220306a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Preserves non numeric properties +info: | + 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) + + %SendableTypedArray%.prototype.reverse is a distinct function that implements the same + algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.21 Array.prototype.reverse ( ) + + ... + 6. Return O. +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample, result; + + sample = new TA(2); + sample.foo = 42; + sample.bar = "bar"; + sample[s] = 1; + result = sample.reverse(); + assert.sameValue(result.foo, 42, "sample.foo === 42"); + assert.sameValue(result.bar, "bar", "sample.bar === 'bar'"); + assert.sameValue(result[s], 1, "sample[s] === 1"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/reverse/prop-desc.js new file mode 100644 index 00000000000..507110a407a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: > + "reverse" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'reverse', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/reverse/resizable-buffer.js new file mode 100644 index 00000000000..c3617a00577 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/resizable-buffer.js @@ -0,0 +1,177 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: > + SendableTypedArray.p.reverse behaves correctly on SendableTypedArrays backed by resizable + buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const wholeArrayView = new ctor(rab); + function WriteData() { + // Write some data into the array. + for (let i = 0; i < wholeArrayView.length; ++i) { + wholeArrayView[i] = MayNeedBigInt(wholeArrayView, 2 * i); + } + } + WriteData(); + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + fixedLength.reverse(); + assert.compareArray(ToNumbers(wholeArrayView), [ + 6, + 4, + 2, + 0 + ]); + fixedLengthWithOffset.reverse(); + assert.compareArray(ToNumbers(wholeArrayView), [ + 6, + 4, + 0, + 2 + ]); + lengthTracking.reverse(); + assert.compareArray(ToNumbers(wholeArrayView), [ + 2, + 0, + 4, + 6 + ]); + lengthTrackingWithOffset.reverse(); + assert.compareArray(ToNumbers(wholeArrayView), [ + 2, + 0, + 6, + 4 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + WriteData(); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + fixedLength.reverse(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.reverse(); + }); + lengthTracking.reverse(); + assert.compareArray(ToNumbers(wholeArrayView), [ + 4, + 2, + 0 + ]); + lengthTrackingWithOffset.reverse(); + assert.compareArray(ToNumbers(wholeArrayView), [ + 4, + 2, + 0 + ]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + WriteData(); + assert.throws(TypeError, () => { + fixedLength.reverse(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.reverse(); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.reverse(); + }); + lengthTracking.reverse(); + assert.compareArray(ToNumbers(wholeArrayView), [0]); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.reverse(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.reverse(); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.reverse(); + }); + lengthTracking.reverse(); + assert.compareArray(ToNumbers(wholeArrayView), []); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + WriteData(); + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + fixedLength.reverse(); + assert.compareArray(ToNumbers(wholeArrayView), [ + 6, + 4, + 2, + 0, + 8, + 10 + ]); + fixedLengthWithOffset.reverse(); + assert.compareArray(ToNumbers(wholeArrayView), [ + 6, + 4, + 0, + 2, + 8, + 10 + ]); + lengthTracking.reverse(); + assert.compareArray(ToNumbers(wholeArrayView), [ + 10, + 8, + 2, + 0, + 4, + 6 + ]); + lengthTrackingWithOffset.reverse(); + assert.compareArray(ToNumbers(wholeArrayView), [ + 10, + 8, + 6, + 4, + 0, + 2 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..b9b9530e488 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.reverse, + 'function', + 'implements SendableTypedArray.prototype.reverse' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.reverse(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.reverse(); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the reverse operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.reverse(); + throw new Test262Error('reverse completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js b/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js new file mode 100644 index 00000000000..2ec20cb0532 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Returns the same object +info: | + 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) + + %SendableTypedArray%.prototype.reverse is a distinct function that implements the same + algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.21 Array.prototype.reverse ( ) + + ... + 6. Return O. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var buffer = new ArrayBuffer(64); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample, result, expectedLength; + + sample = new TA(buffer, 0); + expectedLength = sample.length; + result = sample.reverse(); + assert.sameValue(result, sample, "returns the same object"); + assert.sameValue(sample.buffer, buffer, "keeps the same buffer"); + assert.sameValue(sample.length, expectedLength, "length is preserved"); + + sample = new TA(buffer, 0, 0); + result = sample.reverse(); + assert.sameValue(result, sample, "returns the same object (empty instance)"); + assert.sameValue(sample.buffer, buffer, "keeps the same buffer (empty instance)"); + assert.sameValue(sample.length, 0, "length is preserved (empty instance)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js b/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js new file mode 100644 index 00000000000..ca2e097be04 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Reverts values +info: | + 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) + + %SendableTypedArray%.prototype.reverse is a distinct function that implements the same + algorithm as Array.prototype.reverse as defined in 22.1.3.21 except that the + this object's [[ArrayLength]] internal slot is accessed in place of performing + a [[Get]] of "length". + + 22.1.3.21 Array.prototype.reverse ( ) + + ... + 6. Return O. +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +var buffer = new ArrayBuffer(64); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(buffer, 0, 4); + var other = new TA(buffer, 0, 5); + + sample[0] = 42; + sample[1] = 43; + sample[2] = 2; + sample[3] = 1; + other[4] = 7; + + sample.reverse(); + assert( + compareArray(sample, [1, 2, 43, 42]) + ); + + assert( + compareArray(other, [1, 2, 43, 42, 7]) + ); + + sample[0] = 7; + sample[1] = 17; + sample[2] = 1; + sample[3] = 0; + other[4] = 42; + + other.reverse(); + assert( + compareArray(other, [42, 0, 1, 17, 7]) + ); + + assert( + compareArray(sample, [42, 0, 1, 17]) + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-object.js new file mode 100644 index 00000000000..92c905a79b0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-object.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var reverse = SendableTypedArray.prototype.reverse; + +assert.throws(TypeError, function() { + reverse.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + reverse.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + reverse.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + reverse.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + reverse.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + reverse.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + reverse.call(s); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..87ff87282cc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.reverse +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var reverse = SendableTypedArray.prototype.reverse; + +assert.throws(TypeError, function() { + reverse.call({}); +}, "this is an Object"); + +assert.throws(TypeError, function() { + reverse.call([]); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + reverse.call(ab); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + reverse.call(dv); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js new file mode 100644 index 00000000000..b3d9eb26e19 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Throw a RangeError exception if targetOffset < 0 +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). + 7. If targetOffset < 0, throw a RangeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(4); + + assert.throws(RangeError, function() { + sample.set([1n], -1); + }, "-1"); + + assert.throws(RangeError, function() { + sample.set([1n], -1.00001); + }, "-1.00001"); + + assert.throws(RangeError, function() { + sample.set([1n], -Infinity); + }, "-Infinity"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js new file mode 100644 index 00000000000..45e34728d16 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js @@ -0,0 +1,108 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + ToInteger(offset) operations +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). + 7. If targetOffset < 0, throw a RangeError exception. + ... +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([1n, 2n]); + sample.set([42n], ""); + assert(compareArray(sample, [42n, 2n]), "the empty string"); + + sample = new TA([1n, 2n]); + sample.set([42n], "0"); + assert(compareArray(sample, [42n, 2n]), "'0'"); + + sample = new TA([1n, 2n]); + sample.set([42n], false); + assert(compareArray(sample, [42n, 2n]), "false"); + + sample = new TA([1n, 2n]); + sample.set([42n], 0.1); + assert(compareArray(sample, [42n, 2n]), "0.1"); + + sample = new TA([1n, 2n]); + sample.set([42n], 0.9); + assert(compareArray(sample, [42n, 2n]), "0.9"); + + sample = new TA([1n, 2n]); + sample.set([42n], -0.5); + assert(compareArray(sample, [42n, 2n]), "-0.5"); + + sample = new TA([1n, 2n]); + sample.set([42n], 1.1); + assert(compareArray(sample, [1n, 42n]), "1.1"); + + sample = new TA([1n, 2n]); + sample.set([42n], NaN); + assert(compareArray(sample, [42n, 2n]), "NaN"); + + sample = new TA([1n, 2n]); + sample.set([42n], null); + assert(compareArray(sample, [42n, 2n]), "null"); + + sample = new TA([1n, 2n]); + sample.set([42n], undefined); + assert(compareArray(sample, [42n, 2n]), "undefined"); + + sample = new TA([1n, 2n]); + sample.set([42n], {}); + assert(compareArray(sample, [42n, 2n]), "{}"); + + sample = new TA([1n, 2n]); + sample.set([42n], []); + assert(compareArray(sample, [42n, 2n]), "[]"); + + sample = new TA([1n, 2n]); + sample.set([42n], [0]); + assert(compareArray(sample, [42n, 2n]), "[0]"); + + sample = new TA([1n, 2n]); + sample.set([42n], true); + assert(compareArray(sample, [1n, 42n]), "true"); + + sample = new TA([1n, 2n]); + sample.set([42n], "1"); + assert(compareArray(sample, [1n, 42n]), "'1'"); + + sample = new TA([1n, 2n]); + sample.set([42n], [1]); + assert(compareArray(sample, [1n, 42n]), "[1]"); + + sample = new TA([1n, 2n]); + sample.set([42n], { valueOf: function() {return 1;} }); + assert(compareArray(sample, [1n, 42n]), "valueOf"); + + sample = new TA([1n, 2n]); + sample.set([42n], { toString: function() {return 1;} }); + assert(compareArray(sample, [1n, 42n]), "toString"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js new file mode 100644 index 00000000000..471c4ba97b0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Primitive `array` argument is coerced to an object. +info: | + %SendableTypedArray%.prototype.set ( typedArray [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object + with a [[TypedArrayName]] internal slot. If it is such an Object, + the definition in 22.2.3.23.2 applies. + [...] + 14. Let src be ? ToObject(array). + 15. Let srcLength be ? LengthOfArrayLike(src). + [...] + 19. Let limit be targetByteIndex + targetElementSize × srcLength. + 20. Repeat, while targetByteIndex < limit, + a. Let Pk be ! ToString(k). + b. Let value be ? Get(src, Pk). + c. If target.[[ContentType]] is BigInt, set value to ? ToBigInt(value). + [...] + f. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, Unordered). + [...] +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, SendableTypedArray, Symbol] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var ta1 = new TA([1n, 2n, 3n, 4n]); + ta1.set("567"); + assert.compareArray(ta1, [5n, 6n, 7n, 4n], "string"); + + var ta2 = new TA([1n, 2n, 3n]); + ta2.set(-10, 2); + assert.compareArray(ta2, [1n, 2n, 3n], "number"); + + var ta3 = new TA([1n]); + ta3.set(false); + assert.compareArray(ta3, [1n], "boolean"); + + var ta4 = new TA([1n, 2n]); + ta4.set(Symbol("desc"), 0); + assert.compareArray(ta4, [1n, 2n], "symbol"); + + var ta5 = new TA([1n, 2n]); + ta5.set(4n, 1); + assert.compareArray(ta5, [1n, 2n], "bigint"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js new file mode 100644 index 00000000000..65879a55623 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt getting src "length" +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 16. Let srcLength be ? ToLength(? Get(src, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1n, 2n, 3n]); + + assert.throws(Test262Error, function() { + sample.set(obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js new file mode 100644 index 00000000000..f1a064c1ff1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt from getting src property value +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumber). + ... +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var obj = { + length: 4, + "0": 42n, + "1": 43n, + "3": 44n + }; + Object.defineProperty(obj, "2", { + get: function() { + throw new Test262Error(); + } + }); + + var sample = new TA([1n, 2n, 3n, 4n]); + + assert.throws(Test262Error, function() { + sample.set(obj); + }); + + assert( + compareArray(sample, [42n, 43n, 3n, 4n]), + "values are set until exception" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js new file mode 100644 index 00000000000..b3e2fb2091d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt getting src "length" as symbol +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 16. Let srcLength be ? ToLength(? Get(src, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var obj = { + length: Symbol("1") +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1n, 2n, 3n]); + + assert.throws(TypeError, function() { + sample.set(obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js new file mode 100644 index 00000000000..82732e2e7c8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt from ToLength(src "length") +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 16. Let srcLength be ? ToLength(? Get(src, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj1 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; + +var obj2 = { + length: { + toString: function() { + throw new Test262Error(); + } + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1n, 2n, 3n]); + + assert.throws(Test262Error, function() { + sample.set(obj1); + }, "valueOf"); + + assert.throws(Test262Error, function() { + sample.set(obj2); + }, "toString"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js new file mode 100644 index 00000000000..6dace852fc8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt from ToNumber(src property symbol value) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumber). + ... +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var obj = { + length: 4, + "0": 42n, + "1": 43n, + "2": Symbol("1"), + "3": 44n + }; + + var sample = new TA([1n, 2n, 3n, 4n]); + + assert.throws(TypeError, function() { + sample.set(obj); + }); + + assert( + compareArray(sample, [42n, 43n, 3n, 4n]), + "values are set until exception" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js new file mode 100644 index 00000000000..fecec2142ee --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt from ToNumber(src property value) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumber). + ... +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var obj = { + length: 4, + "0": 42n, + "1": 43n, + "2": { + valueOf: function() { + throw new Test262Error(); + } + }, + "3": 44n + }; + + var sample = new TA([1n, 2n, 3n, 4n]); + + assert.throws(Test262Error, function() { + sample.set(obj); + }); + + assert( + compareArray(sample, [42n, 43n, 3n, 4n]), + "values are set until exception" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js new file mode 100644 index 00000000000..7d1c8d7a1f4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt from ToInteger(Symbol offset) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + assert.throws(TypeError, function() { + sample.set([1n], s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js new file mode 100644 index 00000000000..0aa17e0a7d2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt from ToInteger(offset) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var obj2 = { + toString: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(Test262Error, function() { + sample.set([], obj1); + }, "abrupt from valueOf"); + + assert.throws(Test262Error, function() { + sample.set([], obj2); + }, "abrupt from toString"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js new file mode 100644 index 00000000000..d1a817c72f5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt from ToObject(array) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 15. Let src be ? ToObject(array). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1n, 2n, 3n]); + + assert.throws(TypeError, function() { + sample.set(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.set(null); + }, "null"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js new file mode 100644 index 00000000000..f3b764ec8c4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Get and set each value in order +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumber). + ... +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(5); + var calls = []; + var obj = { + length: 3 + }; + Object.defineProperty(obj, 0, { + get: function() { + calls.push(0); + calls.push(sample.join()); + return 42n; + } + }); + + Object.defineProperty(obj, 1, { + get: function() { + calls.push(1); + calls.push(sample.join()); + return 43n; + } + }); + + Object.defineProperty(obj, 2, { + get: function() { + calls.push(2); + calls.push(sample.join()); + return 44n; + } + }); + + Object.defineProperty(obj, 3, { + get: function() { + throw new Test262Error("Should not call obj[3]"); + } + }); + + sample.set(obj, 1); + + assert( + compareArray(sample, [0n, 42n, 43n, 44n, 0n]), + "values are set for src length" + ); + + assert( + compareArray(calls, [0, "0,0,0,0,0", 1, "0,42,0,0,0", 2, "0,42,43,0,0"]), + "values are set in order" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values.js new file mode 100644 index 00000000000..8b9cea26a73 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values.js @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Set values to target and return undefined +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + Let Pk be ! ToString(k). + Let kNumber be ? ToNumber(? Get(src, Pk)). + If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). + ... + 22. Return undefined. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var src = [42n, 43n]; + var srcObj = { + length: 2, + '0': 7n, + '1': 17n + }; + var sample, result; + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 0); + assert(compareArray(sample, [42n, 43n, 3n, 4n]), "offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 1); + assert(compareArray(sample, [1n, 42n, 43n, 4n]), "offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 2); + assert(compareArray(sample, [1n, 2n, 42n, 43n]), "offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(srcObj, 0); + assert(compareArray(sample, [7n, 17n, 3n, 4n]), "offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(srcObj, 1); + assert(compareArray(sample, [1n, 7n, 17n, 4n]), "offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(srcObj, 2); + assert(compareArray(sample, [1n, 2n, 7n, 17n]), "offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js new file mode 100644 index 00000000000..1060ef8f9a9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Type conversions on ToNumber(src property value) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumber). + ... +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var obj1 = { + valueOf: function() { + return 42n; + } + }; + + var obj2 = { + toString: function() { + return "42"; + } + }; + + var arr = [false, true, obj1, [], [1]]; + + var sample = new TA(arr.length); + var expected = new TA([0n, 1n, 42n, 0n, 1n]); + + sample.set(arr); + + assert( + compareArray(sample, expected), + "sample: [" + sample + "], expected: [" + expected + "]" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js new file mode 100644 index 00000000000..276161de02c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Values from src array are not cached +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumber). + ... +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(5); + var obj = { + length: 5, + '1': 7n, + '2': 7n, + '3': 7n, + '4': 7n + }; + Object.defineProperty(obj, 0, { + get: function() { + obj[1] = 43n; + obj[2] = 44n; + obj[3] = 45n; + obj[4] = 46n; + return 42n; + } + }); + + sample.set(obj); + + assert(compareArray(sample, [42n, 43n, 44n, 45n, 46n])); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js new file mode 100644 index 00000000000..639f60559c4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Uses target's internal [[ArrayLength]] +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 10. Let targetLength be the value of target's [[ArrayLength]] internal slot. + ... + 17. If srcLength + targetOffset > targetLength, throw a RangeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.set([42n, 43n]); + + assert.sameValue(getCalls, 0, "ignores length properties"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js new file mode 100644 index 00000000000..80ab6891dbc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Throws a TypeError if targetBuffer is detached on ToInteger(offset) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). + ... + 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal + slot. + 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var calledOffset = 0; + var obj = { + valueOf: function() { + $DETACHBUFFER(sample.buffer); + calledOffset += 1; + } + }; + + assert.throws(TypeError, function() { + sample.set([1n], obj); + }); + + assert.sameValue(calledOffset, 1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js new file mode 100644 index 00000000000..563882d06d5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Throws a TypeError if targetBuffer is detached +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal + slot. + 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + ... + 15. Let src be ? ToObject(array). + 16. Let srcLength be ? ToLength(? Get(src, "length")). + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + $DETACHBUFFER(sample.buffer); + + assert.throws(TypeError, function() { + sample.set([1n]); + }, "regular check"); + + assert.throws(TypeError, function() { + sample.set(obj); + }, "IsDetachedBuffer happens before Get(src.length)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobigint64.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobigint64.js new file mode 100644 index 00000000000..9d19eebb20c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobigint64.js @@ -0,0 +1,101 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Behavior for input array of BigInts +info: | + %SendableTypedArray%.prototype.set ( array [ , offset ] ) + Sets multiple values in this SendableTypedArray, reading the values from the object + array. The optional offset value indicates the first element index in this + SendableTypedArray where values are written. If omitted, it is assumed to be 0. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. Let value be ? Get(src, Pk). + d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array", + let value be ? ToBigInt(value). + e. Otherwise, let value be ? ToNumber(value). + f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumbervalue, true, "Unordered"). + h. Set k to k + 1. + i. Set targetByteIndex to targetByteIndex + targetElementSize. + ... + + SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isSendableTypedArray, order [ , isLittleEndian ] ) + ... + 8. Let rawBytes be NumberToRawBytes(type, value, isLittleEndian). + ... + + NumberToRawBytes( type, value, isLittleEndian ) + ... + 3. Else, + a. Let n be the Number value of the Element Size specified in Table + [The SendableTypedArray Constructors] for Element Type type. + b. Let convOp be the abstract operation named in the Conversion Operation + column in Table 9 for Element Type type. + + The SendableTypedArray Constructors + Element Type: BigInt64 + Conversion Operation: ToBigInt64 + + ToBigInt64 ( argument ) + The abstract operation ToBigInt64 converts argument to one of 264 integer + values in the range -2^63 through 2^63-1, inclusive. + This abstract operation functions as follows: + 1. Let n be ? ToBigInt(argument). + 2. Let int64bit be n modulo 2^64. + 3. If int64bit ≥ 2^63, return int64bit - 2^64; otherwise return int64bit. + +features: [BigInt, TypedArray] +---*/ + +var vals = [ + 18446744073709551618n, // 2n ** 64n + 2n + 9223372036854775810n, // 2n ** 63n + 2n + 2n, + 0n, + -2n, + -9223372036854775810n, // -(2n ** 63n) - 2n + -18446744073709551618n, // -(2n ** 64n) - 2n +]; + +var typedArray = new BigInt64Array(vals.length); +typedArray.set(vals); + +assert.sameValue(typedArray[0], 2n, + "ToBigInt64(2n ** 64n + 2n) => 2n"); + +assert.sameValue(typedArray[1], -9223372036854775806n, // 2n - 2n ** 63n + "ToBigInt64(2n ** 63n + 2n) => -9223372036854775806n"); + +assert.sameValue(typedArray[2], 2n, + "ToBigInt64(2n) => 2n"); + +assert.sameValue(typedArray[3], 0n, + "ToBigInt64(0n) => 0n"); + +assert.sameValue(typedArray[4], -2n, + "ToBigInt64( -2n) => -2n"); + +assert.sameValue(typedArray[5], 9223372036854775806n, // 2n ** 63n - 2 + "ToBigInt64( -(2n ** 64n) - 2n) => 9223372036854775806n"); + +assert.sameValue(typedArray[6], -2n, + "ToBigInt64( -(2n ** 64n) - 2n) => -2n"); + diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobiguint64.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobiguint64.js new file mode 100644 index 00000000000..d567acaf4ed --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobiguint64.js @@ -0,0 +1,100 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Behavior for input array of BigInts +info: | + %SendableTypedArray%.prototype.set ( array [ , offset ] ) + Sets multiple values in this SendableTypedArray, reading the values from the object + array. The optional offset value indicates the first element index in this + SendableTypedArray where values are written. If omitted, it is assumed to be 0. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. Let value be ? Get(src, Pk). + d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array", + let value be ? ToBigInt(value). + e. Otherwise, let value be ? ToNumber(value). + f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumbervalue, true, "Unordered"). + h. Set k to k + 1. + i. Set targetByteIndex to targetByteIndex + targetElementSize. + ... + + SetValueInBuffer ( arrayBuffer, byteIndex, type, value, isSendableTypedArray, order [ , isLittleEndian ] ) + ... + 8. Let rawBytes be NumberToRawBytes(type, value, isLittleEndian). + ... + + NumberToRawBytes( type, value, isLittleEndian ) + ... + 3. Else, + a. Let n be the Number value of the Element Size specified in Table + [The SendableTypedArray Constructors] for Element Type type. + b. Let convOp be the abstract operation named in the Conversion Operation + column in Table 9 for Element Type type. + + The SendableTypedArray Constructors + Element Type: BigUint64 + Conversion Operation: ToBigUint64 + + ToBigUint64 ( argument ) + The abstract operation ToBigInt64 converts argument to one of 264 integer + values in the range -2^63 through 2^63-1, inclusive. + This abstract operation functions as follows: + 1. Let n be ? ToBigInt(argument). + 2. Let int64bit be n modulo 2^64. + 3. Return int64bit. + +features: [BigInt, TypedArray] +---*/ + +var vals = [ + 18446744073709551618n, // 2n ** 64n + 2n + 9223372036854775810n, // 2n ** 63n + 2n + 2n, + 0n, + -2n, + -9223372036854775810n, // -(2n ** 63n) - 2n + -18446744073709551618n, // -(2n ** 64n) - 2n +]; + +var typedArray = new BigUint64Array(vals.length); +typedArray.set(vals); + +assert.sameValue(typedArray[0], 2n, + "ToBigUint64(2n ** 64n + 2n) => 2n"); + +assert.sameValue(typedArray[1], 9223372036854775810n, // 2n ** 63n + 2n + "ToBigUint64(2n ** 63n + 2n) => 9223372036854775810"); + +assert.sameValue(typedArray[2], 2n, + "ToBigUint64(2n) => 2n"); + +assert.sameValue(typedArray[3], 0n, + "ToBigUint64(0n) => 0n"); + +assert.sameValue(typedArray[4], 18446744073709551614n, // 2n ** 64n - 2n + "ToBigUint64( -2n) => 18446744073709551614n"); + +assert.sameValue(typedArray[5], 9223372036854775806n, // 2n ** 63n - 2n + "ToBigUint64( -(2n ** 63n) - 2n) => 9223372036854775806n"); + +assert.sameValue(typedArray[6], 18446744073709551614n, // 2n ** 64n - 2n + "ToBigUint64( -(2n ** 64n) - 2n) => 18446744073709551614n"); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/boolean-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/boolean-tobigint.js new file mode 100644 index 00000000000..a3385489828 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/boolean-tobigint.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Behavior for input array of Booleans +info: | + %SendableTypedArray%.prototype.set ( array [ , offset ] ) + Sets multiple values in this SendableTypedArray, reading the values from the object + array. The optional offset value indicates the first element index in this + SendableTypedArray where values are written. If omitted, it is assumed to be 0. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. Let value be ? Get(src, Pk). + d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array", + let value be ? ToBigInt(value). + e. Otherwise, let value be ? ToNumber(value). + f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumbervalue, true, "Unordered"). + h. Set k to k + 1. + i. Set targetByteIndex to targetByteIndex + targetElementSize. + ... + + ToBigInt ( argument ) + Object, Apply the following steps: + 1. Let prim be ? ToPrimitive(argument, hint Number). + 2. Return the value that prim corresponds to in Table [BigInt Conversions] + + BigInt Conversions + Argument Type: Boolean + Result: Return 1n if prim is true and 0n if prim is false. + +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var typedArray = new TA(2); + typedArray.set([false, true]) + + assert.sameValue(typedArray[0], 0n, "False converts to BigInt"); + assert.sameValue(typedArray[1], 1n, "True converts to BigInt"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/null-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/null-tobigint.js new file mode 100644 index 00000000000..4763ea6cb70 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/null-tobigint.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt on null +info: | + %SendableTypedArray%.prototype.set ( array [ , offset ] ) + Sets multiple values in this SendableTypedArray, reading the values from the object + array. The optional offset value indicates the first element index in this + SendableTypedArray where values are written. If omitted, it is assumed to be 0. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. Let value be ? Get(src, Pk). + d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array", + let value be ? ToBigInt(value). + e. Otherwise, let value be ? ToNumber(value). + f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumbervalue, true, "Unordered"). + h. Set k to k + 1. + i. Set targetByteIndex to targetByteIndex + targetElementSize. + ... + + ToBigInt ( argument ) + Object, Apply the following steps: + 1. Let prim be ? ToPrimitive(argument, hint Number). + 2. Return the value that prim corresponds to in Table [BigInt Conversions] + + BigInt Conversions + Argument Type: Null + Result: Throw a TypeError exception. + +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var typedArray = new TA(1); + + assert.throws(TypeError, function() { + typedArray.set([null]); + }, "abrupt completion from Null"); + +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/number-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/number-tobigint.js new file mode 100644 index 00000000000..f8b9f2b1291 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/number-tobigint.js @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt on Number +info: | + %SendableTypedArray%.prototype.set ( array [ , offset ] ) + Sets multiple values in this SendableTypedArray, reading the values from the object + array. The optional offset value indicates the first element index in this + SendableTypedArray where values are written. If omitted, it is assumed to be 0. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. Let value be ? Get(src, Pk). + d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array", + let value be ? ToBigInt(value). + e. Otherwise, let value be ? ToNumber(value). + f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumbervalue, true, "Unordered"). + h. Set k to k + 1. + i. Set targetByteIndex to targetByteIndex + targetElementSize. + ... + + ToBigInt ( argument ) + + Object, Apply the following steps: + 1. Let prim be ? ToPrimitive(argument, hint Number). + 2. Return the value that prim corresponds to in Table [BigInt Conversions] + + BigInt Conversions + Argument Type: Number + Result: Throw a TypeError exception. + +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var typedArray = new TA(1); + + assert.throws(TypeError, function() { + typedArray.set([1]); + }, "abrupt completion from Number: 1"); + + assert.throws(TypeError, function() { + typedArray.set([Math.pow(2, 63)]); + }, "abrupt completion from Number: 2**63"); + + assert.throws(TypeError, function() { + typedArray.set([+0]); + }, "abrupt completion from Number: +0"); + + assert.throws(TypeError, function() { + typedArray.set([-0]); + }, "abrupt completion from Number: -0"); + + assert.throws(TypeError, function() { + typedArray.set([Infinity]); + }, "abrupt completion from Number: Infinity"); + + assert.throws(TypeError, function() { + typedArray.set([-Infinity]); + }, "abrupt completion from Number: -Infinity"); + + assert.throws(TypeError, function() { + typedArray.set([NaN]); + }, "abrupt completion from Number: NaN"); + +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-big.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-big.js new file mode 100644 index 00000000000..3119d043def --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-big.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + If typedArray constructor argument is a Big(U)Int, succeed in set +info: | + %SendableTypedArray%.prototype.set( typedArray [ , offset ] ) + Sets multiple values in this SendableTypedArray, reading the values from the + typedArray argument object. The optional offset value indicates the first + element index in this SendableTypedArray where values are written. If omitted, it + is assumed to be 0. + ... + 23. If one of srcType and targetType contains the substring "Big" and the + other does not, throw a TypeError exception. + ... + +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var srcSendableTypedArray; +var targetSendableTypedArray; +var testValue = 42n; + +testWithBigIntSendableTypedArrayConstructors(function(BTA1) { + + srcSendableTypedArray = new BTA1([testValue]); + + testWithBigIntSendableTypedArrayConstructors(function(BTA2) { + + targetSendableTypedArray = new BTA2(1); + targetSendableTypedArray.set(srcSendableTypedArray); + assert.sameValue(targetSendableTypedArray[0], testValue, + "Setting BigInt SendableTypedArray with BigInt SendableTypedArray should succeed.") + }); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js new file mode 100644 index 00000000000..b8f464bb0bb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + If typedArray set argument is not a Big(U)Int, and target is "Big", throw +info: | + %SendableTypedArray%.prototype.set( typedArray [ , offset ] ) + Sets multiple values in this SendableTypedArray, reading the values from the + typedArray argument object. The optional offset value indicates the first + element index in this SendableTypedArray where values are written. If omitted, it + is assumed to be 0. + ... + 23. If one of srcType and targetType contains the substring "Big" and the + other does not, throw a TypeError exception. + ... + +includes: [testBigIntSendableTypedArray.js, testTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var bigSendableTypedArray; +var littleSendableTypedArray; + +testWithSendableTypedArrayConstructors(function(TA) { + + littleSendableTypedArray = new TA([1]); + + testWithBigIntSendableTypedArrayConstructors(function(BTA) { + + bigSendableTypedArray = new BTA(1); + assert.throws(TypeError, function() { + bigSendableTypedArray.set(littleSendableTypedArray); + }); + }); + +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js new file mode 100644 index 00000000000..3597e5593d0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt String, when StringToBigInt returns NaN +info: | + %SendableTypedArray%.prototype.set ( array [ , offset ] ) + Sets multiple values in this SendableTypedArray, reading the values from the object + array. The optional offset value indicates the first element index in this + SendableTypedArray where values are written. If omitted, it is assumed to be 0. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. Let value be ? Get(src, Pk). + d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array", + let value be ? ToBigInt(value). + e. Otherwise, let value be ? ToNumber(value). + f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumbervalue, true, "Unordered"). + h. Set k to k + 1. + i. Set targetByteIndex to targetByteIndex + targetElementSize. + ... + + ToBigInt ( argument ) + Object, Apply the following steps: + 1. Let prim be ? ToPrimitive(argument, hint Number). + 2. Return the value that prim corresponds to in Table [BigInt Conversions] + + BigInt Conversions + Argument Type: String + Result: + 1. Let n be StringToBigInt(prim). + 2. If n is NaN, throw a SyntaxError exception. + 3. Return n. + +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var typedArray = new TA(1); + + assert.throws(SyntaxError, function() { + typedArray.set(["definately not a number"]); + }, "StringToBigInt(prim) == NaN"); + +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-tobigint.js new file mode 100644 index 00000000000..bdeb7318448 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-tobigint.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Behavior for input array of Strings, successful conversion +info: | + %SendableTypedArray%.prototype.set ( array [ , offset ] ) + Sets multiple values in this SendableTypedArray, reading the values from the object + array. The optional offset value indicates the first element index in this + SendableTypedArray where values are written. If omitted, it is assumed to be 0. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. Let value be ? Get(src, Pk). + d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array", + let value be ? ToBigInt(value). + e. Otherwise, let value be ? ToNumber(value). + f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumbervalue, true, "Unordered"). + h. Set k to k + 1. + i. Set targetByteIndex to targetByteIndex + targetElementSize. + ... + + ToBigInt ( argument ) + Object, Apply the following steps: + 1. Let prim be ? ToPrimitive(argument, hint Number). + 2. Return the value that prim corresponds to in Table [BigInt Conversions] + + BigInt Conversions + Argument Type: String + Result: + 1. Let n be StringToBigInt(prim). + 2. If n is NaN, throw a SyntaxError exception. + 3. Return n. + +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var typedArray = new TA(2); + typedArray.set(['', '1']) + + assert.sameValue(typedArray[0], 0n); + assert.sameValue(typedArray[1], 1n); + + assert.throws(SyntaxError, function() { + typedArray.set(['1n']); + }, "A StringNumericLiteral may not include a BigIntLiteralSuffix."); + + assert.throws(SyntaxError, function() { + typedArray.set(["Infinity"]); + }, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow Infinity.."); + + assert.throws(SyntaxError, function() { + typedArray.set(["1.1"]); + }, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow... decimal points..."); + + assert.throws(SyntaxError, function() { + typedArray.set(["1e7"]); + }, "Replace the StrUnsignedDecimalLiteral production with DecimalDigits to not allow... exponents..."); + +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/symbol-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/symbol-tobigint.js new file mode 100644 index 00000000000..790474b817e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/symbol-tobigint.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt on Symbol +info: | + %SendableTypedArray%.prototype.set ( array [ , offset ] ) + Sets multiple values in this SendableTypedArray, reading the values from the object + array. The optional offset value indicates the first element index in this + SendableTypedArray where values are written. If omitted, it is assumed to be 0. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. Let value be ? Get(src, Pk). + d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array", + let value be ? ToBigInt(value). + e. Otherwise, let value be ? ToNumber(value). + f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumbervalue, true, "Unordered"). + h. Set k to k + 1. + i. Set targetByteIndex to targetByteIndex + targetElementSize. + ... + + ToBigInt ( argument ) + + Object, Apply the following steps: + 1. Let prim be ? ToPrimitive(argument, hint Number). + 2. Return the value that prim corresponds to in Table [BigInt Conversions] + + BigInt Conversions + Argument Type: Symbol + Result: Throw a TypeError exception. + +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, Symbol] +---*/ + +var s = Symbol() + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var typedArray = new TA(1) + + assert.throws(TypeError, function() { + typedArray.set([s]); + }, "abrupt completion from Symbol"); + +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js new file mode 100644 index 00000000000..55047be5d77 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Throw a RangeError exception if targetOffset < 0 +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). + 7. If targetOffset < 0, throw a RangeError exception. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(RangeError, function() { + sample.set(sample, -1); + }, "-1"); + + assert.throws(RangeError, function() { + sample.set(sample, -1.00001); + }, "-1.00001"); + + assert.throws(RangeError, function() { + sample.set(sample, -Infinity); + }, "-Infinity"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js new file mode 100644 index 00000000000..174909a103a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + ToInteger(offset) operations +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + var src = new TA([42n]); + + sample = new TA([1n, 2n]); + sample.set(src, ""); + assert(compareArray(sample, [42n, 2n]), "the empty string"); + + sample = new TA([1n, 2n]); + sample.set(src, "0"); + assert(compareArray(sample, [42n, 2n]), "'0'"); + + sample = new TA([1n, 2n]); + sample.set(src, false); + assert(compareArray(sample, [42n, 2n]), "false"); + + sample = new TA([1n, 2n]); + sample.set(src, 0.1); + assert(compareArray(sample, [42n, 2n]), "0.1"); + + sample = new TA([1n, 2n]); + sample.set(src, 0.9); + assert(compareArray(sample, [42n, 2n]), "0.9"); + + sample = new TA([1n, 2n]); + sample.set(src, -0.5); + assert(compareArray(sample, [42n, 2n]), "-0.5"); + + sample = new TA([1n, 2n]); + sample.set(src, 1.1); + assert(compareArray(sample, [1n, 42n]), "1.1"); + + sample = new TA([1n, 2n]); + sample.set(src, NaN); + assert(compareArray(sample, [42n, 2n]), "NaN"); + + sample = new TA([1n, 2n]); + sample.set(src, null); + assert(compareArray(sample, [42n, 2n]), "null"); + + sample = new TA([1n, 2n]); + sample.set(src, undefined); + assert(compareArray(sample, [42n, 2n]), "undefined"); + + sample = new TA([1n, 2n]); + sample.set(src, {}); + assert(compareArray(sample, [42n, 2n]), "{}"); + + sample = new TA([1n, 2n]); + sample.set(src, []); + assert(compareArray(sample, [42n, 2n]), "[]"); + + sample = new TA([1n, 2n]); + sample.set(src, [0]); + assert(compareArray(sample, [42n, 2n]), "[0]"); + + sample = new TA([1n, 2n]); + sample.set(src, true); + assert(compareArray(sample, [1n, 42n]), "true"); + + sample = new TA([1n, 2n]); + sample.set(src, "1"); + assert(compareArray(sample, [1n, 42n]), "'1'"); + + sample = new TA([1n, 2n]); + sample.set(src, [1]); + assert(compareArray(sample, [1n, 42n]), "[1]"); + + sample = new TA([1n, 2n]); + sample.set(src, { valueOf: function() {return 1;} }); + assert(compareArray(sample, [1n, 42n]), "valueOf"); + + sample = new TA([1n, 2n]); + sample.set(src, { toString: function() {return 1;} }); + assert(compareArray(sample, [1n, 42n]), "toString"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js new file mode 100644 index 00000000000..141fe481043 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Return abrupt from ToInteger(Symbol offset) +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.set(sample, s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js new file mode 100644 index 00000000000..6fd95bd9159 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Return abrupt from ToInteger(offset) +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var obj2 = { + toString: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(Test262Error, function() { + sample.set(sample, obj1); + }, "abrupt from valueOf"); + + assert.throws(Test262Error, function() { + sample.set(sample, obj2); + }, "abrupt from toString"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js new file mode 100644 index 00000000000..f747a1f5e11 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js @@ -0,0 +1,115 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the different buffer and different + type. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, SharedArrayBuffer, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sab = new SharedArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT); + var otherCtor = TA === BigInt64Array ? BigUint64Array : BigInt64Array; + var src = new otherCtor(sab); + src[0] = 42n; + src[1] = 43n; + var sample, result; + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 0); + assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src is SAB-backed, offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 1); + assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src is SAB-backed, offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 2); + assert(compareArray(sample, [1n, 2n, 42n, 43n]), "src is SAB-backed, offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + src = new BigInt64Array([42n, 43n]); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + result = sample.set(src, 0); + assert(compareArray(sample, [42n, 43n, 3n, 4n]), "sample is SAB-backed, offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + result = sample.set(src, 1); + assert(compareArray(sample, [1n, 42n, 43n, 4n]), "sample is SAB-backed, offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + result = sample.set(src, 2); + assert(compareArray(sample, [1n, 2n, 42n, 43n]), "sample is SAB-backed, offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + var sab1 = new SharedArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT); + src = new BigInt64Array(sab1); + src[0] = 42n; + src[1] = 43n; + + var sab2; + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab2); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + result = sample.set(src, 0); + assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src and sample are SAB-backed, offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab2); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + result = sample.set(src, 1); + assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src and sample are SAB-backed, offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab2); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + result = sample.set(src, 2); + assert(compareArray(sample, [1n, 2n, 42n, 43n]), "src and sample are SAB-backed, offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js new file mode 100644 index 00000000000..71293338a23 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the different buffer and different + type. +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 23. If SameValue(srcBuffer, targetBuffer) is true, then + ... + 24. Else, let srcByteIndex be srcByteOffset. + ... + 27. If SameValue(srcType, targetType) is true, then, + ... + 28. Else, + a. Repeat, while targetByteIndex < limit + i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType). + ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + value). +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array; + var src = new other([42n, 43n]); + var sample, result; + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 0); + assert(compareArray(sample, [42n, 43n, 3n, 4n]), "offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 1); + assert(compareArray(sample, [1n, 42n, 43n, 4n]), "offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 2); + assert(compareArray(sample, [1n, 2n, 42n, 43n]), "offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js new file mode 100644 index 00000000000..a49c7379a51 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js @@ -0,0 +1,116 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the different buffer and same + constructor. srcBuffer values are cached. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, SharedArrayBuffer, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample, result; + + var sab = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT); + var src = new TA(sab); + src[0] = 42n; + src[1] = 43n; + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 1); + assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src is SAB-backed, offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 0); + assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src is SAB-backed, offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 2); + assert(compareArray(sample, [1n, 2n, 42n, 43n]), "src is SAB-backed, offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + src = new TA([42n, 43n]); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + result = sample.set(src, 1); + assert(compareArray(sample, [1n, 42n, 43n, 4n]), "sample is SAB-backed, offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + result = sample.set(src, 0); + assert(compareArray(sample, [42n, 43n, 3n, 4n]), "sample is SAB-backed, offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + result = sample.set(src, 2); + assert(compareArray(sample, [1n, 2n, 42n, 43n]), "sample is SAB-backed, offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + + var sab1 = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT); + src = new TA(sab1); + src[0] = 42n; + src[1] = 43n; + + var sab2; + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab2); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + result = sample.set(src, 1); + assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src and sample are SAB-backed, offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab2); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + result = sample.set(src, 0); + assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src and sample are SAB-backed, offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab2); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + result = sample.set(src, 2); + assert(compareArray(sample, [1n, 2n, 42n, 43n]), "src and sample are SAB-backed, offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js new file mode 100644 index 00000000000..8866aa45fae --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the different buffer and same + constructor. srcBuffer values are cached. +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 23. If SameValue(srcBuffer, targetBuffer) is true, then + ... + 24. Else, let srcByteIndex be srcByteOffset. + ... + 27. If SameValue(srcType, targetType) is true, then, + a. NOTE: If srcType and targetType are the same, the transfer must be + performed in a manner that preserves the bit-level encoding of the source + data. + b. Repeat, while targetByteIndex < limit + i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8"). + ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8", + value). + ... + 29. Return undefined. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample, result; + var src = new TA([42n, 43n]); + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 1); + assert(compareArray(sample, [1n, 42n, 43n, 4n]), "offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 0); + assert(compareArray(sample, [42n, 43n, 3n, 4n]), "offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + result = sample.set(src, 2); + assert(compareArray(sample, [1n, 2n, 42n, 43n]), "offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js new file mode 100644 index 00000000000..4afc37893fc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the same buffer and same + constructor when underlying ArrayBuffer has been resized +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, SendableTypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var source = new TA(ab); + var target = new TA(ab); + var expected = [10, 20, 30, 40]; + + source[0] = 10n; + source[1] = 20n; + source[2] = 30n; + source[3] = 40n; + + try { + ab.resize(BPE * 5); + expected = [10n, 20n, 30n, 40n, 0n]; + } catch (_) {} + + target.set(source); + assert(compareArray(target, expected), 'following grow'); + + try { + ab.resize(BPE * 3); + expected = [10n, 20n, 30n]; + } catch (_) {} + + target.set(source); + assert(compareArray(target, expected), 'following shrink'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js new file mode 100644 index 00000000000..d2f40ed4986 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the same buffer and same + constructor. srcBuffer values are cached. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, SharedArrayBuffer, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample, src, result, sab; + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + src = new TA(sample.buffer, 0, 2); + result = sample.set(src, 0); + assert(compareArray(sample, [1n, 2n, 3n, 4n]), "offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + src = new TA(sample.buffer, 0, 2); + result = sample.set(src, 1); + assert(compareArray(sample, [1n, 1n, 2n, 4n]), "offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1n; + sample[1] = 2n; + sample[2] = 3n; + sample[3] = 4n; + src = new TA(sample.buffer, 0, 2); + result = sample.set(src, 2); + assert(compareArray(sample, [1n, 2n, 1n, 2n]), "offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js new file mode 100644 index 00000000000..c8872d0c314 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the same buffer and same + constructor. srcBuffer values are cached. +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 23. If SameValue(srcBuffer, targetBuffer) is true, then + a. Let srcBuffer be ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength, + %ArrayBuffer%). + b. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not + have any observable side-effects. + ... + ... + 27. If SameValue(srcType, targetType) is true, then, + a. NOTE: If srcType and targetType are the same, the transfer must be + performed in a manner that preserves the bit-level encoding of the source + data. + b. Repeat, while targetByteIndex < limit + i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8"). + ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8", + value). +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample, src, result; + + sample = new TA([1n, 2n, 3n, 4n]); + src = new TA(sample.buffer, 0, 2); + result = sample.set(src, 0); + assert(compareArray(sample, [1n, 2n, 3n, 4n]), "offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + src = new TA(sample.buffer, 0, 2); + result = sample.set(src, 1); + assert(compareArray(sample, [1n, 1n, 2n, 4n]), "offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1n, 2n, 3n, 4n]); + src = new TA(sample.buffer, 0, 2); + result = sample.set(src, 2); + assert(compareArray(sample, [1n, 2n, 1n, 2n]), "offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js new file mode 100644 index 00000000000..2ff19a3e238 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Uses typedArray's internal [[ArrayLength]] +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 20. Let srcLength be the value of typedArray's [[ArrayLength]] internal slot. + ... + 22. If srcLength + targetOffset > targetLength, throw a RangeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 42; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var src = new TA([42n, 43n]); + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(src, "length", desc); + + sample.set(src); + + assert.sameValue(getCalls, 0, "ignores length properties"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js new file mode 100644 index 00000000000..016e08d30e7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Uses typedArray's internal [[ByteOffset]] +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 21. Let srcByteOffset be typedArray.[[ByteOffset]]. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "byteOffset", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var src = new TA([42n, 43n]); + var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array; + var src2 = new other([42n, 43n]); + var src3 = new other(sample.buffer, 0, 2); + + Object.defineProperty(TA.prototype, "byteOffset", desc); + Object.defineProperty(src, "byteOffset", desc); + Object.defineProperty(src2, "byteOffset", desc); + Object.defineProperty(src3, "byteOffset", desc); + + sample.set(src); + sample.set(src2); + sample.set(src3); + + assert.sameValue(getCalls, 0, "ignores byteOffset properties"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js new file mode 100644 index 00000000000..12f09bcf237 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + If srcLength + targetOffset > targetLength, throw a RangeError exception. +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). + ... + 10. Let targetLength be the value of target's [[ArrayLength]] internal slot. + ... + 20. Let srcLength be the value of typedArray's [[ArrayLength]] internal slot. + ... + 22. If srcLength + targetOffset > targetLength, throw a RangeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample, src; + + sample = new TA(2); + src = new TA(2); + assert.throws(RangeError, function() { + sample.set(src, 1); + }, "2 + 1 > 2"); + + sample = new TA(1); + src = new TA(2); + assert.throws(RangeError, function() { + sample.set(src, 0); + }, "2 + 0 > 1"); + + sample = new TA(1); + src = new TA(0); + assert.throws(RangeError, function() { + sample.set(src, 2); + }, "0 + 2 > 1"); + + sample = new TA(2); + src = new TA(2); + assert.throws(RangeError, function() { + sample.set(src, Infinity); + }, "2 + Infinity > 2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js new file mode 100644 index 00000000000..9674ddceaf7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Throws a TypeError if srcBuffer is detached on ToInteger(offset) +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). + ... + 11. Let srcBuffer be the value of typedArray's [[ViewedArrayBuffer]] internal + slot. + 12. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + var target = new TA(); + var calledOffset = 0; + var obj = { + valueOf: function() { + $DETACHBUFFER(target.buffer); + calledOffset += 1; + } + }; + + assert.throws(TypeError, function() { + sample.set(target, obj); + }); + + assert.sameValue(calledOffset, 1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js new file mode 100644 index 00000000000..35a04143cc0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Uses target's internal [[ArrayLength]] +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + 2. Let target be the this value. + ... + 10. Let targetLength be the value of target's [[ArrayLength]] internal slot. + ... + 22. If srcLength + targetOffset > targetLength, throw a RangeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var src = new TA([42n, 43n]); + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.set(src); + + assert.sameValue(getCalls, 0, "ignores length properties"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js new file mode 100644 index 00000000000..ae28fbb8ab0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Uses target's internal [[ArrayLength]] +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + 2. Let target be the this value. + ... + 16. Let targetByteOffset be target.[[ByteOffset]]. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "byteOffset", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var src = new TA([42n, 43n]); + var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array; + var src2 = new other([42n, 43n]); + var src3 = new other(sample.buffer, 0, 2); + + Object.defineProperty(TA.prototype, "byteOffset", desc); + Object.defineProperty(sample, "byteOffset", desc); + + sample.set(src); + sample.set(src2); + sample.set(src3); + + assert.sameValue(getCalls, 0, "ignores byteoffset properties"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js new file mode 100644 index 00000000000..7d46d9031ad --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: Error when target SendableTypedArray fails boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, SendableTypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.set, + 'function', + 'implements SendableTypedArray.prototype.set' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 4}); + var target = new TA(ab, 0, 4); + var source = new TA(new ArrayBuffer(BPE * 4)); + + var expectedError; + try { + ab.resize(BPE * 3); + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the reverse operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + target.set(source, 0); + throw new Test262Error('The `set` operation completed successfully.'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js new file mode 100644 index 00000000000..fe173872305 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Throws a TypeError if targetBuffer is detached on ToInteger(offset) +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). + ... + 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal + slot. + 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var src = new TA(1); + var calledOffset = 0; + var obj = { + valueOf: function() { + $DETACHBUFFER(sample.buffer); + calledOffset += 1; + } + }; + + assert.throws(TypeError, function() { + sample.set(src, obj); + }); + + assert.sameValue(calledOffset, 1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/undefined-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/undefined-tobigint.js new file mode 100644 index 00000000000..938dc7805e2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/undefined-tobigint.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Return abrupt on undefined +info: | + %SendableTypedArray%.prototype.set ( array [ , offset ] ) + Sets multiple values in this SendableTypedArray, reading the values from the object + array. The optional offset value indicates the first element index in this + SendableTypedArray where values are written. If omitted, it is assumed to be 0. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. Let value be ? Get(src, Pk). + d. If target.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array", + let value be ? ToBigInt(value). + e. Otherwise, let value be ? ToNumber(value). + f. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + g. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumbervalue, true, "Unordered"). + h. Set k to k + 1. + i. Set targetByteIndex to targetByteIndex + targetElementSize. + ... + + ToBigInt ( argument ) + Object, Apply the following steps: + 1. Let prim be ? ToPrimitive(argument, hint Number). + 2. Return the value that prim corresponds to in Table [BigInt Conversions] + + BigInt Conversions + Argument Type: Undefined + Result: Throw a TypeError exception. + +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var typedArray = new TA(1); + + assert.throws(TypeError, function() { + typedArray.set([undefined]); + }, "abrupt completion from undefined"); + +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js new file mode 100644 index 00000000000..c1dadf622af --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Throw a RangeError exception if targetOffset < 0 +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). + 7. If targetOffset < 0, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(4); + + assert.throws(RangeError, function() { + sample.set([1], -1); + }, "-1"); + + assert.throws(RangeError, function() { + sample.set([1], -1.00001); + }, "-1.00001"); + + assert.throws(RangeError, function() { + sample.set([1], -Infinity); + }, "-Infinity"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js new file mode 100644 index 00000000000..a43342756e9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js @@ -0,0 +1,108 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + ToInteger(offset) operations +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). + 7. If targetOffset < 0, throw a RangeError exception. + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([1, 2]); + sample.set([42], ""); + assert(compareArray(sample, [42, 2]), "the empty string"); + + sample = new TA([1, 2]); + sample.set([42], "0"); + assert(compareArray(sample, [42, 2]), "'0'"); + + sample = new TA([1, 2]); + sample.set([42], false); + assert(compareArray(sample, [42, 2]), "false"); + + sample = new TA([1, 2]); + sample.set([42], 0.1); + assert(compareArray(sample, [42, 2]), "0.1"); + + sample = new TA([1, 2]); + sample.set([42], 0.9); + assert(compareArray(sample, [42, 2]), "0.9"); + + sample = new TA([1, 2]); + sample.set([42], -0.5); + assert(compareArray(sample, [42, 2]), "-0.5"); + + sample = new TA([1, 2]); + sample.set([42], 1.1); + assert(compareArray(sample, [1, 42]), "1.1"); + + sample = new TA([1, 2]); + sample.set([42], NaN); + assert(compareArray(sample, [42, 2]), "NaN"); + + sample = new TA([1, 2]); + sample.set([42], null); + assert(compareArray(sample, [42, 2]), "null"); + + sample = new TA([1, 2]); + sample.set([42], undefined); + assert(compareArray(sample, [42, 2]), "undefined"); + + sample = new TA([1, 2]); + sample.set([42], {}); + assert(compareArray(sample, [42, 2]), "{}"); + + sample = new TA([1, 2]); + sample.set([42], []); + assert(compareArray(sample, [42, 2]), "[]"); + + sample = new TA([1, 2]); + sample.set([42], [0]); + assert(compareArray(sample, [42, 2]), "[0]"); + + sample = new TA([1, 2]); + sample.set([42], true); + assert(compareArray(sample, [1, 42]), "true"); + + sample = new TA([1, 2]); + sample.set([42], "1"); + assert(compareArray(sample, [1, 42]), "'1'"); + + sample = new TA([1, 2]); + sample.set([42], [1]); + assert(compareArray(sample, [1, 42]), "[1]"); + + sample = new TA([1, 2]); + sample.set([42], { valueOf: function() {return 1;} }); + assert(compareArray(sample, [1, 42]), "valueOf"); + + sample = new TA([1, 2]); + sample.set([42], { toString: function() {return 1;} }); + assert(compareArray(sample, [1, 42]), "toString"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js new file mode 100644 index 00000000000..ddfb52a7b71 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Primitive `array` argument is coerced to an object. +info: | + %SendableTypedArray%.prototype.set ( typedArray [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object + with a [[TypedArrayName]] internal slot. If it is such an Object, + the definition in 22.2.3.23.2 applies. + [...] + 14. Let src be ? ToObject(array). + 15. Let srcLength be ? LengthOfArrayLike(src). + [...] + 19. Let limit be targetByteIndex + targetElementSize × srcLength. + 20. Repeat, while targetByteIndex < limit, + a. Let Pk be ! ToString(k). + b. Let value be ? Get(src, Pk). + [...] + d. Otherwise, set value to ? ToNumber(value). + [...] + f. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, Unordered). + [...] +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, Symbol] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var ta1 = new TA([1, 2, 3, 4, 5]); + ta1.set("678", 1); + assert.compareArray(ta1, [1, 6, 7, 8, 5], "string"); + + var ta2 = new TA([1, 2, 3]); + ta2.set(0); + assert.compareArray(ta2, [1, 2, 3], "number"); + + var ta3 = new TA([1, 2, 3]); + ta3.set(true, 2); + assert.compareArray(ta3, [1, 2, 3], "boolean"); + + var ta4 = new TA([1]); + ta4.set(Symbol()); + assert.compareArray(ta4, [1], "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js new file mode 100644 index 00000000000..596eb85f127 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt getting src "length" +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 16. Let srcLength be ? ToLength(? Get(src, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1, 2, 3]); + + assert.throws(Test262Error, function() { + sample.set(obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js new file mode 100644 index 00000000000..59abebffaaf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt from getting src property value +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumber). + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var obj = { + length: 4, + "0": 42, + "1": 43, + "3": 44 + }; + Object.defineProperty(obj, "2", { + get: function() { + throw new Test262Error(); + } + }); + + var sample = new TA([1, 2, 3, 4]); + + assert.throws(Test262Error, function() { + sample.set(obj); + }); + + assert( + compareArray(sample, [42, 43, 3, 4]), + "values are set until exception" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js new file mode 100644 index 00000000000..f6f297a3352 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt getting src "length" as symbol +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 16. Let srcLength be ? ToLength(? Get(src, "length")). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var obj = { + length: Symbol("1") +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1, 2, 3]); + + assert.throws(TypeError, function() { + sample.set(obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js new file mode 100644 index 00000000000..4d559bf5fcd --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt from ToLength(src "length") +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 16. Let srcLength be ? ToLength(? Get(src, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var obj1 = { + length: { + valueOf: function() { + throw new Test262Error(); + } + } +}; + +var obj2 = { + length: { + toString: function() { + throw new Test262Error(); + } + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1, 2, 3]); + + assert.throws(Test262Error, function() { + sample.set(obj1); + }, "valueOf"); + + assert.throws(Test262Error, function() { + sample.set(obj2); + }, "toString"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js new file mode 100644 index 00000000000..71352d91c56 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt from ToNumber(src property symbol value) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumber). + ... +includes: [testTypedArray.js, compareArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var obj = { + length: 4, + "0": 42, + "1": 43, + "2": Symbol("1"), + "3": 44 + }; + + var sample = new TA([1, 2, 3, 4]); + + assert.throws(TypeError, function() { + sample.set(obj); + }); + + assert( + compareArray(sample, [42, 43, 3, 4]), + "values are set until exception" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js new file mode 100644 index 00000000000..5734f285363 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt from ToNumber(src property value) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumber). + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var obj = { + length: 4, + "0": 42, + "1": 43, + "2": { + valueOf: function() { + throw new Test262Error(); + } + }, + "3": 44 + }; + + var sample = new TA([1, 2, 3, 4]); + + assert.throws(Test262Error, function() { + sample.set(obj); + }); + + assert( + compareArray(sample, [42, 43, 3, 4]), + "values are set until exception" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js new file mode 100644 index 00000000000..e8b122f0829 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt from ToInteger(Symbol offset) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + assert.throws(TypeError, function() { + sample.set([1], s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js new file mode 100644 index 00000000000..309efa84ba9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt from ToInteger(offset) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var obj1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var obj2 = { + toString: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(Test262Error, function() { + sample.set([], obj1); + }, "abrupt from valueOf"); + + assert.throws(Test262Error, function() { + sample.set([], obj2); + }, "abrupt from toString"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js new file mode 100644 index 00000000000..b96bc5c36a0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Return abrupt from ToObject(array) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 15. Let src be ? ToObject(array). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1, 2, 3]); + + assert.throws(TypeError, function() { + sample.set(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.set(null); + }, "null"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js new file mode 100644 index 00000000000..26a0d25dd87 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Get and set each value in order +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumber). + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(5); + var calls = []; + var obj = { + length: 3 + }; + Object.defineProperty(obj, 0, { + get: function() { + calls.push(0); + calls.push(sample.join()); + return 42; + } + }); + + Object.defineProperty(obj, 1, { + get: function() { + calls.push(1); + calls.push(sample.join()); + return 43; + } + }); + + Object.defineProperty(obj, 2, { + get: function() { + calls.push(2); + calls.push(sample.join()); + return 44; + } + }); + + Object.defineProperty(obj, 3, { + get: function() { + throw new Test262Error("Should not call obj[3]"); + } + }); + + sample.set(obj, 1); + + assert( + compareArray(sample, [0, 42, 43, 44, 0]), + "values are set for src length" + ); + + assert( + compareArray(calls, [0, "0,0,0,0,0", 1, "0,42,0,0,0", 2, "0,42,43,0,0"]), + "values are set in order" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js new file mode 100644 index 00000000000..0a6520fe754 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Set values to target and return undefined +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + Let Pk be ! ToString(k). + Let kNumber be ? ToNumber(? Get(src, Pk)). + If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). + ... + 22. Return undefined. +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var src = [42, 43]; + var srcObj = { + length: 2, + '0': 7, + '1': 17 + }; + var sample, result; + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 0); + assert(compareArray(sample, [42, 43, 3, 4]), "offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 1); + assert(compareArray(sample, [1, 42, 43, 4]), "offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 2); + assert(compareArray(sample, [1, 2, 42, 43]), "offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + result = sample.set(srcObj, 0); + assert(compareArray(sample, [7, 17, 3, 4]), "offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + result = sample.set(srcObj, 1); + assert(compareArray(sample, [1, 7, 17, 4]), "offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + result = sample.set(srcObj, 2); + assert(compareArray(sample, [1, 2, 7, 17]), "offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js new file mode 100644 index 00000000000..108bb451809 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Values conversions on ToNumber(src property value) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumber). + ... +includes: [byteConversionValues.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { + var sample = new TA([initial]); + + sample.set([value]); + + assert.sameValue(sample[0], expected, "["+value+"] => ["+expected +"]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js new file mode 100644 index 00000000000..6639bde9de0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Type conversions on ToNumber(src property value) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumber). + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var obj1 = { + valueOf: function() { + return 42; + } + }; + + var obj2 = { + toString: function() { + return "42"; + } + }; + + var arr = ["1", "", false, true, null, obj1, obj2, [], [1]]; + + var sample = new TA(arr.length); + var expected = new TA([1, 0, 0, 1, 0, 42, 42, 0, 1]); + + sample.set(arr); + + assert( + compareArray(sample, expected), + "sample: [" + sample + "], expected: [" + expected + "]" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js new file mode 100644 index 00000000000..e234f34b852 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Values from src array are not cached +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 21. Repeat, while targetByteIndex < limit + a. Let Pk be ! ToString(k). + b. Let kNumber be ? ToNumber(? Get(src, Pk)). + c. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + kNumber). + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(5); + var obj = { + length: 5, + '1': 7, + '2': 7, + '3': 7, + '4': 7 + }; + Object.defineProperty(obj, 0, { + get: function() { + obj[1] = 43; + obj[2] = 44; + obj[3] = 45; + obj[4] = 46; + return 42; + } + }); + + sample.set(obj); + + assert(compareArray(sample, [42, 43, 44, 45, 46])); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js new file mode 100644 index 00000000000..073a0bce78c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Uses target's internal [[ArrayLength]] +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 10. Let targetLength be the value of target's [[ArrayLength]] internal slot. + ... + 17. If srcLength + targetOffset > targetLength, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.set([42, 43]); + + assert.sameValue(getCalls, 0, "ignores length properties"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js new file mode 100644 index 00000000000..18d2763d2b3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Does not throw if target TA is detached mid-iteration +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1, 2, 3]); + var obj = { + length: 3, + "0": 42 + }; + Object.defineProperty(obj, 1, { + get: function() { + $DETACHBUFFER(sample.buffer); + } + }); + let get2Called = false; + Object.defineProperty(obj, 2, { + get: function() { + get2Called = true; + return 2; + } + }); + + sample.set(obj); + + assert.sameValue(true, get2Called); + assert.sameValue(0, sample.byteLength); + assert.sameValue(0, sample.byteOffset); + assert.sameValue(0, sample.length); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js new file mode 100644 index 00000000000..28ef0f00e24 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Throws a TypeError if targetBuffer is detached on ToInteger(offset) +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). + ... + 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal + slot. + 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var calledOffset = 0; + var obj = { + valueOf: function() { + $DETACHBUFFER(sample.buffer); + calledOffset += 1; + } + }; + + assert.throws(TypeError, function() { + sample.set([1], obj); + }); + + assert.sameValue(calledOffset, 1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js new file mode 100644 index 00000000000..106a258660b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-array-offset +description: > + Throws a TypeError if targetBuffer is detached +info: | + 22.2.3.23.1 %SendableTypedArray%.prototype.set (array [ , offset ] ) + + 1. Assert: array is any ECMAScript language value other than an Object with a + [[TypedArrayName]] internal slot. If it is such an Object, the definition in + 22.2.3.23.2 applies. + ... + 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal + slot. + 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + ... + 15. Let src be ? ToObject(array). + 16. Let srcLength be ? ToLength(? Get(src, "length")). + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + } +}); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + $DETACHBUFFER(sample.buffer); + + assert.throws(TypeError, function() { + sample.set([1]); + }, "regular check"); + + assert.throws(TypeError, function() { + sample.set(obj); + }, "IsDetachedBuffer happens before Get(src.length)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-value-conversion-resizes-array-buffer.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-value-conversion-resizes-array-buffer.js new file mode 100644 index 00000000000..0257f785381 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-value-conversion-resizes-array-buffer.js @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-settypedarrayfromarraylike +description: > + Value conversion shrinks and then grows the array buffer. +info: | + 23.2.3.26.2 SetSendableTypedArrayFromArrayLike ( target, targetOffset, source ) + ... + 9. Repeat, while k < srcLength, + a. Let Pk be ! ToString(𝔽(k)). + b. Let value be ? Get(src, Pk). + c. Let targetIndex be 𝔽(targetOffset + k). + d. Perform ? SendableTypedArraySetElement(target, targetIndex, value). + e. Set k to k + 1. + +features: [resizable-arraybuffer] +includes: [compareArray.js] +---*/ + +var rab = new ArrayBuffer(5, {maxByteLength: 10}); +var typedArray = new Int8Array(rab); + +var log = []; + +var growNumber = 0 + +var grow = { + valueOf() { + log.push("grow"); + rab.resize(rab.byteLength + 1); + return --growNumber; + } +}; + +var shrinkNumber = 0 + +var shrink = { + valueOf() { + log.push("shrink"); + rab.resize(rab.byteLength - 1); + return ++shrinkNumber; + } +}; + +var array = { + get length() { + return 5; + }, + 0: shrink, + 1: shrink, + 2: shrink, + 3: grow, + 4: grow, +} + +typedArray.set(array); + +assert.compareArray(log, [ + "shrink", "shrink", "shrink", "grow", "grow", +]); + +assert.compareArray(typedArray, [ + 1, 2, 0, 0 +]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js b/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js new file mode 100644 index 00000000000..551c9c5b459 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set.2 +description: Preservation of bit-level encoding +info: | + [...] + 28. Else, + a. NOTE: If srcType and targetType are the same, the transfer must be + performed in a manner that preserves the bit-level encoding of the + source data. + b. Repeat, while targetByteIndex < limit + i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8"). + ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8", + value). + iii. Set srcByteIndex to srcByteIndex + 1. + iv. Set targetByteIndex to targetByteIndex + 1. +includes: [nans.js, compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +function body(FA) { + var source = new FA(NaNs); + var target = new FA(NaNs.length); + var sourceBytes, targetBytes; + + target.set(source); + + sourceBytes = new Uint8Array(source.buffer); + targetBytes = new Uint8Array(target.buffer); + + assert(compareArray(sourceBytes, targetBytes)) +} + +testWithSendableTypedArrayConstructors(body, floatArrayConstructors); diff --git a/test/sendable/builtins/TypedArray/prototype/set/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/set/invoked-as-func.js new file mode 100644 index 00000000000..1c4d235e640 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/invoked-as-func.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.22 %SendableTypedArray%.prototype.set ( overloaded [ , offset ]) + + This function is not generic. The this value must be an object with a + [[TypedArrayName]] internal slot. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var set = SendableTypedArray.prototype.set; + +assert.sameValue(typeof set, 'function'); + +assert.throws(TypeError, function() { + set(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/set/invoked-as-method.js new file mode 100644 index 00000000000..a75238f3cf5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/invoked-as-method.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.22 %SendableTypedArray%.prototype.set ( overloaded [ , offset ]) + + This function is not generic. The this value must be an object with a + [[TypedArrayName]] internal slot. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.set, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.set(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/length.js b/test/sendable/builtins/TypedArray/prototype/set/length.js new file mode 100644 index 00000000000..b771286f197 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set +description: > + %SendableTypedArray%.prototype.set.length is 1. +info: | + %SendableTypedArray%.prototype.set ( overloaded [ , offset ]) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.set, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/name.js b/test/sendable/builtins/TypedArray/prototype/set/name.js new file mode 100644 index 00000000000..27921276d77 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set +description: > + %SendableTypedArray%.prototype.set.name is "set". +info: | + %SendableTypedArray%.prototype.set ( overloaded [ , offset ]) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.set, "name", { + value: "set", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/set/not-a-constructor.js new file mode 100644 index 00000000000..00d63c3321b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.set 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.set), + false, + 'isConstructor(SendableTypedArray.prototype.set) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.set([0], 0); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/set/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/set/prop-desc.js new file mode 100644 index 00000000000..96717681c8a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set +description: > + "set" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'set', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js b/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js new file mode 100644 index 00000000000..d88dbe38de4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + If typedArray set argument is a Big(U)Int, and target not "Big", throw +info: | + %SendableTypedArray%.prototype.set( typedArray [ , offset ] ) + Sets multiple values in this SendableTypedArray, reading the values from the + typedArray argument object. The optional offset value indicates the first + element index in this SendableTypedArray where values are written. If omitted, it + is assumed to be 0. + ... + 23. If one of srcType and targetType contains the substring "Big" and the + other does not, throw a TypeError exception. + ... + +includes: [testBigIntSendableTypedArray.js, testTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var bigSendableTypedArray; +var littleSendableTypedArray; + +testWithBigIntSendableTypedArrayConstructors(function(BTA) { + + bigSendableTypedArray = new BTA([1n]); + + testWithSendableTypedArrayConstructors(function(TA) { + + littleSendableTypedArray = new TA(1); + assert.throws(TypeError, function() { + littleSendableTypedArray.set(bigSendableTypedArray); + }); + }); + +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/target-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/set/target-grow-mid-iteration.js new file mode 100644 index 00000000000..857a90b8218 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/target-grow-mid-iteration.js @@ -0,0 +1,125 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set +description: > + SendableTypedArray.p.set behaves correctly on SendableTypedArrays backed by resizable buffers + that are grown mid-iteration due to a Proxy source. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Resizing will happen when we're calling Get for the `resizeAt`:th data +// element, but we haven't yet written it to the target. +function CreateSourceProxy(length, rab, resizeAt, resizeTo) { + let requestedIndices = []; + return new Proxy({}, { + get(target, prop, receiver) { + if (prop == 'length') { + return length; + } + requestedIndices.push(prop); + if (requestedIndices.length == resizeAt) { + rab.resize(resizeTo); + } + return true; // Can be converted to both BigInt and Number. + } + }); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + const resizeAt = 2; + const resizeTo = 6 * ctor.BYTES_PER_ELEMENT; + fixedLength.set(CreateSourceProxy(4, rab, resizeAt, resizeTo)); + assert.compareArray(ToNumbers(fixedLength), [ + 1, + 1, + 1, + 1 + ]); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 1, + 1, + 1, + 1, + 0, + 0 + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const resizeAt = 1; + const resizeTo = 6 * ctor.BYTES_PER_ELEMENT; + fixedLengthWithOffset.set(CreateSourceProxy(2, rab, resizeAt, resizeTo)); + assert.compareArray(ToNumbers(fixedLengthWithOffset), [ + 1, + 1 + ]); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 0, + 2, + 1, + 1, + 0, + 0 + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + const resizeAt = 2; + const resizeTo = 6 * ctor.BYTES_PER_ELEMENT; + lengthTracking.set(CreateSourceProxy(2, rab, resizeAt, resizeTo)); + assert.compareArray(ToNumbers(lengthTracking), [ + 1, + 1, + 4, + 6, + 0, + 0 + ]); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 1, + 1, + 4, + 6, + 0, + 0 + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const resizeAt = 1; + const resizeTo = 6 * ctor.BYTES_PER_ELEMENT; + lengthTrackingWithOffset.set(CreateSourceProxy(2, rab, resizeAt, resizeTo)); + assert.compareArray(ToNumbers(lengthTrackingWithOffset), [ + 1, + 1, + 0, + 0 + ]); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 0, + 2, + 1, + 1, + 0, + 0 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/set/target-grow-source-length-getter.js b/test/sendable/builtins/TypedArray/prototype/set/target-grow-source-length-getter.js new file mode 100644 index 00000000000..64d75719ec5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/target-grow-source-length-getter.js @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set +description: > + SendableTypedArray.p.set behaves correctly on SendableTypedArrays backed by a + resizable buffer is grown due to the source's length getter +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +function CreateSourceProxy(length, rab, resizeTo) { + return new Proxy({}, { + get(target, prop, receiver) { + if (prop == 'length') { + rab.resize(resizeTo); + return length; + } + return true; // Can be converted to both BigInt and Number. + } + }); +} + +// Test that we still throw for lengthTracking TAs if the source length is +// too large, even though we resized in the length getter (we check against +// the original length). +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + const resizeTo = 6 * ctor.BYTES_PER_ELEMENT; + assert.throws(RangeError, () => { + lengthTracking.set(CreateSourceProxy(6, rab, resizeTo)); + }); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 0, + 2, + 4, + 6, + 0, + 0 + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const resizeTo = 6 * ctor.BYTES_PER_ELEMENT; + assert.throws(RangeError, () => { + lengthTrackingWithOffset.set(CreateSourceProxy(4, rab, resizeTo)); + }); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 0, + 2, + 4, + 6, + 0, + 0 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/set/target-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/set/target-shrink-mid-iteration.js new file mode 100644 index 00000000000..03428a72da5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/target-shrink-mid-iteration.js @@ -0,0 +1,111 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set +description: > + SendableTypedArray.p.set behaves correctly on SendableTypedArrays backed by resizable buffers + that are shrunk mid-iteration due to a Proxy source. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +// Resizing will happen when we're calling Get for the `resizeAt`:th data +// element, but we haven't yet written it to the target. +function CreateSourceProxy(length, rab, resizeAt, resizeTo) { + let requestedIndices = []; + return new Proxy({}, { + get(target, prop, receiver) { + if (prop == 'length') { + return length; + } + requestedIndices.push(prop); + if (requestedIndices.length == resizeAt) { + rab.resize(resizeTo); + } + return true; // Can be converted to both BigInt and Number. + } + }); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + const resizeAt = 2; + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + fixedLength.set(CreateSourceProxy(4, rab, resizeAt, resizeTo)); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 1, + 2, + 4 + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const resizeAt = 2; + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + fixedLengthWithOffset.set(CreateSourceProxy(2, rab, resizeAt, resizeTo)); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 0, + 2, + 1 + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + const resizeAt = 2; + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + lengthTracking.set(CreateSourceProxy(2, rab, resizeAt, resizeTo)); + assert.compareArray(ToNumbers(lengthTracking), [ + 1, + 1, + 4 + ]); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 1, + 1, + 4 + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const resizeAt = 2; + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + lengthTrackingWithOffset.set(CreateSourceProxy(2, rab, resizeAt, resizeTo)); + assert.compareArray(ToNumbers(lengthTrackingWithOffset), [1]); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 0, + 2, + 1 + ]); +} + +// Length-tracking TA goes OOB because of the offset. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const resizeAt = 1; + const resizeTo = 1 * ctor.BYTES_PER_ELEMENT; + lengthTrackingWithOffset.set(CreateSourceProxy(2, rab, resizeAt, resizeTo)); + assert.compareArray(ToNumbers(new ctor(rab)), [0]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/set/target-shrink-source-length-getter.js b/test/sendable/builtins/TypedArray/prototype/set/target-shrink-source-length-getter.js new file mode 100644 index 00000000000..3a21bbbd590 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/target-shrink-source-length-getter.js @@ -0,0 +1,159 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set +description: > + SendableTypedArray.p.set behaves correctly on SendableTypedArrays backed by resizable buffers + that are shrunk due to the source's length getter. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +function CreateSourceProxy(length, rab, resizeTo) { + return new Proxy({}, { + get(target, prop, receiver) { + if (prop == 'length') { + rab.resize(resizeTo); + return length; + } + return true; // Can be converted to both BigInt and Number. + } + }); +} + +// Tests where the length getter returns a non-zero value -> these are nop if +// the TA went OOB. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + fixedLength.set(CreateSourceProxy(1, rab, resizeTo)); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 0, + 2, + 4 + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + fixedLengthWithOffset.set(CreateSourceProxy(1, rab, resizeTo)); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 0, + 2, + 4 + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + lengthTracking.set(CreateSourceProxy(1, rab, resizeTo)); + assert.compareArray(ToNumbers(lengthTracking), [ + 1, + 2, + 4 + ]); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 1, + 2, + 4 + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + lengthTrackingWithOffset.set(CreateSourceProxy(1, rab, resizeTo)); + assert.compareArray(ToNumbers(lengthTrackingWithOffset), [1]); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 0, + 2, + 1 + ]); +} + +// Length-tracking TA goes OOB because of the offset. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const resizeTo = 1 * ctor.BYTES_PER_ELEMENT; + lengthTrackingWithOffset.set(CreateSourceProxy(1, rab, resizeTo)); + assert.compareArray(ToNumbers(new ctor(rab)), [0]); +} + +// Tests where the length getter returns a zero -> these don't throw even if +// the TA went OOB. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + fixedLength.set(CreateSourceProxy(0, rab, resizeTo)); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 0, + 2, + 4 + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + fixedLengthWithOffset.set(CreateSourceProxy(0, rab, resizeTo)); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 0, + 2, + 4 + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + lengthTracking.set(CreateSourceProxy(0, rab, resizeTo)); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 0, + 2, + 4 + ]); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + lengthTrackingWithOffset.set(CreateSourceProxy(0, rab, resizeTo)); + assert.compareArray(ToNumbers(new ctor(rab)), [ + 0, + 2, + 4 + ]); +} + +// Length-tracking TA goes OOB because of the offset. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const resizeTo = 1 * ctor.BYTES_PER_ELEMENT; + lengthTrackingWithOffset.set(CreateSourceProxy(0, rab, resizeTo)); + assert.compareArray(ToNumbers(new ctor(rab)), [0]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/set/this-backed-by-resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/set/this-backed-by-resizable-buffer.js new file mode 100644 index 00000000000..fbab9766bb0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/this-backed-by-resizable-buffer.js @@ -0,0 +1,537 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set +description: > + SendableTypedArray.p.set behaves correctly on SendableTypedArrays backed by resizable buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function SetNumOrBigInt(target, source, offset) { + if (target instanceof BigInt64Array || target instanceof BigUint64Array) { + const bigIntSource = []; + for (const s of source) { + bigIntSource.push(BigInt(s)); + } + source = bigIntSource; + } + if (offset == undefined) { + return target.set(source); + } + return target.set(source, offset); +} + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const taFull = new ctor(rab); + + // Orig. array: [0, 0, 0, 0] + // [0, 0, 0, 0] << fixedLength + // [0, 0] << fixedLengthWithOffset + // [0, 0, 0, 0, ...] << lengthTracking + // [0, 0, ...] << lengthTrackingWithOffset + + // For making sure we're not calling the source length or element getters + // if the target is OOB. + const throwingProxy = new Proxy({}, { + get(target, prop, receiver) { + throw new Error('Called getter for ' + prop); + } + }); + SetNumOrBigInt(fixedLength, [ + 1, + 2 + ]); + assert.compareArray(ToNumbers(taFull), [ + 1, + 2, + 0, + 0 + ]); + SetNumOrBigInt(fixedLength, [ + 3, + 4 + ], 1); + assert.compareArray(ToNumbers(taFull), [ + 1, + 3, + 4, + 0 + ]); + assert.throws(RangeError, () => { + SetNumOrBigInt(fixedLength, [ + 0, + 0, + 0, + 0, + 0 + ]); + }); + assert.throws(RangeError, () => { + SetNumOrBigInt(fixedLength, [ + 0, + 0, + 0, + 0 + ], 1); + }); + assert.compareArray(ToNumbers(taFull), [ + 1, + 3, + 4, + 0 + ]); + SetNumOrBigInt(fixedLengthWithOffset, [ + 5, + 6 + ]); + assert.compareArray(ToNumbers(taFull), [ + 1, + 3, + 5, + 6 + ]); + SetNumOrBigInt(fixedLengthWithOffset, [7], 1); + assert.compareArray(ToNumbers(taFull), [ + 1, + 3, + 5, + 7 + ]); + assert.throws(RangeError, () => { + SetNumOrBigInt(fixedLengthWithOffset, [ + 0, + 0, + 0 + ]); + }); + assert.throws(RangeError, () => { + SetNumOrBigInt(fixedLengthWithOffset, [ + 0, + 0 + ], 1); + }); + assert.compareArray(ToNumbers(taFull), [ + 1, + 3, + 5, + 7 + ]); + SetNumOrBigInt(lengthTracking, [ + 8, + 9 + ]); + assert.compareArray(ToNumbers(taFull), [ + 8, + 9, + 5, + 7 + ]); + SetNumOrBigInt(lengthTracking, [ + 10, + 11 + ], 1); + assert.compareArray(ToNumbers(taFull), [ + 8, + 10, + 11, + 7 + ]); + assert.throws(RangeError, () => { + SetNumOrBigInt(lengthTracking, [ + 0, + 0, + 0, + 0, + 0 + ]); + }); + assert.throws(RangeError, () => { + SetNumOrBigInt(lengthTracking, [ + 0, + 0, + 0, + 0 + ], 1); + }); + assert.compareArray(ToNumbers(taFull), [ + 8, + 10, + 11, + 7 + ]); + SetNumOrBigInt(lengthTrackingWithOffset, [ + 12, + 13 + ]); + assert.compareArray(ToNumbers(taFull), [ + 8, + 10, + 12, + 13 + ]); + SetNumOrBigInt(lengthTrackingWithOffset, [14], 1); + assert.compareArray(ToNumbers(taFull), [ + 8, + 10, + 12, + 14 + ]); + assert.throws(RangeError, () => { + SetNumOrBigInt(lengthTrackingWithOffset, [ + 0, + 0, + 0 + ]); + }); + assert.throws(RangeError, () => { + SetNumOrBigInt(lengthTrackingWithOffset, [ + 0, + 0 + ], 1); + }); + assert.compareArray(ToNumbers(taFull), [ + 8, + 10, + 12, + 14 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [8, 10, 12] + // [8, 10, 12, ...] << lengthTracking + // [12, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + SetNumOrBigInt(fixedLength, throwingProxy); + }); + assert.throws(TypeError, () => { + SetNumOrBigInt(fixedLengthWithOffset, throwingProxy); + }); + assert.compareArray(ToNumbers(taFull), [ + 8, + 10, + 12 + ]); + SetNumOrBigInt(lengthTracking, [ + 15, + 16 + ]); + assert.compareArray(ToNumbers(taFull), [ + 15, + 16, + 12 + ]); + SetNumOrBigInt(lengthTracking, [ + 17, + 18 + ], 1); + assert.compareArray(ToNumbers(taFull), [ + 15, + 17, + 18 + ]); + assert.throws(RangeError, () => { + SetNumOrBigInt(lengthTracking, [ + 0, + 0, + 0, + 0 + ]); + }); + assert.throws(RangeError, () => { + SetNumOrBigInt(lengthTracking, [ + 0, + 0, + 0 + ], 1); + }); + assert.compareArray(ToNumbers(taFull), [ + 15, + 17, + 18 + ]); + SetNumOrBigInt(lengthTrackingWithOffset, [19]); + assert.compareArray(ToNumbers(taFull), [ + 15, + 17, + 19 + ]); + assert.throws(RangeError, () => { + SetNumOrBigInt(lengthTrackingWithOffset, [ + 0, + 0 + ]); + }); + assert.throws(RangeError, () => { + SetNumOrBigInt(lengthTrackingWithOffset, [0], 1); + }); + assert.compareArray(ToNumbers(taFull), [ + 15, + 17, + 19 + ]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + SetNumOrBigInt(fixedLength, throwingProxy); + }); + assert.throws(TypeError, () => { + SetNumOrBigInt(fixedLengthWithOffset, throwingProxy); + }); + assert.throws(TypeError, () => { + SetNumOrBigInt(lengthTrackingWithOffset, throwingProxy); + }); + assert.compareArray(ToNumbers(taFull), [15]); + SetNumOrBigInt(lengthTracking, [20]); + assert.compareArray(ToNumbers(taFull), [20]); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + SetNumOrBigInt(fixedLength, throwingProxy); + }); + assert.throws(TypeError, () => { + SetNumOrBigInt(fixedLengthWithOffset, throwingProxy); + }); + assert.throws(TypeError, () => { + SetNumOrBigInt(lengthTrackingWithOffset, throwingProxy); + }); + assert.throws(RangeError, () => { + SetNumOrBigInt(lengthTracking, [0]); + }); + assert.compareArray(ToNumbers(taFull), []); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 0, 0, 0, 0, 0] + // [0, 0, 0, 0] << fixedLength + // [0, 0] << fixedLengthWithOffset + // [0, 0, 0, 0, 0, 0, ...] << lengthTracking + // [0, 0, 0, 0, ...] << lengthTrackingWithOffset + SetNumOrBigInt(fixedLength, [ + 21, + 22 + ]); + assert.compareArray(ToNumbers(taFull), [ + 21, + 22, + 0, + 0, + 0, + 0 + ]); + SetNumOrBigInt(fixedLength, [ + 23, + 24 + ], 1); + assert.compareArray(ToNumbers(taFull), [ + 21, + 23, + 24, + 0, + 0, + 0 + ]); + assert.throws(RangeError, () => { + SetNumOrBigInt(fixedLength, [ + 0, + 0, + 0, + 0, + 0 + ]); + }); + assert.throws(RangeError, () => { + SetNumOrBigInt(fixedLength, [ + 0, + 0, + 0, + 0 + ], 1); + }); + assert.compareArray(ToNumbers(taFull), [ + 21, + 23, + 24, + 0, + 0, + 0 + ]); + SetNumOrBigInt(fixedLengthWithOffset, [ + 25, + 26 + ]); + assert.compareArray(ToNumbers(taFull), [ + 21, + 23, + 25, + 26, + 0, + 0 + ]); + SetNumOrBigInt(fixedLengthWithOffset, [27], 1); + assert.compareArray(ToNumbers(taFull), [ + 21, + 23, + 25, + 27, + 0, + 0 + ]); + assert.throws(RangeError, () => { + SetNumOrBigInt(fixedLengthWithOffset, [ + 0, + 0, + 0 + ]); + }); + assert.throws(RangeError, () => { + SetNumOrBigInt(fixedLengthWithOffset, [ + 0, + 0 + ], 1); + }); + assert.compareArray(ToNumbers(taFull), [ + 21, + 23, + 25, + 27, + 0, + 0 + ]); + SetNumOrBigInt(lengthTracking, [ + 28, + 29, + 30, + 31, + 32, + 33 + ]); + assert.compareArray(ToNumbers(taFull), [ + 28, + 29, + 30, + 31, + 32, + 33 + ]); + SetNumOrBigInt(lengthTracking, [ + 34, + 35, + 36, + 37, + 38 + ], 1); + assert.compareArray(ToNumbers(taFull), [ + 28, + 34, + 35, + 36, + 37, + 38 + ]); + assert.throws(RangeError, () => { + SetNumOrBigInt(lengthTracking, [ + 0, + 0, + 0, + 0, + 0, + 0, + 0 + ]); + }); + assert.throws(RangeError, () => { + SetNumOrBigInt(lengthTracking, [ + 0, + 0, + 0, + 0, + 0, + 0 + ], 1); + }); + assert.compareArray(ToNumbers(taFull), [ + 28, + 34, + 35, + 36, + 37, + 38 + ]); + SetNumOrBigInt(lengthTrackingWithOffset, [ + 39, + 40, + 41, + 42 + ]); + assert.compareArray(ToNumbers(taFull), [ + 28, + 34, + 39, + 40, + 41, + 42 + ]); + SetNumOrBigInt(lengthTrackingWithOffset, [ + 43, + 44, + 45 + ], 1); + assert.compareArray(ToNumbers(taFull), [ + 28, + 34, + 39, + 43, + 44, + 45 + ]); + assert.throws(RangeError, () => { + SetNumOrBigInt(lengthTrackingWithOffset, [ + 0, + 0, + 0, + 0, + 0 + ]); + }); + assert.throws(RangeError, () => { + SetNumOrBigInt(lengthTrackingWithOffset, [ + 0, + 0, + 0, + 0 + ], 1); + }); + assert.compareArray(ToNumbers(taFull), [ + 28, + 34, + 39, + 43, + 44, + 45 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/set/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/set/this-is-not-object.js new file mode 100644 index 00000000000..719a508bd33 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/this-is-not-object.js @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-overloaded-offset +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.23 %SendableTypedArray%.prototype.set + + ... + 2. Let target be the this value. + 3. If Type(target) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var set = SendableTypedArray.prototype.set; + +assert.throws(TypeError, function() { + set.call(undefined, []); +}, "this is undefined"); + +assert.throws(TypeError, function() { + set.call(null, []); +}, "this is null"); + +assert.throws(TypeError, function() { + set.call(undefined, new Int8Array()); +}, "this is undefined"); + +assert.throws(TypeError, function() { + set.call(null, new Int8Array()); +}, "this is null"); + +assert.throws(TypeError, function() { + set.call(42, []); +}, "this is 42"); + +assert.throws(TypeError, function() { + set.call("1", []); +}, "this is a string"); + +assert.throws(TypeError, function() { + set.call(true, []); +}, "this is true"); + +assert.throws(TypeError, function() { + set.call(false, []); +}, "this is false"); + +var s1 = Symbol("s"); +assert.throws(TypeError, function() { + set.call(s1, []); +}, "this is a Symbol"); + +assert.throws(TypeError, function() { + set.call(42, new Int8Array(1)); +}, "this is 42"); + +assert.throws(TypeError, function() { + set.call("1", new Int8Array(1)); +}, "this is a string"); + +assert.throws(TypeError, function() { + set.call(true, new Int8Array(1)); +}, "this is true"); + +assert.throws(TypeError, function() { + set.call(false, new Int8Array(1)); +}, "this is false"); + +var s2 = Symbol("s"); +assert.throws(TypeError, function() { + set.call(s2, new Int8Array(1)); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..a314556edf7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-overloaded-offset +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.23 %SendableTypedArray%.prototype.set + + ... + 2. Let target be the this value. + 3. If Type(target) is not Object, throw a TypeError exception. + 4. If target does not have a [[TypedArrayName]] internal slot, throw a + TypeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var set = SendableTypedArray.prototype.set; + +assert.throws(TypeError, function() { + set.call({}, []); +}, "this is an Object"); + +assert.throws(TypeError, function() { + set.call([], []); +}, "this is an Array"); + +var ab1 = new ArrayBuffer(8); +assert.throws(TypeError, function() { + set.call(ab1, []); +}, "this is an ArrayBuffer instance"); + +var dv1 = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + set.call(dv1, []); +}, "this is a DataView instance"); + +assert.throws(TypeError, function() { + set.call({}, new Int8Array()); +}, "this is an Object"); + +assert.throws(TypeError, function() { + set.call([], new Int8Array()); +}, "this is an Array"); + +var ab2 = new ArrayBuffer(8); +assert.throws(TypeError, function() { + set.call(ab2, new Int8Array()); +}, "this is an ArrayBuffer instance"); + +var dv2 = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + set.call(dv2, new Int8Array()); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js new file mode 100644 index 00000000000..eb788cfda0d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Throw a RangeError exception if targetOffset < 0 +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). + 7. If targetOffset < 0, throw a RangeError exception. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(RangeError, function() { + sample.set(sample, -1); + }, "-1"); + + assert.throws(RangeError, function() { + sample.set(sample, -1.00001); + }, "-1.00001"); + + assert.throws(RangeError, function() { + sample.set(sample, -Infinity); + }, "-Infinity"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js new file mode 100644 index 00000000000..18fb782ea35 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + ToInteger(offset) operations +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + var src = new TA([42]); + + sample = new TA([1, 2]); + sample.set(src, ""); + assert(compareArray(sample, [42, 2]), "the empty string"); + + sample = new TA([1, 2]); + sample.set(src, "0"); + assert(compareArray(sample, [42, 2]), "'0'"); + + sample = new TA([1, 2]); + sample.set(src, false); + assert(compareArray(sample, [42, 2]), "false"); + + sample = new TA([1, 2]); + sample.set(src, 0.1); + assert(compareArray(sample, [42, 2]), "0.1"); + + sample = new TA([1, 2]); + sample.set(src, 0.9); + assert(compareArray(sample, [42, 2]), "0.9"); + + sample = new TA([1, 2]); + sample.set(src, -0.5); + assert(compareArray(sample, [42, 2]), "-0.5"); + + sample = new TA([1, 2]); + sample.set(src, 1.1); + assert(compareArray(sample, [1, 42]), "1.1"); + + sample = new TA([1, 2]); + sample.set(src, NaN); + assert(compareArray(sample, [42, 2]), "NaN"); + + sample = new TA([1, 2]); + sample.set(src, null); + assert(compareArray(sample, [42, 2]), "null"); + + sample = new TA([1, 2]); + sample.set(src, undefined); + assert(compareArray(sample, [42, 2]), "undefined"); + + sample = new TA([1, 2]); + sample.set(src, {}); + assert(compareArray(sample, [42, 2]), "{}"); + + sample = new TA([1, 2]); + sample.set(src, []); + assert(compareArray(sample, [42, 2]), "[]"); + + sample = new TA([1, 2]); + sample.set(src, [0]); + assert(compareArray(sample, [42, 2]), "[0]"); + + sample = new TA([1, 2]); + sample.set(src, true); + assert(compareArray(sample, [1, 42]), "true"); + + sample = new TA([1, 2]); + sample.set(src, "1"); + assert(compareArray(sample, [1, 42]), "'1'"); + + sample = new TA([1, 2]); + sample.set(src, [1]); + assert(compareArray(sample, [1, 42]), "[1]"); + + sample = new TA([1, 2]); + sample.set(src, { valueOf: function() {return 1;} }); + assert(compareArray(sample, [1, 42]), "valueOf"); + + sample = new TA([1, 2]); + sample.set(src, { toString: function() {return 1;} }); + assert(compareArray(sample, [1, 42]), "toString"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js new file mode 100644 index 00000000000..485f3a136d2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Return abrupt from ToInteger(Symbol offset) +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.set(sample, s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js new file mode 100644 index 00000000000..ac4c343d594 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Return abrupt from ToInteger(offset) +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var obj1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var obj2 = { + toString: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(Test262Error, function() { + sample.set(sample, obj1); + }, "abrupt from valueOf"); + + assert.throws(Test262Error, function() { + sample.set(sample, obj2); + }, "abrupt from toString"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js new file mode 100644 index 00000000000..dee9f245859 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set converted values from different buffer of different types and different type instances +includes: [byteConversionValues.js, testTypedArray.js] +features: [SharedArrayBuffer] +---*/ + +testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { + if (TA === Float64Array || TA === Float32Array || (typeof Float16Array !== 'undefined' && TA === Float16Array) || TA === Uint8ClampedArray) { + return; + } + if (TA === Int32Array) { + return; + } + + var sab, src, target; + + sab = new SharedArrayBuffer(4); + src = new Int32Array(sab); + src[0] = value; + target = new TA([initial]); + + target.set(src); + + assert.sameValue(target[0], expected, "src is SAB-backed"); + + sab = new SharedArrayBuffer(4); + src = new Int32Array([value]); + target = new TA(sab); + target[0] = initial; + + target.set(src); + + assert.sameValue(target[0], expected, "target is SAB-backed"); + + var sab1 = new SharedArrayBuffer(4); + var sab2 = new SharedArrayBuffer(4); + src = new Int32Array(sab1); + src[0] = value; + target = new TA(sab2); + target[0] = initial; + + target.set(src); + + assert.sameValue(target[0], expected, "src and target are SAB-backed"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js new file mode 100644 index 00000000000..30974f7fcb9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set converted values from different buffer and different type instances +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 23. If SameValue(srcBuffer, targetBuffer) is true, then + ... + 24. Else, let srcByteIndex be srcByteOffset. + ... + 27. If SameValue(srcType, targetType) is true, then, + ... + 28. Else, + a. Repeat, while targetByteIndex < limit + i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType). + ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + value). +includes: [byteConversionValues.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { + if (TA === Float64Array) { + return; + } + var src = new Float64Array([value]); + var target = new TA([initial]); + + target.set(src); + + assert.sameValue(target[0], expected); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js new file mode 100644 index 00000000000..c1acccbf41a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the different buffer and different + type. +includes: [testTypedArray.js, compareArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; + +testWithSendableTypedArrayConstructors(function(TA) { + var other = Int32Array; + var sab = new SharedArrayBuffer(2 * other.BYTES_PER_ELEMENT); + var src = new other(sab); + src[0] = 42; + src[1] = 43; + var sample, result; + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 0); + assert(compareArray(sample, [42, 43, 3, 4]), "src is SAB-backed, offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 1); + assert(compareArray(sample, [1, 42, 43, 4]), "src is SAB-backed, offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 2); + assert(compareArray(sample, [1, 2, 42, 43]), "src is SAB-backed, offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + + src = new other([42, 43]); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + result = sample.set(src, 0); + assert(compareArray(sample, [42, 43, 3, 4]), "sample is SAB-backed, offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + result = sample.set(src, 1); + assert(compareArray(sample, [1, 42, 43, 4]), "sample is SAB-backed, offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + result = sample.set(src, 2); + assert(compareArray(sample, [1, 2, 42, 43]), "sample is SAB-backed, offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + var sab1 = new SharedArrayBuffer(2 * other.BYTES_PER_ELEMENT); + src = new other(sab1); + src[0] = 42; + src[1] = 43; + + var sab2; + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab2); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + result = sample.set(src, 0); + assert(compareArray(sample, [42, 43, 3, 4]), "src and sample are SAB-backed, offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab2); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + result = sample.set(src, 1); + assert(compareArray(sample, [1, 42, 43, 4]), "src and sample are SAB-backed, offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab2); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + result = sample.set(src, 2); + assert(compareArray(sample, [1, 2, 42, 43]), "src and sample are SAB-backed, offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); +}, int_views); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js new file mode 100644 index 00000000000..1946ef7a150 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the different buffer and different + type. +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 23. If SameValue(srcBuffer, targetBuffer) is true, then + ... + 24. Else, let srcByteIndex be srcByteOffset. + ... + 27. If SameValue(srcType, targetType) is true, then, + ... + 28. Else, + a. Repeat, while targetByteIndex < limit + i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType). + ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + value). +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var other = TA === Float32Array ? Float64Array : Float32Array; + var src = new other([42, 43]); + var sample, result; + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 0); + assert(compareArray(sample, [42, 43, 3, 4]), "offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 1); + assert(compareArray(sample, [1, 42, 43, 4]), "offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 2); + assert(compareArray(sample, [1, 2, 42, 43]), "offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js new file mode 100644 index 00000000000..e7817e768e1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js @@ -0,0 +1,119 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the different buffer and same + constructor. srcBuffer values are cached. +includes: [testTypedArray.js, compareArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample, result; + + var sab = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT); + var src = new TA(sab); + src[0] = 42; + src[1] = 43; + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 1); + assert(compareArray(sample, [1, 42, 43, 4]), "src is SAB-backed, offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 0); + assert(compareArray(sample, [42, 43, 3, 4]), "src is SAB-backed, offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 2); + assert(compareArray(sample, [1, 2, 42, 43]), "src is SAB-backed, offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + + src = new TA([42, 43]); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + result = sample.set(src, 1); + assert(compareArray(sample, [1, 42, 43, 4]), "sample is SAB-backed, offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + result = sample.set(src, 0); + assert(compareArray(sample, [42, 43, 3, 4]), "sample is SAB-backed, offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + result = sample.set(src, 2); + assert(compareArray(sample, [1, 2, 42, 43]), "sample is SAB-backed, offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + + var sab1 = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT); + src = new TA(sab1); + src[0] = 42; + src[1] = 43; + + var sab2; + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab2); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + result = sample.set(src, 1); + assert(compareArray(sample, [1, 42, 43, 4]), "src and sample are SAB-backed, offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab2); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + result = sample.set(src, 0); + assert(compareArray(sample, [42, 43, 3, 4]), "src and sample are SAB-backed, offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab2); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + result = sample.set(src, 2); + assert(compareArray(sample, [1, 2, 42, 43]), "src and sample are SAB-backed, offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); +}, int_views); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js new file mode 100644 index 00000000000..b2be605c069 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the different buffer and same + constructor. srcBuffer values are cached. +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 23. If SameValue(srcBuffer, targetBuffer) is true, then + ... + 24. Else, let srcByteIndex be srcByteOffset. + ... + 27. If SameValue(srcType, targetType) is true, then, + a. NOTE: If srcType and targetType are the same, the transfer must be + performed in a manner that preserves the bit-level encoding of the source + data. + b. Repeat, while targetByteIndex < limit + i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8"). + ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8", + value). + ... + 29. Return undefined. +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample, result; + var src = new TA([42, 43]); + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 1); + assert(compareArray(sample, [1, 42, 43, 4]), "offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 0); + assert(compareArray(sample, [42, 43, 3, 4]), "offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + result = sample.set(src, 2); + assert(compareArray(sample, [1, 2, 42, 43]), "offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js new file mode 100644 index 00000000000..bacb5c0a7af --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the same buffer and different + constructor. +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 23. If SameValue(srcBuffer, targetBuffer) is true, then + a. Let srcBuffer be ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength, + %ArrayBuffer%). + b. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not + have any observable side-effects. + ... + ... + 27. If SameValue(srcType, targetType) is true, then, + ... + 28. Else, + a. Repeat, while targetByteIndex < limit + i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType). + ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, + value). + ... + 29. Return undefined. +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +var expected = { + Float64Array: [1.0000002464512363, 42, 1.875, 4, 5, 6, 7, 8], + Float32Array: [0, 42, 512.0001220703125, 4, 5, 6, 7, 8], + Float16Array: [0, 42, 513, 4, 5, 6, 7, 8], + Int32Array: [1109917696, 42, 0, 4, 5, 6, 7, 8], + Int16Array: [0, 42, 0, 4, 5, 6, 7, 8], + Int8Array: [0, 42, 0, 66, 5, 6, 7, 8], + Uint32Array: [1109917696, 42, 0, 4, 5, 6, 7, 8], + Uint16Array: [0, 42, 0, 4, 5, 6, 7, 8], + Uint8Array: [0, 42, 0, 66, 5, 6, 7, 8], + Uint8ClampedArray: [0, 42, 0, 66, 5, 6, 7, 8] +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var other = TA === Float32Array ? Float64Array : Float32Array; + + var sample = new TA([1, 2, 3, 4, 5, 6, 7, 8]); + var src = new other(sample.buffer, 0, 2); + + // Reflect changes on sample object + src[0] = 42; + + var result = sample.set(src, 1); + + assert(compareArray(sample, expected[TA.name]), sample); + assert.sameValue(result, undefined, "returns undefined"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js new file mode 100644 index 00000000000..41426616da3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the same buffer and same + constructor when underlying ArrayBuffer has been resized +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var source = new TA(ab); + var target = new TA(ab); + var expected = [10, 20, 30, 40]; + + source[0] = 10; + source[1] = 20; + source[2] = 30; + source[3] = 40; + + try { + ab.resize(BPE * 5); + expected = [10, 20, 30, 40, 0]; + } catch (_) {} + + target.set(source); + assert(compareArray(target, expected), 'following grow'); + + try { + ab.resize(BPE * 3); + expected = [10, 20, 30]; + } catch (_) {} + + target.set(source); + assert(compareArray(target, expected), 'following shrink'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js new file mode 100644 index 00000000000..ba99dbcf831 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the same buffer and same + constructor. srcBuffer values are cached. +includes: [testTypedArray.js, compareArray.js] +features: [SharedArrayBuffer, TypedArray] +---*/ + +var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample, src, result, sab; + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + src = new TA(sample.buffer, 0, 2); + result = sample.set(src, 0); + assert(compareArray(sample, [1, 2, 3, 4]), "offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + src = new TA(sample.buffer, 0, 2); + result = sample.set(src, 1); + assert(compareArray(sample, [1, 1, 2, 4]), "offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sample = new TA(sab); + sample[0] = 1; + sample[1] = 2; + sample[2] = 3; + sample[3] = 4; + src = new TA(sample.buffer, 0, 2); + result = sample.set(src, 2); + assert(compareArray(sample, [1, 2, 1, 2]), "offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); +}, int_views); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js new file mode 100644 index 00000000000..d9c7b8d5956 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Set values from different instances using the same buffer and same + constructor. srcBuffer values are cached. +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 23. If SameValue(srcBuffer, targetBuffer) is true, then + a. Let srcBuffer be ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength, + %ArrayBuffer%). + b. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not + have any observable side-effects. + ... + ... + 27. If SameValue(srcType, targetType) is true, then, + a. NOTE: If srcType and targetType are the same, the transfer must be + performed in a manner that preserves the bit-level encoding of the source + data. + b. Repeat, while targetByteIndex < limit + i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8"). + ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8", + value). +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample, src, result; + + sample = new TA([1, 2, 3, 4]); + src = new TA(sample.buffer, 0, 2); + result = sample.set(src, 0); + assert(compareArray(sample, [1, 2, 3, 4]), "offset: 0, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + src = new TA(sample.buffer, 0, 2); + result = sample.set(src, 1); + assert(compareArray(sample, [1, 1, 2, 4]), "offset: 1, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); + + sample = new TA([1, 2, 3, 4]); + src = new TA(sample.buffer, 0, 2); + result = sample.set(src, 2); + assert(compareArray(sample, [1, 2, 1, 2]), "offset: 2, result: " + sample); + assert.sameValue(result, undefined, "returns undefined"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js new file mode 100644 index 00000000000..43910667c9b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Uses typedArray's internal [[ArrayLength]] +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 20. Let srcLength be the value of typedArray's [[ArrayLength]] internal slot. + ... + 22. If srcLength + targetOffset > targetLength, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 42; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var src = new TA([42, 43]); + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(src, "length", desc); + + sample.set(src); + + assert.sameValue(getCalls, 0, "ignores length properties"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-backed-by-resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-backed-by-resizable-buffer.js new file mode 100644 index 00000000000..9df49d52570 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-backed-by-resizable-buffer.js @@ -0,0 +1,241 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set +description: > + SendableTypedArray.p.set behaves correctly on SendableTypedArrays backed by resizable buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function IsBigIntSendableTypedArray(ta) { + return ta instanceof BigInt64Array || ta instanceof BigUint64Array; +} + +function SetNumOrBigInt(target, source, offset) { + if (IsBigIntSendableTypedArray(target)) { + const bigIntSource = []; + for (const s of source) { + bigIntSource.push(BigInt(s)); + } + source = bigIntSource; + } + if (offset == undefined) { + return target.set(source); + } + return target.set(source, offset); +} + +for (let targetIsResizable of [ + false, + true + ]) { + for (let targetCtor of ctors) { + for (let sourceCtor of ctors) { + const rab = CreateResizableArrayBuffer(4 * sourceCtor.BYTES_PER_ELEMENT, 8 * sourceCtor.BYTES_PER_ELEMENT); + const fixedLength = new sourceCtor(rab, 0, 4); + const fixedLengthWithOffset = new sourceCtor(rab, 2 * sourceCtor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new sourceCtor(rab, 0); + const lengthTrackingWithOffset = new sourceCtor(rab, 2 * sourceCtor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taFull = new sourceCtor(rab); + for (let i = 0; i < 4; ++i) { + taFull[i] = MayNeedBigInt(taFull, i + 1); + } + + // Orig. array: [1, 2, 3, 4] + // [1, 2, 3, 4] << fixedLength + // [3, 4] << fixedLengthWithOffset + // [1, 2, 3, 4, ...] << lengthTracking + // [3, 4, ...] << lengthTrackingWithOffset + + const targetAb = targetIsResizable ? new ArrayBuffer(6 * targetCtor.BYTES_PER_ELEMENT) : new ArrayBuffer(6 * targetCtor.BYTES_PER_ELEMENT, { maxByteLength: 8 * targetCtor.BYTES_PER_ELEMENT }); + const target = new targetCtor(targetAb); + if (IsBigIntSendableTypedArray(target) != IsBigIntSendableTypedArray(taFull)) { + // Can't mix BigInt and non-BigInt types. + continue; + } + SetNumOrBigInt(target, fixedLength); + assert.compareArray(ToNumbers(target), [ + 1, + 2, + 3, + 4, + 0, + 0 + ]); + SetNumOrBigInt(target, fixedLengthWithOffset); + assert.compareArray(ToNumbers(target), [ + 3, + 4, + 3, + 4, + 0, + 0 + ]); + SetNumOrBigInt(target, lengthTracking, 1); + assert.compareArray(ToNumbers(target), [ + 3, + 1, + 2, + 3, + 4, + 0 + ]); + SetNumOrBigInt(target, lengthTrackingWithOffset, 1); + assert.compareArray(ToNumbers(target), [ + 3, + 3, + 4, + 3, + 4, + 0 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * sourceCtor.BYTES_PER_ELEMENT); + + // Orig. array: [1, 2, 3] + // [1, 2, 3, ...] << lengthTracking + // [3, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + SetNumOrBigInt(target, fixedLength); + }); + assert.throws(TypeError, () => { + SetNumOrBigInt(target, fixedLengthWithOffset); + }); + assert.compareArray(ToNumbers(target), [ + 3, + 3, + 4, + 3, + 4, + 0 + ]); + SetNumOrBigInt(target, lengthTracking); + assert.compareArray(ToNumbers(target), [ + 1, + 2, + 3, + 3, + 4, + 0 + ]); + SetNumOrBigInt(target, lengthTrackingWithOffset); + assert.compareArray(ToNumbers(target), [ + 3, + 2, + 3, + 3, + 4, + 0 + ]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * sourceCtor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + SetNumOrBigInt(target, fixedLength); + }); + assert.throws(TypeError, () => { + SetNumOrBigInt(target, fixedLengthWithOffset); + }); + assert.throws(TypeError, () => { + SetNumOrBigInt(target, lengthTrackingWithOffset); + }); + SetNumOrBigInt(target, lengthTracking, 3); + assert.compareArray(ToNumbers(target), [ + 3, + 2, + 3, + 1, + 4, + 0 + ]); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + SetNumOrBigInt(target, fixedLength); + }); + assert.throws(TypeError, () => { + SetNumOrBigInt(target, fixedLengthWithOffset); + }); + assert.throws(TypeError, () => { + SetNumOrBigInt(target, lengthTrackingWithOffset); + }); + SetNumOrBigInt(target, lengthTracking, 4); + assert.compareArray(ToNumbers(target), [ + 3, + 2, + 3, + 1, + 4, + 0 + ]); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * sourceCtor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taFull[i] = MayNeedBigInt(taFull, i + 1); + } + + // Orig. array: [1, 2, 3, 4, 5, 6] + // [1, 2, 3, 4] << fixedLength + // [3, 4] << fixedLengthWithOffset + // [1, 2, 3, 4, 5, 6, ...] << lengthTracking + // [3, 4, 5, 6, ...] << lengthTrackingWithOffset + + SetNumOrBigInt(target, fixedLength); + assert.compareArray(ToNumbers(target), [ + 1, + 2, + 3, + 4, + 4, + 0 + ]); + SetNumOrBigInt(target, fixedLengthWithOffset); + assert.compareArray(ToNumbers(target), [ + 3, + 4, + 3, + 4, + 4, + 0 + ]); + SetNumOrBigInt(target, lengthTracking, 0); + assert.compareArray(ToNumbers(target), [ + 1, + 2, + 3, + 4, + 5, + 6 + ]); + SetNumOrBigInt(target, lengthTrackingWithOffset, 1); + assert.compareArray(ToNumbers(target), [ + 1, + 3, + 4, + 5, + 6, + 6 + ]); + } + } +} diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js new file mode 100644 index 00000000000..fb730327b0d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Uses typedArray's internal [[ByteOffset]] +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 21. Let srcByteOffset be typedArray.[[ByteOffset]]. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "byteOffset", desc); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var src = new TA([42, 43]); + var differentTA = TA === Uint8Array ? Int8Array : Uint8Array; + var src2 = new differentTA([42, 43]); + var src3 = new differentTA(sample.buffer, 0, 2); + + Object.defineProperty(TA.prototype, "byteOffset", desc); + Object.defineProperty(src, "byteOffset", desc); + Object.defineProperty(src2, "byteOffset", desc); + Object.defineProperty(src3, "byteOffset", desc); + + sample.set(src); + sample.set(src2); + sample.set(src3); + + assert.sameValue(getCalls, 0, "ignores byteOffset properties"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js new file mode 100644 index 00000000000..9dc257abf3d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + If srcLength + targetOffset > targetLength, throw a RangeError exception. +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). + ... + 10. Let targetLength be the value of target's [[ArrayLength]] internal slot. + ... + 20. Let srcLength be the value of typedArray's [[ArrayLength]] internal slot. + ... + 22. If srcLength + targetOffset > targetLength, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample, src; + + sample = new TA(2); + src = new TA(2); + assert.throws(RangeError, function() { + sample.set(src, 1); + }, "2 + 1 > 2"); + + sample = new TA(1); + src = new TA(2); + assert.throws(RangeError, function() { + sample.set(src, 0); + }, "2 + 0 > 1"); + + sample = new TA(1); + src = new TA(0); + assert.throws(RangeError, function() { + sample.set(src, 2); + }, "0 + 2 > 1"); + + sample = new TA(2); + src = new TA(2); + assert.throws(RangeError, function() { + sample.set(src, Infinity); + }, "2 + Infinity > 2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js new file mode 100644 index 00000000000..77d5ddb855c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Throws a TypeError if srcBuffer is detached on ToInteger(offset) +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). + ... + 11. Let srcBuffer be the value of typedArray's [[ViewedArrayBuffer]] internal + slot. + 12. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + var target = new TA(); + var calledOffset = 0; + var obj = { + valueOf: function() { + $DETACHBUFFER(target.buffer); + calledOffset += 1; + } + }; + + assert.throws(TypeError, function() { + sample.set(target, obj); + }); + + assert.sameValue(calledOffset, 1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js new file mode 100644 index 00000000000..7decf8d948c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Uses target's internal [[ArrayLength]] +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + 2. Let target be the this value. + ... + 10. Let targetLength be the value of target's [[ArrayLength]] internal slot. + ... + 22. If srcLength + targetOffset > targetLength, throw a RangeError exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var src = new TA([42, 43]); + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.set(src); + + assert.sameValue(getCalls, 0, "ignores length properties"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js new file mode 100644 index 00000000000..a910a9ac4a7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Uses target's internal [[ArrayLength]] +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + 2. Let target be the this value. + ... + 16. Let targetByteOffset be target.[[ByteOffset]]. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "byteOffset", desc); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var src = new TA([42, 43]); + var differentTA = TA === Uint8Array ? Int8Array : Uint8Array; + var src2 = new differentTA([42, 43]); + var src3 = new differentTA(sample.buffer, 0, 2); + + Object.defineProperty(TA.prototype, "byteOffset", desc); + Object.defineProperty(sample, "byteOffset", desc); + + sample.set(src); + sample.set(src2); + sample.set(src3); + + assert.sameValue(getCalls, 0, "ignores byteoffset properties"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js new file mode 100644 index 00000000000..1640988d501 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: Error when target SendableTypedArray fails boundary checks +includes: [testTypedArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.set, + 'function', + 'implements SendableTypedArray.prototype.set' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 4}); + var target = new TA(ab, 0, 4); + var source = new TA(new ArrayBuffer(BPE * 4)); + + var expectedError; + try { + ab.resize(BPE * 3); + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the reverse operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + target.set(source, 0); + throw new Test262Error('The `set` operation completed successfully.'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js new file mode 100644 index 00000000000..bd2ab0a1884 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.set-typedarray-offset +description: > + Throws a TypeError if targetBuffer is detached on ToInteger(offset) +info: | + 22.2.3.23.2 %SendableTypedArray%.prototype.set(typedArray [ , offset ] ) + + 1. Assert: typedArray has a [[TypedArrayName]] internal slot. If it does not, + the definition in 22.2.3.23.1 applies. + ... + 6. Let targetOffset be ? ToInteger(offset). + ... + 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal + slot. + 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var src = new TA(1); + var calledOffset = 0; + var obj = { + valueOf: function() { + $DETACHBUFFER(sample.buffer); + calledOffset += 1; + } + }; + + assert.throws(TypeError, function() { + sample.set(src, obj); + }); + + assert.sameValue(calledOffset, 1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js new file mode 100644 index 00000000000..3be5f74e992 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Use internal ArrayLength instead of getting a length property +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 3. Let len be the value of O's [[ArrayLength]] internal slot. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n]); + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + var result = sample.slice(); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert.sameValue(result[0], 42n); + assert.sameValue(result[1], 43n); + assert.sameValue(result.hasOwnProperty(2), false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js new file mode 100644 index 00000000000..f3323a89e06 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during create with custom constructor (other targetType) +info: | + %SendableTypedArray%.prototype.slice ( start, end ) + + Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + + SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + SendableTypedArrayCreate ( constructor, argumentList ) + + Let newSendableTypedArray be ? Construct(constructor, argumentList). + Perform ? ValidateSendableTypedArray(newSendableTypedArray). + + ValidateSendableTypedArray ( O ) + The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: + + Perform ? RequireInternalSlot(O, [[TypedArrayName]]). + Assert: O has a [[ViewedArrayBuffer]] internal slot. + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + let counter = 0; + var sample = new TA(1); + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(count) { + var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array; + counter++; + $DETACHBUFFER(sample.buffer); + return new other(count); + }; + + assert.throws(TypeError, function() { + counter++; + sample.slice(); + }, '`sample.slice()` throws TypeError'); + + assert.sameValue(counter, 2, 'The value of `counter` is 2'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js new file mode 100644 index 00000000000..2a7ce5e584b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during create with custom constructor. +info: | + %SendableTypedArray%.prototype.slice ( start, end ) + + Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + + SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + SendableTypedArrayCreate ( constructor, argumentList ) + + Let newSendableTypedArray be ? Construct(constructor, argumentList). + Perform ? ValidateSendableTypedArray(newSendableTypedArray). + + ValidateSendableTypedArray ( O ) + The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: + + Perform ? RequireInternalSlot(O, [[TypedArrayName]]). + Assert: O has a [[ViewedArrayBuffer]] internal slot. + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + let counter = 0; + let sample = new TA(1); + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(count) { + counter++; + $DETACHBUFFER(sample.buffer); + return new TA(count); + }; + + assert.throws(TypeError, function() { + counter++; + sample.slice(); + }, '`sample.slice()` throws TypeError'); + + assert.sameValue(counter, 2, 'The value of `counter` is 2'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js new file mode 100644 index 00000000000..fb7e7ea545c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during Get custom constructor. +info: | + %SendableTypedArray%.prototype.slice ( start, end ) + + Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + + SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + SendableTypedArrayCreate ( constructor, argumentList ) + + Let newSendableTypedArray be ? Construct(constructor, argumentList). + Perform ? ValidateSendableTypedArray(newSendableTypedArray). + + ValidateSendableTypedArray ( O ) + The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: + + Perform ? RequireInternalSlot(O, [[TypedArrayName]]). + Assert: O has a [[ViewedArrayBuffer]] internal slot. + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + let counter = 0; + let sample = new TA(1); + + Object.defineProperty(sample, "constructor", { + get() { + counter++; + $DETACHBUFFER(sample.buffer); + } + }); + assert.throws(TypeError, function() { + counter++; + sample.slice(); + }, '`sample.slice()` throws TypeError'); + + assert.sameValue(counter, 2, 'The value of `counter` is 2'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js new file mode 100644 index 00000000000..34ce71a9259 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Throws a TypeError if buffer of object created by custom constructor is detached. +info: | + %SendableTypedArray%.prototype.slice ( start, end ) + + Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + + SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + SendableTypedArrayCreate ( constructor, argumentList ) + + Let newSendableTypedArray be ? Construct(constructor, argumentList). + Perform ? ValidateSendableTypedArray(newSendableTypedArray). + + ValidateSendableTypedArray ( O ) + The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: + + Perform ? RequireInternalSlot(O, [[TypedArrayName]]). + Assert: O has a [[ViewedArrayBuffer]] internal slot. + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + let counter = 0; + let sample = new TA(1); + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(count) { + let other = new TA(count); + counter++; + $DETACHBUFFER(other.buffer); + return other; + }; + + assert.throws(TypeError, function() { + counter++; + sample.slice(); + }, '`sample.slice()` throws TypeError'); + + assert.sameValue(counter, 2, 'The value of `counter` is 2'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js new file mode 100644 index 00000000000..3751aab9be0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Does not throw a TypeError if buffer is detached on custom constructor and + count <= 0. Using other targetType. +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + If count > 0, then + ... + Return A + +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + let counter = 0; + let sample, result, Other, other; + let ctor = {}; + ctor[Symbol.species] = function(count) { + counter++; + Other = TA === BigInt64Array ? BigUint64Array : BigInt64Array; + $DETACHBUFFER(sample.buffer); + other = new Other(count); + return other; + }; + + sample = new TA(0); + sample.constructor = ctor; + result = sample.slice(); + assert.sameValue(result.length, 0, 'The value of result.length is 0'); + assert.notSameValue(result.buffer, sample.buffer, 'The value of result.buffer is expected to not equal the value of `sample.buffer`'); + assert.sameValue(result.constructor, Other, 'The value of result.constructor is expected to equal the value of Other'); + assert.sameValue(result, other, 'The value of `result` is expected to equal the value of other'); + assert.sameValue(counter, 1, 'The value of `counter` is 1'); + + sample = new TA(4); + sample.constructor = ctor; + sample.slice(1, 1); // count = 0; + assert.sameValue(counter, 2, 'The value of `counter` is 2'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js new file mode 100644 index 00000000000..f9de4335e6b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Does not throw a TypeError if buffer is detached on custom constructor and + count <= 0. Using same targetType. +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + If count > 0, then + ... + Return A +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + let counter = 0; + let sample, result, other; + let ctor = {}; + ctor[Symbol.species] = function(count) { + counter++; + $DETACHBUFFER(sample.buffer); + other = new TA(count); + return other; + }; + + sample = new TA(0); + sample.constructor = ctor; + result = sample.slice(); + assert.sameValue(result.length, 0, 'The value of result.length is 0'); + assert.notSameValue(result.buffer, sample.buffer, 'The value of result.buffer is expected to not equal the value of `sample.buffer`'); + assert.sameValue(result, other, 'The value of `result` is expected to equal the value of other'); + assert.sameValue(counter, 1, 'The value of `counter` is 1'); + + sample = new TA(4); + sample.constructor = ctor; + result = sample.slice(1, 1); // count = 0; + assert.sameValue(result.length, 0, 'The value of result.length is 0'); + assert.notSameValue( + result.buffer, + sample.buffer, + 'The value of result.buffer is expected to not equal the value of `sample.buffer`' + ); + assert.sameValue(result.constructor, TA, 'The value of result.constructor is expected to equal the value of TA'); + assert.sameValue(counter, 2, 'The value of `counter` is 2'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer.js new file mode 100644 index 00000000000..a9510759ef0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.slice(obj, obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/infinity.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/infinity.js new file mode 100644 index 00000000000..cac872ae421 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/infinity.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Infinity values on start and end +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + assert( + compareArray(sample.slice(-Infinity), [40n, 41n, 42n, 43n]), + "start == -Infinity" + ); + assert( + compareArray(sample.slice(Infinity), []), + "start == Infinity" + ); + assert( + compareArray(sample.slice(0, -Infinity), []), + "end == -Infinity" + ); + assert( + compareArray(sample.slice(0, Infinity), [40n, 41n, 42n, 43n]), + "end == Infinity" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/minus-zero.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/minus-zero.js new file mode 100644 index 00000000000..a130569f753 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/minus-zero.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: -0 values on start and end +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + assert( + compareArray(sample.slice(-0), [40n, 41n, 42n, 43n]), + "start == -0" + ); + assert( + compareArray(sample.slice(-0, 4), [40n, 41n, 42n, 43n]), + "start == -0, end == length" + ); + assert( + compareArray(sample.slice(0, -0), []), + "start == 0, end == -0" + ); + assert( + compareArray(sample.slice(-0, -0), []), + "start == -0, end == -0" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js new file mode 100644 index 00000000000..58a634de9cc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Result does not import own properties +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice( start , end ) +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([41n, 42n, 43n, 44n]); + sample.foo = 42; + + var result = sample.slice(); + assert.sameValue( + result.hasOwnProperty("foo"), + false, + "does not import own property" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-different-length.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-different-length.js new file mode 100644 index 00000000000..db462424802 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-different-length.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: slice may return a new instance with a smaller length +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + function testRes(result, expected, msg) { + assert(compareArray(result, expected), msg + ", result: [" + result + "]"); + } + + testRes(sample.slice(1), [41n, 42n, 43n], "begin == 1"); + testRes(sample.slice(2), [42n, 43n], "begin == 2"); + testRes(sample.slice(3), [43n], "begin == 3"); + + testRes(sample.slice(1, 4), [41n, 42n, 43n], "begin == 1, end == length"); + testRes(sample.slice(2, 4), [42n, 43n], "begin == 2, end == length"); + testRes(sample.slice(3, 4), [43n], "begin == 3, end == length"); + + testRes(sample.slice(0, 1), [40n], "begin == 0, end == 1"); + testRes(sample.slice(0, 2), [40n, 41n], "begin == 0, end == 2"); + testRes(sample.slice(0, 3), [40n, 41n, 42n], "begin == 0, end == 3"); + + testRes(sample.slice(-1), [43n], "begin == -1"); + testRes(sample.slice(-2), [42n, 43n], "begin == -2"); + testRes(sample.slice(-3), [41n, 42n, 43n], "begin == -3"); + + testRes(sample.slice(-1, 4), [43n], "begin == -1, end == length"); + testRes(sample.slice(-2, 4), [42n, 43n], "begin == -2, end == length"); + testRes(sample.slice(-3, 4), [41n, 42n, 43n], "begin == -3, end == length"); + + testRes(sample.slice(0, -1), [40n, 41n, 42n], "begin == 0, end == -1"); + testRes(sample.slice(0, -2), [40n, 41n], "begin == 0, end == -2"); + testRes(sample.slice(0, -3), [40n], "begin == 0, end == -3"); + + testRes(sample.slice(-0, -1), [40n, 41n, 42n], "begin == -0, end == -1"); + testRes(sample.slice(-0, -2), [40n, 41n], "begin == -0, end == -2"); + testRes(sample.slice(-0, -3), [40n], "begin == -0, end == -3"); + + testRes(sample.slice(-2, -1), [42n], "length == 4, begin == -2, end == -1"); + testRes(sample.slice(1, -1), [41n, 42n], "length == 4, begin == 1, end == -1"); + testRes(sample.slice(1, -2), [41n], "length == 4, begin == 1, end == -2"); + testRes(sample.slice(2, -1), [42n], "length == 4, begin == 2, end == -1"); + + testRes(sample.slice(-1, 5), [43n], "begin == -1, end > length"); + testRes(sample.slice(-2, 4), [42n, 43n], "begin == -2, end > length"); + testRes(sample.slice(-3, 4), [41n, 42n, 43n], "begin == -3, end > length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js new file mode 100644 index 00000000000..faa55bf413d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: slice may return a new empty instance +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + function testRes(result, msg) { + assert.sameValue(result.length, 0, msg); + assert.sameValue( + result.hasOwnProperty(0), + false, + msg + " & result.hasOwnProperty(0) === false" + ); + } + + testRes(sample.slice(4), "begin == length"); + testRes(sample.slice(5), "begin > length"); + + testRes(sample.slice(4, 4), "begin == length, end == length"); + testRes(sample.slice(5, 4), "begin > length, end == length"); + + testRes(sample.slice(4, 5), "begin == length, end > length"); + testRes(sample.slice(5, 5), "begin > length, end > length"); + + testRes(sample.slice(0, 0), "begin == 0, end == 0"); + testRes(sample.slice(-0, -0), "begin == -0, end == -0"); + testRes(sample.slice(1, 0), "begin > 0, end == 0"); + testRes(sample.slice(-1, 0), "being < 0, end == 0"); + + testRes(sample.slice(2, 1), "begin > 0, begin < length, begin > end, end > 0"); + testRes(sample.slice(2, 2), "begin > 0, begin < length, begin == end"); + + testRes(sample.slice(2, -2), "begin > 0, begin < length, end == -2"); + + testRes(sample.slice(-1, -1), "length = 4, begin == -1, end == -1"); + testRes(sample.slice(-1, -2), "length = 4, begin == -1, end == -2"); + testRes(sample.slice(-2, -2), "length = 4, begin == -2, end == -2"); + + testRes(sample.slice(0, -4), "begin == 0, end == -length"); + testRes(sample.slice(-4, -4), "begin == -length, end == -length"); + testRes(sample.slice(-5, -4), "begin < -length, end == -length"); + + testRes(sample.slice(0, -5), "begin == 0, end < -length"); + testRes(sample.slice(-4, -5), "begin == -length, end < -length"); + testRes(sample.slice(-5, -5), "begin < -length, end < -length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-same-length.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-same-length.js new file mode 100644 index 00000000000..d45d07523f6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-same-length.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: slice may return a new instance with the same length +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + function testRes(result, msg) { + assert.sameValue(result.length, 4, msg); + assert.sameValue(result[0], 40n, msg + " & result[0] === 40"); + assert.sameValue(result[1], 41n, msg + " & result[1] === 41"); + assert.sameValue(result[2], 42n, msg + " & result[2] === 42"); + assert.sameValue(result[3], 43n, msg + " & result[3] === 43"); + } + + testRes(sample.slice(0), "begin == 0"); + testRes(sample.slice(-4), "begin == -srcLength"); + testRes(sample.slice(-5), "begin < -srcLength"); + + testRes(sample.slice(0, 4), "begin == 0, end == srcLength"); + testRes(sample.slice(-4, 4), "begin == -srcLength, end == srcLength"); + testRes(sample.slice(-5, 4), "begin < -srcLength, end == srcLength"); + + testRes(sample.slice(0, 5), "begin == 0, end > srcLength"); + testRes(sample.slice(-4, 5), "begin == -srcLength, end > srcLength"); + testRes(sample.slice(-5, 5), "begin < -srcLength, end > srcLength"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js new file mode 100644 index 00000000000..83470ca8b34 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Return abrupt from ToInteger(end), end is symbol +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.slice(0, s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js new file mode 100644 index 00000000000..1235f39bfd7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Return abrupt from ToInteger(end) +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var o1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var o2 = { + toString: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(Test262Error, function() { + sample.slice(0, o1); + }); + + assert.throws(Test262Error, function() { + sample.slice(0, o2); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js new file mode 100644 index 00000000000..8157a666204 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Return abrupt from ToInteger(start), start is symbol +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 4. Let relativeStart be ? ToInteger(start). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.slice(s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js new file mode 100644 index 00000000000..c349bb88be7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Return abrupt from ToInteger(start) +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 4. Let relativeStart be ? ToInteger(start). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var o1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var o2 = { + toString: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(Test262Error, function() { + sample.slice(o1); + }); + + assert.throws(Test262Error, function() { + sample.slice(o2); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..70ff43eac75 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.slice, + 'function', + 'implements SendableTypedArray.prototype.slice' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.slice(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.slice(0); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the slice operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.slice(0); + throw new Test262Error('slice completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js new file mode 100644 index 00000000000..c737f8c18c5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Perform regular set if target's uses a different element type +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + 10. Let srcName be the String value of O's [[TypedArrayName]] internal slot. + 11. Let srcType be the String value of the Element Type value in Table 50 for + srcName. + 12. Let targetName be the String value of A's [[TypedArrayName]] internal + slot. + 13. Let targetType be the String value of the Element Type value in Table 50 + for targetName. + 14. If SameValue(srcType, targetType) is false, then + a. Let n be 0. + b. Repeat, while k < final + i. Let Pk be ! ToString(k). + ii. Let kValue be ? Get(O, Pk). + iii. Perform ? Set(A, ! ToString(n), kValue, true). + iv. Increase k by 1. + v. Increase n by 1. + ... + 16. Return A +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +var arr = [42n, 43n, 44n]; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(arr); + var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array; + + sample.constructor = {}; + sample.constructor[Symbol.species] = other; + + var result = sample.slice(); + + assert(compareArray(result, arr), "values are set"); + assert.notSameValue(result.buffer, sample.buffer, "creates a new buffer"); + assert.sameValue(result.constructor, other, "used the custom ctor"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-destination-resizable.js new file mode 100644 index 00000000000..45b888b2221 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-destination-resizable.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws a TypeError if new typedArray's length < count +info: | + 23.2.3.27 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 23.2.4.1 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + 23.2.4.2 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); + const ta = new TA(rab1); + const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); + const lengthTracking = new TA(rab2); + rab2.resize(0); + ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; + assert.throws(TypeError, function() { + ta.slice(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js new file mode 100644 index 00000000000..ef9e54dbe04 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Return abrupt from SpeciesConstructor's get Constructor +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + Object.defineProperty(sample, "constructor", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.slice(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js new file mode 100644 index 00000000000..df610264e4b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: get inherited constructor on SpeciesConstructor +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + var calls = 0; + var result; + + Object.defineProperty(TA.prototype, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.slice(); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + undefined, + "used defaultCtor but still checks the inherited .constructor" + ); + + calls = 6; + result.constructor; + assert.sameValue( + calls, + 7, + "result.constructor triggers the inherited accessor property" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js new file mode 100644 index 00000000000..419ae72b070 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws if O.constructor returns a non-Object and non-undefined value +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + 4. If Type(C) is not Object, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + sample.constructor = 42; + assert.throws(TypeError, function() { + sample.slice(); + }, "42"); + + sample.constructor = "1"; + assert.throws(TypeError, function() { + sample.slice(); + }, "string"); + + sample.constructor = null; + assert.throws(TypeError, function() { + sample.slice(); + }, "null"); + + sample.constructor = NaN; + assert.throws(TypeError, function() { + sample.slice(); + }, "NaN"); + + sample.constructor = false; + assert.throws(TypeError, function() { + sample.slice(); + }, "false"); + + sample.constructor = Symbol("1"); + assert.throws(TypeError, function() { + sample.slice(); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js new file mode 100644 index 00000000000..2f2702722c1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: get constructor on SpeciesConstructor +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + var calls = 0; + var result; + + Object.defineProperty(sample, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.slice(); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + TA, + "use defaultCtor on an undefined return - .constructor check" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js new file mode 100644 index 00000000000..39776a8b6fb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Returns abrupt from get @@species on found constructor +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.slice(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js new file mode 100644 index 00000000000..8a6b4c7f3f1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Verify arguments on custom @@species construct call +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n]); + var result, ctorThis; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(count) { + result = arguments; + ctorThis = this; + return new TA(count); + }; + + sample.slice(1); + + assert.sameValue(result.length, 1, "called with 1 arguments"); + assert.sameValue(result[0], 2, "[0] is the new length count"); + + assert( + ctorThis instanceof sample.constructor[Symbol.species], + "`this` value in the @@species fn is an instance of the function itself" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js new file mode 100644 index 00000000000..07d903804db --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws a TypeError if new typedArray's length < count +info: | + 23.2.3.27 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 23.2.4.1 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + 23.2.4.2 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] +---*/ + + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + const sample = new TA(2); + const rab = new ArrayBuffer(10, {maxByteLength: 20}); + const lengthTracking = new TA(rab); + rab.resize(0); + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return lengthTracking; + }; + assert.throws(TypeError, function() { + sample.slice(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js new file mode 100644 index 00000000000..1512fbff96d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws a TypeError if new typedArray's length < count +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return new TA(); + }; + + assert.throws(TypeError, function() { + sample.slice(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js new file mode 100644 index 00000000000..7595546ea7c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Does not throw a TypeError if new typedArray's length >= count +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var customCount, result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return new TA(customCount); + }; + + customCount = 2; + result = sample.slice(); + assert.sameValue(result.length, customCount, "length == count"); + + customCount = 5; + result = sample.slice(); + assert.sameValue(result.length, customCount, "length > count"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js new file mode 100644 index 00000000000..285f36c957a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Custom @@species constructor may return a totally different SendableTypedArray +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n]); + var other = new BigInt64Array([1n, 0n, 1n]); + var result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return other; + }; + + result = sample.slice(0, 0); + + assert.sameValue(result, other, "returned another typedarray"); + assert(compareArray(result, [1n, 0n, 1n]), "the returned object is preserved"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js new file mode 100644 index 00000000000..38883eb59af --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Custom @@species constructor throws if it does not return a compatible object +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var ctor = function() {}; + + sample.constructor = {}; + sample.constructor[Symbol.species] = ctor; + + assert.throws(TypeError, function() { + sample.slice(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js new file mode 100644 index 00000000000..9e320af1e14 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Use custom @@species constructor if available +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n]); + var calls = 0; + var result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(count) { + calls++; + return new TA(count); + }; + + result = sample.slice(1); + + assert.sameValue(calls, 1, "ctor called once"); + assert(compareArray(result, [41n, 42n]), "expected object"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js new file mode 100644 index 00000000000..c9198d61ccc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws if returned @@species is not a constructor, null or undefined. +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + 7. If IsConstructor(S) is true, return S. + 8. Throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + sample.constructor[Symbol.species] = 0; + assert.throws(TypeError, function() { + sample.slice(); + }, "0"); + + sample.constructor[Symbol.species] = "string"; + assert.throws(TypeError, function() { + sample.slice(); + }, "string"); + + sample.constructor[Symbol.species] = {}; + assert.throws(TypeError, function() { + sample.slice(); + }, "{}"); + + sample.constructor[Symbol.species] = NaN; + assert.throws(TypeError, function() { + sample.slice(); + }, "NaN"); + + sample.constructor[Symbol.species] = false; + assert.throws(TypeError, function() { + sample.slice(); + }, "false"); + + sample.constructor[Symbol.species] = true; + assert.throws(TypeError, function() { + sample.slice(); + }, "true"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js new file mode 100644 index 00000000000..1697fcfd92f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Use defaultConstructor if @@species is either undefined or null +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var result; + + sample.constructor = {}; + + result = sample.slice(); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "undefined @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "undefined @@species - ctor check"); + + sample.constructor[Symbol.species] = null; + result = sample.slice(); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "null @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "null @@species - ctor check"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js new file mode 100644 index 00000000000..e89ed083b6a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + get @@species from found constructor +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var calls = 0; + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + calls++; + } + }); + + sample.slice(); + + assert.sameValue(calls, 1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-end.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-end.js new file mode 100644 index 00000000000..40b4ab033c5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-end.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: ToInteger(end) +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice( start , end ) + + ... + 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj = { + valueOf: function() { + return 2; + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + assert(compareArray(sample.slice(0, false), []), "false"); + assert(compareArray(sample.slice(0, true), [40n]), "true"); + + assert(compareArray(sample.slice(0, NaN), []), "NaN"); + assert(compareArray(sample.slice(0, null), []), "null"); + assert(compareArray(sample.slice(0, undefined), [40n, 41n, 42n, 43n]), "undefined"); + + assert(compareArray(sample.slice(0, 0.6), []), "0.6"); + assert(compareArray(sample.slice(0, 1.1), [40n]), "1.1"); + assert(compareArray(sample.slice(0, 1.5), [40n]), "1.5"); + assert(compareArray(sample.slice(0, -0.6), []), "-0.6"); + assert(compareArray(sample.slice(0, -1.1), [40n, 41n, 42n]), "-1.1"); + assert(compareArray(sample.slice(0, -1.5), [40n, 41n, 42n]), "-1.5"); + + assert(compareArray(sample.slice(0, "3"), [40n, 41n, 42n]), "string"); + assert( + compareArray( + sample.slice(0, obj), + [40n, 41n] + ), + "object" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-start.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-start.js new file mode 100644 index 00000000000..295f43b51d3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-start.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: ToInteger(begin) +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 4. Let relativeStart be ? ToInteger(start). + ... +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj = { + valueOf: function() { + return 2; + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + assert(compareArray(sample.slice(false), [40n, 41n, 42n, 43n]), "false"); + assert(compareArray(sample.slice(true), [41n, 42n, 43n]), "true"); + + assert(compareArray(sample.slice(NaN), [40n, 41n, 42n, 43n]), "NaN"); + assert(compareArray(sample.slice(null), [40n, 41n, 42n, 43n]), "null"); + assert(compareArray(sample.slice(undefined), [40n, 41n, 42n, 43n]), "undefined"); + + assert(compareArray(sample.slice(1.1), [41n, 42n, 43n]), "1.1"); + assert(compareArray(sample.slice(1.5), [41n, 42n, 43n]), "1.5"); + assert(compareArray(sample.slice(0.6), [40n, 41n, 42n, 43n]), "0.6"); + + assert(compareArray(sample.slice(-1.5), [43n]), "-1.5"); + assert(compareArray(sample.slice(-1.1), [43n]), "-1.1"); + assert(compareArray(sample.slice(-0.6), [40n, 41n, 42n, 43n]), "-0.6"); + + assert(compareArray(sample.slice("3"), [43n]), "string"); + assert( + compareArray( + sample.slice(obj), + [42n, 43n] + ), + "object" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js new file mode 100644 index 00000000000..abe7b8fd7a0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Use internal ArrayLength instead of getting a length property +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 3. Let len be the value of O's [[ArrayLength]] internal slot. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43]); + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + var result = sample.slice(); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert.sameValue(result[0], 42); + assert.sameValue(result[1], 43); + assert.sameValue(result.hasOwnProperty(2), false); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js b/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js new file mode 100644 index 00000000000..d2ae292822c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Preservation of bit-level encoding +info: | + [...] + 15. Else if count > 0, then + [...] + e. NOTE: If srcType and targetType are the same, the transfer must be + performed in a manner that preserves the bit-level encoding of the + source data. + f. Let srcByteOffet be the value of O's [[ByteOffset]] internal slot. + g. Let targetByteIndex be A's [[ByteOffset]] internal slot. + h. Let srcByteIndex be (k × elementSize) + srcByteOffet. + i. Let limit be targetByteIndex + count × elementSize. + j. Repeat, while targetByteIndex < limit + i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8"). + ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8", + value). + iii. Increase srcByteIndex by 1. + iv. Increase targetByteIndex by 1. +includes: [nans.js, compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +function body(FloatArray) { + var subject = new FloatArray(NaNs); + var sliced, subjectBytes, slicedBytes; + + sliced = subject.slice(); + + subjectBytes = new Uint8Array(subject.buffer); + slicedBytes = new Uint8Array(sliced.buffer); + + assert(compareArray(subjectBytes, slicedBytes)); +} + +testWithSendableTypedArrayConstructors(body, floatArrayConstructors); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-grow.js b/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-grow.js new file mode 100644 index 00000000000..5d5d3c89838 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-grow.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + SendableTypedArray.p.slice behaves correctly on SendableTypedArrays backed by resizable buffers + that is grown by argument coercion. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// The start argument grows the resizable array buffer rab. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); + } + const evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert.compareArray(ToNumbers(lengthTracking.slice(evil)), [ + 1, + 2, + 3, + 4 + ]); + assert.sameValue(rab.byteLength, 6 * ctor.BYTES_PER_ELEMENT); +} + +// The end argument grows the resizable array buffer rab. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); + } + const evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return 5; + } + }; + assert.compareArray(ToNumbers(lengthTracking.slice(4,evil)), [ + ]); + assert.compareArray(ToNumbers(lengthTracking.slice(3,evil)), [ + 4, + 0 + ]); + assert.sameValue(rab.byteLength, 6 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-shrink.js b/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-shrink.js new file mode 100644 index 00000000000..33eb0745ccb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-shrink.js @@ -0,0 +1,98 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + SendableTypedArray.p.slice behaves correctly on SendableTypedArrays backed by resizable buffers + that are shrunk by argument coercion. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// The start argument shrinks the resizable array buffer rab. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert.throws(TypeError, () => { + fixedLength.slice(evil); + }); + assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); + } + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert.compareArray(ToNumbers(lengthTracking.slice(evil)), [ + 1, + 2, + 0, + 0 + ]); + assert.compareArray(ToNumbers(lengthTracking.slice(evil)), [ + 1, + 2 + ]); + assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); +} + +// The end argument shrinks the resizable array buffer rab. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 5; + } + }; + assert.throws(TypeError, () => { + fixedLength.slice(1, evil); + }); + assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); + } + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 5; + } + }; + assert.compareArray(ToNumbers(lengthTracking.slice(1,evil)), [ + 2, + 0, + 0 + ]); + assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js new file mode 100644 index 00000000000..684e3aff96d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached. Using other + targetType +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + If count > 0, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + let counter = 0; + var sample = new TA(1); + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(count) { + var other = TA === Int8Array ? Int16Array : Int8Array; + counter++; + $DETACHBUFFER(sample.buffer); + return new other(count); + }; + + assert.throws(TypeError, function() { + counter++; + sample.slice(); + }, '`sample.slice()` throws TypeError'); + + assert.sameValue(counter, 2, 'The value of `counter` is 2'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js new file mode 100644 index 00000000000..6a8a090f2ee --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached on Get custom constructor. +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + If count > 0, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + let counter = 0; + let sample = new TA(1); + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(count) { + counter++; + $DETACHBUFFER(sample.buffer); + return new TA(count); + }; + + assert.throws(TypeError, function() { + counter++; + sample.slice(); + }, '`sample.slice()` throws TypeError'); + + assert.sameValue(counter, 2, 'The value of `counter` is 2'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js new file mode 100644 index 00000000000..d64bcb93e6b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached. +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + If count > 0, then + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + let counter = 0; + let sample = new TA(1); + + Object.defineProperty(sample, "constructor", { + get() { + counter++; + $DETACHBUFFER(sample.buffer); + } + }); + assert.throws(TypeError, function() { + counter++; + sample.slice(); + }, '`sample.slice()` throws TypeError'); + + assert.sameValue(counter, 2, 'The value of `counter` is 2'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js new file mode 100644 index 00000000000..79198ab994b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Throws a TypeError if buffer of object created by custom constructor is detached. +info: | + %SendableTypedArray%.prototype.slice ( start, end ) + + Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + + SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + SendableTypedArrayCreate ( constructor, argumentList ) + + Let newSendableTypedArray be ? Construct(constructor, argumentList). + Perform ? ValidateSendableTypedArray(newSendableTypedArray). + + ValidateSendableTypedArray ( O ) + The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: + + Perform ? RequireInternalSlot(O, [[TypedArrayName]]). + Assert: O has a [[ViewedArrayBuffer]] internal slot. + Let buffer be O.[[ViewedArrayBuffer]]. + If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + let counter = 0; + let sample = new TA(1); + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(count) { + let other = new TA(count); + counter++; + $DETACHBUFFER(other.buffer); + return other; + }; + + assert.throws(TypeError, function() { + counter++; + sample.slice(); + }, '`sample.slice()` throws TypeError'); + + assert.sameValue(counter, 2, 'The value of `counter` is 2'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js new file mode 100644 index 00000000000..95a40989a5a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Does not throw a TypeError if buffer is detached on custom constructor and + count <= 0. Using other targetType. +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + If count > 0, then + ... + Return A + +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + let counter = 0; + let sample, result, Other, other; + let ctor = {}; + ctor[Symbol.species] = function(count) { + counter++; + Other = TA === Int16Array ? Int8Array : Int16Array; + $DETACHBUFFER(sample.buffer); + other = new Other(count); + return other; + }; + + sample = new TA(0); + sample.constructor = ctor; + result = sample.slice(); + assert.sameValue(result.length, 0, 'The value of result.length is 0'); + assert.notSameValue(result.buffer, sample.buffer, 'The value of result.buffer is expected to not equal the value of `sample.buffer`'); + assert.sameValue(result.constructor, Other, 'The value of result.constructor is expected to equal the value of Other'); + assert.sameValue(result, other, 'The value of `result` is expected to equal the value of other'); + assert.sameValue(counter, 1, 'The value of `counter` is 1'); + + sample = new TA(4); + sample.constructor = ctor; + sample.slice(1, 1); // count = 0; + assert.sameValue(counter, 2, 'The value of `counter` is 2'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js new file mode 100644 index 00000000000..61c4a2ec9c2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Does not throw a TypeError if buffer is detached on custom constructor and + count <= 0. Using other targetType. +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + If count > 0, then + ... + Return A +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + let counter = 0; + let sample, result, other; + let ctor = {}; + ctor[Symbol.species] = function(count) { + counter++; + $DETACHBUFFER(sample.buffer); + other = new TA(count); + return other; + }; + + sample = new TA(0); + sample.constructor = ctor; + result = sample.slice(); + assert.sameValue(result.length, 0, 'The value of result.length is 0'); + assert.notSameValue(result.buffer, sample.buffer, 'The value of result.buffer is expected to not equal the value of `sample.buffer`'); + assert.sameValue(result, other, 'The value of `result` is expected to equal the value of other'); + assert.sameValue(counter, 1, 'The value of `counter` is 1'); + + sample = new TA(4); + sample.constructor = ctor; + sample.slice(1, 1); // count = 0; + assert.sameValue(counter, 2, 'The value of `counter` is 2'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js new file mode 100644 index 00000000000..98674b6c917 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var obj = { + valueOf: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.slice(obj, obj); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/infinity.js b/test/sendable/builtins/TypedArray/prototype/slice/infinity.js new file mode 100644 index 00000000000..c705db700a7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/infinity.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Infinity values on start and end +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + assert( + compareArray(sample.slice(-Infinity), [40, 41, 42, 43]), + "start == -Infinity" + ); + assert( + compareArray(sample.slice(Infinity), []), + "start == Infinity" + ); + assert( + compareArray(sample.slice(0, -Infinity), []), + "end == -Infinity" + ); + assert( + compareArray(sample.slice(0, Infinity), [40, 41, 42, 43]), + "end == Infinity" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-func.js new file mode 100644 index 00000000000..4ad1f4c91d6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-func.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.23 %SendableTypedArray%.prototype.slice ( start, end ) + + 1. Let O be the this value. + 2. Let valid be ValidateSendableTypedArray(O). + 3. ReturnIfAbrupt(valid). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var slice = SendableTypedArray.prototype.slice; + +assert.sameValue(typeof slice, 'function'); + +assert.throws(TypeError, function() { + slice(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-method.js new file mode 100644 index 00000000000..01b94f74e4e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-method.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.23 %SendableTypedArray%.prototype.slice ( start, end ) + + 1. Let O be the this value. + 2. Let valid be ValidateSendableTypedArray(O). + 3. ReturnIfAbrupt(valid). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.slice, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.slice(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/length.js b/test/sendable/builtins/TypedArray/prototype/slice/length.js new file mode 100644 index 00000000000..d8e4fde91b3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + %SendableTypedArray%.prototype.slice.length is 2. +info: | + %SendableTypedArray%.prototype.slice ( start, end ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.slice, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js b/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js new file mode 100644 index 00000000000..378ad2c8ac6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: -0 values on start and end +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + assert( + compareArray(sample.slice(-0), [40, 41, 42, 43]), + "start == -0" + ); + assert( + compareArray(sample.slice(-0, 4), [40, 41, 42, 43]), + "start == -0, end == length" + ); + assert( + compareArray(sample.slice(0, -0), []), + "start == 0, end == -0" + ); + assert( + compareArray(sample.slice(-0, -0), []), + "start == -0, end == -0" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/name.js b/test/sendable/builtins/TypedArray/prototype/slice/name.js new file mode 100644 index 00000000000..24bc36183f8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + %SendableTypedArray%.prototype.slice.name is "slice". +info: | + %SendableTypedArray%.prototype.slice ( start, end ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.slice, "name", { + value: "slice", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/slice/not-a-constructor.js new file mode 100644 index 00000000000..32b1a53ff00 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.slice 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.slice), + false, + 'isConstructor(SendableTypedArray.prototype.slice) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.slice(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/slice/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/slice/prop-desc.js new file mode 100644 index 00000000000..1865d49df56 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + "slice" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'slice', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/slice/resizable-buffer.js new file mode 100644 index 00000000000..9a6287a4944 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/resizable-buffer.js @@ -0,0 +1,156 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + SendableTypedArray.p.slice behaves correctly on SendableTypedArrays backed by resizable + buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + const fixedLengthSlice = fixedLength.slice(); + assert.compareArray(ToNumbers(fixedLengthSlice), [ + 0, + 1, + 2, + 3 + ]); + assert(!fixedLengthSlice.buffer.resizable); + const fixedLengthWithOffsetSlice = fixedLengthWithOffset.slice(); + assert.compareArray(ToNumbers(fixedLengthWithOffsetSlice), [ + 2, + 3 + ]); + assert(!fixedLengthWithOffsetSlice.buffer.resizable); + const lengthTrackingSlice = lengthTracking.slice(); + assert.compareArray(ToNumbers(lengthTrackingSlice), [ + 0, + 1, + 2, + 3 + ]); + assert(!lengthTrackingSlice.buffer.resizable); + const lengthTrackingWithOffsetSlice = lengthTrackingWithOffset.slice(); + assert.compareArray(ToNumbers(lengthTrackingWithOffsetSlice), [ + 2, + 3 + ]); + assert(!lengthTrackingWithOffsetSlice.buffer.resizable); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.slice(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.slice(); + }); + assert.compareArray(ToNumbers(lengthTracking.slice()), [ + 0, + 1, + 2 + ]); + assert.compareArray(ToNumbers(lengthTrackingWithOffset.slice()), [2]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.slice(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.slice(); + }); + assert.compareArray(ToNumbers(lengthTracking.slice()), [0]); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.slice(); + }); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.slice(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.slice(); + }); + assert.compareArray(ToNumbers(lengthTracking.slice()), []); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.slice(); + }); + + // Verify that the previously created slices aren't affected by the + // shrinking. + assert.compareArray(ToNumbers(fixedLengthSlice), [ + 0, + 1, + 2, + 3 + ]); + assert.compareArray(ToNumbers(fixedLengthWithOffsetSlice), [ + 2, + 3 + ]); + assert.compareArray(ToNumbers(lengthTrackingSlice), [ + 0, + 1, + 2, + 3 + ]); + assert.compareArray(ToNumbers(lengthTrackingWithOffsetSlice), [ + 2, + 3 + ]); + + // Grow so that all TAs are back in-bounds. New memory is zeroed. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + assert.compareArray(ToNumbers(fixedLength.slice()), [ + 0, + 0, + 0, + 0 + ]); + assert.compareArray(ToNumbers(fixedLengthWithOffset.slice()), [ + 0, + 0 + ]); + assert.compareArray(ToNumbers(lengthTracking.slice()), [ + 0, + 0, + 0, + 0, + 0, + 0 + ]); + assert.compareArray(ToNumbers(lengthTrackingWithOffset.slice()), [ + 0, + 0, + 0, + 0 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js b/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js new file mode 100644 index 00000000000..28555608fcd --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Result does not import own properties +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice( start , end ) +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([41, 42, 43, 44]); + sample.foo = 42; + + var result = sample.slice(); + assert.sameValue( + result.hasOwnProperty("foo"), + false, + "does not import own property" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js b/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js new file mode 100644 index 00000000000..90db6ba3130 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: slice may return a new instance with a smaller length +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + function testRes(result, expected, msg) { + assert(compareArray(result, expected), msg + ", result: [" + result + "]"); + } + + testRes(sample.slice(1), [41, 42, 43], "begin == 1"); + testRes(sample.slice(2), [42, 43], "begin == 2"); + testRes(sample.slice(3), [43], "begin == 3"); + + testRes(sample.slice(1, 4), [41, 42, 43], "begin == 1, end == length"); + testRes(sample.slice(2, 4), [42, 43], "begin == 2, end == length"); + testRes(sample.slice(3, 4), [43], "begin == 3, end == length"); + + testRes(sample.slice(0, 1), [40], "begin == 0, end == 1"); + testRes(sample.slice(0, 2), [40, 41], "begin == 0, end == 2"); + testRes(sample.slice(0, 3), [40, 41, 42], "begin == 0, end == 3"); + + testRes(sample.slice(-1), [43], "begin == -1"); + testRes(sample.slice(-2), [42, 43], "begin == -2"); + testRes(sample.slice(-3), [41, 42, 43], "begin == -3"); + + testRes(sample.slice(-1, 4), [43], "begin == -1, end == length"); + testRes(sample.slice(-2, 4), [42, 43], "begin == -2, end == length"); + testRes(sample.slice(-3, 4), [41, 42, 43], "begin == -3, end == length"); + + testRes(sample.slice(0, -1), [40, 41, 42], "begin == 0, end == -1"); + testRes(sample.slice(0, -2), [40, 41], "begin == 0, end == -2"); + testRes(sample.slice(0, -3), [40], "begin == 0, end == -3"); + + testRes(sample.slice(-0, -1), [40, 41, 42], "begin == -0, end == -1"); + testRes(sample.slice(-0, -2), [40, 41], "begin == -0, end == -2"); + testRes(sample.slice(-0, -3), [40], "begin == -0, end == -3"); + + testRes(sample.slice(-2, -1), [42], "length == 4, begin == -2, end == -1"); + testRes(sample.slice(1, -1), [41, 42], "length == 4, begin == 1, end == -1"); + testRes(sample.slice(1, -2), [41], "length == 4, begin == 1, end == -2"); + testRes(sample.slice(2, -1), [42], "length == 4, begin == 2, end == -1"); + + testRes(sample.slice(-1, 5), [43], "begin == -1, end > length"); + testRes(sample.slice(-2, 4), [42, 43], "begin == -2, end > length"); + testRes(sample.slice(-3, 4), [41, 42, 43], "begin == -3, end > length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js b/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js new file mode 100644 index 00000000000..240e8fa7c78 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: slice may return a new empty instance +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + function testRes(result, msg) { + assert.sameValue(result.length, 0, msg); + assert.sameValue( + result.hasOwnProperty(0), + false, + msg + " & result.hasOwnProperty(0) === false" + ); + } + + testRes(sample.slice(4), "begin == length"); + testRes(sample.slice(5), "begin > length"); + + testRes(sample.slice(4, 4), "begin == length, end == length"); + testRes(sample.slice(5, 4), "begin > length, end == length"); + + testRes(sample.slice(4, 5), "begin == length, end > length"); + testRes(sample.slice(5, 5), "begin > length, end > length"); + + testRes(sample.slice(0, 0), "begin == 0, end == 0"); + testRes(sample.slice(-0, -0), "begin == -0, end == -0"); + testRes(sample.slice(1, 0), "begin > 0, end == 0"); + testRes(sample.slice(-1, 0), "being < 0, end == 0"); + + testRes(sample.slice(2, 1), "begin > 0, begin < length, begin > end, end > 0"); + testRes(sample.slice(2, 2), "begin > 0, begin < length, begin == end"); + + testRes(sample.slice(2, -2), "begin > 0, begin < length, end == -2"); + + testRes(sample.slice(-1, -1), "length = 4, begin == -1, end == -1"); + testRes(sample.slice(-1, -2), "length = 4, begin == -1, end == -2"); + testRes(sample.slice(-2, -2), "length = 4, begin == -2, end == -2"); + + testRes(sample.slice(0, -4), "begin == 0, end == -length"); + testRes(sample.slice(-4, -4), "begin == -length, end == -length"); + testRes(sample.slice(-5, -4), "begin < -length, end == -length"); + + testRes(sample.slice(0, -5), "begin == 0, end < -length"); + testRes(sample.slice(-4, -5), "begin == -length, end < -length"); + testRes(sample.slice(-5, -5), "begin < -length, end < -length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js b/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js new file mode 100644 index 00000000000..8231b838195 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: slice may return a new instance with the same length +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + function testRes(result, msg) { + assert.sameValue(result.length, 4, msg); + assert.sameValue(result[0], 40, msg + " & result[0] === 40"); + assert.sameValue(result[1], 41, msg + " & result[1] === 41"); + assert.sameValue(result[2], 42, msg + " & result[2] === 42"); + assert.sameValue(result[3], 43, msg + " & result[3] === 43"); + } + + testRes(sample.slice(0), "begin == 0"); + testRes(sample.slice(-4), "begin == -srcLength"); + testRes(sample.slice(-5), "begin < -srcLength"); + + testRes(sample.slice(0, 4), "begin == 0, end == srcLength"); + testRes(sample.slice(-4, 4), "begin == -srcLength, end == srcLength"); + testRes(sample.slice(-5, 4), "begin < -srcLength, end == srcLength"); + + testRes(sample.slice(0, 5), "begin == 0, end > srcLength"); + testRes(sample.slice(-4, 5), "begin == -srcLength, end > srcLength"); + testRes(sample.slice(-5, 5), "begin < -srcLength, end > srcLength"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js new file mode 100644 index 00000000000..22d13224b6a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Return abrupt from ToInteger(end), end is symbol +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.slice(0, s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js new file mode 100644 index 00000000000..b4fb30fa11d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Return abrupt from ToInteger(end) +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var o1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var o2 = { + toString: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(Test262Error, function() { + sample.slice(0, o1); + }); + + assert.throws(Test262Error, function() { + sample.slice(0, o2); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js new file mode 100644 index 00000000000..328b7f4099b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Return abrupt from ToInteger(start), start is symbol +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 4. Let relativeStart be ? ToInteger(start). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.slice(s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js new file mode 100644 index 00000000000..7888a8250bf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Return abrupt from ToInteger(start) +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 4. Let relativeStart be ? ToInteger(start). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var o1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var o2 = { + toString: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(Test262Error, function() { + sample.slice(o1); + }); + + assert.throws(Test262Error, function() { + sample.slice(o2); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..0c3255e9efb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.slice, + 'function', + 'implements SendableTypedArray.prototype.slice' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.slice(0); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.slice(0); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the slice operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.slice(0); + throw new Test262Error('slice completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js b/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js new file mode 100644 index 00000000000..1e6798e64b7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Perform regular set if target's uses a different element type +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + 10. Let srcName be the String value of O's [[TypedArrayName]] internal slot. + 11. Let srcType be the String value of the Element Type value in Table 50 for + srcName. + 12. Let targetName be the String value of A's [[TypedArrayName]] internal + slot. + 13. Let targetType be the String value of the Element Type value in Table 50 + for targetName. + 14. If SameValue(srcType, targetType) is false, then + a. Let n be 0. + b. Repeat, while k < final + i. Let Pk be ! ToString(k). + ii. Let kValue be ? Get(O, Pk). + iii. Perform ? Set(A, ! ToString(n), kValue, true). + iv. Increase k by 1. + v. Increase n by 1. + ... + 16. Return A +includes: [testTypedArray.js, compareArray.js] +features: [Symbol.species, TypedArray] +---*/ + +var arr = [42, 43, 44]; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(arr); + var other = TA === Int8Array ? Uint8Array : Int8Array; + + sample.constructor = {}; + sample.constructor[Symbol.species] = other; + + var result = sample.slice(); + + assert(compareArray(result, arr), "values are set"); + assert.notSameValue(result.buffer, sample.buffer, "creates a new buffer"); + assert.sameValue(result.constructor, other, "used the custom ctor"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js new file mode 100644 index 00000000000..44f6ff527d4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws a TypeError if new typedArray's length < count +info: | + 23.2.3.27 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 23.2.4.1 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + 23.2.4.2 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); + const ta = new TA(rab1); + const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); + const lengthTracking = new TA(rab2); + rab2.resize(0); + ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; + assert.throws(TypeError, function() { + ta.slice(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js new file mode 100644 index 00000000000..006e53183bd --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Return abrupt from SpeciesConstructor's get Constructor +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + Object.defineProperty(sample, "constructor", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.slice(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js new file mode 100644 index 00000000000..b1730e06cc0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: get inherited constructor on SpeciesConstructor +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + var calls = 0; + var result; + + Object.defineProperty(TA.prototype, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.slice(); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + undefined, + "used defaultCtor but still checks the inherited .constructor" + ); + + calls = 6; + result.constructor; + assert.sameValue( + calls, + 7, + "result.constructor triggers the inherited accessor property" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js new file mode 100644 index 00000000000..5c62fbaf2a6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws if O.constructor returns a non-Object and non-undefined value +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + 4. If Type(C) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + sample.constructor = 42; + assert.throws(TypeError, function() { + sample.slice(); + }, "42"); + + sample.constructor = "1"; + assert.throws(TypeError, function() { + sample.slice(); + }, "string"); + + sample.constructor = null; + assert.throws(TypeError, function() { + sample.slice(); + }, "null"); + + sample.constructor = NaN; + assert.throws(TypeError, function() { + sample.slice(); + }, "NaN"); + + sample.constructor = false; + assert.throws(TypeError, function() { + sample.slice(); + }, "false"); + + sample.constructor = Symbol("1"); + assert.throws(TypeError, function() { + sample.slice(); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js new file mode 100644 index 00000000000..08b21c5438d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: get constructor on SpeciesConstructor +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + var calls = 0; + var result; + + Object.defineProperty(sample, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.slice(); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + TA, + "use defaultCtor on an undefined return - .constructor check" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js new file mode 100644 index 00000000000..c455e3e60c7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Returns abrupt from get @@species on found constructor +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.slice(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js new file mode 100644 index 00000000000..2e3cc5ca54a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Verify arguments on custom @@species construct call +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42]); + var result, ctorThis; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(count) { + result = arguments; + ctorThis = this; + return new TA(count); + }; + + sample.slice(1); + + assert.sameValue(result.length, 1, "called with 1 arguments"); + assert.sameValue(result[0], 2, "[0] is the new length count"); + + assert( + ctorThis instanceof sample.constructor[Symbol.species], + "`this` value in the @@species fn is an instance of the function itself" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js new file mode 100644 index 00000000000..d5faa535090 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws a TypeError if new typedArray's length < count +info: | + 23.2.3.27 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 23.2.4.1 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let result be ? SendableTypedArrayCreate(constructor, argumentList). + + 23.2.4.2 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] +---*/ + + +testWithSendableTypedArrayConstructors(function(TA) { + const sample = new TA(2); + const rab = new ArrayBuffer(10, {maxByteLength: 20}); + const lengthTracking = new TA(rab); + rab.resize(0); + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return lengthTracking; + }; + assert.throws(TypeError, function() { + sample.slice(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js new file mode 100644 index 00000000000..00e9f6dfb09 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws a TypeError if new typedArray's length < count +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return new TA(); + }; + + assert.throws(TypeError, function() { + sample.slice(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js new file mode 100644 index 00000000000..25df8c9fd0c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Does not throw a TypeError if new typedArray's length >= count +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + ... + 3. If argumentList is a List of a single Number, then + a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < + argumentList[0], throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var customCount, result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return new TA(customCount); + }; + + customCount = 2; + result = sample.slice(); + assert.sameValue(result.length, customCount, "length == count"); + + customCount = 5; + result = sample.slice(); + assert.sameValue(result.length, customCount, "length > count"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js new file mode 100644 index 00000000000..8c0dcdef1eb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Custom @@species constructor may return a totally different SendableTypedArray +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testTypedArray.js, compareArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40]); + var other = new Int8Array([1, 0, 1]); + var result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return other; + }; + + result = sample.slice(0, 0); + + assert.sameValue(result, other, "returned another typedarray"); + assert(compareArray(result, [1, 0, 1]), "the returned object is preserved"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js new file mode 100644 index 00000000000..973ac7b25a5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Custom @@species constructor throws if it does not return a compatible object +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var ctor = function() {}; + + sample.constructor = {}; + sample.constructor[Symbol.species] = ctor; + + assert.throws(TypeError, function() { + sample.slice(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js new file mode 100644 index 00000000000..aeb55e59a42 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Use custom @@species constructor if available +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testTypedArray.js, compareArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42]); + var calls = 0; + var result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(count) { + calls++; + return new TA(count); + }; + + result = sample.slice(1); + + assert.sameValue(calls, 1, "ctor called once"); + assert(compareArray(result, [41, 42]), "expected object"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js new file mode 100644 index 00000000000..804db66711f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws if returned @@species is not a constructor, null or undefined. +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + 7. If IsConstructor(S) is true, return S. + 8. Throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + sample.constructor[Symbol.species] = 0; + assert.throws(TypeError, function() { + sample.slice(); + }, "0"); + + sample.constructor[Symbol.species] = "string"; + assert.throws(TypeError, function() { + sample.slice(); + }, "string"); + + sample.constructor[Symbol.species] = {}; + assert.throws(TypeError, function() { + sample.slice(); + }, "{}"); + + sample.constructor[Symbol.species] = NaN; + assert.throws(TypeError, function() { + sample.slice(); + }, "NaN"); + + sample.constructor[Symbol.species] = false; + assert.throws(TypeError, function() { + sample.slice(); + }, "false"); + + sample.constructor[Symbol.species] = true; + assert.throws(TypeError, function() { + sample.slice(); + }, "true"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js new file mode 100644 index 00000000000..0b0f6702fff --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Use defaultConstructor if @@species is either undefined or null +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var result; + + sample.constructor = {}; + + result = sample.slice(); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "undefined @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "undefined @@species - ctor check"); + + sample.constructor[Symbol.species] = null; + result = sample.slice(); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "null @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "null @@species - ctor check"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js new file mode 100644 index 00000000000..87bf3b41ee9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + get @@species from found constructor +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 9. Let A be ? SendableTypedArraySpeciesCreate(O, « count »). + ... + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var calls = 0; + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + calls++; + } + }); + + sample.slice(); + + assert.sameValue(calls, 1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-resize.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-resize.js new file mode 100644 index 00000000000..b01dab67977 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-resize.js @@ -0,0 +1,141 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + SendableTypedArray.p.slice behaves correctly on SendableTypedArrays backed by resizable buffers + which the species constructor resizes. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// The corresponding test for Array.prototype.slice is not possible, since it +// doesn't call the species constructor if the "original array" is not an Array. + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + let resizeWhenConstructorCalled = false; + class MyArray extends ctor { + constructor(...params) { + super(...params); + if (resizeWhenConstructorCalled) { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + } + } + } + ; + const fixedLength = new MyArray(rab, 0, 4); + resizeWhenConstructorCalled = true; + assert.throws(TypeError, () => { + fixedLength.slice(); + }); + assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 1); + } + let resizeWhenConstructorCalled = false; + class MyArray extends ctor { + constructor(...params) { + super(...params); + if (resizeWhenConstructorCalled) { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + } + } + } + ; + const lengthTracking = new MyArray(rab); + resizeWhenConstructorCalled = true; + const a = lengthTracking.slice(); + assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); + // The length of the resulting SendableTypedArray is determined before + // SendableTypedArraySpeciesCreate is called, and it doesn't change. + assert.sameValue(a.length, 4); + assert.compareArray(ToNumbers(a), [ + 1, + 1, + 0, + 0 + ]); +} + +// Test that the (start, end) parameters are computed based on the original +// length. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 1); + } + let resizeWhenConstructorCalled = false; + class MyArray extends ctor { + constructor(...params) { + super(...params); + if (resizeWhenConstructorCalled) { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + } + } + } + ; + const lengthTracking = new MyArray(rab); + resizeWhenConstructorCalled = true; + const a = lengthTracking.slice(-3, -1); + assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); + // The length of the resulting SendableTypedArray is determined before + // SendableTypedArraySpeciesCreate is called, and it doesn't change. + assert.sameValue(a.length, 2); + assert.compareArray(ToNumbers(a), [ + 1, + 0 + ]); +} + +// Test where the buffer gets resized "between elements". +{ + const rab = CreateResizableArrayBuffer(8, 16); + const taWrite = new Uint8Array(rab); + for (let i = 0; i < 8; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 255); + } + let resizeWhenConstructorCalled = false; + class MyArray extends Uint16Array { + constructor(...params) { + super(...params); + if (resizeWhenConstructorCalled) { + rab.resize(5); + } + } + } + ; + const lengthTracking = new MyArray(rab); + assert.compareArray(ToNumbers(lengthTracking), [ + 65535, + 65535, + 65535, + 65535 + ]); + resizeWhenConstructorCalled = true; + const a = lengthTracking.slice(); + assert.sameValue(rab.byteLength, 5); + assert.sameValue(a.length, 4); + assert.sameValue(a[0], 65535); + assert.sameValue(a[1], 65535); + assert.sameValue(a[2], 0); + assert.sameValue(a[3], 0); +} diff --git a/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-object.js new file mode 100644 index 00000000000..3b052658414 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-object.js @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var slice = SendableTypedArray.prototype.slice; + +assert.throws(TypeError, function() { + slice.call(undefined, 0, 0); +}, "this is undefined"); + +assert.throws(TypeError, function() { + slice.call(null, 0, 0); +}, "this is null"); + +assert.throws(TypeError, function() { + slice.call(42, 0, 0); +}, "this is 42"); + +assert.throws(TypeError, function() { + slice.call("1", 0, 0); +}, "this is a string"); + +assert.throws(TypeError, function() { + slice.call(true, 0, 0); +}, "this is true"); + +assert.throws(TypeError, function() { + slice.call(false, 0, 0); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + slice.call(s, 0, 0); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..3f063114a09 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var slice = SendableTypedArray.prototype.slice; + +assert.throws(TypeError, function() { + slice.call({}, 0, 0); +}, "this is an Object"); + +assert.throws(TypeError, function() { + slice.call([], 0, 0); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + slice.call(ab, 0, 0); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + slice.call(dv, 0, 0); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js new file mode 100644 index 00000000000..b141aa42287 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: ToInteger(end) +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice( start , end ) + + ... + 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ? + ToInteger(end). + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +var obj = { + valueOf: function() { + return 2; + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + assert(compareArray(sample.slice(0, false), []), "false"); + assert(compareArray(sample.slice(0, true), [40]), "true"); + + assert(compareArray(sample.slice(0, NaN), []), "NaN"); + assert(compareArray(sample.slice(0, null), []), "null"); + assert(compareArray(sample.slice(0, undefined), [40, 41, 42, 43]), "undefined"); + + assert(compareArray(sample.slice(0, 0.6), []), "0.6"); + assert(compareArray(sample.slice(0, 1.1), [40]), "1.1"); + assert(compareArray(sample.slice(0, 1.5), [40]), "1.5"); + assert(compareArray(sample.slice(0, -0.6), []), "-0.6"); + assert(compareArray(sample.slice(0, -1.1), [40, 41, 42]), "-1.1"); + assert(compareArray(sample.slice(0, -1.5), [40, 41, 42]), "-1.5"); + + assert(compareArray(sample.slice(0, "3"), [40, 41, 42]), "string"); + assert( + compareArray( + sample.slice(0, obj), + [40, 41] + ), + "object" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js new file mode 100644 index 00000000000..73ffee651e2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.slice +description: ToInteger(begin) +info: | + 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) + + ... + 4. Let relativeStart be ? ToInteger(start). + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +var obj = { + valueOf: function() { + return 2; + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + assert(compareArray(sample.slice(false), [40, 41, 42, 43]), "false"); + assert(compareArray(sample.slice(true), [41, 42, 43]), "true"); + + assert(compareArray(sample.slice(NaN), [40, 41, 42, 43]), "NaN"); + assert(compareArray(sample.slice(null), [40, 41, 42, 43]), "null"); + assert(compareArray(sample.slice(undefined), [40, 41, 42, 43]), "undefined"); + + assert(compareArray(sample.slice(1.1), [41, 42, 43]), "1.1"); + assert(compareArray(sample.slice(1.5), [41, 42, 43]), "1.5"); + assert(compareArray(sample.slice(0.6), [40, 41, 42, 43]), "0.6"); + + assert(compareArray(sample.slice(-1.5), [43]), "-1.5"); + assert(compareArray(sample.slice(-1.1), [43]), "-1.1"); + assert(compareArray(sample.slice(-0.6), [40, 41, 42, 43]), "-0.6"); + + assert(compareArray(sample.slice("3"), [43]), "string"); + assert( + compareArray( + sample.slice(obj), + [42, 43] + ), + "object" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js new file mode 100644 index 00000000000..218fec87496 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + thisArg does not affect callbackfn arguments +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + var results = []; + var thisArg = ["test262", 0, "ecma262", 0]; + + sample.some(function() { + results.push(arguments); + }, thisArg); + + assert.sameValue(results.length, 3, "results.length"); + assert.sameValue(thisArg.length, 4, "thisArg.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42n, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43n, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44n, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js new file mode 100644 index 00000000000..5195972a28a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + callbackfn arguments +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + var results = []; + + sample.some(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 3, "results.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42n, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43n, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44n, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js new file mode 100644 index 00000000000..f6b114e887a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + Instance buffer can be detached during loop +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [detachArrayBuffer.js, testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.some(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + return false; + }); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js new file mode 100644 index 00000000000..9a71c8d6908 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + Does not interact over non-integer properties +info: | + 22.2.3.7 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7n, 8n]); + + var results = []; + + sample.foo = 42; + sample[Symbol("1")] = 43; + + sample.some(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0][1], 0, "results[0][1] - key"); + assert.sameValue(results[1][1], 1, "results[1][1] - key"); + + assert.sameValue(results[0][0], 7n, "results[0][0] - value"); + assert.sameValue(results[1][0], 8n, "results[1][0] - value"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js new file mode 100644 index 00000000000..479eb2fb8bc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: Throws a TypeError if callbackfn is not callable +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 3. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + assert.throws(TypeError, function() { + sample.some(); + }, "no args"); + + assert.throws(TypeError, function() { + sample.some(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.some(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.some("abc"); + }, "string"); + + assert.throws(TypeError, function() { + sample.some(1); + }, "number"); + + assert.throws(TypeError, function() { + sample.some(NaN); + }, "NaN"); + + assert.throws(TypeError, function() { + sample.some(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.some(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.some({}); + }, "{}"); + + assert.throws(TypeError, function() { + sample.some(sample); + }, "same typedArray instance"); + + assert.throws(TypeError, function() { + sample.some(Symbol("1")); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js new file mode 100644 index 00000000000..4dc5747f95d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + callbackfn is not called on empty instances +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var called = 0; + + new TA().some(function() { + called++; + }); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js new file mode 100644 index 00000000000..7ed788544ed --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + The callbackfn return does not change the instance +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n]); + + sample.some(function() { + return 0; + }); + + assert.sameValue(sample[0], 40n, "[0] == 40"); + assert.sameValue(sample[1], 41n, "[1] == 41"); + assert.sameValue(sample[2], 42n, "[2] == 42"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js new file mode 100644 index 00000000000..729fbd92a7e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: Returns abrupt from callbackfn +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + assert.throws(Test262Error, function() { + sample.some(function() { + throw new Test262Error(); + }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js new file mode 100644 index 00000000000..389919b4f57 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Reflect.set, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + var newVal = 0n; + + sample.some(function(val, i) { + if (i > 0) { + assert.sameValue( + sample[i - 1], newVal - 1n, + "get the changed value during the loop" + ); + assert.sameValue( + Reflect.set(sample, 0, 7n), + true, + "re-set a value for sample[0]" + ); + } + assert.sameValue( + Reflect.set(sample, i, newVal), + true, + "set value during iteration" + ); + + newVal++; + }); + + assert.sameValue(sample[0], 7n, "changed values after iteration [0] == 7"); + assert.sameValue(sample[1], 1n, "changed values after iteration [1] == 1"); + assert.sameValue(sample[2], 2n, "changed values after iteration [2] == 2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-this.js new file mode 100644 index 00000000000..e01316d9e5d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-this.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + callbackfn `this` value +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + ... + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var expected = (function() { return this; })(); +var thisArg = {}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var results1 = []; + + sample.some(function() { + results1.push(this); + }); + + assert.sameValue(results1.length, 3, "results1"); + assert.sameValue(results1[0], expected, "without thisArg - [0]"); + assert.sameValue(results1[1], expected, "without thisArg - [1]"); + assert.sameValue(results1[2], expected, "without thisArg - [2]"); + + var results2 = []; + + sample.some(function() { + results2.push(this); + }, thisArg); + + assert.sameValue(results2.length, 3, "results2"); + assert.sameValue(results2[0], thisArg, "using thisArg - [0]"); + assert.sameValue(results2[1], thisArg, "using thisArg - [1]"); + assert.sameValue(results2[2], thisArg, "using thisArg - [2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/detached-buffer.js new file mode 100644 index 00000000000..2a658d89439 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var callbackfn = function() { + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.some(callbackfn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..1f39e0cd05b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n]); + var calls = 0; + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.some(function() { + calls++; + }); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert.sameValue(calls, 2, "iterations are not affected by custom length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..893d43f0935 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.some, + 'function', + 'implements SendableTypedArray.prototype.some' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.some(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.some(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the some operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.some(() => {}); + throw new Test262Error('some completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js new file mode 100644 index 00000000000..ec6e0046189 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + Returns false if every callbackfn calls returns a coerced false. +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 7. Return true. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(42); + + [ + false, + "", + 0, + -0, + NaN, + undefined, + null + ].forEach(function(val) { + var called = 0; + var result = sample.some(function() { + called++; + return val; + }); + assert.sameValue(called, 42, "callbackfn called for each index property"); + assert.sameValue(result, false, "result is false - " + val); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js new file mode 100644 index 00000000000..91069ccfec9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + Returns true if any callbackfn returns a coerced true. +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + iii. If testResult is true, return true. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(42); + [ + true, + 1, + "test262", + s, + {}, + [], + -1, + Infinity, + -Infinity, + 0.1, + -0.1 + ].forEach(function(val) { + var called = 0; + var result = sample.some(function() { + called++; + if (called == 1) { + return false; + } + return val; + }); + assert.sameValue(called, 2, "callbackfn called for each index property"); + + var msg = "result is true - " + (val === s ? "symbol" : val); + assert.sameValue(result, true, msg); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/values-are-not-cached.js new file mode 100644 index 00000000000..5a20088041b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/values-are-not-cached.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + Integer indexed values are not cached before iteration +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n]); + + sample.some(function(v, i) { + if (i < sample.length - 1) { + sample[i+1] = 42n; + } + + assert.sameValue( + v, 42n, "method does not cache values before callbackfn calls" + ); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js new file mode 100644 index 00000000000..b9060ce396a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + thisArg does not affect callbackfn arguments +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + var results = []; + var thisArg = ["test262", 0, "ecma262", 0]; + + sample.some(function() { + results.push(arguments); + }, thisArg); + + assert.sameValue(results.length, 3, "results.length"); + assert.sameValue(thisArg.length, 4, "thisArg.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js new file mode 100644 index 00000000000..3c708571661 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + callbackfn arguments +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + var results = []; + + sample.some(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 3, "results.length"); + + assert.sameValue(results[0].length, 3, "results[0].length"); + assert.sameValue(results[0][0], 42, "results[0][0] - kValue"); + assert.sameValue(results[0][1], 0, "results[0][1] - k"); + assert.sameValue(results[0][2], sample, "results[0][2] - this"); + + assert.sameValue(results[1].length, 3, "results[1].length"); + assert.sameValue(results[1][0], 43, "results[1][0] - kValue"); + assert.sameValue(results[1][1], 1, "results[1][1] - k"); + assert.sameValue(results[1][2], sample, "results[1][2] - this"); + + assert.sameValue(results[2].length, 3, "results[2].length"); + assert.sameValue(results[2][0], 44, "results[2][0] - kValue"); + assert.sameValue(results[2][1], 2, "results[2][1] - k"); + assert.sameValue(results[2][2], sample, "results[2][2] - this"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js new file mode 100644 index 00000000000..d7bcee3ba24 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + Instance buffer can be detached during loop +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [detachArrayBuffer.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var loops = 0; + var sample = new TA(2); + + sample.some(function() { + if (loops === 0) { + $DETACHBUFFER(sample.buffer); + } + loops++; + return false; + }); + + assert.sameValue(loops, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js new file mode 100644 index 00000000000..364877da24f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + Does not interact over non-integer properties +info: | + 22.2.3.7 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([7, 8]); + + var results = []; + + sample.foo = 42; + sample[Symbol("1")] = 43; + + sample.some(function() { + results.push(arguments); + }); + + assert.sameValue(results.length, 2, "results.length"); + + assert.sameValue(results[0][1], 0, "results[0][1] - key"); + assert.sameValue(results[1][1], 1, "results[1][1] - key"); + + assert.sameValue(results[0][0], 7, "results[0][0] - value"); + assert.sameValue(results[1][0], 8, "results[1][0] - value"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js new file mode 100644 index 00000000000..b64dd3225d8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js @@ -0,0 +1,82 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: Throws a TypeError if callbackfn is not callable +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 3. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + assert.throws(TypeError, function() { + sample.some(); + }, "no args"); + + assert.throws(TypeError, function() { + sample.some(null); + }, "null"); + + assert.throws(TypeError, function() { + sample.some(undefined); + }, "undefined"); + + assert.throws(TypeError, function() { + sample.some("abc"); + }, "string"); + + assert.throws(TypeError, function() { + sample.some(1); + }, "number"); + + assert.throws(TypeError, function() { + sample.some(NaN); + }, "NaN"); + + assert.throws(TypeError, function() { + sample.some(false); + }, "false"); + + assert.throws(TypeError, function() { + sample.some(true); + }, "true"); + + assert.throws(TypeError, function() { + sample.some({}); + }, "{}"); + + assert.throws(TypeError, function() { + sample.some(sample); + }, "same typedArray instance"); + + assert.throws(TypeError, function() { + sample.some(Symbol("1")); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js new file mode 100644 index 00000000000..f85835885e7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + callbackfn is not called on empty instances +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var called = 0; + + new TA().some(function() { + called++; + }); + + assert.sameValue(called, 0); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js new file mode 100644 index 00000000000..f1ddd7b276e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js @@ -0,0 +1,86 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: Instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); + +testWithSendableTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var finalElement, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + + elements = []; + indices = []; + arrays = []; + result = sample.some(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + finalElement = undefined; + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + finalElement = 0; + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, [0, 0, finalElement], 'elements (shrink)'); + assert.compareArray(indices, [0, 1, 2], 'indices (shrink)'); + assert.compareArray(arrays, [sample, sample, sample], 'arrays (shrink)'); + assert.sameValue(result, false, 'result (shrink)'); + + elements = []; + indices = []; + arrays = []; + result = sample.some(function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, false, 'result (grow)'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js new file mode 100644 index 00000000000..141142b5cbb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + The callbackfn return does not change the instance +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42]); + + sample.some(function() { + return 0; + }); + + assert.sameValue(sample[0], 40, "[0] == 40"); + assert.sameValue(sample[1], 41, "[1] == 41"); + assert.sameValue(sample[2], 42, "[2] == 42"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js new file mode 100644 index 00000000000..c211ef3eaed --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: Returns abrupt from callbackfn +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + assert.throws(Test262Error, function() { + sample.some(function() { + throw new Test262Error(); + }); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js new file mode 100644 index 00000000000..6f1e59a64c4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + Integer indexed values changed during iteration +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [Reflect.set, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + var newVal = 0; + + sample.some(function(val, i) { + if (i > 0) { + assert.sameValue( + sample[i - 1], newVal - 1, + "get the changed value during the loop" + ); + assert.sameValue( + Reflect.set(sample, 0, 7), + true, + "re-set a value for sample[0]" + ); + } + assert.sameValue( + Reflect.set(sample, i, newVal), + true, + "set value during iteration" + ); + + newVal++; + }); + + assert.sameValue(sample[0], 7, "changed values after iteration [0] == 7"); + assert.sameValue(sample[1], 1, "changed values after iteration [1] == 1"); + assert.sameValue(sample[2], 2, "changed values after iteration [2] == 2"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js new file mode 100644 index 00000000000..17de885f0f5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + callbackfn `this` value +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 4. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + ... + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var expected = (function() { return this; })(); +var thisArg = {}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(3); + + var results1 = []; + + sample.some(function() { + results1.push(this); + }); + + assert.sameValue(results1.length, 3, "results1"); + assert.sameValue(results1[0], expected, "without thisArg - [0]"); + assert.sameValue(results1[1], expected, "without thisArg - [1]"); + assert.sameValue(results1[2], expected, "without thisArg - [2]"); + + var results2 = []; + + sample.some(function() { + results2.push(this); + }, thisArg); + + assert.sameValue(results2.length, 3, "results2"); + assert.sameValue(results2[0], thisArg, "using thisArg - [0]"); + assert.sameValue(results2[1], thisArg, "using thisArg - [1]"); + assert.sameValue(results2[2], thisArg, "using thisArg - [2]"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js new file mode 100644 index 00000000000..6f43a62a3bb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var callbackfn = function() { + throw new Test262Error(); +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.some(callbackfn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..2202f0bc6c1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? ToLength(? Get(O, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43]); + var calls = 0; + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.some(function() { + calls++; + }); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert.sameValue(calls, 2, "iterations are not affected by custom length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/some/invoked-as-func.js new file mode 100644 index 00000000000..be49515ed67 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/invoked-as-func.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.24 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var some = SendableTypedArray.prototype.some; + +assert.sameValue(typeof some, 'function'); + +assert.throws(TypeError, function() { + some(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/some/invoked-as-method.js new file mode 100644 index 00000000000..3d83b55aad9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/invoked-as-method.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.24 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.some, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.some(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/length.js b/test/sendable/builtins/TypedArray/prototype/some/length.js new file mode 100644 index 00000000000..b70fe282c73 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + %SendableTypedArray%.prototype.some.length is 1. +info: | + %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.some, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/name.js b/test/sendable/builtins/TypedArray/prototype/some/name.js new file mode 100644 index 00000000000..dc6118f6c76 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + %SendableTypedArray%.prototype.some.name is "some". +info: | + %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.some, "name", { + value: "some", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/some/not-a-constructor.js new file mode 100644 index 00000000000..9f78d65f29c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.some 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.some), + false, + 'isConstructor(SendableTypedArray.prototype.some) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.some(() => {}); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/some/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/some/prop-desc.js new file mode 100644 index 00000000000..2b1b3b254e6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + "some" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'some', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..62a3f270435 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,96 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + SendableTypedArray.p.some behaves correctly on SendableTypedArrays backed by resizable buffers + which are grown mid-iteration. +features: [resizable-arraybuffer] +includes: [compareArray.js, resizableArrayBufferUtils.js] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Below the argument array should be a view of the resizable array buffer rab. +// This array gets collected into values via reduce and CollectValuesAndResize. +// The latter performs an during which, after resizeAfter steps, rab is resized +// to length resizeTo. Note that rab, values, resizeAfter, and resizeTo may need +// to be reset before calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(!fixedLength.some(ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(!fixedLengthWithOffset.some(ResizeMidIteration)); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(!lengthTracking.some(ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + rab = rab; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(!lengthTrackingWithOffset.some(ResizeMidIteration)); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..efb2fca44a0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + SendableTypedArray.p.some behaves correctly on SendableTypedArrays backed by resizable buffers + which are shrunk mid-iteration. +features: [resizable-arraybuffer] +includes: [compareArray.js, resizableArrayBufferUtils.js] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Below the argument array should be a view of the resizable array buffer rab. +// This array gets collected into values via reduce and CollectValuesAndResize. +// The latter performs an during which, after resizeAfter steps, rab is resized +// to length resizeTo. Note that rab, values, resizeAfter, and resizeTo may need +// to be reset before calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(!fixedLength.some(ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2, + undefined, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(!fixedLengthWithOffset.some(ResizeMidIteration)); + assert.compareArray(values, [ + 4, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(!lengthTracking.some(ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2, + 4, + undefined + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(!lengthTrackingWithOffset.some(ResizeMidIteration)); + assert.compareArray(values, [ + 4, + undefined + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer.js new file mode 100644 index 00000000000..b76a99edf4e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer.js @@ -0,0 +1,127 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + SendableTypedArray.p.some behaves correctly on SendableTypedArrays backed by resizable buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + function div3(n) { + return Number(n) % 3 == 0; + } + function over10(n) { + return Number(n) > 10; + } + assert(fixedLength.some(div3)); + assert(!fixedLength.some(over10)); + assert(fixedLengthWithOffset.some(div3)); + assert(!fixedLengthWithOffset.some(over10)); + assert(lengthTracking.some(div3)); + assert(!lengthTracking.some(over10)); + assert(lengthTrackingWithOffset.some(div3)); + assert(!lengthTrackingWithOffset.some(over10)); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + fixedLength.some(div3); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.some(div3); + }); + + assert(lengthTracking.some(div3)); + assert(!lengthTracking.some(over10)); + assert(!lengthTrackingWithOffset.some(div3)); + assert(!lengthTrackingWithOffset.some(over10)); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.some(div3); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.some(div3); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.some(div3); + }); + + assert(lengthTracking.some(div3)); + assert(!lengthTracking.some(over10)); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.some(div3); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.some(div3); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.some(div3); + }); + + assert(!lengthTracking.some(div3)); + assert(!lengthTracking.some(over10)); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert(fixedLength.some(div3)); + assert(!fixedLength.some(over10)); + assert(fixedLengthWithOffset.some(div3)); + assert(!fixedLengthWithOffset.some(over10)); + assert(lengthTracking.some(div3)); + assert(!lengthTracking.some(over10)); + assert(lengthTrackingWithOffset.some(div3)); + assert(!lengthTrackingWithOffset.some(over10)); +} diff --git a/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..926ba0120b9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.some, + 'function', + 'implements SendableTypedArray.prototype.some' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.some(() => {}); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.some(() => {}); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the some operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.some(() => {}); + throw new Test262Error('some completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js b/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js new file mode 100644 index 00000000000..87161fe6c07 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + Returns false if every callbackfn calls returns a coerced false. +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 7. Return true. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(42); + + [ + false, + "", + 0, + -0, + NaN, + undefined, + null + ].forEach(function(val) { + var called = 0; + var result = sample.some(function() { + called++; + return val; + }); + assert.sameValue(called, 42, "callbackfn called for each index property"); + assert.sameValue(result, false, "result is false - " + val); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js b/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js new file mode 100644 index 00000000000..9f7198fa8cf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + Returns true if any callbackfn returns a coerced true. +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + ... + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + iii. If testResult is true, return true. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(42); + [ + true, + 1, + "test262", + s, + {}, + [], + -1, + Infinity, + -Infinity, + 0.1, + -0.1 + ].forEach(function(val) { + var called = 0; + var result = sample.some(function() { + called++; + if (called == 1) { + return false; + } + return val; + }); + assert.sameValue(called, 2, "callbackfn called for each index property"); + + var msg = "result is true - " + (val === s ? "symbol" : val); + assert.sameValue(result, true, msg); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/some/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/some/this-is-not-object.js new file mode 100644 index 00000000000..77a59d2e42f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/this-is-not-object.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var some = SendableTypedArray.prototype.some; +var callbackfn = function() {}; + +assert.throws(TypeError, function() { + some.call(undefined, callbackfn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + some.call(null, callbackfn); +}, "this is null"); + +assert.throws(TypeError, function() { + some.call(42, callbackfn); +}, "this is 42"); + +assert.throws(TypeError, function() { + some.call("1", callbackfn); +}, "this is a string"); + +assert.throws(TypeError, function() { + some.call(true, callbackfn); +}, "this is true"); + +assert.throws(TypeError, function() { + some.call(false, callbackfn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + some.call(s, callbackfn); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..9dbef33dd7d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var some = SendableTypedArray.prototype.some; +var callbackfn = function () {}; + +assert.throws(TypeError, function() { + some.call({}, callbackfn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + some.call([], callbackfn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + some.call(ab, callbackfn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + some.call(dv, callbackfn); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js new file mode 100644 index 00000000000..70a196d7b98 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.some +description: > + Integer indexed values are not cached before iteration +info: | + 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) + + %SendableTypedArray%.prototype.some is a distinct function that implements the same + algorithm as Array.prototype.some as defined in 22.1.3.24 except that the this + object's [[ArrayLength]] internal slot is accessed in place of performing a + [[Get]] of "length". + + 22.1.3.24 Array.prototype.some ( callbackfn [ , thisArg ] ) + + ... + 6. Repeat, while k < len + .. + c. If kPresent is true, then + i. Let kValue be ? Get(O, Pk). + ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44]); + + sample.some(function(v, i) { + if (i < sample.length - 1) { + sample[i+1] = 42; + } + + assert.sameValue( + v, 42, "method does not cache values before callbackfn calls" + ); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js new file mode 100644 index 00000000000..22f9f1a7826 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Use internal ArrayLength instead of getting a length property +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + ... + 3. Let len be the value of obj's [[ArrayLength]] internal slot. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 42n, 42n]); + getCalls = 0; + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + var result = sample.sort(); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert( + compareArray(result, sample), + "result is not affected by custom length" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js new file mode 100644 index 00000000000..5a3b390f91d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Returns abrupt from comparefn +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + When the SendableTypedArray SortCompare abstract operation is called with two + arguments x and y, the following steps are taken: + + ... + 2. If the argument comparefn is not undefined, then + a. Let v be ? Call(comparefn, undefined, « x, y »). + ... + ... + + 22.1.3.25 Array.prototype.sort (comparefn) + + The following steps are taken: + + - If an abrupt completion is returned from any of these operations, it is + immediately returned as the value of this function. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n, 45n, 46n]); + var calls = 0; + + var comparefn = function() { + calls += 1; + throw new Test262Error(); + }; + + assert.throws(Test262Error, function() { + sample.sort(comparefn); + }); + + assert.sameValue(calls, 1, "immediately returned"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-calls.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-calls.js new file mode 100644 index 00000000000..bd80c9d0293 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-calls.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: comparefn is called if not undefined +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + When the SendableTypedArray SortCompare abstract operation is called with two + arguments x and y, the following steps are taken: + + ... + 2. If the argument comparefn is not undefined, then + a. Let v be ? Call(comparefn, undefined, « x, y »). + ... + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var expectedThis = (function() { + return this; +})(); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 42n, 42n, 42n, 42n]); + var calls = []; + + var comparefn = function() { + calls.push([this, arguments]); + }; + + sample.sort(comparefn); + + assert(calls.length > 0, "calls comparefn"); + calls.forEach(function(args) { + assert.sameValue(args[0], expectedThis, "comparefn is called no specific this"); + assert.sameValue(args[1].length, 2, "comparefn is always called with 2 args"); + assert.sameValue(args[1][0], 42n, "x is a listed value"); + assert.sameValue(args[1][0], 42n, "y is a listed value"); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js new file mode 100644 index 00000000000..4fc8da18d88 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: > + Treats explicit undefined comparefn the same as implicit undefined comparefn +info: | + %SendableTypedArray%.prototype.sort ( comparefn ) + + 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. + ... +includes: [compareArray.js, testBigIntSendableTypedArray.js] +features: [TypedArray, BigInt] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + let sample = new TA([42n, 44n, 46n, 43n, 45n]); + let explicit = sample.sort(undefined); + let implicit = sample.sort(); + + assert.compareArray(explicit, [42n, 43n, 44n, 45n, 46n], 'The value of `explicit` is [42n, 43n, 44n, 45n, 46n]'); + assert.compareArray(implicit, [42n, 43n, 44n, 45n, 46n], 'The value of `implicit` is [42n, 43n, 44n, 45n, 46n]'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js new file mode 100644 index 00000000000..caf16768134 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: throws on a non-undefined non-function +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + Upon entry, the following steps are performed to initialize evaluation + of the sort function. These steps are used instead of the entry steps + in 22.1.3.25: + + ... + 1. If _comparefn_ is not *undefined* and IsCallable(_comparefn_) is *false*, throw a *TypeError* exception. + ... + +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n, 44n, 45n, 46n]); + + assert.throws(TypeError, function() { + sample.sort(null); + }); + + assert.throws(TypeError, function() { + sample.sort(true); + }); + + assert.throws(TypeError, function() { + sample.sort(false); + }); + + assert.throws(TypeError, function() { + sample.sort(''); + }); + + assert.throws(TypeError, function() { + sample.sort(/a/g); + }); + + assert.throws(TypeError, function() { + sample.sort(42); + }); + + assert.throws(TypeError, function() { + sample.sort([]); + }); + + assert.throws(TypeError, function() { + sample.sort({}); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/detached-buffer.js new file mode 100644 index 00000000000..802bc70e9ff --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/detached-buffer.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + 1. Let obj be the this value. + 2. Let buffer be ? ValidateSendableTypedArray(obj). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var comparefn = function() { + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.sort(comparefn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..9635e0cc690 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.sort, + 'function', + 'implements SendableTypedArray.prototype.sort' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.sort(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.sort(); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the sort operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.sort(); + throw new Test262Error('sort completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-same-instance.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-same-instance.js new file mode 100644 index 00000000000..5fefa74b198 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-same-instance.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Returns the same instance +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + When the SendableTypedArray SortCompare abstract operation is called with two + arguments x and y, the following steps are taken: + + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([2n, 1n]); + var result = sample.sort(); + + assert.sameValue(sample, result, "without comparefn"); + + result = sample.sort(function() { return 0; }); + assert.sameValue(sample, result, "with comparefn"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js new file mode 100644 index 00000000000..a08a33d03d9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: SendableTypedArrays sort does not cast values to String +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + When the SendableTypedArray SortCompare abstract operation is called with two + arguments x and y, the following steps are taken: + + ... + 2. If the argument comparefn is not undefined, then + a. Let v be ? Call(comparefn, undefined, « x, y »). + ... + ... +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +var toStringCalled = false; +BigInt.prototype.toString = function() { + toStringCalled = true; +} + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([20n, 100n, 3n]); + var result = sample.sort(); + assert.sameValue(toStringCalled, false, "BigInt.prototype.toString will not be called"); + assert(compareArray(result, [3n, 20n, 100n])); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sorted-values.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sorted-values.js new file mode 100644 index 00000000000..65be4f5a264 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sorted-values.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Sort values to numeric ascending order +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + When the SendableTypedArray SortCompare abstract operation is called with two + arguments x and y, the following steps are taken: + + ... +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([4n, 3n, 2n, 1n]).sort(); + assert(compareArray(sample, [1n, 2n, 3n, 4n]), "descending values"); + + sample = new TA([3n, 4n, 1n, 2n]).sort(); + assert(compareArray(sample, [1n, 2n, 3n, 4n]), "mixed numbers"); + + sample = new TA([3n, 4n, 3n, 1n, 0n, 1n, 2n]).sort(); + assert(compareArray(sample, [0n, 1n, 1n, 2n, 3n, 3n, 4n]), "repeating numbers"); +}); + +var sample = new BigInt64Array([-4n, 3n, 4n, -3n, 2n, -2n, 1n, 0n]).sort(); +assert(compareArray(sample, [-4n, -3n, -2n, 0n, 1n, 2n, 3n, 4n]), "negative values"); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js new file mode 100644 index 00000000000..5164fe6a8c2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Use internal ArrayLength instead of getting a length property +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + ... + 3. Let len be the value of obj's [[ArrayLength]] internal slot. +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 42, 42]); + getCalls = 0; + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + var result = sample.sort(); + + assert.sameValue(getCalls, 0, "ignores length properties"); + assert( + compareArray(result, sample), + "result is not affected by custom length" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js new file mode 100644 index 00000000000..cf3a7db86ca --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Returns abrupt from comparefn +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + When the SendableTypedArray SortCompare abstract operation is called with two + arguments x and y, the following steps are taken: + + ... + 2. If the argument comparefn is not undefined, then + a. Let v be ? Call(comparefn, undefined, « x, y »). + ... + ... + + 22.1.3.25 Array.prototype.sort (comparefn) + + The following steps are taken: + + - If an abrupt completion is returned from any of these operations, it is + immediately returned as the value of this function. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44, 45, 46]); + var calls = 0; + + var comparefn = function() { + calls += 1; + throw new Test262Error(); + }; + + assert.throws(Test262Error, function() { + sample.sort(comparefn); + }); + + assert.sameValue(calls, 1, "immediately returned"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js new file mode 100644 index 00000000000..d6ce290f725 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: comparefn is called if not undefined +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + When the SendableTypedArray SortCompare abstract operation is called with two + arguments x and y, the following steps are taken: + + ... + 2. If the argument comparefn is not undefined, then + a. Let v be ? Call(comparefn, undefined, « x, y »). + ... + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var expectedThis = (function() { + return this; +})(); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 42, 42, 42, 42]); + var calls = []; + + var comparefn = function() { + calls.push([this, arguments]); + }; + + sample.sort(comparefn); + + assert(calls.length > 0, "calls comparefn"); + calls.forEach(function(args) { + assert.sameValue(args[0], expectedThis, "comparefn is called no specific this"); + assert.sameValue(args[1].length, 2, "comparefn is always called with 2 args"); + assert.sameValue(args[1][0], 42, "x is a listed value"); + assert.sameValue(args[1][0], 42, "y is a listed value"); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-grow.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-grow.js new file mode 100644 index 00000000000..b229279f360 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-grow.js @@ -0,0 +1,83 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: > + SendableTypedArray.p.sort behaves correctly on SendableTypedArrays backed by resizable buffers + which are grown by the comparison callback. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Returns a function that resizes rab to size resizeTo and then compares its +// arguments. Such a result function is to be used as an argument to .sort. +function ResizeAndCompare(rab, resizeTo) { + return (a, b) => { + rab.resize(resizeTo); + if (a < b) { + return -1; + } + if (a > b) { + return 1; + } + return 0; + } +} + +function WriteUnsortedData(taFull) { + for (let i = 0; i < taFull.length; ++i) { + taFull[i] = MayNeedBigInt(taFull, 10 - i); + } +} + +// Fixed length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const resizeTo = 6 * ctor.BYTES_PER_ELEMENT; + const fixedLength = new ctor(rab, 0, 4); + const taFull = new ctor(rab, 0); + WriteUnsortedData(taFull); + fixedLength.sort(ResizeAndCompare(rab, resizeTo)); + // Growing doesn't affect the sorting. + assert.compareArray(ToNumbers(taFull), [ + 7, + 8, + 9, + 10, + 0, + 0 + ]); +} + +// Length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const resizeTo = 6 * ctor.BYTES_PER_ELEMENT; + const lengthTracking = new ctor(rab, 0); + const taFull = new ctor(rab, 0); + WriteUnsortedData(taFull); + lengthTracking.sort(ResizeAndCompare(rab, resizeTo)); + // Growing doesn't affect the sorting. Only the elements that were part of + // the original TA are sorted. + assert.compareArray(ToNumbers(taFull), [ + 7, + 8, + 9, + 10, + 0, + 0 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js new file mode 100644 index 00000000000..b15ef97e307 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: > + Treats explicit undefined comparefn the same as implicit undefined comparefn +info: | + %SendableTypedArray%.prototype.sort ( comparefn ) + + 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. + ... +includes: [compareArray.js, testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + let sample = new TA([42, 44, 46, 43, 45]); + let explicit = sample.sort(undefined); + let implicit = sample.sort(); + + assert.compareArray(explicit, [42, 43, 44, 45, 46], 'The value of `explicit` is [42, 43, 44, 45, 46]'); + assert.compareArray(implicit, [42, 43, 44, 45, 46], 'The value of `implicit` is [42, 43, 44, 45, 46]'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js new file mode 100644 index 00000000000..0b9488e481a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: throws on a non-undefined non-function +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + Upon entry, the following steps are performed to initialize evaluation + of the sort function. These steps are used instead of the entry steps + in 22.1.3.25: + + ... + 1. If _comparefn_ is not *undefined* and IsCallable(_comparefn_) is *false*, throw a *TypeError* exception. + ... + +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42, 43, 44, 45, 46]); + + assert.throws(TypeError, function() { + sample.sort(null); + }); + + assert.throws(TypeError, function() { + sample.sort(true); + }); + + assert.throws(TypeError, function() { + sample.sort(false); + }); + + assert.throws(TypeError, function() { + sample.sort(''); + }); + + assert.throws(TypeError, function() { + sample.sort(/a/g); + }); + + assert.throws(TypeError, function() { + sample.sort(42); + }); + + assert.throws(TypeError, function() { + sample.sort([]); + }); + + assert.throws(TypeError, function() { + sample.sort({}); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-resizable-buffer.js new file mode 100644 index 00000000000..97b7a2ebabc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-resizable-buffer.js @@ -0,0 +1,218 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: > + SendableTypedArray.p.sort behaves correctly on SendableTypedArrays backed by resizable buffers + and passed a user-provided comparison callback. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const taFull = new ctor(rab, 0); + function WriteUnsortedData() { + // Write some data into the array. + for (let i = 0; i < taFull.length; ++i) { + taFull[i] = MayNeedBigInt(taFull, 10 - i); + } + } + function OddBeforeEvenComparison(a, b) { + // Sort all odd numbers before even numbers. + a = Number(a); + b = Number(b); + if (a % 2 == 1 && b % 2 == 0) { + return -1; + } + if (a % 2 == 0 && b % 2 == 1) { + return 1; + } + if (a < b) { + return -1; + } + if (a > b) { + return 1; + } + return 0; + } + // Orig. array: [10, 9, 8, 7] + // [10, 9, 8, 7] << fixedLength + // [8, 7] << fixedLengthWithOffset + // [10, 9, 8, 7, ...] << lengthTracking + // [8, 7, ...] << lengthTrackingWithOffset + + WriteUnsortedData(); + fixedLength.sort(OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 7, + 9, + 8, + 10 + ]); + WriteUnsortedData(); + fixedLengthWithOffset.sort(OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 10, + 9, + 7, + 8 + ]); + WriteUnsortedData(); + lengthTracking.sort(OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 7, + 9, + 8, + 10 + ]); + WriteUnsortedData(); + lengthTrackingWithOffset.sort(OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 10, + 9, + 7, + 8 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [10, 9, 8] + // [10, 9, 8, ...] << lengthTracking + // [8, ...] << lengthTrackingWithOffset + + WriteUnsortedData(); + assert.throws(TypeError, () => { + fixedLength.sort(OddBeforeEvenComparison); + }); + assert.compareArray(ToNumbers(taFull), [ + 10, + 9, + 8 + ]); + assert.throws(TypeError, () => { + fixedLengthWithOffset.sort(OddBeforeEvenComparison); + }); + assert.compareArray(ToNumbers(taFull), [ + 10, + 9, + 8 + ]); + WriteUnsortedData(); + lengthTracking.sort(OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 9, + 8, + 10 + ]); + WriteUnsortedData(); + lengthTrackingWithOffset.sort(OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 10, + 9, + 8 + ]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + WriteUnsortedData(); + assert.throws(TypeError, () => { + fixedLength.sort(OddBeforeEvenComparison); + }); + assert.compareArray(ToNumbers(taFull), [10]); + assert.throws(TypeError, () => { + fixedLengthWithOffset.sort(OddBeforeEvenComparison); + }); + assert.compareArray(ToNumbers(taFull), [10]); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.sort(OddBeforeEvenComparison); + }); + assert.compareArray(ToNumbers(taFull), [10]); + + WriteUnsortedData(); + lengthTracking.sort(OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [10]); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.sort(OddBeforeEvenComparison); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.sort(OddBeforeEvenComparison); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.sort(OddBeforeEvenComparison); + }); + + lengthTracking.sort(OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), []); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [10, 9, 8, 7, 6, 5] + // [10, 9, 8, 7] << fixedLength + // [8, 7] << fixedLengthWithOffset + // [10, 9, 8, 7, 6, 5, ...] << lengthTracking + // [8, 7, 6, 5, ...] << lengthTrackingWithOffset + + WriteUnsortedData(); + fixedLength.sort(OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 7, + 9, + 8, + 10, + 6, + 5 + ]); + WriteUnsortedData(); + fixedLengthWithOffset.sort(OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 10, + 9, + 7, + 8, + 6, + 5 + ]); + WriteUnsortedData(); + lengthTracking.sort(OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 5, + 7, + 9, + 6, + 8, + 10 + ]); + WriteUnsortedData(); + lengthTrackingWithOffset.sort(OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 10, + 9, + 5, + 7, + 6, + 8 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-shrink.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-shrink.js new file mode 100644 index 00000000000..78a8e2ead80 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-shrink.js @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: > + SendableTypedArray.p.sort behaves correctly on SendableTypedArrays backed by a + resizable buffer and is shrunk by the comparison callback +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer, Array.prototype.includes] +---*/ + +// Returns a function that resizes rab to size resizeTo and then compares its +// arguments. Such a result function is to be used as an argument to .sort. +function ResizeAndCompare(rab, resizeTo) { + return (a, b) => { + rab.resize(resizeTo); + if (a < b) { + return -1; + } + if (a > b) { + return 1; + } + return 0; + } +} + +function WriteUnsortedData(taFull) { + for (let i = 0; i < taFull.length; ++i) { + taFull[i] = MayNeedBigInt(taFull, 10 - i); + } +} + +// Fixed length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const resizeTo = 2 * ctor.BYTES_PER_ELEMENT; + const fixedLength = new ctor(rab, 0, 4); + const taFull = new ctor(rab, 0); + WriteUnsortedData(taFull); + fixedLength.sort(ResizeAndCompare(rab, resizeTo)); + // The data is unchanged. + assert.compareArray(ToNumbers(taFull), [ + 10, + 9 + ]); +} + +// Length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const resizeTo = 2 * ctor.BYTES_PER_ELEMENT; + const lengthTracking = new ctor(rab, 0); + const taFull = new ctor(rab, 0); + WriteUnsortedData(taFull); + lengthTracking.sort(ResizeAndCompare(rab, resizeTo)); + // The sort result is implementation defined, but it contains 2 elements out + // of the 4 original ones. + const newData = ToNumbers(taFull); + assert.sameValue(newData.length, 2); + assert([ + 10, + 9, + 8, + 7 + ].includes(newData[0])); + assert([ + 10, + 9, + 8, + 7 + ].includes(newData[1])); +} diff --git a/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js new file mode 100644 index 00000000000..3c43668fc4d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + 1. Let obj be the this value. + 2. Let buffer be ? ValidateSendableTypedArray(obj). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var comparefn = function() { + throw new Test262Error(); +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.sort(comparefn); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-func.js new file mode 100644 index 00000000000..bd84af94648 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-func.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.25 %SendableTypedArray%.prototype.sort ( comparefn ) + + ... + This function is not generic. The this value must be an object with a + [[TypedArrayName]] internal slot. + ... + + 1. Let obj be the this value as the argument. + 2. Let buffer be ValidateSendableTypedArray(obj). + 3. ReturnIfAbrupt(buffer). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var sort = SendableTypedArray.prototype.sort; + +assert.sameValue(typeof sort, 'function'); + +assert.throws(TypeError, function() { + sort(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-method.js new file mode 100644 index 00000000000..9fd482f30a9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-method.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.25 %SendableTypedArray%.prototype.sort ( comparefn ) + + ... + This function is not generic. The this value must be an object with a + [[TypedArrayName]] internal slot. + ... + + 1. Let obj be the this value as the argument. + 2. Let buffer be ValidateSendableTypedArray(obj). + 3. ReturnIfAbrupt(buffer). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.sort, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.sort(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/length.js b/test/sendable/builtins/TypedArray/prototype/sort/length.js new file mode 100644 index 00000000000..62ccc91cddf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: > + %SendableTypedArray%.prototype.sort.length is 1. +info: | + %SendableTypedArray%.prototype.sort ( comparefn ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.sort, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/name.js b/test/sendable/builtins/TypedArray/prototype/sort/name.js new file mode 100644 index 00000000000..a5dd930c9e3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: > + %SendableTypedArray%.prototype.sort.name is "sort". +info: | + %SendableTypedArray%.prototype.sort ( comparefn ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.sort, "name", { + value: "sort", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/sort/not-a-constructor.js new file mode 100644 index 00000000000..535b1350b43 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.sort 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.sort), + false, + 'isConstructor(SendableTypedArray.prototype.sort) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.sort(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/sort/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/sort/prop-desc.js new file mode 100644 index 00000000000..76cdf0b51f3 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: > + "sort" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'sort', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/resizable-buffer-default-comparator.js b/test/sendable/builtins/TypedArray/prototype/sort/resizable-buffer-default-comparator.js new file mode 100644 index 00000000000..dab973cfeaa --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/resizable-buffer-default-comparator.js @@ -0,0 +1,194 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: > + SendableTypedArray.p.sort behaves correctly on SendableTypedArrays backed by resizable buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// This test cannot be reused between SendableTypedArray.protoype.sort and +// Array.prototype.sort, since the default sorting functions differ. + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const taFull = new ctor(rab, 0); + function WriteUnsortedData() { + // Write some data into the array. + for (let i = 0; i < taFull.length; ++i) { + taFull[i] = MayNeedBigInt(taFull, 10 - 2 * i); + } + } + // Orig. array: [10, 8, 6, 4] + // [10, 8, 6, 4] << fixedLength + // [6, 4] << fixedLengthWithOffset + // [10, 8, 6, 4, ...] << lengthTracking + // [6, 4, ...] << lengthTrackingWithOffset + + WriteUnsortedData(); + fixedLength.sort(); + assert.compareArray(ToNumbers(taFull), [ + 4, + 6, + 8, + 10 + ]); + WriteUnsortedData(); + fixedLengthWithOffset.sort(); + assert.compareArray(ToNumbers(taFull), [ + 10, + 8, + 4, + 6 + ]); + WriteUnsortedData(); + lengthTracking.sort(); + assert.compareArray(ToNumbers(taFull), [ + 4, + 6, + 8, + 10 + ]); + WriteUnsortedData(); + lengthTrackingWithOffset.sort(); + assert.compareArray(ToNumbers(taFull), [ + 10, + 8, + 4, + 6 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [10, 8, 6] + // [10, 8, 6, ...] << lengthTracking + // [6, ...] << lengthTrackingWithOffset + + WriteUnsortedData(); + assert.throws(TypeError, () => { + fixedLength.sort(); + }); + WriteUnsortedData(); + assert.throws(TypeError, () => { + fixedLengthWithOffset.sort(); + }); + WriteUnsortedData(); + lengthTracking.sort(); + assert.compareArray(ToNumbers(taFull), [ + 6, + 8, + 10 + ]); + WriteUnsortedData(); + lengthTrackingWithOffset.sort(); + assert.compareArray(ToNumbers(taFull), [ + 10, + 8, + 6 + ]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + WriteUnsortedData(); + assert.throws(TypeError, () => { + fixedLength.sort(); + }); + WriteUnsortedData(); + assert.throws(TypeError, () => { + fixedLengthWithOffset.sort(); + }); + WriteUnsortedData(); + lengthTracking.sort(); + assert.compareArray(ToNumbers(taFull), [10]); + WriteUnsortedData(); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.sort(); + }); + + // Shrink to zero. + rab.resize(0); + WriteUnsortedData(); + assert.throws(TypeError, () => { + fixedLength.sort(); + }); + WriteUnsortedData(); + assert.throws(TypeError, () => { + fixedLengthWithOffset.sort(); + }); + WriteUnsortedData(); + lengthTracking.sort(); + assert.compareArray(ToNumbers(taFull), []); + WriteUnsortedData(); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.sort(); + }); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [10, 8, 6, 4, 2, 0] + // [10, 8, 6, 4] << fixedLength + // [6, 4] << fixedLengthWithOffset + // [10, 8, 6, 4, 2, 0, ...] << lengthTracking + // [6, 4, 2, 0, ...] << lengthTrackingWithOffset + + WriteUnsortedData(); + fixedLength.sort(); + assert.compareArray(ToNumbers(taFull), [ + 4, + 6, + 8, + 10, + 2, + 0 + ]); + WriteUnsortedData(); + fixedLengthWithOffset.sort(); + assert.compareArray(ToNumbers(taFull), [ + 10, + 8, + 4, + 6, + 2, + 0 + ]); + WriteUnsortedData(); + lengthTracking.sort(); + assert.compareArray(ToNumbers(taFull), [ + 0, + 2, + 4, + 6, + 8, + 10 + ]); + WriteUnsortedData(); + lengthTrackingWithOffset.sort(); + assert.compareArray(ToNumbers(taFull), [ + 10, + 8, + 0, + 2, + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..99738f99176 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.sort, + 'function', + 'implements SendableTypedArray.prototype.sort' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.sort(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.sort(); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the sort operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.sort(); + throw new Test262Error('sort completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js b/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js new file mode 100644 index 00000000000..014b5ff8e4a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Returns the same instance +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + When the SendableTypedArray SortCompare abstract operation is called with two + arguments x and y, the following steps are taken: + + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([2, 1]); + var result = sample.sort(); + + assert.sameValue(sample, result, "without comparefn"); + + result = sample.sort(function() { return 0; }); + assert.sameValue(sample, result, "with comparefn"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js b/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js new file mode 100644 index 00000000000..b3865e9a6db --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: The result of compareFn is immediately passed through ToNumber +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + ... + 2. If comparefn is not undefined, then + a. Let v be ? ToNumber(? Call(comparefn, undefined, « x, y »)). + b. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var ta = new TA(4); + var ab = ta.buffer; + + var called = false; + ta.sort(function(a, b) { + // Detaching the buffer does not cause sort to throw. + $DETACHBUFFER(ab); + return { + [Symbol.toPrimitive]() { called = true; } + }; + }); + + assert.sameValue(true, called); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js b/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js new file mode 100644 index 00000000000..a8497c21381 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: SendableTypedArrays sort does not cast values to String +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + When the SendableTypedArray SortCompare abstract operation is called with two + arguments x and y, the following steps are taken: + + ... + 2. If the argument comparefn is not undefined, then + a. Let v be ? Call(comparefn, undefined, « x, y »). + ... + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +var toStringCalled = false; +Number.prototype.toString = function() { + toStringCalled = true; +} + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([20, 100, 3]); + var result = sample.sort(); + assert.sameValue(toStringCalled, false, "Number.prototype.toString will not be called"); + assert(compareArray(result, [3, 20, 100]), "Default sorting by value"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js new file mode 100644 index 00000000000..6e3da314cc0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Sort values to numeric ascending order +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + When the SendableTypedArray SortCompare abstract operation is called with two + arguments x and y, the following steps are taken: + + ... + + NOTE: Because NaN always compares greater than any other value, NaN property + values always sort to the end of the result when comparefn is not provided. +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([2, NaN, NaN, 0, 1]).sort(); + assert.sameValue(sample[0], 0, "#1 [0]"); + assert.sameValue(sample[1], 1, "#1 [1]"); + assert.sameValue(sample[2], 2, "#1 [2]"); + assert.sameValue(sample[3], NaN, "#1 [3]"); + assert.sameValue(sample[4], NaN, "#1 [4]"); + + sample = new TA([3, NaN, NaN, Infinity, 0, -Infinity, 2]).sort(); + assert.sameValue(sample[0], -Infinity, "#2 [0]"); + assert.sameValue(sample[1], 0, "#2 [1]"); + assert.sameValue(sample[2], 2, "#2 [2]"); + assert.sameValue(sample[3], 3, "#2 [3]"); + assert.sameValue(sample[4], Infinity, "#2 [4]"); + assert.sameValue(sample[5], NaN, "#2 [5]"); + assert.sameValue(sample[6], NaN, "#2 [6]"); +}, floatArrayConstructors); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js new file mode 100644 index 00000000000..121ca15d111 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Sort values to numeric ascending order +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + When the SendableTypedArray SortCompare abstract operation is called with two + arguments x and y, the following steps are taken: + + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([4, 3, 2, 1]).sort(); + assert(compareArray(sample, [1, 2, 3, 4]), "descending values"); + + sample = new TA([3, 4, 1, 2]).sort(); + assert(compareArray(sample, [1, 2, 3, 4]), "mixed numbers"); + + sample = new TA([3, 4, 3, 1, 0, 1, 2]).sort(); + assert(compareArray(sample, [0, 1, 1, 2, 3, 3, 4]), "repeating numbers"); +}); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1, 0, -0, 2]).sort(); + assert(compareArray(sample, [-0, 0, 1, 2]), "0s"); +}, floatArrayConstructors); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([1, 0, -0, 2]).sort(); + assert(compareArray(sample, [0, 0, 1, 2]), "0s"); +}, intArrayConstructors); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([-4, 3, 4, -3, 2, -2, 1, 0]).sort(); + assert(compareArray(sample, [-4, -3, -2, 0, 1, 2, 3, 4]), "negative values"); +}, floatArrayConstructors.concat([Int8Array, Int16Array, Int32Array])); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample; + + sample = new TA([0.5, 0, 1.5, 1]).sort(); + assert(compareArray(sample, [0, 0.5, 1, 1.5]), "non integers"); + + sample = new TA([0.5, 0, 1.5, -0.5, -1, -1.5, 1]).sort(); + assert(compareArray(sample, [-1.5, -1, -0.5, 0, 0.5, 1, 1.5]), "non integers + negatives"); + + sample = new TA([3, 4, Infinity, -Infinity, 1, 2]).sort(); + assert(compareArray(sample, [-Infinity, 1, 2, 3, 4, Infinity]), "infinities"); + +}, floatArrayConstructors); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/stability.js b/test/sendable/builtins/TypedArray/prototype/sort/stability.js new file mode 100644 index 00000000000..f9dbfaed88f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/stability.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Stability of %SendableTypedArray%.prototype.sort. +info: | + https://github.com/tc39/ecma262/pull/1433 +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +// Treat 0..3, 4..7, etc. as equal. +const compare = (a, b) => (a / 4 | 0) - (b / 4 | 0); + +testWithSendableTypedArrayConstructors((TA) => { + // Create an array of the form `[0, 1, …, 126, 127]`. + const array = Array.from({ length: 128 }, (_, i) => i); + + const typedArray1 = new TA(array); + assert(compareArray( + typedArray1.sort(compare), + array + ), 'pre-sorted'); + + // Reverse `array` in-place so it becomes `[127, 126, …, 1, 0]`. + array.reverse(); + + const typedArray2 = new TA(array); + assert(compareArray( + typedArray2.sort(compare), + [ + 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, + 15, 14, 13, 12, 19, 18, 17, 16, 23, 22, 21, 20, + 27, 26, 25, 24, 31, 30, 29, 28, 35, 34, 33, 32, + 39, 38, 37, 36, 43, 42, 41, 40, 47, 46, 45, 44, + 51, 50, 49, 48, 55, 54, 53, 52, 59, 58, 57, 56, + 63, 62, 61, 60, 67, 66, 65, 64, 71, 70, 69, 68, + 75, 74, 73, 72, 79, 78, 77, 76, 83, 82, 81, 80, + 87, 86, 85, 84, 91, 90, 89, 88, 95, 94, 93, 92, + 99, 98, 97, 96, 103, 102, 101, 100, 107, 106, 105, 104, + 111, 110, 109, 108, 115, 114, 113, 112, 119, 118, 117, 116, + 123, 122, 121, 120, 127, 126, 125, 124, + ] + ), 'not presorted'); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-object.js new file mode 100644 index 00000000000..42e5d9b9b2f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-object.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + 1. Let obj be the this value as the argument. + 2. Let buffer be ? ValidateSendableTypedArray(obj). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var sort = SendableTypedArray.prototype.sort; +var comparefn = function() {}; + +assert.throws(TypeError, function() { + sort.call(undefined, comparefn); +}, "this is undefined"); + +assert.throws(TypeError, function() { + sort.call(null, comparefn); +}, "this is null"); + +assert.throws(TypeError, function() { + sort.call(42, comparefn); +}, "this is 42"); + +assert.throws(TypeError, function() { + sort.call("1", comparefn); +}, "this is a string"); + +assert.throws(TypeError, function() { + sort.call(true, comparefn); +}, "this is true"); + +assert.throws(TypeError, function() { + sort.call(false, comparefn); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + sort.call(s, comparefn); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..0c0dcaeeda6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.sort +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) + + 1. Let obj be the this value as the argument. + 2. Let buffer be ? ValidateSendableTypedArray(obj). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var sort = SendableTypedArray.prototype.sort; +var comparefn = function() {}; + +assert.throws(TypeError, function() { + sort.call({}, comparefn); +}, "this is an Object"); + +assert.throws(TypeError, function() { + sort.call([], comparefn); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + sort.call(ab, comparefn); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + sort.call(dv, comparefn); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/detached-buffer.js new file mode 100644 index 00000000000..d5d441b2b44 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/detached-buffer.js @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Throws a TypeError creating a new instance with a detached buffer +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 7. Let relativeBegin be ? ToInteger(begin). + ... + 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd be + ? ToInteger(end). + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + ... + + 22.2.4.5 SendableTypedArray ( buffer [ , byteOffset [ , length ] ] ) + + ... + 11. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +var begin, end; + +var o1 = { + valueOf: function() { + begin = true; + return 0; + } +}; + +var o2 = { + valueOf: function() { + end = true; + return 2; + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + begin = false; + end = false; + + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.subarray(o1, o2); + }); + + assert(begin, "observable ToInteger(begin)"); + assert(end, "observable ToInteger(end)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/infinity.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/infinity.js new file mode 100644 index 00000000000..95b96db44fb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/infinity.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Infinity values on begin and end +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + assert( + compareArray(sample.subarray(-Infinity), [40n, 41n, 42n, 43n]), + "begin == -Infinity" + ); + assert( + compareArray(sample.subarray(Infinity), []), + "being == Infinity" + ); + assert( + compareArray(sample.subarray(0, -Infinity), []), + "end == -Infinity" + ); + assert( + compareArray(sample.subarray(0, Infinity), [40n, 41n, 42n, 43n]), + "end == Infinity" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/minus-zero.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/minus-zero.js new file mode 100644 index 00000000000..11b4ba88bba --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/minus-zero.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: -0 values on begin and end +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + assert( + compareArray(sample.subarray(-0), [40n, 41n, 42n, 43n]), + "begin == -0" + ); + assert( + compareArray(sample.subarray(-0, 4), [40n, 41n, 42n, 43n]), + "being == -0, end == length" + ); + assert( + compareArray(sample.subarray(0, -0), []), + "being == 0, end == -0" + ); + assert( + compareArray(sample.subarray(-0, -0), []), + "being == -0, end == -0" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js new file mode 100644 index 00000000000..62601427b5d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Subarray result does not import own property +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([41n, 42n, 43n, 44n]); + var result; + + sample.foo = 42; + + result = sample.subarray(0); + assert.sameValue( + result.hasOwnProperty("foo"), + false, + "does not import own property" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js new file mode 100644 index 00000000000..bc58fde3e6b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Returns a new instance from the same constructor +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + var result = sample.subarray(1); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "prototype" + ); + assert.sameValue(result.constructor, sample.constructor, "constructor"); + assert(result instanceof TA, "instanceof"); + + assert( + compareArray(sample, [40n, 41n, 42n, 43n]), + "original sample remains the same" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js new file mode 100644 index 00000000000..94301173131 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Returns a new instance sharing the same buffer +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + var buffer = sample.buffer; + var result = sample.subarray(1); + + assert.notSameValue(result, sample, "returns a new instance"); + assert.sameValue(result.buffer, sample.buffer, "shared buffer"); + assert.sameValue(sample.buffer, buffer, "original buffer is preserved"); + + sample[1] = 100n; + assert( + compareArray(result, [100n, 42n, 43n]), + "changes on the original sample values affect the new instance" + ); + + result[1] = 111n; + assert( + compareArray(sample, [40n, 100n, 111n, 43n]), + "changes on the new instance values affect the original sample" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js new file mode 100644 index 00000000000..edd700da11a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Subarray may return a new instance with a smaller length +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + function testRes(result, expected, msg) { + assert(compareArray(result, expected), msg + ", result: [" + result + "]"); + } + + testRes(sample.subarray(1), [41n, 42n, 43n], "begin == 1"); + testRes(sample.subarray(2), [42n, 43n], "begin == 2"); + testRes(sample.subarray(3), [43n], "begin == 3"); + + testRes(sample.subarray(1, 4), [41n, 42n, 43n], "begin == 1, end == length"); + testRes(sample.subarray(2, 4), [42n, 43n], "begin == 2, end == length"); + testRes(sample.subarray(3, 4), [43n], "begin == 3, end == length"); + + testRes(sample.subarray(0, 1), [40n], "begin == 0, end == 1"); + testRes(sample.subarray(0, 2), [40n, 41n], "begin == 0, end == 2"); + testRes(sample.subarray(0, 3), [40n, 41n, 42n], "begin == 0, end == 3"); + + testRes(sample.subarray(-1), [43n], "begin == -1"); + testRes(sample.subarray(-2), [42n, 43n], "begin == -2"); + testRes(sample.subarray(-3), [41n, 42n, 43n], "begin == -3"); + + testRes(sample.subarray(-1, 4), [43n], "begin == -1, end == length"); + testRes(sample.subarray(-2, 4), [42n, 43n], "begin == -2, end == length"); + testRes(sample.subarray(-3, 4), [41n, 42n, 43n], "begin == -3, end == length"); + + testRes(sample.subarray(0, -1), [40n, 41n, 42n], "begin == 0, end == -1"); + testRes(sample.subarray(0, -2), [40n, 41n], "begin == 0, end == -2"); + testRes(sample.subarray(0, -3), [40n], "begin == 0, end == -3"); + + testRes(sample.subarray(-0, -1), [40n, 41n, 42n], "begin == -0, end == -1"); + testRes(sample.subarray(-0, -2), [40n, 41n], "begin == -0, end == -2"); + testRes(sample.subarray(-0, -3), [40n], "begin == -0, end == -3"); + + testRes(sample.subarray(-2, -1), [42n], "length == 4, begin == -2, end == -1"); + testRes(sample.subarray(1, -1), [41n, 42n], "length == 4, begin == 1, end == -1"); + testRes(sample.subarray(1, -2), [41n], "length == 4, begin == 1, end == -2"); + testRes(sample.subarray(2, -1), [42n], "length == 4, begin == 2, end == -1"); + + testRes(sample.subarray(-1, 5), [43n], "begin == -1, end > length"); + testRes(sample.subarray(-2, 4), [42n, 43n], "begin == -2, end > length"); + testRes(sample.subarray(-3, 4), [41n, 42n, 43n], "begin == -3, end > length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js new file mode 100644 index 00000000000..a1df6689315 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Subarray may return a new empty instance +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + function testRes(result, msg) { + assert.sameValue(result.length, 0, msg); + assert.sameValue( + result.hasOwnProperty(0), + false, + msg + " & result.hasOwnProperty(0) === false" + ); + } + + testRes(sample.subarray(4), "begin == length"); + testRes(sample.subarray(5), "begin > length"); + + testRes(sample.subarray(4, 4), "begin == length, end == length"); + testRes(sample.subarray(5, 4), "begin > length, end == length"); + + testRes(sample.subarray(4, 4), "begin == length, end > length"); + testRes(sample.subarray(5, 4), "begin > length, end > length"); + + testRes(sample.subarray(0, 0), "begin == 0, end == 0"); + testRes(sample.subarray(-0, -0), "begin == -0, end == -0"); + testRes(sample.subarray(1, 0), "begin > 0, end == 0"); + testRes(sample.subarray(-1, 0), "being < 0, end == 0"); + + testRes(sample.subarray(2, 1), "begin > 0, begin < length, begin > end, end > 0"); + testRes(sample.subarray(2, 2), "begin > 0, begin < length, begin == end"); + + testRes(sample.subarray(2, -2), "begin > 0, begin < length, end == -2"); + + testRes(sample.subarray(-1, -1), "length = 4, begin == -1, end == -1"); + testRes(sample.subarray(-1, -2), "length = 4, begin == -1, end == -2"); + testRes(sample.subarray(-2, -2), "length = 4, begin == -2, end == -2"); + + testRes(sample.subarray(0, -4), "begin == 0, end == -length"); + testRes(sample.subarray(-4, -4), "begin == -length, end == -length"); + testRes(sample.subarray(-5, -4), "begin < -length, end == -length"); + + testRes(sample.subarray(0, -5), "begin == 0, end < -length"); + testRes(sample.subarray(-4, -5), "begin == -length, end < -length"); + testRes(sample.subarray(-5, -5), "begin < -length, end < -length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js new file mode 100644 index 00000000000..7474b5d0a77 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Subarray may return a new instance with the same length +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + function testRes(result, msg) { + assert.sameValue(result.length, 4, msg); + assert.sameValue(result[0], 40n, msg + " & result[0] === 40"); + assert.sameValue(result[1], 41n, msg + " & result[1] === 41"); + assert.sameValue(result[2], 42n, msg + " & result[2] === 42"); + assert.sameValue(result[3], 43n, msg + " & result[3] === 43"); + } + + testRes(sample.subarray(0), "begin == 0"); + testRes(sample.subarray(-4), "begin == -srcLength"); + testRes(sample.subarray(-5), "begin < -srcLength"); + + testRes(sample.subarray(0, 4), "begin == 0, end == srcLength"); + testRes(sample.subarray(-4, 4), "begin == -srcLength, end == srcLength"); + testRes(sample.subarray(-5, 4), "begin < -srcLength, end == srcLength"); + + testRes(sample.subarray(0, 5), "begin == 0, end > srcLength"); + testRes(sample.subarray(-4, 5), "begin == -srcLength, end > srcLength"); + testRes(sample.subarray(-5, 5), "begin < -srcLength, end > srcLength"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js new file mode 100644 index 00000000000..56770074da9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Return abrupt from ToInteger(begin), begin is symbol +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 7. Let relativeBegin be ? ToInteger(begin). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.subarray(s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js new file mode 100644 index 00000000000..776d35fd739 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Return abrupt from ToInteger(begin) +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 7. Let relativeBegin be ? ToInteger(begin). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var o1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var o2 = { + toString: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(Test262Error, function() { + sample.subarray(o1); + }); + + assert.throws(Test262Error, function() { + sample.subarray(o2); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js new file mode 100644 index 00000000000..8df68dbf589 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Return abrupt from ToInteger(end), end is symbol +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd + be ? ToInteger(end). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.subarray(0, s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js new file mode 100644 index 00000000000..6a44999b476 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Return abrupt from ToInteger(end) +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd + be ? ToInteger(end). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var o1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var o2 = { + toString: function() { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(Test262Error, function() { + sample.subarray(0, o1); + }); + + assert.throws(Test262Error, function() { + sample.subarray(0, o2); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js new file mode 100644 index 00000000000..6026900a439 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Return abrupt from SpeciesConstructor's get Constructor +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + Object.defineProperty(sample, "constructor", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.subarray(0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js new file mode 100644 index 00000000000..9026b018d29 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: get inherited constructor on SpeciesConstructor +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + var calls = 0; + var result; + + Object.defineProperty(TA.prototype, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.subarray(0); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + undefined, + "used defaultCtor but still checks the inherited .constructor" + ); + + calls = 6; + result.constructor; + assert.sameValue( + calls, + 7, + "result.constructor triggers the inherited accessor property" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js new file mode 100644 index 00000000000..6b1e5c5f4c7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Throws if O.constructor returns a non-Object and non-undefined value +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + 4. If Type(C) is not Object, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + sample.constructor = 42; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "42"); + + sample.constructor = "1"; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "string"); + + sample.constructor = null; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "null"); + + sample.constructor = NaN; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "NaN"); + + sample.constructor = false; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "false"); + + sample.constructor = Symbol("1"); + assert.throws(TypeError, function() { + sample.subarray(0); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js new file mode 100644 index 00000000000..d1e7f8fd797 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: get constructor on SpeciesConstructor +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + var calls = 0; + var result; + + Object.defineProperty(sample, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.subarray(0); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + TA, + "use defaultCtor on an undefined return - .constructor check" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js new file mode 100644 index 00000000000..ff6b7b7b965 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Returns abrupt from get @@species on found constructor +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.subarray(0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js new file mode 100644 index 00000000000..be848e33974 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Verify arguments on custom @@species construct call +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n]); + var expectedOffset = TA.BYTES_PER_ELEMENT; + var result, ctorThis; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(buffer, offset, length) { + result = arguments; + ctorThis = this; + return new TA(buffer, offset, length); + }; + + sample.subarray(1); + + assert.sameValue(result.length, 3, "called with 3 arguments"); + assert.sameValue(result[0], sample.buffer, "[0] is sample.buffer"); + assert.sameValue(result[1], expectedOffset, "[1] is the byte offset pos"); + assert.sameValue(result[2], 2, "[2] is expected length"); + + assert( + ctorThis instanceof sample.constructor[Symbol.species], + "`this` value in the @@species fn is an instance of the function itself" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js new file mode 100644 index 00000000000..63c9562a718 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Custom @@species constructor may return a totally different SendableTypedArray +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n]); + var other = new BigInt64Array([1n, 0n, 1n]); + var result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return other; + }; + + result = sample.subarray(0, 0); + + assert.sameValue(result, other, "returned another typedarray"); + assert(compareArray(result, [1n, 0n, 1n]), "the returned object is preserved"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js new file mode 100644 index 00000000000..e22c76cd56c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Custom @@species constructor throws if it does not return a compatible object +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var ctor = function() {}; + + sample.constructor = {}; + sample.constructor[Symbol.species] = ctor; + + assert.throws(TypeError, function() { + sample.subarray(0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js new file mode 100644 index 00000000000..c356b3dadaf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Use custom @@species constructor if available +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n]); + var calls = 0; + var result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(buffer, offset, length) { + calls++; + return new TA(buffer, offset, length); + }; + + result = sample.subarray(1); + + assert.sameValue(calls, 1, "ctor called once"); + assert(compareArray(result, [41n, 42n]), "expected subarray"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js new file mode 100644 index 00000000000..5797ce67cf7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Throws if returned @@species is not a constructor, null or undefined. +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + 7. If IsConstructor(S) is true, return S. + 8. Throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + sample.constructor[Symbol.species] = 0; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "0"); + + sample.constructor[Symbol.species] = "string"; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "string"); + + sample.constructor[Symbol.species] = {}; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "{}"); + + sample.constructor[Symbol.species] = NaN; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "NaN"); + + sample.constructor[Symbol.species] = false; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "false"); + + sample.constructor[Symbol.species] = true; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "true"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js new file mode 100644 index 00000000000..4c42525d47f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Use defaultConstructor if @@species is either undefined or null +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var result; + + sample.constructor = {}; + + result = sample.subarray(0); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "undefined @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "undefined @@species - ctor check"); + + sample.constructor[Symbol.species] = null; + result = sample.subarray(0); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "null @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "null @@species - ctor check"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js new file mode 100644 index 00000000000..2106005b8c9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + get @@species from found constructor +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.species, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var calls = 0; + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + calls++; + } + }); + + sample.subarray(0); + + assert.sameValue(calls, 1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js new file mode 100644 index 00000000000..109f308edaf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: ToInteger(begin) +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 7. Let relativeBegin be ? ToInteger(begin). + ... +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj = { + valueOf: function() { + return 2; + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + assert(compareArray(sample.subarray(false), [40n, 41n, 42n, 43n]), "false"); + assert(compareArray(sample.subarray(true), [41n, 42n, 43n]), "true"); + + assert(compareArray(sample.subarray(NaN), [40n, 41n, 42n, 43n]), "NaN"); + assert(compareArray(sample.subarray(null), [40n, 41n, 42n, 43n]), "null"); + assert(compareArray(sample.subarray(undefined), [40n, 41n, 42n, 43n]), "undefined"); + + assert(compareArray(sample.subarray(1.1), [41n, 42n, 43n]), "1.1"); + assert(compareArray(sample.subarray(1.5), [41n, 42n, 43n]), "1.5"); + assert(compareArray(sample.subarray(0.6), [40n, 41n, 42n, 43n]), "0.6"); + + assert(compareArray(sample.subarray(-1.5), [43n]), "-1.5"); + assert(compareArray(sample.subarray(-1.1), [43n]), "-1.1"); + assert(compareArray(sample.subarray(-0.6), [40n, 41n, 42n, 43n]), "-0.6"); + + assert(compareArray(sample.subarray("3"), [43n]), "string"); + assert( + compareArray( + sample.subarray(obj), + [42n, 43n] + ), + "object" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-end.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-end.js new file mode 100644 index 00000000000..d3edc71b7de --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-end.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: ToInteger(end) +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd be + ? ToInteger(end). + ... +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +var obj = { + valueOf: function() { + return 2; + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40n, 41n, 42n, 43n]); + + assert(compareArray(sample.subarray(0, false), []), "false"); + assert(compareArray(sample.subarray(0, true), [40n]), "true"); + + assert(compareArray(sample.subarray(0, NaN), []), "NaN"); + assert(compareArray(sample.subarray(0, null), []), "null"); + assert(compareArray(sample.subarray(0, undefined), [40n, 41n, 42n, 43n]), "undefined"); + + assert(compareArray(sample.subarray(0, 0.6), []), "0.6"); + assert(compareArray(sample.subarray(0, 1.1), [40n]), "1.1"); + assert(compareArray(sample.subarray(0, 1.5), [40n]), "1.5"); + assert(compareArray(sample.subarray(0, -0.6), []), "-0.6"); + assert(compareArray(sample.subarray(0, -1.1), [40n, 41n, 42n]), "-1.1"); + assert(compareArray(sample.subarray(0, -1.5), [40n, 41n, 42n]), "-1.5"); + + assert(compareArray(sample.subarray(0, "3"), [40n, 41n, 42n]), "string"); + assert( + compareArray( + sample.subarray(0, obj), + [40n, 41n] + ), + "object" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-grow.js b/test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-grow.js new file mode 100644 index 00000000000..c3510b04eaf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-grow.js @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + SendableTypedArray.p.subarray behaves correctly on SendableTypedArrays backed by resizable + buffers that are grown by argument coercion. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [0, 2, 4, 6, ...] << lengthTracking + +// Growing a fixed length TA back in bounds. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + // Make `fixedLength` OOB. + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + const evil = { + valueOf: () => { + rab.resize(4 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + // The length computation is done before parameter conversion. At that + // point, the length is 0, since the TA is OOB. + assert.compareArray(ToNumbers(fixedLength.subarray(evil, 1)), []); +} + +// As above but with the second parameter conversion growing the buffer. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + // Make `fixedLength` OOB. + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + const evil = { + valueOf: () => { + rab.resize(4 * ctor.BYTES_PER_ELEMENT); + return 1; + } + }; + // The length computation is done before parameter conversion. At that + // point, the length is 0, since the TA is OOB. + assert.compareArray(ToNumbers(fixedLength.subarray(0, evil)), []); +} + + +// Growing + fixed-length TA. Growing won't affect anything. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert.compareArray(ToNumbers(fixedLength.subarray(evil)), [ + 0, + 2, + 4, + 6 + ]); +} + +// As above but with the second parameter conversion growing the buffer. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return 4; + } + }; + assert.compareArray(ToNumbers(fixedLength.subarray(0, evil)), [ + 0, + 2, + 4, + 6 + ]); +} + +// Growing + length-tracking TA. The length computation is done with the +// original length. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + const evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert.compareArray( + ToNumbers(lengthTracking.subarray(evil, lengthTracking.length)), [ + 0, + 2, + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-shrink.js b/test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-shrink.js new file mode 100644 index 00000000000..e0674c08e16 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-shrink.js @@ -0,0 +1,204 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + SendableTypedArray.p.subarray behaves correctly on SendableTypedArrays backed by resizable + buffers that are shrunk by argument coercion. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [0, 2, 4, 6, ...] << lengthTracking + + +// Fixed-length TA + first parameter conversion shrinks. The old length is +// used in the length computation, and the subarray construction fails. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert.throws(RangeError, () => { + fixedLength.subarray(evil); + }); +} + +// Like the previous test, but now we construct a smaller subarray and it +// succeeds. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert.compareArray(ToNumbers(fixedLength.subarray(evil, 1)), [0]); +} + +// As above but with the second parameter conversion shrinking the buffer. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 1; + } + }; + assert.compareArray(ToNumbers(fixedLength.subarray(0,evil)), [0]); +} + +// Fixed-length TA + second parameter conversion shrinks. The old length is +// used in the length computation, and the subarray construction fails. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 3; + } + }; + assert.throws(RangeError, () => { + fixedLength.subarray(0, evil); + }); +} + +// Like the previous test, but now we construct a smaller subarray and it +// succeeds. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 1; + } + }; + assert.compareArray(ToNumbers(fixedLength.subarray(0, evil)), [0]); +} + +// Shrinking + fixed-length TA, subarray construction succeeds even though the +// TA goes OOB. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert.compareArray(ToNumbers(fixedLength.subarray(evil, 1)), [0]); +} + +// As above but with the second parameter conversion shrinking the buffer. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 1; + } + }; + assert.compareArray(ToNumbers(fixedLength.subarray(0,evil)), [0]); +} + +// Length-tracking TA + first parameter conversion shrinks. The old length is +// used in the length computation, and the subarray construction fails. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert.throws(RangeError, () => { + lengthTracking.subarray(evil, lengthTracking.length); + }); +} + +// Like the previous test, but now we construct a smaller subarray and it +// succeeds. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert.compareArray(ToNumbers(lengthTracking.subarray(evil, 1)), [0]); +} + +// As above but with the second parameter conversion shrinking the buffer. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 1; + } + }; + assert.compareArray(ToNumbers(lengthTracking.subarray(0,evil)), [0]); +} + +// Length-tracking TA + first parameter conversion shrinks. The second +// parameter is negative -> the relative index is not recomputed, and the +// subarray construction fails. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert.throws(RangeError, () => { + lengthTracking.subarray(evil, -1); + }); +} + +// Length-tracking TA + second parameter conversion shrinks. The second +// parameter is too large -> the subarray construction fails. +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab); + let evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 3; + } + }; + assert.throws(RangeError, () => { + lengthTracking.subarray(0, evil); + }); +} diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js new file mode 100644 index 00000000000..55abecfe385 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Throws a TypeError creating a new instance with a detached buffer +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 7. Let relativeBegin be ? ToInteger(begin). + ... + 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd be + ? ToInteger(end). + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + ... + + 22.2.4.5 SendableTypedArray ( buffer [ , byteOffset [ , length ] ] ) + + ... + 11. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +var begin, end; + +var o1 = { + valueOf: function() { + begin = true; + return 0; + } +}; + +var o2 = { + valueOf: function() { + end = true; + return 2; + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + begin = false; + end = false; + + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.subarray(o1, o2); + }); + + assert(begin, "observable ToInteger(begin)"); + assert(end, "observable ToInteger(end)"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js b/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js new file mode 100644 index 00000000000..8a9c56b11ea --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Infinity values on begin and end +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + assert( + compareArray(sample.subarray(-Infinity), [40, 41, 42, 43]), + "begin == -Infinity" + ); + assert( + compareArray(sample.subarray(Infinity), []), + "being == Infinity" + ); + assert( + compareArray(sample.subarray(0, -Infinity), []), + "end == -Infinity" + ); + assert( + compareArray(sample.subarray(0, Infinity), [40, 41, 42, 43]), + "end == Infinity" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-func.js new file mode 100644 index 00000000000..c57731ba007 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-func.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.26 %SendableTypedArray%.prototype.subarray( [ begin [ , end ] ] ) + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var subarray = SendableTypedArray.prototype.subarray; + +assert.sameValue(typeof subarray, 'function'); + +assert.throws(TypeError, function() { + subarray(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-method.js new file mode 100644 index 00000000000..bf5fb848f16 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-method.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.26 %SendableTypedArray%.prototype.subarray( [ begin [ , end ] ] ) + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.subarray, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.subarray(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/length.js b/test/sendable/builtins/TypedArray/prototype/subarray/length.js new file mode 100644 index 00000000000..89c5e0e299b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + %SendableTypedArray%.prototype.subarray.length is 2. +info: | + %SendableTypedArray%.prototype.subarray( [ begin [ , end ] ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.subarray, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js b/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js new file mode 100644 index 00000000000..d01db124860 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: -0 values on begin and end +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + assert( + compareArray(sample.subarray(-0), [40, 41, 42, 43]), + "begin == -0" + ); + assert( + compareArray(sample.subarray(-0, 4), [40, 41, 42, 43]), + "being == -0, end == length" + ); + assert( + compareArray(sample.subarray(0, -0), []), + "being == 0, end == -0" + ); + assert( + compareArray(sample.subarray(-0, -0), []), + "being == -0, end == -0" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/name.js b/test/sendable/builtins/TypedArray/prototype/subarray/name.js new file mode 100644 index 00000000000..f57644751c9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + %SendableTypedArray%.prototype.subarray.name is "subarray". +info: | + %SendableTypedArray%.prototype.subarray( [ begin [ , end ] ] ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.subarray, "name", { + value: "subarray", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/subarray/not-a-constructor.js new file mode 100644 index 00000000000..1ca3a1d13b4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.subarray 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.subarray), + false, + 'isConstructor(SendableTypedArray.prototype.subarray) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.subarray(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/subarray/prop-desc.js new file mode 100644 index 00000000000..99693267287 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + "subarray" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'subarray', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/resizable-buffer.js new file mode 100644 index 00000000000..d2049de41bb --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/resizable-buffer.js @@ -0,0 +1,184 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + SendableTypedArray.p.subarray behaves correctly on SendableTypedArrays backed by resizable + buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + const fixedLengthSubFull = fixedLength.subarray(0); + assert.compareArray(ToNumbers(fixedLengthSubFull), [ + 0, + 2, + 4, + 6 + ]); + const fixedLengthWithOffsetSubFull = fixedLengthWithOffset.subarray(0); + assert.compareArray(ToNumbers(fixedLengthWithOffsetSubFull), [ + 4, + 6 + ]); + const lengthTrackingSubFull = lengthTracking.subarray(0); + assert.compareArray(ToNumbers(lengthTrackingSubFull), [ + 0, + 2, + 4, + 6 + ]); + const lengthTrackingWithOffsetSubFull = lengthTrackingWithOffset.subarray(0); + assert.compareArray(ToNumbers(lengthTrackingWithOffsetSubFull), [ + 4, + 6 + ]); + + // Relative offsets + assert.compareArray(ToNumbers(fixedLength.subarray(-2)), [ + 4, + 6 + ]); + assert.compareArray(ToNumbers(fixedLengthWithOffset.subarray(-1)), [6]); + assert.compareArray(ToNumbers(lengthTracking.subarray(-2)), [ + 4, + 6 + ]); + assert.compareArray(ToNumbers(lengthTrackingWithOffset.subarray(-1)), [6]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + // We can create subarrays of OOB arrays (which have length 0), as long as + // the new arrays are not OOB. + assert.compareArray(ToNumbers(fixedLength.subarray(0)), []); + assert.compareArray(ToNumbers(fixedLengthWithOffset.subarray(0)), []); + assert.compareArray(ToNumbers(lengthTracking.subarray(0)), [ + 0, + 2, + 4 + ]); + assert.compareArray(ToNumbers(lengthTrackingWithOffset.subarray(0)), [4]); + + // Also the previously created subarrays are OOB. + assert.sameValue(fixedLengthSubFull.length, 0); + assert.sameValue(fixedLengthWithOffsetSubFull.length, 0); + + // Relative offsets + assert.compareArray(ToNumbers(lengthTracking.subarray(-2)), [ + 2, + 4 + ]); + assert.compareArray(ToNumbers(lengthTrackingWithOffset.subarray(-1)), [4]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.compareArray(ToNumbers(fixedLength.subarray(0)), []); + assert.compareArray(ToNumbers(lengthTracking.subarray(0)), [0]); + + // Even the 0-length subarray of fixedLengthWithOffset would be OOB -> + // this throws. + assert.throws(RangeError, () => { + fixedLengthWithOffset.subarray(0); + }); + + // Also the previously created subarrays are OOB. + assert.sameValue(fixedLengthSubFull.length, 0); + assert.sameValue(fixedLengthWithOffsetSubFull.length, 0); + assert.sameValue(lengthTrackingWithOffsetSubFull.length, 0); + + // Shrink to zero. + rab.resize(0); + assert.compareArray(ToNumbers(fixedLength.subarray(0)), []); + assert.compareArray(ToNumbers(lengthTracking.subarray(0)), []); + assert.throws(RangeError, () => { + fixedLengthWithOffset.subarray(0); + }); + assert.throws(RangeError, () => { + lengthTrackingWithOffset.subarray(0); + }); + + // Also the previously created subarrays are OOB. + assert.sameValue(fixedLengthSubFull.length, 0); + assert.sameValue(fixedLengthWithOffsetSubFull.length, 0); + assert.sameValue(lengthTrackingWithOffsetSubFull.length, 0); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert.compareArray(ToNumbers(fixedLength.subarray(0)), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ToNumbers(fixedLengthWithOffset.subarray(0)), [ + 4, + 6 + ]); + assert.compareArray(ToNumbers(lengthTracking.subarray(0)), [ + 0, + 2, + 4, + 6, + 8, + 10 + ]); + assert.compareArray(ToNumbers(lengthTrackingWithOffset.subarray(0)), [ + 4, + 6, + 8, + 10 + ]); + + // Also the previously created subarrays are no longer OOB. + assert.sameValue(fixedLengthSubFull.length, 4); + assert.sameValue(fixedLengthWithOffsetSubFull.length, 2); + // Subarrays of length-tracking TAs are also length-tracking. + assert.sameValue(lengthTrackingSubFull.length, 6); + assert.sameValue(lengthTrackingWithOffsetSubFull.length, 4); +} diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js new file mode 100644 index 00000000000..277d58b41a1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Result has the correct byteOffset when input is initially out-of-bounds. +info: | + %SendableTypedArray%.prototype.subarray ( start, end ) + + ... + 13. Let srcByteOffset be O.[[ByteOffset]]. + 14. Let beginByteOffset be srcByteOffset + (startIndex × elementSize). + 15. If O.[[ArrayLength]] is auto and end is undefined, then + a. Let argumentsList be « buffer, 𝔽(beginByteOffset) ». + 16. + ... + e. Let newLength be max(endIndex - startIndex, 0). + f. Let argumentsList be « buffer, 𝔽(beginByteOffset), 𝔽(newLength) ». + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(10, {maxByteLength: 10}); + +let autoLength = new Int8Array(rab, 4); +let withLength = new Int8Array(rab, 4, 2); + +let start = { + valueOf() { + // Make |autoLength| and |withLength| in-bounds again. + rab.resize(10); + return 1; + } +}; + +// Make |autoLength| out-of-bounds. +rab.resize(0); + +let resultAutoLength = autoLength.subarray(start); +assert.sameValue(resultAutoLength.byteOffset, 4); +assert.sameValue(resultAutoLength.length, 6); + +// Make |withLength| out-of-bounds. +rab.resize(0); + +let resultWithLength = withLength.subarray(start); +assert.sameValue(resultWithLength.byteOffset, 4); +assert.sameValue(resultWithLength.length, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js new file mode 100644 index 00000000000..3cf858d7c82 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Subarray result does not import own property +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([41, 42, 43, 44]); + var result; + + sample.foo = 42; + + result = sample.subarray(0); + assert.sameValue( + result.hasOwnProperty("foo"), + false, + "does not import own property" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js new file mode 100644 index 00000000000..cd8fdcddcbf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Returns a new instance from the same constructor +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + var result = sample.subarray(1); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "prototype" + ); + assert.sameValue(result.constructor, sample.constructor, "constructor"); + assert(result instanceof TA, "instanceof"); + + assert( + compareArray(sample, [40, 41, 42, 43]), + "original sample remains the same" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js new file mode 100644 index 00000000000..3b0aaa33da4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Returns a new instance sharing the same buffer +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + var buffer = sample.buffer; + var result = sample.subarray(1); + + assert.notSameValue(result, sample, "returns a new instance"); + assert.sameValue(result.buffer, sample.buffer, "shared buffer"); + assert.sameValue(sample.buffer, buffer, "original buffer is preserved"); + + sample[1] = 100; + assert( + compareArray(result, [100, 42, 43]), + "changes on the original sample values affect the new instance" + ); + + result[1] = 111; + assert( + compareArray(sample, [40, 100, 111, 43]), + "changes on the new instance values affect the original sample" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js new file mode 100644 index 00000000000..1b4a4df0789 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Subarray may return a new instance with a smaller length +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + function testRes(result, expected, msg) { + assert(compareArray(result, expected), msg + ", result: [" + result + "]"); + } + + testRes(sample.subarray(1), [41, 42, 43], "begin == 1"); + testRes(sample.subarray(2), [42, 43], "begin == 2"); + testRes(sample.subarray(3), [43], "begin == 3"); + + testRes(sample.subarray(1, 4), [41, 42, 43], "begin == 1, end == length"); + testRes(sample.subarray(2, 4), [42, 43], "begin == 2, end == length"); + testRes(sample.subarray(3, 4), [43], "begin == 3, end == length"); + + testRes(sample.subarray(0, 1), [40], "begin == 0, end == 1"); + testRes(sample.subarray(0, 2), [40, 41], "begin == 0, end == 2"); + testRes(sample.subarray(0, 3), [40, 41, 42], "begin == 0, end == 3"); + + testRes(sample.subarray(-1), [43], "begin == -1"); + testRes(sample.subarray(-2), [42, 43], "begin == -2"); + testRes(sample.subarray(-3), [41, 42, 43], "begin == -3"); + + testRes(sample.subarray(-1, 4), [43], "begin == -1, end == length"); + testRes(sample.subarray(-2, 4), [42, 43], "begin == -2, end == length"); + testRes(sample.subarray(-3, 4), [41, 42, 43], "begin == -3, end == length"); + + testRes(sample.subarray(0, -1), [40, 41, 42], "begin == 0, end == -1"); + testRes(sample.subarray(0, -2), [40, 41], "begin == 0, end == -2"); + testRes(sample.subarray(0, -3), [40], "begin == 0, end == -3"); + + testRes(sample.subarray(-0, -1), [40, 41, 42], "begin == -0, end == -1"); + testRes(sample.subarray(-0, -2), [40, 41], "begin == -0, end == -2"); + testRes(sample.subarray(-0, -3), [40], "begin == -0, end == -3"); + + testRes(sample.subarray(-2, -1), [42], "length == 4, begin == -2, end == -1"); + testRes(sample.subarray(1, -1), [41, 42], "length == 4, begin == 1, end == -1"); + testRes(sample.subarray(1, -2), [41], "length == 4, begin == 1, end == -2"); + testRes(sample.subarray(2, -1), [42], "length == 4, begin == 2, end == -1"); + + testRes(sample.subarray(-1, 5), [43], "begin == -1, end > length"); + testRes(sample.subarray(-2, 4), [42, 43], "begin == -2, end > length"); + testRes(sample.subarray(-3, 4), [41, 42, 43], "begin == -3, end > length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js new file mode 100644 index 00000000000..47ef57488ec --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Subarray may return a new empty instance +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + function testRes(result, msg) { + assert.sameValue(result.length, 0, msg); + assert.sameValue( + result.hasOwnProperty(0), + false, + msg + " & result.hasOwnProperty(0) === false" + ); + } + + testRes(sample.subarray(4), "begin == length"); + testRes(sample.subarray(5), "begin > length"); + + testRes(sample.subarray(4, 4), "begin == length, end == length"); + testRes(sample.subarray(5, 4), "begin > length, end == length"); + + testRes(sample.subarray(4, 4), "begin == length, end > length"); + testRes(sample.subarray(5, 4), "begin > length, end > length"); + + testRes(sample.subarray(0, 0), "begin == 0, end == 0"); + testRes(sample.subarray(-0, -0), "begin == -0, end == -0"); + testRes(sample.subarray(1, 0), "begin > 0, end == 0"); + testRes(sample.subarray(-1, 0), "being < 0, end == 0"); + + testRes(sample.subarray(2, 1), "begin > 0, begin < length, begin > end, end > 0"); + testRes(sample.subarray(2, 2), "begin > 0, begin < length, begin == end"); + + testRes(sample.subarray(2, -2), "begin > 0, begin < length, end == -2"); + + testRes(sample.subarray(-1, -1), "length = 4, begin == -1, end == -1"); + testRes(sample.subarray(-1, -2), "length = 4, begin == -1, end == -2"); + testRes(sample.subarray(-2, -2), "length = 4, begin == -2, end == -2"); + + testRes(sample.subarray(0, -4), "begin == 0, end == -length"); + testRes(sample.subarray(-4, -4), "begin == -length, end == -length"); + testRes(sample.subarray(-5, -4), "begin < -length, end == -length"); + + testRes(sample.subarray(0, -5), "begin == 0, end < -length"); + testRes(sample.subarray(-4, -5), "begin == -length, end < -length"); + testRes(sample.subarray(-5, -5), "begin < -length, end < -length"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js new file mode 100644 index 00000000000..bf812a4aa1d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Subarray may return a new instance with the same length +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + function testRes(result, msg) { + assert.sameValue(result.length, 4, msg); + assert.sameValue(result[0], 40, msg + " & result[0] === 40"); + assert.sameValue(result[1], 41, msg + " & result[1] === 41"); + assert.sameValue(result[2], 42, msg + " & result[2] === 42"); + assert.sameValue(result[3], 43, msg + " & result[3] === 43"); + } + + testRes(sample.subarray(0), "begin == 0"); + testRes(sample.subarray(-4), "begin == -srcLength"); + testRes(sample.subarray(-5), "begin < -srcLength"); + + testRes(sample.subarray(0, 4), "begin == 0, end == srcLength"); + testRes(sample.subarray(-4, 4), "begin == -srcLength, end == srcLength"); + testRes(sample.subarray(-5, 4), "begin < -srcLength, end == srcLength"); + + testRes(sample.subarray(0, 5), "begin == 0, end > srcLength"); + testRes(sample.subarray(-4, 5), "begin == -srcLength, end > srcLength"); + testRes(sample.subarray(-5, 5), "begin < -srcLength, end > srcLength"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js new file mode 100644 index 00000000000..c32feae168b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Return abrupt from ToInteger(begin), begin is symbol +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 7. Let relativeBegin be ? ToInteger(begin). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.subarray(s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js new file mode 100644 index 00000000000..045b88b83cc --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Return abrupt from ToInteger(begin) +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 7. Let relativeBegin be ? ToInteger(begin). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var o1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var o2 = { + toString: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(Test262Error, function() { + sample.subarray(o1); + }); + + assert.throws(Test262Error, function() { + sample.subarray(o2); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js new file mode 100644 index 00000000000..d63c2c817bd --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Return abrupt from ToInteger(end), end is symbol +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd + be ? ToInteger(end). + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var s = Symbol("1"); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(TypeError, function() { + sample.subarray(0, s); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js new file mode 100644 index 00000000000..6d2d99d1882 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Return abrupt from ToInteger(end) +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd + be ? ToInteger(end). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var o1 = { + valueOf: function() { + throw new Test262Error(); + } +}; + +var o2 = { + toString: function() { + throw new Test262Error(); + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + + assert.throws(Test262Error, function() { + sample.subarray(0, o1); + }); + + assert.throws(Test262Error, function() { + sample.subarray(0, o2); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js new file mode 100644 index 00000000000..d667ce49a5f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Return abrupt from SpeciesConstructor's get Constructor +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + Object.defineProperty(sample, "constructor", { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.subarray(0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js new file mode 100644 index 00000000000..1b95ab71bd9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: get inherited constructor on SpeciesConstructor +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + var calls = 0; + var result; + + Object.defineProperty(TA.prototype, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.subarray(0); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + undefined, + "used defaultCtor but still checks the inherited .constructor" + ); + + calls = 6; + result.constructor; + assert.sameValue( + calls, + 7, + "result.constructor triggers the inherited accessor property" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js new file mode 100644 index 00000000000..fba4d10d4f0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js @@ -0,0 +1,75 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Throws if O.constructor returns a non-Object and non-undefined value +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + 4. If Type(C) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + sample.constructor = 42; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "42"); + + sample.constructor = "1"; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "string"); + + sample.constructor = null; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "null"); + + sample.constructor = NaN; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "NaN"); + + sample.constructor = false; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "false"); + + sample.constructor = Symbol("1"); + assert.throws(TypeError, function() { + sample.subarray(0); + }, "symbol"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js new file mode 100644 index 00000000000..6e6f4536566 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: get constructor on SpeciesConstructor +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + 3. If C is undefined, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + var calls = 0; + var result; + + Object.defineProperty(sample, "constructor", { + get: function() { + calls++; + } + }); + + result = sample.subarray(0); + + assert.sameValue(calls, 1, "called custom ctor get accessor once"); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "use defaultCtor on an undefined return - getPrototypeOf check" + ); + assert.sameValue( + result.constructor, + TA, + "use defaultCtor on an undefined return - .constructor check" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js new file mode 100644 index 00000000000..6fa035a8280 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Returns abrupt from get @@species on found constructor +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } + }); + + assert.throws(Test262Error, function() { + sample.subarray(0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js new file mode 100644 index 00000000000..40afc297c0d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Verify arguments on custom @@species construct call +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42]); + var expectedOffset = TA.BYTES_PER_ELEMENT; + var result, ctorThis; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(buffer, offset, length) { + result = arguments; + ctorThis = this; + return new TA(buffer, offset, length); + }; + + sample.subarray(1); + + assert.sameValue(result.length, 3, "called with 3 arguments"); + assert.sameValue(result[0], sample.buffer, "[0] is sample.buffer"); + assert.sameValue(result[1], expectedOffset, "[1] is the byte offset pos"); + assert.sameValue(result[2], 2, "[2] is expected length"); + + assert( + ctorThis instanceof sample.constructor[Symbol.species], + "`this` value in the @@species fn is an instance of the function itself" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js new file mode 100644 index 00000000000..5440156c6aa --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Custom @@species constructor may return a totally different SendableTypedArray +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testTypedArray.js, compareArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40]); + var other = new Int8Array([1, 0, 1]); + var result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function() { + return other; + }; + + result = sample.subarray(0, 0); + + assert.sameValue(result, other, "returned another typedarray"); + assert(compareArray(result, [1, 0, 1]), "the returned object is preserved"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js new file mode 100644 index 00000000000..ebb90ecfc69 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Custom @@species constructor throws if it does not return a compatible object +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var ctor = function() {}; + + sample.constructor = {}; + sample.constructor[Symbol.species] = ctor; + + assert.throws(TypeError, function() { + sample.subarray(0); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js new file mode 100644 index 00000000000..346ce571985 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Use custom @@species constructor if available +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + 4. Return ? SendableTypedArrayCreate(constructor, argumentList). + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + ... + 7. If IsConstructor(S) is true, return S. + ... + + 22.2.4.6 SendableTypedArrayCreate ( constructor, argumentList ) + + 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). + 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). + 3. If argumentList is a List of a single Number, then + ... + 4. Return newSendableTypedArray. +includes: [testTypedArray.js, compareArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42]); + var calls = 0; + var result; + + sample.constructor = {}; + sample.constructor[Symbol.species] = function(buffer, offset, length) { + calls++; + return new TA(buffer, offset, length); + }; + + result = sample.subarray(1); + + assert.sameValue(calls, 1, "ctor called once"); + assert(compareArray(result, [41, 42]), "expected subarray"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js new file mode 100644 index 00000000000..f3ba6d7be25 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Throws if returned @@species is not a constructor, null or undefined. +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + 7. If IsConstructor(S) is true, return S. + 8. Throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + + sample.constructor = {}; + + sample.constructor[Symbol.species] = 0; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "0"); + + sample.constructor[Symbol.species] = "string"; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "string"); + + sample.constructor[Symbol.species] = {}; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "{}"); + + sample.constructor[Symbol.species] = NaN; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "NaN"); + + sample.constructor[Symbol.species] = false; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "false"); + + sample.constructor[Symbol.species] = true; + assert.throws(TypeError, function() { + sample.subarray(0); + }, "true"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js new file mode 100644 index 00000000000..af18e9052e1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Use defaultConstructor if @@species is either undefined or null +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + ... + 5. Let S be ? Get(C, @@species). + 6. If S is either undefined or null, return defaultConstructor. + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var result; + + sample.constructor = {}; + + result = sample.subarray(0); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "undefined @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "undefined @@species - ctor check"); + + sample.constructor[Symbol.species] = null; + result = sample.subarray(0); + + assert.sameValue( + Object.getPrototypeOf(result), + Object.getPrototypeOf(sample), + "null @@species - prototype check " + ); + assert.sameValue(result.constructor, TA, "null @@species - ctor check"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js new file mode 100644 index 00000000000..f81e7949c3c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + get @@species from found constructor +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). + + 22.2.4.7 SendableTypedArraySpeciesCreate ( exemplar, argumentList ) + + ... + 3. Let constructor be ? SpeciesConstructor(exemplar, defaultConstructor). + ... + + 7.3.20 SpeciesConstructor ( O, defaultConstructor ) + + 1. Assert: Type(O) is Object. + 2. Let C be ? Get(O, "constructor"). + ... + 5. Let S be ? Get(C, @@species). + ... +includes: [testTypedArray.js] +features: [Symbol.species, TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(2); + var calls = 0; + + sample.constructor = {}; + + Object.defineProperty(sample.constructor, Symbol.species, { + get: function() { + calls++; + } + }); + + sample.subarray(0); + + assert.sameValue(calls, 1); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-object.js new file mode 100644 index 00000000000..a7dfcada61a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-object.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + The following steps are taken: + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var subarray = SendableTypedArray.prototype.subarray; + +assert.throws(TypeError, function() { + subarray.call(undefined, 0, 0); +}, "this is undefined"); + +assert.throws(TypeError, function() { + subarray.call(null, 0, 0); +}, "this is null"); + +assert.throws(TypeError, function() { + subarray.call(42, 0, 0); +}, "this is 42"); + +assert.throws(TypeError, function() { + subarray.call("1", 0, 0); +}, "this is a string"); + +assert.throws(TypeError, function() { + subarray.call(true, 0, 0); +}, "this is true"); + +assert.throws(TypeError, function() { + subarray.call(false, 0, 0); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + subarray.call(s, 0, 0); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..9796c8cdf48 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.9 %SendableTypedArray%.prototype.subarray( begin , end ) + + The following steps are taken: + + 1. Let O be the this value. + 2. If Type(O) is not Object, throw a TypeError exception. + 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var subarray = SendableTypedArray.prototype.subarray; + +assert.throws(TypeError, function() { + subarray.call({}, 0, 0); +}, "this is an Object"); + +assert.throws(TypeError, function() { + subarray.call([], 0, 0); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + subarray.call(ab, 0, 0); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + subarray.call(dv, 0, 0); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js new file mode 100644 index 00000000000..5547d861633 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: ToInteger(begin) +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 7. Let relativeBegin be ? ToInteger(begin). + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +var obj = { + valueOf: function() { + return 2; + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + assert(compareArray(sample.subarray(false), [40, 41, 42, 43]), "false"); + assert(compareArray(sample.subarray(true), [41, 42, 43]), "true"); + + assert(compareArray(sample.subarray(NaN), [40, 41, 42, 43]), "NaN"); + assert(compareArray(sample.subarray(null), [40, 41, 42, 43]), "null"); + assert(compareArray(sample.subarray(undefined), [40, 41, 42, 43]), "undefined"); + + assert(compareArray(sample.subarray(1.1), [41, 42, 43]), "1.1"); + assert(compareArray(sample.subarray(1.5), [41, 42, 43]), "1.5"); + assert(compareArray(sample.subarray(0.6), [40, 41, 42, 43]), "0.6"); + + assert(compareArray(sample.subarray(-1.5), [43]), "-1.5"); + assert(compareArray(sample.subarray(-1.1), [43]), "-1.1"); + assert(compareArray(sample.subarray(-0.6), [40, 41, 42, 43]), "-0.6"); + + assert(compareArray(sample.subarray("3"), [43]), "string"); + assert( + compareArray( + sample.subarray(obj), + [42, 43] + ), + "object" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js new file mode 100644 index 00000000000..8cd13b3c906 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.subarray +description: ToInteger(end) +info: | + 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) + + ... + 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd be + ? ToInteger(end). + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +var obj = { + valueOf: function() { + return 2; + } +}; + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA([40, 41, 42, 43]); + + assert(compareArray(sample.subarray(0, false), []), "false"); + assert(compareArray(sample.subarray(0, true), [40]), "true"); + + assert(compareArray(sample.subarray(0, NaN), []), "NaN"); + assert(compareArray(sample.subarray(0, null), []), "null"); + assert(compareArray(sample.subarray(0, undefined), [40, 41, 42, 43]), "undefined"); + + assert(compareArray(sample.subarray(0, 0.6), []), "0.6"); + assert(compareArray(sample.subarray(0, 1.1), [40]), "1.1"); + assert(compareArray(sample.subarray(0, 1.5), [40]), "1.5"); + assert(compareArray(sample.subarray(0, -0.6), []), "-0.6"); + assert(compareArray(sample.subarray(0, -1.1), [40, 41, 42]), "-1.1"); + assert(compareArray(sample.subarray(0, -1.5), [40, 41, 42]), "-1.5"); + + assert(compareArray(sample.subarray(0, "3"), [40, 41, 42]), "string"); + assert( + compareArray( + sample.subarray(0, obj), + [40, 41] + ), + "object" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js new file mode 100644 index 00000000000..6076bff2dff --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Calls toLocaleString from each property's value +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testBigIntSendableTypedArray.js, compareArray.js] +features: [BigInt, TypedArray] +---*/ + +var separator = ["", ""].toLocaleString(); +var calls; + +BigInt.prototype.toLocaleString = function() { + calls.push(this); + return "hacks" + calls.length; +}; + +var expected = ["hacks1", "hacks2"].join(separator); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 0n]); + calls = []; + assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); + assert( + compareArray(new TA(calls), sample), + "toLocaleString called for each item" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js new file mode 100644 index 00000000000..2fac0204d46 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + Calls toString from each property's value return from toLocaleString +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var separator = ["", ""].toLocaleString(); +var calls; + +BigInt.prototype.toLocaleString = function() { + return { + toString: function() { + calls++; + return "hacks" + calls; + }, + valueOf: function() { + throw new Test262Error("should not call valueOf if toString is present"); + } + }; +}; + +var arr = [42n, 0n]; +var expected = ["hacks1", "hacks2"].join(separator); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(arr); + calls = 0; + assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); + assert.sameValue(calls, 2, "toString called once for each item"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js new file mode 100644 index 00000000000..e970aa83778 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + Calls valueOf from each property's value return from toLocaleString +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var separator = ["", ""].toLocaleString(); +var calls; + +BigInt.prototype.toLocaleString = function() { + return { + toString: undefined, + valueOf: function() { + calls++; + return "hacks" + calls; + } + }; +}; + +var expected = ["hacks1", "hacks2"].join(separator); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 0n]); + calls = 0; + assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); + assert.sameValue(calls, 2, "valueOf called once for each item"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js new file mode 100644 index 00000000000..71ae9fc1ff1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.toLocaleString(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js new file mode 100644 index 00000000000..2b27b934936 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Returns an empty string if called on an empty instance +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 4. If len is zero, return the empty String. + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.sameValue(sample.toLocaleString(), ""); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..add0c53c006 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + 1. Let array be ? ToObject(this value). + 2.Let len be ? ToLength(? Get(array, "length")). + ... +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 43n]); + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.toLocaleString(); + + assert.sameValue(getCalls, 0, "ignores length properties"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js new file mode 100644 index 00000000000..237117500b4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Returns abrupt from firstElement's toLocaleString +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 4. If len is zero, return the empty String. + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var calls; + +BigInt.prototype.toLocaleString = function() { + calls++; + throw new Test262Error(); +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + calls = 0; + var sample = new TA([42n, 0n]); + assert.throws(Test262Error, function() { + sample.toLocaleString(); + }); + assert.sameValue(calls, 1, "abrupt from first element"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js new file mode 100644 index 00000000000..b14ba6aa416 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + Return abrupt from firstElement's toLocaleString => toString +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var calls = 0; + +BigInt.prototype.toLocaleString = function() { + return { + toString: function() { + calls++; + throw new Test262Error(); + } + }; +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 0n]); + calls = 0; + assert.throws(Test262Error, function() { + sample.toLocaleString(); + }); + assert.sameValue(calls, 1, "toString called once"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js new file mode 100644 index 00000000000..4c9f25bc10d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + Return abrupt from firstElement's toLocaleString => valueOf +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var calls = 0; + +BigInt.prototype.toLocaleString = function() { + return { + toString: undefined, + valueOf: function() { + calls++; + throw new Test262Error(); + } + }; +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 0n]); + calls = 0; + assert.throws(Test262Error, function() { + sample.toLocaleString(); + }); + assert.sameValue(calls, 1, "toString called once"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js new file mode 100644 index 00000000000..b82ec62b703 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Returns abrupt from a nextElement's toLocaleString +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var calls = 0; + +BigInt.prototype.toLocaleString = function() { + calls++; + if (calls > 1) { + throw new Test262Error(); + } +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + calls = 0; + var sample = new TA([42n, 0n]); + assert.throws(Test262Error, function() { + sample.toLocaleString(); + }); + assert.sameValue(calls, 2, "abrupt from a next element"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js new file mode 100644 index 00000000000..09b473b65be --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + Return abrupt from nextElement's toLocaleString => valueOf +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var calls = 0; + +BigInt.prototype.toLocaleString = function() { + return { + toString: function() { + calls++; + if (calls > 1) { + throw new Test262Error(); + } + } + }; +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 0n]); + calls = 0; + assert.throws(Test262Error, function() { + sample.toLocaleString(); + }); + assert.sameValue(calls, 2, "abrupt from a nextElement"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js new file mode 100644 index 00000000000..1b78858ade7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + Return abrupt from nextElement's toLocaleString => valueOf +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var calls = 0; + +BigInt.prototype.toLocaleString = function() { + return { + toString: undefined, + valueOf: function() { + calls++; + if (calls > 1) { + throw new Test262Error(); + } + } + }; +}; + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 0n]); + calls = 0; + assert.throws(Test262Error, function() { + sample.toLocaleString(); + }); + assert.sameValue(calls, 2, "abrupt from a nextElement"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..82e536c0b1d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.toLocaleString, + 'function', + 'implements SendableTypedArray.prototype.toLocaleString' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.toLocaleString(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.toLocaleString(); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the toLocaleString operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.toLocaleString(); + throw new Test262Error('toLocaleString completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-result.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-result.js new file mode 100644 index 00000000000..15dc9992364 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-result.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Returns a string +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +var separator = ["", ""].toLocaleString(); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([42n, 0n, 43n]); + var expected = + sample[0].toLocaleString().toString() + + separator + + sample[1].toLocaleString().toString() + + separator + + sample[2].toLocaleString().toString(); + assert.sameValue(sample.toLocaleString(), expected); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js new file mode 100644 index 00000000000..5a04104dbf9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Calls toLocaleString from each property's value +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray] +---*/ + +var separator = ["", ""].toLocaleString(); +var calls; + +Number.prototype.toLocaleString = function() { + calls.push(this); + return "hacks" + calls.length; +}; + +var arr = [42, 0]; +var expected = ["hacks1", "hacks2"].join(separator); + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(arr); + calls = []; + assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); + assert( + compareArray(new TA(calls), sample), + "toLocaleString called for each item" + ); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js new file mode 100644 index 00000000000..1262b8c5819 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + Calls toString from each property's value return from toLocaleString +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var separator = ["", ""].toLocaleString(); +var calls; + +Number.prototype.toLocaleString = function() { + return { + toString: function() { + calls++; + return "hacks" + calls; + }, + valueOf: function() { + throw new Test262Error("should not call valueOf if toString is present"); + } + }; +}; + +var arr = [42, 0]; +var expected = ["hacks1", "hacks2"].join(separator); + +testWithSendableTypedArrayConstructors(function(TA, N) { + var sample = new TA(arr); + calls = 0; + assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); + assert.sameValue(calls, 2, "toString called once for each item"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js new file mode 100644 index 00000000000..0815715a33b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + Calls valueOf from each property's value return from toLocaleString +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var separator = ["", ""].toLocaleString(); +var calls; + +Number.prototype.toLocaleString = function() { + return { + toString: undefined, + valueOf: function() { + calls++; + return "hacks" + calls; + } + }; +}; + +var arr = [42, 0]; +var expected = ["hacks1", "hacks2"].join(separator); + +testWithSendableTypedArrayConstructors(function(TA, N) { + var sample = new TA(arr); + calls = 0; + assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); + assert.sameValue(calls, 2, "valueOf called once for each item"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js new file mode 100644 index 00000000000..d0b8aea7834 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.toLocaleString(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js new file mode 100644 index 00000000000..d1b83d142df --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Returns an empty string if called on an empty instance +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 4. If len is zero, return the empty String. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(); + assert.sameValue(sample.toLocaleString(), ""); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js new file mode 100644 index 00000000000..1be6f0f04d1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Get "length" uses internal ArrayLength +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + 1. Let array be ? ToObject(this value). + 2.Let len be ? ToLength(? Get(array, "length")). + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var getCalls = 0; +var desc = { + get: function getLen() { + getCalls++; + return 0; + } +}; + +Object.defineProperty(SendableTypedArray.prototype, "length", desc); + +testWithSendableTypedArrayConstructors(function(TA, N) { + var sample = new TA([42, 43]); + + Object.defineProperty(TA.prototype, "length", desc); + Object.defineProperty(sample, "length", desc); + + sample.toLocaleString(); + + assert.sameValue(getCalls, 0, "ignores length properties"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-func.js new file mode 100644 index 00000000000..8b1999b2657 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-func.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.27 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + ... + + This function is not generic. ValidateSendableTypedArray is applied to the this + value prior to evaluating the algorithm. If its result is an abrupt + completion that exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var toLocaleString = SendableTypedArray.prototype.toLocaleString; + +assert.sameValue(typeof toLocaleString, 'function'); + +assert.throws(TypeError, function() { + toLocaleString(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-method.js new file mode 100644 index 00000000000..fab89ccafb8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-method.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.27 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + ... + + This function is not generic. ValidateSendableTypedArray is applied to the this + value prior to evaluating the algorithm. If its result is an abrupt + completion that exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.toLocaleString, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.toLocaleString(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/length.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/length.js new file mode 100644 index 00000000000..457b9e2d603 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + %SendableTypedArray%.prototype.toLocaleString.length is 0. +info: | + %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.toLocaleString, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/name.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/name.js new file mode 100644 index 00000000000..6159aaf861d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + %SendableTypedArray%.prototype.toLocaleString.name is "toLocaleString". +info: | + %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.toLocaleString, "name", { + value: "toLocaleString", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/not-a-constructor.js new file mode 100644 index 00000000000..e7eb42898c5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.toLocaleString 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.toLocaleString), + false, + 'isConstructor(SendableTypedArray.prototype.toLocaleString) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.toLocaleString(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/prop-desc.js new file mode 100644 index 00000000000..04ccfea12f9 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + "toLocaleString" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'toLocaleString', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/resizable-buffer.js new file mode 100644 index 00000000000..0a32d6ce6ef --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/resizable-buffer.js @@ -0,0 +1,126 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + SendableTypedArray.p.toLocaleString behaves correctly on SendableTypedArrays backed by + resizable buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const taWrite = new ctor(rab); + + // toLocaleString separator is implementation dependent. + function listToString(list) { + const comma = ['',''].toLocaleString(); + const len = list.length; + let result = ''; + if (len > 1) { + for (let i=0; i < len - 1 ; i++) { + result += list[i] + comma; + } + } + if (len > 0) { + result += list[len-1]; + } + return result; + } + + // Write some data into the array. + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + assert.sameValue(fixedLength.toLocaleString(),listToString([0,2,4,6])); + assert.sameValue(fixedLengthWithOffset.toLocaleString(),listToString([4,6])); + assert.sameValue(lengthTracking.toLocaleString(),listToString([0,2,4,6])); + assert.sameValue(lengthTrackingWithOffset.toLocaleString(),listToString([4,6])); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + assert.throws(TypeError, () => { + fixedLength.toLocaleString(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.toLocaleString(); + }); + + assert.sameValue(lengthTracking.toLocaleString(),listToString([0,2,4])); + assert.sameValue(lengthTrackingWithOffset.toLocaleString(),listToString([4])); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.toLocaleString(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.toLocaleString(); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.toLocaleString(); + }); + + assert.sameValue(lengthTracking.toLocaleString(),listToString([0])); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.toLocaleString(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.toLocaleString(); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.toLocaleString(); + }); + + assert.sameValue(lengthTracking.toLocaleString(),listToString([])); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert.sameValue(fixedLength.toLocaleString(),listToString([0,2,4,6])); + assert.sameValue(fixedLengthWithOffset.toLocaleString(),listToString([4,6])); + assert.sameValue(lengthTracking.toLocaleString(),listToString([0,2,4,6,8,10])); + assert.sameValue(lengthTrackingWithOffset.toLocaleString(),listToString([4,6,8,10])); +} diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js new file mode 100644 index 00000000000..11f2f62fd5e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Returns abrupt from firstElement's toLocaleString +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 4. If len is zero, return the empty String. + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var calls; + +Number.prototype.toLocaleString = function() { + calls++; + throw new Test262Error(); +}; + +var arr = [42, 0]; + +testWithSendableTypedArrayConstructors(function(TA, N) { + calls = 0; + var sample = new TA(arr); + assert.throws(Test262Error, function() { + sample.toLocaleString(); + }); + assert.sameValue(calls, 1, "abrupt from first element"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js new file mode 100644 index 00000000000..69ff2b4d399 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + Return abrupt from firstElement's toLocaleString => toString +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var calls = 0; + +Number.prototype.toLocaleString = function() { + return { + toString: function() { + calls++; + throw new Test262Error(); + } + }; +}; + +var arr = [42, 0]; + +testWithSendableTypedArrayConstructors(function(TA, N) { + var sample = new TA(arr); + calls = 0; + assert.throws(Test262Error, function() { + sample.toLocaleString(); + }); + assert.sameValue(calls, 1, "toString called once"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js new file mode 100644 index 00000000000..d85513b5447 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + Return abrupt from firstElement's toLocaleString => valueOf +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var calls = 0; + +Number.prototype.toLocaleString = function() { + return { + toString: undefined, + valueOf: function() { + calls++; + throw new Test262Error(); + } + }; +}; + +var arr = [42, 0]; + +testWithSendableTypedArrayConstructors(function(TA, N) { + var sample = new TA(arr); + calls = 0; + assert.throws(Test262Error, function() { + sample.toLocaleString(); + }); + assert.sameValue(calls, 1, "toString called once"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js new file mode 100644 index 00000000000..dddc2eb361a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Returns abrupt from a nextElement's toLocaleString +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var calls = 0; + +Number.prototype.toLocaleString = function() { + calls++; + if (calls > 1) { + throw new Test262Error(); + } +}; + +var arr = [42, 0]; + +testWithSendableTypedArrayConstructors(function(TA, N) { + calls = 0; + var sample = new TA(arr); + assert.throws(Test262Error, function() { + sample.toLocaleString(); + }); + assert.sameValue(calls, 2, "abrupt from a next element"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js new file mode 100644 index 00000000000..2013c59a593 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + Return abrupt from nextElement's toLocaleString => valueOf +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var calls = 0; + +Number.prototype.toLocaleString = function() { + return { + toString: function() { + calls++; + if (calls > 1) { + throw new Test262Error(); + } + } + }; +}; + +var arr = [42, 0]; + +testWithSendableTypedArrayConstructors(function(TA, N) { + var sample = new TA(arr); + calls = 0; + assert.throws(Test262Error, function() { + sample.toLocaleString(); + }); + assert.sameValue(calls, 2, "abrupt from a nextElement"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js new file mode 100644 index 00000000000..f4c2e02deae --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + Return abrupt from nextElement's toLocaleString => valueOf +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var calls = 0; + +Number.prototype.toLocaleString = function() { + return { + toString: undefined, + valueOf: function() { + calls++; + if (calls > 1) { + throw new Test262Error(); + } + } + }; +}; + +var arr = [42, 0]; + +testWithSendableTypedArrayConstructors(function(TA, N) { + var sample = new TA(arr); + calls = 0; + assert.throws(Test262Error, function() { + sample.toLocaleString(); + }); + assert.sameValue(calls, 2, "abrupt from a nextElement"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..d45ff8588a0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.toLocaleString, + 'function', + 'implements SendableTypedArray.prototype.toLocaleString' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.toLocaleString(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.toLocaleString(); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the toLocaleString operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.toLocaleString(); + throw new Test262Error('toLocaleString completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js new file mode 100644 index 00000000000..7f2e43cef8b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Returns a string +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + %SendableTypedArray%.prototype.toLocaleString is a distinct function that implements + the same algorithm as Array.prototype.toLocaleString as defined in 22.1.3.27 + except that the this object's [[ArrayLength]] internal slot is accessed in + place of performing a [[Get]] of "length". + + 22.1.3.27 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + + ... + 5. Let firstElement be ? Get(array, "0"). + 6. If firstElement is undefined or null, then + a. Let R be the empty String. + 7. Else, + a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). + 8. Let k be 1. + 9.Repeat, while k < len + a. Let S be a String value produced by concatenating R and separator. + b. Let nextElement be ? Get(array, ! ToString(k)). + c. If nextElement is undefined or null, then + i. Let R be the empty String. + d. Else, + i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var separator = ["", ""].toLocaleString(); + +var arr = [42, 0, 43]; + +testWithSendableTypedArrayConstructors(function(TA, N) { + var sample = new TA(arr); + var expected = + sample[0].toLocaleString().toString() + + separator + + sample[1].toLocaleString().toString() + + separator + + sample[2].toLocaleString().toString(); + assert.sameValue(sample.toLocaleString(), expected); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-object.js new file mode 100644 index 00000000000..fb435f6645f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-object.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var toLocaleString = SendableTypedArray.prototype.toLocaleString; + +assert.throws(TypeError, function() { + toLocaleString.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + toLocaleString.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + toLocaleString.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + toLocaleString.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + toLocaleString.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + toLocaleString.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + toLocaleString.call(s); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..2e35b82c0aa --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var toLocaleString = SendableTypedArray.prototype.toLocaleString; + +assert.throws(TypeError, function() { + toLocaleString.call({}); +}, "this is an Object"); + +assert.throws(TypeError, function() { + toLocaleString.call([]); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + toLocaleString.call(ab); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + toLocaleString.call(dv); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-grow.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-grow.js new file mode 100644 index 00000000000..b67c0da64ec --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-grow.js @@ -0,0 +1,94 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + SendableTypedArray.p.toLocaleString behaves correctly when {Number,BigInt}. + prototype.toLocaleString is replaced with a user-provided function + that grows the underlying resizable buffer. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +const oldNumberPrototypeToLocaleString = Number.prototype.toLocaleString; +const oldBigIntPrototypeToLocaleString = BigInt.prototype.toLocaleString; + +// toLocaleString separator is implementation dependent. +function listToString(list) { + const comma = ['',''].toLocaleString(); + const len = list.length; + let result = ''; + if (len > 1) { + for (let i=0; i < len - 1 ; i++) { + result += list[i] + comma; + } + } + if (len > 0) { + result += list[len-1]; + } + return result; +} + +// Growing + fixed-length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let resizeAfter = 2; + Number.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + } + return oldNumberPrototypeToLocaleString.call(this); + }; + BigInt.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + } + return oldBigIntPrototypeToLocaleString.call(this); + }; + + // We iterate 4 elements since it was the starting length. Resizing doesn't + // affect the TA. + assert.sameValue(fixedLength.toLocaleString(), listToString([0,0,0,0])); +} + +// Growing + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + let resizeAfter = 2; + Number.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + } + return oldNumberPrototypeToLocaleString.call(this); + }; + BigInt.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + } + return oldBigIntPrototypeToLocaleString.call(this); + }; + + // We iterate 4 elements since it was the starting length. + assert.sameValue(lengthTracking.toLocaleString(), listToString([0,0,0,0])); +} +Number.prototype.toLocaleString = oldNumberPrototypeToLocaleString; +BigInt.prototype.toLocaleString = oldBigIntPrototypeToLocaleString; diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-shrink.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-shrink.js new file mode 100644 index 00000000000..26e5bc68af4 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-shrink.js @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tolocalestring +description: > + SendableTypedArray.p.toLocaleString behaves correctly when {Number,BigInt}. + prototype.toLocaleString is replaced with a user-provided function + that shrinks the underlying resizable buffer. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +const oldNumberPrototypeToLocaleString = Number.prototype.toLocaleString; +const oldBigIntPrototypeToLocaleString = BigInt.prototype.toLocaleString; + +// toLocaleString separator is implementation dependent. +function listToString(list) { + const comma = ['',''].toLocaleString(); + const len = list.length; + let result = ''; + if (len > 1) { + for (let i=0; i < len - 1 ; i++) { + result += list[i] + comma; + } + } + if (len > 0) { + result += list[len-1]; + } + return result; +} + +// Shrinking + fixed-length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let resizeAfter = 2; + Number.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + } + return oldNumberPrototypeToLocaleString.call(this); + }; + BigInt.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + } + return oldBigIntPrototypeToLocaleString.call(this); + }; + + // We iterate 4 elements, since it was the starting length. The TA goes + // OOB after 2 elements. + assert.sameValue(fixedLength.toLocaleString(), listToString([0,0,'',''])); +} + +// Shrinking + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + let resizeAfter = 2; + Number.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + } + return oldNumberPrototypeToLocaleString.call(this); + }; + BigInt.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + } + return oldBigIntPrototypeToLocaleString.call(this); + }; + + // We iterate 4 elements, since it was the starting length. Elements beyond + // the new length are converted to the empty string. + assert.sameValue(lengthTracking.toLocaleString(), listToString([0,0,'',''])); +} +Number.prototype.toLocaleString = oldNumberPrototypeToLocaleString; +BigInt.prototype.toLocaleString = oldBigIntPrototypeToLocaleString; diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js b/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js new file mode 100644 index 00000000000..7f65638049e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toReversed +description: > + %SendableTypedArray%.prototype.toReversed ignores @@species +info: | + %SendableTypedArray%.prototype.toReversed ( ) + + ... + 4. Let A be ? SendableTypedArrayCreateSameType(O, « 𝔽(length) »). + ... + + SendableTypedArrayCreateSameType ( exemplar, argumentList ) + ... + 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var ta = new TA(); + ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array; + assert.sameValue(Object.getPrototypeOf(ta.toReversed()), TA.prototype); + + ta = new TA(); + ta.constructor = { + [Symbol.species]: TA === Uint8Array ? Int32Array : Uint8Array, + }; + assert.sameValue(Object.getPrototypeOf(ta.toReversed()), TA.prototype); + + ta = new TA(); + Object.defineProperty(ta, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } + }); + ta.toReversed(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js b/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js new file mode 100644 index 00000000000..2cfc8f48c57 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toReversed +description: > + %SendableTypedArray%.prototype.toReversed does not mutate its this value +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var ta = new TA([0, 1, 2]); + ta.toReversed(); + + assert.compareArray(ta, [0, 1, 2]); + assert.notSameValue(ta.toReversed(), ta); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js b/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js new file mode 100644 index 00000000000..26333f09f8b --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toReversed +description: > + %SendableTypedArray%.prototype.toReversed does not read a "length" property +info: | + %SendableTypedArray%.prototype.toReversed ( ) + + ... + 3. Let length be O.[[ArrayLength]]. + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var ta = new TA([0, 1, 2]); + Object.defineProperty(ta, "length", { value: 2 }) + var res = ta.toReversed(); + assert.compareArray(res, [2, 1, 0]); + assert.sameValue(res.length, 3); + + ta = new TA([0, 1, 2]); + Object.defineProperty(ta, "length", { value: 5 }); + res = ta.toReversed(); + assert.compareArray(res, [2, 1, 0]); + assert.sameValue(res.length, 3); +}); + +function setLength(length) { + Object.defineProperty(SendableTypedArray.prototype, "length", { + get: () => length, + }); +} + +testWithSendableTypedArrayConstructors(TA => { + var ta = new TA([0, 1, 2]); + + setLength(2); + var res = ta.toReversed(); + setLength(3); + assert.compareArray(res, [2, 1, 0]); + + setLength(5); + res = ta.toReversed(); + setLength(3); + assert.compareArray(res, [2, 1, 0]); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/length.js b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/length.js new file mode 100644 index 00000000000..4bd258f464c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/length.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toReversed +description: > + The "length" property of %SendableTypedArray%.prototype.toReversed +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +verifyProperty(SendableTypedArray.prototype.toReversed, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/name.js b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/name.js new file mode 100644 index 00000000000..45c102f8fb5 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toReversed +description: > + %SendableTypedArray%.prototype.toReversed.name is "toReversed". +info: | + %SendableTypedArray%.prototype.toReversed ( ) + + 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, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +verifyProperty(SendableTypedArray.prototype.toReversed, "name", { + value: "toReversed", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/property-descriptor.js b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/property-descriptor.js new file mode 100644 index 00000000000..03447c38237 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/property-descriptor.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toReversed +description: > + "toReversed" property of %SendableTypedArray%.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + 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, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +assert.sameValue(typeof SendableTypedArray.prototype.toReversed, "function", "typeof"); + +verifyProperty(SendableTypedArray.prototype, "toReversed", { + value: SendableTypedArray.prototype.toReversed, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/toReversed/not-a-constructor.js new file mode 100644 index 00000000000..bf8302dec6a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + %SendableTypedArray%.prototype.toReversed 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, testTypedArray.js] +features: [TypedArray, change-array-by-copy, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.toReversed), + false, + 'isConstructor(SendableTypedArray.prototype.toReversed) must return false' +); + +assert.throws(TypeError, () => { + new SendableTypedArray.prototype.toReversed(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js b/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js new file mode 100644 index 00000000000..d4aacae92df --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toReversed +description: > + %SendableTypedArray%.prototype.toReversed throws if the receiver is not a valid SendableTypedArray +info: | + %SendableTypedArray%.prototype.toReversed ( ) + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... +includes: [detachArrayBuffer.js, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +var invalidValues = { + 'null': null, + 'undefined': undefined, + 'true': true, + '"abc"': "abc", + '12': 12, + 'Symbol()': Symbol(), + '[1, 2, 3]': [1, 2, 3], + '{ 0: 1, 1: 2, 2: 3, length: 3 }': { 0: 1, 1: 2, 2: 3, length: 3 }, + 'Uint8Array.prototype': Uint8Array.prototype, + '1n': 1n, +}; + +Object.entries(invalidValues).forEach(value => { + assert.throws(TypeError, () => { + SendableTypedArray.prototype.toReversed.call(value[1]); + }, `${value[0]} is not a valid SendableTypedArray`); +}); + +testWithSendableTypedArrayConstructors(function(TA) { + let buffer = new ArrayBuffer(8); + let sample = new TA(buffer, 0, 1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, () => { + sample.toReversed(); + }, `array has a detached buffer`); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js new file mode 100644 index 00000000000..0bccce96cbe --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + %SendableTypedArray%.prototype.toSorted verifies that the comparator is callable before reading the length. +info: | + %SendableTypedArray%.prototype.toSorted ( comparefn ) + + 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. + 2. ... + 3. Let len be ? LengthOfArrayLike(O). +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +var invalidComparators = [null, true, false, "", /a/g, 42, 42n, [], {}, Symbol()]; + +testWithSendableTypedArrayConstructors(TA => { + const ta = new TA([1]); + for (var i = 0; i < invalidComparators.length; i++) { + assert.throws(TypeError, function() { + ta.toSorted(invalidComparators[i]); + }, String(invalidComparators[i])); + } +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js new file mode 100644 index 00000000000..1988d785da2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + %SendableTypedArray%.prototype.toSorted doesn't call copmareFn if there is an error +info: | + %SendableTypedArray%.prototype.toSorted ( compareFn ) + + ... + 9. Sort items using an implementation-defined sequence of + calls to SortCompare. If any such call returns an abrupt + completion, stop before performing any further calls to + SortCompare or steps in this algorithm and return that completion. + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var calls = 0; + var ta = new TA([3, 1, 2]); + try { + ta.toSorted(() => { + ++calls; + if (calls === 1) { + throw new Test262Error(); + } + }); + } catch (e) {} + assert.sameValue(calls <= 1, true, "compareFn is not called after an error"); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js b/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js new file mode 100644 index 00000000000..6a37633f949 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + %SendableTypedArray%.prototype.toSorted ignores @@species +info: | + %SendableTypedArray%.prototype.toSorted ( comparefn ) + + ... + 6. Let A be ? SendableTypedArrayCreateSameType(O, « 𝔽(len) »). + ... + + SendableTypedArrayCreateSameType ( exemplar, argumentList ) + ... + 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var ta = new TA(); + ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array; + assert.sameValue(Object.getPrototypeOf(ta.toSorted()), TA.prototype); + + ta = new TA(); + ta.constructor = { + [Symbol.species]: TA === Uint8Array ? Int32Array : Uint8Array, + }; + assert.sameValue(Object.getPrototypeOf(ta.toSorted()), TA.prototype); + + ta = new TA(); + Object.defineProperty(ta, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } + }); + ta.toSorted(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js b/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js new file mode 100644 index 00000000000..b8ceb45417e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + %SendableTypedArray%.prototype.toSorted does not mutate its this value +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + ta.toSorted(); + + assert.compareArray(ta, [3, 1, 2]); + assert.notSameValue(ta.toSorted(), ta); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js b/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js new file mode 100644 index 00000000000..055821febcf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + %SendableTypedArray%.prototype.toSorted does not read a "length" property +info: | + %SendableTypedArray%.prototype.toSorted ( comparefn ) + + ... + 4. Let len be O.[[ArrayLength]]. + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + Object.defineProperty(ta, "length", { value: 2 }) + var res = ta.toSorted() + assert.compareArray(res, [1, 2, 3]); + assert.sameValue(res.length, 3); + + ta = new TA([3, 1, 2]); + Object.defineProperty(ta, "length", { value: 5 }); + res = ta.toSorted(); + assert.compareArray(res, [1, 2, 3]); + assert.sameValue(res.length, 3); +}); + +function setLength(length) { + Object.defineProperty(SendableTypedArray.prototype, "length", { + get: () => length, + }); +} + +testWithSendableTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + + setLength(2); + var res = ta.toSorted(); + setLength(3); + assert.compareArray(res, [1, 2, 3]); + + setLength(5); + res = ta.toSorted(); + setLength(3); + + assert.compareArray(res, [1, 2, 3]); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/length.js b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/length.js new file mode 100644 index 00000000000..99c0877b861 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/length.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + The "length" property of %SendableTypedArray%.prototype.toSorted +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +verifyProperty(SendableTypedArray.prototype.toSorted, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/name.js b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/name.js new file mode 100644 index 00000000000..ef4102fc799 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + %SendableTypedArray%.prototype.toSorted.name is "toSorted". +info: | + %SendableTypedArray%.prototype.toSorted ( comparefn ) + + 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, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +verifyProperty(SendableTypedArray.prototype.toSorted, "name", { + value: "toSorted", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/property-descriptor.js b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/property-descriptor.js new file mode 100644 index 00000000000..29feb4c6235 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/property-descriptor.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + "toSorted" property of %SendableTypedArray%.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + 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, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +assert.sameValue(typeof SendableTypedArray.prototype.toSorted, "function", "typeof"); + +verifyProperty(SendableTypedArray.prototype, "toSorted", { + value: SendableTypedArray.prototype.toSorted, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/toSorted/not-a-constructor.js new file mode 100644 index 00000000000..dd25753c678 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + %SendableTypedArray%.prototype.toSorted 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, testTypedArray.js] +features: [TypedArray, change-array-by-copy, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.toSorted), + false, + 'isConstructor(SendableTypedArray.prototype.toSorted) must return false' +); + +assert.throws(TypeError, () => { + new SendableTypedArray.prototype.toSorted(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js b/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js new file mode 100644 index 00000000000..0a0fdc59b62 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.toSorted +description: > + %SendableTypedArray%.prototype.toSorted throws if the receiver is not a valid SendableTypedArray +info: | + %SendableTypedArray%.prototype.toSorted ( comparefn ) + + 2. Let O be the this value. + 3. Perform ? ValidateSendableTypedArray(O). + ... +includes: [detachArrayBuffer.js, testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +var invalidValues = { + 'null': null, + 'undefined': undefined, + 'true': true, + '"abc"': "abc", + '12': 12, + 'Symbol()': Symbol(), + '[1, 2, 3]': [1, 2, 3], + '{ 0: 1, 1: 2, 2: 3, length: 3 }': { 0: 1, 1: 2, 2: 3, length: 3 }, + 'Uint8Array.prototype': Uint8Array.prototype, + '1n': 1n, +}; + +Object.entries(invalidValues).forEach(value => { + assert.throws(TypeError, () => { + SendableTypedArray.prototype.toSorted.call(value[1]); + }, `${value[0]} is not a valid SendableTypedArray`); +}); + +testWithSendableTypedArrayConstructors(function(TA) { + let buffer = new ArrayBuffer(8); + let sample = new TA(buffer, 0, 1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, () => { + sample.toSorted(); + }, `array has a detached buffer`); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toString.js b/test/sendable/builtins/TypedArray/prototype/toString.js new file mode 100644 index 00000000000..19c028a21ff --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toString.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tostring +description: > + "toString" property of SendableTypedArrayPrototype +info: | + 22.2.3.28 %SendableTypedArray%.prototype.toString ( ) + + The initial value of the %SendableTypedArray%.prototype.toString data property is the + same built-in function object as the Array.prototype.toString method defined + in 22.1.3.27. + + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(SendableTypedArrayPrototype.toString, Array.prototype.toString); + +verifyProperty(SendableTypedArrayPrototype, 'toString', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toString/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/toString/BigInt/detached-buffer.js new file mode 100644 index 00000000000..de9026c62a8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toString/BigInt/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tostring +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.29 %SendableTypedArray%.prototype.toString () + + ... + + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.toString(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js new file mode 100644 index 00000000000..1ab0dba9867 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.tostring +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.29 %SendableTypedArray%.prototype.toString () + + ... + + 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) + + This function is not generic. ValidateSendableTypedArray is applied to the this value + prior to evaluating the algorithm. If its result is an abrupt completion that + exception is thrown instead of evaluating the algorithm. + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.toString(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/toString/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/toString/not-a-constructor.js new file mode 100644 index 00000000000..dda9fcef61e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/toString/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.toString 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.toString), + false, + 'isConstructor(SendableTypedArray.prototype.toString) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.toString(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/values/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/values/BigInt/detached-buffer.js new file mode 100644 index 00000000000..778a953d659 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/BigInt/detached-buffer.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.30 %SendableTypedArray%.prototype.values ( ) + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.values(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/values/BigInt/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/values/BigInt/iter-prototype.js new file mode 100644 index 00000000000..1be184865bf --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/BigInt/iter-prototype.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + The prototype of the returned iterator is ArrayIteratorPrototype +info: | + 22.2.3.30 %SendableTypedArray%.prototype.values ( ) + + ... + 3. Return CreateArrayIterator(O, "value"). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, Symbol.iterator, TypedArray] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var sample = new TA([0n, 42n, 64n]); + var iter = sample.values(); + + assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..e1fbf86b7de --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testBigIntSendableTypedArray.js] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.values, + 'function', + 'implements SendableTypedArray.prototype.values' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithBigIntSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.values(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.values(); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the values operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.values(); + throw new Test262Error('values completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-itor.js b/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-itor.js new file mode 100644 index 00000000000..18e5bb1193c --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-itor.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: Return an iterator for the values. +info: | + 22.2.3.30 %SendableTypedArray%.prototype.values ( ) + + ... + 3. Return CreateArrayIterator(O, "value"). +includes: [testBigIntSendableTypedArray.js] +features: [BigInt, TypedArray] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var typedArray = new TA([0n, 42n, 64n]); + var itor = typedArray.values(); + + var next = itor.next(); + assert.sameValue(next.value, 0n); + assert.sameValue(next.done, false); + + next = itor.next(); + assert.sameValue(next.value, 42n); + assert.sameValue(next.done, false); + + next = itor.next(); + assert.sameValue(next.value, 64n); + assert.sameValue(next.done, false); + + next = itor.next(); + assert.sameValue(next.value, undefined); + assert.sameValue(next.done, true); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js new file mode 100644 index 00000000000..4e74c3523a6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: Throws a TypeError if this has a detached buffer +info: | + 22.2.3.30 %SendableTypedArray%.prototype.values ( ) + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + ... + 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. + ... +includes: [testTypedArray.js, detachArrayBuffer.js] +features: [TypedArray] +---*/ + +testWithSendableTypedArrayConstructors(function(TA) { + var sample = new TA(1); + $DETACHBUFFER(sample.buffer); + assert.throws(TypeError, function() { + sample.values(); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/values/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/values/invoked-as-func.js new file mode 100644 index 00000000000..2d6517aade7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/invoked-as-func.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: Throws a TypeError exception when invoked as a function +info: | + 22.2.3.29 %SendableTypedArray%.prototype.values ( ) + + 1. Let O be the this value. + 2. Let valid be ValidateSendableTypedArray(O). + 3. ReturnIfAbrupt(valid). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var values = SendableTypedArray.prototype.values; + +assert.sameValue(typeof values, 'function'); + +assert.throws(TypeError, function() { + values(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/values/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/values/invoked-as-method.js new file mode 100644 index 00000000000..a46a861d403 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/invoked-as-method.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: Requires a [[TypedArrayName]] internal slot. +info: | + 22.2.3.29 %SendableTypedArray%.prototype.values ( ) + + 1. Let O be the this value. + 2. Let valid be ValidateSendableTypedArray(O). + 3. ReturnIfAbrupt(valid). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +assert.sameValue(typeof SendableTypedArrayPrototype.values, 'function'); + +assert.throws(TypeError, function() { + SendableTypedArrayPrototype.values(); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js new file mode 100644 index 00000000000..30f32ba57db --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + The prototype of the returned iterator is ArrayIteratorPrototype +info: | + 22.2.3.30 %SendableTypedArray%.prototype.values ( ) + + ... + 3. Return CreateArrayIterator(O, "value"). +includes: [testTypedArray.js] +features: [Symbol.iterator, TypedArray] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); + +testWithSendableTypedArrayConstructors(function(TA, N) { + var sample = new TA([0, 42, 64]); + var iter = sample.values(); + + assert.sameValue(Object.getPrototypeOf(iter), ArrayIteratorProto); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/values/length.js b/test/sendable/builtins/TypedArray/prototype/values/length.js new file mode 100644 index 00000000000..0456ef08f1d --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/length.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + %SendableTypedArray%.prototype.values.length is 0. +info: | + %SendableTypedArray%.prototype.values ( ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.values, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js b/test/sendable/builtins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js new file mode 100644 index 00000000000..92f28797242 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js @@ -0,0 +1,67 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + Iterator is still exhausted when typedarray is changed to in-bounds. +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let ta = new Int8Array(rab); + +// Ensure the SendableTypedArray is correctly initialised. +assert.sameValue(ta.length, 3); +assert.sameValue(ta.byteOffset, 0); + +ta[0] = 11; +ta[1] = 22; +ta[2] = 33; + +let it = ta.values(); +let r; + +// Fetch the first value. +r = it.next(); +assert.sameValue(r.done, false); +assert.sameValue(r.value, 11); + +// Resize buffer to zero. +rab.resize(0); + +// SendableTypedArray is now out-of-bounds. +assert.sameValue(ta.length, 0); +assert.sameValue(ta.byteOffset, 0); + +// Resize buffer to zero. +rab.resize(0); + +// Attempt to fetch the next value. This exhausts the iterator. +r = it.next(); +assert.sameValue(r.done, true); +assert.sameValue(r.value, undefined); + +// Resize buffer so the typed array is again in-bounds. +rab.resize(5); + +// SendableTypedArray is now in-bounds. +assert.sameValue(ta.length, 5); +assert.sameValue(ta.byteOffset, 0); + +// Attempt to fetch another value from an already exhausted iterator. +r = it.next(); +assert.sameValue(r.done, true); +assert.sameValue(r.value, undefined); diff --git a/test/sendable/builtins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js b/test/sendable/builtins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js new file mode 100644 index 00000000000..c33082f7414 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + Calling next on an out-of-bounds typedarray throws no error when iterator exhausted. +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let ta = new Int8Array(rab, 1); + +// Ensure the SendableTypedArray is correctly initialised. +assert.sameValue(ta.length, 2); +assert.sameValue(ta.byteOffset, 1); + +ta[0] = 11; +ta[1] = 22; + +let it = ta.values(); +let r; + +// Fetch the first value. +r = it.next(); +assert.sameValue(r.done, false); +assert.sameValue(r.value, 11); + +// Fetch the second value. +r = it.next(); +assert.sameValue(r.done, false); +assert.sameValue(r.value, 22); + +// Iterator is now exhausted. +r = it.next(); +assert.sameValue(r.done, true); +assert.sameValue(r.value, undefined); + +// Resize buffer to zero. +rab.resize(0); + +// SendableTypedArray is now out-of-bounds. +assert.sameValue(ta.length, 0); +assert.sameValue(ta.byteOffset, 0); + +// Calling next doesn't throw an error. +r = it.next(); +assert.sameValue(r.done, true); +assert.sameValue(r.value, undefined); diff --git a/test/sendable/builtins/TypedArray/prototype/values/name.js b/test/sendable/builtins/TypedArray/prototype/values/name.js new file mode 100644 index 00000000000..2547b3e459f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + %SendableTypedArray%.prototype.values.name is "values". +info: | + %SendableTypedArray%.prototype.values ( ) + + 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, testTypedArray.js] +features: [TypedArray] +---*/ + +verifyProperty(SendableTypedArray.prototype.values, "name", { + value: "values", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/values/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/values/not-a-constructor.js new file mode 100644 index 00000000000..0d61ab80b53 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableTypedArray.prototype.values 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, testTypedArray.js] +features: [Reflect.construct, arrow-function, TypedArray] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.values), + false, + 'isConstructor(SendableTypedArray.prototype.values) must return false' +); + +assert.throws(TypeError, () => { + let u8 = new Uint8Array(1); new u8.values(); +}); + diff --git a/test/sendable/builtins/TypedArray/prototype/values/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/values/prop-desc.js new file mode 100644 index 00000000000..bc7074b8a0e --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/prop-desc.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + "values" property of SendableTypedArrayPrototype +info: | + ES6 section 17: 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, testTypedArray.js] +features: [TypedArray] +---*/ + +var SendableTypedArrayPrototype = SendableTypedArray.prototype; + +verifyProperty(SendableTypedArrayPrototype, 'values', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..502b692be44 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + SendableTypedArray.p.values behaves correctly on SendableTypedArrays backed by resizable + buffers and resized mid-iteration. +features: [resizable-arraybuffer] +includes: [compareArray.js, resizableArrayBufferUtils.js] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset + +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + // The fixed length array is not affected by resizing. + TestIterationAndResize(fixedLength.values(), [ + 0, + 2, + 4, + 6 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + // The fixed length array is not affected by resizing. + TestIterationAndResize(fixedLengthWithOffset.values(), [ + 4, + 6 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + TestIterationAndResize(lengthTracking.values(), [ + 0, + 2, + 4, + 6, + 0, + 0 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + TestIterationAndResize(lengthTrackingWithOffset.values(), [ + 4, + 6, + 0, + 0 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..a78a685f621 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + SendableTypedArray.p.values behaves correctly on SendableTypedArrays backed by resizable + buffers that are shrunk mid-iteration. +features: [resizable-arraybuffer] +includes: [compareArray.js, resizableArrayBufferUtils.js] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + + // The fixed length array goes out of bounds when the RAB is resized. + assert.throws(TypeError, () => { + TestIterationAndResize(fixedLength.values(), null, rab, 2, 3 * ctor.BYTES_PER_ELEMENT); + }); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + assert.throws(TypeError, () => { + TestIterationAndResize(fixedLengthWithOffset.values(), null, rab, 2, 3 * ctor.BYTES_PER_ELEMENT); + }); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + TestIterationAndResize(lengthTracking.values(), [ + 0, + 2, + 4 + ], rab, 2, 3 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // The fixed length array goes out of bounds when the RAB is resized. + TestIterationAndResize(lengthTrackingWithOffset.values(), [ + 4, + 6 + ], rab, 2, 3 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer.js new file mode 100644 index 00000000000..8f5dc0d5b11 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer.js @@ -0,0 +1,161 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + SendableTypedArray.p.values behaves correctly on SendableTypedArrays backed by resizable + buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function IteratorToNumbers(iterator) { + let result = []; + for (let value of iterator) { + result.push(Number(value)); + } + return result; +} + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + + assert.compareArray(IteratorToNumbers(fixedLength.values()), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(IteratorToNumbers(fixedLengthWithOffset.values()), [ + 4, + 6 + ]); + assert.compareArray(IteratorToNumbers(lengthTracking.values()), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(IteratorToNumbers(lengthTrackingWithOffset.values()), [ + 4, + 6 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + // SendableTypedArray.prototype.{entries, keys, values} throw right away when + // called. Array.prototype.{entries, keys, values} don't throw, but when + // we try to iterate the returned ArrayIterator, that throws. + assert.throws(TypeError, () => { + fixedLength.values(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.values(); + }); + + assert.compareArray(IteratorToNumbers(lengthTracking.values()), [ + 0, + 2, + 4 + ]); + assert.compareArray(IteratorToNumbers(lengthTrackingWithOffset.values()), [4]); + + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.throws(TypeError, () => { + fixedLength.values(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.values(); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.values(); + }); + + assert.compareArray(IteratorToNumbers(lengthTracking.values()), [0]); + + // Shrink to zero. + rab.resize(0); + assert.throws(TypeError, () => { + fixedLength.values(); + }); + assert.throws(TypeError, () => { + fixedLengthWithOffset.values(); + }); + assert.throws(TypeError, () => { + lengthTrackingWithOffset.values(); + }); + + assert.compareArray(IteratorToNumbers(lengthTracking.values()), []); + + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert.compareArray(IteratorToNumbers(fixedLength.values()), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(IteratorToNumbers(fixedLengthWithOffset.values()), [ + 4, + 6 + ]); + assert.compareArray(IteratorToNumbers(lengthTracking.values()), [ + 0, + 2, + 4, + 6, + 8, + 10 + ]); + assert.compareArray(IteratorToNumbers(lengthTrackingWithOffset.values()), [ + 4, + 6, + 8, + 10 + ]); +} diff --git a/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js new file mode 100644 index 00000000000..092b36f7e63 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: Return abrupt when "this" value fails buffer boundary checks +includes: [testTypedArray.js] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +---*/ + +assert.sameValue( + typeof SendableTypedArray.prototype.values, + 'function', + 'implements SendableTypedArray.prototype.values' +); + +assert.sameValue( + typeof ArrayBuffer.prototype.resize, + 'function', + 'implements ArrayBuffer.prototype.resize' +); + +testWithSendableTypedArrayConstructors(TA => { + var BPE = TA.BYTES_PER_ELEMENT; + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var array = new TA(ab, BPE, 2); + + try { + ab.resize(BPE * 5); + } catch (_) {} + + // no error following grow: + array.values(); + + try { + ab.resize(BPE * 3); + } catch (_) {} + + // no error following shrink (within bounds): + array.values(); + + var expectedError; + try { + ab.resize(BPE * 3 - 1); + // If the preceding "resize" operation is successful, the typed array will + // be out out of bounds, so the subsequent prototype method should produce + // a TypeError due to the semantics of ValidateSendableTypedArray. + expectedError = TypeError; + } catch (_) { + // The host is permitted to fail any "resize" operation at its own + // discretion. If that occurs, the values operation should complete + // successfully. + expectedError = Test262Error; + } + + assert.throws(expectedError, () => { + array.values(); + throw new Test262Error('values completed successfully'); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/values/return-itor.js b/test/sendable/builtins/TypedArray/prototype/values/return-itor.js new file mode 100644 index 00000000000..2ad3eb20f42 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/return-itor.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: Return an iterator for the values. +info: | + 22.2.3.30 %SendableTypedArray%.prototype.values ( ) + + ... + 3. Return CreateArrayIterator(O, "value"). +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var sample = [0, 42, 64]; + +testWithSendableTypedArrayConstructors(function(TA) { + var typedArray = new TA(sample); + var itor = typedArray.values(); + + var next = itor.next(); + assert.sameValue(next.value, 0); + assert.sameValue(next.done, false); + + next = itor.next(); + assert.sameValue(next.value, 42); + assert.sameValue(next.done, false); + + next = itor.next(); + assert.sameValue(next.value, 64); + assert.sameValue(next.done, false); + + next = itor.next(); + assert.sameValue(next.value, undefined); + assert.sameValue(next.done, true); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/values/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/values/this-is-not-object.js new file mode 100644 index 00000000000..56d42b8ebc0 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/this-is-not-object.js @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: Throws a TypeError exception when `this` is not Object +info: | + 22.2.3.30 %SendableTypedArray%.prototype.values ( ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + ... +includes: [testTypedArray.js] +features: [Symbol, TypedArray] +---*/ + +var values = SendableTypedArray.prototype.values; + +assert.throws(TypeError, function() { + values.call(undefined); +}, "this is undefined"); + +assert.throws(TypeError, function() { + values.call(null); +}, "this is null"); + +assert.throws(TypeError, function() { + values.call(42); +}, "this is 42"); + +assert.throws(TypeError, function() { + values.call("1"); +}, "this is a string"); + +assert.throws(TypeError, function() { + values.call(true); +}, "this is true"); + +assert.throws(TypeError, function() { + values.call(false); +}, "this is false"); + +var s = Symbol("s"); +assert.throws(TypeError, function() { + values.call(s); +}, "this is a Symbol"); diff --git a/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js new file mode 100644 index 00000000000..9b9247806c7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.values +description: > + Throws a TypeError exception when `this` is not a SendableTypedArray instance +info: | + 22.2.3.30 %SendableTypedArray%.prototype.values ( ) + + The following steps are taken: + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... + + 22.2.3.5.1 Runtime Semantics: ValidateSendableTypedArray ( O ) + + 1. If Type(O) is not Object, throw a TypeError exception. + 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError + exception. + ... +includes: [testTypedArray.js] +features: [TypedArray] +---*/ + +var values = SendableTypedArray.prototype.values; + +assert.throws(TypeError, function() { + values.call({}); +}, "this is an Object"); + +assert.throws(TypeError, function() { + values.call([]); +}, "this is an Array"); + +var ab = new ArrayBuffer(8); +assert.throws(TypeError, function() { + values.call(ab); +}, "this is an ArrayBuffer instance"); + +var dv = new DataView(new ArrayBuffer(8), 0, 1); +assert.throws(TypeError, function() { + values.call(dv); +}, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js b/test/sendable/builtins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js new file mode 100644 index 00000000000..81d8c392a4a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %SendableTypedArray%.prototype.with invokes ToNumber before copying +info: | + %SendableTypedArray%.prototype.with ( index, value ) + + ... + 7. If _O_.[[ContentType]] is ~BigInt~, set _value_ to ? ToBigInt(_value_). + 8. Else, set _value_ to ? ToNumber(_value_). + ... +features: [BigInt, SendableTypedArray, change-array-by-copy] +includes: [testBigIntSendableTypedArray.js, compareArray.js] +---*/ + +testWithBigIntSendableTypedArrayConstructors(function(TA) { + var arr = new TA([0n, 1n, 2n]); + + var value = { + valueOf() { + arr[0] = 3n; + return 4n; + } + }; + + assert.compareArray(arr.with(1, value), [3n, 4n, 2n]); + assert.compareArray(arr, [3n, 1n, 2n]); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js b/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js new file mode 100644 index 00000000000..9a13899400f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %SendableTypedArray%.prototype.with invokes ToNumber before copying +info: | + %SendableTypedArray%.prototype.with ( index, value ) + + ... + 7. If _O_.[[ContentType]] is ~BigInt~, set _value_ to ? ToBigInt(_value_). + 8. Else, set _value_ to ? ToNumber(_value_). + ... +features: [TypedArray, change-array-by-copy] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var arr = new TA([0, 1, 2]); + + var value = { + valueOf() { + arr[0] = 3; + return 4; + } + }; + + assert.compareArray(arr.with(1, value), [3, 4, 2]); + assert.compareArray(arr, [3, 1, 2]); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js b/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js new file mode 100644 index 00000000000..b8fe1569b24 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %SendableTypedArray%.prototype.with ignores @@species +info: | + %SendableTypedArray%.prototype.with ( index, value ) + + ... + 10. Let A be ? SendableTypedArrayCreateSameType(O, « 𝔽(len) »). + ... + + SendableTypedArrayCreateSameType ( exemplar, argumentList ) + ... + 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var ta = new TA([1, 2, 3]); + ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array; + assert.sameValue(Object.getPrototypeOf(ta.with(0, 2)), TA.prototype); + + ta = new TA([1, 2, 3]); + ta.constructor = { + [Symbol.species]: TA === Uint8Array ? Int32Array : Uint8Array, + }; + assert.sameValue(Object.getPrototypeOf(ta.with(0, 2)), TA.prototype); + + ta = new TA([1, 2, 3]); + Object.defineProperty(ta, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } + }); + ta.with(0, 2); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/with/immutable.js b/test/sendable/builtins/TypedArray/prototype/with/immutable.js new file mode 100644 index 00000000000..3672bf8559f --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/immutable.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %SendableTypedArray%.prototype.with does not mutate its this value +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + ta.with(0, 2); + + assert.compareArray(ta, [3, 1, 2]); + assert.notSameValue(ta.with(0, 2), ta); + assert.notSameValue(ta.with(0, 3), ta); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js b/test/sendable/builtins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js new file mode 100644 index 00000000000..834d7682fb1 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-typed%array%.prototype.with +description: > + %SendableTypedArray%.prototype.with throws if the index is bigger than or equal to the array length. +info: | + %SendableTypedArray%.prototype.with ( index, value ) + + ... + 3. Let len be O.[[ArrayLength]]. + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + 6. If ! IsValidIntegerIndex(O, actualIndex) is false, throw a *RangeError* exception. + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var arr = new TA([0, 1, 2]); + + assert.throws(RangeError, function() { + arr.with(3, 7); + }); + + assert.throws(RangeError, function() { + arr.with(10, 7); + }); + + assert.throws(RangeError, function() { + arr.with(2 ** 53 + 2, 7); + }); + + assert.throws(RangeError, function() { + arr.with(Infinity, 7); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js b/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js new file mode 100644 index 00000000000..f8da3926569 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %SendableTypedArray%.prototype.with casts the index to an integer. +info: | + %SendableTypedArray%.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + ... +features: [TypedArray, change-array-by-copy] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var arr = new TA([0, 4, 16]); + + assert.compareArray(arr.with(1.2, 7), [0, 7, 16]); + assert.compareArray(arr.with("1", 3), [0, 3, 16]); + assert.compareArray(arr.with("-1", 5), [0, 4, 5]); + assert.compareArray(arr.with(NaN, 2), [2, 4, 16]); + assert.compareArray(arr.with("dog", 33), [33, 4, 16]); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-negative.js b/test/sendable/builtins/TypedArray/prototype/with/index-negative.js new file mode 100644 index 00000000000..af5668c0662 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/index-negative.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %SendableTypedArray%.prototype.with adds length to index if it's negative. +info: | + %SendableTypedArray%.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + ... +features: [TypedArray, change-array-by-copy] +includes: [testTypedArray.js, compareArray.js] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var arr = new TA([0, 1, 2]); + + assert.compareArray(arr.with(-1, 4), [0, 1, 4]); + assert.compareArray(arr.with(-3, 4), [4, 1, 2]); + // -0 is not negative. + assert.compareArray(arr.with(-0, 4), [4, 1, 2]); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js b/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js new file mode 100644 index 00000000000..ca56c85a4e7 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %SendableTypedArray%.prototype.with throws if the (negative) index is smaller than -length. +info: | + %SendableTypedArray%.prototype.with ( index, value ) + + ... + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + 6. If actualIndex >= len or actualIndex < 0, throw a *RangeError* exception. + ... +features: [TypedArray, change-array-by-copy] +includes: [testTypedArray.js] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var arr = new TA([0, 1, 2]); + + assert.throws(RangeError, function() { + arr.with(-4, 7); + }); + + assert.throws(RangeError, function() { + arr.with(-10, 7); + }); + + assert.throws(RangeError, function() { + arr.with(-(2 ** 53) - 2, 7); + }); + + assert.throws(RangeError, function() { + arr.with(-Infinity, 7); + }); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-validated-against-current-length.js b/test/sendable/builtins/TypedArray/prototype/with/index-validated-against-current-length.js new file mode 100644 index 00000000000..730ade902df --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/index-validated-against-current-length.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + The index is validated against the current length. +info: | + %SendableTypedArray%.prototype.with ( index, value ) + + 1. Let O be the this value. + 2. Let taRecord be ? ValidateSendableTypedArray(O, SEQ-CST). + 3. Let len be SendableTypedArrayLength(taRecord). + ... + 8. Else, let numericValue be ? ToNumber(value). + ... + 10. Let A be ? SendableTypedArrayCreateSameType(O, « 𝔽(len) »). + ... + 13. Return A. + +features: [TypedArray, resizable-arraybuffer] +---*/ + +let rab = new ArrayBuffer(2, {maxByteLength: 5}); +let ta = new Int8Array(rab); + +ta[0] = 11; +ta[1] = 22; + +// Ensure typed array is correctly initialised. +assert.sameValue(ta.length, 2); +assert.sameValue(ta[0], 11); +assert.sameValue(ta[1], 22); + +// Index is initially out-of-bounds. +let index = 4; + +let value = { + valueOf() { + rab.resize(5); + return 123; + } +}; + +let result = ta.with(index, value); + +// Typed array has been resized. +assert.sameValue(ta.length, 5); +assert.sameValue(ta[0], 11); +assert.sameValue(ta[1], 22); +assert.sameValue(ta[2], 0); +assert.sameValue(ta[3], 0); +assert.sameValue(ta[4], 0); + +// Result is correctly initialised. +assert.sameValue(result.length, 2); +assert.sameValue(result[0], 11); +assert.sameValue(result[1], 22); diff --git a/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js b/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js new file mode 100644 index 00000000000..2dd5b44cbf2 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %SendableTypedArray%.prototype.with reads the SendableTypedArray length ignoring the .length property +info: | + %SendableTypedArray%.prototype.with ( index, value ) + + ... + 3. Let len be O.[[ArrayLength]]. + ... +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +testWithSendableTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + Object.defineProperty(ta, "length", { value: 2 }) + var res = ta.with(0, 0); + assert.compareArray(res, [0, 1, 2]); + assert.sameValue(res.length, 3); + + ta = new TA([3, 1, 2]); + Object.defineProperty(ta, "length", { value: 5 }); + res = ta.with(0, 0); + assert.compareArray(res, [0, 1, 2]); + assert.sameValue(res.length, 3); +}); + +function setLength(length) { + Object.defineProperty(SendableTypedArray.prototype, "length", { + get: () => length, + }); +} + +testWithSendableTypedArrayConstructors(TA => { + var ta = new TA([3, 1, 2]); + + setLength(2); + var res = ta.with(0, 0); + setLength(3); + assert.compareArray(res, [0, 1, 2]); + + setLength(5); + res = ta.with(0, 0); + setLength(3); + assert.compareArray(res, [0, 1, 2]); +}); diff --git a/test/sendable/builtins/TypedArray/prototype/with/metadata/length.js b/test/sendable/builtins/TypedArray/prototype/with/metadata/length.js new file mode 100644 index 00000000000..ab09ba9d50a --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/metadata/length.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + The "length" property of %SendableTypedArray%.prototype.with +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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: [testTypedArray.js, propertyHelper.js] +features: [TypedArray, change-array-by-copy] +---*/ + +verifyProperty(SendableTypedArray.prototype.with, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/TypedArray/prototype/with/metadata/name.js b/test/sendable/builtins/TypedArray/prototype/with/metadata/name.js new file mode 100644 index 00000000000..5b36339f6e8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/metadata/name.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %SendableTypedArray%.prototype.with.name is "with". +info: | + %SendableTypedArray%.prototype.with ( index, value ) + + 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: [testTypedArray.js, propertyHelper.js] +features: [TypedArray, change-array-by-copy] +---*/ + +verifyProperty(SendableTypedArray.prototype.with, "name", { + value: "with", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/TypedArray/prototype/with/metadata/property-descriptor.js b/test/sendable/builtins/TypedArray/prototype/with/metadata/property-descriptor.js new file mode 100644 index 00000000000..15cdf4da442 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/metadata/property-descriptor.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + "with" property of %SendableTypedArray%.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + 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: [testTypedArray.js, propertyHelper.js] +features: [TypedArray, change-array-by-copy] +---*/ + +assert.sameValue(typeof SendableTypedArray.prototype.with, "function", "typeof"); + +verifyProperty(SendableTypedArray.prototype, "with", { + value: SendableTypedArray.prototype.with, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/TypedArray/prototype/with/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/with/not-a-constructor.js new file mode 100644 index 00000000000..c2946f997d6 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + %SendableTypedArray%.prototype.with 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, testTypedArray.js] +features: [TypedArray, change-array-by-copy, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(SendableTypedArray.prototype.with), + false, + 'isConstructor(SendableTypedArray.prototype.with) must return false' +); + +assert.throws(TypeError, () => { + new SendableTypedArray.prototype.with(0, 1); +}, '`new %SendableTypedArray%.prototype.with()` throws TypeError'); + diff --git a/test/sendable/builtins/TypedArray/prototype/with/this-value-invalid.js b/test/sendable/builtins/TypedArray/prototype/with/this-value-invalid.js new file mode 100644 index 00000000000..fa16bfa3278 --- /dev/null +++ b/test/sendable/builtins/TypedArray/prototype/with/this-value-invalid.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-%typedarray%.prototype.with +description: > + %SendableTypedArray%.prototype.with throws if the receiver is null or undefined +info: | + %SendableTypedArray%.prototype.with ( index, value ) + + 1. Let O be the this value. + 2. Perform ? ValidateSendableTypedArray(O). + ... +includes: [testTypedArray.js] +features: [TypedArray, change-array-by-copy] +---*/ + +var invalidValues = { + 'null': null, + 'undefined': undefined, + 'true': true, + '"abc"': "abc", + '12': 12, + 'Symbol()': Symbol(), + '[1, 2, 3]': [1, 2, 3], + '{ 0: 1, 1: 2, 2: 3, length: 3 }': { 0: 1, 1: 2, 2: 3, length: 3 }, + 'Uint8Array.prototype': Uint8Array.prototype, +}; + +Object.keys(invalidValues).forEach(desc => { + var value = invalidValues[desc]; + assert.throws(TypeError, () => { + SendableTypedArray.prototype.with.call(value, 0, 0); + }, `${desc} is not a valid SendableTypedArray`); +}); diff --git a/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-1.js b/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-1.js new file mode 100644 index 00000000000..1824a1030dc --- /dev/null +++ b/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-1.js @@ -0,0 +1,70 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-arraybuffer-length +description: > + Basic functionality of length-tracking SendableTypedArrays backed by resizable + buffers +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +const rab = CreateResizableArrayBuffer(16, 40); +let tas = []; +for (let ctor of ctors) { + tas.push(new ctor(rab)); +} +for (let ta of tas) { + assert.sameValue(ta.length, 16 / ta.BYTES_PER_ELEMENT); + assert.sameValue(ta.byteLength, 16); +} +rab.resize(40); +for (let ta of tas) { + assert.sameValue(ta.length, 40 / ta.BYTES_PER_ELEMENT); + assert.sameValue(ta.byteLength, 40); +} +// Resize to a number which is not a multiple of all byte_lengths. +rab.resize(19); +for (let ta of tas) { + const expected_length = Math.floor(19 / ta.BYTES_PER_ELEMENT); + assert.sameValue(ta.length, expected_length); + assert.sameValue(ta.byteLength, expected_length * ta.BYTES_PER_ELEMENT); +} +rab.resize(1); +for (let ta of tas) { + if (ta.BYTES_PER_ELEMENT == 1) { + assert.sameValue(ta.length, 1); + assert.sameValue(ta.byteLength, 1); + } else { + assert.sameValue(ta.length, 0); + assert.sameValue(ta.byteLength, 0); + } +} +rab.resize(0); +for (let ta of tas) { + assert.sameValue(ta.length, 0); + assert.sameValue(ta.byteLength, 0); +} +rab.resize(8); +for (let ta of tas) { + assert.sameValue(ta.length, 8 / ta.BYTES_PER_ELEMENT); + assert.sameValue(ta.byteLength, 8); +} +rab.resize(40); +for (let ta of tas) { + assert.sameValue(ta.length, 40 / ta.BYTES_PER_ELEMENT); + assert.sameValue(ta.byteLength, 40); +} diff --git a/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-2.js b/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-2.js new file mode 100644 index 00000000000..80460496fd8 --- /dev/null +++ b/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-2.js @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-arraybuffer-length +description: > + Length-tracking SendableTypedArrays backed by resizable buffers with offsets + behave correctly +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// length-tracking-1 but with offsets. + +const rab = CreateResizableArrayBuffer(16, 40); +const offset = 8; +let tas = []; +for (let ctor of ctors) { + tas.push(new ctor(rab, offset)); +} +for (let ta of tas) { + assert.sameValue(ta.length, (16 - offset) / ta.BYTES_PER_ELEMENT); + assert.sameValue(ta.byteLength, 16 - offset); + assert.sameValue(ta.byteOffset, offset); +} +rab.resize(40); +for (let ta of tas) { + assert.sameValue(ta.length, (40 - offset) / ta.BYTES_PER_ELEMENT); + assert.sameValue(ta.byteLength, 40 - offset); + assert.sameValue(ta.byteOffset, offset); +} +// Resize to a number which is not a multiple of all byte_lengths. +rab.resize(20); +for (let ta of tas) { + const expected_length = Math.floor((20 - offset) / ta.BYTES_PER_ELEMENT); + assert.sameValue(ta.length, expected_length); + assert.sameValue(ta.byteLength, expected_length * ta.BYTES_PER_ELEMENT); + assert.sameValue(ta.byteOffset, offset); +} +// Resize so that all SendableTypedArrays go out of bounds (because of the offset). +rab.resize(7); +for (let ta of tas) { + assert.sameValue(ta.length, 0); + assert.sameValue(ta.byteLength, 0); + assert.sameValue(ta.byteOffset, 0); +} +rab.resize(0); +for (let ta of tas) { + assert.sameValue(ta.length, 0); + assert.sameValue(ta.byteLength, 0); + assert.sameValue(ta.byteOffset, 0); +} +rab.resize(8); +for (let ta of tas) { + assert.sameValue(ta.length, 0); + assert.sameValue(ta.byteLength, 0); + assert.sameValue(ta.byteOffset, offset); +} +// Resize so that the SendableTypedArrays which have element size > 1 go out of bounds +// (because less than 1 full element would fit). +rab.resize(offset + 1); +for (let ta of tas) { + if (ta.BYTES_PER_ELEMENT == 1) { + assert.sameValue(ta.length, 1); + assert.sameValue(ta.byteLength, 1); + assert.sameValue(ta.byteOffset, offset); + } else { + assert.sameValue(ta.length, 0); + assert.sameValue(ta.byteLength, 0); + assert.sameValue(ta.byteOffset, offset); + } +} +rab.resize(40); +for (let ta of tas) { + assert.sameValue(ta.length, (40 - offset) / ta.BYTES_PER_ELEMENT); + assert.sameValue(ta.byteLength, 40 - offset); + assert.sameValue(ta.byteOffset, offset); +} -- Gitee From 303188b32f880bc4ecc6c9c430c66d8afe4cad54 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 30 Dec 2024 10:19:27 +0800 Subject: [PATCH 50/93] update typedarray test header Signed-off-by: zhuzhihui7 --- .../prototype/apply/resizable-buffer.js | 2 +- .../TypedArray/from/arylk-get-length-error.js | 2 +- .../TypedArray/from/arylk-to-length-error.js | 2 +- .../from/from-array-mapper-detaches-result.js | 4 ++-- ...array-mapper-makes-result-out-of-bounds.js | 4 ++-- ...rray-into-itself-mapper-detaches-result.js | 4 ++-- ...tself-mapper-makes-result-out-of-bounds.js | 4 ++-- .../from-typedarray-mapper-detaches-result.js | 4 ++-- ...array-mapper-makes-result-out-of-bounds.js | 4 ++-- .../TypedArray/from/invoked-as-func.js | 2 +- .../TypedArray/from/invoked-as-method.js | 2 +- .../TypedArray/from/iter-access-error.js | 2 +- .../TypedArray/from/iter-invoke-error.js | 2 +- .../TypedArray/from/iter-next-error.js | 2 +- .../TypedArray/from/iter-next-value-error.js | 2 +- .../iterated-array-changed-by-tonumber.js | 2 +- .../builtins/TypedArray/from/length.js | 2 +- .../TypedArray/from/mapfn-is-not-callable.js | 2 +- .../from/this-is-not-constructor.js | 2 +- test/sendable/builtins/TypedArray/invoked.js | 4 ++-- test/sendable/builtins/TypedArray/length.js | 2 +- test/sendable/builtins/TypedArray/name.js | 2 +- .../TypedArray/of/invoked-as-method.js | 2 +- .../sendable/builtins/TypedArray/of/length.js | 2 +- ...ith-out-of-bounds-and-in-bounds-indices.js | 4 ++-- .../TypedArray/of/this-is-not-constructor.js | 2 +- .../out-of-bounds-behaves-like-detached.js | 2 +- .../TypedArray/out-of-bounds-get-and-set.js | 2 +- .../builtins/TypedArray/out-of-bounds-has.js | 2 +- .../sendable/builtins/TypedArray/prototype.js | 2 +- .../TypedArray/prototype/Symbol.iterator.js | 2 +- .../BigInt/detached-buffer.js | 2 +- .../BigInt/invoked-as-accessor.js | 2 +- .../BigInt/invoked-as-func.js | 2 +- .../Symbol.toStringTag/BigInt/length.js | 2 +- .../Symbol.toStringTag/BigInt/name.js | 2 +- .../Symbol.toStringTag/BigInt/prop-desc.js | 2 +- .../BigInt/return-typedarrayname.js | 2 +- .../this-has-no-typedarrayname-internal.js | 6 ++--- .../BigInt/this-is-not-object.js | 2 +- .../this-has-no-typedarrayname-internal.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../prototype/at/coerced-index-resize.js | 6 ++--- .../prototype/at/index-argument-tointeger.js | 2 +- ...-non-numeric-argument-tointeger-invalid.js | 2 +- .../index-non-numeric-argument-tointeger.js | 2 +- .../TypedArray/prototype/at/length.js | 2 +- .../builtins/TypedArray/prototype/at/name.js | 2 +- .../TypedArray/prototype/at/prop-desc.js | 2 +- .../prototype/at/resizable-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- .../prototype/at/return-abrupt-from-this.js | 2 +- .../at/returns-item-relative-index.js | 2 +- .../TypedArray/prototype/at/returns-item.js | 2 +- ...ns-undefined-for-holes-in-sparse-arrays.js | 2 +- ...eturns-undefined-for-out-of-range-index.js | 2 +- .../buffer/BigInt/detached-buffer.js | 6 ++--- .../prototype/buffer/BigInt/return-buffer.js | 8 +++---- .../prototype/buffer/detached-buffer.js | 4 ++-- .../prototype/buffer/invoked-as-accessor.js | 4 ++-- .../prototype/buffer/invoked-as-func.js | 2 +- .../prototype/buffer/return-buffer.js | 6 ++--- .../this-has-no-typedarrayname-internal.js | 4 ++-- .../byteLength/BigInt/detached-buffer.js | 4 ++-- .../BigInt/resizable-array-buffer-auto.js | 12 +++++----- .../BigInt/resizable-array-buffer-fixed.js | 12 +++++----- .../byteLength/BigInt/return-bytelength.js | 2 +- .../prototype/byteLength/detached-buffer.js | 2 +- .../byteLength/invoked-as-accessor.js | 4 ++-- .../prototype/byteLength/invoked-as-func.js | 2 +- .../byteLength/resizable-array-buffer-auto.js | 8 +++---- .../resizable-array-buffer-fixed.js | 8 +++---- .../byteLength/resizable-buffer-assorted.js | 2 +- .../byteLength/resized-out-of-bounds-1.js | 2 +- .../byteLength/resized-out-of-bounds-2.js | 2 +- .../this-has-no-typedarrayname-internal.js | 4 ++-- .../byteOffset/BigInt/detached-buffer.js | 6 ++--- .../BigInt/resizable-array-buffer-auto.js | 12 +++++----- .../BigInt/resizable-array-buffer-fixed.js | 12 +++++----- .../byteOffset/BigInt/return-byteoffset.js | 6 ++--- .../prototype/byteOffset/detached-buffer.js | 4 ++-- .../byteOffset/invoked-as-accessor.js | 4 ++-- .../prototype/byteOffset/invoked-as-func.js | 2 +- .../byteOffset/resizable-array-buffer-auto.js | 8 +++---- .../resizable-array-buffer-fixed.js | 8 +++---- .../byteOffset/resized-out-of-bounds.js | 2 +- .../prototype/byteOffset/return-byteoffset.js | 4 ++-- .../this-has-no-typedarrayname-internal.js | 4 ++-- .../TypedArray/prototype/constructor.js | 2 +- .../copyWithin/BigInt/coerced-values-end.js | 4 ++-- .../copyWithin/BigInt/coerced-values-start.js | 4 ++-- .../BigInt/coerced-values-target.js | 4 ++-- .../copyWithin/BigInt/detached-buffer.js | 4 ++-- .../BigInt/get-length-ignores-length-prop.js | 4 ++-- .../copyWithin/BigInt/negative-end.js | 4 ++-- .../BigInt/negative-out-of-bounds-end.js | 4 ++-- .../BigInt/negative-out-of-bounds-start.js | 4 ++-- .../BigInt/negative-out-of-bounds-target.js | 4 ++-- .../copyWithin/BigInt/negative-start.js | 4 ++-- .../copyWithin/BigInt/negative-target.js | 4 ++-- .../BigInt/non-negative-out-of-bounds-end.js | 4 ++-- ...negative-out-of-bounds-target-and-start.js | 4 ++-- .../BigInt/non-negative-target-and-start.js | 4 ++-- .../non-negative-target-start-and-end.js | 4 ++-- .../return-abrupt-from-end-is-symbol.js | 4 ++-- .../BigInt/return-abrupt-from-end.js | 4 ++-- .../return-abrupt-from-start-is-symbol.js | 4 ++-- .../BigInt/return-abrupt-from-start.js | 4 ++-- .../return-abrupt-from-target-is-symbol.js | 4 ++-- .../BigInt/return-abrupt-from-target.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../copyWithin/BigInt/return-this.js | 4 ++-- .../copyWithin/BigInt/undefined-end.js | 4 ++-- .../prototype/copyWithin/bit-precision.js | 2 +- .../prototype/copyWithin/byteoffset.js | 2 +- .../coerced-target-start-end-shrink.js | 6 ++--- .../copyWithin/coerced-target-start-grow.js | 2 +- .../coerced-values-end-detached-prototype.js | 4 ++-- .../copyWithin/coerced-values-end-detached.js | 4 ++-- .../copyWithin/coerced-values-end.js | 2 +- .../coerced-values-start-detached.js | 4 ++-- .../copyWithin/coerced-values-start.js | 2 +- .../copyWithin/coerced-values-target.js | 2 +- .../prototype/copyWithin/detached-buffer.js | 2 +- .../get-length-ignores-length-prop.js | 2 +- .../prototype/copyWithin/invoked-as-func.js | 2 +- .../prototype/copyWithin/invoked-as-method.js | 2 +- .../TypedArray/prototype/copyWithin/length.js | 2 +- .../TypedArray/prototype/copyWithin/name.js | 2 +- .../prototype/copyWithin/negative-end.js | 2 +- .../copyWithin/negative-out-of-bounds-end.js | 2 +- .../negative-out-of-bounds-start.js | 2 +- .../negative-out-of-bounds-target.js | 2 +- .../prototype/copyWithin/negative-start.js | 2 +- .../prototype/copyWithin/negative-target.js | 2 +- .../non-negative-out-of-bounds-end.js | 2 +- ...negative-out-of-bounds-target-and-start.js | 2 +- .../non-negative-target-and-start.js | 2 +- .../non-negative-target-start-and-end.js | 2 +- .../prototype/copyWithin/prop-desc.js | 2 +- .../prototype/copyWithin/resizable-buffer.js | 4 ++-- .../return-abrupt-from-end-is-symbol.js | 2 +- .../copyWithin/return-abrupt-from-end.js | 2 +- .../return-abrupt-from-start-is-symbol.js | 2 +- .../copyWithin/return-abrupt-from-start.js | 2 +- .../return-abrupt-from-target-is-symbol.js | 2 +- .../copyWithin/return-abrupt-from-target.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- .../prototype/copyWithin/return-this.js | 2 +- .../copyWithin/this-is-not-object.js | 2 +- .../this-is-not-typedarray-instance.js | 8 +++---- .../prototype/copyWithin/undefined-end.js | 2 +- .../entries/BigInt/detached-buffer.js | 4 ++-- .../entries/BigInt/iter-prototype.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../prototype/entries/BigInt/return-itor.js | 4 ++-- .../prototype/entries/detached-buffer.js | 2 +- .../prototype/entries/invoked-as-func.js | 2 +- .../prototype/entries/invoked-as-method.js | 2 +- .../prototype/entries/iter-prototype.js | 2 +- .../TypedArray/prototype/entries/length.js | 2 +- .../TypedArray/prototype/entries/name.js | 2 +- .../TypedArray/prototype/entries/prop-desc.js | 2 +- .../resizable-buffer-grow-mid-iteration.js | 2 +- .../resizable-buffer-shrink-mid-iteration.js | 2 +- .../prototype/entries/resizable-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- .../prototype/entries/return-itor.js | 2 +- .../prototype/entries/this-is-not-object.js | 2 +- .../this-is-not-typedarray-instance.js | 8 +++---- .../callbackfn-arguments-with-thisarg.js | 4 ++-- .../callbackfn-arguments-without-thisarg.js | 4 ++-- .../every/BigInt/callbackfn-detachbuffer.js | 4 ++-- ...lbackfn-no-interaction-over-non-integer.js | 4 ++-- .../BigInt/callbackfn-not-callable-throws.js | 4 ++-- .../BigInt/callbackfn-not-called-on-empty.js | 4 ++-- ...lbackfn-return-does-not-change-instance.js | 4 ++-- .../every/BigInt/callbackfn-returns-abrupt.js | 4 ++-- ...callbackfn-set-value-during-interaction.js | 4 ++-- .../prototype/every/BigInt/callbackfn-this.js | 4 ++-- .../prototype/every/BigInt/detached-buffer.js | 4 ++-- .../get-length-uses-internal-arraylength.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../returns-false-if-any-cb-returns-false.js | 4 ++-- .../returns-true-if-every-cb-returns-true.js | 4 ++-- .../every/BigInt/values-are-not-cached.js | 4 ++-- .../callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../every/callbackfn-detachbuffer.js | 2 +- ...lbackfn-no-interaction-over-non-integer.js | 2 +- .../every/callbackfn-not-callable-throws.js | 2 +- .../every/callbackfn-not-called-on-empty.js | 2 +- .../prototype/every/callbackfn-resize.js | 8 +++---- ...lbackfn-return-does-not-change-instance.js | 2 +- .../every/callbackfn-returns-abrupt.js | 2 +- ...callbackfn-set-value-during-interaction.js | 2 +- .../prototype/every/callbackfn-this.js | 2 +- .../prototype/every/detached-buffer.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../prototype/every/invoked-as-func.js | 2 +- .../prototype/every/invoked-as-method.js | 2 +- .../TypedArray/prototype/every/length.js | 2 +- .../TypedArray/prototype/every/name.js | 2 +- .../TypedArray/prototype/every/prop-desc.js | 2 +- .../resizable-buffer-grow-mid-iteration.js | 2 +- .../resizable-buffer-shrink-mid-iteration.js | 2 +- .../prototype/every/resizable-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- .../returns-false-if-any-cb-returns-false.js | 2 +- .../returns-true-if-every-cb-returns-true.js | 2 +- .../prototype/every/this-is-not-object.js | 2 +- .../every/this-is-not-typedarray-instance.js | 8 +++---- .../prototype/every/values-are-not-cached.js | 2 +- .../prototype/fill/BigInt/coerced-indexes.js | 4 ++-- .../prototype/fill/BigInt/detached-buffer.js | 4 ++-- .../BigInt/fill-values-conversion-once.js | 4 ++-- .../fill-values-custom-start-and-end.js | 4 ++-- .../BigInt/fill-values-non-numeric-throw.js | 8 +++---- .../fill/BigInt/fill-values-non-numeric.js | 8 +++---- .../fill/BigInt/fill-values-relative-end.js | 4 ++-- .../fill/BigInt/fill-values-relative-start.js | 4 ++-- .../fill/BigInt/fill-values-symbol-throws.js | 8 +++---- .../prototype/fill/BigInt/fill-values.js | 4 ++-- .../BigInt/get-length-ignores-length-prop.js | 4 ++-- .../return-abrupt-from-end-as-symbol.js | 4 ++-- .../fill/BigInt/return-abrupt-from-end.js | 4 ++-- .../BigInt/return-abrupt-from-set-value.js | 8 +++---- .../return-abrupt-from-start-as-symbol.js | 4 ++-- .../fill/BigInt/return-abrupt-from-start.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../prototype/fill/BigInt/return-this.js | 4 ++-- ...nt-indices-computed-from-initial-length.js | 4 ++-- .../prototype/fill/coerced-end-detach.js | 4 ++-- .../prototype/fill/coerced-indexes.js | 2 +- .../prototype/fill/coerced-start-detach.js | 4 ++-- .../prototype/fill/coerced-value-detach.js | 4 ++-- .../fill/coerced-value-start-end-resize.js | 8 +++---- .../prototype/fill/detached-buffer.js | 2 +- .../fill/fill-values-conversion-once.js | 2 +- ...es-conversion-operations-consistent-nan.js | 2 +- .../fill/fill-values-conversion-operations.js | 2 +- .../fill/fill-values-custom-start-and-end.js | 2 +- .../prototype/fill/fill-values-non-numeric.js | 6 ++--- .../fill/fill-values-relative-end.js | 2 +- .../fill/fill-values-relative-start.js | 2 +- .../fill/fill-values-symbol-throws.js | 6 ++--- .../TypedArray/prototype/fill/fill-values.js | 2 +- .../fill/get-length-ignores-length-prop.js | 2 +- .../prototype/fill/invoked-as-func.js | 2 +- .../prototype/fill/invoked-as-method.js | 2 +- .../TypedArray/prototype/fill/length.js | 2 +- .../TypedArray/prototype/fill/name.js | 2 +- .../TypedArray/prototype/fill/prop-desc.js | 2 +- .../prototype/fill/resizable-buffer.js | 4 ++-- .../fill/return-abrupt-from-end-as-symbol.js | 2 +- .../prototype/fill/return-abrupt-from-end.js | 2 +- .../fill/return-abrupt-from-set-value.js | 6 ++--- .../return-abrupt-from-start-as-symbol.js | 2 +- .../fill/return-abrupt-from-start.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- .../TypedArray/prototype/fill/return-this.js | 2 +- .../prototype/fill/this-is-not-object.js | 2 +- .../fill/this-is-not-typedarray-instance.js | 8 +++---- .../filter/BigInt/arraylength-internal.js | 4 ++-- .../callbackfn-arguments-with-thisarg.js | 4 ++-- .../callbackfn-arguments-without-thisarg.js | 4 ++-- .../BigInt/callbackfn-called-before-ctor.js | 4 ++-- .../callbackfn-called-before-species.js | 4 ++-- .../filter/BigInt/callbackfn-detachbuffer.js | 4 ++-- ...allbackfn-no-iteration-over-non-integer.js | 4 ++-- .../BigInt/callbackfn-not-callable-throws.js | 4 ++-- .../BigInt/callbackfn-not-called-on-empty.js | 4 ++-- ...lbackfn-return-does-not-change-instance.js | 4 ++-- .../BigInt/callbackfn-returns-abrupt.js | 4 ++-- .../callbackfn-set-value-during-iteration.js | 4 ++-- .../filter/BigInt/callbackfn-this.js | 4 ++-- .../filter/BigInt/detached-buffer.js | 4 ++-- .../BigInt/result-does-not-share-buffer.js | 4 ++-- .../result-empty-callbackfn-returns-false.js | 4 ++-- .../result-full-callbackfn-returns-true.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../speciesctor-destination-resizable.js | 8 +++---- .../BigInt/speciesctor-get-ctor-abrupt.js | 4 ++-- .../BigInt/speciesctor-get-ctor-inherited.js | 4 ++-- .../speciesctor-get-ctor-returns-throws.js | 4 ++-- .../filter/BigInt/speciesctor-get-ctor.js | 4 ++-- .../BigInt/speciesctor-get-species-abrupt.js | 4 ++-- ...ctor-get-species-custom-ctor-invocation.js | 4 ++-- ...tor-length-throws-resizable-arraybuffer.js | 6 ++--- ...r-get-species-custom-ctor-length-throws.js | 4 ++-- ...ciesctor-get-species-custom-ctor-length.js | 4 ++-- ...es-custom-ctor-returns-another-instance.js | 4 ++-- ...ciesctor-get-species-custom-ctor-throws.js | 4 ++-- .../speciesctor-get-species-custom-ctor.js | 4 ++-- .../speciesctor-get-species-returns-throws.js | 4 ++-- ...peciesctor-get-species-use-default-ctor.js | 4 ++-- .../filter/BigInt/speciesctor-get-species.js | 4 ++-- .../filter/BigInt/values-are-not-cached.js | 4 ++-- .../prototype/filter/BigInt/values-are-set.js | 4 ++-- .../prototype/filter/arraylength-internal.js | 2 +- .../callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../filter/callbackfn-called-before-ctor.js | 2 +- .../callbackfn-called-before-species.js | 2 +- .../filter/callbackfn-detachbuffer.js | 2 +- ...allbackfn-no-iteration-over-non-integer.js | 2 +- .../filter/callbackfn-not-callable-throws.js | 2 +- .../filter/callbackfn-not-called-on-empty.js | 2 +- .../prototype/filter/callbackfn-resize.js | 8 +++---- ...lbackfn-return-does-not-change-instance.js | 2 +- .../filter/callbackfn-returns-abrupt.js | 2 +- .../callbackfn-set-value-during-iteration.js | 2 +- .../prototype/filter/callbackfn-this.js | 2 +- .../prototype/filter/detached-buffer.js | 2 +- .../prototype/filter/invoked-as-func.js | 2 +- .../prototype/filter/invoked-as-method.js | 2 +- .../TypedArray/prototype/filter/length.js | 2 +- .../TypedArray/prototype/filter/name.js | 2 +- .../TypedArray/prototype/filter/prop-desc.js | 2 +- .../resizable-buffer-grow-mid-iteration.js | 2 +- .../resizable-buffer-shrink-mid-iteration.js | 2 +- .../prototype/filter/resizable-buffer.js | 4 ++-- .../filter/result-does-not-share-buffer.js | 2 +- .../result-empty-callbackfn-returns-false.js | 2 +- .../result-full-callbackfn-returns-true.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- .../speciesctor-destination-resizable.js | 6 ++--- .../filter/speciesctor-get-ctor-abrupt.js | 2 +- .../filter/speciesctor-get-ctor-inherited.js | 2 +- .../speciesctor-get-ctor-returns-throws.js | 2 +- .../prototype/filter/speciesctor-get-ctor.js | 2 +- .../filter/speciesctor-get-species-abrupt.js | 2 +- ...ctor-get-species-custom-ctor-invocation.js | 2 +- ...tor-length-throws-resizable-arraybuffer.js | 4 ++-- ...r-get-species-custom-ctor-length-throws.js | 2 +- ...ciesctor-get-species-custom-ctor-length.js | 2 +- ...es-custom-ctor-returns-another-instance.js | 2 +- ...ciesctor-get-species-custom-ctor-throws.js | 2 +- .../speciesctor-get-species-custom-ctor.js | 2 +- .../speciesctor-get-species-returns-throws.js | 2 +- ...peciesctor-get-species-use-default-ctor.js | 2 +- .../filter/speciesctor-get-species.js | 2 +- .../prototype/filter/this-is-not-object.js | 2 +- .../filter/this-is-not-typedarray-instance.js | 8 +++---- .../prototype/filter/values-are-not-cached.js | 2 +- .../prototype/filter/values-are-set.js | 2 +- .../prototype/find/BigInt/detached-buffer.js | 4 ++-- .../BigInt/get-length-ignores-length-prop.js | 4 ++-- .../BigInt/predicate-call-changes-value.js | 4 ++-- .../find/BigInt/predicate-call-parameters.js | 4 ++-- .../BigInt/predicate-call-this-non-strict.js | 4 ++-- .../find/BigInt/predicate-call-this-strict.js | 4 ++-- .../predicate-is-not-callable-throws.js | 4 ++-- .../BigInt/predicate-may-detach-buffer.js | 6 ++--- .../predicate-not-called-on-empty-array.js | 4 ++-- .../return-abrupt-from-predicate-call.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- ...rn-found-value-predicate-result-is-true.js | 4 ++-- ...efined-if-predicate-returns-false-value.js | 4 ++-- .../prototype/find/callbackfn-resize.js | 8 +++---- .../prototype/find/detached-buffer.js | 2 +- .../find/get-length-ignores-length-prop.js | 2 +- .../prototype/find/invoked-as-func.js | 2 +- .../prototype/find/invoked-as-method.js | 2 +- .../TypedArray/prototype/find/length.js | 2 +- .../TypedArray/prototype/find/name.js | 2 +- .../find/predicate-call-changes-value.js | 2 +- .../find/predicate-call-parameters.js | 2 +- .../find/predicate-call-this-non-strict.js | 2 +- .../find/predicate-call-this-strict.js | 2 +- .../find/predicate-is-not-callable-throws.js | 2 +- .../find/predicate-may-detach-buffer.js | 4 ++-- .../predicate-not-called-on-empty-array.js | 2 +- .../TypedArray/prototype/find/prop-desc.js | 2 +- .../resizable-buffer-grow-mid-iteration.js | 2 +- .../resizable-buffer-shrink-mid-iteration.js | 2 +- .../prototype/find/resizable-buffer.js | 4 ++-- .../find/return-abrupt-from-predicate-call.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- ...rn-found-value-predicate-result-is-true.js | 2 +- ...efined-if-predicate-returns-false-value.js | 2 +- .../prototype/find/this-is-not-object.js | 2 +- .../find/this-is-not-typedarray-instance.js | 8 +++---- .../findIndex/BigInt/detached-buffer.js | 4 ++-- .../BigInt/get-length-ignores-length-prop.js | 4 ++-- .../BigInt/predicate-call-changes-value.js | 4 ++-- .../BigInt/predicate-call-parameters.js | 4 ++-- .../BigInt/predicate-call-this-non-strict.js | 4 ++-- .../BigInt/predicate-call-this-strict.js | 4 ++-- .../predicate-is-not-callable-throws.js | 4 ++-- .../BigInt/predicate-may-detach-buffer.js | 6 ++--- .../predicate-not-called-on-empty-array.js | 4 ++-- .../return-abrupt-from-predicate-call.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../return-index-predicate-result-is-true.js | 4 ++-- ...ve-one-if-predicate-returns-false-value.js | 4 ++-- .../prototype/findIndex/callbackfn-resize.js | 8 +++---- .../prototype/findIndex/detached-buffer.js | 2 +- .../get-length-ignores-length-prop.js | 2 +- .../prototype/findIndex/invoked-as-func.js | 2 +- .../prototype/findIndex/invoked-as-method.js | 2 +- .../TypedArray/prototype/findIndex/length.js | 2 +- .../TypedArray/prototype/findIndex/name.js | 2 +- .../findIndex/predicate-call-changes-value.js | 2 +- .../findIndex/predicate-call-parameters.js | 2 +- .../predicate-call-this-non-strict.js | 2 +- .../findIndex/predicate-call-this-strict.js | 2 +- .../predicate-is-not-callable-throws.js | 2 +- .../findIndex/predicate-may-detach-buffer.js | 4 ++-- .../predicate-not-called-on-empty-array.js | 2 +- .../prototype/findIndex/prop-desc.js | 2 +- .../resizable-buffer-grow-mid-iteration.js | 2 +- .../resizable-buffer-shrink-mid-iteration.js | 2 +- .../prototype/findIndex/resizable-buffer.js | 4 ++-- .../return-abrupt-from-predicate-call.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- .../return-index-predicate-result-is-true.js | 2 +- ...ve-one-if-predicate-returns-false-value.js | 2 +- .../prototype/findIndex/this-is-not-object.js | 2 +- .../this-is-not-typedarray-instance.js | 8 +++---- .../findLast/BigInt/detached-buffer.js | 4 ++-- .../BigInt/get-length-ignores-length-prop.js | 4 ++-- .../BigInt/predicate-call-changes-value.js | 4 ++-- .../BigInt/predicate-call-parameters.js | 4 ++-- .../BigInt/predicate-call-this-non-strict.js | 4 ++-- .../BigInt/predicate-call-this-strict.js | 4 ++-- .../predicate-is-not-callable-throws.js | 4 ++-- .../BigInt/predicate-may-detach-buffer.js | 6 ++--- .../predicate-not-called-on-empty-array.js | 4 ++-- .../return-abrupt-from-predicate-call.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- ...rn-found-value-predicate-result-is-true.js | 4 ++-- ...efined-if-predicate-returns-false-value.js | 4 ++-- .../prototype/findLast/callbackfn-resize.js | 8 +++---- .../prototype/findLast/detached-buffer.js | 2 +- .../get-length-ignores-length-prop.js | 2 +- .../prototype/findLast/invoked-as-func.js | 2 +- .../prototype/findLast/invoked-as-method.js | 2 +- .../TypedArray/prototype/findLast/length.js | 2 +- .../TypedArray/prototype/findLast/name.js | 2 +- .../findLast/predicate-call-changes-value.js | 2 +- .../findLast/predicate-call-parameters.js | 2 +- .../predicate-call-this-non-strict.js | 2 +- .../findLast/predicate-call-this-strict.js | 2 +- .../predicate-is-not-callable-throws.js | 2 +- .../findLast/predicate-may-detach-buffer.js | 4 ++-- .../predicate-not-called-on-empty-array.js | 2 +- .../prototype/findLast/prop-desc.js | 2 +- .../resizable-buffer-grow-mid-iteration.js | 2 +- .../resizable-buffer-shrink-mid-iteration.js | 2 +- .../prototype/findLast/resizable-buffer.js | 4 ++-- .../return-abrupt-from-predicate-call.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- ...rn-found-value-predicate-result-is-true.js | 2 +- ...efined-if-predicate-returns-false-value.js | 2 +- .../prototype/findLast/this-is-not-object.js | 2 +- .../this-is-not-typedarray-instance.js | 8 +++---- .../findLastIndex/BigInt/detached-buffer.js | 4 ++-- .../BigInt/get-length-ignores-length-prop.js | 4 ++-- .../BigInt/predicate-call-changes-value.js | 4 ++-- .../BigInt/predicate-call-parameters.js | 4 ++-- .../BigInt/predicate-call-this-non-strict.js | 4 ++-- .../BigInt/predicate-call-this-strict.js | 4 ++-- .../predicate-is-not-callable-throws.js | 4 ++-- .../BigInt/predicate-may-detach-buffer.js | 6 ++--- .../predicate-not-called-on-empty-array.js | 4 ++-- .../return-abrupt-from-predicate-call.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../return-index-predicate-result-is-true.js | 4 ++-- ...ve-one-if-predicate-returns-false-value.js | 4 ++-- .../findLastIndex/callbackfn-resize.js | 8 +++---- .../findLastIndex/detached-buffer.js | 2 +- .../get-length-ignores-length-prop.js | 2 +- .../findLastIndex/invoked-as-func.js | 2 +- .../findLastIndex/invoked-as-method.js | 2 +- .../prototype/findLastIndex/length.js | 2 +- .../prototype/findLastIndex/name.js | 2 +- .../predicate-call-changes-value.js | 2 +- .../predicate-call-parameters.js | 2 +- .../predicate-call-this-non-strict.js | 2 +- .../predicate-call-this-strict.js | 2 +- .../predicate-is-not-callable-throws.js | 2 +- .../predicate-may-detach-buffer.js | 4 ++-- .../predicate-not-called-on-empty-array.js | 2 +- .../prototype/findLastIndex/prop-desc.js | 2 +- .../resizable-buffer-grow-mid-iteration.js | 2 +- .../resizable-buffer-shrink-mid-iteration.js | 2 +- .../findLastIndex/resizable-buffer.js | 4 ++-- .../return-abrupt-from-predicate-call.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- .../return-index-predicate-result-is-true.js | 2 +- ...ve-one-if-predicate-returns-false-value.js | 2 +- .../findLastIndex/this-is-not-object.js | 2 +- .../this-is-not-typedarray-instance.js | 8 +++---- .../forEach/BigInt/arraylength-internal.js | 4 ++-- .../callbackfn-arguments-with-thisarg.js | 4 ++-- .../callbackfn-arguments-without-thisarg.js | 4 ++-- .../forEach/BigInt/callbackfn-detachbuffer.js | 4 ++-- .../BigInt/callbackfn-is-not-callable.js | 4 ++-- ...lbackfn-no-interaction-over-non-integer.js | 4 ++-- .../BigInt/callbackfn-not-called-on-empty.js | 4 ++-- ...lbackfn-return-does-not-change-instance.js | 4 ++-- .../BigInt/callbackfn-returns-abrupt.js | 4 ++-- ...callbackfn-set-value-during-interaction.js | 4 ++-- .../forEach/BigInt/callbackfn-this.js | 4 ++-- .../forEach/BigInt/detached-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../forEach/BigInt/returns-undefined.js | 4 ++-- .../forEach/BigInt/values-are-not-cached.js | 4 ++-- .../prototype/forEach/arraylength-internal.js | 2 +- .../callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../forEach/callbackfn-detachbuffer.js | 2 +- .../forEach/callbackfn-is-not-callable.js | 2 +- ...lbackfn-no-interaction-over-non-integer.js | 2 +- .../forEach/callbackfn-not-called-on-empty.js | 2 +- .../prototype/forEach/callbackfn-resize.js | 8 +++---- ...lbackfn-return-does-not-change-instance.js | 2 +- .../forEach/callbackfn-returns-abrupt.js | 2 +- ...callbackfn-set-value-during-interaction.js | 2 +- .../prototype/forEach/callbackfn-this.js | 2 +- .../prototype/forEach/detached-buffer.js | 2 +- .../prototype/forEach/invoked-as-func.js | 2 +- .../prototype/forEach/invoked-as-method.js | 2 +- .../TypedArray/prototype/forEach/length.js | 2 +- .../TypedArray/prototype/forEach/name.js | 2 +- .../TypedArray/prototype/forEach/prop-desc.js | 2 +- .../resizable-buffer-grow-mid-iteration.js | 2 +- .../resizable-buffer-shrink-mid-iteration.js | 2 +- .../prototype/forEach/resizable-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- .../prototype/forEach/returns-undefined.js | 2 +- .../prototype/forEach/this-is-not-object.js | 2 +- .../this-is-not-typedarray-instance.js | 8 +++---- .../forEach/values-are-not-cached.js | 2 +- ...during-fromIndex-returns-false-for-zero.js | 4 ++-- ...ng-fromIndex-returns-true-for-undefined.js | 4 ++-- .../includes/BigInt/detached-buffer.js | 4 ++-- ...x-equal-or-greater-length-returns-false.js | 4 ++-- .../includes/BigInt/fromIndex-infinity.js | 4 ++-- .../includes/BigInt/fromIndex-minus-zero.js | 4 ++-- .../get-length-uses-internal-arraylength.js | 4 ++-- .../BigInt/length-zero-returns-false.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- ...eturn-abrupt-tointeger-fromindex-symbol.js | 4 ++-- .../return-abrupt-tointeger-fromindex.js | 4 ++-- .../BigInt/search-found-returns-true.js | 4 ++-- .../BigInt/search-not-found-returns-false.js | 4 ++-- .../includes/BigInt/tointeger-fromindex.js | 4 ++-- .../coerced-searchelement-fromindex-resize.js | 12 +++++----- ...during-fromIndex-returns-false-for-zero.js | 2 +- ...ng-fromIndex-returns-true-for-undefined.js | 2 +- .../prototype/includes/detached-buffer.js | 2 +- ...x-equal-or-greater-length-returns-false.js | 2 +- .../prototype/includes/fromIndex-infinity.js | 2 +- .../includes/fromIndex-minus-zero.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- ...ed-against-initial-length-out-of-bounds.js | 4 ++-- .../index-compared-against-initial-length.js | 4 ++-- .../prototype/includes/invoked-as-func.js | 2 +- .../prototype/includes/invoked-as-method.js | 2 +- .../includes/length-zero-returns-false.js | 2 +- .../TypedArray/prototype/includes/length.js | 2 +- .../TypedArray/prototype/includes/name.js | 2 +- .../prototype/includes/prop-desc.js | 2 +- .../resizable-buffer-special-float-values.js | 4 ++-- .../prototype/includes/resizable-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- ...eturn-abrupt-tointeger-fromindex-symbol.js | 2 +- .../return-abrupt-tointeger-fromindex.js | 2 +- .../prototype/includes/samevaluezero.js | 2 +- .../includes/search-found-returns-true.js | 2 +- .../search-not-found-returns-false.js | 2 +- .../includes/searchelement-not-integer.js | 2 +- .../prototype/includes/this-is-not-object.js | 2 +- .../this-is-not-typedarray-instance.js | 8 +++---- .../prototype/includes/tointeger-fromindex.js | 2 +- ...omIndex-returns-minus-one-for-undefined.js | 4 ++-- ...ng-fromIndex-returns-minus-one-for-zero.js | 4 ++-- .../indexOf/BigInt/detached-buffer.js | 4 ++-- ...ual-or-greater-length-returns-minus-one.js | 4 ++-- .../indexOf/BigInt/fromIndex-infinity.js | 4 ++-- .../indexOf/BigInt/fromIndex-minus-zero.js | 4 ++-- .../get-length-uses-internal-arraylength.js | 4 ++-- .../BigInt/length-zero-returns-minus-one.js | 4 ++-- .../prototype/indexOf/BigInt/no-arg.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- ...eturn-abrupt-tointeger-fromindex-symbol.js | 4 ++-- .../return-abrupt-tointeger-fromindex.js | 4 ++-- .../BigInt/search-found-returns-index.js | 4 ++-- .../search-not-found-returns-minus-one.js | 4 ++-- .../indexOf/BigInt/tointeger-fromindex.js | 4 ++-- .../coerced-searchelement-fromindex-grow.js | 6 ++--- .../coerced-searchelement-fromindex-shrink.js | 8 +++---- ...omIndex-returns-minus-one-for-undefined.js | 2 +- ...ng-fromIndex-returns-minus-one-for-zero.js | 2 +- .../prototype/indexOf/detached-buffer.js | 2 +- ...ual-or-greater-length-returns-minus-one.js | 2 +- .../prototype/indexOf/fromIndex-infinity.js | 2 +- .../prototype/indexOf/fromIndex-minus-zero.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../prototype/indexOf/invoked-as-func.js | 2 +- .../prototype/indexOf/invoked-as-method.js | 2 +- .../indexOf/length-zero-returns-minus-one.js | 2 +- .../TypedArray/prototype/indexOf/length.js | 2 +- .../TypedArray/prototype/indexOf/name.js | 2 +- .../TypedArray/prototype/indexOf/no-arg.js | 2 +- .../TypedArray/prototype/indexOf/prop-desc.js | 2 +- .../resizable-buffer-special-float-values.js | 4 ++-- .../prototype/indexOf/resizable-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- ...eturn-abrupt-tointeger-fromindex-symbol.js | 2 +- .../return-abrupt-tointeger-fromindex.js | 2 +- .../indexOf/search-found-returns-index.js | 2 +- .../search-not-found-returns-minus-one.js | 2 +- .../prototype/indexOf/strict-comparison.js | 2 +- .../prototype/indexOf/this-is-not-object.js | 2 +- .../this-is-not-typedarray-instance.js | 8 +++---- .../prototype/indexOf/tointeger-fromindex.js | 2 +- ...sult-from-tostring-on-each-simple-value.js | 4 ++-- ...r-during-fromIndex-returns-single-comma.js | 4 ++-- .../prototype/join/BigInt/detached-buffer.js | 4 ++-- .../BigInt/empty-instance-empty-string.js | 4 ++-- .../get-length-uses-internal-arraylength.js | 4 ++-- ...sult-from-tostring-on-each-simple-value.js | 4 ++-- .../return-abrupt-from-separator-symbol.js | 4 ++-- .../BigInt/return-abrupt-from-separator.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../prototype/join/coerced-separator-grow.js | 6 ++--- .../join/coerced-separator-shrink.js | 6 ++--- ...sult-from-tostring-on-each-simple-value.js | 2 +- ...ator-result-from-tostring-on-each-value.js | 2 +- ...r-during-fromIndex-returns-single-comma.js | 2 +- .../prototype/join/detached-buffer.js | 2 +- .../join/empty-instance-empty-string.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../prototype/join/invoked-as-func.js | 2 +- .../prototype/join/invoked-as-method.js | 2 +- .../TypedArray/prototype/join/length.js | 2 +- .../TypedArray/prototype/join/name.js | 2 +- .../TypedArray/prototype/join/prop-desc.js | 2 +- .../prototype/join/resizable-buffer.js | 4 ++-- ...sult-from-tostring-on-each-simple-value.js | 2 +- .../result-from-tostring-on-each-value.js | 2 +- .../return-abrupt-from-separator-symbol.js | 2 +- .../join/return-abrupt-from-separator.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- .../separator-tostring-once-after-resized.js | 4 ++-- .../prototype/join/this-is-not-object.js | 2 +- .../join/this-is-not-typedarray-instance.js | 8 +++---- .../prototype/keys/BigInt/detached-buffer.js | 4 ++-- .../prototype/keys/BigInt/iter-prototype.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../prototype/keys/BigInt/return-itor.js | 4 ++-- .../prototype/keys/detached-buffer.js | 2 +- .../prototype/keys/invoked-as-func.js | 2 +- .../prototype/keys/invoked-as-method.js | 2 +- .../prototype/keys/iter-prototype.js | 2 +- .../TypedArray/prototype/keys/length.js | 2 +- .../TypedArray/prototype/keys/name.js | 2 +- .../TypedArray/prototype/keys/prop-desc.js | 2 +- .../resizable-buffer-grow-mid-iteration.js | 2 +- .../resizable-buffer-shrink-mid-iteration.js | 2 +- .../prototype/keys/resizable-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- .../TypedArray/prototype/keys/return-itor.js | 2 +- .../prototype/keys/this-is-not-object.js | 2 +- .../keys/this-is-not-typedarray-instance.js | 8 +++---- ...omIndex-returns-minus-one-for-undefined.js | 4 ++-- ...ng-fromIndex-returns-minus-one-for-zero.js | 4 ++-- .../lastIndexOf/BigInt/detached-buffer.js | 4 ++-- .../lastIndexOf/BigInt/fromIndex-infinity.js | 4 ++-- .../BigInt/fromIndex-minus-zero.js | 4 ++-- .../get-length-uses-internal-arraylength.js | 4 ++-- .../BigInt/length-zero-returns-minus-one.js | 4 ++-- .../prototype/lastIndexOf/BigInt/no-arg.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- ...eturn-abrupt-tointeger-fromindex-symbol.js | 4 ++-- .../return-abrupt-tointeger-fromindex.js | 4 ++-- .../BigInt/search-found-returns-index.js | 4 ++-- .../search-not-found-returns-minus-one.js | 4 ++-- .../lastIndexOf/BigInt/tointeger-fromindex.js | 4 ++-- .../lastIndexOf/coerced-position-grow.js | 6 ++--- .../lastIndexOf/coerced-position-shrink.js | 8 +++---- ...omIndex-returns-minus-one-for-undefined.js | 2 +- ...ng-fromIndex-returns-minus-one-for-zero.js | 2 +- .../prototype/lastIndexOf/detached-buffer.js | 2 +- .../lastIndexOf/fromIndex-infinity.js | 2 +- .../lastIndexOf/fromIndex-minus-zero.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../prototype/lastIndexOf/invoked-as-func.js | 2 +- .../lastIndexOf/invoked-as-method.js | 2 +- .../length-zero-returns-minus-one.js | 2 +- .../prototype/lastIndexOf/length.js | 2 +- .../TypedArray/prototype/lastIndexOf/name.js | 2 +- .../prototype/lastIndexOf/no-arg.js | 2 +- .../prototype/lastIndexOf/prop-desc.js | 2 +- .../resizable-buffer-special-float-values.js | 4 ++-- .../prototype/lastIndexOf/resizable-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 10 ++++----- ...eturn-abrupt-tointeger-fromindex-symbol.js | 2 +- .../return-abrupt-tointeger-fromindex.js | 2 +- .../lastIndexOf/search-found-returns-index.js | 2 +- .../search-not-found-returns-minus-one.js | 2 +- .../lastIndexOf/strict-comparison.js | 2 +- .../lastIndexOf/this-is-not-object.js | 2 +- .../this-is-not-typedarray-instance.js | 8 +++---- .../lastIndexOf/tointeger-fromindex.js | 2 +- .../length/BigInt/detached-buffer.js | 4 ++-- .../BigInt/resizable-array-buffer-auto.js | 12 +++++----- .../BigInt/resizable-array-buffer-fixed.js | 12 +++++----- .../prototype/length/BigInt/return-length.js | 2 +- .../prototype/length/detached-buffer.js | 2 +- .../prototype/length/invoked-as-accessor.js | 2 +- .../length/resizable-array-buffer-auto.js | 8 +++---- .../length/resizable-array-buffer-fixed.js | 8 +++---- .../length/resizable-buffer-assorted.js | 2 +- .../length/resized-out-of-bounds-1.js | 2 +- .../length/resized-out-of-bounds-2.js | 2 +- .../this-has-no-typedarrayname-internal.js | 4 ++-- .../map/BigInt/arraylength-internal.js | 4 ++-- .../callbackfn-arguments-with-thisarg.js | 4 ++-- .../callbackfn-arguments-without-thisarg.js | 4 ++-- .../map/BigInt/callbackfn-detachbuffer.js | 4 ++-- .../map/BigInt/callbackfn-is-not-callable.js | 4 ++-- ...interaction-over-non-integer-properties.js | 4 ++-- .../BigInt/callbackfn-not-called-on-empty.js | 4 ++-- ...llbackfn-return-affects-returned-object.js | 4 ++-- ...lbackfn-return-does-not-change-instance.js | 4 ++-- ...rn-does-not-copy-non-integer-properties.js | 4 ++-- .../map/BigInt/callbackfn-returns-abrupt.js | 4 ++-- ...callbackfn-set-value-during-interaction.js | 4 ++-- .../prototype/map/BigInt/callbackfn-this.js | 4 ++-- .../prototype/map/BigInt/detached-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- ...return-new-typedarray-from-empty-length.js | 4 ++-- ...urn-new-typedarray-from-positive-length.js | 4 ++-- .../speciesctor-destination-resizable.js | 8 +++---- .../map/BigInt/speciesctor-get-ctor-abrupt.js | 4 ++-- .../BigInt/speciesctor-get-ctor-inherited.js | 4 ++-- .../speciesctor-get-ctor-returns-throws.js | 4 ++-- .../map/BigInt/speciesctor-get-ctor.js | 4 ++-- .../BigInt/speciesctor-get-species-abrupt.js | 4 ++-- ...ctor-get-species-custom-ctor-invocation.js | 4 ++-- ...tor-length-throws-resizable-arraybuffer.js | 6 ++--- ...r-get-species-custom-ctor-length-throws.js | 4 ++-- ...ciesctor-get-species-custom-ctor-length.js | 4 ++-- ...es-custom-ctor-returns-another-instance.js | 4 ++-- ...ciesctor-get-species-custom-ctor-throws.js | 4 ++-- .../speciesctor-get-species-custom-ctor.js | 4 ++-- .../speciesctor-get-species-returns-throws.js | 4 ++-- ...peciesctor-get-species-use-default-ctor.js | 4 ++-- .../map/BigInt/speciesctor-get-species.js | 4 ++-- .../map/BigInt/values-are-not-cached.js | 4 ++-- .../prototype/map/arraylength-internal.js | 2 +- .../map/callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../prototype/map/callbackfn-detachbuffer.js | 2 +- .../map/callbackfn-is-not-callable.js | 2 +- ...interaction-over-non-integer-properties.js | 2 +- .../map/callbackfn-not-called-on-empty.js | 2 +- .../prototype/map/callbackfn-resize.js | 8 +++---- ...llbackfn-return-affects-returned-object.js | 2 +- ...lbackfn-return-does-not-change-instance.js | 2 +- ...rn-does-not-copy-non-integer-properties.js | 2 +- .../map/callbackfn-returns-abrupt.js | 2 +- ...callbackfn-set-value-during-interaction.js | 2 +- .../prototype/map/callbackfn-this.js | 2 +- .../prototype/map/detached-buffer.js | 2 +- .../prototype/map/invoked-as-func.js | 2 +- .../prototype/map/invoked-as-method.js | 2 +- .../TypedArray/prototype/map/length.js | 2 +- .../builtins/TypedArray/prototype/map/name.js | 2 +- .../TypedArray/prototype/map/prop-desc.js | 2 +- .../resizable-buffer-grow-mid-iteration.js | 2 +- .../resizable-buffer-shrink-mid-iteration.js | 2 +- .../prototype/map/resizable-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 10 ++++----- ...ray-conversion-operation-consistent-nan.js | 4 ++-- ...urn-new-typedarray-conversion-operation.js | 4 ++-- ...return-new-typedarray-from-empty-length.js | 2 +- ...urn-new-typedarray-from-positive-length.js | 2 +- .../map/speciesctor-destination-resizable.js | 6 ++--- .../map/speciesctor-get-ctor-abrupt.js | 2 +- .../map/speciesctor-get-ctor-inherited.js | 2 +- .../speciesctor-get-ctor-returns-throws.js | 2 +- .../prototype/map/speciesctor-get-ctor.js | 2 +- .../map/speciesctor-get-species-abrupt.js | 2 +- ...ctor-get-species-custom-ctor-invocation.js | 2 +- ...tor-length-throws-resizable-arraybuffer.js | 4 ++-- ...r-get-species-custom-ctor-length-throws.js | 2 +- ...ciesctor-get-species-custom-ctor-length.js | 2 +- ...es-custom-ctor-returns-another-instance.js | 2 +- ...ciesctor-get-species-custom-ctor-throws.js | 2 +- .../speciesctor-get-species-custom-ctor.js | 2 +- .../speciesctor-get-species-returns-throws.js | 2 +- ...peciesctor-get-species-use-default-ctor.js | 2 +- .../prototype/map/speciesctor-get-species.js | 2 +- .../map/speciesctor-resizable-buffer-grow.js | 6 ++--- .../speciesctor-resizable-buffer-shrink.js | 6 ++--- .../prototype/map/this-is-not-object.js | 2 +- .../map/this-is-not-typedarray-instance.js | 8 +++---- .../prototype/map/values-are-not-cached.js | 2 +- ...callbackfn-arguments-custom-accumulator.js | 4 ++-- ...allbackfn-arguments-default-accumulator.js | 4 ++-- .../reduce/BigInt/callbackfn-detachbuffer.js | 4 ++-- .../callbackfn-is-not-callable-throws.js | 4 ++-- ...o-iteration-over-non-integer-properties.js | 4 ++-- .../BigInt/callbackfn-not-called-on-empty.js | 4 ++-- ...lbackfn-return-does-not-change-instance.js | 4 ++-- .../BigInt/callbackfn-returns-abrupt.js | 4 ++-- .../callbackfn-set-value-during-iteration.js | 4 ++-- .../reduce/BigInt/callbackfn-this.js | 4 ++-- .../reduce/BigInt/detached-buffer.js | 4 ++-- .../empty-instance-return-initialvalue.js | 4 ++-- ...ty-instance-with-no-initialvalue-throws.js | 4 ++-- .../get-length-uses-internal-arraylength.js | 4 ++-- .../result-is-last-callbackfn-return.js | 4 ++-- .../reduce/BigInt/result-of-any-type.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../return-first-value-without-callbackfn.js | 4 ++-- .../reduce/BigInt/values-are-not-cached.js | 4 ++-- ...callbackfn-arguments-custom-accumulator.js | 2 +- ...allbackfn-arguments-default-accumulator.js | 2 +- .../reduce/callbackfn-detachbuffer.js | 2 +- .../callbackfn-is-not-callable-throws.js | 2 +- ...o-iteration-over-non-integer-properties.js | 2 +- .../reduce/callbackfn-not-called-on-empty.js | 2 +- .../prototype/reduce/callbackfn-resize.js | 4 ++-- ...lbackfn-return-does-not-change-instance.js | 2 +- .../reduce/callbackfn-returns-abrupt.js | 2 +- .../callbackfn-set-value-during-iteration.js | 2 +- .../prototype/reduce/callbackfn-this.js | 2 +- .../prototype/reduce/detached-buffer.js | 2 +- .../empty-instance-return-initialvalue.js | 2 +- ...ty-instance-with-no-initialvalue-throws.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../prototype/reduce/invoked-as-func.js | 2 +- .../prototype/reduce/invoked-as-method.js | 2 +- .../TypedArray/prototype/reduce/length.js | 2 +- .../TypedArray/prototype/reduce/name.js | 2 +- .../TypedArray/prototype/reduce/prop-desc.js | 2 +- .../resizable-buffer-grow-mid-iteration.js | 2 +- .../resizable-buffer-shrink-mid-iteration.js | 2 +- .../prototype/reduce/resizable-buffer.js | 4 ++-- .../result-is-last-callbackfn-return.js | 2 +- .../prototype/reduce/result-of-any-type.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 ++++----- .../return-first-value-without-callbackfn.js | 2 +- .../prototype/reduce/this-is-not-object.js | 2 +- .../reduce/this-is-not-typedarray-instance.js | 8 +++---- .../prototype/reduce/values-are-not-cached.js | 2 +- ...callbackfn-arguments-custom-accumulator.js | 4 ++-- ...allbackfn-arguments-default-accumulator.js | 4 ++-- .../BigInt/callbackfn-detachbuffer.js | 4 ++-- .../callbackfn-is-not-callable-throws.js | 4 ++-- ...o-iteration-over-non-integer-properties.js | 4 ++-- .../BigInt/callbackfn-not-called-on-empty.js | 4 ++-- ...lbackfn-return-does-not-change-instance.js | 4 ++-- .../BigInt/callbackfn-returns-abrupt.js | 4 ++-- .../callbackfn-set-value-during-iteration.js | 4 ++-- .../reduceRight/BigInt/callbackfn-this.js | 4 ++-- .../reduceRight/BigInt/detached-buffer.js | 4 ++-- .../empty-instance-return-initialvalue.js | 4 ++-- ...ty-instance-with-no-initialvalue-throws.js | 4 ++-- .../get-length-uses-internal-arraylength.js | 4 ++-- .../result-is-last-callbackfn-return.js | 4 ++-- .../reduceRight/BigInt/result-of-any-type.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../return-first-value-without-callbackfn.js | 4 ++-- .../BigInt/values-are-not-cached.js | 4 ++-- ...callbackfn-arguments-custom-accumulator.js | 2 +- ...allbackfn-arguments-default-accumulator.js | 2 +- .../reduceRight/callbackfn-detachbuffer.js | 2 +- .../callbackfn-is-not-callable-throws.js | 2 +- ...o-iteration-over-non-integer-properties.js | 2 +- .../callbackfn-not-called-on-empty.js | 2 +- .../reduceRight/callbackfn-resize.js | 4 ++-- ...lbackfn-return-does-not-change-instance.js | 2 +- .../reduceRight/callbackfn-returns-abrupt.js | 2 +- .../callbackfn-set-value-during-iteration.js | 2 +- .../prototype/reduceRight/callbackfn-this.js | 2 +- .../prototype/reduceRight/detached-buffer.js | 2 +- .../empty-instance-return-initialvalue.js | 2 +- ...ty-instance-with-no-initialvalue-throws.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../prototype/reduceRight/invoked-as-func.js | 2 +- .../reduceRight/invoked-as-method.js | 2 +- .../prototype/reduceRight/length.js | 2 +- .../TypedArray/prototype/reduceRight/name.js | 2 +- .../prototype/reduceRight/prop-desc.js | 2 +- .../resizable-buffer-grow-mid-iteration.js | 2 +- .../resizable-buffer-shrink-mid-iteration.js | 2 +- .../prototype/reduceRight/resizable-buffer.js | 4 ++-- .../result-is-last-callbackfn-return.js | 2 +- .../reduceRight/result-of-any-type.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 ++++----- .../return-first-value-without-callbackfn.js | 2 +- .../reduceRight/this-is-not-object.js | 2 +- .../this-is-not-typedarray-instance.js | 8 +++---- .../reduceRight/values-are-not-cached.js | 2 +- ...resizable-and-fixed-have-same-prototype.js | 6 ++--- .../reverse/BigInt/detached-buffer.js | 4 ++-- .../get-length-uses-internal-arraylength.js | 4 ++-- .../preserves-non-numeric-properties.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../reverse/BigInt/returns-original-object.js | 6 ++--- .../prototype/reverse/BigInt/reverts.js | 6 ++--- .../prototype/reverse/detached-buffer.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../prototype/reverse/invoked-as-func.js | 2 +- .../prototype/reverse/invoked-as-method.js | 2 +- .../TypedArray/prototype/reverse/length.js | 2 +- .../TypedArray/prototype/reverse/name.js | 2 +- .../preserves-non-numeric-properties.js | 2 +- .../TypedArray/prototype/reverse/prop-desc.js | 2 +- .../prototype/reverse/resizable-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 8 +++---- .../reverse/returns-original-object.js | 4 ++-- .../TypedArray/prototype/reverse/reverts.js | 4 ++-- .../prototype/reverse/this-is-not-object.js | 2 +- .../this-is-not-typedarray-instance.js | 8 +++---- ...rray-arg-negative-integer-offset-throws.js | 4 ++-- .../set/BigInt/array-arg-offset-tointeger.js | 4 ++-- .../BigInt/array-arg-primitive-toobject.js | 4 ++-- ...y-arg-return-abrupt-from-src-get-length.js | 4 ++-- ...ay-arg-return-abrupt-from-src-get-value.js | 4 ++-- ...rg-return-abrupt-from-src-length-symbol.js | 4 ++-- ...array-arg-return-abrupt-from-src-length.js | 4 ++-- ...n-abrupt-from-src-tonumber-value-symbol.js | 4 ++-- ...g-return-abrupt-from-src-tonumber-value.js | 4 ++-- ...urn-abrupt-from-tointeger-offset-symbol.js | 4 ++-- ...arg-return-abrupt-from-tointeger-offset.js | 4 ++-- ...-arg-return-abrupt-from-toobject-offset.js | 4 ++-- .../BigInt/array-arg-set-values-in-order.js | 4 ++-- .../set/BigInt/array-arg-set-values.js | 4 ++-- ...arg-src-tonumber-value-type-conversions.js | 4 ++-- .../array-arg-src-values-are-not-cached.js | 4 ++-- .../array-arg-target-arraylength-internal.js | 4 ++-- ...fer-detached-on-tointeger-offset-throws.js | 6 ++--- .../array-arg-targetbuffer-detached-throws.js | 6 ++--- .../prototype/set/BigInt/bigint-tobigint64.js | 2 +- .../set/BigInt/bigint-tobiguint64.js | 2 +- .../prototype/set/BigInt/boolean-tobigint.js | 4 ++-- .../prototype/set/BigInt/null-tobigint.js | 4 ++-- .../prototype/set/BigInt/number-tobigint.js | 4 ++-- .../set/BigInt/src-typedarray-big.js | 4 ++-- .../BigInt/src-typedarray-not-big-throws.js | 4 ++-- .../set/BigInt/string-nan-tobigint.js | 4 ++-- .../prototype/set/BigInt/string-tobigint.js | 4 ++-- .../prototype/set/BigInt/symbol-tobigint.js | 4 ++-- ...rray-arg-negative-integer-offset-throws.js | 4 ++-- .../BigInt/typedarray-arg-offset-tointeger.js | 4 ++-- ...urn-abrupt-from-tointeger-offset-symbol.js | 4 ++-- ...arg-return-abrupt-from-tointeger-offset.js | 4 ++-- ...g-set-values-diff-buffer-other-type-sab.js | 22 +++++++++---------- ...y-arg-set-values-diff-buffer-other-type.js | 4 ++-- ...rg-set-values-diff-buffer-same-type-sab.js | 22 +++++++++---------- ...ay-arg-set-values-diff-buffer-same-type.js | 4 ++-- ...et-values-same-buffer-same-type-resized.js | 12 +++++----- ...rg-set-values-same-buffer-same-type-sab.js | 12 +++++----- ...ay-arg-set-values-same-buffer-same-type.js | 10 ++++----- ...typedarray-arg-src-arraylength-internal.js | 4 ++-- .../typedarray-arg-src-byteoffset-internal.js | 4 ++-- ...-greather-than-target-throws-rangeerror.js | 4 ++-- ...detached-during-tointeger-offset-throws.js | 6 ++--- ...edarray-arg-target-arraylength-internal.js | 4 ++-- ...pedarray-arg-target-byteoffset-internal.js | 4 ++-- .../typedarray-arg-target-out-of-bounds.js | 12 +++++----- ...detached-during-tointeger-offset-throws.js | 6 ++--- .../set/BigInt/undefined-tobigint.js | 4 ++-- ...rray-arg-negative-integer-offset-throws.js | 2 +- .../set/array-arg-offset-tointeger.js | 2 +- .../set/array-arg-primitive-toobject.js | 2 +- ...y-arg-return-abrupt-from-src-get-length.js | 2 +- ...ay-arg-return-abrupt-from-src-get-value.js | 2 +- ...rg-return-abrupt-from-src-length-symbol.js | 2 +- ...array-arg-return-abrupt-from-src-length.js | 2 +- ...n-abrupt-from-src-tonumber-value-symbol.js | 2 +- ...g-return-abrupt-from-src-tonumber-value.js | 2 +- ...urn-abrupt-from-tointeger-offset-symbol.js | 2 +- ...arg-return-abrupt-from-tointeger-offset.js | 2 +- ...-arg-return-abrupt-from-toobject-offset.js | 2 +- .../set/array-arg-set-values-in-order.js | 2 +- .../prototype/set/array-arg-set-values.js | 2 +- ...rray-arg-src-tonumber-value-conversions.js | 2 +- ...arg-src-tonumber-value-type-conversions.js | 2 +- .../array-arg-src-values-are-not-cached.js | 2 +- .../array-arg-target-arraylength-internal.js | 2 +- ...ffer-detached-on-get-src-value-no-throw.js | 2 +- ...fer-detached-on-tointeger-offset-throws.js | 4 ++-- .../array-arg-targetbuffer-detached-throws.js | 4 ++-- ...g-value-conversion-resizes-array-buffer.js | 2 +- .../TypedArray/prototype/set/bit-precision.js | 2 +- .../prototype/set/invoked-as-func.js | 2 +- .../prototype/set/invoked-as-method.js | 2 +- .../TypedArray/prototype/set/length.js | 2 +- .../builtins/TypedArray/prototype/set/name.js | 2 +- .../TypedArray/prototype/set/prop-desc.js | 2 +- .../set/src-typedarray-big-throws.js | 4 ++-- .../set/target-grow-mid-iteration.js | 2 +- .../set/target-grow-source-length-getter.js | 2 +- .../set/target-shrink-mid-iteration.js | 2 +- .../set/target-shrink-source-length-getter.js | 2 +- .../set/this-backed-by-resizable-buffer.js | 4 ++-- .../prototype/set/this-is-not-object.js | 2 +- .../set/this-is-not-typedarray-instance.js | 14 ++++++------ ...rray-arg-negative-integer-offset-throws.js | 2 +- .../set/typedarray-arg-offset-tointeger.js | 2 +- ...urn-abrupt-from-tointeger-offset-symbol.js | 2 +- ...arg-return-abrupt-from-tointeger-offset.js | 2 +- ...-diff-buffer-other-type-conversions-sab.js | 12 +++++----- ...lues-diff-buffer-other-type-conversions.js | 2 +- ...g-set-values-diff-buffer-other-type-sab.js | 20 ++++++++--------- ...y-arg-set-values-diff-buffer-other-type.js | 2 +- ...rg-set-values-diff-buffer-same-type-sab.js | 20 ++++++++--------- ...ay-arg-set-values-diff-buffer-same-type.js | 2 +- ...y-arg-set-values-same-buffer-other-type.js | 8 +++---- ...et-values-same-buffer-same-type-resized.js | 10 ++++----- ...rg-set-values-same-buffer-same-type-sab.js | 10 ++++----- ...ay-arg-set-values-same-buffer-same-type.js | 8 +++---- ...typedarray-arg-src-arraylength-internal.js | 2 +- ...rray-arg-src-backed-by-resizable-buffer.js | 6 ++--- .../typedarray-arg-src-byteoffset-internal.js | 2 +- ...-greather-than-target-throws-rangeerror.js | 2 +- ...detached-during-tointeger-offset-throws.js | 4 ++-- ...edarray-arg-target-arraylength-internal.js | 2 +- ...pedarray-arg-target-byteoffset-internal.js | 2 +- .../typedarray-arg-target-out-of-bounds.js | 10 ++++----- ...detached-during-tointeger-offset-throws.js | 4 ++-- .../slice/BigInt/arraylength-internal.js | 4 ++-- ...hed-buffer-custom-ctor-other-targettype.js | 10 ++++----- ...ched-buffer-custom-ctor-same-targettype.js | 10 ++++----- .../slice/BigInt/detached-buffer-get-ctor.js | 10 ++++----- ...ciesctor-get-species-custom-ctor-throws.js | 8 +++---- ...zero-count-custom-ctor-other-targettype.js | 4 ++-- ...-zero-count-custom-ctor-same-targettype.js | 4 ++-- .../prototype/slice/BigInt/detached-buffer.js | 4 ++-- .../prototype/slice/BigInt/infinity.js | 4 ++-- .../prototype/slice/BigInt/minus-zero.js | 4 ++-- ...esult-does-not-copy-ordinary-properties.js | 4 ++-- .../BigInt/results-with-different-length.js | 4 ++-- .../slice/BigInt/results-with-empty-length.js | 4 ++-- .../slice/BigInt/results-with-same-length.js | 4 ++-- .../BigInt/return-abrupt-from-end-symbol.js | 4 ++-- .../slice/BigInt/return-abrupt-from-end.js | 4 ++-- .../BigInt/return-abrupt-from-start-symbol.js | 4 ++-- .../slice/BigInt/return-abrupt-from-start.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../set-values-from-different-ctor-type.js | 4 ++-- .../speciesctor-destination-resizable.js | 8 +++---- .../BigInt/speciesctor-get-ctor-abrupt.js | 4 ++-- .../BigInt/speciesctor-get-ctor-inherited.js | 4 ++-- .../speciesctor-get-ctor-returns-throws.js | 4 ++-- .../slice/BigInt/speciesctor-get-ctor.js | 4 ++-- .../BigInt/speciesctor-get-species-abrupt.js | 4 ++-- ...ctor-get-species-custom-ctor-invocation.js | 4 ++-- ...tor-length-throws-resizable-arraybuffer.js | 6 ++--- ...r-get-species-custom-ctor-length-throws.js | 4 ++-- ...ciesctor-get-species-custom-ctor-length.js | 4 ++-- ...es-custom-ctor-returns-another-instance.js | 4 ++-- ...ciesctor-get-species-custom-ctor-throws.js | 4 ++-- .../speciesctor-get-species-custom-ctor.js | 4 ++-- .../speciesctor-get-species-returns-throws.js | 4 ++-- ...peciesctor-get-species-use-default-ctor.js | 4 ++-- .../slice/BigInt/speciesctor-get-species.js | 4 ++-- .../prototype/slice/BigInt/tointeger-end.js | 4 ++-- .../prototype/slice/BigInt/tointeger-start.js | 4 ++-- .../prototype/slice/arraylength-internal.js | 2 +- .../prototype/slice/bit-precision.js | 2 +- .../prototype/slice/coerced-start-end-grow.js | 6 ++--- .../slice/coerced-start-end-shrink.js | 10 ++++----- ...hed-buffer-custom-ctor-other-targettype.js | 6 ++--- ...ched-buffer-custom-ctor-same-targettype.js | 6 ++--- .../slice/detached-buffer-get-ctor.js | 6 ++--- ...ciesctor-get-species-custom-ctor-throws.js | 6 ++--- ...zero-count-custom-ctor-other-targettype.js | 2 +- ...-zero-count-custom-ctor-same-targettype.js | 2 +- .../prototype/slice/detached-buffer.js | 2 +- .../TypedArray/prototype/slice/infinity.js | 2 +- .../prototype/slice/invoked-as-func.js | 2 +- .../prototype/slice/invoked-as-method.js | 2 +- .../TypedArray/prototype/slice/length.js | 2 +- .../TypedArray/prototype/slice/minus-zero.js | 2 +- .../TypedArray/prototype/slice/name.js | 2 +- .../TypedArray/prototype/slice/prop-desc.js | 2 +- .../prototype/slice/resizable-buffer.js | 4 ++-- ...esult-does-not-copy-ordinary-properties.js | 2 +- .../slice/results-with-different-length.js | 2 +- .../slice/results-with-empty-length.js | 2 +- .../slice/results-with-same-length.js | 2 +- .../slice/return-abrupt-from-end-symbol.js | 2 +- .../prototype/slice/return-abrupt-from-end.js | 2 +- .../slice/return-abrupt-from-start-symbol.js | 2 +- .../slice/return-abrupt-from-start.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 ++++----- .../set-values-from-different-ctor-type.js | 2 +- .../speciesctor-destination-resizable.js | 6 ++--- .../slice/speciesctor-get-ctor-abrupt.js | 2 +- .../slice/speciesctor-get-ctor-inherited.js | 2 +- .../speciesctor-get-ctor-returns-throws.js | 2 +- .../prototype/slice/speciesctor-get-ctor.js | 2 +- .../slice/speciesctor-get-species-abrupt.js | 2 +- ...ctor-get-species-custom-ctor-invocation.js | 2 +- ...tor-length-throws-resizable-arraybuffer.js | 4 ++-- ...r-get-species-custom-ctor-length-throws.js | 2 +- ...ciesctor-get-species-custom-ctor-length.js | 2 +- ...es-custom-ctor-returns-another-instance.js | 2 +- ...ciesctor-get-species-custom-ctor-throws.js | 2 +- .../speciesctor-get-species-custom-ctor.js | 2 +- .../speciesctor-get-species-returns-throws.js | 2 +- ...peciesctor-get-species-use-default-ctor.js | 2 +- .../slice/speciesctor-get-species.js | 2 +- .../prototype/slice/speciesctor-resize.js | 10 ++++----- .../prototype/slice/this-is-not-object.js | 2 +- .../slice/this-is-not-typedarray-instance.js | 8 +++---- .../prototype/slice/tointeger-end.js | 2 +- .../prototype/slice/tointeger-start.js | 2 +- .../callbackfn-arguments-with-thisarg.js | 4 ++-- .../callbackfn-arguments-without-thisarg.js | 4 ++-- .../some/BigInt/callbackfn-detachbuffer.js | 4 ++-- ...lbackfn-no-interaction-over-non-integer.js | 4 ++-- .../BigInt/callbackfn-not-callable-throws.js | 4 ++-- .../BigInt/callbackfn-not-called-on-empty.js | 4 ++-- ...lbackfn-return-does-not-change-instance.js | 4 ++-- .../some/BigInt/callbackfn-returns-abrupt.js | 4 ++-- ...callbackfn-set-value-during-interaction.js | 4 ++-- .../prototype/some/BigInt/callbackfn-this.js | 4 ++-- .../prototype/some/BigInt/detached-buffer.js | 4 ++-- .../get-length-uses-internal-arraylength.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- ...returns-false-if-every-cb-returns-false.js | 4 ++-- .../returns-true-if-any-cb-returns-true.js | 4 ++-- .../some/BigInt/values-are-not-cached.js | 4 ++-- .../some/callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../prototype/some/callbackfn-detachbuffer.js | 2 +- ...lbackfn-no-interaction-over-non-integer.js | 2 +- .../some/callbackfn-not-callable-throws.js | 2 +- .../some/callbackfn-not-called-on-empty.js | 2 +- .../prototype/some/callbackfn-resize.js | 8 +++---- ...lbackfn-return-does-not-change-instance.js | 2 +- .../some/callbackfn-returns-abrupt.js | 2 +- ...callbackfn-set-value-during-interaction.js | 2 +- .../prototype/some/callbackfn-this.js | 2 +- .../prototype/some/detached-buffer.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../prototype/some/invoked-as-func.js | 2 +- .../prototype/some/invoked-as-method.js | 2 +- .../TypedArray/prototype/some/length.js | 2 +- .../TypedArray/prototype/some/name.js | 2 +- .../TypedArray/prototype/some/prop-desc.js | 2 +- .../resizable-buffer-grow-mid-iteration.js | 2 +- .../resizable-buffer-shrink-mid-iteration.js | 2 +- .../prototype/some/resizable-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 10 ++++----- ...returns-false-if-every-cb-returns-false.js | 2 +- .../returns-true-if-any-cb-returns-true.js | 2 +- .../prototype/some/this-is-not-object.js | 2 +- .../some/this-is-not-typedarray-instance.js | 8 +++---- .../prototype/some/values-are-not-cached.js | 2 +- .../sort/BigInt/arraylength-internal.js | 4 ++-- .../sort/BigInt/comparefn-call-throws.js | 4 ++-- .../prototype/sort/BigInt/comparefn-calls.js | 4 ++-- .../sort/BigInt/comparefn-is-undefined.js | 4 ++-- .../comparefn-nonfunction-call-throws.js | 4 ++-- .../prototype/sort/BigInt/detached-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../sort/BigInt/return-same-instance.js | 4 ++-- .../BigInt/sortcompare-with-no-tostring.js | 4 ++-- .../prototype/sort/BigInt/sorted-values.js | 4 ++-- .../prototype/sort/arraylength-internal.js | 2 +- .../prototype/sort/comparefn-call-throws.js | 2 +- .../prototype/sort/comparefn-calls.js | 2 +- .../prototype/sort/comparefn-grow.js | 6 ++--- .../prototype/sort/comparefn-is-undefined.js | 2 +- .../sort/comparefn-nonfunction-call-throws.js | 2 +- .../sort/comparefn-resizable-buffer.js | 4 ++-- .../prototype/sort/comparefn-shrink.js | 6 ++--- .../prototype/sort/detached-buffer.js | 2 +- .../prototype/sort/invoked-as-func.js | 2 +- .../prototype/sort/invoked-as-method.js | 2 +- .../TypedArray/prototype/sort/length.js | 2 +- .../TypedArray/prototype/sort/name.js | 2 +- .../TypedArray/prototype/sort/prop-desc.js | 2 +- .../resizable-buffer-default-comparator.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 10 ++++----- .../prototype/sort/return-same-instance.js | 2 +- .../prototype/sort/sort-tonumber.js | 2 +- .../sort/sortcompare-with-no-tostring.js | 2 +- .../prototype/sort/sorted-values-nan.js | 2 +- .../prototype/sort/sorted-values.js | 2 +- .../TypedArray/prototype/sort/stability.js | 2 +- .../prototype/sort/this-is-not-object.js | 2 +- .../sort/this-is-not-typedarray-instance.js | 8 +++---- .../subarray/BigInt/detached-buffer.js | 4 ++-- .../prototype/subarray/BigInt/infinity.js | 4 ++-- .../prototype/subarray/BigInt/minus-zero.js | 4 ++-- ...esult-does-not-copy-ordinary-properties.js | 4 ++-- .../result-is-new-instance-from-same-ctor.js | 4 ++-- ...sult-is-new-instance-with-shared-buffer.js | 4 ++-- .../BigInt/results-with-different-length.js | 4 ++-- .../BigInt/results-with-empty-length.js | 4 ++-- .../BigInt/results-with-same-length.js | 4 ++-- .../BigInt/return-abrupt-from-begin-symbol.js | 4 ++-- .../BigInt/return-abrupt-from-begin.js | 4 ++-- .../BigInt/return-abrupt-from-end-symbol.js | 4 ++-- .../subarray/BigInt/return-abrupt-from-end.js | 4 ++-- .../BigInt/speciesctor-get-ctor-abrupt.js | 4 ++-- .../BigInt/speciesctor-get-ctor-inherited.js | 4 ++-- .../speciesctor-get-ctor-returns-throws.js | 4 ++-- .../subarray/BigInt/speciesctor-get-ctor.js | 4 ++-- .../BigInt/speciesctor-get-species-abrupt.js | 4 ++-- ...ctor-get-species-custom-ctor-invocation.js | 4 ++-- ...es-custom-ctor-returns-another-instance.js | 4 ++-- ...ciesctor-get-species-custom-ctor-throws.js | 4 ++-- .../speciesctor-get-species-custom-ctor.js | 4 ++-- .../speciesctor-get-species-returns-throws.js | 4 ++-- ...peciesctor-get-species-use-default-ctor.js | 4 ++-- .../BigInt/speciesctor-get-species.js | 4 ++-- .../subarray/BigInt/tointeger-begin.js | 4 ++-- .../subarray/BigInt/tointeger-end.js | 4 ++-- .../subarray/coerced-begin-end-grow.js | 2 +- .../subarray/coerced-begin-end-shrink.js | 2 +- .../prototype/subarray/detached-buffer.js | 2 +- .../TypedArray/prototype/subarray/infinity.js | 2 +- .../prototype/subarray/invoked-as-func.js | 2 +- .../prototype/subarray/invoked-as-method.js | 2 +- .../TypedArray/prototype/subarray/length.js | 2 +- .../prototype/subarray/minus-zero.js | 2 +- .../TypedArray/prototype/subarray/name.js | 2 +- .../prototype/subarray/prop-desc.js | 2 +- .../prototype/subarray/resizable-buffer.js | 4 ++-- .../result-byteOffset-from-out-of-bounds.js | 4 ++-- ...esult-does-not-copy-ordinary-properties.js | 2 +- .../result-is-new-instance-from-same-ctor.js | 2 +- ...sult-is-new-instance-with-shared-buffer.js | 2 +- .../subarray/results-with-different-length.js | 2 +- .../subarray/results-with-empty-length.js | 2 +- .../subarray/results-with-same-length.js | 2 +- .../return-abrupt-from-begin-symbol.js | 2 +- .../subarray/return-abrupt-from-begin.js | 2 +- .../subarray/return-abrupt-from-end-symbol.js | 2 +- .../subarray/return-abrupt-from-end.js | 2 +- .../subarray/speciesctor-get-ctor-abrupt.js | 2 +- .../speciesctor-get-ctor-inherited.js | 2 +- .../speciesctor-get-ctor-returns-throws.js | 2 +- .../subarray/speciesctor-get-ctor.js | 2 +- .../speciesctor-get-species-abrupt.js | 2 +- ...ctor-get-species-custom-ctor-invocation.js | 2 +- ...es-custom-ctor-returns-another-instance.js | 2 +- ...ciesctor-get-species-custom-ctor-throws.js | 2 +- .../speciesctor-get-species-custom-ctor.js | 2 +- .../speciesctor-get-species-returns-throws.js | 2 +- ...peciesctor-get-species-use-default-ctor.js | 2 +- .../subarray/speciesctor-get-species.js | 2 +- .../prototype/subarray/this-is-not-object.js | 2 +- .../this-is-not-typedarray-instance.js | 8 +++---- .../prototype/subarray/tointeger-begin.js | 2 +- .../prototype/subarray/tointeger-end.js | 2 +- .../calls-tolocalestring-from-each-value.js | 4 ++-- .../BigInt/calls-tostring-from-each-value.js | 4 ++-- .../BigInt/calls-valueof-from-each-value.js | 4 ++-- .../toLocaleString/BigInt/detached-buffer.js | 4 ++-- .../empty-instance-returns-empty-string.js | 4 ++-- .../get-length-uses-internal-arraylength.js | 4 ++-- ...abrupt-from-firstelement-tolocalestring.js | 4 ++-- ...eturn-abrupt-from-firstelement-tostring.js | 4 ++-- ...return-abrupt-from-firstelement-valueof.js | 4 ++-- ...-abrupt-from-nextelement-tolocalestring.js | 4 ++-- ...return-abrupt-from-nextelement-tostring.js | 4 ++-- .../return-abrupt-from-nextelement-valueof.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../toLocaleString/BigInt/return-result.js | 4 ++-- .../calls-tolocalestring-from-each-value.js | 2 +- .../calls-tostring-from-each-value.js | 2 +- .../calls-valueof-from-each-value.js | 2 +- .../toLocaleString/detached-buffer.js | 2 +- .../empty-instance-returns-empty-string.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../toLocaleString/invoked-as-func.js | 2 +- .../toLocaleString/invoked-as-method.js | 2 +- .../prototype/toLocaleString/length.js | 2 +- .../prototype/toLocaleString/name.js | 2 +- .../prototype/toLocaleString/prop-desc.js | 2 +- .../toLocaleString/resizable-buffer.js | 4 ++-- ...abrupt-from-firstelement-tolocalestring.js | 2 +- ...eturn-abrupt-from-firstelement-tostring.js | 2 +- ...return-abrupt-from-firstelement-valueof.js | 2 +- ...-abrupt-from-nextelement-tolocalestring.js | 2 +- ...return-abrupt-from-nextelement-tostring.js | 2 +- .../return-abrupt-from-nextelement-valueof.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 ++++----- .../prototype/toLocaleString/return-result.js | 2 +- .../toLocaleString/this-is-not-object.js | 2 +- .../this-is-not-typedarray-instance.js | 8 +++---- .../user-provided-tolocalestring-grow.js | 6 ++--- .../user-provided-tolocalestring-shrink.js | 6 ++--- .../prototype/toReversed/ignores-species.js | 2 +- .../prototype/toReversed/immutable.js | 2 +- .../toReversed/length-property-ignored.js | 2 +- .../prototype/toReversed/metadata/length.js | 2 +- .../prototype/toReversed/metadata/name.js | 2 +- .../metadata/property-descriptor.js | 2 +- .../toReversed/this-value-invalid.js | 4 ++-- .../toSorted/comparefn-not-a-function.js | 2 +- .../toSorted/comparefn-stop-after-error.js | 2 +- .../prototype/toSorted/ignores-species.js | 2 +- .../prototype/toSorted/immutable.js | 2 +- .../toSorted/length-property-ignored.js | 2 +- .../prototype/toSorted/metadata/length.js | 2 +- .../prototype/toSorted/metadata/name.js | 2 +- .../toSorted/metadata/property-descriptor.js | 2 +- .../prototype/toSorted/this-value-invalid.js | 4 ++-- .../builtins/TypedArray/prototype/toString.js | 2 +- .../toString/BigInt/detached-buffer.js | 4 ++-- .../prototype/toString/detached-buffer.js | 2 +- .../values/BigInt/detached-buffer.js | 4 ++-- .../prototype/values/BigInt/iter-prototype.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 12 +++++----- .../prototype/values/BigInt/return-itor.js | 4 ++-- .../prototype/values/detached-buffer.js | 2 +- .../prototype/values/invoked-as-func.js | 2 +- .../prototype/values/invoked-as-method.js | 2 +- .../prototype/values/iter-prototype.js | 2 +- .../TypedArray/prototype/values/length.js | 2 +- .../values/make-in-bounds-after-exhausted.js | 4 ++-- .../make-out-of-bounds-after-exhausted.js | 4 ++-- .../TypedArray/prototype/values/name.js | 2 +- .../TypedArray/prototype/values/prop-desc.js | 2 +- .../resizable-buffer-grow-mid-iteration.js | 2 +- .../resizable-buffer-shrink-mid-iteration.js | 2 +- .../prototype/values/resizable-buffer.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 10 ++++----- .../prototype/values/return-itor.js | 2 +- .../prototype/values/this-is-not-object.js | 2 +- .../values/this-is-not-typedarray-instance.js | 8 +++---- .../with/BigInt/early-type-coercion-bigint.js | 4 ++-- .../prototype/with/early-type-coercion.js | 2 +- .../prototype/with/ignores-species.js | 2 +- .../TypedArray/prototype/with/immutable.js | 2 +- .../prototype/with/index-casted-to-number.js | 2 +- .../prototype/with/index-negative.js | 2 +- .../with/index-smaller-than-minus-length.js | 2 +- .../index-validated-against-current-length.js | 4 ++-- .../prototype/with/length-property-ignored.js | 2 +- .../prototype/with/metadata/length.js | 2 +- .../prototype/with/metadata/name.js | 2 +- .../with/metadata/property-descriptor.js | 2 +- .../prototype/with/this-value-invalid.js | 2 +- .../resizable-buffer-length-tracking-1.js | 2 +- .../resizable-buffer-length-tracking-2.js | 2 +- 1352 files changed, 2433 insertions(+), 2433 deletions(-) diff --git a/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js b/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js index 04e62faa4a9..1509f44322a 100644 --- a/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js +++ b/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js @@ -18,7 +18,7 @@ esid: sec-function.prototype.apply description: > SendableFunction.p.apply behaves correctly when the argument array is a TypedSendableArray backed by resizable buffer -includes: [compareSendableArray.js, resizableSendableSendableArrayBufferUtils.js] +includes: [compareSendableArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/arylk-get-length-error.js b/test/sendable/builtins/TypedArray/from/arylk-get-length-error.js index 5a005139da5..57860d77937 100644 --- a/test/sendable/builtins/TypedArray/from/arylk-get-length-error.js +++ b/test/sendable/builtins/TypedArray/from/arylk-get-length-error.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: Returns error produced by accessing array-like's length info: | 22.2.2.1 %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) diff --git a/test/sendable/builtins/TypedArray/from/arylk-to-length-error.js b/test/sendable/builtins/TypedArray/from/arylk-to-length-error.js index 579fba082bc..8575f8925eb 100644 --- a/test/sendable/builtins/TypedArray/from/arylk-to-length-error.js +++ b/test/sendable/builtins/TypedArray/from/arylk-to-length-error.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: Returns error produced by interpreting length property as a length info: | 22.2.2.1 %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) diff --git a/test/sendable/builtins/TypedArray/from/from-array-mapper-detaches-result.js b/test/sendable/builtins/TypedArray/from/from-array-mapper-detaches-result.js index 8995f237874..ab118789a49 100644 --- a/test/sendable/builtins/TypedArray/from/from-array-mapper-detaches-result.js +++ b/test/sendable/builtins/TypedArray/from/from-array-mapper-detaches-result.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: > If the mapper function detaches the result typed array, .from performs Set operation which ignores out-of-bounds indices. info: | @@ -32,7 +32,7 @@ includes: [detachArrayBuffer.js] features: [TypedArray] ---*/ -let ab = new ArrayBuffer(3); +let ab = new SendableArrayBuffer(3); let target = new Int8Array(ab); let values = [0, 1, 2]; diff --git a/test/sendable/builtins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js b/test/sendable/builtins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js index 0e87da3ae19..8026f5bb5af 100644 --- a/test/sendable/builtins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: > If the mapper function makes result typed array out-of-bounds, .from performs Set operation which ignores out-of-bounds indices. info: | @@ -31,7 +31,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let rab = new SendableArrayBuffer(3, {maxByteLength: 5}); let target = new Int8Array(rab); let values = [0, 1, 2]; diff --git a/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js b/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js index 68aa5183dda..660e0d6ce4b 100644 --- a/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js +++ b/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: > If the mapper function detaches the result typed array, .from performs Set operation which ignores out-of-bounds indices. info: | @@ -32,7 +32,7 @@ includes: [detachArrayBuffer.js] features: [TypedArray] ---*/ -let ab = new ArrayBuffer(3); +let ab = new SendableArrayBuffer(3); let target = new Int8Array(ab); target.set([0, 1, 2]); diff --git a/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js b/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js index 24acc9a4e4f..46d353fc344 100644 --- a/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: > If the mapper function makes result typed array out-of-bounds, .from performs Set operation which ignores out-of-bounds indices. info: | @@ -31,7 +31,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let rab = new SendableArrayBuffer(3, {maxByteLength: 5}); let target = new Int8Array(rab); target.set([0, 1, 2]); diff --git a/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-detaches-result.js b/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-detaches-result.js index 7b2935995d0..0275af591e5 100644 --- a/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-detaches-result.js +++ b/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-detaches-result.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: > If the mapper function detaches the result typed array, .from performs Set operation which ignores out-of-bounds indices. info: | @@ -32,7 +32,7 @@ includes: [detachArrayBuffer.js] features: [TypedArray] ---*/ -let ab = new ArrayBuffer(3); +let ab = new SendableArrayBuffer(3); let target = new Int8Array(ab); let values = new Int8Array([0, 1, 2]); diff --git a/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js b/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js index 2b8006c4da7..241ec7a1ad1 100644 --- a/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: > If the mapper function makes result typed array out-of-bounds, .from performs Set operation which ignores out-of-bounds indices. info: | @@ -31,7 +31,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let rab = new SendableArrayBuffer(3, {maxByteLength: 5}); let target = new Int8Array(rab); let values = new Int8Array([0, 1, 2]); diff --git a/test/sendable/builtins/TypedArray/from/invoked-as-func.js b/test/sendable/builtins/TypedArray/from/invoked-as-func.js index 40a7dd7b195..7ba631c0dca 100644 --- a/test/sendable/builtins/TypedArray/from/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/from/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: > "from" cannot be invoked as a function info: | diff --git a/test/sendable/builtins/TypedArray/from/invoked-as-method.js b/test/sendable/builtins/TypedArray/from/invoked-as-method.js index 7014e7cd0fb..179e987c76d 100644 --- a/test/sendable/builtins/TypedArray/from/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/from/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: > "from" cannot be invoked as a method of %SendableTypedArray% info: | diff --git a/test/sendable/builtins/TypedArray/from/iter-access-error.js b/test/sendable/builtins/TypedArray/from/iter-access-error.js index e5edb6fd1da..9d525fc55e4 100644 --- a/test/sendable/builtins/TypedArray/from/iter-access-error.js +++ b/test/sendable/builtins/TypedArray/from/iter-access-error.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: Returns error produced by accessing @@iterator info: | 22.2.2.1 %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) diff --git a/test/sendable/builtins/TypedArray/from/iter-invoke-error.js b/test/sendable/builtins/TypedArray/from/iter-invoke-error.js index 60fdc9c9029..d14bcfdbeb3 100644 --- a/test/sendable/builtins/TypedArray/from/iter-invoke-error.js +++ b/test/sendable/builtins/TypedArray/from/iter-invoke-error.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: Returns error produced by invoking @@iterator info: | 22.2.2.1 %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) diff --git a/test/sendable/builtins/TypedArray/from/iter-next-error.js b/test/sendable/builtins/TypedArray/from/iter-next-error.js index 319051f84cb..69529161aa7 100644 --- a/test/sendable/builtins/TypedArray/from/iter-next-error.js +++ b/test/sendable/builtins/TypedArray/from/iter-next-error.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: Returns error produced by advancing the iterator info: | 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items ) diff --git a/test/sendable/builtins/TypedArray/from/iter-next-value-error.js b/test/sendable/builtins/TypedArray/from/iter-next-value-error.js index 2d3e8ed4ee9..1409340d39f 100644 --- a/test/sendable/builtins/TypedArray/from/iter-next-value-error.js +++ b/test/sendable/builtins/TypedArray/from/iter-next-value-error.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: Returns error produced by accessing iterated value info: | 22.2.2.1.1 Runtime Semantics: IterableToArrayLike( items ) diff --git a/test/sendable/builtins/TypedArray/from/iterated-array-changed-by-tonumber.js b/test/sendable/builtins/TypedArray/from/iterated-array-changed-by-tonumber.js index e253d8ac9b5..6eddef139ed 100644 --- a/test/sendable/builtins/TypedArray/from/iterated-array-changed-by-tonumber.js +++ b/test/sendable/builtins/TypedArray/from/iterated-array-changed-by-tonumber.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: > Modifications to input array after iteration are handled correctly. info: | diff --git a/test/sendable/builtins/TypedArray/from/length.js b/test/sendable/builtins/TypedArray/from/length.js index cc3ff257fcf..ecb0197eeb0 100644 --- a/test/sendable/builtins/TypedArray/from/length.js +++ b/test/sendable/builtins/TypedArray/from/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: > %SendableTypedArray%.from.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/from/mapfn-is-not-callable.js b/test/sendable/builtins/TypedArray/from/mapfn-is-not-callable.js index 19f160043af..65fe48c9f6c 100644 --- a/test/sendable/builtins/TypedArray/from/mapfn-is-not-callable.js +++ b/test/sendable/builtins/TypedArray/from/mapfn-is-not-callable.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: Throw a TypeError exception is mapfn is not callable info: | 22.2.2.1 %SendableTypedArray%.from ( source [ , mapfn [ , thisArg ] ] ) diff --git a/test/sendable/builtins/TypedArray/from/this-is-not-constructor.js b/test/sendable/builtins/TypedArray/from/this-is-not-constructor.js index e69b14725f0..15b04a0b2d7 100644 --- a/test/sendable/builtins/TypedArray/from/this-is-not-constructor.js +++ b/test/sendable/builtins/TypedArray/from/this-is-not-constructor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.from +esid: sec-%sendabletypedarray%.from description: > Throws a TypeError exception if this is not a constructor info: | diff --git a/test/sendable/builtins/TypedArray/invoked.js b/test/sendable/builtins/TypedArray/invoked.js index 412aa012aed..2a174db6f75 100644 --- a/test/sendable/builtins/TypedArray/invoked.js +++ b/test/sendable/builtins/TypedArray/invoked.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray% +esid: sec-%sendabletypedarray% description: Throw a TypeError exception if directly invoked. info: | 22.2.1.1 %SendableTypedArray% ( ) @@ -69,7 +69,7 @@ assert.throws(TypeError, function() { new SendableTypedArray(typedArray); }); -var buffer = new ArrayBuffer(4); +var buffer = new SendableArrayBuffer(4); assert.throws(TypeError, function() { SendableTypedArray(buffer); }); diff --git a/test/sendable/builtins/TypedArray/length.js b/test/sendable/builtins/TypedArray/length.js index f02d7d81b27..5e3543d219a 100644 --- a/test/sendable/builtins/TypedArray/length.js +++ b/test/sendable/builtins/TypedArray/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray% +esid: sec-%sendabletypedarray% description: > SendableTypedArray has a "length" property whose value is 0. info: | diff --git a/test/sendable/builtins/TypedArray/name.js b/test/sendable/builtins/TypedArray/name.js index f76dd7ba092..122943ba67e 100644 --- a/test/sendable/builtins/TypedArray/name.js +++ b/test/sendable/builtins/TypedArray/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray% +esid: sec-%sendabletypedarray% description: > SendableTypedArray has a 'name' property whose value is "SendableTypedArray". info: | diff --git a/test/sendable/builtins/TypedArray/of/invoked-as-method.js b/test/sendable/builtins/TypedArray/of/invoked-as-method.js index 55c1aae53d5..8dd62435eab 100644 --- a/test/sendable/builtins/TypedArray/of/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/of/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.of +esid: sec-%sendabletypedarray%.of description: > "of" cannot be invoked as a method of %SendableTypedArray% info: | diff --git a/test/sendable/builtins/TypedArray/of/length.js b/test/sendable/builtins/TypedArray/of/length.js index 64f92887c4c..222839a9537 100644 --- a/test/sendable/builtins/TypedArray/of/length.js +++ b/test/sendable/builtins/TypedArray/of/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%-of +esid: sec-%sendabletypedarray%-of description: > %SendableTypedArray%.of.length is 0. info: | diff --git a/test/sendable/builtins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js b/test/sendable/builtins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js index 5601dd3c4ce..716ff7fdfc1 100644 --- a/test/sendable/builtins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js +++ b/test/sendable/builtins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.of +esid: sec-%sendabletypedarray%.of description: > Performs Set operation which ignores out-of-bounds indices. info: | @@ -29,7 +29,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new ArrayBuffer(3, {maxByteLength: 4}); +let rab = new SendableArrayBuffer(3, {maxByteLength: 4}); let ta = new Int8Array(rab); let one = { diff --git a/test/sendable/builtins/TypedArray/of/this-is-not-constructor.js b/test/sendable/builtins/TypedArray/of/this-is-not-constructor.js index e60f2e30620..d5056740fed 100644 --- a/test/sendable/builtins/TypedArray/of/this-is-not-constructor.js +++ b/test/sendable/builtins/TypedArray/of/this-is-not-constructor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.of +esid: sec-%sendabletypedarray%.of description: > Throws a TypeError exception if this is not a constructor info: | diff --git a/test/sendable/builtins/TypedArray/out-of-bounds-behaves-like-detached.js b/test/sendable/builtins/TypedArray/out-of-bounds-behaves-like-detached.js index 9997bf55059..7f82eb6ed8a 100644 --- a/test/sendable/builtins/TypedArray/out-of-bounds-behaves-like-detached.js +++ b/test/sendable/builtins/TypedArray/out-of-bounds-behaves-like-detached.js @@ -22,7 +22,7 @@ includes: [resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableArrayBuffer(16, 40); +const rab = CreateResizableSendableArrayBuffer(16, 40); const i8a = new Int8Array(rab, 0, 4); i8a.__proto__ = { 2: 'wrong value' }; i8a[2] = 10; diff --git a/test/sendable/builtins/TypedArray/out-of-bounds-get-and-set.js b/test/sendable/builtins/TypedArray/out-of-bounds-get-and-set.js index 88ccef49bfa..e3db7c04db1 100644 --- a/test/sendable/builtins/TypedArray/out-of-bounds-get-and-set.js +++ b/test/sendable/builtins/TypedArray/out-of-bounds-get-and-set.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 40 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 40 * ctor.BYTES_PER_ELEMENT); const array = new ctor(rab, 0, 4); // Initial values for (let i = 0; i < 4; ++i) { diff --git a/test/sendable/builtins/TypedArray/out-of-bounds-has.js b/test/sendable/builtins/TypedArray/out-of-bounds-has.js index f72d12ddbed..142b7ebee40 100644 --- a/test/sendable/builtins/TypedArray/out-of-bounds-has.js +++ b/test/sendable/builtins/TypedArray/out-of-bounds-has.js @@ -28,7 +28,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 40 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 40 * ctor.BYTES_PER_ELEMENT); const array = new ctor(rab, 0, 4); // Within-bounds read for (let i = 0; i < 4; ++i) { diff --git a/test/sendable/builtins/TypedArray/prototype.js b/test/sendable/builtins/TypedArray/prototype.js index 0922616d5d1..fd929a83951 100644 --- a/test/sendable/builtins/TypedArray/prototype.js +++ b/test/sendable/builtins/TypedArray/prototype.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray% +esid: sec-%sendabletypedarray% description: > "prototype" property of SendableTypedArray info: | diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.iterator.js b/test/sendable/builtins/TypedArray/prototype/Symbol.iterator.js index c26005ab17f..b25cd2e5d58 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.iterator.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.iterator.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype-@@iterator +esid: sec-%sendableTypedArray%.prototype-@@iterator description: > Initial state of the Symbol.iterator property info: | diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js index 098b67e93b6..d8eecbc8a92 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js @@ -23,7 +23,7 @@ info: | 4. Let name be the value of O's [[TypedArrayName]] internal slot. 5. Assert: name is a String value. 6. Return name. -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js index 65f215dff30..bce272476b3 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js @@ -24,7 +24,7 @@ info: | ... 3. If O does not have a [[TypedArrayName]] internal slot, return undefined. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js index 25501b1c92a..2f0431c2b5c 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, return undefined. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js index c378c040e5f..fc27a805b57 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testBigIntSendableTypedArray.js] +includes: [propertyHelper.js, testBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js index 6f0aa4dc68a..8ee106f99e3 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js @@ -28,7 +28,7 @@ info: | 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, testBigIntSendableTypedArray.js] +includes: [propertyHelper.js, testBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js index 1a51b32cf08..3170142e1bd 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js @@ -26,7 +26,7 @@ info: | This property has the attributes { [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testBigIntSendableTypedArray.js] +includes: [propertyHelper.js, testBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js index 15c66a44ded..addac178a79 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js @@ -24,7 +24,7 @@ info: | 4. Let name be the value of O's [[TypedArrayName]] internal slot. 5. Assert: name is a String value. 6. Return name. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js index 431af2abf1e..bd540beb3dc 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js @@ -24,7 +24,7 @@ info: | ... 3. If O does not have a [[TypedArrayName]] internal slot, return undefined. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag, DataView, TypedArray] ---*/ @@ -35,8 +35,8 @@ var getter = Object.getOwnPropertyDescriptor( assert.sameValue(getter.call({}), undefined); assert.sameValue(getter.call([]), undefined); -assert.sameValue(getter.call(new ArrayBuffer(8)), undefined); +assert.sameValue(getter.call(new SendableArrayBuffer(8)), undefined); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); var dv = new DataView(ab, 0, 1); assert.sameValue(getter.call(dv), undefined); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js index d86993396e4..3ffea3b142e 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, return undefined. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js index ea29a5ba5b0..9e77c155051 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js @@ -35,8 +35,8 @@ var getter = Object.getOwnPropertyDescriptor( assert.sameValue(getter.call({}), undefined); assert.sameValue(getter.call([]), undefined); -assert.sameValue(getter.call(new ArrayBuffer(8)), undefined); +assert.sameValue(getter.call(new SendableArrayBuffer(8)), undefined); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); var dv = new DataView(ab, 0, 1); assert.sameValue(getter.call(dv), undefined); diff --git a/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js index 26694d155da..ff52fe8b2e8 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, SendableTypedArray.prototype.at, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, SendableTypedArray.prototype.at, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/at/coerced-index-resize.js b/test/sendable/builtins/TypedArray/prototype/at/coerced-index-resize.js index 81da0413f25..f768e429d1a 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/coerced-index-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/at/coerced-index-resize.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: > SendableTypedArray.p.at behaves correctly on SendableTypedArrays backed by resizable buffers when the SendableTypedArray is resized during parameter conversion @@ -28,7 +28,7 @@ function SendableTypedArrayAtHelper(ta, index) { } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { valueOf: () => { @@ -40,7 +40,7 @@ for (let ctor of ctors) { } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); let evil = { valueOf: () => { diff --git a/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js b/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js index 8ba990ca4bc..cd8e7d5b6a4 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: > Property type and descriptor. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js index 4e87bc573b7..70106a6bc94 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js +++ b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: > Property type and descriptor. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js index fc5ef9c5d46..b5d81219458 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: > Property type and descriptor. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/at/length.js b/test/sendable/builtins/TypedArray/prototype/at/length.js index eceb23ad027..8e7b5a9afa1 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/length.js +++ b/test/sendable/builtins/TypedArray/prototype/at/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: > SendableTypedArray.prototype.at.length value and descriptor. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/at/name.js b/test/sendable/builtins/TypedArray/prototype/at/name.js index e9b1e0322b7..22264e9f66a 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/name.js +++ b/test/sendable/builtins/TypedArray/prototype/at/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: > %SendableTypedArray%.prototype.at.name value and descriptor. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/at/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/at/prop-desc.js index 0af3b9c230c..e082440c4ba 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/at/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: > Property type and descriptor. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/at/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/at/resizable-buffer.js index 7ef7e3f8e5e..5817f286b0d 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/at/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: > SendableTypedArray.p.at behaves correctly on SendableTypedArrays backed by resizable buffers includes: [resizableArrayBufferUtils.js] @@ -27,7 +27,7 @@ function SendableTypedArrayAtHelper(ta, index) { } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js index 6e83421c846..25a7319a0a9 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, SendableTypedArray.prototype.at, resizable-arraybuffer] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js index 5db72011090..35fede39d03 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js +++ b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: > Return abrupt from ToObject(this value). info: | diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js b/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js index 245eb499752..db4d6ba2307 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: > Returns the item value at the specified relative index info: | diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-item.js b/test/sendable/builtins/TypedArray/prototype/at/returns-item.js index afca90519f0..e3f4ea7e85d 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/returns-item.js +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-item.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: > Returns the item value at the specified index info: | diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js index 6e15814147b..fff1315b3f2 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: > Returns the item value at the specified index, holes are filled in sparse arrays. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js index 005c7f02889..1e7dc7edd3b 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.at +esid: sec-%sendableTypedArray%.prototype.at description: > Returns undefined if the specified index less than or greater than the available index range. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/detached-buffer.js index bc438dfccf4..15c4c2b82f5 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/detached-buffer.js @@ -20,14 +20,14 @@ info: | 22.2.3.1 get %SendableTypedArray%.prototype.buffer ... - 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. 5. Return buffer. -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ testWithBigIntSendableTypedArrayConstructors(function(TA) { - var buffer = new ArrayBuffer(8); + var buffer = new SendableArrayBuffer(8); var sample = new TA(buffer, 0, 1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.buffer, buffer); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/return-buffer.js b/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/return-buffer.js index 7cb8288dd8d..cc9705da69c 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/return-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/return-buffer.js @@ -16,19 +16,19 @@ /*--- esid: sec-get-%typedarray%.prototype.buffer description: > - Return buffer from [[ViewedArrayBuffer]] internal slot + Return buffer from [[ViewedSendableArrayBuffer]] internal slot info: | 22.2.3.1 get %SendableTypedArray%.prototype.buffer ... - 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. 5. Return buffer. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ testWithBigIntSendableTypedArrayConstructors(function(TA) { - var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT); + var buffer = new SendableArrayBuffer(TA.BYTES_PER_ELEMENT); var ta = new TA(buffer); assert.sameValue(ta.buffer, buffer); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js index d627f7f7eba..b88de349994 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js @@ -20,14 +20,14 @@ info: | 22.2.3.1 get %SendableTypedArray%.prototype.buffer ... - 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. 5. Return buffer. includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ testWithSendableTypedArrayConstructors(function(TA) { - var buffer = new ArrayBuffer(8); + var buffer = new SendableArrayBuffer(8); var sample = new TA(buffer, 0, 1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.buffer, buffer); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js index 314b0e1238e..575ca9a54d6 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js @@ -16,13 +16,13 @@ /*--- esid: sec-get-%typedarray%.prototype.buffer description: > - Requires this value to have a [[ViewedArrayBuffer]] internal slot + Requires this value to have a [[ViewedSendableArrayBuffer]] internal slot info: | 22.2.3.1 get %SendableTypedArray%.prototype.buffer 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. - 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + 3. If O does not have a [[ViewedSendableArrayBuffer]] internal slot, throw a TypeError exception. ... includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js index 7ecc1c79a5a..1f4e9c2f45b 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. - 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + 3. If O does not have a [[ViewedSendableArrayBuffer]] internal slot, throw a TypeError exception. ... includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js b/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js index 89c165b5145..953760053b3 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js @@ -16,19 +16,19 @@ /*--- esid: sec-get-%typedarray%.prototype.buffer description: > - Return buffer from [[ViewedArrayBuffer]] internal slot + Return buffer from [[ViewedSendableArrayBuffer]] internal slot info: | 22.2.3.1 get %SendableTypedArray%.prototype.buffer ... - 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. 5. Return buffer. includes: [testTypedArray.js] features: [TypedArray] ---*/ testWithSendableTypedArrayConstructors(function(TA) { - var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT); + var buffer = new SendableArrayBuffer(TA.BYTES_PER_ELEMENT); var ta = new TA(buffer); assert.sameValue(ta.buffer, buffer); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js index 7074f46fe09..8675fc203f1 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js @@ -43,12 +43,12 @@ assert.throws(TypeError, function() { getter.call([]); }); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { getter.call(ab); }); -var dv = new DataView(new ArrayBuffer(8), 0); +var dv = new DataView(new SendableArrayBuffer(8), 0); assert.throws(TypeError, function() { getter.call(dv); }); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js index e150204f2ab..878342117b6 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js @@ -20,10 +20,10 @@ info: | 22.2.3.2 get %SendableTypedArray%.prototype.byteLength ... - 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. 5. If IsDetachedBuffer(buffer) is true, return 0. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js index bbbdb73edfa..fb7a18284b1 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.byteoffset description: | - reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); testWithBigIntSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE); var expected = BPE * 3; diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js index 77b055c3fb1..096ddde6cdb 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.bytelength description: | - reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); testWithBigIntSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); assert.sameValue(array.byteLength, BPE * 2); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js index 922317d8492..a6632944348 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js @@ -23,7 +23,7 @@ info: | ... 6. Let size be the value of O's [[ByteLength]] internal slot. 7. Return size. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js index a3ee70c70d5..feff892351e 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js @@ -20,7 +20,7 @@ info: | 22.2.3.2 get %SendableTypedArray%.prototype.byteLength ... - 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. 5. If IsDetachedBuffer(buffer) is true, return 0. ... includes: [testTypedArray.js, detachArrayBuffer.js] diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js index dff0d9cdffc..aeed5c2355b 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js @@ -16,13 +16,13 @@ /*--- esid: sec-get-%typedarray%.prototype.bytelength description: > - Requires this value to have a [[ViewedArrayBuffer]] internal slot + Requires this value to have a [[ViewedSendableArrayBuffer]] internal slot info: | 22.2.3.2 get %SendableTypedArray%.prototype.byteLength 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. - 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + 3. If O does not have a [[ViewedSendableArrayBuffer]] internal slot, throw a TypeError exception. ... includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js index 62885ee8c13..b6ba3adbcd5 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. - 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + 3. If O does not have a [[ViewedSendableArrayBuffer]] internal slot, throw a TypeError exception. ... includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js index 61f7b893980..62ed958b2a1 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.byteoffset description: | - reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE); var expected = BPE * 3; diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js index 69d8b8fd33a..324f4fc4e61 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.bytelength description: | - reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); assert.sameValue(array.byteLength, BPE * 2); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-buffer-assorted.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-buffer-assorted.js index 80be3aedb16..8f3db193209 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-buffer-assorted.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-buffer-assorted.js @@ -22,7 +22,7 @@ includes: [compareArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableArrayBuffer(40, 80); +const rab = CreateResizableSendableArrayBuffer(40, 80); for (let ctor of ctors) { const ta = new ctor(rab, 0, 3); assert.compareArray(ta.buffer, rab); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-1.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-1.js index e53a44c8689..b3d8f40aca0 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-1.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-1.js @@ -22,7 +22,7 @@ includes: [compareArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableArrayBuffer(16, 40); +const rab = CreateResizableSendableArrayBuffer(16, 40); // Create TAs which cover the bytes 0-7. let tas_and_lengths = []; diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-2.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-2.js index d1d64451f0e..e7a6e5c6b85 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-2.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-2.js @@ -22,7 +22,7 @@ includes: [compareArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableArrayBuffer(20, 40); +const rab = CreateResizableSendableArrayBuffer(20, 40); // Create TAs with offset, which cover the bytes 8-15. let tas_and_lengths = []; diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js index 378633a1100..4174339b26a 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js @@ -43,12 +43,12 @@ assert.throws(TypeError, function() { getter.call([]); }); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { getter.call(ab); }); -var dv = new DataView(new ArrayBuffer(8), 0); +var dv = new DataView(new SendableArrayBuffer(8), 0); assert.throws(TypeError, function() { getter.call(dv); }); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js index 0e11a7388ed..a6aed18d04b 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js @@ -20,15 +20,15 @@ info: | 22.2.3.3 get %SendableTypedArray%.prototype.byteOffset ... - 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. 5. If IsDetachedBuffer(buffer) is true, return 0. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ testWithBigIntSendableTypedArrayConstructors(function(TA) { - var buffer = new ArrayBuffer(128); + var buffer = new SendableArrayBuffer(128); var sample = new TA(buffer, 8, 1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.byteOffset, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js index 7348f7543f4..5d451fee29a 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.byteoffset description: | - reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); testWithBigIntSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE); assert.sameValue(array.byteOffset, BPE); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js index c825d6681f5..05618c17959 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.byteoffset description: | - reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); testWithBigIntSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); assert.sameValue(array.byteOffset, BPE); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js index b0ac28468ab..15110557146 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js @@ -23,7 +23,7 @@ info: | ... 6. Let offset be the value of O's [[ByteOffset]] internal slot. 7. Return size. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ @@ -33,11 +33,11 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { var offset = 4 * TA.BYTES_PER_ELEMENT; - var buffer1 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var buffer1 = new SendableArrayBuffer(8 * TA.BYTES_PER_ELEMENT); var ta2 = new TA(buffer1, offset); assert.sameValue(ta2.byteOffset, offset, "TA(buffer, offset)"); - var buffer2 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var buffer2 = new SendableArrayBuffer(8 * TA.BYTES_PER_ELEMENT); var sample = new TA(buffer2, offset); var ta3 = new TA(sample); assert.sameValue(ta3.byteOffset, 0, "TA(typedArray)"); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js index ee6e9f04671..ee7bf4ad486 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js @@ -20,7 +20,7 @@ info: | 22.2.3.3 get %SendableTypedArray%.prototype.byteOffset ... - 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. 5. If IsDetachedBuffer(buffer) is true, return 0. ... includes: [testTypedArray.js, detachArrayBuffer.js] @@ -28,7 +28,7 @@ features: [TypedArray] ---*/ testWithSendableTypedArrayConstructors(function(TA) { - var buffer = new ArrayBuffer(128); + var buffer = new SendableArrayBuffer(128); var sample = new TA(buffer, 8, 1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.byteOffset, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js index 9c159226ac3..f8b60246fa5 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js @@ -16,13 +16,13 @@ /*--- esid: sec-get-%typedarray%.prototype.byteoffset description: > - Requires this value to have a [[ViewedArrayBuffer]] internal slot + Requires this value to have a [[ViewedSendableArrayBuffer]] internal slot info: | 22.2.3.3 get %SendableTypedArray%.prototype.byteOffset 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. - 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + 3. If O does not have a [[ViewedSendableArrayBuffer]] internal slot, throw a TypeError exception. ... includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js index 180da3b738a..30592d357ac 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. - 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError + 3. If O does not have a [[ViewedSendableArrayBuffer]] internal slot, throw a TypeError exception. ... includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js index 77e715a5370..12f844e8a37 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.byteoffset description: | - reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE); assert.sameValue(array.byteOffset, BPE); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js index 13042f28f9a..9ea2440eb5a 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.byteoffset description: | - reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); assert.sameValue(array.byteOffset, BPE); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/resized-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/resized-out-of-bounds.js index ba5338bf20a..6e5c84c953b 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/resized-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/resized-out-of-bounds.js @@ -22,7 +22,7 @@ includes: [compareArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableArrayBuffer(20, 40); +const rab = CreateResizableSendableArrayBuffer(20, 40); // Create TAs which cover the bytes 8-15. let tas_and_lengths = []; diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js index ea0b6b951cb..455d017400a 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js @@ -33,11 +33,11 @@ testWithSendableTypedArrayConstructors(function(TA) { var offset = 4 * TA.BYTES_PER_ELEMENT; - var buffer1 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var buffer1 = new SendableArrayBuffer(8 * TA.BYTES_PER_ELEMENT); var ta2 = new TA(buffer1, offset); assert.sameValue(ta2.byteOffset, offset, "TA(buffer, offset)"); - var buffer2 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var buffer2 = new SendableArrayBuffer(8 * TA.BYTES_PER_ELEMENT); var sample = new TA(buffer2, offset); var ta3 = new TA(sample); assert.sameValue(ta3.byteOffset, 0, "TA(typedArray)"); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js index d91b35e4685..aa21f08edab 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js @@ -43,12 +43,12 @@ assert.throws(TypeError, function() { getter.call([]); }); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { getter.call(ab); }); -var dv = new DataView(new ArrayBuffer(8), 0); +var dv = new DataView(new SendableArrayBuffer(8), 0); assert.throws(TypeError, function() { getter.call(dv); }); diff --git a/test/sendable/builtins/TypedArray/prototype/constructor.js b/test/sendable/builtins/TypedArray/prototype/constructor.js index 84e8dd47e03..656ea71c664 100644 --- a/test/sendable/builtins/TypedArray/prototype/constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/constructor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.constructor +esid: sec-%sendableTypedArray%.prototype.constructor description: > Initial state of the constructor property info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js index 8530f418415..68c28608451 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > end argument is coerced to an integer values. info: | @@ -35,7 +35,7 @@ info: | 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js index a959879f08e..2787a0ca2ce 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > start argument is coerced to an integer value. info: | @@ -34,7 +34,7 @@ info: | ... 5. Let relativeStart be ? ToInteger(start). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js index d4ad9f8492b..a4e180af0c2 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > target argument is coerced to an integer value. info: | @@ -34,7 +34,7 @@ info: | ... 3. Let relativeTarget be ? ToInteger(target). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js index 90ec1d0481b..6ff7498ac2a 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: Throws a TypeError if this has a detached buffer info: | 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [, end ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js index 42a88e0ce29..80a64f5de41 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned. info: | @@ -34,7 +34,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-end.js index b104fb92b05..9f336524273 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Set values with negative end argument. info: | @@ -37,7 +37,7 @@ info: | 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js index 35f5cbe0330..523e421e153 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Set values with negative out of bounds end argument. info: | @@ -37,7 +37,7 @@ info: | 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js index 766be0e29bc..34eb4aef0fe 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Set values with out of bounds negative start argument. info: | @@ -35,7 +35,7 @@ info: | 6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let from be min(relativeStart, len). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js index fc9b0d4300e..b00c23fb957 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Set values with out of bounds negative target argument. info: | @@ -35,7 +35,7 @@ info: | 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let to be min(relativeTarget, len). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-start.js index 7dc156985c1..0d6d34e327a 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Set values with negative start argument. info: | @@ -35,7 +35,7 @@ info: | 6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let from be min(relativeStart, len). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-target.js index 5bc56360e19..78e21adbf67 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-target.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Set values with negative target argument. info: | @@ -35,7 +35,7 @@ info: | 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let to be min(relativeTarget, len). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js index 7280d5c6d84..fb0cd7dc9e9 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Max value of end position is the this.length. info: | @@ -28,7 +28,7 @@ info: | source data. ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js index 8260b853cdb..92bbfea753d 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Max values of target and start positions are this.length. info: | @@ -28,7 +28,7 @@ info: | source data. ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js index ad31d4e7ae1..20c34e1e4eb 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Copy values with non-negative target and start positions. info: | @@ -28,7 +28,7 @@ info: | source data. ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js index 91ee5469c23..e3daa32a35d 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Copy values with non-negative target, start and end positions. info: | @@ -28,7 +28,7 @@ info: | source data. ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js index c6fb7952668..ca30734eecc 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Return abrupt if end is a Symbol. info: | @@ -35,7 +35,7 @@ info: | 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js index d198c4e58cf..63c2816e96d 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Return abrupt from ToInteger(end). info: | @@ -35,7 +35,7 @@ info: | 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js index af4440eaf6f..2279a7919b9 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Return abrupt if start is a Symbol. info: | @@ -34,7 +34,7 @@ info: | ... 5. Let relativeStart be ? ToInteger(start). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js index 493c12e1c74..03fc7206579 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Return abrupt from ToInteger(start). info: | @@ -34,7 +34,7 @@ info: | ... 5. Let relativeStart be ? ToInteger(start). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js index 5d015cccf03..f6c84ed6312 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Return abrupt if target is a Symbol. info: | @@ -34,7 +34,7 @@ info: | ... 3. Let relativeTarget be ? ToInteger(target). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js index 0fcb91df800..9d48c3f4d51 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Return abrupt from ToInteger(target). info: | @@ -34,7 +34,7 @@ info: | ... 3. Let relativeTarget be ? ToInteger(target). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js index 0dadf576a4a..dcd160f560f 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-this.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-this.js index 8495d347e88..6d75b7a5ee4 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-this.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Returns `this`. info: | @@ -32,7 +32,7 @@ info: | 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) 13. Return O. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js index 65cb9e367ff..1b988619941 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > If `end` is undefined, set final position to `this.length`. info: | @@ -35,7 +35,7 @@ info: | 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js index 31552969c3d..e84c445f91b 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: Preservation of bit-level encoding info: | Array.prototype.copyWithin (target, start [ , end ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js index 3934bf4eb62..d4d28bcada8 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > copyWithin should respect typedarray's byteOffset info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-end-shrink.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-end-shrink.js index f736b7bcba1..cf1c1634cd5 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-end-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-end-shrink.js @@ -22,7 +22,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const evil = { valueOf: () => { @@ -43,7 +43,7 @@ for (let ctor of ctors) { }); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i); @@ -67,7 +67,7 @@ for (let ctor of ctors) { ]); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-grow.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-grow.js index e9f412cd658..c5b55f87466 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-grow.js @@ -22,7 +22,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js index 1aa9299444e..39001e4a3c5 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > SECURITY: end argument is coerced to an integer values causing array detachment, but the value is still defined @@ -27,7 +27,7 @@ info: | 10. Let count be min(final - from, len - to). 11. If count > 0, then a. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data. - b. Let buffer be O.[[ViewedArrayBuffer]]. + b. Let buffer be O.[[ViewedSendableArrayBuffer]]. c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... includes: [testTypedArray.js, detachArrayBuffer.js] diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js index bfac54944e3..74cb365314c 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > SECURITY: end argument is coerced to an integer values causing array detachment @@ -27,7 +27,7 @@ info: | 10. Let count be min(final - from, len - to). 11. If count > 0, then a. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data. - b. Let buffer be O.[[ViewedArrayBuffer]]. + b. Let buffer be O.[[ViewedSendableArrayBuffer]]. c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... includes: [testTypedArray.js, detachArrayBuffer.js] diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js index 9c75dd44776..19eb5f66690 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > end argument is coerced to an integer values. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js index 05d2a078dcc..3b56a5b92ae 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > SECURITY: start argument is coerced to an integer value, which detached the array @@ -27,7 +27,7 @@ info: | 10. Let count be min(final - from, len - to). 11. If count > 0, then a. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data. - b. Let buffer be O.[[ViewedArrayBuffer]]. + b. Let buffer be O.[[ViewedSendableArrayBuffer]]. c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... includes: [testTypedArray.js, detachArrayBuffer.js] diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js index 2b01761b076..9524f2ae7d5 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > start argument is coerced to an integer value. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js index 834d3bdbf77..2ad93d64fbd 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > target argument is coerced to an integer value. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js index c819ba22168..8c9d34a9be0 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: Throws a TypeError if this has a detached buffer info: | 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [, end ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js index 4164cd326c9..3ac21fffe7e 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-func.js index 7105f735c7a..a36f5d6946f 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: Throws a TypeError exception when invoked as a function info: | 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [, end ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-method.js index d4eaed9e298..37d0717cf58 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [, end ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/length.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/length.js index a0dfc9ffd50..ca38f83b593 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/length.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > %SendableTypedArray%.prototype.copyWithin.length is 2. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/name.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/name.js index 3ffc98371de..a8871cf3451 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/name.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > %SendableTypedArray%.prototype.copyWithin.name is "copyWithin". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js index fcfade66b14..e9964e82de7 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Set values with negative end argument. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js index 8fcda9982d9..0a354b19c4e 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Set values with negative out of bounds end argument. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js index e1acd2dea12..b58ef3b4420 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Set values with out of bounds negative start argument. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js index 5c61c2b699c..6885d2aed2a 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Set values with out of bounds negative target argument. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js index fa8715c2de4..ac9aa9f719e 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Set values with negative start argument. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js index 623ae0ba34e..503bdd17535 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Set values with negative target argument. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js index f15d5e28c3f..579f4fedee4 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Max value of end position is the this.length. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js index 5a09fc686a4..4ee87cea4e1 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Max values of target and start positions are this.length. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js index 2a74da9da49..9c181feedab 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Copy values with non-negative target and start positions. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js index 5a7a271c1ba..e372fd7ce14 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Copy values with non-negative target, start and end positions. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/prop-desc.js index 89cd9def80a..c05dfeac757 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > "copyWithin" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/resizable-buffer.js index 1b55ce37478..f66dedf23fa 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > SendableTypedArray.p.copyWithin behaves correctly when the receiver is backed by resizable buffer @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js index 08292a4c205..66ebaeda73e 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Return abrupt if end is a Symbol. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js index 07250c58462..3f44560e2d0 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Return abrupt from ToInteger(end). info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js index 70423988af2..892e50239d2 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Return abrupt if start is a Symbol. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js index a30d1ee547a..5dda85d9d4d 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Return abrupt from ToInteger(start). info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js index 4d6ae32b8c1..f310efc51a8 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Return abrupt if target is a Symbol. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js index 5c020ad3a23..4cab84b69f6 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Return abrupt from ToInteger(target). info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js index 2b387156859..4923c75fc6a 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js index fd9f178684e..43f76ef31e2 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Returns `this`. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-object.js index a4ff468e198..3286d9bab70 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.5 %SendableTypedArray%.prototype.copyWithin (target, start [ , end ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js index 667d124671e..b11d4efdacf 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { copyWithin.call([], 0, 0); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { copyWithin.call(ab, 0, 0); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { copyWithin.call(dv, 0, 0); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js index a1604a5661d..8053d705fdf 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.copywithin +esid: sec-%sendableTypedArray%.prototype.copywithin description: > If `end` is undefined, set final position to `this.length`. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js index 3b2baa5e0a9..95a8586723c 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: Throws a TypeError if this has a detached buffer info: | 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) @@ -27,7 +27,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/iter-prototype.js index b18f8956c8d..cf6d8f1d7eb 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/iter-prototype.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: > The prototype of the returned iterator is ArrayIteratorPrototype info: | @@ -22,7 +22,7 @@ info: | ... 3. Return CreateArrayIterator(O, "key+value"). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.iterator, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js index fa398cc4003..b1a66816a95 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-itor.js b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-itor.js index 7f1035c291e..13f44246924 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-itor.js @@ -14,14 +14,14 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: Return an iterator for the entries. info: | 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) ... 3. Return CreateArrayIterator(O, "key+value"). -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js index a39bb1f7c5c..19468243978 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: Throws a TypeError if this has a detached buffer info: | 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-func.js index 6754771eed1..a68ba993a72 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: Throws a TypeError exception when invoked as a function info: | 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-method.js index e50c14189d8..c418250e2df 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js index e6e441ee701..b4dd4cbac2e 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: > The prototype of the returned iterator is ArrayIteratorPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/entries/length.js b/test/sendable/builtins/TypedArray/prototype/entries/length.js index f96f4cf7246..54f1a95330d 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/length.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: > %SendableTypedArray%.prototype.entries.length is 0. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/entries/name.js b/test/sendable/builtins/TypedArray/prototype/entries/name.js index a0158942cd6..0978e77b4d5 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/name.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: > %SendableTypedArray%.prototype.entries.name is "entries". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/entries/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/entries/prop-desc.js index 3a4beff9e88..a0a3ec30a5a 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: > "entries" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-grow-mid-iteration.js index 9cca324076a..5b1d75df32e 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: > SendableTypedArray.p.entries behaves correctly when receiver is backed by a resizable buffer and resized mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-shrink-mid-iteration.js index 5f990c29457..77f145802dd 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: > SendableTypedArray.p.entries behaves correctly when receiver is backed by resizable buffer that is shrunk mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer.js index 804aced1fb9..a6698383eec 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: > SendableTypedArray.p.values behaves correctly when receiver is backed by resizable buffer @@ -34,7 +34,7 @@ function ValuesFromSendableTypedArrayEntries(ta) { } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js index 722eff8b822..b856e793e3b 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js b/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js index 6ab02ed440b..d5130ad94d9 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: Return an iterator for the entries. info: | 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-object.js index edad5e15856..0ef0eaba9ab 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.6 %SendableTypedArray%.prototype.entries ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js index 3fbce89978e..b500e911114 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.entries +esid: sec-%sendableTypedArray%.prototype.entries description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -46,12 +46,12 @@ assert.throws(TypeError, function() { entries.call([]); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { entries.call(ab); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { entries.call(dv); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js index 6d2245d087a..84e281942f8 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > thisArg does not affect callbackfn arguments info: | @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js index 144d262f7d4..3ce7f8e5661 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > callbackfn arguments info: | @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js index 9455a9860c3..d7745a45fb0 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > Instance buffer can be detached during loop info: | @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [detachArrayBuffer.js, testBigIntSendableTypedArray.js] +includes: [detachArrayBuffer.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js index 3c703c8e98a..92bb1f4471b 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > Does not interact over non-integer properties info: | @@ -27,7 +27,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js index 290e9887f16..cd404fc8b56 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: Throws a TypeError if callbackfn is not callable info: | 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) @@ -29,7 +29,7 @@ info: | ... 3. If IsCallable(callbackfn) is false, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js index fd00b13ed25..374b8fef758 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > callbackfn is not called on empty instances info: | @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js index 07196fda61f..b12c0376638 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > The callbackfn return does not change the instance info: | @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js index b4d280241ae..82307437d19 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: Returns abrupt from callbackfn info: | 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) @@ -33,7 +33,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js index 7ae098bea5d..c3db0a5ff24 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > Integer indexed values changed during iteration info: | @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Reflect.set, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-this.js index e3c950e2917..8f689c2e306 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > callbackfn `this` value info: | @@ -36,7 +36,7 @@ info: | ... ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/detached-buffer.js index 631b8e2ff8a..ed39703a3ef 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: Throws a TypeError if this has a detached buffer info: | 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js index 83362816d01..23442513f1e 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: Get "length" uses internal ArrayLength info: | 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js index 7896c2a97a0..6c2baf7e1eb 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js index 250405a9aac..e9f265ffc63 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > Returns false if any callbackfn call returns a coerced false. info: | @@ -29,7 +29,7 @@ info: | ... 7. Return true. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js index 1a255cc7c4e..955c3ea1917 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > Returns true if every callbackfn returns a coerced true. info: | @@ -29,7 +29,7 @@ info: | ... 7. Return true. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/values-are-not-cached.js index b8713376c36..c4e7be9f6d7 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > Integer indexed values are not cached before iteration info: | @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js index a3536b6e421..83b95c96df0 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > thisArg does not affect callbackfn arguments info: | diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js index c25b59e3153..49db00244a2 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > callbackfn arguments info: | diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js index fd6819e40e0..ac0055c1e13 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > Instance buffer can be detached during loop info: | diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js index e931d9fdc75..67eb0975edd 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > Does not interact over non-integer properties info: | diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js index 378ba78f612..5dd8c8f62c0 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: Throws a TypeError if callbackfn is not callable info: | 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js index f100e4b138d..d46882a9b8f 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > callbackfn is not called on empty instances info: | diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js index f8858f0197e..e243973c1c9 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js @@ -14,21 +14,21 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: Instance buffer can be resized during iteration includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js index 9148229df1f..9a65acfea58 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > The callbackfn return does not change the instance info: | diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js index 23a37da5b66..0bd927c490a 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: Returns abrupt from callbackfn info: | 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js index 7a2c6f5588e..beeea7e5746 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > Integer indexed values changed during iteration info: | diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js index eae584efff3..b082b5aa09e 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > callbackfn `this` value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js index 5aaeb259d60..b5be092e98c 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: Throws a TypeError if this has a detached buffer info: | 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js index 40598c6931e..d19d0d7f1f6 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: Get "length" uses internal ArrayLength info: | 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/every/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/every/invoked-as-func.js index c2327c12b9f..fe14736e800 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/every/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: Throws a TypeError exception when invoked as a function info: | 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/every/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/every/invoked-as-method.js index b033ed67e26..a4863b8099c 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/every/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/every/length.js b/test/sendable/builtins/TypedArray/prototype/every/length.js index a5a87402c56..852683c5013 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/length.js +++ b/test/sendable/builtins/TypedArray/prototype/every/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > %SendableTypedArray%.prototype.every.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/every/name.js b/test/sendable/builtins/TypedArray/prototype/every/name.js index 0fc415b2a09..3623a0723b4 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/name.js +++ b/test/sendable/builtins/TypedArray/prototype/every/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > %SendableTypedArray%.prototype.every.name is "every". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/every/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/every/prop-desc.js index 1b61c14e22c..2d9c3b3ff57 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/every/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > "every" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-grow-mid-iteration.js index bd91a9f2eed..313d0a1c274 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > SendableTypedArray.p.every behaves correctly when receiver is backed by resizable buffer that is grown mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-shrink-mid-iteration.js index eafb81b374d..6c5c6e1ebf4 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > SendableTypedArray.p.every behaves correctly when receiver is backed by resizable buffer that is shrunk mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer.js index cd3a6c291d1..3545f4c4872 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > SendableTypedArray.p.every behaves correctly when the receiver is backed by resizable buffer @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js index 4c2ac392753..ee3252361f9 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js b/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js index 2b049a41b8d..420a81ccb42 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > Returns false if any callbackfn call returns a coerced false. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js b/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js index 10d52fd59e9..cc0dc8a4475 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > Returns true if every callbackfn returns a coerced true. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/every/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/every/this-is-not-object.js index 907ed972042..2f3982a1200 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/every/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.7 %SendableTypedArray%.prototype.every ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js index 9766fc40796..8a0ad5cd215 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { every.call([], callbackfn); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { every.call(ab, callbackfn); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { every.call(dv, callbackfn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js index 5d49761829a..6ad7094dcde 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.every +esid: sec-%sendableTypedArray%.prototype.every description: > Integer indexed values are not cached before iteration info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/coerced-indexes.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/coerced-indexes.js index 2732e1b2f54..a5b3b2bd679 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/coerced-indexes.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/coerced-indexes.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills elements from coerced to Integer `start` and `end` values info: | @@ -40,7 +40,7 @@ info: | 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/detached-buffer.js index 1622d6917c5..c704df83bae 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: Throws a TypeError if this has a detached buffer info: | 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js index 78ed463ecbd..8e65038d939 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills all the elements with non numeric values values. info: | @@ -24,7 +24,7 @@ info: | 3. If O.[[TypedArrayName]] is "BigUint64Array" or "BigInt64Array", let value be ? ToBigInt(value). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js index 313551ae454..1c8637d5aaa 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills all the elements from a with a custom start and end indexes. info: | @@ -42,7 +42,7 @@ info: | 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js index d76d4c97c2c..3c53b2dae53 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills all the elements with non numeric values values. info: | @@ -33,7 +33,7 @@ info: | If relativeEnd is -Infinity, let final be 0. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). Else, let final be min(relativeEnd, len). - If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. Repeat, while k < final, Let Pk be ! ToString(F(k)). Perform ! Set(O, Pk, value, true). @@ -45,7 +45,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedArrayBuffer]]. + Let buffer be O.[[ViewedSendableArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. @@ -56,7 +56,7 @@ info: | Return NormalCompletion(undefined). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js index 6f007e2730c..a4ab9ec324c 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills all the elements with non numeric values values. info: | @@ -33,7 +33,7 @@ info: | If relativeEnd is -Infinity, let final be 0. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). Else, let final be min(relativeEnd, len). - If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. Repeat, while k < final, Let Pk be ! ToString(F(k)). Perform ! Set(O, Pk, value, true). @@ -45,7 +45,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedArrayBuffer]]. + Let buffer be O.[[ViewedSendableArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. @@ -55,7 +55,7 @@ info: | Perform SetValueInBuffer(buffer, indexedPosition, elementType, numValue, true, Unordered). Return NormalCompletion(undefined). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js index 44df948c75a..8fcc142fde8 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills all the elements from a with a custom end index. info: | @@ -39,7 +39,7 @@ info: | 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js index a82638dbcbf..bda20643be0 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills all the elements from a with a custom start index. info: | @@ -37,7 +37,7 @@ info: | 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be min(relativeStart, len). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js index 89ecace68e4..bf4770a9374 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Throws a TypeError if value is a Symbol info: | @@ -33,7 +33,7 @@ info: | If relativeEnd is -Infinity, let final be 0. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). Else, let final be min(relativeEnd, len). - If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. Repeat, while k < final, Let Pk be ! ToString(F(k)). Perform ! Set(O, Pk, value, true). @@ -45,7 +45,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedArrayBuffer]]. + Let buffer be O.[[ViewedSendableArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. @@ -56,7 +56,7 @@ info: | Return NormalCompletion(undefined). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values.js index 740485dff81..ede79153e26 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills all the elements with `value` from a default start and index. info: | @@ -37,7 +37,7 @@ info: | 7. Repeat, while k < final a. Let Pk be ! ToString(k). b. Perform ? Set(O, Pk, value, true). -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js index b2556ab5b41..aaa00c906b4 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned. info: | @@ -36,7 +36,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js index e71e46d81b5..a244569d38e 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Return abrupt if end is a Symbol. info: | @@ -37,7 +37,7 @@ info: | 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js index ac3a0289fed..c714e60167d 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Return abrupt from ToInteger(end). info: | @@ -37,7 +37,7 @@ info: | 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js index 685ac549bbd..d2603c2374a 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Returns abrupt from value set info: | @@ -33,7 +33,7 @@ info: | If relativeEnd is -Infinity, let final be 0. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). Else, let final be min(relativeEnd, len). - If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. Repeat, while k < final, Let Pk be ! ToString(F(k)). Perform ! Set(O, Pk, value, true). @@ -45,7 +45,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedArrayBuffer]]. + Let buffer be O.[[ViewedSendableArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. @@ -56,7 +56,7 @@ info: | Return NormalCompletion(undefined). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js index ec152106c2a..5921bfb41c2 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Return abrupt from ToInteger(start) as a Symbol. info: | @@ -36,7 +36,7 @@ info: | ... 3. Let relativeStart be ? ToInteger(start). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js index 8f0e42ffbf8..b98a7bba1ee 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Return abrupt from ToInteger(start). info: | @@ -36,7 +36,7 @@ info: | ... 3. Let relativeStart be ? ToInteger(start). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js index d69315a7814..21f2d1cc5fd 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-this.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-this.js index c38827009aa..ebb178c8cba 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-this.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-this.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Returns `this`. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js b/test/sendable/builtins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js index c1740c908ef..047ce0b38f2 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Absent start and end parameters are computed from initial length. info: | @@ -36,7 +36,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new ArrayBuffer(1, {maxByteLength: 4}); +let rab = new SendableArrayBuffer(1, {maxByteLength: 4}); let ta = new Int8Array(rab); let value = { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js index 408378872c6..1446d7988a7 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js @@ -14,14 +14,14 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Security Throws a TypeError if end coercion detaches the buffer info: | 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) 9. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len). - 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + 10. If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js index 7fca6ae3bbc..4080e4935d3 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills elements from coerced to Integer `start` and `end` values info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js index 164f5b8c0a7..0b5312682ac 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Security Throws a TypeError if start coercion detaches the buffer info: | @@ -22,7 +22,7 @@ info: | 6. Let relativeStart be ? ToInteger(start). ... - 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + 10. If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js index ecd417abea3..744081bd942 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Security Throws a TypeError if value coercion detaches the buffer info: | @@ -22,7 +22,7 @@ info: | 5. Otherwise, set value to ? ToNumber(value). ... - 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + 10. If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-start-end-resize.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-start-end-resize.js index 2ba94ef2de1..845f9157783 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-start-end-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-start-end-resize.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > SendableTypedArray.p.fill behaves correctly on receivers backed by a resizable buffer that's resized during argument coercion @@ -31,7 +31,7 @@ function SendableTypedArrayFillHelper(ta, n, start, end) { } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const evil = { valueOf: () => { @@ -44,7 +44,7 @@ for (let ctor of ctors) { }); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const evil = { valueOf: () => { @@ -57,7 +57,7 @@ for (let ctor of ctors) { }); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const evil = { valueOf: () => { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js index 321d6638120..52a28e2bedb 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: Throws a TypeError if this has a detached buffer info: | 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js index 0d9a20a703a..6c5811146b3 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills all the elements with non numeric values values. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js index 82b02658cbd..021432ee980 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > An implementation must always choose either the same encoding for each implementation distinguishable *NaN* value, or an implementation-defined canonical value. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations.js index 7a8f704cc0e..673c1beb80e 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills all the elements with non numeric values values. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js index 1208918e6d4..40777457a7f 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills all the elements from a with a custom start and end indexes. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js index 8612eb99a2d..71bbf3dbfd5 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills all the elements with non numeric values values. info: | @@ -33,7 +33,7 @@ info: | If relativeEnd is -Infinity, let final be 0. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). Else, let final be min(relativeEnd, len). - If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. Repeat, while k < final, Let Pk be ! ToString(F(k)). Perform ! Set(O, Pk, value, true). @@ -45,7 +45,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedArrayBuffer]]. + Let buffer be O.[[ViewedSendableArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js index dc21a923611..ac59e14a13e 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills all the elements from a with a custom end index. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js index 6cc33510e6d..7a2bd11ce17 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills all the elements from a with a custom start index. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js index 0d8224665d0..1fe0eb4cf8c 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Throws a TypeError if value is a Symbol info: | @@ -33,7 +33,7 @@ info: | If relativeEnd is -Infinity, let final be 0. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). Else, let final be min(relativeEnd, len). - If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. Repeat, while k < final, Let Pk be ! ToString(F(k)). Perform ! Set(O, Pk, value, true). @@ -45,7 +45,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedArrayBuffer]]. + Let buffer be O.[[ViewedSendableArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js index c11b99174d0..15a7e2396c0 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Fills all the elements with `value` from a default start and index. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js index 1e531493927..ce57bfd8b42 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Unreachable abrupt from Get(O, "length") as [[ArrayLength]] is returned. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-func.js index a7ebad2bbcf..d6dd9872838 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: Throws a TypeError exception when invoked as a function info: | 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-method.js index 6cea364f46a..b06ff32798d 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/fill/length.js b/test/sendable/builtins/TypedArray/prototype/fill/length.js index c362dc93bd2..3b3e241f2cf 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/length.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > %SendableTypedArray%.prototype.fill.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/name.js b/test/sendable/builtins/TypedArray/prototype/fill/name.js index 4a17d9aa518..329a42f3cb9 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/name.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > %SendableTypedArray%.prototype.fill.name is "fill". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/fill/prop-desc.js index eca1ffab353..b46ba693c6a 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > "fill" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/fill/resizable-buffer.js index 223d09adf5a..8e2ce25d6b9 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > SendableTypedArray.p.fill behaves correctly when the receiver is backed by resizable buffer @@ -40,7 +40,7 @@ function SendableTypedArrayFillHelper(ta, n, start, end) { } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js index 5d1d04c899c..5106304f51c 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Return abrupt if end is a Symbol. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js index b2d56c27085..6e6f58f648e 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Return abrupt from ToInteger(end). info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js index e76ff3e6003..b5882acc25c 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Returns abrupt from value set info: | @@ -33,7 +33,7 @@ info: | If relativeEnd is -Infinity, let final be 0. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). Else, let final be min(relativeEnd, len). - If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. Repeat, while k < final, Let Pk be ! ToString(F(k)). Perform ! Set(O, Pk, value, true). @@ -45,7 +45,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedArrayBuffer]]. + Let buffer be O.[[ViewedSendableArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js index 8241f4e81b0..d545699126c 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Return abrupt from ToInteger(start) as a Symbol. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js index d58fcd9c448..18d3da40835 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Return abrupt from ToInteger(start). info: | diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js index 65543c854d9..a543925a375 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-this.js b/test/sendable/builtins/TypedArray/prototype/fill/return-this.js index 5ef376eab78..106481375c0 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-this.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Returns `this`. includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-object.js index 7c976237b93..9a6a7727a72 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js index f8d6b7f18b4..95578ca769f 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.fill +esid: sec-%sendableTypedArray%.prototype.fill description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { fill.call([], 0); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { fill.call(ab, 0); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { fill.call(dv, 0); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js index 8c858da49ea..db4a7f851ba 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: Uses internal ArrayLength instead of length property info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) @@ -22,7 +22,7 @@ info: | ... 3. Let len be the value of O's [[ArrayLength]] internal slot. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js index 973f27a7cbc..e706b43c84b 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > thisArg does not affect callbackfn arguments info: | @@ -25,7 +25,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js index e2b24944778..f3924fe8aaf 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > callbackfn arguments info: | @@ -25,7 +25,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js index b605532d76d..021531c3f86 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: callbackfn is called for each item before SendableTypedArraySpeciesCreate info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) @@ -26,7 +26,7 @@ info: | ... 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js index 8b80a9b48b0..9496b5a96d7 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: callbackfn is called for each item before SendableTypedArraySpeciesCreate info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) @@ -26,7 +26,7 @@ info: | ... 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js index b45603462c4..50610e89fd9 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Instance buffer can be detached during loop info: | @@ -26,7 +26,7 @@ info: | b. Let kValue be ? Get(O, Pk). c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [detachArrayBuffer.js, testBigIntSendableTypedArray.js] +includes: [detachArrayBuffer.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js index d0d5e7f3c43..9c3f2ffce3d 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Does not iterate over non-integer properties info: | @@ -25,7 +25,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js index 120db9c74b0..dfcd5741d99 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: Throws TypeError if callbackfn is not callable info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) @@ -22,7 +22,7 @@ info: | ... 4. If IsCallable(callbackfn) is false, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js index 99ed7b24b0b..2701ed3e464 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > callbackfn is not called on empty instances info: | @@ -25,7 +25,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js index 0ed2fda2cfe..92ddae69b0e 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > The callbackfn return does not change the instance -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js index a16300c5437..8d22092a6ed 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Returns abrupt from callbackfn info: | @@ -25,7 +25,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js index c1963371ed0..fd72aac31ad 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Integer indexed values changed during iteration info: | @@ -25,7 +25,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Reflect.set, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-this.js index 91caa1206d5..e9ee24e5219 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > callbackfn `this` value info: | @@ -27,7 +27,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/detached-buffer.js index a2c7a056cdf..d2124643524 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: Throws a TypeError if this has a detached buffer info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js index fd8cca4f4ec..8a0b4e64364 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Return does not share buffer info: | @@ -24,7 +24,7 @@ info: | 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). ... 13. Return A. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js index b2a3fe71be9..dfaa571afa7 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Returns empty if every callbackfn returns boolean false info: | @@ -25,7 +25,7 @@ info: | a. Perform ! Set(A, ! ToString(n), e, true). b. Increment n by 1. 13. Return A. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js index 1e6d9d8fa16..82b40ec7a0a 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Returns full length result if every callbackfn returns boolean false info: | @@ -25,7 +25,7 @@ info: | a. Perform ! Set(A, ! ToString(n), e, true). b. Increment n by 1. 13. Return A. -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js index 7fcfeffcde9..8b916389eeb 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-destination-resizable.js index beff337f9d6..36560fbd3cb 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-destination-resizable.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Throws a TypeError if new typedArray's length < count info: | @@ -36,14 +36,14 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ testWithBigIntSendableTypedArrayConstructors(function(TA) { - const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); + const rab1 = new SendableArrayBuffer(8, {maxByteLength: 100}); const ta = new TA(rab1); - const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); + const rab2 = new SendableArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab2); rab2.resize(0); ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js index e8c63dabdab..b6006fa20c8 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: Return abrupt from SpeciesConstructor's get Constructor info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js index 2b4b7a5e980..05f2b3521ed 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: get inherited constructor on SpeciesConstructor info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js index 493f66ac532..eccbfb4523a 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Throws if O.constructor returns a non-Object and non-undefined value info: | @@ -37,7 +37,7 @@ info: | 3. If C is undefined, return defaultConstructor. 4. If Type(C) is not Object, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js index 500b7260f16..00c3e8240e2 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: get constructor on SpeciesConstructor info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js index e6dd9b316aa..27e10f046ce 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Returns abrupt from get @@species on found constructor info: | @@ -37,7 +37,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js index 4fbd31986be..032ab01cf45 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Verify arguments on custom @@species construct call info: | @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index 6628ccff37e..8c27ddb1091 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Throws a TypeError if new typedArray's length < count info: | @@ -36,13 +36,13 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ testWithBigIntSendableTypedArrayConstructors(function(TA) { var sample = new TA(2); - const rab = new ArrayBuffer(10, {maxByteLength: 20}); + const rab = new SendableArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab); sample.constructor = {}; sample.constructor[Symbol.species] = function() { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js index 7b7b6cbb1b7..9058f162f1d 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Throws a TypeError if new typedArray's length < captured info: | @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js index 7713e4351f4..c790ac2ecfe 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Does not throw a TypeError if new typedArray's length >= captured info: | @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js index be812bd84ac..3b27ce7d7e8 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Custom @@species constructor may return a different SendableTypedArray info: | @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js index 995fea92819..00725953d8d 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Custom @@species constructor throws if it does not return a compatible object info: | @@ -43,7 +43,7 @@ info: | 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js index c63ff4d07b9..db2c20914dc 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Use custom @@species constructor if available info: | @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js index 134982a97f1..d91877d175d 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Throws if returned @@species is not a constructor, null or undefined. info: | @@ -38,7 +38,7 @@ info: | 7. If IsConstructor(S) is true, return S. 8. Throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js index 3fed50402ac..94a9c346c31 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Use defaultConstructor if @@species is either undefined or null info: | @@ -36,7 +36,7 @@ info: | 5. Let S be ? Get(C, @@species). 6. If S is either undefined or null, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js index 413f2b1bc8f..5c1f0c840d5 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > get @@species from found constructor info: | @@ -37,7 +37,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js index 9a51f64361f..008d1deae66 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Integer indexed values are not cached before interaction info: | @@ -25,7 +25,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-set.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-set.js index 50b56244b26..185e0583846 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-set.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-set.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Returned instance with filtered values set on it info: | @@ -25,7 +25,7 @@ info: | a. Perform ! Set(A, ! ToString(n), e, true). b. Increment n by 1. 13. Return A. -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js index 3166fdd6cbc..93e203643aa 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: Uses internal ArrayLength instead of length property info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js index 0fc165341fe..788a8cab209 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > thisArg does not affect callbackfn arguments info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js index 6de9a6d1310..6714f4f8afc 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > callbackfn arguments info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js index 8083916e7d4..afb4bbdd198 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: callbackfn is called for each item before SendableTypedArraySpeciesCreate info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js index d9171bcca1d..96482032861 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: callbackfn is called for each item before SendableTypedArraySpeciesCreate info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js index 740bfcd5368..1e22c861f2a 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Instance buffer can be detached during loop info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js index 26587ac6dbc..855feaa90dd 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Does not iterate over non-integer properties info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js index 2df1f29e3ef..5644dc1bebc 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: Throws TypeError if callbackfn is not callable info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js index 2031d39f728..e0b6b0a6157 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > callbackfn is not called on empty instances info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js index 691e14c8c5b..22c6f0ff265 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js @@ -14,22 +14,22 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: Instance buffer can be resized during iteration includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; var NaNvalue = isFloatSendableTypedArrayConstructor(TA) ? NaN : 0; - var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, finalResult, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js index 2b117a3082e..d97f7e610f3 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > The callbackfn return does not change the instance includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js index ee1a8effa9e..9d60e5ecd74 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Returns abrupt from callbackfn info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js index 40da97c20eb..bb90c1ac644 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Integer indexed values changed during iteration info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js index 1bab8d1d53c..1e9e25db6b4 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > callbackfn `this` value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js index 92b375ac8c7..c4155ce1ac5 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: Throws a TypeError if this has a detached buffer info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-func.js index 15e72e14c23..50b25324f33 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: Throws a TypeError exception when invoked as a function info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-method.js index 8dbc8ffa504..7ab2565c0d2 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/filter/length.js b/test/sendable/builtins/TypedArray/prototype/filter/length.js index 5a8940078c1..e41c7c39998 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/length.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > %SendableTypedArray%.prototype.filter.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/name.js b/test/sendable/builtins/TypedArray/prototype/filter/name.js index 64841d0b0e8..6ce6d6356b1 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/name.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > %SendableTypedArray%.prototype.filter.name is "filter". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/filter/prop-desc.js index bf870f3a798..fa4c880e9c4 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > "filter" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-grow-mid-iteration.js index bb6186c9242..06caa682701 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > SendableTypedArray.p.filter behaves correctly on SendableTypedArrays backed by resizable buffers that grow mid-iteration. diff --git a/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-shrink-mid-iteration.js index 9ccb8bb19f5..1d31584ab23 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > SendableTypedArray.p.filter behaves correctly on SendableTypedArrays backed by resizable buffers that are shrunk mid-iteration. diff --git a/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer.js index c220cb33a28..69627eef937 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > SendableTypedArray.p.filter behaves correctly on SendableTypedArrays backed by resizable buffers @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js index edfdbed14dc..fb6a545a4a7 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Return does not share buffer info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js b/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js index 1206a308906..ae25a9ffb22 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Returns empty if every callbackfn returns boolean false info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js b/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js index b6b4b812b71..968d669e788 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Returns full length result if every callbackfn returns boolean false info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js index 2582a726fdb..d615388e699 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js index dad29c24b9d..b340770279b 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Throws a TypeError if new typedArray's length < count info: | @@ -41,9 +41,9 @@ features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ testWithSendableTypedArrayConstructors(function(TA) { - const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); + const rab1 = new SendableArrayBuffer(8, {maxByteLength: 100}); const ta = new TA(rab1); - const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); + const rab2 = new SendableArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab2); rab2.resize(0); ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js index 8a845a7dd17..775b0d5e95f 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: Return abrupt from SpeciesConstructor's get Constructor info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js index a6430c7fbe3..766ac4ed41b 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: get inherited constructor on SpeciesConstructor info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js index b6379888ea6..58fe22e7f25 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Throws if O.constructor returns a non-Object and non-undefined value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js index eea4d32b8cd..110f213487d 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: get constructor on SpeciesConstructor info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js index 79e606c1513..4bebf086548 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Returns abrupt from get @@species on found constructor info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js index 746b2dd9e50..0975335f30c 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Verify arguments on custom @@species construct call info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index 0992779f9ad..13a6db6617d 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Throws a TypeError if new typedArray's length < count info: | @@ -42,7 +42,7 @@ features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] testWithSendableTypedArrayConstructors(function(TA) { var sample = new TA(2); - const rab = new ArrayBuffer(10, {maxByteLength: 20}); + const rab = new SendableArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab); sample.constructor = {}; sample.constructor[Symbol.species] = function() { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js index 0c0437e4df1..b0f634a1606 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Throws a TypeError if new typedArray's length < captured info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js index c45d1063ee2..1681221bd10 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Does not throw a TypeError if new typedArray's length >= captured info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js index e9d3f7202b5..71b89c10e2d 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Custom @@species constructor may return a different SendableTypedArray info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js index b76efe4858e..2ca18b4b67a 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Custom @@species constructor throws if it does not return a compatible object info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js index ec50aa09a15..03996c21d22 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Use custom @@species constructor if available info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js index 57f6ec4e468..d8b48236355 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Throws if returned @@species is not a constructor, null or undefined. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js index 7aa068cfa9d..bc747ca1431 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Use defaultConstructor if @@species is either undefined or null info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js index 7297407e58b..c5da28fcb1e 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > get @@species from found constructor info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-object.js index 6b9f671644b..b6bd43dda18 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.9 %SendableTypedArray%.prototype.filter ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js index 985b664dd3e..403c1cc5513 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -47,12 +47,12 @@ assert.throws(TypeError, function() { filter.call([], callbackfn); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { filter.call(ab, callbackfn); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { filter.call(dv, callbackfn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js index 8692ce8849a..fd64adc2977 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Integer indexed values are not cached before interaction info: | diff --git a/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js b/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js index 7331443a9ed..fe4550f09d1 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.filter +esid: sec-%sendableTypedArray%.prototype.filter description: > Returned instance with filtered values set on it info: | diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/detached-buffer.js index 41b83ba2ff8..818a3c19522 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: Throws a TypeError if this has a detached buffer info: | 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js index feadbbbd360..1ce4f8eeba2 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > [[Get]] of "length" uses [[ArrayLength]] info: | @@ -34,7 +34,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js index b3d555206a1..cd6b76dc003 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Change values during predicate call info: | @@ -38,7 +38,7 @@ info: | ... c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js index e484e85db27..a48c1c1d869 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. info: | @@ -38,7 +38,7 @@ info: | ... c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js index e34462edb6c..4e5e2bcce26 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Verify predicate this on non-strict mode info: | @@ -39,7 +39,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... flags: [noStrict] -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-strict.js index 91d6266450f..44a83915738 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Verify predicate this on strict mode info: | @@ -39,7 +39,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... flags: [onlyStrict] -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js index 1b78d29092a..99b8d1a0924 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Throws a TypeError exception if predicate is not callable. info: | @@ -34,7 +34,7 @@ info: | ... 3. If IsCallable(predicate) is false, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js index 58d543f206d..d4a8a0a3023 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Predicate may detach the buffer info: | @@ -48,10 +48,10 @@ info: | IntegerIndexedElementGet ( O, index ) ... - Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js index dc78e2eaed4..8d2617e61a3 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Predicate is not called on empty instances info: | @@ -36,7 +36,7 @@ info: | ... c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js index f9ddbfe6e00..4eea0c3025f 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Return abrupt from predicate call. info: | @@ -36,7 +36,7 @@ info: | ... c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js index b6adea0bb90..f39a4b83c56 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js index e9f4d621d94..4595e8d8ec7 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Return found value if predicate return a boolean true value. info: | @@ -37,7 +37,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). d. If testResult is true, return kValue. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js index 469bc2ff6c1..9519c80fdd9 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Return undefined if predicate always returns a boolean false value. info: | @@ -37,7 +37,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... 7. Return undefined. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js index 941770effb8..607fde4ee38 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js @@ -14,21 +14,21 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: Instance buffer can be resized during iteration includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js index 21ef474d589..0d26c336c9c 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: Throws a TypeError if this has a detached buffer info: | 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js index 2666bf1a106..439e9ecbab5 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > [[Get]] of "length" uses [[ArrayLength]] info: | diff --git a/test/sendable/builtins/TypedArray/prototype/find/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/find/invoked-as-func.js index 94bc8089e39..584d12b63f0 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/find/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: Throws a TypeError exception when invoked as a function info: | 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/find/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/find/invoked-as-method.js index 4d4e2295147..b6894c06d94 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/find/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/find/length.js b/test/sendable/builtins/TypedArray/prototype/find/length.js index 1e6b6eda97a..afe2231166a 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/length.js +++ b/test/sendable/builtins/TypedArray/prototype/find/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > %SendableTypedArray%.prototype.find.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/find/name.js b/test/sendable/builtins/TypedArray/prototype/find/name.js index 145f9880690..d7d2faff69d 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/name.js +++ b/test/sendable/builtins/TypedArray/prototype/find/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > %SendableTypedArray%.prototype.find.name is "find". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js index b4fcf8eeab5..bb4c1691937 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Change values during predicate call info: | diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js index 54ae928585d..c98d8e4c4ec 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js index f60e49b230b..dfd5f783fa6 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Verify predicate this on non-strict mode info: | diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js index ba041a4d18d..22252d5e621 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Verify predicate this on strict mode info: | diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js index 1bb8dad2c6c..4d61560fcb6 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Throws a TypeError exception if predicate is not callable. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js index e6f3a4daa1c..1c8c918a6c0 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Predicate may detach the buffer info: | @@ -48,7 +48,7 @@ info: | IntegerIndexedElementGet ( O, index ) ... - Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. includes: [testTypedArray.js, detachArrayBuffer.js] diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js index 87107d2da39..9c7fc711109 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Predicate is not called on empty instances info: | diff --git a/test/sendable/builtins/TypedArray/prototype/find/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/find/prop-desc.js index 8c018a55e94..866da14feb6 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/find/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > "find" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-grow-mid-iteration.js index 5e573f739e8..4d9154decb0 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > SendableTypedArray.p.find behaves correctly when receiver is backed by resizable buffer that is grown mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-shrink-mid-iteration.js index 11902e66c15..f0b2926bb91 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > SendableTypedArray.p.find behaves correctly when receiver is backed by resizable buffer that is shrunk mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer.js index 1ad8c26825a..c11c238c22f 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > SendableTypedArray.p.find behaves correctly when receiver is backed by resizable buffer @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js index fcc56365cd9..185c124d50e 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Return abrupt from predicate call. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js index 46751f4dd67..4789586547b 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js index 34d67846986..37273089a65 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Return found value if predicate return a boolean true value. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js index f6d07db5357..8f0c4a4d442 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Return undefined if predicate always returns a boolean false value. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/find/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/find/this-is-not-object.js index 98778eba08b..943f082e6ed 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/find/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.10 %SendableTypedArray%.prototype.find (predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js index e7c49dba7a9..969880dbcf5 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.find +esid: sec-%sendableTypedArray%.prototype.find description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { find.call([], predicate); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { find.call(ab, predicate); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { find.call(dv, predicate); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js index 4ec9effba72..271d70b0411 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: Throws a TypeError if this has a detached buffer info: | 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js index a880836a31a..c8b91bfe1b3 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > [[Get]] of "length" uses [[ArrayLength]] info: | @@ -32,7 +32,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js index 80b4b59d1d0..c19c0bf59cc 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Change values during predicate call info: | @@ -34,7 +34,7 @@ info: | ... c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js index b1607095437..15dd2b3ad29 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. info: | @@ -36,7 +36,7 @@ info: | ... c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js index 8be0de2b156..952cc84cdbf 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Verify predicate this on non-strict mode info: | @@ -37,7 +37,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... flags: [noStrict] -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict.js index cd94c7a5b59..e5126ad4e2f 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. info: | @@ -37,7 +37,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... flags: [onlyStrict] -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js index a59f5211ba3..a4b87ca0278 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Throws a TypeError exception if predicate is not callable. info: | @@ -32,7 +32,7 @@ info: | ... 3. If IsCallable(predicate) is false, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js index 75aa30a1315..0422761cac4 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Predicate may detach the buffer info: | @@ -39,10 +39,10 @@ info: | 9.4.5.8 IntegerIndexedElementGet ( O, index ) ... - 3. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 3. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js index 2a575a032dd..e6190884597 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Predicate is not called on an empty instance info: | @@ -35,7 +35,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... 7. Return -1. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js index 94393730393..2e8b382c1e3 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Return abrupt from predicate call. info: | @@ -35,7 +35,7 @@ info: | ... c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js index fe1d5a76c1c..a766744a718 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js index 6f605ba52be..0cac30c67a6 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Return index if predicate return a boolean true value. info: | @@ -36,7 +36,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). d. If testResult is true, return k. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js index cf9e67e14c3..c120f7df039 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Return -1 if predicate always returns a boolean false value. info: | @@ -35,7 +35,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... 7. Return -1. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js index 94cdcfdec1c..b307bc28aa0 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js @@ -14,21 +14,21 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: Instance buffer can be resized during iteration includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js index b3b77ec226c..adf2ffdcb83 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: Throws a TypeError if this has a detached buffer info: | 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js index bb50b80ea8f..2e8972fc609 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > [[Get]] of "length" uses [[ArrayLength]] info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-func.js index 91a16bd3ed6..e7411b66d9d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: Throws a TypeError exception when invoked as a function info: | 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-method.js index 7ca5a9a14c9..180e57e1ae3 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/length.js b/test/sendable/builtins/TypedArray/prototype/findIndex/length.js index 5d65b315706..6cf6091b507 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/length.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > %SendableTypedArray%.prototype.findIndex.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/name.js b/test/sendable/builtins/TypedArray/prototype/findIndex/name.js index 521c0475429..d74106a06e0 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/name.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > %SendableTypedArray%.prototype.findIndex.name is "findIndex". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js index 0de62a3d336..d891dbd598c 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Change values during predicate call info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js index 22d57b8b04f..2c743ab07e9 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js index 3ed551ab8c8..74cd8dea116 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Verify predicate this on non-strict mode info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js index 58e6e43ef7b..9dba29e8469 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js index 23cd2c79ba8..6c449cccd0d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Throws a TypeError exception if predicate is not callable. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js index b460c8d90a7..05c28a15e8b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Predicate may detach the buffer info: | @@ -37,7 +37,7 @@ info: | IntegerIndexedElementGet ( O, index ) - Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. includes: [testTypedArray.js, detachArrayBuffer.js] diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js index d275eed6f86..a29c4690859 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Predicate is not called on an empty instance info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/findIndex/prop-desc.js index fcefd8e511e..48ac0e52c26 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > "findIndex" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-grow-mid-iteration.js index cc47e995f7f..426192a180f 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > SendableTypedArray.p.findIndex behaves correctly when receiver is backed by resizable buffer that is grown mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-shrink-mid-iteration.js index 269f6aa9e17..a8f35e6f0c2 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > SendableTypedArray.p.findIndex behaves correctly when receiver is backed by resizable buffer that is shrunk mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer.js index e06a115e1a7..00cee504fed 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > SendableTypedArray.p.findIndex behaves correctly when receiver is backed by resizable buffer @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js index 3e13533d6b9..13d694bec45 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Return abrupt from predicate call. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js index e1837d03c6b..c2c999868c4 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js index b4fc005f254..d9b82044dee 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Return index if predicate return a boolean true value. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js index 618515daae1..f4aef2d5c58 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Return -1 if predicate always returns a boolean false value. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-object.js index bd3bffcb7a0..336be044e6b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.11 %SendableTypedArray%.prototype.findIndex ( predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js index 21d80bdc6be..fbdf72a9596 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findindex +esid: sec-%sendableTypedArray%.prototype.findindex description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { findIndex.call([], predicate); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { findIndex.call(ab, predicate); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { findIndex.call(dv, predicate); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/detached-buffer.js index b7b23d57876..5623c1f2ae8 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: Throws a TypeError if this has a detached buffer info: | %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) @@ -26,7 +26,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js index 445f77fada9..1cf9e43f41e 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > [[Get]] of "length" uses [[ArrayLength]] info: | @@ -23,7 +23,7 @@ info: | ... 3. Let len be O.[[ArrayLength]]. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js index d025d7c55bf..d48dd8c884a 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Change values during predicate call info: | @@ -26,7 +26,7 @@ info: | ... c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js index 9ed6b6f543f..d1e19a9b6af 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. info: | @@ -25,7 +25,7 @@ info: | ... c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js index 68c8c7127fb..1389fbe0319 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Verify predicate this on non-strict mode info: | @@ -25,7 +25,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... flags: [noStrict] -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict.js index fbc9b9f23ef..2d7af1778f8 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Verify predicate this on strict mode info: | @@ -25,7 +25,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... flags: [onlyStrict] -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js index 5679e7ea020..dfac2ea30b1 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Throws a TypeError exception if predicate is not callable. info: | @@ -23,7 +23,7 @@ info: | ... 4. If IsCallable(predicate) is false, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js index 66c35616d92..01f2e878adb 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Predicate may detach the buffer info: | @@ -30,10 +30,10 @@ info: | IntegerIndexedElementGet ( O, index ) ... - Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js index 66b3a92cee4..da6868d68ca 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Predicate is not called on empty instances info: | @@ -24,7 +24,7 @@ info: | ... c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js index bd858d0821e..b3c7a3b7a99 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Return abrupt from predicate call. info: | @@ -24,7 +24,7 @@ info: | ... c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js index fdd1ac5fe60..9cdc9f31276 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, array-find-from-last, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, array-find-from-last, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js index e3ab7cd8431..1e9ec140629 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Return found value if predicate return a boolean true value. info: | @@ -25,7 +25,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). d. If testResult is true, return kValue. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js index 2282b1ae485..b17b8299fba 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Return undefined if predicate always returns a boolean false value. info: | @@ -26,7 +26,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... 7. Return undefined. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js index 9ad2eff84ba..7a89e1c68ee 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js @@ -14,21 +14,21 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: Instance buffer can be resized during iteration includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var secondElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js index b0db2eb7f08..02dd8fa3a7c 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: Throws a TypeError if this has a detached buffer info: | %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js index a56aff02bbc..d30cf2ca1b7 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > [[Get]] of "length" uses [[ArrayLength]] info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-func.js index 05fc6644e2d..2e7e989c569 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: Throws a TypeError exception when invoked as a function info: | %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-method.js index de76e7ce8ea..1c5b6798b42 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: Requires a [[TypedArrayName]] internal slot. info: | %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/length.js b/test/sendable/builtins/TypedArray/prototype/findLast/length.js index 198150ef4ab..4276a25ada0 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/length.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > %SendableTypedArray%.prototype.findLast.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/name.js b/test/sendable/builtins/TypedArray/prototype/findLast/name.js index cf30c441ca9..f784f660ffc 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/name.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > %SendableTypedArray%.prototype.findLast.name is "findLast". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js index 2cecf5cafe7..99f70a5a8bf 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Change values during predicate call info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js index 3f7d9640a9a..0ac4e56db1e 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js index 6f6ee789c36..d96849c1964 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Verify predicate this on non-strict mode info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js index c43e4aa2a33..842832d7b60 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Verify predicate this on strict mode info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js index 073fd1f7b06..1f31e09159d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Throws a TypeError exception if predicate is not callable. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js index d6927603ed3..f5d6066fb6f 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Predicate may detach the buffer info: | @@ -30,7 +30,7 @@ info: | IntegerIndexedElementGet ( O, index ) ... - Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. includes: [testTypedArray.js, detachArrayBuffer.js] diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js index 349574268e1..d4e0150d095 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Predicate is not called on empty instances info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/findLast/prop-desc.js index 06792a0fc5c..e6284d09761 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findLast +esid: sec-%sendableTypedArray%.prototype.findLast description: > "findLast" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-grow-mid-iteration.js index e0ee9de847e..55d0c94442b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > SendableTypedArray.p.findLast behaves correctly when receiver is backed by resizable buffer that is grown mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-shrink-mid-iteration.js index a45d71ecd68..dd14ff28572 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > SendableTypedArray.p.findLast behaves correctly when receiver is backed by resizable buffer that is shrunk mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer.js index b22c328860a..5c97ec610b8 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > SendableTypedArray.p.findLast behaves correctly when receiver is backed by resizable buffer @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js index 61b13a96b65..fe2000d0439 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Return abrupt from predicate call. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js index 28267652df9..d1b6a957323 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer, array-find-from-last] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js index d3f834148e5..875ed9c1e7d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Return found value if predicate return a boolean true value. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js index e142890d616..4d0e7a0fc82 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Return undefined if predicate always returns a boolean false value. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-object.js index b401eefa4e3..ae2baaffd10 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: Throws a TypeError exception when `this` is not Object info: | %SendableTypedArray%.prototype.findLast (predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js index e0c18a53b49..61ff1e0ca17 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlast +esid: sec-%sendableTypedArray%.prototype.findlast description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -43,12 +43,12 @@ assert.throws(TypeError, function() { findlast.call([], predicate); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { findlast.call(ab, predicate); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { findlast.call(dv, predicate); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js index 4b2fa232e16..5a4e4efda4f 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: Throws a TypeError if this has a detached buffer info: | %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js index 86762ad2892..c75f03a3f81 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > [[Get]] of "length" uses [[ArrayLength]] info: | @@ -23,7 +23,7 @@ info: | ... 3. Let len be O.[[ArrayLength]]. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js index ac985664793..1cdea936b4a 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Change values during predicate call info: | @@ -25,7 +25,7 @@ info: | ... c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js index 448e56ca3f7..f967a1278a4 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. info: | @@ -26,7 +26,7 @@ info: | ... c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js index f366e82a6c7..709cdf02dc3 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Verify predicate this on non-strict mode info: | @@ -27,7 +27,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... flags: [noStrict] -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict.js index b63f0830a60..aa0b6e11462 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. info: | @@ -27,7 +27,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... flags: [onlyStrict] -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js index d1f5440d7b8..9a4ac7297f1 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Throws a TypeError exception if predicate is not callable. info: | @@ -23,7 +23,7 @@ info: | ... 4. If IsCallable(predicate) is false, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js index fc84c7f0ac3..b98f9a29b4f 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Predicate may detach the buffer info: | @@ -29,10 +29,10 @@ info: | IntegerIndexedElementGet ( O, index ) - Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js index 75f9b06f205..a389b9102a9 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Predicate is not called on an empty instance info: | @@ -26,7 +26,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... 7. Return -1. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js index 195b6d6d8eb..adba841a034 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Return abrupt from predicate call. info: | @@ -26,7 +26,7 @@ info: | ... c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js index a82c66fd0ae..c36007ad173 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, array-find-from-last, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, array-find-from-last, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js index 08a81efcfc6..5a0532baaee 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Return index if predicate return a boolean true value. info: | @@ -27,7 +27,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). d. If testResult is true, return 𝔽(k). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js index f6ec5f0823f..553b6d54174 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Return -1 if predicate always returns a boolean false value. info: | @@ -27,7 +27,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... 7. Return -1𝔽. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js index bf5bd4e3d4b..91bef630442 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js @@ -14,21 +14,21 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: Instance buffer can be resized during iteration includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var secondElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js index a55cbeec969..c9b6d6d99c8 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: Throws a TypeError if this has a detached buffer info: | %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js index cdfbc279f08..0613a9fd03d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > [[Get]] of "length" uses [[ArrayLength]] info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-func.js index cc099593ccf..9d3ab0aea92 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: Throws a TypeError exception when invoked as a function info: | %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-method.js index de880435118..eca7cca2680 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: Requires a [[TypedArrayName]] internal slot. info: | %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/length.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/length.js index d4c561e014e..fef2b798982 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/length.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > %SendableTypedArray%.prototype.findLastIndex.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/name.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/name.js index 15698a146a7..d24bfdc6360 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/name.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > %SendableTypedArray%.prototype.findLastIndex.name is "findLastIndex". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js index 70b87f9f326..4811f00dd1f 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Change values during predicate call info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js index ac04f354b12..a8d5df611f6 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Predicate called as F.call( thisArg, kValue, k, O ) for each array entry. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js index 98d60bf8de3..ebed22fe8f5 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Verify predicate this on non-strict mode info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js index e25ee335434..91e4150d242 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Predicate thisArg as F.call( thisArg, kValue, k, O ) for each array entry. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js index 36924a67059..56004040415 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Throws a TypeError exception if predicate is not callable. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js index ea4e512f6e0..143848f51f7 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Predicate may detach the buffer info: | @@ -29,7 +29,7 @@ info: | IntegerIndexedElementGet ( O, index ) - Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. includes: [testTypedArray.js, detachArrayBuffer.js] diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js index c85e35adb60..896e55b8452 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Predicate is not called on an empty instance info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/prop-desc.js index 4e14b00a316..8fb7bd56aed 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > "findLastIndex" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-grow-mid-iteration.js index 931bf5e6da3..cb6cb82c860 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > SendableTypedArray.p.findLastIndex behaves correctly when receiver is backed by resizable buffer that is grown mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-shrink-mid-iteration.js index 675c3112dd1..59acab440ef 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > SendableTypedArray.p.findLastIndex behaves correctly when receiver is backed by resizable buffer that is shrunk mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer.js index 749019e5dc1..9c8ad827b17 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > SendableTypedArray.p.findLastIndex behaves correctly when receiver is backed by resizable buffer @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js index 704395a8206..bf19545c1b6 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Return abrupt from predicate call. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js index 0cd9a330228..aae3f0dc2d7 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer, array-find-from-last] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js index 1a5cae6d22e..2f60ffde4db 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Return index if predicate return a boolean true value. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js index 99558214c0c..a75d3f96556 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Return -1 if predicate always returns a boolean false value. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-object.js index b370ea78d22..a045abcb55a 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: Throws a TypeError exception when `this` is not Object info: | %SendableTypedArray%.prototype.findLastIndex ( predicate [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js index 307be3c8ce5..51a85d09c4e 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.findlastindex +esid: sec-%sendableTypedArray%.prototype.findlastindex description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { findLastIndex.call([], predicate); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { findLastIndex.call(ab, predicate); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { findLastIndex.call(dv, predicate); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js index e04b79116fc..b8c8cb92232 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > [[ArrayLength]] is accessed in place of performing a [[Get]] of "length" info: | @@ -24,7 +24,7 @@ info: | algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the this object's [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of "length" -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js index c7515cb8fa9..aeeffd24978 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > thisArg does not affect callbackfn arguments info: | @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Perform ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js index 57377b04532..bb6c56625b0 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > callbackfn arguments info: | @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Perform ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js index 1db0184bf45..a9b4a87c854 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > Instance buffer can be detached during loop info: | @@ -34,7 +34,7 @@ info: | ... ii. Perform ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [detachArrayBuffer.js, testBigIntSendableTypedArray.js] +includes: [detachArrayBuffer.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js index f003992dfaf..29a496b4f4e 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > callbackfn is not callable info: | @@ -30,7 +30,7 @@ info: | ... 3. If IsCallable(callbackfn) is false, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js index f253db73d62..5b31f0d069a 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > Does not interact over non-integer properties info: | @@ -27,7 +27,7 @@ info: | ... ii. Perform ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js index ca8a482dadb..98222e7cd5c 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > callbackfn is not called on empty instances info: | @@ -34,7 +34,7 @@ info: | ... ii. Perform ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js index 51528130617..92b2c069a58 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > The callbackfn return does not change the instance info: | @@ -24,7 +24,7 @@ info: | algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the this object's [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of "length" -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js index 2059f0e4573..2a4e5edd65c 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > Returns abrupt from callbackfn info: | @@ -34,7 +34,7 @@ info: | ... ii. Perform ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js index a8991c28f1f..c8282741f9a 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > Integer indexed values changed during iteration info: | @@ -24,7 +24,7 @@ info: | algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the this object's [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of "length" -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Reflect.set, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js index 8a8bb51068b..ccaae25443d 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > callbackfn `this` value info: | @@ -36,7 +36,7 @@ info: | ... ii. Perform ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/detached-buffer.js index dbd1ac29df6..fb106d8524f 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: Throws a TypeError if this has a detached buffer info: | 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js index c95bf39e4df..3f22b3af59c 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/returns-undefined.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/returns-undefined.js index 6967351c7fc..bc60afafca0 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/returns-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/returns-undefined.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > Returns undefined info: | @@ -24,7 +24,7 @@ info: | algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the this object's [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of "length" -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js index dd96a06b373..387f1358926 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > Integer indexed values are not cached before iteration info: | @@ -24,7 +24,7 @@ info: | algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the this object's [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of "length" -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js index 6c6f7ec7472..e2fc16c34f6 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > [[ArrayLength]] is accessed in place of performing a [[Get]] of "length" info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js index aa1c02f2b7e..93dd31cf2ba 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > thisArg does not affect callbackfn arguments info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js index 689fdf3d5d5..fa9dbc67263 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > callbackfn arguments info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js index 5f7507dd0f6..cef3c231e9a 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > Instance buffer can be detached during loop info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js index fb9c8b8ca86..9990c375035 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > callbackfn is not callable info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js index 70c6dc1d2e5..e7f257781e2 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > Does not interact over non-integer properties info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js index ba3ec8859d0..940691237c7 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > callbackfn is not called on empty instances info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js index 5aa77ab33d2..4e938d4b93d 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js @@ -14,21 +14,21 @@ */ /*--- -esid: sec-%typedarray%.prototype.forEach +esid: sec-%sendableTypedArray%.prototype.forEach description: Instance buffer can be resized during iteration includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js index 164b176df71..00c3ebfcaad 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > The callbackfn return does not change the instance info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js index 917525264a9..b45bd9ac9dd 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > Returns abrupt from callbackfn info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js index fccf5a6247d..8c0c91d370e 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > Integer indexed values changed during iteration info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js index f03186c1999..7e4d648c2e4 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > callbackfn `this` value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js index 316c4d1244a..3c4adfe4a6c 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: Throws a TypeError if this has a detached buffer info: | 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-func.js index 0801b598a11..fdf5bbd97ce 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: Throws a TypeError exception when invoked as a function info: | 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-method.js index 20ebddd4c22..2dd53538708 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/length.js b/test/sendable/builtins/TypedArray/prototype/forEach/length.js index 8130e1ff798..ee9d5fc0034 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/length.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > %SendableTypedArray%.prototype.forEach.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/name.js b/test/sendable/builtins/TypedArray/prototype/forEach/name.js index c5a91e1423d..f3720767962 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/name.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > %SendableTypedArray%.prototype.forEach.name is "forEach". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/forEach/prop-desc.js index 4541148279a..9985a93fb58 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > "forEach" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-grow-mid-iteration.js index f43377101bf..1bbcb172047 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > SendableTypedArray.p.forEach behaves correctly on SendableTypedArrays backed by resizable buffers that are grown mid-iteration. diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-shrink-mid-iteration.js index 3791c679555..594cee451b6 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > SendableTypedArray.p.forEach behaves correctly on SendableTypedArrays backed by resizable buffers that are shrunk mid-iteration. diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer.js index 51d5cbecb87..bb8c6aa3def 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > SendableTypedArray.p.forEach behaves correctly when on SendableTypedArrays backed by resizable buffers. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js index 93d06f6b49b..664f34e2320 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js b/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js index e644046c6b3..0664b4c4128 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > Returns undefined info: | diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-object.js index 4d0492fa3da..702813e2af9 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.12 %SendableTypedArray%.prototype.forEach ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js index d8d6db1db7b..e02e41dc53f 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { forEach.call([], callbackfn); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { forEach.call(ab, callbackfn); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { forEach.call(dv, callbackfn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js index a9b303b89ef..69e33c1f859 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.foreach +esid: sec-%sendableTypedArray%.prototype.foreach description: > Integer indexed values are not cached before iteration info: | diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js index 55228ffcf4a..16980a0f4a0 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Returns -1 if buffer is detached after ValidateSendableTypedArray info: | %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) @@ -42,7 +42,7 @@ info: | Set k to k + 1. Return false. -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js index be8172aa8dc..95679e44e5f 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: > Returns false if buffer is detached after ValidateSendableTypedArray and searchElement is a value info: | @@ -43,7 +43,7 @@ info: | Set k to k + 1. Return false. -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer.js index fbdbef7fc4a..3a091ab6b96 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Throws a TypeError if this has a detached buffer info: | 22.2.3.14 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js index 8ef71f9f681..b13d8349354 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Return false if fromIndex >= ArrayLength info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) @@ -35,7 +35,7 @@ info: | 7. Repeat, while k < len ... 8. Return false. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js index 0554cbe3d4e..cb382781844 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: handle Infinity values for fromIndex info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) @@ -37,7 +37,7 @@ info: | 7. Repeat, while k < len ... 8. Return false. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js index 7f788c323b8..ff121da9a41 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: -0 fromIndex becomes 0 info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) @@ -32,7 +32,7 @@ info: | ... 7. Repeat, while k < len ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js index f3118895001..a6f2654bd32 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Get "length" uses internal ArrayLength info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) @@ -29,7 +29,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js index 1e13fe4abff..6b1ce7eceff 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Returns false if length is 0 info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) @@ -30,7 +30,7 @@ info: | 2. Let len be ? ToLength(? Get(O, "length")). 3. If len is 0, return false. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js index 95f343cc479..a6dbaf75e51 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js index dfaa231f9b7..14104c0866c 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Return abrupt from ToInteger(fromIndex) - using symbol info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) @@ -30,7 +30,7 @@ info: | 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js index 8652f171d32..4fa2df002d1 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Return abrupt from ToInteger(fromIndex) info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) @@ -30,7 +30,7 @@ info: | 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js index eb6e2c2c11b..40379665d03 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: returns true for found index info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) @@ -37,7 +37,7 @@ info: | b. If SameValueZero(searchElement, elementK) is true, return true. c. Increase k by 1. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js index 5c50e0dc574..91a2ee6b15f 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: returns false if the element is not found info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) @@ -37,7 +37,7 @@ info: | b. If SameValueZero(searchElement, elementK) is true, return true. c. Increase k by 1. 8. Return false. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js index 2cbe65c52ad..b24702d5e73 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: get the integer value from fromIndex info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) @@ -37,7 +37,7 @@ info: | b. If SameValueZero(searchElement, elementK) is true, return true. c. Increase k by 1. 8. Return false. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/coerced-searchelement-fromindex-resize.js b/test/sendable/builtins/TypedArray/prototype/includes/coerced-searchelement-fromindex-resize.js index 1ba12c57467..ab2d653cb30 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/coerced-searchelement-fromindex-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/coerced-searchelement-fromindex-resize.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: > SendableTypedArray.p.includes behaves correctly on SendableTypedArrays backed by resizable buffers that are resized during argument coercion. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer, Array.prototype.includes] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { valueOf: () => { @@ -36,7 +36,7 @@ for (let ctor of ctors) { assert(fixedLength.includes(undefined, evil)); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { valueOf: () => { @@ -50,7 +50,7 @@ for (let ctor of ctors) { assert(!fixedLength.includes(n0, evil)); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); let evil = { valueOf: () => { @@ -63,7 +63,7 @@ for (let ctor of ctors) { assert(lengthTracking.includes(undefined, evil)); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, 1); @@ -80,7 +80,7 @@ for (let ctor of ctors) { assert(!lengthTracking.includes(n0, evil)); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); lengthTracking[0] = MayNeedBigInt(lengthTracking, 1); let evil = { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js index 6da3b3f7005..4b6cbd23899 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: > Returns false if buffer is detached after ValidateSendableTypedArray and searchElement is a value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js index 06d32ecc494..ee595c972dc 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: > Returns true if buffer is detached after ValidateSendableTypedArray and searchElement is undefined info: | diff --git a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js index f397f9f4d44..c2fc8fbff9c 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Throws a TypeError if this has a detached buffer info: | 22.2.3.14 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js index 2877e3a97a6..bcd6216229b 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Return false if fromIndex >= ArrayLength info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js index cf45794c95f..90b546351ad 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: handle Infinity values for fromIndex info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js index ce5a3e4b5b9..a47bf2d66eb 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: -0 fromIndex becomes 0 info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js index 4703754debf..948b4299ca0 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Get "length" uses internal ArrayLength info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js index bf57425bc7b..10a076f2748 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: > Index is compared against the initial length when typed array is made out-of-bounds. info: | @@ -35,7 +35,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new ArrayBuffer(4, {maxByteLength: 20}); +let rab = new SendableArrayBuffer(4, {maxByteLength: 20}); // Uses byteOffset to make typed array out-of-bounds when shrinking size to zero. let byteOffset = 1; diff --git a/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length.js b/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length.js index a9d949936aa..48bed4510ee 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: > Index is compared against the initial length. info: | @@ -35,7 +35,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new ArrayBuffer(4, {maxByteLength: 20}); +let rab = new SendableArrayBuffer(4, {maxByteLength: 20}); let ta = new Int8Array(rab); let index = { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-func.js index cf93c0971c2..8f2a5d2ebe9 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Throws a TypeError exception when invoked as a function info: | 22.2.3.14 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-method.js index f5e2301f8f5..e1be14101e9 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.14 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js index 404c38dcc1e..6ecc486bd48 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Returns false if length is 0 info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/length.js b/test/sendable/builtins/TypedArray/prototype/includes/length.js index c6af728665d..19d61861c9b 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/length.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: > %SendableTypedArray%.prototype.includes.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/includes/name.js b/test/sendable/builtins/TypedArray/prototype/includes/name.js index 844ff64545c..14eaeafe269 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/name.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: > %SendableTypedArray%.prototype.includes.name is "includes". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/includes/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/includes/prop-desc.js index 23187ddaadb..af0247a2d96 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: > "includes" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer-special-float-values.js b/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer-special-float-values.js index 4f8e3f41c38..8e5badda738 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer-special-float-values.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer-special-float-values.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: > SendableTypedArray.p.includes behaves correctly for special float values when receiver is a float SendableTypedArray backed by a resizable buffer. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer, Array.prototype.includes] ---*/ for (let ctor of floatCtors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); lengthTracking[0] = -Infinity; lengthTracking[1] = Infinity; diff --git a/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer.js index c2f20786193..966d2c4e220 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: > SendableTypedArray.p.includes behaves correctly on SendableTypedArrays backed by resizable buffers. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer, Array.prototype.includes] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js index ce486baea18..60ec96b2383 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js index c388075498c..7e517793220 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Return abrupt from ToInteger(fromIndex) - using symbol info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js index 520ab9ade45..1c64db0f548 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Return abrupt from ToInteger(fromIndex) info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js b/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js index 4d65547f090..da43b0f5660 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: search element is compared using SameValueZero info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js b/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js index ed11009c822..cf725cedf79 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: returns true for found index info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js index 10f0507b25e..fdbd16b64b5 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: returns false if the element is not found info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js b/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js index b2604e58ec0..dbe9872c82b 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Check that search element is not coerced if not an integer info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-object.js index 5d8d10a64d8..476394b853f 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.14 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js index fdc17fd8eac..31e97666da9 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { includes.call([], 42); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { includes.call(ab, 42); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { includes.call(dv, 42); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js index a0adce1d89b..f32a3d7363d 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.includes +esid: sec-%sendableTypedArray%.prototype.includes description: get the integer value from fromIndex info: | 22.2.3.13 %SendableTypedArray%.prototype.includes ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index 7cfb35e1c6e..840564acdfb 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Throws a TypeError if this has a detached buffer info: | %SendableTypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ) @@ -45,7 +45,7 @@ info: | Set k to k + 1. Return -1F. -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index 05d7df17820..9bb06c44a06 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Throws a TypeError if this has a detached buffer info: | %SendableTypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ) @@ -45,7 +45,7 @@ info: | Set k to k + 1. Return -1F. -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js index b4651067f22..efb1b0d9591 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Throws a TypeError if this has a detached buffer info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js index a330a5ae6a3..57f1039e7c7 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Return -1 if fromIndex >= ArrayLength info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) @@ -30,7 +30,7 @@ info: | 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js index 328d9876a57..8690f73f20e 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: handle Infinity values for fromIndex info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) @@ -40,7 +40,7 @@ info: | searchElement === elementK. iii. If same is true, return k. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js index 59e5f732941..df532469410 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: -0 fromIndex becomes 0 info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) @@ -30,7 +30,7 @@ info: | 6. If n ≥ 0, then a. If n is -0, let k be +0; else let k be n. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js index 0611196ae56..59434ae057a 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Get "length" uses internal ArrayLength info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) @@ -29,7 +29,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js index b7405d2186e..b63eb9f3fa9 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Returns -1 if length is 0 info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) @@ -30,7 +30,7 @@ info: | 2. Let len be ? ToLength(? Get(O, "length")). 3. If len is 0, return -1. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/no-arg.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/no-arg.js index 994c35bf69d..27089238321 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/no-arg.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/no-arg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: > If `searchElement` is not supplied, -1 is returned. info: | @@ -29,7 +29,7 @@ info: | [...] 10. Return -1. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js index e1a48766331..109f32b4105 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js index bbe128b6802..03f528bfacb 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Return abrupt from ToInteger(fromIndex) - using symbol info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) @@ -30,7 +30,7 @@ info: | 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js index 2160f6e665f..7763aa7aa2b 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Return abrupt from ToInteger(fromIndex) info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) @@ -30,7 +30,7 @@ info: | 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js index ed86ca48cb0..70f94cf088f 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: returns index for the first found element info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) @@ -40,7 +40,7 @@ info: | searchElement === elementK. iii. If same is true, return k. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js index dcf10d88f6b..2ee8bafda61 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: returns -1 if the element if not found info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) @@ -34,7 +34,7 @@ info: | b. If k < 0, let k be 0. ... 9. Return -1. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js index 96c70fdeda4..cb70c9d8505 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Return -1 if fromIndex >= ArrayLength - converted values info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) @@ -30,7 +30,7 @@ info: | 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-grow.js b/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-grow.js index 44c0dae5528..2d59a411894 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-grow.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: > SendableTypedArray.p.indexOf behaves correctly when the backing resizable buffer is grown during argument coercion. @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // Growing + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, 1); @@ -43,7 +43,7 @@ for (let ctor of ctors) { // Growing + length-tracking TA, index conversion. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); lengthTracking[0] = MayNeedBigInt(lengthTracking, 1); let evil = { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-shrink.js b/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-shrink.js index 1a41a2250f5..e3ebaac62dd 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-shrink.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: > SendableTypedArray.p.indexOf behaves correctly when receiver is shrunk during argument coercion @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // Shrinking + fixed-length TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { valueOf: () => { @@ -38,7 +38,7 @@ for (let ctor of ctors) { assert.sameValue(fixedLength.indexOf(n0, evil), -1); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { valueOf: () => { @@ -54,7 +54,7 @@ for (let ctor of ctors) { // Shrinking + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index e8cae487be0..140232716b9 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Returns -1 if buffer is detached after ValidateSendableTypedArray info: | %SendableTypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index 4dcd64dbb2d..6cdf4107777 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Returns -1 if buffer is detached after ValidateSendableTypedArray info: | %SendableTypedArray%.prototype.indexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js index 57f4ec5a6c7..5a23869ce3d 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Throws a TypeError if this has a detached buffer info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js index 17b0d8249f6..a1ddfe9c292 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Return -1 if fromIndex >= ArrayLength info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js index 5d9c4b1fd04..60e39d69937 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: handle Infinity values for fromIndex info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js index cb6d86d66ec..330958a51f8 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: -0 fromIndex becomes 0 info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js index 8487b3c2dc8..71570178934 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Get "length" uses internal ArrayLength info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-func.js index 0030e2365db..10fe3621977 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Throws a TypeError exception when invoked as a function info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-method.js index 35a4331d84e..387487a0e89 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js index 633806fa413..370b603de90 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Returns -1 if length is 0 info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/length.js b/test/sendable/builtins/TypedArray/prototype/indexOf/length.js index 45be393c678..115bd4b44c9 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/length.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: > %SendableTypedArray%.prototype.indexOf.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/name.js b/test/sendable/builtins/TypedArray/prototype/indexOf/name.js index ec50942a0d0..2215f5b8f1a 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/name.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: > %SendableTypedArray%.prototype.indexOf.name is "indexOf". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js b/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js index 165236be458..ecdee218d4e 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: > If `searchElement` is not supplied, -1 is returned. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/indexOf/prop-desc.js index de150f2e56d..ad884ab5416 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: > "indexOf" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer-special-float-values.js b/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer-special-float-values.js index 6201b51d69f..79545a5ee8f 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer-special-float-values.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer-special-float-values.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: > SendableTypedArray.p.indexOf behaves correctly for special float values on float SendableTypedArrays backed by resizable buffers. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer, Array.prototype.includes] ---*/ for (let ctor of floatCtors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); lengthTracking[0] = -Infinity; lengthTracking[1] = -Infinity; diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer.js index 89818f6219e..aef1b2222f3 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: > SendableTypedArray.p.indexOf behaves correctly on SendableTypedArrays backed by resizable buffers. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js index 32f5aa2e61d..622870658bc 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js index 7341b711b21..324d3033f77 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Return abrupt from ToInteger(fromIndex) - using symbol info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js index ff8305aa5cc..89da9814db4 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Return abrupt from ToInteger(fromIndex) info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js b/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js index f062980fa8c..4fdc919cada 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: returns index for the first found element info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js index ee212a0f6e1..367b1c95fd3 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: returns -1 if the element if not found info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js b/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js index a7b9d24ff23..213b596d7ca 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: search element is compared using strict comparing (===) info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-object.js index 0fabbe89cb9..4526d1061e1 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js index a2ba42b3b58..6c84e3e4836 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { indexOf.call([], 42); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { indexOf.call(ab, 42); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { indexOf.call(dv, 42); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js index 1cdb745f937..84955b9b99c 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.indexof +esid: sec-%sendableTypedArray%.prototype.indexof description: Return -1 if fromIndex >= ArrayLength - converted values info: | 22.2.3.13 %SendableTypedArray%.prototype.indexOf (searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js index 3c82ee013eb..ae020285b97 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: > Concatenates the result of toString for each value with custom separator info: | @@ -38,7 +38,7 @@ info: | let next be ? ToString(element). d. Let R be a String value produced by concatenating S and next. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js index 1d2c98b3860..8909a261d89 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Returns single separator if buffer is detached after ValidateSendableTypedArray info: | %SendableTypedArray%.prototype.join ( separator ) @@ -38,7 +38,7 @@ info: | Set k to k + 1. Return R. -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer.js index 1018a6dd34b..097b5a1ed87 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Throws a TypeError if this has a detached buffer info: | %SendableTypedArray%.prototype.join ( separator ) @@ -27,7 +27,7 @@ info: | Perform ? ValidateSendableTypedArray(O). ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js index 8e68d24a9a3..74718f29d14 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Return the empty String if length is 0 info: | 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) @@ -30,7 +30,7 @@ info: | 4. Let sep be ? ToString(separator). 5. If len is zero, return the empty String. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js index b5ce34dd6c5..31fb0f7b26a 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Get "length" uses internal ArrayLength info: | 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) @@ -31,7 +31,7 @@ info: | ... 5. If len is zero, return the empty String. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js index 939303f8115..a48d4e9b7e2 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Concatenates the result of toString for each simple value info: | 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) @@ -37,7 +37,7 @@ info: | let next be ? ToString(element). d. Let R be a String value produced by concatenating S and next. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js index 5096dc16c6e..2c2a87af075 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Return abrupt from ToString(Symbol separator) info: | 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) @@ -30,7 +30,7 @@ info: | 4. Let sep be ? ToString(separator). 5. If len is zero, return the empty String. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js index 16bc41dd79a..113bb909968 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Return abrupt from ToString(separator) info: | 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) @@ -30,7 +30,7 @@ info: | 4. Let sep be ? ToString(separator). 5. If len is zero, return the empty String. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js index e104a609469..1668736e5c6 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-grow.js b/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-grow.js index 9243b2a965b..1b9d0f4cf82 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-grow.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: > SendableTypedArray.p.join behaves correctly when the receiver is grown during argument coercion @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // Growing + fixed-length TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { toString: () => { @@ -37,7 +37,7 @@ for (let ctor of ctors) { // Growing + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); let evil = { toString: () => { diff --git a/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-shrink.js b/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-shrink.js index 2daa9f9bfac..2a10f3b6889 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-shrink.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: > SendableTypedArray.p.join behaves correctly when the receiver is shrunk during argument coercion @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // Shrinking + fixed-length TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { toString: () => { @@ -40,7 +40,7 @@ for (let ctor of ctors) { // Shrinking + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); let evil = { toString: () => { diff --git a/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js index 1fd649441ce..986864797bc 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: > Concatenates the result of toString for each value with custom separator info: | diff --git a/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js index 5f9e6265b5d..03a46ecc966 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: > Concatenates the result of toString for each value with custom separator info: | diff --git a/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js index 3b6b231fb87..610e7275d1b 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js +++ b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Returns single separator if buffer is detached after ValidateSendableTypedArray info: | %SendableTypedArray%.prototype.join ( separator ) diff --git a/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js index c51a978b05e..877e2b17a3b 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Throws a TypeError if this has a detached buffer info: | %SendableTypedArray%.prototype.join ( separator ) diff --git a/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js b/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js index 8bb52c80205..a2e3f5ca33f 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js +++ b/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Return the empty String if length is 0 info: | 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) diff --git a/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js index c0f1dc1078e..418b5836747 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Get "length" uses internal ArrayLength info: | 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) diff --git a/test/sendable/builtins/TypedArray/prototype/join/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/join/invoked-as-func.js index a43e069d4e0..4c9fb595c94 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/join/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Throws a TypeError exception when invoked as a function info: | 22.2.3.14 %SendableTypedArray%.prototype.join ( separator ) diff --git a/test/sendable/builtins/TypedArray/prototype/join/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/join/invoked-as-method.js index 257e6a1e908..5ad9501eb19 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/join/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.14 %SendableTypedArray%.prototype.join ( separator ) diff --git a/test/sendable/builtins/TypedArray/prototype/join/length.js b/test/sendable/builtins/TypedArray/prototype/join/length.js index 4f851da696f..a373eaba400 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/length.js +++ b/test/sendable/builtins/TypedArray/prototype/join/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: > %SendableTypedArray%.prototype.join.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/join/name.js b/test/sendable/builtins/TypedArray/prototype/join/name.js index 4ceec17b80c..a3a5006c14e 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/name.js +++ b/test/sendable/builtins/TypedArray/prototype/join/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: > %SendableTypedArray%.prototype.join.name is "join". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/join/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/join/prop-desc.js index 8daa6292e5f..ab25d7fc2e8 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/join/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: > "join" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/join/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/join/resizable-buffer.js index baf541e9b57..c45c35f66c8 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/join/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: > SendableTypedArray.p.join behaves correctly when the receiver is backed by resizable buffer @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js index 83095a6eb8c..dc85cf2ca9f 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Concatenates the result of toString for each simple value info: | 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) diff --git a/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js index 681396b6e0c..590613be4ec 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Concatenates the result of toString for each value info: | 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) diff --git a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js index 29ff4bcc558..a8bc3977d5d 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Return abrupt from ToString(Symbol separator) info: | 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) diff --git a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js index 1eecd03ab3b..f3eb9394d46 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js +++ b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Return abrupt from ToString(separator) info: | 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) diff --git a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js index b8f158e73be..139de343028 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/join/separator-tostring-once-after-resized.js b/test/sendable/builtins/TypedArray/prototype/join/separator-tostring-once-after-resized.js index db9f6f05804..3b136b9eaf1 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/separator-tostring-once-after-resized.js +++ b/test/sendable/builtins/TypedArray/prototype/join/separator-tostring-once-after-resized.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: > ToString is called once when the array is resized. info: | @@ -30,7 +30,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let rab = new SendableArrayBuffer(3, {maxByteLength: 5}); let ta = new Int8Array(rab); let callCount = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/join/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/join/this-is-not-object.js index d445912a0f8..d917ae09b0a 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/join/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.15 %SendableTypedArray%.prototype.join ( separator ) diff --git a/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js index c044bfb3aae..1f2b462b4d4 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.join +esid: sec-%sendableTypedArray%.prototype.join description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { join.call([], ""); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { join.call(ab, ""); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { join.call(dv, ""); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/detached-buffer.js index b3de4b3069e..3bd55d78c23 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: Throws a TypeError if this has a detached buffer info: | 22.2.3.16 %SendableTypedArray%.prototype.keys ( ) @@ -27,7 +27,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/iter-prototype.js index 01281583456..595baa6adab 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/iter-prototype.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: > The prototype of the returned iterator is ArrayIteratorPrototype info: | @@ -22,7 +22,7 @@ info: | ... 3. Return CreateArrayIterator(O, "key"). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.iterator, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js index 34945718b04..14a14f60c2c 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-itor.js b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-itor.js index acaf48dcdb4..935c357552d 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-itor.js @@ -14,14 +14,14 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: Return an iterator for the keys. info: | 22.2.3.16 %SendableTypedArray%.prototype.keys ( ) ... 3. Return CreateArrayIterator(O, "key"). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js index 64cc926873d..4efd73cfebb 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: Throws a TypeError if this has a detached buffer info: | 22.2.3.16 %SendableTypedArray%.prototype.keys ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-func.js index b38c7b47e09..39e03a89873 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: Throws a TypeError exception when invoked as a function info: | 22.2.3.15 %SendableTypedArray%.prototype.keys ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-method.js index 1096a00773d..4ca60479387 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.15 %SendableTypedArray%.prototype.keys ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js index 061b0cdc327..73b8250fb00 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: > The prototype of the returned iterator is ArrayIteratorPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/keys/length.js b/test/sendable/builtins/TypedArray/prototype/keys/length.js index 2888ee4af6f..520a888aa6a 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/length.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: > %SendableTypedArray%.prototype.keys.length is 0. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/keys/name.js b/test/sendable/builtins/TypedArray/prototype/keys/name.js index 07c2a8dbce1..8e0e1427ab3 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/name.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: > %SendableTypedArray%.prototype.keys.name is "keys". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/keys/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/keys/prop-desc.js index 6386ac813c1..d4c373babde 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: > "keys" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-grow-mid-iteration.js index 0cc6e35d0a1..78c3c81a796 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: > SendableTypedArray.p.keys behaves correctly when receiver is backed by a resizable buffer and is grown mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-shrink-mid-iteration.js index bcd5e20e6b4..a18237137a4 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: > SendableTypedArray.p.keys behaves correctly when receiver is backed by resizable buffer that is shrunk mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer.js index 1f04eee0b6a..13002e0773a 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: > SendableTypedArray.p.keys behaves correctly when receiver is backed by resizable buffer @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js index 88710e769cc..b11c1d43b90 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js b/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js index 06d1b17a233..3568f0039da 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: Return an iterator for the keys. info: | 22.2.3.16 %SendableTypedArray%.prototype.keys ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-object.js index ef48555e15b..4016c43ccdc 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.16 %SendableTypedArray%.prototype.keys ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js index 05e482325ed..5cbde78d5a9 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.keys +esid: sec-%sendableTypedArray%.prototype.keys description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -46,12 +46,12 @@ assert.throws(TypeError, function() { keys.call([]); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { keys.call(ab); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { keys.call(dv); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index 5151147472a..e9a7b18f3b5 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Returns -1 if buffer is detached after ValidateSendableTypedArray info: | %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) @@ -42,7 +42,7 @@ info: | Set k to k - 1. Return -1F. -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index 16680ecd3b0..673b709bd1c 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Returns -1 if buffer is detached after ValidateSendableTypedArray info: | %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) @@ -42,7 +42,7 @@ info: | Set k to k - 1. Return -1F. -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js index 0fdfdf0fec8..27100f8c96d 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Throws a TypeError if this has a detached buffer info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js index 997a423b429..b4ad5335913 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: handle Infinity values for fromIndex info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) @@ -33,7 +33,7 @@ info: | a. Let k be len + n. 7. Repeat, while k ≥ 0 ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js index ea5b2a3da8a..1a6d65e9554 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: -0 fromIndex becomes 0 info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) @@ -30,7 +30,7 @@ info: | 5. If n ≥ 0, then a. If n is -0, let k be +0; else let k be min(n, len - 1). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js index 146b18adb06..2788e86411b 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Get "length" uses internal ArrayLength info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) @@ -29,7 +29,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js index 4629bb26ad5..a7b20696b3d 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Returns -1 if length is 0 info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) @@ -30,7 +30,7 @@ info: | 2. Let len be ? ToLength(? Get(O, "length")). 3. If len is 0, return -1. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js index 365024746e7..bffff533ec1 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: > If `searchElement` is not supplied, -1 is returned. info: | @@ -29,7 +29,7 @@ info: | [...] 8. Return -1. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js index 57ec0d89e4a..4be062841cc 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js index 902a4275962..360aa1f6d21 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Return abrupt from ToInteger(fromIndex) - using symbol info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) @@ -30,7 +30,7 @@ info: | 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let n be len-1. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js index 37a4fa62415..d13d7195edd 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Return abrupt from ToInteger(fromIndex) info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) @@ -30,7 +30,7 @@ info: | 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let n be len-1. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js index 3ab67a86557..4dcf2d6a780 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: returns index for the first found element info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) @@ -39,7 +39,7 @@ info: | searchElement === elementK. iii. If same is true, return k. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js index f91a2758ee7..8b3ad8d3223 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: returns -1 if the element if not found info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) @@ -34,7 +34,7 @@ info: | 7. Repeat, while k ≥ 0 ... 8. Return -1. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js index f1f380e8afa..f3dfb9b0c6d 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Return -1 if fromIndex >= ArrayLength - converted values info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) @@ -30,7 +30,7 @@ info: | 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let n be len-1. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-grow.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-grow.js index f46e7f5641c..4dfe58e889e 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-grow.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: > SendableTypedArray.p.lastIndexOf behaves correctly on SendableTypedArrays backed by resizable buffers that are grown by argument coercion. @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // Growing + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, 1); @@ -46,7 +46,7 @@ for (let ctor of ctors) { // Growing + length-tracking TA, index conversion. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); let evil = { valueOf: () => { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-shrink.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-shrink.js index ce8c2d8a059..705d79d2b7a 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-shrink.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: > SendableTypedArray.p.lastIndexOf behaves correctly on SendableTypedArrays backed by resizable buffers that are shrunk by argument coercion. @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // Shrinking + fixed-length TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { valueOf: () => { @@ -38,7 +38,7 @@ for (let ctor of ctors) { assert.sameValue(fixedLength.lastIndexOf(n0, evil), -1); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { valueOf: () => { @@ -54,7 +54,7 @@ for (let ctor of ctors) { // Shrinking + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index 035115a672f..864ae25ae5e 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Returns -1 if buffer is detached after ValidateSendableTypedArray info: | %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index 7c80b675362..2fef7d4ac97 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Returns -1 if buffer is detached after ValidateSendableTypedArray info: | %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js index ad898b42630..722d6109877 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Throws a TypeError if this has a detached buffer info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js index 2600d39a8b2..f8110e1240b 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: handle Infinity values for fromIndex info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js index f2b872503cf..c0c4ee69797 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: -0 fromIndex becomes 0 info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js index a747895e8b1..c94f209a628 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Get "length" uses internal ArrayLength info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-func.js index e6772141784..e1dfa6dec89 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Throws a TypeError exception when invoked as a function info: | 22.2.3.16 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-method.js index bdf53f63d0b..2991a6a4464 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.16 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js index 01588052789..a965012ef09 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Returns -1 if length is 0 info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length.js index f6ea5ac88af..52716caf3dd 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: > %SendableTypedArray%.prototype.lastIndexOf.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/name.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/name.js index d7ffda153d1..9abf1eb72ed 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/name.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: > %SendableTypedArray%.prototype.lastIndexOf.name is "lastIndexOf". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js index 4f60232f5f6..d247f360d98 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: > If `searchElement` is not supplied, -1 is returned. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/prop-desc.js index 0284d6e7c45..e07b6fc1ecd 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: > "lastIndexOf" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer-special-float-values.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer-special-float-values.js index 41d3ec2ee47..48c30d995c0 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer-special-float-values.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer-special-float-values.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: > SendableTypedArray.p.lastIndexOf behaves correctly for special float values on float SendableTypedArrays backed by resizable buffers. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer, Array.prototype.includes] ---*/ for (let ctor of floatCtors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); lengthTracking[0] = -Infinity; lengthTracking[1] = -Infinity; diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer.js index abe12a2cc55..842bc6c2746 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: > SendableTypedArray.p.lastIndexOf behaves correctly on SendableTypedArrays backed by resizable buffers. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js index e77f3f9d058..34e56243e33 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js index db47e8fd91c..8a70c1e5835 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Return abrupt from ToInteger(fromIndex) - using symbol info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js index 38d79ad76ba..f5adf6128e0 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Return abrupt from ToInteger(fromIndex) info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js index 5902f723e28..4c2ec9b1f24 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: returns index for the first found element info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js index 961422e9d8d..7824fa53433 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: returns -1 if the element if not found info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js index f0940cbad42..7bc4ad9706b 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: search element is compared using strict comparing (===) info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-object.js index 64b2c307df1..166640c2e32 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js index b89c63a4927..bc896f0ba3b 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { lastIndexOf.call([], 42); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { lastIndexOf.call(ab, 42); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { lastIndexOf.call(dv, 42); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js index 9cce3182750..959afab2346 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.lastindexof +esid: sec-%sendableTypedArray%.prototype.lastindexof description: Return -1 if fromIndex >= ArrayLength - converted values info: | 22.2.3.17 %SendableTypedArray%.prototype.lastIndexOf ( searchElement [ , fromIndex ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/length/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/length/BigInt/detached-buffer.js index 7eee1af7429..7109d19f73c 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/length/BigInt/detached-buffer.js @@ -20,10 +20,10 @@ info: | 22.2.3.18 get %SendableTypedArray%.prototype.length ... - 5. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 5. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. 6. If IsDetachedBuffer(buffer) is true, return 0. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js index 835d2a8813f..002a1fdd2f8 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.length description: | - reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); testWithBigIntSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE); var expected = 3; diff --git a/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js index 3ac50a1f72f..b34baf532f1 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.length description: | - reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); testWithBigIntSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); assert.sameValue(array.length, 2, "initial value"); diff --git a/test/sendable/builtins/TypedArray/prototype/length/BigInt/return-length.js b/test/sendable/builtins/TypedArray/prototype/length/BigInt/return-length.js index 6af171c4abe..57729f6e671 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/BigInt/return-length.js +++ b/test/sendable/builtins/TypedArray/prototype/length/BigInt/return-length.js @@ -28,7 +28,7 @@ info: | The current tests on `prop-desc.js` and `length.js` already assert `length` is not a dynamic property as in regular arrays. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js index e6ff36b5f84..24d1ccc8af2 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js @@ -20,7 +20,7 @@ info: | 22.2.3.18 get %SendableTypedArray%.prototype.length ... - 5. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. + 5. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. 6. If IsDetachedBuffer(buffer) is true, return 0. ... includes: [testTypedArray.js, detachArrayBuffer.js] diff --git a/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js index ae4057279f7..1948de0fb70 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js @@ -16,7 +16,7 @@ /*--- esid: sec-get-%typedarray%.prototype.length description: > - Requires this value to have a [[ViewedArrayBuffer]] internal slot + Requires this value to have a [[ViewedSendableArrayBuffer]] internal slot info: | 22.2.3.17 get %SendableTypedArray%.prototype.length diff --git a/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js index fd9e0fb31fe..ecfbe40b030 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.length description: | - reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE); var expected = 3; diff --git a/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js index 0b99164ae24..d69be677095 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.length description: | - reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); assert.sameValue(array.length, 2, "initial value"); diff --git a/test/sendable/builtins/TypedArray/prototype/length/resizable-buffer-assorted.js b/test/sendable/builtins/TypedArray/prototype/length/resizable-buffer-assorted.js index 4831e2d5775..9c5229771b6 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/resizable-buffer-assorted.js +++ b/test/sendable/builtins/TypedArray/prototype/length/resizable-buffer-assorted.js @@ -22,7 +22,7 @@ includes: [compareArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableArrayBuffer(40, 80); +const rab = CreateResizableSendableArrayBuffer(40, 80); for (let ctor of ctors) { const ta = new ctor(rab, 0, 3); assert.compareArray(ta.buffer, rab); diff --git a/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-1.js b/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-1.js index 0d4e1f8b36f..2ffaadfd77f 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-1.js +++ b/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-1.js @@ -22,7 +22,7 @@ includes: [compareArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableArrayBuffer(16, 40); +const rab = CreateResizableSendableArrayBuffer(16, 40); // Create TAs which cover the bytes 0-7. let tas_and_lengths = []; diff --git a/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-2.js b/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-2.js index 853f6391616..39cb0696be4 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-2.js +++ b/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-2.js @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // Like resized-out-of-bounds-1.js but with offsets. -const rab = CreateResizableArrayBuffer(20, 40); +const rab = CreateResizableSendableArrayBuffer(20, 40); // Create TAs with offset, which cover the bytes 8-15. let tas_and_lengths = []; diff --git a/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js index 5852412a6e3..9a0a0128b0f 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js @@ -43,12 +43,12 @@ assert.throws(TypeError, function() { getter.call([]); }); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { getter.call(ab); }); -var dv = new DataView(new ArrayBuffer(8), 0); +var dv = new DataView(new SendableArrayBuffer(8), 0); assert.throws(TypeError, function() { getter.call(dv); }); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/arraylength-internal.js index 0b8f91e9d5f..d31da56662f 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > [[ArrayLength]] is accessed in place of performing a [[Get]] of "length" info: | @@ -23,7 +23,7 @@ info: | ... 3. Let len be the value of O's [[ArrayLength]] internal slot. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js index 55d9d61495a..352e297353a 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > thisArg does not affect callbackfn arguments info: | @@ -26,7 +26,7 @@ info: | b. Let kValue be ? Get(O, Pk). c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js index ba41a1e775d..abf1c2273ef 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > callbackfn arguments info: | @@ -26,7 +26,7 @@ info: | b. Let kValue be ? Get(O, Pk). c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js index 3af2894a6d5..531be9e6710 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Instance buffer can be detached during loop info: | @@ -26,7 +26,7 @@ info: | b. Let kValue be ? Get(O, Pk). c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [detachArrayBuffer.js, testBigIntSendableTypedArray.js] +includes: [detachArrayBuffer.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js index 4b00af5fcb3..bad3a355e65 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > callbackfn is not callable info: | @@ -23,7 +23,7 @@ info: | ... 4. If IsCallable(callbackfn) is false, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js index f89764b4410..3a3bfff72f3 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Does not interact over non-integer properties info: | @@ -26,7 +26,7 @@ info: | b. Let kValue be ? Get(O, Pk). c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js index 55064dfff87..9b74b4403f4 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > callbackfn is not called on empty instances info: | @@ -26,7 +26,7 @@ info: | ... c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js index ec10d31cff2..e6c820f52db 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > The callbackfn returned values are applied to the new instance info: | @@ -28,7 +28,7 @@ info: | d. Perform ? Set(A, Pk, mappedValue, true). ... 9. Return A. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js index ee853e6871a..926f1bbc568 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js @@ -14,12 +14,12 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > The callbackfn return does not change the `this` instance info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js index 17aa32326fa..cf69d929812 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Does not copy non-integer properties to returned value info: | @@ -26,7 +26,7 @@ info: | b. Let kValue be ? Get(O, Pk). c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js index e2bc748f32c..ff490b2c719 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js @@ -14,13 +14,13 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Returns abrupt from callbackfn info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js index 2f5b957538c..a67387ade45 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js @@ -14,12 +14,12 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Integer indexed values changed during iteration info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Reflect.set, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-this.js index 7071a3913a3..021a346ea9a 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > callbackfn `this` value info: | @@ -27,7 +27,7 @@ info: | ... c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/detached-buffer.js index 92608dd1cf3..2c2c2c645ec 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: Throws a TypeError if this has a detached buffer info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js index bc1fcfc6576..912a0785ea1 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js index 60ce5c9d714..36ce72bb9fb 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Returns a new typedArray instance from the same constructor with the same length and a new buffer object - testing on an instance with length == 0 @@ -29,7 +29,7 @@ info: | c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... 9. Return A. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js index 8dcc978cba5..17ef4f0dbf9 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Returns a new typedArray instance from the same constructor with the same length and a new buffer object - testing on an instance with length > 0 @@ -29,7 +29,7 @@ info: | c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... 9. Return A. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-destination-resizable.js index 7042ce74221..b70a94f8db6 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-destination-resizable.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Throws a TypeError if new typedArray's length < count info: | @@ -36,14 +36,14 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ testWithBigIntSendableTypedArrayConstructors(function(TA) { - const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); + const rab1 = new SendableArrayBuffer(8, {maxByteLength: 100}); const ta = new TA(rab1); - const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); + const rab2 = new SendableArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab2); rab2.resize(0); ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js index 15c36b2cd3f..144807ecee9 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: Return abrupt from SpeciesConstructor's get Constructor info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js index ffb8f9f25e4..9f783e5b055 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: get inherited constructor on SpeciesConstructor info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js index 3c6c040d26f..9f9eb1f9814 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Throws if O.constructor returns a non-Object and non-undefined value info: | @@ -37,7 +37,7 @@ info: | 3. If C is undefined, return defaultConstructor. 4. If Type(C) is not Object, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js index 2504eeb8471..058b5e15d74 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: get constructor on SpeciesConstructor info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js index 25ba0b7ee65..f1e044305c1 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Returns abrupt from get @@species on found constructor info: | @@ -37,7 +37,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js index 0b9f7183b3f..98497c089fd 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Verify arguments on custom @@species construct call info: | @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index 74d6dff6015..f604dc1510c 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Throws a TypeError if new typedArray's length < count info: | @@ -36,13 +36,13 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ testWithBigIntSendableTypedArrayConstructors(function(TA) { const sample = new TA(2); - const rab = new ArrayBuffer(10, {maxByteLength: 20}); + const rab = new SendableArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab); rab.resize(0); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js index 1d7324193b3..50143698fbb 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Throws a TypeError if new typedArray's length < len info: | @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js index f9b9befcd6a..95c76a6b904 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Does not throw a TypeError if new typedArray's length >= len info: | @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js index 1314ddfdcd5..8a112bb94ba 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Custom @@species constructor may return a different SendableTypedArray info: | @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js index 2b13d91fa0a..05c7b78ff59 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Custom @@species constructor throws if it does not return a compatible object info: | @@ -43,7 +43,7 @@ info: | 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js index 68512ee8f29..32233257501 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Use custom @@species constructor if available info: | @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js index b3c5287e27b..babf827f91f 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Throws if returned @@species is not a constructor, null or undefined. info: | @@ -38,7 +38,7 @@ info: | 7. If IsConstructor(S) is true, return S. 8. Throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js index 3fe9ae9585c..1bfcec3713b 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Use defaultConstructor if @@species is either undefined or null info: | @@ -36,7 +36,7 @@ info: | 5. Let S be ? Get(C, @@species). 6. If S is either undefined or null, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js index f08ed05d4fb..38f0a298ff1 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > get @@species from found constructor info: | @@ -37,7 +37,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/values-are-not-cached.js index 69487e241a8..c495060d1f3 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/values-are-not-cached.js @@ -14,12 +14,12 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Integer indexed values changed during iteration info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js index 7b9132b7703..5f2754fc90b 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > [[ArrayLength]] is accessed in place of performing a [[Get]] of "length" info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js index 1b234bc4193..2bc552b73bf 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > thisArg does not affect callbackfn arguments info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js index 3a823a82b86..6b4a754fe41 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > callbackfn arguments info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js index 823bea1c46c..3a6a68b4aab 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Instance buffer can be detached during loop info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js index f887f27aab0..683f0339cbd 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > callbackfn is not callable info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js index 9e8e6ff6e37..f3df1a68cef 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Does not interact over non-integer properties info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js index 018dc61866c..a771196f5ea 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > callbackfn is not called on empty instances info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js index 4d0d725c2ee..51693a8416e 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js @@ -14,22 +14,22 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: Instance buffer can be resized during iteration includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; var NaNvalue = isFloatSendableTypedArrayConstructor(TA) ? NaN : 0; - var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js index b8ec2c52ee2..b79e4ab6620 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > The callbackfn returned values are applied to the new instance info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js index c53af669e83..bdbdf423165 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > The callbackfn return does not change the `this` instance info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js index 3e54601b9b7..22f9ece3336 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Does not copy non-integer properties to returned value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js index 749c6184017..290bf265d01 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Returns abrupt from callbackfn info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js index b10e08f5c3f..b57d1285633 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Integer indexed values changed during iteration info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js index 5afea302d14..5798a117844 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > callbackfn `this` value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js index 334d036185a..8806833aae7 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: Throws a TypeError if this has a detached buffer info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/map/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/map/invoked-as-func.js index f9420cd364b..7bb22cbdb56 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/map/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: Throws a TypeError exception when invoked as a function info: | 22.2.3.18 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/map/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/map/invoked-as-method.js index d03b2a5bd4e..9b2fbe7354b 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/map/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.18 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/map/length.js b/test/sendable/builtins/TypedArray/prototype/map/length.js index f36aded276f..d1c339e7b27 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > %SendableTypedArray%.prototype.map.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/name.js b/test/sendable/builtins/TypedArray/prototype/map/name.js index 4beabce9572..894107554b6 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/name.js +++ b/test/sendable/builtins/TypedArray/prototype/map/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > %SendableTypedArray%.prototype.map.name is "map". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/map/prop-desc.js index b1ff03e20cf..c221ba89cbc 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/map/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > "map" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-grow-mid-iteration.js index fe5c2841522..643fbc5e0e9 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > SendableTypedArray.p.map behaves correctly on SendableTypedArrays backed by resizable buffers that are grown mid-iteration. diff --git a/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-shrink-mid-iteration.js index 8f96c0bdf25..98c0f61d4a0 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > SendableTypedArray.p.map behaves correctly on SendableTypedArrays backed by resizable buffers that are shrunk mid-iteration. diff --git a/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer.js index 791ede6fc34..1344805bb0d 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > SendableTypedArray.p.map behaves as expected on SendableTypedArrays backed by resizable buffers. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js index 5dd59da357c..3a3f73bcbed 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js index d327e7b4206..063f8f90dc2 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: Consistent canonicalization of NaN values info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) @@ -30,7 +30,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedArrayBuffer]]. + Let buffer be O.[[ViewedSendableArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js index 1c63743dde9..e9c6f9573df 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Verify conversion values on returned instance info: | @@ -31,7 +31,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedArrayBuffer]]. + Let buffer be O.[[ViewedSendableArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js index 7cc07666f25..5eca79eafad 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Returns a new typedArray instance from the same constructor with the same length and a new buffer object - testing on an instance with length == 0 diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js index c607c292459..b6946752484 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Returns a new typedArray instance from the same constructor with the same length and a new buffer object - testing on an instance with length > 0 diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js index eddf8d9bec1..456ed8e3268 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Throws a TypeError if new typedArray's length < count info: | @@ -41,9 +41,9 @@ features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ testWithSendableTypedArrayConstructors(function(TA) { - const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); + const rab1 = new SendableArrayBuffer(8, {maxByteLength: 100}); const ta = new TA(rab1); - const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); + const rab2 = new SendableArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab2); rab2.resize(0); ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js index b2411295072..510527aeb88 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: Return abrupt from SpeciesConstructor's get Constructor info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js index bdec5820ad2..aeffe520d94 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: get inherited constructor on SpeciesConstructor info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js index d2802dd43b2..7fd3b9aba3c 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Throws if O.constructor returns a non-Object and non-undefined value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js index 84960a0fe81..1d66f242462 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: get constructor on SpeciesConstructor info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js index e53ad8beaff..a082af3c5da 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Returns abrupt from get @@species on found constructor info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js index 207079120e1..bfa7f5bbeb8 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Verify arguments on custom @@species construct call info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index 3fd1cf8984d..8487610bf83 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Throws a TypeError if new typedArray's length < count info: | @@ -42,7 +42,7 @@ features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] testWithSendableTypedArrayConstructors(function(TA) { const sample = new TA(2); - const rab = new ArrayBuffer(10, {maxByteLength: 20}); + const rab = new SendableArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab); rab.resize(0); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js index e218c00f467..8229f215fd2 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Throws a TypeError if new typedArray's length < len info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js index ed59012a4b0..9ba6f9b537c 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Does not throw a TypeError if new typedArray's length >= len info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js index 093968a733e..33cda479bb0 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Custom @@species constructor may return a different SendableTypedArray info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js index 45fc82e2a19..0134d64abb2 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Custom @@species constructor throws if it does not return a compatible object info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js index 48918caaa25..17041b7f132 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Use custom @@species constructor if available info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js index faacd5cc3d7..0d2b069b8af 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Throws if returned @@species is not a constructor, null or undefined. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js index 1c75b92b1b5..095fb841b3e 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Use defaultConstructor if @@species is either undefined or null info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js index 7332eb8c7c1..99fd886c1d8 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > get @@species from found constructor info: | diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-grow.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-grow.js index 767f845c158..8c75785281a 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-grow.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > SendableTypedArray.p.map behaves correctly on SendableTypedArrays backed by resizable buffers that are grown by the species constructor. @@ -41,7 +41,7 @@ function CollectWithUndefined(values) { } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const taWrite = new ctor(rab); for (let i = 0; i < 4; ++i) { taWrite[i] = MayNeedBigInt(taWrite, i); @@ -68,7 +68,7 @@ for (let ctor of ctors) { assert.sameValue(rab.byteLength, 6 * ctor.BYTES_PER_ELEMENT); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const taWrite = new ctor(rab); for (let i = 0; i < 4; ++i) { taWrite[i] = MayNeedBigInt(taWrite, i); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-shrink.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-shrink.js index 12963e3fe33..35c4bcdaf3c 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-shrink.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > SendableTypedArray.p.map behaves correctly on SendableTypedArrays backed by resizable buffers that are shrunk by the species constructor. @@ -41,7 +41,7 @@ function CollectWithUndefined(values) { } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); let resizeWhenConstructorCalled = false; class MyArray extends ctor { constructor(...params) { @@ -65,7 +65,7 @@ for (let ctor of ctors) { assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const taWrite = new ctor(rab); for (let i = 0; i < 4; ++i) { taWrite[i] = MayNeedBigInt(taWrite, i); diff --git a/test/sendable/builtins/TypedArray/prototype/map/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/map/this-is-not-object.js index 9b808c20b20..07d875a2171 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/map/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js index e6ea40132b6..8df30bfa45e 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { map.call([], callbackfn); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { map.call(ab, callbackfn); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { map.call(dv, callbackfn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js index d2a2f93b038..bc4d4687905 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.map +esid: sec-%sendableTypedArray%.prototype.map description: > Integer indexed values changed during iteration info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js index d48cf5da2a9..3959cbb1ed1 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > callbackfn arguments using custom accumulator info: | @@ -35,7 +35,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js index 48894cbe8f1..604ecb9a5ad 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > callbackfn arguments using default accumulator (value at index 0) info: | @@ -42,7 +42,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js index 63ca28cffdd..b132e5b482c 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Instance buffer can be detached during loop info: | @@ -35,7 +35,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [detachArrayBuffer.js, testBigIntSendableTypedArray.js] +includes: [detachArrayBuffer.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js index 1f194d9e398..2cf35a071eb 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Throws TypeError if callbackfn is not callable info: | @@ -31,7 +31,7 @@ info: | 3. If IsCallable(callbackfn) is false, throw a TypeError exception. 4. If len is 0 and initialValue is not present, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js index 7731c264027..cf8390d9b2f 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Does not iterate over non-integer properties info: | @@ -35,7 +35,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js index 3390a426634..466450aec0b 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > callbackfn is not called on empty instances info: | @@ -37,7 +37,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js index 8469d8c168d..1b89460398f 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > The callbackfn return does not change the `this` instance -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js index 6ad8524d03f..31fac08e3f3 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Returns abrupt from callbackfn info: | @@ -35,7 +35,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js index 60d58b6ac76..675a29fbcb6 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Integer indexed values changed during iteration info: | @@ -26,7 +26,7 @@ info: | a [[Get]] of "length". 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Reflect.set, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js index 455018d64d0..822202614e4 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > callbackfn `this` value info: | @@ -35,7 +35,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/detached-buffer.js index f08a1b399c1..9f64bd46861 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: Throws a TypeError if this has a detached buffer info: | 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js index 1cce363392c..cd2370572c3 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Returns given initialValue on empty instances without calling callbackfn info: | @@ -39,7 +39,7 @@ info: | 8. Repeat, while k < len ... 9. Return accumulator. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js index e89454ebbcb..c277b187d7a 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > If len is 0 and initialValue is not present, throw a TypeError exception. info: | @@ -30,7 +30,7 @@ info: | ... 4. If len is 0 and initialValue is not present, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js index 68ddd43f826..1c60e728447 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: Get "length" uses internal ArrayLength info: | 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js index 863c4c67e65..387bbe1259e 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Returns last accumulator value info: | @@ -43,7 +43,7 @@ info: | ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). 9. Return accumulator. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js index b9c0c2e8076..e381496c881 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Result can be of any type without any number conversions info: | @@ -43,7 +43,7 @@ info: | ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). 9. Return accumulator. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js index bbbdb91b76c..bbf05df36a6 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js index cd22b7102a7..8275660e298 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Returns [0] without calling callbackfn if length is 1 and initialValue is not present. @@ -40,7 +40,7 @@ info: | 8. Repeat, while k < len ... 9. Return accumulator. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js index 033063000a1..e883ae181ea 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Integer indexed values are not cached before iteration info: | @@ -35,7 +35,7 @@ info: | ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js index 7f74bec0ae5..223a41c9858 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > callbackfn arguments using custom accumulator info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js index 76312163638..1928c4d082a 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > callbackfn arguments using default accumulator (value at index 0) info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js index dbe75c977c6..466222143f2 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Instance buffer can be detached during loop info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js index f6eb00b41d0..ee38745b2f9 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Throws TypeError if callbackfn is not callable info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js index a0847608e47..2440fb3f788 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Does not iterate over non-integer properties info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js index 1565adbdd68..ef459de13fd 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > callbackfn is not called on empty instances info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js index 78c676227ee..3a6ec1915eb 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: Instance buffer can be resized during iteration includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] @@ -22,7 +22,7 @@ features: [TypedArray, resizable-arraybuffer] testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 3}); + var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 3}); var sample = new TA(buffer); var finalNext, expectedPrevs, expectedNexts, expectedIndices, expectedArrays; var prevs, nexts, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js index c37177a98b8..bc6eb468bfb 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > The callbackfn return does not change the `this` instance includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js index e7541755e68..a1dd3424ab6 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Returns abrupt from callbackfn info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js index c37a287332c..c1c7be34851 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Integer indexed values changed during iteration info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js index ea166720836..4a3c16b4523 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > callbackfn `this` value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js index 44e1eb68f43..6932201fe39 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: Throws a TypeError if this has a detached buffer info: | 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js index 42311f5d09f..8c0a2b3f7bf 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Returns given initialValue on empty instances without calling callbackfn info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js index 26fcfe8bf0c..fa02c933292 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > If len is 0 and initialValue is not present, throw a TypeError exception. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js index d6a70e09894..fbc17566c50 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: Get "length" uses internal ArrayLength info: | 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-func.js index 5e1ab17b48f..200528ef122 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: Throws a TypeError exception when invoked as a function info: | 22.2.3.19 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-method.js index 22c762ec797..edaeb907b5a 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.19 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/length.js b/test/sendable/builtins/TypedArray/prototype/reduce/length.js index 9beb5dbf6a8..ada9f402856 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/length.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > %SendableTypedArray%.prototype.reduce.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/name.js b/test/sendable/builtins/TypedArray/prototype/reduce/name.js index deb5073cc76..c36f5d124bc 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/name.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > %SendableTypedArray%.prototype.reduce.name is "reduce". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/reduce/prop-desc.js index 454c112f12e..11b1233aa26 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > "reduce" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-grow-mid-iteration.js index 3dbb6ea2738..3654de54054 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > SendableTypedArray.p.reduce behaves correctly on SendableTypedArrays backed by resizable buffers that are grown mid-iteration. diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-shrink-mid-iteration.js index 404c9fe4d09..6b269bfd57a 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > SendableTypedArray.p.reduce behaves correctly on SendableTypedArrays backed by resizable buffers that are shrunk mid-iteration. diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer.js index 4fbcf4ed2b8..f73a09c5d0e 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > SendableTypedArray.p.reduce behaves correctly on SendableTypedArrays backed by resizable buffers. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js b/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js index 156b2d09864..fe312115d55 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Returns last accumulator value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js b/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js index 945394c4bc2..639fa397987 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Result can be of any type without any number conversions info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js index 202518ef358..81b32b9b5d8 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js b/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js index f68808bb9de..16f0d9bd193 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Returns [0] without calling callbackfn if length is 1 and initialValue is not present. diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-object.js index f8e64f6e212..d86ebcc6a95 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.20 %SendableTypedArray%.prototype.reduce ( callbackfn [ , initialValue ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js index e3cdb3ee728..d40e62435c7 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { reduce.call([], callbackfn); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { reduce.call(ab, callbackfn); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { reduce.call(dv, callbackfn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js index d55708bf0c4..1258b865eeb 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduce +esid: sec-%sendableTypedArray%.prototype.reduce description: > Integer indexed values are not cached before iteration info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js index 6288454260f..0693424da55 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > callbackfn arguments using custom accumulator info: | @@ -36,7 +36,7 @@ info: | kValue, k, O »). d. Decrease k by 1. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js index a78f98a5037..84d317442ad 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > callbackfn arguments using default accumulator (value at last index) info: | @@ -45,7 +45,7 @@ info: | kValue, k, O »). d. Decrease k by 1. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js index 2cab666717c..4287349e835 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Instance buffer can be detached during loop info: | @@ -35,7 +35,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [detachArrayBuffer.js, testBigIntSendableTypedArray.js] +includes: [detachArrayBuffer.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js index 3d0f49e3bb7..4b4a9250777 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Throws TypeError if callbackfn is not callable info: | @@ -31,7 +31,7 @@ info: | 3. If IsCallable(callbackfn) is false, throw a TypeError exception. 4. If len is 0 and initialValue is not present, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js index 93eb4ad7945..a8c63164a0f 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Does not iterate over non-integer properties info: | @@ -36,7 +36,7 @@ info: | kValue, k, O »). d. Decrease k by 1. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js index 55953229b50..f25a28d0598 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > callbackfn is not called on empty instances info: | @@ -38,7 +38,7 @@ info: | kValue, k, O »). d. Decrease k by 1. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js index b16c7184026..68d293f6bbc 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > The callbackfn return does not change the `this` instance -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js index 2d9710cb9e6..69d2cb91bd5 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Returns abrupt from callbackfn info: | @@ -35,7 +35,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js index 5e4af5486dc..c031ff1f94e 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Integer indexed values changed during iteration info: | @@ -26,7 +26,7 @@ info: | performing a [[Get]] of "length". 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Reflect.set, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js index e7605677b1b..5f09bd22462 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > callbackfn `this` value info: | @@ -36,7 +36,7 @@ info: | kValue, k, O »). d. Decrease k by 1. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js index e8b34e96dd5..3e8160a1564 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: Throws a TypeError if this has a detached buffer info: | 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js index 4a66f5e3df7..f802420ade4 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Returns given initialValue on empty instances without calling callbackfn info: | @@ -40,7 +40,7 @@ info: | 8. Repeat, while k ≥ 0 ... 9. Return accumulator. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js index 51cf39dad56..bcaf40fc1c9 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > If len is 0 and initialValue is not present, throw a TypeError exception. info: | @@ -30,7 +30,7 @@ info: | ... 4. If len is 0 and initialValue is not present, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js index d989bdd11e4..b1cf4f25d0e 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: Get "length" uses internal ArrayLength info: | 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js index 3f54374cd7e..753ec8cdcb0 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Returns last accumulator value info: | @@ -45,7 +45,7 @@ info: | kValue, k, O »). d. Decrease k by 1. 9. Return accumulator. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js index c28e086ac06..27b0940f12f 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Result can be of any type without any number conversions info: | @@ -45,7 +45,7 @@ info: | kValue, k, O »). d. Decrease k by 1. 9. Return accumulator. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js index 8cbf37062d4..ef9861400ad 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js index c371663da8c..118fd31dabd 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Returns [0] without calling callbackfn if length is 1 and initialValue is not present. @@ -41,7 +41,7 @@ info: | 8. Repeat, while k ≥ 0 ... 9. Return accumulator. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js index 4d94ed892a6..e6f35db6bca 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Integer indexed values are not cached before iteration info: | @@ -36,7 +36,7 @@ info: | kValue, k, O »). d. Decrease k by 1. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js index f3a2bf2e5e3..fd4d430089d 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > callbackfn arguments using custom accumulator info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js index 6d383a11e7c..429f000b103 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > callbackfn arguments using default accumulator (value at last index) info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js index 9063ee6c453..06915052112 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Instance buffer can be detached during loop info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js index 236f2e5f803..0f2c1a25015 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Throws TypeError if callbackfn is not callable info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js index f1610995d2a..582f15b5892 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Does not iterate over non-integer properties info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js index 564fa6d0f11..a9a0a53d84d 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > callbackfn is not called on empty instances info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js index c8224891c53..c298d6ecc60 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: Instance buffer can be resized during iteration includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] @@ -22,7 +22,7 @@ features: [TypedArray, resizable-arraybuffer] testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 3}); + var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 3}); var sample = new TA(buffer); var secondNext, expectedPrevs, expectedNexts, expectedIndices, expectedArrays; var prevs, nexts, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js index 9bf09768df6..2122aaf6bf0 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > The callbackfn return does not change the `this` instance includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js index 88d862069d0..36c34044450 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Returns abrupt from callbackfn info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js index 13465ebdec8..ee9d3a73336 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Integer indexed values changed during iteration info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js index 0ef7056f517..86a04c0eee0 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > callbackfn `this` value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js index 65c382ded61..8e6e1688d11 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: Throws a TypeError if this has a detached buffer info: | 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js index aff35e4dced..3a9994b0aec 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Returns given initialValue on empty instances without calling callbackfn info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js index 704c6c748ca..b87b7ff5921 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > If len is 0 and initialValue is not present, throw a TypeError exception. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js index 3e3cf412001..81c0ab53016 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: Get "length" uses internal ArrayLength info: | 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-func.js index b4401eb60fd..aed0b90bd4b 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: Throws a TypeError exception when invoked as a function info: | 22.2.3.20 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-method.js index 34ce0388ba4..2958993c074 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.20 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/length.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/length.js index ba49d03cbf9..31a02e9f35b 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/length.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > %SendableTypedArray%.prototype.reduceRight.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/name.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/name.js index 5184319caac..4860d0fa0a6 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/name.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > %SendableTypedArray%.prototype.reduceRight.name is "reduceRight". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/prop-desc.js index 436630347d8..8672c15bd8a 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > "reduceRight" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-grow-mid-iteration.js index f8a9381158f..4af57666134 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > SendableTypedArray.p.reduceRight behaves correctly on SendableTypedArrays backed by resizable buffers that are grown mid-iteration. diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-shrink-mid-iteration.js index eee63523134..160989602a8 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > SendableTypedArray.p.reduceRight behaves correctly on SendableTypedArrays backed by resizable buffer that is shrunk mid-iteration diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer.js index ee3aab51c21..e4e784e4721 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > SendableTypedArray.p.reduceRight behaves correctly on SendableTypedArrays backed by resizable buffers. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js index aa57c33bbab..4b12a0d0303 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Returns last accumulator value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js index 138e700768d..d5a3fb921fb 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Result can be of any type without any number conversions info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js index cea732df64c..945ae4051af 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js index b04c27990b1..b5667f55bfd 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Returns [0] without calling callbackfn if length is 1 and initialValue is not present. diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-object.js index a3e946b6ab3..60b0c372f0c 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.21 %SendableTypedArray%.prototype.reduceRight ( callbackfn [ , initialValue ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js index 3250c2f86a0..01eabdedd1f 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { reduceRight.call([], callbackfn); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { reduceRight.call(ab, callbackfn); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { reduceRight.call(dv, callbackfn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js index 3c95c446914..ddf4e9297b5 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reduceright +esid: sec-%sendableTypedArray%.prototype.reduceright description: > Integer indexed values are not cached before iteration info: | diff --git a/test/sendable/builtins/TypedArray/prototype/resizable-and-fixed-have-same-prototype.js b/test/sendable/builtins/TypedArray/prototype/resizable-and-fixed-have-same-prototype.js index 516c3302aa4..6ef857e5bc1 100644 --- a/test/sendable/builtins/TypedArray/prototype/resizable-and-fixed-have-same-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/resizable-and-fixed-have-same-prototype.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype +esid: sec-%sendableTypedArray%.prototype description: > SendableTypedArrays that are backed by resizable buffers have the same prototypes as those backed by fixed-length buffers @@ -22,8 +22,8 @@ includes: [resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableArrayBuffer(40, 80); -const ab = new ArrayBuffer(80); +const rab = CreateResizableSendableArrayBuffer(40, 80); +const ab = new SendableArrayBuffer(80); for (let ctor of ctors) { const ta_rab = new ctor(rab, 0, 3); const ta_ab = new ctor(ab, 0, 3); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/detached-buffer.js index ef4ff1d454b..245f2f062a7 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Throws a TypeError if this has a detached buffer info: | 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js index c35bd5bbfbe..662bcd8c22c 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Get "length" uses internal ArrayLength info: | 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js index d662e933621..7e92c083e14 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Preserves non numeric properties info: | 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) @@ -28,7 +28,7 @@ info: | ... 6. Return O. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js index beed9eb8d88..d81ee679e5f 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/returns-original-object.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/returns-original-object.js index 9da7f679b0c..2844522d7d8 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/returns-original-object.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/returns-original-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Returns the same object info: | 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) @@ -28,11 +28,11 @@ info: | ... 6. Return O. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -var buffer = new ArrayBuffer(64); +var buffer = new SendableArrayBuffer(64); testWithBigIntSendableTypedArrayConstructors(function(TA) { var sample, result, expectedLength; diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/reverts.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/reverts.js index 162b1710832..ce8abdb9356 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/reverts.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/reverts.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Reverts values info: | 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) @@ -28,11 +28,11 @@ info: | ... 6. Return O. -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -var buffer = new ArrayBuffer(64); +var buffer = new SendableArrayBuffer(64); testWithBigIntSendableTypedArrayConstructors(function(TA) { var sample = new TA(buffer, 0, 4); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js index 56730967c01..f7e0caa2253 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Throws a TypeError if this has a detached buffer info: | 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js index c2d5577d123..2e3f9a51b49 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Get "length" uses internal ArrayLength info: | 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-func.js index b276cb4866c..3a2cf5519a6 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Throws a TypeError exception when invoked as a function info: | 22.2.3.21 %SendableTypedArray%.prototype.reverse ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-method.js index c993903f9a7..c69e2a55f0c 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.21 %SendableTypedArray%.prototype.reverse ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/length.js b/test/sendable/builtins/TypedArray/prototype/reverse/length.js index 3172819ae73..33929a0fe39 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/length.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: > %SendableTypedArray%.prototype.reverse.length is 0. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/name.js b/test/sendable/builtins/TypedArray/prototype/reverse/name.js index e7ca1a5a478..476870fdb3c 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/name.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: > %SendableTypedArray%.prototype.reverse.name is "reverse". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js b/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js index d110220306a..afba7793b91 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Preserves non numeric properties info: | 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/reverse/prop-desc.js index 507110a407a..a93b8756715 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: > "reverse" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/reverse/resizable-buffer.js index c3617a00577..a99c2c04bab 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: > SendableTypedArray.p.reverse behaves correctly on SendableTypedArrays backed by resizable buffers. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js index b9b9530e488..77997210d7d 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js b/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js index 2ec20cb0532..4e804a32c62 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Returns the same object info: | 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) @@ -32,7 +32,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -var buffer = new ArrayBuffer(64); +var buffer = new SendableArrayBuffer(64); testWithSendableTypedArrayConstructors(function(TA) { var sample, result, expectedLength; diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js b/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js index ca2e097be04..e103d7d1d10 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Reverts values info: | 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) @@ -32,7 +32,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -var buffer = new ArrayBuffer(64); +var buffer = new SendableArrayBuffer(64); testWithSendableTypedArrayConstructors(function(TA) { var sample = new TA(buffer, 0, 4); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-object.js index 92c905a79b0..ed9465cb9fd 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.22 %SendableTypedArray%.prototype.reverse ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js index 87ff87282cc..e40bd7cb71a 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.reverse +esid: sec-%sendableTypedArray%.prototype.reverse description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { reverse.call([]); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { reverse.call(ab); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { reverse.call(dv); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js index b3d9eb26e19..355b1b24a89 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Throw a RangeError exception if targetOffset < 0 info: | @@ -27,7 +27,7 @@ info: | 6. Let targetOffset be ? ToInteger(offset). 7. If targetOffset < 0, throw a RangeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js index 45e34728d16..95ea6044c27 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > ToInteger(offset) operations info: | @@ -27,7 +27,7 @@ info: | 6. Let targetOffset be ? ToInteger(offset). 7. If targetOffset < 0, throw a RangeError exception. ... -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js index 471c4ba97b0..eeea0a84c70 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Primitive `array` argument is coerced to an object. info: | @@ -35,7 +35,7 @@ info: | [...] f. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, Unordered). [...] -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, SendableTypedArray, Symbol] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js index 65879a55623..9607189edad 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt getting src "length" info: | @@ -26,7 +26,7 @@ info: | ... 16. Let srcLength be ? ToLength(? Get(src, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js index f1a064c1ff1..4cb0a686007 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt from getting src property value info: | @@ -31,7 +31,7 @@ info: | d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js index b3e2fb2091d..f1aa5794662 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt getting src "length" as symbol info: | @@ -26,7 +26,7 @@ info: | ... 16. Let srcLength be ? ToLength(? Get(src, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js index 82732e2e7c8..64ad6c0c81e 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt from ToLength(src "length") info: | @@ -26,7 +26,7 @@ info: | ... 16. Let srcLength be ? ToLength(? Get(src, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js index 6dace852fc8..bec32c94f82 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt from ToNumber(src property symbol value) info: | @@ -31,7 +31,7 @@ info: | d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js index fecec2142ee..4172819051e 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt from ToNumber(src property value) info: | @@ -31,7 +31,7 @@ info: | d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js index 7d1c8d7a1f4..99cef969c2d 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt from ToInteger(Symbol offset) info: | @@ -25,7 +25,7 @@ info: | 22.2.3.23.2 applies. ... 6. Let targetOffset be ? ToInteger(offset). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js index 0aa17e0a7d2..adaff35f18e 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt from ToInteger(offset) info: | @@ -25,7 +25,7 @@ info: | 22.2.3.23.2 applies. ... 6. Let targetOffset be ? ToInteger(offset). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js index d1a817c72f5..8f7d20990fc 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt from ToObject(array) info: | @@ -26,7 +26,7 @@ info: | ... 15. Let src be ? ToObject(array). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js index f3b764ec8c4..03b3d357196 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Get and set each value in order info: | @@ -31,7 +31,7 @@ info: | d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values.js index 8b9cea26a73..6569d003d2a 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Set values to target and return undefined info: | @@ -31,7 +31,7 @@ info: | Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... 22. Return undefined. -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js index 1060ef8f9a9..aff5bca47d2 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Type conversions on ToNumber(src property value) info: | @@ -31,7 +31,7 @@ info: | d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js index 276161de02c..8e7abd92581 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Values from src array are not cached info: | @@ -31,7 +31,7 @@ info: | d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js index 639f60559c4..b58669a8416 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Uses target's internal [[ArrayLength]] info: | @@ -28,7 +28,7 @@ info: | ... 17. If srcLength + targetOffset > targetLength, throw a RangeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js index 80ab6891dbc..2d65ebd1f52 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Throws a TypeError if targetBuffer is detached on ToInteger(offset) info: | @@ -26,11 +26,11 @@ info: | ... 6. Let targetOffset be ? ToInteger(offset). ... - 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal + 8. Let targetBuffer be the value of target's [[ViewedSendableArrayBuffer]] internal slot. 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js index 563882d06d5..902107b4ee4 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Throws a TypeError if targetBuffer is detached info: | @@ -24,14 +24,14 @@ info: | [[TypedArrayName]] internal slot. If it is such an Object, the definition in 22.2.3.23.2 applies. ... - 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal + 8. Let targetBuffer be the value of target's [[ViewedSendableArrayBuffer]] internal slot. 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. ... 15. Let src be ? ToObject(array). 16. Let srcLength be ? ToLength(? Get(src, "length")). ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobigint64.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobigint64.js index 9d19eebb20c..aba9285ff3c 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobigint64.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobigint64.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Behavior for input array of BigInts info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobiguint64.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobiguint64.js index d567acaf4ed..5cff1148bf1 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobiguint64.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/bigint-tobiguint64.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Behavior for input array of BigInts info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/boolean-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/boolean-tobigint.js index a3385489828..1ef8c0a6a1a 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/boolean-tobigint.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/boolean-tobigint.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Behavior for input array of Booleans info: | @@ -46,7 +46,7 @@ info: | Argument Type: Boolean Result: Return 1n if prim is true and 0n if prim is false. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/null-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/null-tobigint.js index 4763ea6cb70..db148722f34 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/null-tobigint.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/null-tobigint.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt on null info: | @@ -46,7 +46,7 @@ info: | Argument Type: Null Result: Throw a TypeError exception. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/number-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/number-tobigint.js index f8b9f2b1291..ad99d47d029 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/number-tobigint.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/number-tobigint.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt on Number info: | @@ -47,7 +47,7 @@ info: | Argument Type: Number Result: Throw a TypeError exception. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-big.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-big.js index 3119d043def..02ea3034a44 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-big.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-big.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > If typedArray constructor argument is a Big(U)Int, succeed in set info: | @@ -28,7 +28,7 @@ info: | other does not, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js index b8f464bb0bb..096df4816e2 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > If typedArray set argument is not a Big(U)Int, and target is "Big", throw info: | @@ -28,7 +28,7 @@ info: | other does not, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, testTypedArray.js] +includes: [testBigIntTypedArray.js, testTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js index 3597e5593d0..585dd3199c0 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt String, when StringToBigInt returns NaN info: | @@ -49,7 +49,7 @@ info: | 2. If n is NaN, throw a SyntaxError exception. 3. Return n. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-tobigint.js index bdeb7318448..aae55b05fb3 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-tobigint.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-tobigint.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Behavior for input array of Strings, successful conversion info: | @@ -49,7 +49,7 @@ info: | 2. If n is NaN, throw a SyntaxError exception. 3. Return n. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/symbol-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/symbol-tobigint.js index 790474b817e..8b870ac29c5 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/symbol-tobigint.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/symbol-tobigint.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt on Symbol info: | @@ -47,7 +47,7 @@ info: | Argument Type: Symbol Result: Throw a TypeError exception. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, Symbol] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js index 55047be5d77..f80d3fb2240 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Throw a RangeError exception if targetOffset < 0 info: | @@ -25,7 +25,7 @@ info: | ... 6. Let targetOffset be ? ToInteger(offset). 7. If targetOffset < 0, throw a RangeError exception. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js index 174909a103a..27b020eec0a 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > ToInteger(offset) operations info: | @@ -24,7 +24,7 @@ info: | the definition in 22.2.3.23.1 applies. ... 6. Let targetOffset be ? ToInteger(offset). -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js index 141fe481043..14ae9b687a2 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Return abrupt from ToInteger(Symbol offset) info: | @@ -24,7 +24,7 @@ info: | the definition in 22.2.3.23.1 applies. ... 6. Let targetOffset be ? ToInteger(offset). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js index 6fd95bd9159..b99358f4cdd 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Return abrupt from ToInteger(offset) info: | @@ -24,7 +24,7 @@ info: | the definition in 22.2.3.23.1 applies. ... 6. Let targetOffset be ? ToInteger(offset). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js index f747a1f5e11..5248ebd7539 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js @@ -14,16 +14,16 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the different buffer and different type. -includes: [testBigIntSendableTypedArray.js, compareArray.js] -features: [BigInt, SharedArrayBuffer, TypedArray] +includes: [testBigIntTypedArray.js, compareArray.js] +features: [BigInt, SharedSendableArrayBuffer, TypedArray] ---*/ testWithBigIntSendableTypedArrayConstructors(function(TA) { - var sab = new SharedArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT); + var sab = new SharedSendableArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT); var otherCtor = TA === BigInt64Array ? BigUint64Array : BigInt64Array; var src = new otherCtor(sab); src[0] = 42n; @@ -47,7 +47,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { src = new BigInt64Array([42n, 43n]); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -57,7 +57,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42n, 43n, 3n, 4n]), "sample is SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -67,7 +67,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1n, 42n, 43n, 4n]), "sample is SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -77,13 +77,13 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1n, 2n, 42n, 43n]), "sample is SAB-backed, offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - var sab1 = new SharedArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT); + var sab1 = new SharedSendableArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT); src = new BigInt64Array(sab1); src[0] = 42n; src[1] = 43n; var sab2; - sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1n; sample[1] = 2n; @@ -93,7 +93,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src and sample are SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1n; sample[1] = 2n; @@ -103,7 +103,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src and sample are SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1n; sample[1] = 2n; diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js index 71293338a23..5a824bbef50 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the different buffer and different type. @@ -35,7 +35,7 @@ info: | i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType). ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value). -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js index a49c7379a51..13c6a469ce7 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js @@ -14,18 +14,18 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the different buffer and same constructor. srcBuffer values are cached. -includes: [testBigIntSendableTypedArray.js, compareArray.js] -features: [BigInt, SharedArrayBuffer, TypedArray] +includes: [testBigIntTypedArray.js, compareArray.js] +features: [BigInt, SharedSendableArrayBuffer, TypedArray] ---*/ testWithBigIntSendableTypedArrayConstructors(function(TA) { var sample, result; - var sab = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT); + var sab = new SharedSendableArrayBuffer(2 * TA.BYTES_PER_ELEMENT); var src = new TA(sab); src[0] = 42n; src[1] = 43n; @@ -47,7 +47,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { src = new TA([42n, 43n]); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -57,7 +57,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1n, 42n, 43n, 4n]), "sample is SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -67,7 +67,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42n, 43n, 3n, 4n]), "sample is SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -78,13 +78,13 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert.sameValue(result, undefined, "returns undefined"); - var sab1 = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT); + var sab1 = new SharedSendableArrayBuffer(2 * TA.BYTES_PER_ELEMENT); src = new TA(sab1); src[0] = 42n; src[1] = 43n; var sab2; - sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1n; sample[1] = 2n; @@ -94,7 +94,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src and sample are SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1n; sample[1] = 2n; @@ -104,7 +104,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src and sample are SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1n; sample[1] = 2n; diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js index 8866aa45fae..5c07c8a06ee 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the different buffer and same constructor. srcBuffer values are cached. @@ -38,7 +38,7 @@ info: | value). ... 29. Return undefined. -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js index 4afc37893fc..47012f18a3e 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js @@ -14,23 +14,23 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the same buffer and same - constructor when underlying ArrayBuffer has been resized -includes: [testBigIntSendableTypedArray.js, compareArray.js] + constructor when underlying SendableArrayBuffer has been resized +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var source = new TA(ab); var target = new TA(ab); var expected = [10, 20, 30, 40]; diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js index d2f40ed4986..c1f705b7b8b 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js @@ -14,18 +14,18 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the same buffer and same constructor. srcBuffer values are cached. -includes: [testBigIntSendableTypedArray.js, compareArray.js] -features: [BigInt, SharedArrayBuffer, TypedArray] +includes: [testBigIntTypedArray.js, compareArray.js] +features: [BigInt, SharedSendableArrayBuffer, TypedArray] ---*/ testWithBigIntSendableTypedArrayConstructors(function(TA) { var sample, src, result, sab; - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -36,7 +36,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1n, 2n, 3n, 4n]), "offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -47,7 +47,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1n, 1n, 2n, 4n]), "offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js index c8872d0c314..9a84e0f9330 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the same buffer and same constructor. srcBuffer values are cached. @@ -25,9 +25,9 @@ info: | the definition in 22.2.3.23.1 applies. ... 23. If SameValue(srcBuffer, targetBuffer) is true, then - a. Let srcBuffer be ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength, - %ArrayBuffer%). - b. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not + a. Let srcBuffer be ? CloneSendableArrayBuffer(srcBuffer, srcByteOffset, srcLength, + %SendableArrayBuffer%). + b. NOTE: %SendableArrayBuffer% is used to clone srcBuffer because is it known to not have any observable side-effects. ... ... @@ -39,7 +39,7 @@ info: | i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8"). ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8", value). -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js index 2ff19a3e238..a785f020450 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Uses typedArray's internal [[ArrayLength]] info: | @@ -27,7 +27,7 @@ info: | ... 22. If srcLength + targetOffset > targetLength, throw a RangeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js index 016e08d30e7..74722f8f1e6 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Uses typedArray's internal [[ByteOffset]] info: | @@ -24,7 +24,7 @@ info: | ... 21. Let srcByteOffset be typedArray.[[ByteOffset]]. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js index 12f09bcf237..d4792b5a043 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > If srcLength + targetOffset > targetLength, throw a RangeError exception. info: | @@ -31,7 +31,7 @@ info: | ... 22. If srcLength + targetOffset > targetLength, throw a RangeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js index 9674ddceaf7..4c9997e38ae 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Throws a TypeError if srcBuffer is detached on ToInteger(offset) info: | @@ -25,11 +25,11 @@ info: | ... 6. Let targetOffset be ? ToInteger(offset). ... - 11. Let srcBuffer be the value of typedArray's [[ViewedArrayBuffer]] internal + 11. Let srcBuffer be the value of typedArray's [[ViewedSendableArrayBuffer]] internal slot. 12. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js index 35a04143cc0..c1f4aa40192 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Uses target's internal [[ArrayLength]] info: | @@ -28,7 +28,7 @@ info: | ... 22. If srcLength + targetOffset > targetLength, throw a RangeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js index ae28fbb8ab0..912aa697a64 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Uses target's internal [[ArrayLength]] info: | @@ -25,7 +25,7 @@ info: | ... 16. Let targetByteOffset be target.[[ByteOffset]]. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js index 7d46d9031ad..18339e4572f 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js @@ -14,9 +14,9 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: Error when target SendableTypedArray fails boundary checks -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ @@ -27,16 +27,16 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 4}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 4}); var target = new TA(ab, 0, 4); - var source = new TA(new ArrayBuffer(BPE * 4)); + var source = new TA(new SendableArrayBuffer(BPE * 4)); var expectedError; try { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js index fe173872305..b9c88b02e35 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Throws a TypeError if targetBuffer is detached on ToInteger(offset) info: | @@ -25,11 +25,11 @@ info: | ... 6. Let targetOffset be ? ToInteger(offset). ... - 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal + 8. Let targetBuffer be the value of target's [[ViewedSendableArrayBuffer]] internal slot. 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/undefined-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/undefined-tobigint.js index 938dc7805e2..0b83e27f046 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/undefined-tobigint.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/undefined-tobigint.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Return abrupt on undefined info: | @@ -46,7 +46,7 @@ info: | Argument Type: Undefined Result: Throw a TypeError exception. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js index c1dadf622af..941da95950c 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Throw a RangeError exception if targetOffset < 0 info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js index a43342756e9..01397f0320c 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > ToInteger(offset) operations info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js index ddfb52a7b71..660fdf91ab3 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Primitive `array` argument is coerced to an object. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js index 596eb85f127..fd1b672cc09 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt getting src "length" info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js index 59abebffaaf..b5e5897e5ae 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt from getting src property value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js index f6f297a3352..f6dbd2d3377 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt getting src "length" as symbol info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js index 4d559bf5fcd..8eae5217957 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt from ToLength(src "length") info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js index 71352d91c56..1237d41536b 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt from ToNumber(src property symbol value) info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js index 5734f285363..1fb7da2bf62 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt from ToNumber(src property value) info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js index e8b122f0829..69746683c72 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt from ToInteger(Symbol offset) info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js index 309efa84ba9..a57ca6acade 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt from ToInteger(offset) info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js index b96bc5c36a0..5b8e37aa969 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Return abrupt from ToObject(array) info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js index 26a0d25dd87..747c8e39bcc 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Get and set each value in order info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js index 0a6520fe754..0c42a5297db 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Set values to target and return undefined info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js index 108bb451809..3d73e5c55d3 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Values conversions on ToNumber(src property value) info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js index 6639bde9de0..fb7d89f83c8 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Type conversions on ToNumber(src property value) info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js index e234f34b852..de495fb6148 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Values from src array are not cached info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js index 073a0bce78c..5f8f7c9404a 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Uses target's internal [[ArrayLength]] info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js index 18d2763d2b3..89921f37226 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Does not throw if target TA is detached mid-iteration includes: [testTypedArray.js, detachArrayBuffer.js] diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js index 28ef0f00e24..b9c59f18163 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Throws a TypeError if targetBuffer is detached on ToInteger(offset) info: | @@ -26,7 +26,7 @@ info: | ... 6. Let targetOffset be ? ToInteger(offset). ... - 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal + 8. Let targetBuffer be the value of target's [[ViewedSendableArrayBuffer]] internal slot. 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. ... diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js index 106a258660b..6b966c1f157 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-array-offset +esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Throws a TypeError if targetBuffer is detached info: | @@ -24,7 +24,7 @@ info: | [[TypedArrayName]] internal slot. If it is such an Object, the definition in 22.2.3.23.2 applies. ... - 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal + 8. Let targetBuffer be the value of target's [[ViewedSendableArrayBuffer]] internal slot. 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. ... diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-value-conversion-resizes-array-buffer.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-value-conversion-resizes-array-buffer.js index 0257f785381..3c5381c1bc4 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-value-conversion-resizes-array-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-value-conversion-resizes-array-buffer.js @@ -31,7 +31,7 @@ features: [resizable-arraybuffer] includes: [compareArray.js] ---*/ -var rab = new ArrayBuffer(5, {maxByteLength: 10}); +var rab = new SendableArrayBuffer(5, {maxByteLength: 10}); var typedArray = new Int8Array(rab); var log = []; diff --git a/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js b/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js index 551c9c5b459..3cef5d9dba9 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js +++ b/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set.2 +esid: sec-%sendableTypedArray%.prototype.set.2 description: Preservation of bit-level encoding info: | [...] diff --git a/test/sendable/builtins/TypedArray/prototype/set/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/set/invoked-as-func.js index 1c4d235e640..973a2883020 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/set/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set +esid: sec-%sendableTypedArray%.prototype.set description: Throws a TypeError exception when invoked as a function info: | 22.2.3.22 %SendableTypedArray%.prototype.set ( overloaded [ , offset ]) diff --git a/test/sendable/builtins/TypedArray/prototype/set/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/set/invoked-as-method.js index a75238f3cf5..6a4fe60c0d5 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/set/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set +esid: sec-%sendableTypedArray%.prototype.set description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.22 %SendableTypedArray%.prototype.set ( overloaded [ , offset ]) diff --git a/test/sendable/builtins/TypedArray/prototype/set/length.js b/test/sendable/builtins/TypedArray/prototype/set/length.js index b771286f197..54e51db8608 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/length.js +++ b/test/sendable/builtins/TypedArray/prototype/set/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set +esid: sec-%sendableTypedArray%.prototype.set description: > %SendableTypedArray%.prototype.set.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/name.js b/test/sendable/builtins/TypedArray/prototype/set/name.js index 27921276d77..e2346590cda 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/name.js +++ b/test/sendable/builtins/TypedArray/prototype/set/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set +esid: sec-%sendableTypedArray%.prototype.set description: > %SendableTypedArray%.prototype.set.name is "set". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/set/prop-desc.js index 96717681c8a..76202377349 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/set/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set +esid: sec-%sendableTypedArray%.prototype.set description: > "set" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js b/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js index d88dbe38de4..d49f5b17c13 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > If typedArray set argument is a Big(U)Int, and target not "Big", throw info: | @@ -28,7 +28,7 @@ info: | other does not, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, testTypedArray.js] +includes: [testBigIntTypedArray.js, testTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/target-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/set/target-grow-mid-iteration.js index 857a90b8218..a073096efa8 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/target-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/set/target-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set +esid: sec-%sendableTypedArray%.prototype.set description: > SendableTypedArray.p.set behaves correctly on SendableTypedArrays backed by resizable buffers that are grown mid-iteration due to a Proxy source. diff --git a/test/sendable/builtins/TypedArray/prototype/set/target-grow-source-length-getter.js b/test/sendable/builtins/TypedArray/prototype/set/target-grow-source-length-getter.js index 64d75719ec5..3bcb6e7fdb0 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/target-grow-source-length-getter.js +++ b/test/sendable/builtins/TypedArray/prototype/set/target-grow-source-length-getter.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set +esid: sec-%sendableTypedArray%.prototype.set description: > SendableTypedArray.p.set behaves correctly on SendableTypedArrays backed by a resizable buffer is grown due to the source's length getter diff --git a/test/sendable/builtins/TypedArray/prototype/set/target-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/set/target-shrink-mid-iteration.js index 03428a72da5..858245e23f7 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/target-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/set/target-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set +esid: sec-%sendableTypedArray%.prototype.set description: > SendableTypedArray.p.set behaves correctly on SendableTypedArrays backed by resizable buffers that are shrunk mid-iteration due to a Proxy source. diff --git a/test/sendable/builtins/TypedArray/prototype/set/target-shrink-source-length-getter.js b/test/sendable/builtins/TypedArray/prototype/set/target-shrink-source-length-getter.js index 3a21bbbd590..d7e6dafaeae 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/target-shrink-source-length-getter.js +++ b/test/sendable/builtins/TypedArray/prototype/set/target-shrink-source-length-getter.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set +esid: sec-%sendableTypedArray%.prototype.set description: > SendableTypedArray.p.set behaves correctly on SendableTypedArrays backed by resizable buffers that are shrunk due to the source's length getter. diff --git a/test/sendable/builtins/TypedArray/prototype/set/this-backed-by-resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/set/this-backed-by-resizable-buffer.js index fbab9766bb0..7692172f13b 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/this-backed-by-resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/set/this-backed-by-resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set +esid: sec-%sendableTypedArray%.prototype.set description: > SendableTypedArray.p.set behaves correctly on SendableTypedArrays backed by resizable buffers. includes: [compareArray.js, resizableArrayBufferUtils.js] @@ -36,7 +36,7 @@ function SetNumOrBigInt(target, source, offset) { } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/set/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/set/this-is-not-object.js index 719a508bd33..c4346cf0dc4 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/set/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-overloaded-offset +esid: sec-%sendableTypedArray%.prototype.set-overloaded-offset description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.23 %SendableTypedArray%.prototype.set diff --git a/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js index a314556edf7..49a9e75c4b1 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-overloaded-offset +esid: sec-%sendableTypedArray%.prototype.set-overloaded-offset description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -40,12 +40,12 @@ assert.throws(TypeError, function() { set.call([], []); }, "this is an Array"); -var ab1 = new ArrayBuffer(8); +var ab1 = new SendableArrayBuffer(8); assert.throws(TypeError, function() { set.call(ab1, []); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv1 = new DataView(new ArrayBuffer(8), 0, 1); +var dv1 = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { set.call(dv1, []); }, "this is a DataView instance"); @@ -58,12 +58,12 @@ assert.throws(TypeError, function() { set.call([], new Int8Array()); }, "this is an Array"); -var ab2 = new ArrayBuffer(8); +var ab2 = new SendableArrayBuffer(8); assert.throws(TypeError, function() { set.call(ab2, new Int8Array()); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv2 = new DataView(new ArrayBuffer(8), 0, 1); +var dv2 = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { set.call(dv2, new Int8Array()); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js index eb788cfda0d..6dd0207a400 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Throw a RangeError exception if targetOffset < 0 info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js index 18fb782ea35..8da3fd56fac 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > ToInteger(offset) operations info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js index 485f3a136d2..43c73308a2e 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Return abrupt from ToInteger(Symbol offset) info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js index ac4c343d594..be0750d8ac1 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Return abrupt from ToInteger(offset) info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js index dee9f245859..215a4cc1d11 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js @@ -14,11 +14,11 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set converted values from different buffer of different types and different type instances includes: [byteConversionValues.js, testTypedArray.js] -features: [SharedArrayBuffer] +features: [SharedSendableArrayBuffer] ---*/ testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { @@ -31,7 +31,7 @@ testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expe var sab, src, target; - sab = new SharedArrayBuffer(4); + sab = new SharedSendableArrayBuffer(4); src = new Int32Array(sab); src[0] = value; target = new TA([initial]); @@ -40,7 +40,7 @@ testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expe assert.sameValue(target[0], expected, "src is SAB-backed"); - sab = new SharedArrayBuffer(4); + sab = new SharedSendableArrayBuffer(4); src = new Int32Array([value]); target = new TA(sab); target[0] = initial; @@ -49,8 +49,8 @@ testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expe assert.sameValue(target[0], expected, "target is SAB-backed"); - var sab1 = new SharedArrayBuffer(4); - var sab2 = new SharedArrayBuffer(4); + var sab1 = new SharedSendableArrayBuffer(4); + var sab2 = new SharedSendableArrayBuffer(4); src = new Int32Array(sab1); src[0] = value; target = new TA(sab2); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js index 30974f7fcb9..499eceed2f0 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set converted values from different buffer and different type instances info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js index c1acccbf41a..a632b47c845 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js @@ -14,19 +14,19 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the different buffer and different type. includes: [testTypedArray.js, compareArray.js] -features: [SharedArrayBuffer, TypedArray] +features: [SharedSendableArrayBuffer, TypedArray] ---*/ var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; testWithSendableTypedArrayConstructors(function(TA) { var other = Int32Array; - var sab = new SharedArrayBuffer(2 * other.BYTES_PER_ELEMENT); + var sab = new SharedSendableArrayBuffer(2 * other.BYTES_PER_ELEMENT); var src = new other(sab); src[0] = 42; src[1] = 43; @@ -50,7 +50,7 @@ testWithSendableTypedArrayConstructors(function(TA) { src = new other([42, 43]); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -60,7 +60,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42, 43, 3, 4]), "sample is SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -70,7 +70,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1, 42, 43, 4]), "sample is SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -80,13 +80,13 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1, 2, 42, 43]), "sample is SAB-backed, offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - var sab1 = new SharedArrayBuffer(2 * other.BYTES_PER_ELEMENT); + var sab1 = new SharedSendableArrayBuffer(2 * other.BYTES_PER_ELEMENT); src = new other(sab1); src[0] = 42; src[1] = 43; var sab2; - sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1; sample[1] = 2; @@ -96,7 +96,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42, 43, 3, 4]), "src and sample are SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1; sample[1] = 2; @@ -106,7 +106,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1, 42, 43, 4]), "src and sample are SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1; sample[1] = 2; diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js index 1946ef7a150..659c49ae088 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the different buffer and different type. diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js index e7817e768e1..bd750a4e4a0 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js @@ -14,12 +14,12 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the different buffer and same constructor. srcBuffer values are cached. includes: [testTypedArray.js, compareArray.js] -features: [SharedArrayBuffer, TypedArray] +features: [SharedSendableArrayBuffer, TypedArray] ---*/ var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; @@ -27,7 +27,7 @@ var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uin testWithSendableTypedArrayConstructors(function(TA) { var sample, result; - var sab = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT); + var sab = new SharedSendableArrayBuffer(2 * TA.BYTES_PER_ELEMENT); var src = new TA(sab); src[0] = 42; src[1] = 43; @@ -50,7 +50,7 @@ testWithSendableTypedArrayConstructors(function(TA) { src = new TA([42, 43]); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -60,7 +60,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1, 42, 43, 4]), "sample is SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -70,7 +70,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42, 43, 3, 4]), "sample is SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -81,13 +81,13 @@ testWithSendableTypedArrayConstructors(function(TA) { assert.sameValue(result, undefined, "returns undefined"); - var sab1 = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT); + var sab1 = new SharedSendableArrayBuffer(2 * TA.BYTES_PER_ELEMENT); src = new TA(sab1); src[0] = 42; src[1] = 43; var sab2; - sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1; sample[1] = 2; @@ -97,7 +97,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1, 42, 43, 4]), "src and sample are SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1; sample[1] = 2; @@ -107,7 +107,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42, 43, 3, 4]), "src and sample are SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1; sample[1] = 2; diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js index b2be605c069..0a05f884ef7 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the different buffer and same constructor. srcBuffer values are cached. diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js index bacb5c0a7af..2a0ce84d80a 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the same buffer and different constructor. @@ -25,9 +25,9 @@ info: | the definition in 22.2.3.23.1 applies. ... 23. If SameValue(srcBuffer, targetBuffer) is true, then - a. Let srcBuffer be ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength, - %ArrayBuffer%). - b. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not + a. Let srcBuffer be ? CloneSendableArrayBuffer(srcBuffer, srcByteOffset, srcLength, + %SendableArrayBuffer%). + b. NOTE: %SendableArrayBuffer% is used to clone srcBuffer because is it known to not have any observable side-effects. ... ... diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js index 41426616da3..7df5a9077f2 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js @@ -14,23 +14,23 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the same buffer and same - constructor when underlying ArrayBuffer has been resized + constructor when underlying SendableArrayBuffer has been resized includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var source = new TA(ab); var target = new TA(ab); var expected = [10, 20, 30, 40]; diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js index ba99dbcf831..7b1dfc1ed96 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js @@ -14,12 +14,12 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the same buffer and same constructor. srcBuffer values are cached. includes: [testTypedArray.js, compareArray.js] -features: [SharedArrayBuffer, TypedArray] +features: [SharedSendableArrayBuffer, TypedArray] ---*/ var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; @@ -27,7 +27,7 @@ var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uin testWithSendableTypedArrayConstructors(function(TA) { var sample, src, result, sab; - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -38,7 +38,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1, 2, 3, 4]), "offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -49,7 +49,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1, 1, 2, 4]), "offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js index d9c7b8d5956..c1f8705664b 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the same buffer and same constructor. srcBuffer values are cached. @@ -25,9 +25,9 @@ info: | the definition in 22.2.3.23.1 applies. ... 23. If SameValue(srcBuffer, targetBuffer) is true, then - a. Let srcBuffer be ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength, - %ArrayBuffer%). - b. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not + a. Let srcBuffer be ? CloneSendableArrayBuffer(srcBuffer, srcByteOffset, srcLength, + %SendableArrayBuffer%). + b. NOTE: %SendableArrayBuffer% is used to clone srcBuffer because is it known to not have any observable side-effects. ... ... diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js index 43910667c9b..befe8894369 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Uses typedArray's internal [[ArrayLength]] info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-backed-by-resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-backed-by-resizable-buffer.js index 9df49d52570..a6e5b4a3599 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-backed-by-resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-backed-by-resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set +esid: sec-%sendableTypedArray%.prototype.set description: > SendableTypedArray.p.set behaves correctly on SendableTypedArrays backed by resizable buffers. includes: [compareArray.js, resizableArrayBufferUtils.js] @@ -45,7 +45,7 @@ for (let targetIsResizable of [ ]) { for (let targetCtor of ctors) { for (let sourceCtor of ctors) { - const rab = CreateResizableArrayBuffer(4 * sourceCtor.BYTES_PER_ELEMENT, 8 * sourceCtor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * sourceCtor.BYTES_PER_ELEMENT, 8 * sourceCtor.BYTES_PER_ELEMENT); const fixedLength = new sourceCtor(rab, 0, 4); const fixedLengthWithOffset = new sourceCtor(rab, 2 * sourceCtor.BYTES_PER_ELEMENT, 2); const lengthTracking = new sourceCtor(rab, 0); @@ -63,7 +63,7 @@ for (let targetIsResizable of [ // [1, 2, 3, 4, ...] << lengthTracking // [3, 4, ...] << lengthTrackingWithOffset - const targetAb = targetIsResizable ? new ArrayBuffer(6 * targetCtor.BYTES_PER_ELEMENT) : new ArrayBuffer(6 * targetCtor.BYTES_PER_ELEMENT, { maxByteLength: 8 * targetCtor.BYTES_PER_ELEMENT }); + const targetAb = targetIsResizable ? new SendableArrayBuffer(6 * targetCtor.BYTES_PER_ELEMENT) : new SendableArrayBuffer(6 * targetCtor.BYTES_PER_ELEMENT, { maxByteLength: 8 * targetCtor.BYTES_PER_ELEMENT }); const target = new targetCtor(targetAb); if (IsBigIntSendableTypedArray(target) != IsBigIntSendableTypedArray(taFull)) { // Can't mix BigInt and non-BigInt types. diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js index fb730327b0d..d5fed20564e 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Uses typedArray's internal [[ByteOffset]] info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js index 9dc257abf3d..eae41d72e6a 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > If srcLength + targetOffset > targetLength, throw a RangeError exception. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js index 77d5ddb855c..2ebb9f535b3 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Throws a TypeError if srcBuffer is detached on ToInteger(offset) info: | @@ -25,7 +25,7 @@ info: | ... 6. Let targetOffset be ? ToInteger(offset). ... - 11. Let srcBuffer be the value of typedArray's [[ViewedArrayBuffer]] internal + 11. Let srcBuffer be the value of typedArray's [[ViewedSendableArrayBuffer]] internal slot. 12. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception. ... diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js index 7decf8d948c..0980d39db76 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Uses target's internal [[ArrayLength]] info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js index a910a9ac4a7..04177bddaf1 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Uses target's internal [[ArrayLength]] info: | diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js index 1640988d501..7faa679b263 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: Error when target SendableTypedArray fails boundary checks includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] @@ -27,16 +27,16 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 4}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 4}); var target = new TA(ab, 0, 4); - var source = new TA(new ArrayBuffer(BPE * 4)); + var source = new TA(new SendableArrayBuffer(BPE * 4)); var expectedError; try { diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js index bd2ab0a1884..ac007b30172 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.set-typedarray-offset +esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Throws a TypeError if targetBuffer is detached on ToInteger(offset) info: | @@ -25,7 +25,7 @@ info: | ... 6. Let targetOffset be ? ToInteger(offset). ... - 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal + 8. Let targetBuffer be the value of target's [[ViewedSendableArrayBuffer]] internal slot. 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. ... diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js index 3be5f74e992..1223f19d366 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Use internal ArrayLength instead of getting a length property info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) @@ -22,7 +22,7 @@ info: | ... 3. Let len be the value of O's [[ArrayLength]] internal slot. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js index f3323a89e06..d66767235bd 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js @@ -14,9 +14,9 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > - Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during create with custom constructor (other targetType) + Throws a TypeError if _O_.[[ViewedSendableArrayBuffer]] is detached during create with custom constructor (other targetType) info: | %SendableTypedArray%.prototype.slice ( start, end ) @@ -35,12 +35,12 @@ info: | The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: Perform ? RequireInternalSlot(O, [[TypedArrayName]]). - Assert: O has a [[ViewedArrayBuffer]] internal slot. - Let buffer be O.[[ViewedArrayBuffer]]. + Assert: O has a [[ViewedSendableArrayBuffer]] internal slot. + Let buffer be O.[[ViewedSendableArrayBuffer]]. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js index 2a7ce5e584b..d6405aca26b 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js @@ -14,9 +14,9 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > - Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during create with custom constructor. + Throws a TypeError if _O_.[[ViewedSendableArrayBuffer]] is detached during create with custom constructor. info: | %SendableTypedArray%.prototype.slice ( start, end ) @@ -35,12 +35,12 @@ info: | The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: Perform ? RequireInternalSlot(O, [[TypedArrayName]]). - Assert: O has a [[ViewedArrayBuffer]] internal slot. - Let buffer be O.[[ViewedArrayBuffer]]. + Assert: O has a [[ViewedSendableArrayBuffer]] internal slot. + Let buffer be O.[[ViewedSendableArrayBuffer]]. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js index fb7e7ea545c..e0a92558973 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js @@ -14,9 +14,9 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > - Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during Get custom constructor. + Throws a TypeError if _O_.[[ViewedSendableArrayBuffer]] is detached during Get custom constructor. info: | %SendableTypedArray%.prototype.slice ( start, end ) @@ -35,12 +35,12 @@ info: | The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: Perform ? RequireInternalSlot(O, [[TypedArrayName]]). - Assert: O has a [[ViewedArrayBuffer]] internal slot. - Let buffer be O.[[ViewedArrayBuffer]]. + Assert: O has a [[ViewedSendableArrayBuffer]] internal slot. + Let buffer be O.[[ViewedSendableArrayBuffer]]. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js index 34ce71a9259..1da68db48da 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Throws a TypeError if buffer of object created by custom constructor is detached. info: | %SendableTypedArray%.prototype.slice ( start, end ) @@ -34,12 +34,12 @@ info: | The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: Perform ? RequireInternalSlot(O, [[TypedArrayName]]). - Assert: O has a [[ViewedArrayBuffer]] internal slot. - Let buffer be O.[[ViewedArrayBuffer]]. + Assert: O has a [[ViewedSendableArrayBuffer]] internal slot. + Let buffer be O.[[ViewedSendableArrayBuffer]]. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js index 3751aab9be0..9793843f3eb 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Does not throw a TypeError if buffer is detached on custom constructor and count <= 0. Using other targetType. @@ -26,7 +26,7 @@ info: | ... Return A -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js index f9de4335e6b..b721f9a905a 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Does not throw a TypeError if buffer is detached on custom constructor and count <= 0. Using same targetType. @@ -25,7 +25,7 @@ info: | If count > 0, then ... Return A -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer.js index a9510759ef0..0e55e240e9a 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Throws a TypeError if this has a detached buffer info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) @@ -27,7 +27,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/infinity.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/infinity.js index cac872ae421..e772572bb38 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/infinity.js @@ -14,9 +14,9 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Infinity values on start and end -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/minus-zero.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/minus-zero.js index a130569f753..4724598233c 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/minus-zero.js @@ -14,11 +14,11 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: -0 values on start and end info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js index 58a634de9cc..89a9c9be585 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js @@ -14,11 +14,11 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Result does not import own properties info: | 22.2.3.24 %SendableTypedArray%.prototype.slice( start , end ) -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-different-length.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-different-length.js index db462424802..f8422373ef1 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-different-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-different-length.js @@ -14,9 +14,9 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: slice may return a new instance with a smaller length -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js index faa55bf413d..763d5dc9483 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js @@ -14,9 +14,9 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: slice may return a new empty instance -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-same-length.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-same-length.js index d45d07523f6..40bbe839155 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-same-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-same-length.js @@ -14,9 +14,9 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: slice may return a new instance with the same length -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js index 83470ca8b34..c3e9023af08 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt from ToInteger(end), end is symbol info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) @@ -23,7 +23,7 @@ info: | 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js index 1235f39bfd7..ad88ecad3b8 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt from ToInteger(end) info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) @@ -23,7 +23,7 @@ info: | 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js index 8157a666204..a11a8eaa82f 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt from ToInteger(start), start is symbol info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) @@ -22,7 +22,7 @@ info: | ... 4. Let relativeStart be ? ToInteger(start). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js index c349bb88be7..3d4a6e9240a 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt from ToInteger(start) info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) @@ -22,7 +22,7 @@ info: | ... 4. Let relativeStart be ? ToInteger(start). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js index 70ff43eac75..9d8ab5f590f 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js index c737f8c18c5..ed9accb838f 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Perform regular set if target's uses a different element type info: | @@ -39,7 +39,7 @@ info: | v. Increase n by 1. ... 16. Return A -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-destination-resizable.js index 45b888b2221..f0d4bc303ab 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-destination-resizable.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Throws a TypeError if new typedArray's length < count info: | @@ -36,14 +36,14 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ testWithBigIntSendableTypedArrayConstructors(function(TA) { - const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); + const rab1 = new SendableArrayBuffer(8, {maxByteLength: 100}); const ta = new TA(rab1); - const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); + const rab2 = new SendableArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab2); rab2.resize(0); ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js index ef9e54dbe04..fcefb45906f 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt from SpeciesConstructor's get Constructor info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js index df610264e4b..a83263fc5b0 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: get inherited constructor on SpeciesConstructor info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js index 419ae72b070..cf7d0735ddc 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Throws if O.constructor returns a non-Object and non-undefined value info: | @@ -37,7 +37,7 @@ info: | 3. If C is undefined, return defaultConstructor. 4. If Type(C) is not Object, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js index 2f2702722c1..061205ae3ee 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: get constructor on SpeciesConstructor info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js index 39776a8b6fb..c34eb2d2880 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Returns abrupt from get @@species on found constructor info: | @@ -37,7 +37,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js index 8a6b4c7f3f1..e62b54bb45d 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Verify arguments on custom @@species construct call info: | @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index 07d903804db..303207b1463 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Throws a TypeError if new typedArray's length < count info: | @@ -36,14 +36,14 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ testWithBigIntSendableTypedArrayConstructors(function(TA) { const sample = new TA(2); - const rab = new ArrayBuffer(10, {maxByteLength: 20}); + const rab = new SendableArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab); rab.resize(0); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js index 1512fbff96d..36c0038e29e 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Throws a TypeError if new typedArray's length < count info: | @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js index 7595546ea7c..5c59e265947 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Does not throw a TypeError if new typedArray's length >= count info: | @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js index 285f36c957a..63f07f4669e 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Custom @@species constructor may return a totally different SendableTypedArray info: | @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js index 38883eb59af..09e6b0cbf22 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Custom @@species constructor throws if it does not return a compatible object info: | @@ -43,7 +43,7 @@ info: | 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js index 9e320af1e14..3bf553febfe 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Use custom @@species constructor if available info: | @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js index c9198d61ccc..20086b1812d 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Throws if returned @@species is not a constructor, null or undefined. info: | @@ -38,7 +38,7 @@ info: | 7. If IsConstructor(S) is true, return S. 8. Throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js index 1697fcfd92f..531b54eff6c 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Use defaultConstructor if @@species is either undefined or null info: | @@ -36,7 +36,7 @@ info: | 5. Let S be ? Get(C, @@species). 6. If S is either undefined or null, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js index e89ed083b6a..9e1d3faa3ea 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > get @@species from found constructor info: | @@ -37,7 +37,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-end.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-end.js index 40b4ab033c5..2fd552dcb9b 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-end.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: ToInteger(end) info: | 22.2.3.24 %SendableTypedArray%.prototype.slice( start , end ) @@ -23,7 +23,7 @@ info: | 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-start.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-start.js index 295f43b51d3..c238253a4e4 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-start.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: ToInteger(begin) info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) @@ -22,7 +22,7 @@ info: | ... 4. Let relativeStart be ? ToInteger(start). ... -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js index abe7b8fd7a0..21230225c69 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Use internal ArrayLength instead of getting a length property info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js b/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js index d2ae292822c..6b6b2eaeb8e 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Preservation of bit-level encoding info: | [...] diff --git a/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-grow.js b/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-grow.js index 5d5d3c89838..39ed0fbc209 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-grow.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > SendableTypedArray.p.slice behaves correctly on SendableTypedArrays backed by resizable buffers that is grown by argument coercion. @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // The start argument grows the resizable array buffer rab. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); @@ -46,7 +46,7 @@ for (let ctor of ctors) { // The end argument grows the resizable array buffer rab. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-shrink.js b/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-shrink.js index 33eb0745ccb..e9aa6ea492d 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-shrink.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > SendableTypedArray.p.slice behaves correctly on SendableTypedArrays backed by resizable buffers that are shrunk by argument coercion. @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // The start argument shrinks the resizable array buffer rab. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const evil = { valueOf: () => { @@ -38,7 +38,7 @@ for (let ctor of ctors) { assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); @@ -64,7 +64,7 @@ for (let ctor of ctors) { // The end argument shrinks the resizable array buffer rab. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const evil = { valueOf: () => { @@ -78,7 +78,7 @@ for (let ctor of ctors) { assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js index 684e3aff96d..6cfbc5a41b2 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js @@ -14,9 +14,9 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > - Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached. Using other + Throws a TypeError if _O_.[[ViewedSendableArrayBuffer]] is detached. Using other targetType info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) @@ -24,7 +24,7 @@ info: | ... Let A be ? SendableTypedArraySpeciesCreate(O, « count »). If count > 0, then - If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js index 6a8a090f2ee..b904bd0f484 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js @@ -14,15 +14,15 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice -description: Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached on Get custom constructor. +esid: sec-%sendableTypedArray%.prototype.slice +description: Throws a TypeError if _O_.[[ViewedSendableArrayBuffer]] is detached on Get custom constructor. info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) ... Let A be ? SendableTypedArraySpeciesCreate(O, « count »). If count > 0, then - If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js index d64bcb93e6b..ee8c04f23a6 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js @@ -14,15 +14,15 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice -description: Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached. +esid: sec-%sendableTypedArray%.prototype.slice +description: Throws a TypeError if _O_.[[ViewedSendableArrayBuffer]] is detached. info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) ... Let A be ? SendableTypedArraySpeciesCreate(O, « count »). If count > 0, then - If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js index 79198ab994b..5f597d6a1e8 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Throws a TypeError if buffer of object created by custom constructor is detached. info: | %SendableTypedArray%.prototype.slice ( start, end ) @@ -34,8 +34,8 @@ info: | The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: Perform ? RequireInternalSlot(O, [[TypedArrayName]]). - Assert: O has a [[ViewedArrayBuffer]] internal slot. - Let buffer be O.[[ViewedArrayBuffer]]. + Assert: O has a [[ViewedSendableArrayBuffer]] internal slot. + Let buffer be O.[[ViewedSendableArrayBuffer]]. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js index 95a40989a5a..bb1feea522d 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Does not throw a TypeError if buffer is detached on custom constructor and count <= 0. Using other targetType. diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js index 61c4a2ec9c2..79c211b4887 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Does not throw a TypeError if buffer is detached on custom constructor and count <= 0. Using other targetType. diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js index 98674b6c917..552b459dcaa 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Throws a TypeError if this has a detached buffer info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/infinity.js b/test/sendable/builtins/TypedArray/prototype/slice/infinity.js index c705db700a7..a1a1eda6251 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/infinity.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Infinity values on start and end includes: [testTypedArray.js, compareArray.js] features: [TypedArray] diff --git a/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-func.js index 4ad1f4c91d6..b7a2074dd6a 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Throws a TypeError exception when invoked as a function info: | 22.2.3.23 %SendableTypedArray%.prototype.slice ( start, end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-method.js index 01b94f74e4e..d96a865e6c6 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.23 %SendableTypedArray%.prototype.slice ( start, end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/length.js b/test/sendable/builtins/TypedArray/prototype/slice/length.js index d8e4fde91b3..68c2c4e4590 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > %SendableTypedArray%.prototype.slice.length is 2. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js b/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js index 378ad2c8ac6..b613d67bc96 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: -0 values on start and end info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/name.js b/test/sendable/builtins/TypedArray/prototype/slice/name.js index 24bc36183f8..88385fcfd15 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/name.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > %SendableTypedArray%.prototype.slice.name is "slice". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/slice/prop-desc.js index 1865d49df56..df0b01a332a 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > "slice" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/slice/resizable-buffer.js index 9a6287a4944..2c0618c6849 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > SendableTypedArray.p.slice behaves correctly on SendableTypedArrays backed by resizable buffers. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js b/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js index 28555608fcd..35c549167ef 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Result does not import own properties info: | 22.2.3.24 %SendableTypedArray%.prototype.slice( start , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js b/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js index 90db6ba3130..86e0461e50f 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: slice may return a new instance with a smaller length includes: [testTypedArray.js, compareArray.js] features: [TypedArray] diff --git a/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js b/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js index 240e8fa7c78..00597893ffb 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: slice may return a new empty instance includes: [testTypedArray.js] features: [TypedArray] diff --git a/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js b/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js index 8231b838195..543c19cbe4f 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: slice may return a new instance with the same length includes: [testTypedArray.js] features: [TypedArray] diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js index 22d13224b6a..79e9c95d86b 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt from ToInteger(end), end is symbol info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js index b4fb30fa11d..e610a1e2268 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt from ToInteger(end) info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js index 328b7f4099b..538d9bc222e 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt from ToInteger(start), start is symbol info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js index 7888a8250bf..4a55d6877b5 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt from ToInteger(start) info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js index 0c3255e9efb..122b7ea846c 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js b/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js index 1e6798e64b7..d0b628fca3e 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Perform regular set if target's uses a different element type info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js index 44f6ff527d4..0fd50fdbb77 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Throws a TypeError if new typedArray's length < count info: | @@ -41,9 +41,9 @@ features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ testWithSendableTypedArrayConstructors(function(TA) { - const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); + const rab1 = new SendableArrayBuffer(8, {maxByteLength: 100}); const ta = new TA(rab1); - const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); + const rab2 = new SendableArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab2); rab2.resize(0); ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js index 006e53183bd..4757c763400 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt from SpeciesConstructor's get Constructor info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js index b1730e06cc0..25b0b078af5 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: get inherited constructor on SpeciesConstructor info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js index 5c62fbaf2a6..6348efb5cff 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Throws if O.constructor returns a non-Object and non-undefined value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js index 08b21c5438d..f7e501ec029 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: get constructor on SpeciesConstructor info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js index c455e3e60c7..26e3bddadd5 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Returns abrupt from get @@species on found constructor info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js index 2e3cc5ca54a..5a979a56f7a 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Verify arguments on custom @@species construct call info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index d5faa535090..598947b7742 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Throws a TypeError if new typedArray's length < count info: | @@ -43,7 +43,7 @@ features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] testWithSendableTypedArrayConstructors(function(TA) { const sample = new TA(2); - const rab = new ArrayBuffer(10, {maxByteLength: 20}); + const rab = new SendableArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab); rab.resize(0); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js index 00e9f6dfb09..79898cc18a9 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Throws a TypeError if new typedArray's length < count info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js index 25df8c9fd0c..3e0133f01a1 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Does not throw a TypeError if new typedArray's length >= count info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js index 8c0dcdef1eb..d89d1f6c5c9 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Custom @@species constructor may return a totally different SendableTypedArray info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js index 973ac7b25a5..f092c7ae5f2 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Custom @@species constructor throws if it does not return a compatible object info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js index aeb55e59a42..29c4903c906 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Use custom @@species constructor if available info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js index 804db66711f..8b620842c8d 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Throws if returned @@species is not a constructor, null or undefined. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js index 0b0f6702fff..3dcbb181833 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Use defaultConstructor if @@species is either undefined or null info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js index 87bf3b41ee9..31acbe8d384 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > get @@species from found constructor info: | diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-resize.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-resize.js index b01dab67977..d56ca882789 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-resize.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > SendableTypedArray.p.slice behaves correctly on SendableTypedArrays backed by resizable buffers which the species constructor resizes. @@ -26,7 +26,7 @@ features: [resizable-arraybuffer] // doesn't call the species constructor if the "original array" is not an Array. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); let resizeWhenConstructorCalled = false; class MyArray extends ctor { constructor(...params) { @@ -45,7 +45,7 @@ for (let ctor of ctors) { assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const taWrite = new ctor(rab); for (let i = 0; i < 4; ++i) { taWrite[i] = MayNeedBigInt(taWrite, 1); @@ -78,7 +78,7 @@ for (let ctor of ctors) { // Test that the (start, end) parameters are computed based on the original // length. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const taWrite = new ctor(rab); for (let i = 0; i < 4; ++i) { taWrite[i] = MayNeedBigInt(taWrite, 1); @@ -108,7 +108,7 @@ for (let ctor of ctors) { // Test where the buffer gets resized "between elements". { - const rab = CreateResizableArrayBuffer(8, 16); + const rab = CreateResizableSendableArrayBuffer(8, 16); const taWrite = new Uint8Array(rab); for (let i = 0; i < 8; ++i) { taWrite[i] = MayNeedBigInt(taWrite, 255); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-object.js index 3b052658414..65a721d66b4 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js index 3f063114a09..c7b6c2c1104 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -46,12 +46,12 @@ assert.throws(TypeError, function() { slice.call([], 0, 0); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { slice.call(ab, 0, 0); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { slice.call(dv, 0, 0); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js index b141aa42287..855e75d225f 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: ToInteger(end) info: | 22.2.3.24 %SendableTypedArray%.prototype.slice( start , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js index 73ffee651e2..6898537eb7b 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.slice +esid: sec-%sendableTypedArray%.prototype.slice description: ToInteger(begin) info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js index 218fec87496..1635c76c2b2 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > thisArg does not affect callbackfn arguments info: | @@ -36,7 +36,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js index 5195972a28a..9a1cb3f0cc8 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > callbackfn arguments info: | @@ -36,7 +36,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js index f6b114e887a..36f4073bb5b 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > Instance buffer can be detached during loop info: | @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [detachArrayBuffer.js, testBigIntSendableTypedArray.js] +includes: [detachArrayBuffer.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js index 9a71c8d6908..935c283aa14 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > Does not interact over non-integer properties info: | @@ -27,7 +27,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js index 479eb2fb8bc..670d93456dd 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: Throws a TypeError if callbackfn is not callable info: | 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) @@ -29,7 +29,7 @@ info: | ... 3. If IsCallable(callbackfn) is false, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js index 4dc5747f95d..47af0c2a6ba 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > callbackfn is not called on empty instances info: | @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js index 7ed788544ed..641e2023e34 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > The callbackfn return does not change the instance info: | @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js index 729fbd92a7e..42705924b82 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: Returns abrupt from callbackfn info: | 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) @@ -33,7 +33,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js index 389919b4f57..bedb28d3356 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > Integer indexed values changed during iteration info: | @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Reflect.set, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-this.js index e01316d9e5d..4283f78a3eb 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > callbackfn `this` value info: | @@ -36,7 +36,7 @@ info: | ... ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/detached-buffer.js index 2a658d89439..162d24ea59f 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: Throws a TypeError if this has a detached buffer info: | 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js index 1f39e0cd05b..16852de601c 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: Get "length" uses internal ArrayLength info: | 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js index 893d43f0935..5765585b66a 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js index ec6e0046189..6b306ba74ae 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > Returns false if every callbackfn calls returns a coerced false. info: | @@ -29,7 +29,7 @@ info: | ... 7. Return true. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js index 91069ccfec9..1eb222db4a7 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > Returns true if any callbackfn returns a coerced true. info: | @@ -35,7 +35,7 @@ info: | ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). iii. If testResult is true, return true. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/values-are-not-cached.js index 5a20088041b..10c5551a6f4 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > Integer indexed values are not cached before iteration info: | @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js index b9060ce396a..565538ec995 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > thisArg does not affect callbackfn arguments info: | diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js index 3c708571661..a8b4bc84bf6 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > callbackfn arguments info: | diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js index d7bcee3ba24..0664e3646de 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > Instance buffer can be detached during loop info: | diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js index 364877da24f..1ce474d7768 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > Does not interact over non-integer properties info: | diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js index b64dd3225d8..c8ea61df252 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: Throws a TypeError if callbackfn is not callable info: | 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js index f85835885e7..ea3ff51ab49 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > callbackfn is not called on empty instances info: | diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js index f1ddd7b276e..a0ee8b3f0e5 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js @@ -14,21 +14,21 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: Instance buffer can be resized during iteration includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); testWithSendableTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js index 141142b5cbb..93ac61c059b 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > The callbackfn return does not change the instance info: | diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js index c211ef3eaed..c47604d9117 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: Returns abrupt from callbackfn info: | 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js index 6f1e59a64c4..5da445a7cdb 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > Integer indexed values changed during iteration info: | diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js index 17de885f0f5..097c58faf13 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > callbackfn `this` value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js index 6f43a62a3bb..e4d78d1d229 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: Throws a TypeError if this has a detached buffer info: | 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js index 2202f0bc6c1..5b9bdb84a66 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: Get "length" uses internal ArrayLength info: | 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/some/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/some/invoked-as-func.js index be49515ed67..46728b6ab14 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/some/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: Throws a TypeError exception when invoked as a function info: | 22.2.3.24 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/some/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/some/invoked-as-method.js index 3d83b55aad9..aaf4f16b78f 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/some/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.24 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/some/length.js b/test/sendable/builtins/TypedArray/prototype/some/length.js index b70fe282c73..453d4a8916e 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/length.js +++ b/test/sendable/builtins/TypedArray/prototype/some/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > %SendableTypedArray%.prototype.some.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/some/name.js b/test/sendable/builtins/TypedArray/prototype/some/name.js index dc6118f6c76..8d421b3c75f 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/name.js +++ b/test/sendable/builtins/TypedArray/prototype/some/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > %SendableTypedArray%.prototype.some.name is "some". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/some/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/some/prop-desc.js index 2b1b3b254e6..aeb75893d3f 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/some/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > "some" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-grow-mid-iteration.js index 62a3f270435..44c82f2d3f5 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > SendableTypedArray.p.some behaves correctly on SendableTypedArrays backed by resizable buffers which are grown mid-iteration. diff --git a/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-shrink-mid-iteration.js index efb2fca44a0..14325ef35a9 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > SendableTypedArray.p.some behaves correctly on SendableTypedArrays backed by resizable buffers which are shrunk mid-iteration. diff --git a/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer.js index b76a99edf4e..250d3ddf1b1 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > SendableTypedArray.p.some behaves correctly on SendableTypedArrays backed by resizable buffers. includes: [resizableArrayBufferUtils.js] @@ -22,7 +22,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js index 926ba0120b9..66ac3d571f3 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js b/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js index 87161fe6c07..a6615c913d3 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > Returns false if every callbackfn calls returns a coerced false. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js b/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js index 9f7198fa8cf..c1ffbe330de 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > Returns true if any callbackfn returns a coerced true. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/some/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/some/this-is-not-object.js index 77a59d2e42f..04e08593aca 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/some/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.25 %SendableTypedArray%.prototype.some ( callbackfn [ , thisArg ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js index 9dbef33dd7d..6c0e2285f19 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { some.call([], callbackfn); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { some.call(ab, callbackfn); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { some.call(dv, callbackfn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js index 70a196d7b98..b10ef123ba0 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.some +esid: sec-%sendableTypedArray%.prototype.some description: > Integer indexed values are not cached before iteration info: | diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js index 22f9f1a7826..a3aceae3b7e 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js @@ -14,14 +14,14 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Use internal ArrayLength instead of getting a length property info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) ... 3. Let len be the value of obj's [[ArrayLength]] internal slot. -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js index 5a3b390f91d..0ebbb007f63 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Returns abrupt from comparefn info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) @@ -34,7 +34,7 @@ info: | - If an abrupt completion is returned from any of these operations, it is immediately returned as the value of this function. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-calls.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-calls.js index bd80c9d0293..de2c12c5374 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-calls.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-calls.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: comparefn is called if not undefined info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) @@ -27,7 +27,7 @@ info: | a. Let v be ? Call(comparefn, undefined, « x, y »). ... ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js index 4fc8da18d88..73a09dab54b 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: > Treats explicit undefined comparefn the same as implicit undefined comparefn info: | @@ -22,7 +22,7 @@ info: | 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. ... -includes: [compareArray.js, testBigIntSendableTypedArray.js] +includes: [compareArray.js, testBigIntTypedArray.js] features: [TypedArray, BigInt] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js index caf16768134..389246fdc38 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: throws on a non-undefined non-function info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) @@ -27,7 +27,7 @@ info: | 1. If _comparefn_ is not *undefined* and IsCallable(_comparefn_) is *false*, throw a *TypeError* exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/detached-buffer.js index 802bc70e9ff..f2e500dee1f 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Throws a TypeError if this has a detached buffer info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) @@ -27,7 +27,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js index 9635e0cc690..e7e1fe40a58 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-same-instance.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-same-instance.js index 5fefa74b198..51debbda8b4 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-same-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-same-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Returns the same instance info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) @@ -23,7 +23,7 @@ info: | arguments x and y, the following steps are taken: ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js index a08a33d03d9..4cb902b9a5c 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: SendableTypedArrays sort does not cast values to String info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) @@ -27,7 +27,7 @@ info: | a. Let v be ? Call(comparefn, undefined, « x, y »). ... ... -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sorted-values.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sorted-values.js index 65be4f5a264..220df48a2d3 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sorted-values.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sorted-values.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Sort values to numeric ascending order info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) @@ -23,7 +23,7 @@ info: | arguments x and y, the following steps are taken: ... -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js index 5164fe6a8c2..0962f84b06a 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Use internal ArrayLength instead of getting a length property info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js index cf3a7db86ca..07ddf7c8ff3 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Returns abrupt from comparefn info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js index d6ce290f725..a583d663d01 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: comparefn is called if not undefined info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-grow.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-grow.js index b229279f360..36f61ffb308 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-grow.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: > SendableTypedArray.p.sort behaves correctly on SendableTypedArrays backed by resizable buffers which are grown by the comparison callback. @@ -45,7 +45,7 @@ function WriteUnsortedData(taFull) { // Fixed length TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const resizeTo = 6 * ctor.BYTES_PER_ELEMENT; const fixedLength = new ctor(rab, 0, 4); const taFull = new ctor(rab, 0); @@ -64,7 +64,7 @@ for (let ctor of ctors) { // Length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const resizeTo = 6 * ctor.BYTES_PER_ELEMENT; const lengthTracking = new ctor(rab, 0); const taFull = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js index b15ef97e307..aaa7af17e02 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: > Treats explicit undefined comparefn the same as implicit undefined comparefn info: | diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js index 0b9488e481a..2865251c080 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: throws on a non-undefined non-function info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-resizable-buffer.js index 97b7a2ebabc..9fc5f77352e 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: > SendableTypedArray.p.sort behaves correctly on SendableTypedArrays backed by resizable buffers and passed a user-provided comparison callback. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-shrink.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-shrink.js index 78a8e2ead80..445bf36ff52 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-shrink.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: > SendableTypedArray.p.sort behaves correctly on SendableTypedArrays backed by a resizable buffer and is shrunk by the comparison callback @@ -45,7 +45,7 @@ function WriteUnsortedData(taFull) { // Fixed length TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const resizeTo = 2 * ctor.BYTES_PER_ELEMENT; const fixedLength = new ctor(rab, 0, 4); const taFull = new ctor(rab, 0); @@ -60,7 +60,7 @@ for (let ctor of ctors) { // Length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const resizeTo = 2 * ctor.BYTES_PER_ELEMENT; const lengthTracking = new ctor(rab, 0); const taFull = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js index 3c43668fc4d..dfaeb627556 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Throws a TypeError if this has a detached buffer info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) diff --git a/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-func.js index bd84af94648..0e5c5ac8211 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Throws a TypeError exception when invoked as a function info: | 22.2.3.25 %SendableTypedArray%.prototype.sort ( comparefn ) diff --git a/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-method.js index 9fd482f30a9..823ba6ae9b2 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.25 %SendableTypedArray%.prototype.sort ( comparefn ) diff --git a/test/sendable/builtins/TypedArray/prototype/sort/length.js b/test/sendable/builtins/TypedArray/prototype/sort/length.js index 62ccc91cddf..869b7cbc29f 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/length.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: > %SendableTypedArray%.prototype.sort.length is 1. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/sort/name.js b/test/sendable/builtins/TypedArray/prototype/sort/name.js index a5dd930c9e3..f908e9d3a2b 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/name.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: > %SendableTypedArray%.prototype.sort.name is "sort". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/sort/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/sort/prop-desc.js index 76cdf0b51f3..e17c900d91a 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: > "sort" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/sort/resizable-buffer-default-comparator.js b/test/sendable/builtins/TypedArray/prototype/sort/resizable-buffer-default-comparator.js index dab973cfeaa..938b3b71db0 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/resizable-buffer-default-comparator.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/resizable-buffer-default-comparator.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: > SendableTypedArray.p.sort behaves correctly on SendableTypedArrays backed by resizable buffers. includes: [compareArray.js, resizableArrayBufferUtils.js] @@ -25,7 +25,7 @@ features: [resizable-arraybuffer] // Array.prototype.sort, since the default sorting functions differ. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js index 99738f99176..04a4ddfdd70 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js b/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js index 014b5ff8e4a..e8db33130f9 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Returns the same instance info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js b/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js index b3865e9a6db..0157658e80c 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: The result of compareFn is immediately passed through ToNumber info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js b/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js index a8497c21381..f40bcb46501 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: SendableTypedArrays sort does not cast values to String info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js index 6e3da314cc0..657c201129f 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Sort values to numeric ascending order info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js index 121ca15d111..fd2a4269e02 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Sort values to numeric ascending order info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) diff --git a/test/sendable/builtins/TypedArray/prototype/sort/stability.js b/test/sendable/builtins/TypedArray/prototype/sort/stability.js index f9dbfaed88f..5e9f9083af1 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/stability.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/stability.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Stability of %SendableTypedArray%.prototype.sort. info: | https://github.com/tc39/ecma262/pull/1433 diff --git a/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-object.js index 42e5d9b9b2f..7138e1815e0 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.26 %SendableTypedArray%.prototype.sort ( comparefn ) diff --git a/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js index 0c0dcaeeda6..66a0b24d887 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.sort +esid: sec-%sendableTypedArray%.prototype.sort description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { sort.call([], comparefn); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { sort.call(ab, comparefn); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { sort.call(dv, comparefn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/detached-buffer.js index d5d441b2b44..b0e3fea9198 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Throws a TypeError creating a new instance with a detached buffer info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) @@ -43,7 +43,7 @@ info: | ... 11. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/infinity.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/infinity.js index 95b96db44fb..cd36b1fa3d5 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/infinity.js @@ -14,11 +14,11 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Infinity values on begin and end info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/minus-zero.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/minus-zero.js index 11b4ba88bba..629c9f4f23e 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/minus-zero.js @@ -14,11 +14,11 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: -0 values on begin and end info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js index 62601427b5d..fd54157b068 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js @@ -14,14 +14,14 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Subarray result does not import own property info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) ... 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js index bc58fde3e6b..9bb0693c2d2 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js @@ -14,14 +14,14 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Returns a new instance from the same constructor info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) ... 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js index 94301173131..9c1f3588534 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js @@ -14,14 +14,14 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Returns a new instance sharing the same buffer info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) ... 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js index edd700da11a..a5ba9767f8e 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js @@ -14,14 +14,14 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Subarray may return a new instance with a smaller length info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) ... 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js index a1df6689315..7dd0cf1113a 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js @@ -14,14 +14,14 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Subarray may return a new empty instance info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) ... 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js index 7474b5d0a77..21bdd848efb 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js @@ -14,14 +14,14 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Subarray may return a new instance with the same length info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) ... 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js index 56770074da9..1fd34587646 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Return abrupt from ToInteger(begin), begin is symbol info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) @@ -22,7 +22,7 @@ info: | ... 7. Let relativeBegin be ? ToInteger(begin). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js index 776d35fd739..c808a3737a7 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Return abrupt from ToInteger(begin) info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) @@ -22,7 +22,7 @@ info: | ... 7. Let relativeBegin be ? ToInteger(begin). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js index 8df68dbf589..d46b09dbc35 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Return abrupt from ToInteger(end), end is symbol info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) @@ -23,7 +23,7 @@ info: | 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd be ? ToInteger(end). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js index 6a44999b476..050cc2f5cff 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Return abrupt from ToInteger(end) info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) @@ -23,7 +23,7 @@ info: | 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd be ? ToInteger(end). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js index 6026900a439..9a21e294467 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Return abrupt from SpeciesConstructor's get Constructor info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) @@ -34,7 +34,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js index 9026b018d29..04a523cfcdf 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: get inherited constructor on SpeciesConstructor info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) @@ -34,7 +34,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js index 6b1e5c5f4c7..cd5e08ff683 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Throws if O.constructor returns a non-Object and non-undefined value info: | @@ -36,7 +36,7 @@ info: | 3. If C is undefined, return defaultConstructor. 4. If Type(C) is not Object, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js index d1e7f8fd797..1d7ca140eb8 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: get constructor on SpeciesConstructor info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) @@ -34,7 +34,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js index ff6b7b7b965..b3b966f6855 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Returns abrupt from get @@species on found constructor info: | @@ -36,7 +36,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js index be848e33974..e7daad8b15d 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Verify arguments on custom @@species construct call info: | @@ -44,7 +44,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js index 63c9562a718..1ec60b8cbdf 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Custom @@species constructor may return a totally different SendableTypedArray info: | @@ -44,7 +44,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js index e22c76cd56c..14571786371 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Custom @@species constructor throws if it does not return a compatible object info: | @@ -42,7 +42,7 @@ info: | 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js index c356b3dadaf..b09a188b4d3 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Use custom @@species constructor if available info: | @@ -44,7 +44,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js index 5797ce67cf7..8451ded2a57 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Throws if returned @@species is not a constructor, null or undefined. info: | @@ -37,7 +37,7 @@ info: | 7. If IsConstructor(S) is true, return S. 8. Throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js index 4c42525d47f..b3c41553139 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Use defaultConstructor if @@species is either undefined or null info: | @@ -35,7 +35,7 @@ info: | 5. Let S be ? Get(C, @@species). 6. If S is either undefined or null, return defaultConstructor. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js index 2106005b8c9..859764f0321 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > get @@species from found constructor info: | @@ -36,7 +36,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js index 109f308edaf..de7ff9531b7 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: ToInteger(begin) info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) @@ -22,7 +22,7 @@ info: | ... 7. Let relativeBegin be ? ToInteger(begin). ... -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-end.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-end.js index d3edc71b7de..6be6d65bae4 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-end.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: ToInteger(end) info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) @@ -23,7 +23,7 @@ info: | 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd be ? ToInteger(end). ... -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-grow.js b/test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-grow.js index c3510b04eaf..396ed930aa6 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-grow.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > SendableTypedArray.p.subarray behaves correctly on SendableTypedArrays backed by resizable buffers that are grown by argument coercion. diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-shrink.js b/test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-shrink.js index e0674c08e16..8629081d570 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/coerced-begin-end-shrink.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > SendableTypedArray.p.subarray behaves correctly on SendableTypedArrays backed by resizable buffers that are shrunk by argument coercion. diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js index 55abecfe385..fe8128e881f 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Throws a TypeError creating a new instance with a detached buffer info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js b/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js index 8a9c56b11ea..69e4f19e658 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Infinity values on begin and end info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-func.js index c57731ba007..9ec2127de76 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Throws a TypeError exception when invoked as a function info: | 22.2.3.26 %SendableTypedArray%.prototype.subarray( [ begin [ , end ] ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-method.js index bf5fb848f16..07f064b21a8 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.26 %SendableTypedArray%.prototype.subarray( [ begin [ , end ] ] ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/length.js b/test/sendable/builtins/TypedArray/prototype/subarray/length.js index 89c5e0e299b..1a82eba3c54 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > %SendableTypedArray%.prototype.subarray.length is 2. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js b/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js index d01db124860..a3c59f2f052 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: -0 values on begin and end info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/name.js b/test/sendable/builtins/TypedArray/prototype/subarray/name.js index f57644751c9..8d2879362a9 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/name.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > %SendableTypedArray%.prototype.subarray.name is "subarray". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/subarray/prop-desc.js index 99693267287..d1853d93eea 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > "subarray" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/resizable-buffer.js index d2049de41bb..0bed1275c06 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > SendableTypedArray.p.subarray behaves correctly on SendableTypedArrays backed by resizable buffers. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js index 277d58b41a1..250bfe3e309 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Result has the correct byteOffset when input is initially out-of-bounds. info: | @@ -33,7 +33,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new ArrayBuffer(10, {maxByteLength: 10}); +let rab = new SendableArrayBuffer(10, {maxByteLength: 10}); let autoLength = new Int8Array(rab, 4); let withLength = new Int8Array(rab, 4, 2); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js index 3cf858d7c82..989a5601e95 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Subarray result does not import own property info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js index cd8fdcddcbf..54f410fb699 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Returns a new instance from the same constructor info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js index 3b0aaa33da4..2bf11b61e15 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Returns a new instance sharing the same buffer info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js index 1b4a4df0789..14a2f1135f1 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Subarray may return a new instance with a smaller length info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js index 47ef57488ec..4dce41a2d1b 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Subarray may return a new empty instance info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js index bf812a4aa1d..9e06f67be5f 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Subarray may return a new instance with the same length info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js index c32feae168b..edf2ffcf915 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Return abrupt from ToInteger(begin), begin is symbol info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js index 045b88b83cc..3854d8608d1 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Return abrupt from ToInteger(begin) info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js index d63c2c817bd..bea2c25ecf5 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Return abrupt from ToInteger(end), end is symbol info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js index 6d2d99d1882..c7e49d7aff3 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Return abrupt from ToInteger(end) info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js index d667ce49a5f..3690fb95052 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Return abrupt from SpeciesConstructor's get Constructor info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js index 1b95ab71bd9..f5368ac4fe0 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: get inherited constructor on SpeciesConstructor info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js index fba4d10d4f0..a63cc1a5e4e 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Throws if O.constructor returns a non-Object and non-undefined value info: | diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js index 6e6f4536566..5c8cb06d8fb 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: get constructor on SpeciesConstructor info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js index 6fa035a8280..52c29de4737 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Returns abrupt from get @@species on found constructor info: | diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js index 40afc297c0d..68f57d8fb10 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Verify arguments on custom @@species construct call info: | diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js index 5440156c6aa..82a65103c81 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Custom @@species constructor may return a totally different SendableTypedArray info: | diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js index ebb90ecfc69..2c9394ffedc 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Custom @@species constructor throws if it does not return a compatible object info: | diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js index 346ce571985..9081a307bf1 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Use custom @@species constructor if available info: | diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js index f3ba6d7be25..2fb4865af1b 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Throws if returned @@species is not a constructor, null or undefined. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js index af18e9052e1..eca5ac7de52 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Use defaultConstructor if @@species is either undefined or null info: | diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js index f81e7949c3c..1fb8aaccf28 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > get @@species from found constructor info: | diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-object.js index a7dfcada61a..a5592df640d 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js index 9796c8cdf48..abbfaeae49e 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -41,12 +41,12 @@ assert.throws(TypeError, function() { subarray.call([], 0, 0); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { subarray.call(ab, 0, 0); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { subarray.call(dv, 0, 0); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js index 5547d861633..9864f79c576 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: ToInteger(begin) info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js index 8cd13b3c906..ed29c8b471b 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.subarray +esid: sec-%sendableTypedArray%.prototype.subarray description: ToInteger(end) info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js index 6076bff2dff..2399a41949a 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Calls toLocaleString from each property's value info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) @@ -40,7 +40,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js index 2fac0204d46..ce5fb943bd7 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > Calls toString from each property's value return from toLocaleString info: | @@ -41,7 +41,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js index e970aa83778..fc99fa92f70 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > Calls valueOf from each property's value return from toLocaleString info: | @@ -41,7 +41,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js index 71ae9fc1ff1..467816c73c6 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Throws a TypeError if this has a detached buffer info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js index 2b27b934936..a13cafe7c4d 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Returns an empty string if called on an empty instance info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) @@ -29,7 +29,7 @@ info: | ... 4. If len is zero, return the empty String. ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js index add0c53c006..1d171eb318f 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Get "length" uses internal ArrayLength info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) @@ -29,7 +29,7 @@ info: | 1. Let array be ? ToObject(this value). 2.Let len be ? ToLength(? Get(array, "length")). ... -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js index 237117500b4..1398517debb 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Returns abrupt from firstElement's toLocaleString info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) @@ -33,7 +33,7 @@ info: | a. Let R be the empty String. 7. Else, a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js index b14ba6aa416..8b37cf6d924 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > Return abrupt from firstElement's toLocaleString => toString info: | @@ -41,7 +41,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js index 4c9f25bc10d..21b1d8d4a69 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > Return abrupt from firstElement's toLocaleString => valueOf info: | @@ -41,7 +41,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js index b82ec62b703..e7da22d9933 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Returns abrupt from a nextElement's toLocaleString info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) @@ -34,7 +34,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js index 09b473b65be..a37b1463ea3 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > Return abrupt from nextElement's toLocaleString => valueOf info: | @@ -41,7 +41,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js index 1b78858ade7..1b68ad4df81 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > Return abrupt from nextElement's toLocaleString => valueOf info: | @@ -41,7 +41,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js index 82e536c0b1d..6c11513620b 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-result.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-result.js index 15dc9992364..991f05f38a8 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-result.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-result.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Returns a string info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) @@ -40,7 +40,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js index 5a04104dbf9..a6b70a67206 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Calls toLocaleString from each property's value info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js index 1262b8c5819..297d6c742d8 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > Calls toString from each property's value return from toLocaleString info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js index 0815715a33b..01a0ba0b6c6 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > Calls valueOf from each property's value return from toLocaleString info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js index d0b8aea7834..3db574a92ee 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Throws a TypeError if this has a detached buffer info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js index d1b83d142df..772a1c07cf9 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Returns an empty string if called on an empty instance info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js index 1be6f0f04d1..25a8de57067 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Get "length" uses internal ArrayLength info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-func.js index 8b1999b2657..77eafe795c6 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Throws a TypeError exception when invoked as a function info: | 22.2.3.27 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-method.js index fab89ccafb8..b0d13a773f8 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.27 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/length.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/length.js index 457b9e2d603..61296bb94a1 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/length.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > %SendableTypedArray%.prototype.toLocaleString.length is 0. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/name.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/name.js index 6159aaf861d..fd91a2b3d0a 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/name.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > %SendableTypedArray%.prototype.toLocaleString.name is "toLocaleString". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/prop-desc.js index 04ccfea12f9..f0f90246261 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > "toLocaleString" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/resizable-buffer.js index 0a32d6ce6ef..e048ba5bd41 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > SendableTypedArray.p.toLocaleString behaves correctly on SendableTypedArrays backed by resizable buffers. @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js index 11f2f62fd5e..c23f259785c 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Returns abrupt from firstElement's toLocaleString info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js index 69ff2b4d399..0fb5cf5c9f4 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > Return abrupt from firstElement's toLocaleString => toString info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js index d85513b5447..a04453cd9bb 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > Return abrupt from firstElement's toLocaleString => valueOf info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js index dddc2eb361a..dd4211e9f6e 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Returns abrupt from a nextElement's toLocaleString info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js index 2013c59a593..e9e09c262d7 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > Return abrupt from nextElement's toLocaleString => valueOf info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js index f4c2e02deae..e757d835a5a 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > Return abrupt from nextElement's toLocaleString => valueOf info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js index d45ff8588a0..ee8777a4cbc 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js index 7f2e43cef8b..4509bc99fda 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Returns a string info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-object.js index fb435f6645f..81330634d9f 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.28 %SendableTypedArray%.prototype.toLocaleString ([ reserved1 [ , reserved2 ] ]) diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js index 2e35b82c0aa..58c43a37101 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { toLocaleString.call([]); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { toLocaleString.call(ab); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { toLocaleString.call(dv); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-grow.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-grow.js index b67c0da64ec..827c294956c 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-grow.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > SendableTypedArray.p.toLocaleString behaves correctly when {Number,BigInt}. prototype.toLocaleString is replaced with a user-provided function @@ -44,7 +44,7 @@ function listToString(list) { // Growing + fixed-length TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let resizeAfter = 2; Number.prototype.toLocaleString = function () { @@ -69,7 +69,7 @@ for (let ctor of ctors) { // Growing + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); let resizeAfter = 2; Number.prototype.toLocaleString = function () { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-shrink.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-shrink.js index 26e5bc68af4..7e90491c8b7 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-shrink.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tolocalestring +esid: sec-%sendableTypedArray%.prototype.tolocalestring description: > SendableTypedArray.p.toLocaleString behaves correctly when {Number,BigInt}. prototype.toLocaleString is replaced with a user-provided function @@ -44,7 +44,7 @@ function listToString(list) { // Shrinking + fixed-length TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let resizeAfter = 2; Number.prototype.toLocaleString = function () { @@ -69,7 +69,7 @@ for (let ctor of ctors) { // Shrinking + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); let resizeAfter = 2; Number.prototype.toLocaleString = function () { diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js b/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js index 7f65638049e..e18fc5f4353 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toReversed +esid: sec-%sendableTypedArray%.prototype.toReversed description: > %SendableTypedArray%.prototype.toReversed ignores @@species info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js b/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js index 2cfc8f48c57..626c5f7d46f 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toReversed +esid: sec-%sendableTypedArray%.prototype.toReversed description: > %SendableTypedArray%.prototype.toReversed does not mutate its this value includes: [testTypedArray.js, compareArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js b/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js index 26333f09f8b..7369e0ed73d 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toReversed +esid: sec-%sendableTypedArray%.prototype.toReversed description: > %SendableTypedArray%.prototype.toReversed does not read a "length" property info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/length.js b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/length.js index 4bd258f464c..9dff1fd3826 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/length.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toReversed +esid: sec-%sendableTypedArray%.prototype.toReversed description: > The "length" property of %SendableTypedArray%.prototype.toReversed info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/name.js b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/name.js index 45c102f8fb5..592be3bb341 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/name.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toReversed +esid: sec-%sendableTypedArray%.prototype.toReversed description: > %SendableTypedArray%.prototype.toReversed.name is "toReversed". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/property-descriptor.js b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/property-descriptor.js index 03447c38237..f2403295da7 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/property-descriptor.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/property-descriptor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toReversed +esid: sec-%sendableTypedArray%.prototype.toReversed description: > "toReversed" property of %SendableTypedArray%.prototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js b/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js index d4aacae92df..663c8a82d2e 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toReversed +esid: sec-%sendableTypedArray%.prototype.toReversed description: > %SendableTypedArray%.prototype.toReversed throws if the receiver is not a valid SendableTypedArray info: | @@ -47,7 +47,7 @@ Object.entries(invalidValues).forEach(value => { }); testWithSendableTypedArrayConstructors(function(TA) { - let buffer = new ArrayBuffer(8); + let buffer = new SendableArrayBuffer(8); let sample = new TA(buffer, 0, 1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, () => { diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js index 0bccce96cbe..aa60d304c20 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toSorted +esid: sec-%sendableTypedArray%.prototype.toSorted description: > %SendableTypedArray%.prototype.toSorted verifies that the comparator is callable before reading the length. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js index 1988d785da2..abbd5f0b953 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toSorted +esid: sec-%sendableTypedArray%.prototype.toSorted description: > %SendableTypedArray%.prototype.toSorted doesn't call copmareFn if there is an error info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js b/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js index 6a37633f949..2e9cd05ec62 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toSorted +esid: sec-%sendableTypedArray%.prototype.toSorted description: > %SendableTypedArray%.prototype.toSorted ignores @@species info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js b/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js index b8ceb45417e..f9bbc332f9b 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toSorted +esid: sec-%sendableTypedArray%.prototype.toSorted description: > %SendableTypedArray%.prototype.toSorted does not mutate its this value includes: [testTypedArray.js, compareArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js b/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js index 055821febcf..0ac1eb9423c 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toSorted +esid: sec-%sendableTypedArray%.prototype.toSorted description: > %SendableTypedArray%.prototype.toSorted does not read a "length" property info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/length.js b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/length.js index 99c0877b861..d80f4717500 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/length.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toSorted +esid: sec-%sendableTypedArray%.prototype.toSorted description: > The "length" property of %SendableTypedArray%.prototype.toSorted info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/name.js b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/name.js index ef4102fc799..0bf5a465df5 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/name.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toSorted +esid: sec-%sendableTypedArray%.prototype.toSorted description: > %SendableTypedArray%.prototype.toSorted.name is "toSorted". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/property-descriptor.js b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/property-descriptor.js index 29feb4c6235..c780901806b 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/property-descriptor.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/property-descriptor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toSorted +esid: sec-%sendableTypedArray%.prototype.toSorted description: > "toSorted" property of %SendableTypedArray%.prototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js b/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js index 0a0fdc59b62..06ead20dee4 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.toSorted +esid: sec-%sendableTypedArray%.prototype.toSorted description: > %SendableTypedArray%.prototype.toSorted throws if the receiver is not a valid SendableTypedArray info: | @@ -47,7 +47,7 @@ Object.entries(invalidValues).forEach(value => { }); testWithSendableTypedArrayConstructors(function(TA) { - let buffer = new ArrayBuffer(8); + let buffer = new SendableArrayBuffer(8); let sample = new TA(buffer, 0, 1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, () => { diff --git a/test/sendable/builtins/TypedArray/prototype/toString.js b/test/sendable/builtins/TypedArray/prototype/toString.js index 19c028a21ff..295c133f2df 100644 --- a/test/sendable/builtins/TypedArray/prototype/toString.js +++ b/test/sendable/builtins/TypedArray/prototype/toString.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tostring +esid: sec-%sendableTypedArray%.prototype.tostring description: > "toString" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/toString/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/toString/BigInt/detached-buffer.js index de9026c62a8..f714fd2ce9b 100644 --- a/test/sendable/builtins/TypedArray/prototype/toString/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/toString/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tostring +esid: sec-%sendableTypedArray%.prototype.tostring description: Throws a TypeError if this has a detached buffer info: | 22.2.3.29 %SendableTypedArray%.prototype.toString () @@ -32,7 +32,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js index 1ab0dba9867..e7f77ea6bc6 100644 --- a/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.tostring +esid: sec-%sendableTypedArray%.prototype.tostring description: Throws a TypeError if this has a detached buffer info: | 22.2.3.29 %SendableTypedArray%.prototype.toString () diff --git a/test/sendable/builtins/TypedArray/prototype/values/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/values/BigInt/detached-buffer.js index 778a953d659..656a2f42327 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/values/BigInt/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: Throws a TypeError if this has a detached buffer info: | 22.2.3.30 %SendableTypedArray%.prototype.values ( ) @@ -27,7 +27,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntSendableTypedArray.js, detachArrayBuffer.js] +includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/BigInt/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/values/BigInt/iter-prototype.js index 1be184865bf..56468c22b80 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/BigInt/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/values/BigInt/iter-prototype.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: > The prototype of the returned iterator is ArrayIteratorPrototype info: | @@ -22,7 +22,7 @@ info: | ... 3. Return CreateArrayIterator(O, "value"). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.iterator, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js index e1fbf86b7de..fc283be4416 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntSendableTypedArray.js] -features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +includes: [testBigIntTypedArray.js] +features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithBigIntSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-itor.js b/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-itor.js index 18e5bb1193c..2a28d3f8ca8 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-itor.js @@ -14,14 +14,14 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: Return an iterator for the values. info: | 22.2.3.30 %SendableTypedArray%.prototype.values ( ) ... 3. Return CreateArrayIterator(O, "value"). -includes: [testBigIntSendableTypedArray.js] +includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js index 4e74c3523a6..41ac4945b93 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: Throws a TypeError if this has a detached buffer info: | 22.2.3.30 %SendableTypedArray%.prototype.values ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/values/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/values/invoked-as-func.js index 2d6517aade7..58347c03d87 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/values/invoked-as-func.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: Throws a TypeError exception when invoked as a function info: | 22.2.3.29 %SendableTypedArray%.prototype.values ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/values/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/values/invoked-as-method.js index a46a861d403..40de76e3007 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/values/invoked-as-method.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: Requires a [[TypedArrayName]] internal slot. info: | 22.2.3.29 %SendableTypedArray%.prototype.values ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js index 30f32ba57db..9d4a9cb3939 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: > The prototype of the returned iterator is ArrayIteratorPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/values/length.js b/test/sendable/builtins/TypedArray/prototype/values/length.js index 0456ef08f1d..1db2ba2a275 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/length.js +++ b/test/sendable/builtins/TypedArray/prototype/values/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: > %SendableTypedArray%.prototype.values.length is 0. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js b/test/sendable/builtins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js index 92f28797242..b205e1bb996 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js +++ b/test/sendable/builtins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js @@ -14,13 +14,13 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: > Iterator is still exhausted when typedarray is changed to in-bounds. features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let rab = new SendableArrayBuffer(3, {maxByteLength: 5}); let ta = new Int8Array(rab); // Ensure the SendableTypedArray is correctly initialised. diff --git a/test/sendable/builtins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js b/test/sendable/builtins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js index c33082f7414..f4bcf8cbce4 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js +++ b/test/sendable/builtins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js @@ -14,13 +14,13 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: > Calling next on an out-of-bounds typedarray throws no error when iterator exhausted. features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new ArrayBuffer(3, {maxByteLength: 5}); +let rab = new SendableArrayBuffer(3, {maxByteLength: 5}); let ta = new Int8Array(rab, 1); // Ensure the SendableTypedArray is correctly initialised. diff --git a/test/sendable/builtins/TypedArray/prototype/values/name.js b/test/sendable/builtins/TypedArray/prototype/values/name.js index 2547b3e459f..b69590e5cee 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/name.js +++ b/test/sendable/builtins/TypedArray/prototype/values/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: > %SendableTypedArray%.prototype.values.name is "values". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/values/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/values/prop-desc.js index bc7074b8a0e..4817e5ec606 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/values/prop-desc.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: > "values" property of SendableTypedArrayPrototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-grow-mid-iteration.js index 502b692be44..8dea611e6c0 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-grow-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-grow-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: > SendableTypedArray.p.values behaves correctly on SendableTypedArrays backed by resizable buffers and resized mid-iteration. diff --git a/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-shrink-mid-iteration.js index a78a685f621..0dba590f0db 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-shrink-mid-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer-shrink-mid-iteration.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: > SendableTypedArray.p.values behaves correctly on SendableTypedArrays backed by resizable buffers that are shrunk mid-iteration. diff --git a/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer.js index 8f5dc0d5b11..1d5eb92ff39 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: > SendableTypedArray.p.values behaves correctly on SendableTypedArrays backed by resizable buffers. @@ -31,7 +31,7 @@ function IteratorToNumbers(iterator) { } for (let ctor of ctors) { - const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js index 092b36f7e63..45a9fdbfec1 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js @@ -14,10 +14,10 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof ArrayBuffer.prototype.resize, + typeof SendableArrayBuffer.prototype.resize, 'function', - 'implements ArrayBuffer.prototype.resize' + 'implements SendableArrayBuffer.prototype.resize' ); testWithSendableTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/values/return-itor.js b/test/sendable/builtins/TypedArray/prototype/values/return-itor.js index 2ad3eb20f42..9fe1bad05b8 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/values/return-itor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: Return an iterator for the values. info: | 22.2.3.30 %SendableTypedArray%.prototype.values ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/values/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/values/this-is-not-object.js index 56d42b8ebc0..a02bde0d02b 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/values/this-is-not-object.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: Throws a TypeError exception when `this` is not Object info: | 22.2.3.30 %SendableTypedArray%.prototype.values ( ) diff --git a/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js index 9b9247806c7..13b8bc10a64 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.values +esid: sec-%sendableTypedArray%.prototype.values description: > Throws a TypeError exception when `this` is not a SendableTypedArray instance info: | @@ -46,12 +46,12 @@ assert.throws(TypeError, function() { values.call([]); }, "this is an Array"); -var ab = new ArrayBuffer(8); +var ab = new SendableArrayBuffer(8); assert.throws(TypeError, function() { values.call(ab); -}, "this is an ArrayBuffer instance"); +}, "this is an SendableArrayBuffer instance"); -var dv = new DataView(new ArrayBuffer(8), 0, 1); +var dv = new DataView(new SendableArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { values.call(dv); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js b/test/sendable/builtins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js index 81d8c392a4a..fc079cd8c20 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js +++ b/test/sendable/builtins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.with +esid: sec-%sendableTypedArray%.prototype.with description: > %SendableTypedArray%.prototype.with invokes ToNumber before copying info: | @@ -25,7 +25,7 @@ info: | 8. Else, set _value_ to ? ToNumber(_value_). ... features: [BigInt, SendableTypedArray, change-array-by-copy] -includes: [testBigIntSendableTypedArray.js, compareArray.js] +includes: [testBigIntTypedArray.js, compareArray.js] ---*/ testWithBigIntSendableTypedArrayConstructors(function(TA) { diff --git a/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js b/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js index 9a13899400f..6597edeb6ed 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js +++ b/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.with +esid: sec-%sendableTypedArray%.prototype.with description: > %SendableTypedArray%.prototype.with invokes ToNumber before copying info: | diff --git a/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js b/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js index b8fe1569b24..c4ec8e91f89 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js +++ b/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.with +esid: sec-%sendableTypedArray%.prototype.with description: > %SendableTypedArray%.prototype.with ignores @@species info: | diff --git a/test/sendable/builtins/TypedArray/prototype/with/immutable.js b/test/sendable/builtins/TypedArray/prototype/with/immutable.js index 3672bf8559f..3a33a253417 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/immutable.js +++ b/test/sendable/builtins/TypedArray/prototype/with/immutable.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.with +esid: sec-%sendableTypedArray%.prototype.with description: > %SendableTypedArray%.prototype.with does not mutate its this value includes: [testTypedArray.js, compareArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js b/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js index f8da3926569..eacca562a98 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js +++ b/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.with +esid: sec-%sendableTypedArray%.prototype.with description: > %SendableTypedArray%.prototype.with casts the index to an integer. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-negative.js b/test/sendable/builtins/TypedArray/prototype/with/index-negative.js index af5668c0662..5cb309fb376 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/index-negative.js +++ b/test/sendable/builtins/TypedArray/prototype/with/index-negative.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.with +esid: sec-%sendableTypedArray%.prototype.with description: > %SendableTypedArray%.prototype.with adds length to index if it's negative. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js b/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js index ca56c85a4e7..703742f7b70 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js +++ b/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.with +esid: sec-%sendableTypedArray%.prototype.with description: > %SendableTypedArray%.prototype.with throws if the (negative) index is smaller than -length. info: | diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-validated-against-current-length.js b/test/sendable/builtins/TypedArray/prototype/with/index-validated-against-current-length.js index 730ade902df..521f4b082cc 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/index-validated-against-current-length.js +++ b/test/sendable/builtins/TypedArray/prototype/with/index-validated-against-current-length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.with +esid: sec-%sendableTypedArray%.prototype.with description: > The index is validated against the current length. info: | @@ -33,7 +33,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new ArrayBuffer(2, {maxByteLength: 5}); +let rab = new SendableArrayBuffer(2, {maxByteLength: 5}); let ta = new Int8Array(rab); ta[0] = 11; diff --git a/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js b/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js index 2dd5b44cbf2..e49b11421df 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js +++ b/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.with +esid: sec-%sendableTypedArray%.prototype.with description: > %SendableTypedArray%.prototype.with reads the SendableTypedArray length ignoring the .length property info: | diff --git a/test/sendable/builtins/TypedArray/prototype/with/metadata/length.js b/test/sendable/builtins/TypedArray/prototype/with/metadata/length.js index ab09ba9d50a..0d09091415e 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/metadata/length.js +++ b/test/sendable/builtins/TypedArray/prototype/with/metadata/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.with +esid: sec-%sendableTypedArray%.prototype.with description: > The "length" property of %SendableTypedArray%.prototype.with info: | diff --git a/test/sendable/builtins/TypedArray/prototype/with/metadata/name.js b/test/sendable/builtins/TypedArray/prototype/with/metadata/name.js index 5b36339f6e8..1fbd8773b13 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/metadata/name.js +++ b/test/sendable/builtins/TypedArray/prototype/with/metadata/name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.with +esid: sec-%sendableTypedArray%.prototype.with description: > %SendableTypedArray%.prototype.with.name is "with". info: | diff --git a/test/sendable/builtins/TypedArray/prototype/with/metadata/property-descriptor.js b/test/sendable/builtins/TypedArray/prototype/with/metadata/property-descriptor.js index 15cdf4da442..2d7439cbf5b 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/metadata/property-descriptor.js +++ b/test/sendable/builtins/TypedArray/prototype/with/metadata/property-descriptor.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.with +esid: sec-%sendableTypedArray%.prototype.with description: > "with" property of %SendableTypedArray%.prototype info: | diff --git a/test/sendable/builtins/TypedArray/prototype/with/this-value-invalid.js b/test/sendable/builtins/TypedArray/prototype/with/this-value-invalid.js index fa16bfa3278..3d8da3b4a9b 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/this-value-invalid.js +++ b/test/sendable/builtins/TypedArray/prototype/with/this-value-invalid.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-%typedarray%.prototype.with +esid: sec-%sendableTypedArray%.prototype.with description: > %SendableTypedArray%.prototype.with throws if the receiver is null or undefined info: | diff --git a/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-1.js b/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-1.js index 1824a1030dc..ada12424eff 100644 --- a/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-1.js +++ b/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-1.js @@ -22,7 +22,7 @@ includes: [resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableArrayBuffer(16, 40); +const rab = CreateResizableSendableArrayBuffer(16, 40); let tas = []; for (let ctor of ctors) { tas.push(new ctor(rab)); diff --git a/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-2.js b/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-2.js index 80460496fd8..cd7b7d2525b 100644 --- a/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-2.js +++ b/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-2.js @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // length-tracking-1 but with offsets. -const rab = CreateResizableArrayBuffer(16, 40); +const rab = CreateResizableSendableArrayBuffer(16, 40); const offset = 8; let tas = []; for (let ctor of ctors) { -- Gitee From c26a9228e310b2b7fb2cc8a70e2e8ac2bca34d44 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 30 Dec 2024 10:35:22 +0800 Subject: [PATCH 51/93] update typedarray test constructors ref Signed-off-by: zhuzhihui7 --- .../from/from-array-mapper-detaches-result.js | 2 +- ...array-mapper-makes-result-out-of-bounds.js | 2 +- ...rray-into-itself-mapper-detaches-result.js | 2 +- ...tself-mapper-makes-result-out-of-bounds.js | 2 +- .../from-typedarray-mapper-detaches-result.js | 2 +- ...array-mapper-makes-result-out-of-bounds.js | 2 +- test/sendable/builtins/TypedArray/invoked.js | 2 +- ...ith-out-of-bounds-and-in-bounds-indices.js | 2 +- .../out-of-bounds-behaves-like-detached.js | 2 +- .../TypedArray/out-of-bounds-get-and-set.js | 2 +- .../builtins/TypedArray/out-of-bounds-has.js | 2 +- .../BigInt/detached-buffer.js | 2 +- .../BigInt/return-typedarrayname.js | 2 +- .../this-has-no-typedarrayname-internal.js | 4 ++-- .../Symbol.toStringTag/detached-buffer.js | 2 +- .../return-typedarrayname.js | 2 +- .../this-has-no-typedarrayname-internal.js | 4 ++-- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../prototype/at/coerced-index-resize.js | 4 ++-- .../prototype/at/index-argument-tointeger.js | 2 +- ...-non-numeric-argument-tointeger-invalid.js | 2 +- .../index-non-numeric-argument-tointeger.js | 2 +- .../prototype/at/resizable-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- .../prototype/at/return-abrupt-from-this.js | 2 +- .../at/returns-item-relative-index.js | 2 +- .../TypedArray/prototype/at/returns-item.js | 2 +- ...ns-undefined-for-holes-in-sparse-arrays.js | 2 +- ...eturns-undefined-for-out-of-range-index.js | 2 +- .../buffer/BigInt/detached-buffer.js | 6 +++--- .../prototype/buffer/BigInt/return-buffer.js | 8 ++++---- .../prototype/buffer/detached-buffer.js | 6 +++--- .../prototype/buffer/invoked-as-accessor.js | 4 ++-- .../prototype/buffer/invoked-as-func.js | 2 +- .../prototype/buffer/return-buffer.js | 8 ++++---- .../this-has-no-typedarrayname-internal.js | 4 ++-- .../buffer/this-inherits-typedarray.js | 2 +- .../byteLength/BigInt/detached-buffer.js | 4 ++-- .../BigInt/resizable-array-buffer-auto.js | 12 +++++------ .../BigInt/resizable-array-buffer-fixed.js | 12 +++++------ .../byteLength/BigInt/return-bytelength.js | 2 +- .../prototype/byteLength/detached-buffer.js | 4 ++-- .../byteLength/invoked-as-accessor.js | 4 ++-- .../prototype/byteLength/invoked-as-func.js | 2 +- .../byteLength/resizable-array-buffer-auto.js | 10 +++++----- .../resizable-array-buffer-fixed.js | 10 +++++----- .../byteLength/resizable-buffer-assorted.js | 2 +- .../byteLength/resized-out-of-bounds-1.js | 2 +- .../byteLength/resized-out-of-bounds-2.js | 2 +- .../prototype/byteLength/return-bytelength.js | 2 +- .../this-has-no-typedarrayname-internal.js | 4 ++-- .../byteOffset/BigInt/detached-buffer.js | 6 +++--- .../BigInt/resizable-array-buffer-auto.js | 12 +++++------ .../BigInt/resizable-array-buffer-fixed.js | 12 +++++------ .../byteOffset/BigInt/return-byteoffset.js | 6 +++--- .../prototype/byteOffset/detached-buffer.js | 6 +++--- .../byteOffset/invoked-as-accessor.js | 4 ++-- .../prototype/byteOffset/invoked-as-func.js | 2 +- .../byteOffset/resizable-array-buffer-auto.js | 10 +++++----- .../resizable-array-buffer-fixed.js | 10 +++++----- .../byteOffset/resized-out-of-bounds.js | 2 +- .../prototype/byteOffset/return-byteoffset.js | 6 +++--- .../this-has-no-typedarrayname-internal.js | 4 ++-- .../copyWithin/BigInt/coerced-values-end.js | 2 +- .../copyWithin/BigInt/coerced-values-start.js | 2 +- .../BigInt/coerced-values-target.js | 2 +- .../copyWithin/BigInt/detached-buffer.js | 2 +- .../BigInt/get-length-ignores-length-prop.js | 2 +- .../copyWithin/BigInt/negative-end.js | 2 +- .../BigInt/negative-out-of-bounds-end.js | 2 +- .../BigInt/negative-out-of-bounds-start.js | 2 +- .../BigInt/negative-out-of-bounds-target.js | 2 +- .../copyWithin/BigInt/negative-start.js | 2 +- .../copyWithin/BigInt/negative-target.js | 2 +- .../BigInt/non-negative-out-of-bounds-end.js | 2 +- ...negative-out-of-bounds-target-and-start.js | 2 +- .../BigInt/non-negative-target-and-start.js | 2 +- .../non-negative-target-start-and-end.js | 2 +- .../return-abrupt-from-end-is-symbol.js | 2 +- .../BigInt/return-abrupt-from-end.js | 2 +- .../return-abrupt-from-start-is-symbol.js | 2 +- .../BigInt/return-abrupt-from-start.js | 2 +- .../return-abrupt-from-target-is-symbol.js | 2 +- .../BigInt/return-abrupt-from-target.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../copyWithin/BigInt/return-this.js | 2 +- .../copyWithin/BigInt/undefined-end.js | 2 +- .../prototype/copyWithin/bit-precision.js | 2 +- .../prototype/copyWithin/byteoffset.js | 2 +- .../coerced-target-start-end-shrink.js | 6 +++--- .../copyWithin/coerced-target-start-grow.js | 2 +- .../coerced-values-end-detached-prototype.js | 4 ++-- .../copyWithin/coerced-values-end-detached.js | 4 ++-- .../copyWithin/coerced-values-end.js | 2 +- .../coerced-values-start-detached.js | 4 ++-- .../copyWithin/coerced-values-start.js | 2 +- .../copyWithin/coerced-values-target.js | 2 +- .../prototype/copyWithin/detached-buffer.js | 2 +- .../get-length-ignores-length-prop.js | 2 +- .../prototype/copyWithin/negative-end.js | 2 +- .../copyWithin/negative-out-of-bounds-end.js | 2 +- .../negative-out-of-bounds-start.js | 2 +- .../negative-out-of-bounds-target.js | 2 +- .../prototype/copyWithin/negative-start.js | 2 +- .../prototype/copyWithin/negative-target.js | 2 +- .../non-negative-out-of-bounds-end.js | 2 +- ...negative-out-of-bounds-target-and-start.js | 2 +- .../non-negative-target-and-start.js | 2 +- .../non-negative-target-start-and-end.js | 2 +- .../prototype/copyWithin/resizable-buffer.js | 2 +- .../return-abrupt-from-end-is-symbol.js | 2 +- .../copyWithin/return-abrupt-from-end.js | 2 +- .../return-abrupt-from-start-is-symbol.js | 2 +- .../copyWithin/return-abrupt-from-start.js | 2 +- .../return-abrupt-from-target-is-symbol.js | 2 +- .../copyWithin/return-abrupt-from-target.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- .../prototype/copyWithin/return-this.js | 2 +- .../this-is-not-typedarray-instance.js | 6 +++--- .../prototype/copyWithin/undefined-end.js | 2 +- .../entries/BigInt/detached-buffer.js | 2 +- .../entries/BigInt/iter-prototype.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../prototype/entries/BigInt/return-itor.js | 2 +- .../prototype/entries/detached-buffer.js | 2 +- .../prototype/entries/iter-prototype.js | 2 +- .../prototype/entries/resizable-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- .../prototype/entries/return-itor.js | 2 +- .../this-is-not-typedarray-instance.js | 6 +++--- .../callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../every/BigInt/callbackfn-detachbuffer.js | 2 +- ...lbackfn-no-interaction-over-non-integer.js | 2 +- .../BigInt/callbackfn-not-callable-throws.js | 2 +- .../BigInt/callbackfn-not-called-on-empty.js | 2 +- ...lbackfn-return-does-not-change-instance.js | 2 +- .../every/BigInt/callbackfn-returns-abrupt.js | 2 +- ...callbackfn-set-value-during-interaction.js | 2 +- .../prototype/every/BigInt/callbackfn-this.js | 2 +- .../prototype/every/BigInt/detached-buffer.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../returns-false-if-any-cb-returns-false.js | 2 +- .../returns-true-if-every-cb-returns-true.js | 2 +- .../every/BigInt/values-are-not-cached.js | 2 +- .../callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../every/callbackfn-detachbuffer.js | 2 +- ...lbackfn-no-interaction-over-non-integer.js | 2 +- .../every/callbackfn-not-callable-throws.js | 2 +- .../every/callbackfn-not-called-on-empty.js | 2 +- .../prototype/every/callbackfn-resize.js | 8 ++++---- ...lbackfn-return-does-not-change-instance.js | 2 +- .../every/callbackfn-returns-abrupt.js | 2 +- ...callbackfn-set-value-during-interaction.js | 2 +- .../prototype/every/callbackfn-this.js | 2 +- .../prototype/every/detached-buffer.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../prototype/every/resizable-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- .../returns-false-if-any-cb-returns-false.js | 2 +- .../returns-true-if-every-cb-returns-true.js | 2 +- .../every/this-is-not-typedarray-instance.js | 6 +++--- .../prototype/every/values-are-not-cached.js | 2 +- .../prototype/fill/BigInt/coerced-indexes.js | 2 +- .../prototype/fill/BigInt/detached-buffer.js | 2 +- .../BigInt/fill-values-conversion-once.js | 2 +- .../fill-values-custom-start-and-end.js | 2 +- .../BigInt/fill-values-non-numeric-throw.js | 6 +++--- .../fill/BigInt/fill-values-non-numeric.js | 6 +++--- .../fill/BigInt/fill-values-relative-end.js | 2 +- .../fill/BigInt/fill-values-relative-start.js | 2 +- .../fill/BigInt/fill-values-symbol-throws.js | 6 +++--- .../prototype/fill/BigInt/fill-values.js | 2 +- .../BigInt/get-length-ignores-length-prop.js | 2 +- .../return-abrupt-from-end-as-symbol.js | 2 +- .../fill/BigInt/return-abrupt-from-end.js | 2 +- .../BigInt/return-abrupt-from-set-value.js | 6 +++--- .../return-abrupt-from-start-as-symbol.js | 2 +- .../fill/BigInt/return-abrupt-from-start.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../prototype/fill/BigInt/return-this.js | 2 +- ...nt-indices-computed-from-initial-length.js | 2 +- .../prototype/fill/coerced-end-detach.js | 4 ++-- .../prototype/fill/coerced-indexes.js | 2 +- .../prototype/fill/coerced-start-detach.js | 4 ++-- .../prototype/fill/coerced-value-detach.js | 4 ++-- .../fill/coerced-value-start-end-resize.js | 6 +++--- .../prototype/fill/detached-buffer.js | 2 +- .../fill/fill-values-conversion-once.js | 2 +- ...es-conversion-operations-consistent-nan.js | 2 +- .../fill/fill-values-custom-start-and-end.js | 2 +- .../prototype/fill/fill-values-non-numeric.js | 6 +++--- .../fill/fill-values-relative-end.js | 2 +- .../fill/fill-values-relative-start.js | 2 +- .../fill/fill-values-symbol-throws.js | 6 +++--- .../TypedArray/prototype/fill/fill-values.js | 2 +- .../fill/get-length-ignores-length-prop.js | 2 +- .../prototype/fill/resizable-buffer.js | 2 +- .../fill/return-abrupt-from-end-as-symbol.js | 2 +- .../prototype/fill/return-abrupt-from-end.js | 2 +- .../fill/return-abrupt-from-set-value.js | 6 +++--- .../return-abrupt-from-start-as-symbol.js | 2 +- .../fill/return-abrupt-from-start.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- .../TypedArray/prototype/fill/return-this.js | 2 +- .../fill/this-is-not-typedarray-instance.js | 6 +++--- .../filter/BigInt/arraylength-internal.js | 2 +- .../callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../BigInt/callbackfn-called-before-ctor.js | 2 +- .../callbackfn-called-before-species.js | 2 +- .../filter/BigInt/callbackfn-detachbuffer.js | 2 +- ...allbackfn-no-iteration-over-non-integer.js | 2 +- .../BigInt/callbackfn-not-callable-throws.js | 2 +- .../BigInt/callbackfn-not-called-on-empty.js | 2 +- ...lbackfn-return-does-not-change-instance.js | 2 +- .../BigInt/callbackfn-returns-abrupt.js | 2 +- .../callbackfn-set-value-during-iteration.js | 2 +- .../filter/BigInt/callbackfn-this.js | 2 +- .../filter/BigInt/detached-buffer.js | 2 +- .../BigInt/result-does-not-share-buffer.js | 2 +- .../result-empty-callbackfn-returns-false.js | 2 +- .../result-full-callbackfn-returns-true.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../speciesctor-destination-resizable.js | 6 +++--- .../BigInt/speciesctor-get-ctor-abrupt.js | 2 +- .../BigInt/speciesctor-get-ctor-inherited.js | 2 +- .../speciesctor-get-ctor-returns-throws.js | 2 +- .../filter/BigInt/speciesctor-get-ctor.js | 2 +- .../BigInt/speciesctor-get-species-abrupt.js | 2 +- ...ctor-get-species-custom-ctor-invocation.js | 2 +- ...tor-length-throws-resizable-arraybuffer.js | 4 ++-- ...r-get-species-custom-ctor-length-throws.js | 2 +- ...ciesctor-get-species-custom-ctor-length.js | 2 +- ...es-custom-ctor-returns-another-instance.js | 2 +- ...ciesctor-get-species-custom-ctor-throws.js | 2 +- .../speciesctor-get-species-custom-ctor.js | 2 +- .../speciesctor-get-species-returns-throws.js | 2 +- ...peciesctor-get-species-use-default-ctor.js | 2 +- .../filter/BigInt/speciesctor-get-species.js | 2 +- .../filter/BigInt/values-are-not-cached.js | 2 +- .../prototype/filter/BigInt/values-are-set.js | 2 +- .../prototype/filter/arraylength-internal.js | 2 +- .../callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../filter/callbackfn-called-before-ctor.js | 2 +- .../callbackfn-called-before-species.js | 2 +- .../filter/callbackfn-detachbuffer.js | 2 +- ...allbackfn-no-iteration-over-non-integer.js | 2 +- .../filter/callbackfn-not-callable-throws.js | 2 +- .../filter/callbackfn-not-called-on-empty.js | 2 +- .../prototype/filter/callbackfn-resize.js | 8 ++++---- ...lbackfn-return-does-not-change-instance.js | 2 +- .../filter/callbackfn-returns-abrupt.js | 2 +- .../callbackfn-set-value-during-iteration.js | 2 +- .../prototype/filter/callbackfn-this.js | 2 +- .../prototype/filter/detached-buffer.js | 2 +- .../prototype/filter/resizable-buffer.js | 2 +- .../filter/result-does-not-share-buffer.js | 2 +- .../result-empty-callbackfn-returns-false.js | 2 +- .../result-full-callbackfn-returns-true.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- .../speciesctor-destination-resizable.js | 6 +++--- .../filter/speciesctor-get-ctor-abrupt.js | 2 +- .../filter/speciesctor-get-ctor-inherited.js | 2 +- .../speciesctor-get-ctor-returns-throws.js | 2 +- .../prototype/filter/speciesctor-get-ctor.js | 2 +- .../filter/speciesctor-get-species-abrupt.js | 2 +- ...ctor-get-species-custom-ctor-invocation.js | 2 +- ...tor-length-throws-resizable-arraybuffer.js | 4 ++-- ...r-get-species-custom-ctor-length-throws.js | 2 +- ...ciesctor-get-species-custom-ctor-length.js | 2 +- ...es-custom-ctor-returns-another-instance.js | 2 +- ...ciesctor-get-species-custom-ctor-throws.js | 2 +- .../speciesctor-get-species-custom-ctor.js | 2 +- .../speciesctor-get-species-returns-throws.js | 2 +- ...peciesctor-get-species-use-default-ctor.js | 2 +- .../filter/speciesctor-get-species.js | 2 +- .../filter/this-is-not-typedarray-instance.js | 6 +++--- .../prototype/filter/values-are-not-cached.js | 2 +- .../prototype/filter/values-are-set.js | 2 +- .../prototype/find/BigInt/detached-buffer.js | 2 +- .../BigInt/get-length-ignores-length-prop.js | 2 +- .../BigInt/predicate-call-changes-value.js | 2 +- .../find/BigInt/predicate-call-parameters.js | 2 +- .../BigInt/predicate-call-this-non-strict.js | 2 +- .../find/BigInt/predicate-call-this-strict.js | 2 +- .../predicate-is-not-callable-throws.js | 2 +- .../BigInt/predicate-may-detach-buffer.js | 4 ++-- .../predicate-not-called-on-empty-array.js | 2 +- .../return-abrupt-from-predicate-call.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- ...rn-found-value-predicate-result-is-true.js | 2 +- ...efined-if-predicate-returns-false-value.js | 2 +- .../prototype/find/callbackfn-resize.js | 8 ++++---- .../prototype/find/detached-buffer.js | 2 +- .../find/get-length-ignores-length-prop.js | 2 +- .../find/predicate-call-changes-value.js | 2 +- .../find/predicate-call-parameters.js | 2 +- .../find/predicate-call-this-non-strict.js | 2 +- .../find/predicate-call-this-strict.js | 2 +- .../find/predicate-is-not-callable-throws.js | 2 +- .../find/predicate-may-detach-buffer.js | 4 ++-- .../predicate-not-called-on-empty-array.js | 2 +- .../prototype/find/resizable-buffer.js | 2 +- .../find/return-abrupt-from-predicate-call.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- ...rn-found-value-predicate-result-is-true.js | 2 +- ...efined-if-predicate-returns-false-value.js | 2 +- .../find/this-is-not-typedarray-instance.js | 6 +++--- .../findIndex/BigInt/detached-buffer.js | 2 +- .../BigInt/get-length-ignores-length-prop.js | 2 +- .../BigInt/predicate-call-changes-value.js | 2 +- .../BigInt/predicate-call-parameters.js | 2 +- .../BigInt/predicate-call-this-non-strict.js | 2 +- .../BigInt/predicate-call-this-strict.js | 2 +- .../predicate-is-not-callable-throws.js | 2 +- .../BigInt/predicate-may-detach-buffer.js | 4 ++-- .../predicate-not-called-on-empty-array.js | 2 +- .../return-abrupt-from-predicate-call.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../return-index-predicate-result-is-true.js | 2 +- ...ve-one-if-predicate-returns-false-value.js | 2 +- .../prototype/findIndex/callbackfn-resize.js | 8 ++++---- .../prototype/findIndex/detached-buffer.js | 2 +- .../get-length-ignores-length-prop.js | 2 +- .../findIndex/predicate-call-changes-value.js | 2 +- .../findIndex/predicate-call-parameters.js | 2 +- .../predicate-call-this-non-strict.js | 2 +- .../findIndex/predicate-call-this-strict.js | 2 +- .../predicate-is-not-callable-throws.js | 2 +- .../findIndex/predicate-may-detach-buffer.js | 4 ++-- .../predicate-not-called-on-empty-array.js | 2 +- .../prototype/findIndex/resizable-buffer.js | 2 +- .../return-abrupt-from-predicate-call.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- .../return-index-predicate-result-is-true.js | 2 +- ...ve-one-if-predicate-returns-false-value.js | 2 +- .../this-is-not-typedarray-instance.js | 6 +++--- .../findLast/BigInt/detached-buffer.js | 2 +- .../BigInt/get-length-ignores-length-prop.js | 2 +- .../BigInt/predicate-call-changes-value.js | 2 +- .../BigInt/predicate-call-parameters.js | 2 +- .../BigInt/predicate-call-this-non-strict.js | 2 +- .../BigInt/predicate-call-this-strict.js | 2 +- .../predicate-is-not-callable-throws.js | 2 +- .../BigInt/predicate-may-detach-buffer.js | 4 ++-- .../predicate-not-called-on-empty-array.js | 2 +- .../return-abrupt-from-predicate-call.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- ...rn-found-value-predicate-result-is-true.js | 2 +- ...efined-if-predicate-returns-false-value.js | 2 +- .../prototype/findLast/callbackfn-resize.js | 8 ++++---- .../prototype/findLast/detached-buffer.js | 2 +- .../get-length-ignores-length-prop.js | 2 +- .../findLast/predicate-call-changes-value.js | 2 +- .../findLast/predicate-call-parameters.js | 2 +- .../predicate-call-this-non-strict.js | 2 +- .../findLast/predicate-call-this-strict.js | 2 +- .../predicate-is-not-callable-throws.js | 2 +- .../findLast/predicate-may-detach-buffer.js | 4 ++-- .../predicate-not-called-on-empty-array.js | 2 +- .../prototype/findLast/resizable-buffer.js | 2 +- .../return-abrupt-from-predicate-call.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- ...rn-found-value-predicate-result-is-true.js | 2 +- ...efined-if-predicate-returns-false-value.js | 2 +- .../this-is-not-typedarray-instance.js | 6 +++--- .../findLastIndex/BigInt/detached-buffer.js | 2 +- .../BigInt/get-length-ignores-length-prop.js | 2 +- .../BigInt/predicate-call-changes-value.js | 2 +- .../BigInt/predicate-call-parameters.js | 2 +- .../BigInt/predicate-call-this-non-strict.js | 2 +- .../BigInt/predicate-call-this-strict.js | 2 +- .../predicate-is-not-callable-throws.js | 2 +- .../BigInt/predicate-may-detach-buffer.js | 4 ++-- .../predicate-not-called-on-empty-array.js | 2 +- .../return-abrupt-from-predicate-call.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../return-index-predicate-result-is-true.js | 2 +- ...ve-one-if-predicate-returns-false-value.js | 2 +- .../findLastIndex/callbackfn-resize.js | 8 ++++---- .../findLastIndex/detached-buffer.js | 2 +- .../get-length-ignores-length-prop.js | 2 +- .../predicate-call-changes-value.js | 2 +- .../predicate-call-parameters.js | 2 +- .../predicate-call-this-non-strict.js | 2 +- .../predicate-call-this-strict.js | 2 +- .../predicate-is-not-callable-throws.js | 2 +- .../predicate-may-detach-buffer.js | 4 ++-- .../predicate-not-called-on-empty-array.js | 2 +- .../findLastIndex/resizable-buffer.js | 2 +- .../return-abrupt-from-predicate-call.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- .../return-index-predicate-result-is-true.js | 2 +- ...ve-one-if-predicate-returns-false-value.js | 2 +- .../this-is-not-typedarray-instance.js | 6 +++--- .../forEach/BigInt/arraylength-internal.js | 2 +- .../callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../forEach/BigInt/callbackfn-detachbuffer.js | 2 +- .../BigInt/callbackfn-is-not-callable.js | 2 +- ...lbackfn-no-interaction-over-non-integer.js | 2 +- .../BigInt/callbackfn-not-called-on-empty.js | 2 +- ...lbackfn-return-does-not-change-instance.js | 2 +- .../BigInt/callbackfn-returns-abrupt.js | 2 +- ...callbackfn-set-value-during-interaction.js | 2 +- .../forEach/BigInt/callbackfn-this.js | 2 +- .../forEach/BigInt/detached-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../forEach/BigInt/returns-undefined.js | 2 +- .../forEach/BigInt/values-are-not-cached.js | 2 +- .../prototype/forEach/arraylength-internal.js | 2 +- .../callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../forEach/callbackfn-detachbuffer.js | 2 +- .../forEach/callbackfn-is-not-callable.js | 2 +- ...lbackfn-no-interaction-over-non-integer.js | 2 +- .../forEach/callbackfn-not-called-on-empty.js | 2 +- .../prototype/forEach/callbackfn-resize.js | 8 ++++---- ...lbackfn-return-does-not-change-instance.js | 2 +- .../forEach/callbackfn-returns-abrupt.js | 2 +- ...callbackfn-set-value-during-interaction.js | 2 +- .../prototype/forEach/callbackfn-this.js | 2 +- .../prototype/forEach/detached-buffer.js | 2 +- .../prototype/forEach/resizable-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- .../prototype/forEach/returns-undefined.js | 2 +- .../this-is-not-typedarray-instance.js | 6 +++--- .../forEach/values-are-not-cached.js | 2 +- ...during-fromIndex-returns-false-for-zero.js | 2 +- ...ng-fromIndex-returns-true-for-undefined.js | 2 +- .../includes/BigInt/detached-buffer.js | 2 +- ...x-equal-or-greater-length-returns-false.js | 2 +- .../includes/BigInt/fromIndex-infinity.js | 2 +- .../includes/BigInt/fromIndex-minus-zero.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../BigInt/length-zero-returns-false.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- ...eturn-abrupt-tointeger-fromindex-symbol.js | 2 +- .../return-abrupt-tointeger-fromindex.js | 2 +- .../BigInt/search-found-returns-true.js | 2 +- .../BigInt/search-not-found-returns-false.js | 2 +- .../includes/BigInt/tointeger-fromindex.js | 2 +- .../coerced-searchelement-fromindex-resize.js | 10 +++++----- ...during-fromIndex-returns-false-for-zero.js | 2 +- ...ng-fromIndex-returns-true-for-undefined.js | 2 +- .../prototype/includes/detached-buffer.js | 2 +- ...x-equal-or-greater-length-returns-false.js | 2 +- .../prototype/includes/fromIndex-infinity.js | 2 +- .../includes/fromIndex-minus-zero.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- ...ed-against-initial-length-out-of-bounds.js | 2 +- .../index-compared-against-initial-length.js | 2 +- .../includes/length-zero-returns-false.js | 2 +- .../resizable-buffer-special-float-values.js | 2 +- .../prototype/includes/resizable-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- ...eturn-abrupt-tointeger-fromindex-symbol.js | 2 +- .../return-abrupt-tointeger-fromindex.js | 2 +- .../prototype/includes/samevaluezero.js | 4 ++-- .../includes/search-found-returns-true.js | 2 +- .../search-not-found-returns-false.js | 2 +- .../includes/searchelement-not-integer.js | 2 +- .../this-is-not-typedarray-instance.js | 6 +++--- .../prototype/includes/tointeger-fromindex.js | 2 +- ...omIndex-returns-minus-one-for-undefined.js | 2 +- ...ng-fromIndex-returns-minus-one-for-zero.js | 2 +- .../indexOf/BigInt/detached-buffer.js | 2 +- ...ual-or-greater-length-returns-minus-one.js | 2 +- .../indexOf/BigInt/fromIndex-infinity.js | 2 +- .../indexOf/BigInt/fromIndex-minus-zero.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../BigInt/length-zero-returns-minus-one.js | 2 +- .../prototype/indexOf/BigInt/no-arg.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- ...eturn-abrupt-tointeger-fromindex-symbol.js | 2 +- .../return-abrupt-tointeger-fromindex.js | 2 +- .../BigInt/search-found-returns-index.js | 2 +- .../search-not-found-returns-minus-one.js | 2 +- .../indexOf/BigInt/tointeger-fromindex.js | 2 +- .../coerced-searchelement-fromindex-grow.js | 4 ++-- .../coerced-searchelement-fromindex-shrink.js | 6 +++--- ...omIndex-returns-minus-one-for-undefined.js | 2 +- ...ng-fromIndex-returns-minus-one-for-zero.js | 2 +- .../prototype/indexOf/detached-buffer.js | 2 +- ...ual-or-greater-length-returns-minus-one.js | 2 +- .../prototype/indexOf/fromIndex-infinity.js | 2 +- .../prototype/indexOf/fromIndex-minus-zero.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../indexOf/length-zero-returns-minus-one.js | 2 +- .../TypedArray/prototype/indexOf/no-arg.js | 2 +- .../resizable-buffer-special-float-values.js | 2 +- .../prototype/indexOf/resizable-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- ...eturn-abrupt-tointeger-fromindex-symbol.js | 2 +- .../return-abrupt-tointeger-fromindex.js | 2 +- .../indexOf/search-found-returns-index.js | 2 +- .../search-not-found-returns-minus-one.js | 2 +- .../prototype/indexOf/strict-comparison.js | 2 +- .../this-is-not-typedarray-instance.js | 6 +++--- .../prototype/indexOf/tointeger-fromindex.js | 2 +- ...sult-from-tostring-on-each-simple-value.js | 2 +- ...r-during-fromIndex-returns-single-comma.js | 2 +- .../prototype/join/BigInt/detached-buffer.js | 2 +- .../BigInt/empty-instance-empty-string.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- ...sult-from-tostring-on-each-simple-value.js | 2 +- .../return-abrupt-from-separator-symbol.js | 2 +- .../BigInt/return-abrupt-from-separator.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../prototype/join/coerced-separator-grow.js | 4 ++-- .../join/coerced-separator-shrink.js | 4 ++-- ...sult-from-tostring-on-each-simple-value.js | 2 +- ...ator-result-from-tostring-on-each-value.js | 2 +- ...r-during-fromIndex-returns-single-comma.js | 2 +- .../prototype/join/detached-buffer.js | 2 +- .../join/empty-instance-empty-string.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../prototype/join/resizable-buffer.js | 2 +- ...sult-from-tostring-on-each-simple-value.js | 2 +- .../result-from-tostring-on-each-value.js | 2 +- .../return-abrupt-from-separator-symbol.js | 2 +- .../join/return-abrupt-from-separator.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- .../separator-tostring-once-after-resized.js | 2 +- .../join/this-is-not-typedarray-instance.js | 6 +++--- .../prototype/keys/BigInt/detached-buffer.js | 2 +- .../prototype/keys/BigInt/iter-prototype.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../prototype/keys/BigInt/return-itor.js | 2 +- .../prototype/keys/detached-buffer.js | 2 +- .../prototype/keys/iter-prototype.js | 2 +- .../prototype/keys/resizable-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- .../TypedArray/prototype/keys/return-itor.js | 2 +- .../keys/this-is-not-typedarray-instance.js | 6 +++--- ...omIndex-returns-minus-one-for-undefined.js | 2 +- ...ng-fromIndex-returns-minus-one-for-zero.js | 2 +- .../lastIndexOf/BigInt/detached-buffer.js | 2 +- .../lastIndexOf/BigInt/fromIndex-infinity.js | 2 +- .../BigInt/fromIndex-minus-zero.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../BigInt/length-zero-returns-minus-one.js | 2 +- .../prototype/lastIndexOf/BigInt/no-arg.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- ...eturn-abrupt-tointeger-fromindex-symbol.js | 2 +- .../return-abrupt-tointeger-fromindex.js | 2 +- .../BigInt/search-found-returns-index.js | 2 +- .../search-not-found-returns-minus-one.js | 2 +- .../lastIndexOf/BigInt/tointeger-fromindex.js | 2 +- .../lastIndexOf/coerced-position-grow.js | 4 ++-- .../lastIndexOf/coerced-position-shrink.js | 6 +++--- ...omIndex-returns-minus-one-for-undefined.js | 2 +- ...ng-fromIndex-returns-minus-one-for-zero.js | 2 +- .../prototype/lastIndexOf/detached-buffer.js | 2 +- .../lastIndexOf/fromIndex-infinity.js | 2 +- .../lastIndexOf/fromIndex-minus-zero.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../length-zero-returns-minus-one.js | 2 +- .../prototype/lastIndexOf/no-arg.js | 2 +- .../resizable-buffer-special-float-values.js | 2 +- .../prototype/lastIndexOf/resizable-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- ...eturn-abrupt-tointeger-fromindex-symbol.js | 2 +- .../return-abrupt-tointeger-fromindex.js | 2 +- .../lastIndexOf/search-found-returns-index.js | 2 +- .../search-not-found-returns-minus-one.js | 2 +- .../lastIndexOf/strict-comparison.js | 2 +- .../this-is-not-typedarray-instance.js | 6 +++--- .../lastIndexOf/tointeger-fromindex.js | 2 +- .../length/BigInt/detached-buffer.js | 4 ++-- .../BigInt/resizable-array-buffer-auto.js | 12 +++++------ .../BigInt/resizable-array-buffer-fixed.js | 12 +++++------ .../prototype/length/BigInt/return-length.js | 2 +- .../prototype/length/detached-buffer.js | 4 ++-- .../prototype/length/invoked-as-accessor.js | 2 +- .../length/resizable-array-buffer-auto.js | 10 +++++----- .../length/resizable-array-buffer-fixed.js | 10 +++++----- .../length/resizable-buffer-assorted.js | 2 +- .../length/resized-out-of-bounds-1.js | 2 +- .../length/resized-out-of-bounds-2.js | 2 +- .../prototype/length/return-length.js | 2 +- .../this-has-no-typedarrayname-internal.js | 4 ++-- .../map/BigInt/arraylength-internal.js | 2 +- .../callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../map/BigInt/callbackfn-detachbuffer.js | 2 +- .../map/BigInt/callbackfn-is-not-callable.js | 2 +- ...interaction-over-non-integer-properties.js | 2 +- .../BigInt/callbackfn-not-called-on-empty.js | 2 +- ...llbackfn-return-affects-returned-object.js | 2 +- ...lbackfn-return-does-not-change-instance.js | 2 +- ...rn-does-not-copy-non-integer-properties.js | 2 +- .../map/BigInt/callbackfn-returns-abrupt.js | 2 +- ...callbackfn-set-value-during-interaction.js | 2 +- .../prototype/map/BigInt/callbackfn-this.js | 2 +- .../prototype/map/BigInt/detached-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- ...return-new-typedarray-from-empty-length.js | 2 +- ...urn-new-typedarray-from-positive-length.js | 2 +- .../speciesctor-destination-resizable.js | 6 +++--- .../map/BigInt/speciesctor-get-ctor-abrupt.js | 2 +- .../BigInt/speciesctor-get-ctor-inherited.js | 2 +- .../speciesctor-get-ctor-returns-throws.js | 2 +- .../map/BigInt/speciesctor-get-ctor.js | 2 +- .../BigInt/speciesctor-get-species-abrupt.js | 2 +- ...ctor-get-species-custom-ctor-invocation.js | 2 +- ...tor-length-throws-resizable-arraybuffer.js | 4 ++-- ...r-get-species-custom-ctor-length-throws.js | 2 +- ...ciesctor-get-species-custom-ctor-length.js | 2 +- ...es-custom-ctor-returns-another-instance.js | 2 +- ...ciesctor-get-species-custom-ctor-throws.js | 2 +- .../speciesctor-get-species-custom-ctor.js | 2 +- .../speciesctor-get-species-returns-throws.js | 2 +- ...peciesctor-get-species-use-default-ctor.js | 2 +- .../map/BigInt/speciesctor-get-species.js | 2 +- .../map/BigInt/values-are-not-cached.js | 2 +- .../prototype/map/arraylength-internal.js | 2 +- .../map/callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../prototype/map/callbackfn-detachbuffer.js | 2 +- .../map/callbackfn-is-not-callable.js | 2 +- ...interaction-over-non-integer-properties.js | 2 +- .../map/callbackfn-not-called-on-empty.js | 2 +- .../prototype/map/callbackfn-resize.js | 8 ++++---- ...llbackfn-return-affects-returned-object.js | 2 +- ...lbackfn-return-does-not-change-instance.js | 2 +- ...rn-does-not-copy-non-integer-properties.js | 2 +- .../map/callbackfn-returns-abrupt.js | 2 +- ...callbackfn-set-value-during-interaction.js | 2 +- .../prototype/map/callbackfn-this.js | 2 +- .../prototype/map/detached-buffer.js | 2 +- .../prototype/map/resizable-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- ...ray-conversion-operation-consistent-nan.js | 4 ++-- ...urn-new-typedarray-conversion-operation.js | 2 +- ...return-new-typedarray-from-empty-length.js | 2 +- ...urn-new-typedarray-from-positive-length.js | 2 +- .../map/speciesctor-destination-resizable.js | 6 +++--- .../map/speciesctor-get-ctor-abrupt.js | 2 +- .../map/speciesctor-get-ctor-inherited.js | 2 +- .../speciesctor-get-ctor-returns-throws.js | 2 +- .../prototype/map/speciesctor-get-ctor.js | 2 +- .../map/speciesctor-get-species-abrupt.js | 2 +- ...ctor-get-species-custom-ctor-invocation.js | 2 +- ...tor-length-throws-resizable-arraybuffer.js | 4 ++-- ...r-get-species-custom-ctor-length-throws.js | 2 +- ...ciesctor-get-species-custom-ctor-length.js | 2 +- ...es-custom-ctor-returns-another-instance.js | 2 +- ...ciesctor-get-species-custom-ctor-throws.js | 2 +- .../speciesctor-get-species-custom-ctor.js | 2 +- .../speciesctor-get-species-returns-throws.js | 2 +- ...peciesctor-get-species-use-default-ctor.js | 2 +- .../prototype/map/speciesctor-get-species.js | 2 +- .../map/speciesctor-resizable-buffer-grow.js | 4 ++-- .../speciesctor-resizable-buffer-shrink.js | 4 ++-- .../map/this-is-not-typedarray-instance.js | 6 +++--- .../prototype/map/values-are-not-cached.js | 2 +- ...callbackfn-arguments-custom-accumulator.js | 2 +- ...allbackfn-arguments-default-accumulator.js | 2 +- .../reduce/BigInt/callbackfn-detachbuffer.js | 2 +- .../callbackfn-is-not-callable-throws.js | 2 +- ...o-iteration-over-non-integer-properties.js | 2 +- .../BigInt/callbackfn-not-called-on-empty.js | 2 +- ...lbackfn-return-does-not-change-instance.js | 2 +- .../BigInt/callbackfn-returns-abrupt.js | 2 +- .../callbackfn-set-value-during-iteration.js | 2 +- .../reduce/BigInt/callbackfn-this.js | 2 +- .../reduce/BigInt/detached-buffer.js | 2 +- .../empty-instance-return-initialvalue.js | 2 +- ...ty-instance-with-no-initialvalue-throws.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../result-is-last-callbackfn-return.js | 2 +- .../reduce/BigInt/result-of-any-type.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../return-first-value-without-callbackfn.js | 2 +- .../reduce/BigInt/values-are-not-cached.js | 2 +- ...callbackfn-arguments-custom-accumulator.js | 2 +- ...allbackfn-arguments-default-accumulator.js | 2 +- .../reduce/callbackfn-detachbuffer.js | 2 +- .../callbackfn-is-not-callable-throws.js | 2 +- ...o-iteration-over-non-integer-properties.js | 2 +- .../reduce/callbackfn-not-called-on-empty.js | 2 +- .../prototype/reduce/callbackfn-resize.js | 4 ++-- ...lbackfn-return-does-not-change-instance.js | 2 +- .../reduce/callbackfn-returns-abrupt.js | 2 +- .../callbackfn-set-value-during-iteration.js | 2 +- .../prototype/reduce/callbackfn-this.js | 2 +- .../prototype/reduce/detached-buffer.js | 2 +- .../empty-instance-return-initialvalue.js | 2 +- ...ty-instance-with-no-initialvalue-throws.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../prototype/reduce/resizable-buffer.js | 2 +- .../result-is-last-callbackfn-return.js | 2 +- .../prototype/reduce/result-of-any-type.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../return-first-value-without-callbackfn.js | 2 +- .../reduce/this-is-not-typedarray-instance.js | 6 +++--- .../prototype/reduce/values-are-not-cached.js | 2 +- ...callbackfn-arguments-custom-accumulator.js | 2 +- ...allbackfn-arguments-default-accumulator.js | 2 +- .../BigInt/callbackfn-detachbuffer.js | 2 +- .../callbackfn-is-not-callable-throws.js | 2 +- ...o-iteration-over-non-integer-properties.js | 2 +- .../BigInt/callbackfn-not-called-on-empty.js | 2 +- ...lbackfn-return-does-not-change-instance.js | 2 +- .../BigInt/callbackfn-returns-abrupt.js | 2 +- .../callbackfn-set-value-during-iteration.js | 2 +- .../reduceRight/BigInt/callbackfn-this.js | 2 +- .../reduceRight/BigInt/detached-buffer.js | 2 +- .../empty-instance-return-initialvalue.js | 2 +- ...ty-instance-with-no-initialvalue-throws.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../result-is-last-callbackfn-return.js | 2 +- .../reduceRight/BigInt/result-of-any-type.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../return-first-value-without-callbackfn.js | 2 +- .../BigInt/values-are-not-cached.js | 2 +- ...callbackfn-arguments-custom-accumulator.js | 2 +- ...allbackfn-arguments-default-accumulator.js | 2 +- .../reduceRight/callbackfn-detachbuffer.js | 2 +- .../callbackfn-is-not-callable-throws.js | 2 +- ...o-iteration-over-non-integer-properties.js | 2 +- .../callbackfn-not-called-on-empty.js | 2 +- .../reduceRight/callbackfn-resize.js | 4 ++-- ...lbackfn-return-does-not-change-instance.js | 2 +- .../reduceRight/callbackfn-returns-abrupt.js | 2 +- .../callbackfn-set-value-during-iteration.js | 2 +- .../prototype/reduceRight/callbackfn-this.js | 2 +- .../prototype/reduceRight/detached-buffer.js | 2 +- .../empty-instance-return-initialvalue.js | 2 +- ...ty-instance-with-no-initialvalue-throws.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../prototype/reduceRight/resizable-buffer.js | 2 +- .../result-is-last-callbackfn-return.js | 2 +- .../reduceRight/result-of-any-type.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../return-first-value-without-callbackfn.js | 2 +- .../this-is-not-typedarray-instance.js | 6 +++--- .../reduceRight/values-are-not-cached.js | 2 +- ...resizable-and-fixed-have-same-prototype.js | 4 ++-- .../reverse/BigInt/detached-buffer.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../preserves-non-numeric-properties.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../reverse/BigInt/returns-original-object.js | 4 ++-- .../prototype/reverse/BigInt/reverts.js | 4 ++-- .../prototype/reverse/detached-buffer.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../preserves-non-numeric-properties.js | 2 +- .../prototype/reverse/resizable-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 8 ++++---- .../reverse/returns-original-object.js | 4 ++-- .../TypedArray/prototype/reverse/reverts.js | 4 ++-- .../this-is-not-typedarray-instance.js | 6 +++--- ...rray-arg-negative-integer-offset-throws.js | 2 +- .../set/BigInt/array-arg-offset-tointeger.js | 2 +- .../BigInt/array-arg-primitive-toobject.js | 2 +- ...y-arg-return-abrupt-from-src-get-length.js | 2 +- ...ay-arg-return-abrupt-from-src-get-value.js | 2 +- ...rg-return-abrupt-from-src-length-symbol.js | 2 +- ...array-arg-return-abrupt-from-src-length.js | 2 +- ...n-abrupt-from-src-tonumber-value-symbol.js | 2 +- ...g-return-abrupt-from-src-tonumber-value.js | 2 +- ...urn-abrupt-from-tointeger-offset-symbol.js | 2 +- ...arg-return-abrupt-from-tointeger-offset.js | 2 +- ...-arg-return-abrupt-from-toobject-offset.js | 2 +- .../BigInt/array-arg-set-values-in-order.js | 2 +- .../set/BigInt/array-arg-set-values.js | 2 +- ...arg-src-tonumber-value-type-conversions.js | 2 +- .../array-arg-src-values-are-not-cached.js | 2 +- .../array-arg-target-arraylength-internal.js | 2 +- ...fer-detached-on-tointeger-offset-throws.js | 4 ++-- .../array-arg-targetbuffer-detached-throws.js | 4 ++-- .../prototype/set/BigInt/boolean-tobigint.js | 2 +- .../prototype/set/BigInt/null-tobigint.js | 2 +- .../prototype/set/BigInt/number-tobigint.js | 2 +- .../set/BigInt/src-typedarray-big.js | 4 ++-- .../BigInt/src-typedarray-not-big-throws.js | 4 ++-- .../set/BigInt/string-nan-tobigint.js | 2 +- .../prototype/set/BigInt/string-tobigint.js | 2 +- .../prototype/set/BigInt/symbol-tobigint.js | 2 +- ...rray-arg-negative-integer-offset-throws.js | 2 +- .../BigInt/typedarray-arg-offset-tointeger.js | 2 +- ...urn-abrupt-from-tointeger-offset-symbol.js | 2 +- ...arg-return-abrupt-from-tointeger-offset.js | 2 +- ...g-set-values-diff-buffer-other-type-sab.js | 20 +++++++++---------- ...y-arg-set-values-diff-buffer-other-type.js | 2 +- ...rg-set-values-diff-buffer-same-type-sab.js | 20 +++++++++---------- ...ay-arg-set-values-diff-buffer-same-type.js | 2 +- ...et-values-same-buffer-same-type-resized.js | 10 +++++----- ...rg-set-values-same-buffer-same-type-sab.js | 10 +++++----- ...ay-arg-set-values-same-buffer-same-type.js | 8 ++++---- ...typedarray-arg-src-arraylength-internal.js | 2 +- .../typedarray-arg-src-byteoffset-internal.js | 2 +- ...-greather-than-target-throws-rangeerror.js | 2 +- ...detached-during-tointeger-offset-throws.js | 4 ++-- ...edarray-arg-target-arraylength-internal.js | 2 +- ...pedarray-arg-target-byteoffset-internal.js | 2 +- .../typedarray-arg-target-out-of-bounds.js | 10 +++++----- ...detached-during-tointeger-offset-throws.js | 4 ++-- .../set/BigInt/undefined-tobigint.js | 2 +- ...rray-arg-negative-integer-offset-throws.js | 2 +- .../set/array-arg-offset-tointeger.js | 2 +- .../set/array-arg-primitive-toobject.js | 2 +- ...y-arg-return-abrupt-from-src-get-length.js | 2 +- ...ay-arg-return-abrupt-from-src-get-value.js | 2 +- ...rg-return-abrupt-from-src-length-symbol.js | 2 +- ...array-arg-return-abrupt-from-src-length.js | 2 +- ...n-abrupt-from-src-tonumber-value-symbol.js | 2 +- ...g-return-abrupt-from-src-tonumber-value.js | 2 +- ...urn-abrupt-from-tointeger-offset-symbol.js | 2 +- ...arg-return-abrupt-from-tointeger-offset.js | 2 +- ...-arg-return-abrupt-from-toobject-offset.js | 2 +- .../set/array-arg-set-values-in-order.js | 2 +- .../prototype/set/array-arg-set-values.js | 2 +- ...arg-src-tonumber-value-type-conversions.js | 2 +- .../array-arg-src-values-are-not-cached.js | 2 +- .../array-arg-target-arraylength-internal.js | 2 +- ...ffer-detached-on-get-src-value-no-throw.js | 2 +- ...fer-detached-on-tointeger-offset-throws.js | 4 ++-- .../array-arg-targetbuffer-detached-throws.js | 4 ++-- ...g-value-conversion-resizes-array-buffer.js | 2 +- .../TypedArray/prototype/set/bit-precision.js | 2 +- .../set/src-typedarray-big-throws.js | 4 ++-- .../set/this-backed-by-resizable-buffer.js | 2 +- .../set/this-is-not-typedarray-instance.js | 12 +++++------ ...rray-arg-negative-integer-offset-throws.js | 2 +- .../set/typedarray-arg-offset-tointeger.js | 2 +- ...urn-abrupt-from-tointeger-offset-symbol.js | 2 +- ...arg-return-abrupt-from-tointeger-offset.js | 2 +- ...-diff-buffer-other-type-conversions-sab.js | 10 +++++----- ...g-set-values-diff-buffer-other-type-sab.js | 20 +++++++++---------- ...y-arg-set-values-diff-buffer-other-type.js | 2 +- ...rg-set-values-diff-buffer-same-type-sab.js | 20 +++++++++---------- ...ay-arg-set-values-diff-buffer-same-type.js | 2 +- ...y-arg-set-values-same-buffer-other-type.js | 8 ++++---- ...et-values-same-buffer-same-type-resized.js | 10 +++++----- ...rg-set-values-same-buffer-same-type-sab.js | 10 +++++----- ...ay-arg-set-values-same-buffer-same-type.js | 8 ++++---- ...typedarray-arg-src-arraylength-internal.js | 2 +- ...rray-arg-src-backed-by-resizable-buffer.js | 4 ++-- .../typedarray-arg-src-byteoffset-internal.js | 2 +- ...-greather-than-target-throws-rangeerror.js | 2 +- ...detached-during-tointeger-offset-throws.js | 4 ++-- ...edarray-arg-target-arraylength-internal.js | 2 +- ...pedarray-arg-target-byteoffset-internal.js | 2 +- .../typedarray-arg-target-out-of-bounds.js | 10 +++++----- ...detached-during-tointeger-offset-throws.js | 4 ++-- .../slice/BigInt/arraylength-internal.js | 2 +- ...hed-buffer-custom-ctor-other-targettype.js | 8 ++++---- ...ched-buffer-custom-ctor-same-targettype.js | 8 ++++---- .../slice/BigInt/detached-buffer-get-ctor.js | 8 ++++---- ...ciesctor-get-species-custom-ctor-throws.js | 6 +++--- ...zero-count-custom-ctor-other-targettype.js | 2 +- ...-zero-count-custom-ctor-same-targettype.js | 2 +- .../prototype/slice/BigInt/detached-buffer.js | 2 +- .../prototype/slice/BigInt/infinity.js | 2 +- .../prototype/slice/BigInt/minus-zero.js | 2 +- ...esult-does-not-copy-ordinary-properties.js | 2 +- .../BigInt/results-with-different-length.js | 2 +- .../slice/BigInt/results-with-empty-length.js | 2 +- .../slice/BigInt/results-with-same-length.js | 2 +- .../BigInt/return-abrupt-from-end-symbol.js | 2 +- .../slice/BigInt/return-abrupt-from-end.js | 2 +- .../BigInt/return-abrupt-from-start-symbol.js | 2 +- .../slice/BigInt/return-abrupt-from-start.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../set-values-from-different-ctor-type.js | 2 +- .../speciesctor-destination-resizable.js | 6 +++--- .../BigInt/speciesctor-get-ctor-abrupt.js | 2 +- .../BigInt/speciesctor-get-ctor-inherited.js | 2 +- .../speciesctor-get-ctor-returns-throws.js | 2 +- .../slice/BigInt/speciesctor-get-ctor.js | 2 +- .../BigInt/speciesctor-get-species-abrupt.js | 2 +- ...ctor-get-species-custom-ctor-invocation.js | 2 +- ...tor-length-throws-resizable-arraybuffer.js | 4 ++-- ...r-get-species-custom-ctor-length-throws.js | 2 +- ...ciesctor-get-species-custom-ctor-length.js | 2 +- ...es-custom-ctor-returns-another-instance.js | 2 +- ...ciesctor-get-species-custom-ctor-throws.js | 2 +- .../speciesctor-get-species-custom-ctor.js | 2 +- .../speciesctor-get-species-returns-throws.js | 2 +- ...peciesctor-get-species-use-default-ctor.js | 2 +- .../slice/BigInt/speciesctor-get-species.js | 2 +- .../prototype/slice/BigInt/tointeger-end.js | 2 +- .../prototype/slice/BigInt/tointeger-start.js | 2 +- .../prototype/slice/arraylength-internal.js | 2 +- .../prototype/slice/bit-precision.js | 2 +- .../prototype/slice/coerced-start-end-grow.js | 4 ++-- .../slice/coerced-start-end-shrink.js | 8 ++++---- ...hed-buffer-custom-ctor-other-targettype.js | 6 +++--- ...ched-buffer-custom-ctor-same-targettype.js | 6 +++--- .../slice/detached-buffer-get-ctor.js | 6 +++--- ...ciesctor-get-species-custom-ctor-throws.js | 6 +++--- ...zero-count-custom-ctor-other-targettype.js | 2 +- ...-zero-count-custom-ctor-same-targettype.js | 2 +- .../prototype/slice/detached-buffer.js | 2 +- .../TypedArray/prototype/slice/infinity.js | 2 +- .../TypedArray/prototype/slice/minus-zero.js | 2 +- .../prototype/slice/resizable-buffer.js | 2 +- ...esult-does-not-copy-ordinary-properties.js | 2 +- .../slice/results-with-different-length.js | 2 +- .../slice/results-with-empty-length.js | 2 +- .../slice/results-with-same-length.js | 2 +- .../slice/return-abrupt-from-end-symbol.js | 2 +- .../prototype/slice/return-abrupt-from-end.js | 2 +- .../slice/return-abrupt-from-start-symbol.js | 2 +- .../slice/return-abrupt-from-start.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../set-values-from-different-ctor-type.js | 2 +- .../speciesctor-destination-resizable.js | 6 +++--- .../slice/speciesctor-get-ctor-abrupt.js | 2 +- .../slice/speciesctor-get-ctor-inherited.js | 2 +- .../speciesctor-get-ctor-returns-throws.js | 2 +- .../prototype/slice/speciesctor-get-ctor.js | 2 +- .../slice/speciesctor-get-species-abrupt.js | 2 +- ...ctor-get-species-custom-ctor-invocation.js | 2 +- ...tor-length-throws-resizable-arraybuffer.js | 4 ++-- ...r-get-species-custom-ctor-length-throws.js | 2 +- ...ciesctor-get-species-custom-ctor-length.js | 2 +- ...es-custom-ctor-returns-another-instance.js | 2 +- ...ciesctor-get-species-custom-ctor-throws.js | 2 +- .../speciesctor-get-species-custom-ctor.js | 2 +- .../speciesctor-get-species-returns-throws.js | 2 +- ...peciesctor-get-species-use-default-ctor.js | 2 +- .../slice/speciesctor-get-species.js | 2 +- .../prototype/slice/speciesctor-resize.js | 8 ++++---- .../slice/this-is-not-typedarray-instance.js | 6 +++--- .../prototype/slice/tointeger-end.js | 2 +- .../prototype/slice/tointeger-start.js | 2 +- .../callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../some/BigInt/callbackfn-detachbuffer.js | 2 +- ...lbackfn-no-interaction-over-non-integer.js | 2 +- .../BigInt/callbackfn-not-callable-throws.js | 2 +- .../BigInt/callbackfn-not-called-on-empty.js | 2 +- ...lbackfn-return-does-not-change-instance.js | 2 +- .../some/BigInt/callbackfn-returns-abrupt.js | 2 +- ...callbackfn-set-value-during-interaction.js | 2 +- .../prototype/some/BigInt/callbackfn-this.js | 2 +- .../prototype/some/BigInt/detached-buffer.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- ...returns-false-if-every-cb-returns-false.js | 2 +- .../returns-true-if-any-cb-returns-true.js | 2 +- .../some/BigInt/values-are-not-cached.js | 2 +- .../some/callbackfn-arguments-with-thisarg.js | 2 +- .../callbackfn-arguments-without-thisarg.js | 2 +- .../prototype/some/callbackfn-detachbuffer.js | 2 +- ...lbackfn-no-interaction-over-non-integer.js | 2 +- .../some/callbackfn-not-callable-throws.js | 2 +- .../some/callbackfn-not-called-on-empty.js | 2 +- .../prototype/some/callbackfn-resize.js | 8 ++++---- ...lbackfn-return-does-not-change-instance.js | 2 +- .../some/callbackfn-returns-abrupt.js | 2 +- ...callbackfn-set-value-during-interaction.js | 2 +- .../prototype/some/callbackfn-this.js | 2 +- .../prototype/some/detached-buffer.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../prototype/some/resizable-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- ...returns-false-if-every-cb-returns-false.js | 2 +- .../returns-true-if-any-cb-returns-true.js | 2 +- .../some/this-is-not-typedarray-instance.js | 6 +++--- .../prototype/some/values-are-not-cached.js | 2 +- .../sort/BigInt/arraylength-internal.js | 2 +- .../sort/BigInt/comparefn-call-throws.js | 2 +- .../prototype/sort/BigInt/comparefn-calls.js | 2 +- .../sort/BigInt/comparefn-is-undefined.js | 2 +- .../comparefn-nonfunction-call-throws.js | 2 +- .../prototype/sort/BigInt/detached-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../sort/BigInt/return-same-instance.js | 2 +- .../BigInt/sortcompare-with-no-tostring.js | 2 +- .../prototype/sort/BigInt/sorted-values.js | 2 +- .../prototype/sort/arraylength-internal.js | 2 +- .../prototype/sort/comparefn-call-throws.js | 2 +- .../prototype/sort/comparefn-calls.js | 2 +- .../prototype/sort/comparefn-grow.js | 4 ++-- .../prototype/sort/comparefn-is-undefined.js | 2 +- .../sort/comparefn-nonfunction-call-throws.js | 2 +- .../sort/comparefn-resizable-buffer.js | 2 +- .../prototype/sort/comparefn-shrink.js | 4 ++-- .../prototype/sort/detached-buffer.js | 2 +- .../resizable-buffer-default-comparator.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../prototype/sort/return-same-instance.js | 2 +- .../prototype/sort/sort-tonumber.js | 2 +- .../sort/sortcompare-with-no-tostring.js | 2 +- .../prototype/sort/sorted-values-nan.js | 2 +- .../prototype/sort/sorted-values.js | 10 +++++----- .../TypedArray/prototype/sort/stability.js | 2 +- .../sort/this-is-not-typedarray-instance.js | 6 +++--- .../subarray/BigInt/detached-buffer.js | 2 +- .../prototype/subarray/BigInt/infinity.js | 2 +- .../prototype/subarray/BigInt/minus-zero.js | 2 +- ...esult-does-not-copy-ordinary-properties.js | 2 +- .../result-is-new-instance-from-same-ctor.js | 2 +- ...sult-is-new-instance-with-shared-buffer.js | 2 +- .../BigInt/results-with-different-length.js | 2 +- .../BigInt/results-with-empty-length.js | 2 +- .../BigInt/results-with-same-length.js | 2 +- .../BigInt/return-abrupt-from-begin-symbol.js | 2 +- .../BigInt/return-abrupt-from-begin.js | 2 +- .../BigInt/return-abrupt-from-end-symbol.js | 2 +- .../subarray/BigInt/return-abrupt-from-end.js | 2 +- .../BigInt/speciesctor-get-ctor-abrupt.js | 2 +- .../BigInt/speciesctor-get-ctor-inherited.js | 2 +- .../speciesctor-get-ctor-returns-throws.js | 2 +- .../subarray/BigInt/speciesctor-get-ctor.js | 2 +- .../BigInt/speciesctor-get-species-abrupt.js | 2 +- ...ctor-get-species-custom-ctor-invocation.js | 2 +- ...es-custom-ctor-returns-another-instance.js | 2 +- ...ciesctor-get-species-custom-ctor-throws.js | 2 +- .../speciesctor-get-species-custom-ctor.js | 2 +- .../speciesctor-get-species-returns-throws.js | 2 +- ...peciesctor-get-species-use-default-ctor.js | 2 +- .../BigInt/speciesctor-get-species.js | 2 +- .../subarray/BigInt/tointeger-begin.js | 2 +- .../subarray/BigInt/tointeger-end.js | 2 +- .../prototype/subarray/detached-buffer.js | 2 +- .../TypedArray/prototype/subarray/infinity.js | 2 +- .../prototype/subarray/minus-zero.js | 2 +- .../prototype/subarray/resizable-buffer.js | 2 +- .../result-byteOffset-from-out-of-bounds.js | 2 +- ...esult-does-not-copy-ordinary-properties.js | 2 +- .../result-is-new-instance-from-same-ctor.js | 2 +- ...sult-is-new-instance-with-shared-buffer.js | 2 +- .../subarray/results-with-different-length.js | 2 +- .../subarray/results-with-empty-length.js | 2 +- .../subarray/results-with-same-length.js | 2 +- .../return-abrupt-from-begin-symbol.js | 2 +- .../subarray/return-abrupt-from-begin.js | 2 +- .../subarray/return-abrupt-from-end-symbol.js | 2 +- .../subarray/return-abrupt-from-end.js | 2 +- .../subarray/speciesctor-get-ctor-abrupt.js | 2 +- .../speciesctor-get-ctor-inherited.js | 2 +- .../speciesctor-get-ctor-returns-throws.js | 2 +- .../subarray/speciesctor-get-ctor.js | 2 +- .../speciesctor-get-species-abrupt.js | 2 +- ...ctor-get-species-custom-ctor-invocation.js | 2 +- ...es-custom-ctor-returns-another-instance.js | 2 +- ...ciesctor-get-species-custom-ctor-throws.js | 2 +- .../speciesctor-get-species-custom-ctor.js | 2 +- .../speciesctor-get-species-returns-throws.js | 2 +- ...peciesctor-get-species-use-default-ctor.js | 2 +- .../subarray/speciesctor-get-species.js | 2 +- .../this-is-not-typedarray-instance.js | 6 +++--- .../prototype/subarray/tointeger-begin.js | 2 +- .../prototype/subarray/tointeger-end.js | 2 +- .../calls-tolocalestring-from-each-value.js | 2 +- .../BigInt/calls-tostring-from-each-value.js | 2 +- .../BigInt/calls-valueof-from-each-value.js | 2 +- .../toLocaleString/BigInt/detached-buffer.js | 2 +- .../empty-instance-returns-empty-string.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- ...abrupt-from-firstelement-tolocalestring.js | 2 +- ...eturn-abrupt-from-firstelement-tostring.js | 2 +- ...return-abrupt-from-firstelement-valueof.js | 2 +- ...-abrupt-from-nextelement-tolocalestring.js | 2 +- ...return-abrupt-from-nextelement-tostring.js | 2 +- .../return-abrupt-from-nextelement-valueof.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../toLocaleString/BigInt/return-result.js | 2 +- .../calls-tolocalestring-from-each-value.js | 2 +- .../calls-tostring-from-each-value.js | 2 +- .../calls-valueof-from-each-value.js | 2 +- .../toLocaleString/detached-buffer.js | 2 +- .../empty-instance-returns-empty-string.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../toLocaleString/resizable-buffer.js | 2 +- ...abrupt-from-firstelement-tolocalestring.js | 2 +- ...eturn-abrupt-from-firstelement-tostring.js | 2 +- ...return-abrupt-from-firstelement-valueof.js | 2 +- ...-abrupt-from-nextelement-tolocalestring.js | 2 +- ...return-abrupt-from-nextelement-tostring.js | 2 +- .../return-abrupt-from-nextelement-valueof.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../prototype/toLocaleString/return-result.js | 2 +- .../this-is-not-typedarray-instance.js | 6 +++--- .../user-provided-tolocalestring-grow.js | 4 ++-- .../user-provided-tolocalestring-shrink.js | 4 ++-- .../prototype/toReversed/ignores-species.js | 2 +- .../prototype/toReversed/immutable.js | 2 +- .../toReversed/length-property-ignored.js | 4 ++-- .../toReversed/this-value-invalid.js | 4 ++-- .../toSorted/comparefn-not-a-function.js | 2 +- .../toSorted/comparefn-stop-after-error.js | 2 +- .../prototype/toSorted/ignores-species.js | 2 +- .../prototype/toSorted/immutable.js | 2 +- .../toSorted/length-property-ignored.js | 4 ++-- .../prototype/toSorted/this-value-invalid.js | 4 ++-- .../toString/BigInt/detached-buffer.js | 2 +- .../prototype/toString/detached-buffer.js | 2 +- .../values/BigInt/detached-buffer.js | 2 +- .../prototype/values/BigInt/iter-prototype.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../prototype/values/BigInt/return-itor.js | 2 +- .../prototype/values/detached-buffer.js | 2 +- .../prototype/values/iter-prototype.js | 2 +- .../values/make-in-bounds-after-exhausted.js | 2 +- .../make-out-of-bounds-after-exhausted.js | 2 +- .../prototype/values/resizable-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 10 +++++----- .../prototype/values/return-itor.js | 2 +- .../values/this-is-not-typedarray-instance.js | 6 +++--- .../with/BigInt/early-type-coercion-bigint.js | 2 +- .../prototype/with/early-type-coercion.js | 2 +- .../prototype/with/ignores-species.js | 2 +- .../TypedArray/prototype/with/immutable.js | 2 +- .../with/index-bigger-or-eq-than-length.js | 2 +- .../prototype/with/index-casted-to-number.js | 2 +- .../prototype/with/index-negative.js | 2 +- .../with/index-smaller-than-minus-length.js | 2 +- .../index-validated-against-current-length.js | 2 +- .../prototype/with/length-property-ignored.js | 4 ++-- .../resizable-buffer-length-tracking-1.js | 2 +- .../resizable-buffer-length-tracking-2.js | 2 +- 1122 files changed, 1671 insertions(+), 1671 deletions(-) diff --git a/test/sendable/builtins/TypedArray/from/from-array-mapper-detaches-result.js b/test/sendable/builtins/TypedArray/from/from-array-mapper-detaches-result.js index ab118789a49..6052231533a 100644 --- a/test/sendable/builtins/TypedArray/from/from-array-mapper-detaches-result.js +++ b/test/sendable/builtins/TypedArray/from/from-array-mapper-detaches-result.js @@ -32,7 +32,7 @@ includes: [detachArrayBuffer.js] features: [TypedArray] ---*/ -let ab = new SendableArrayBuffer(3); +let ab = new ArrayBuffer(3); let target = new Int8Array(ab); let values = [0, 1, 2]; diff --git a/test/sendable/builtins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js b/test/sendable/builtins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js index 8026f5bb5af..f0497ed23dc 100644 --- a/test/sendable/builtins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/from/from-array-mapper-makes-result-out-of-bounds.js @@ -31,7 +31,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new SendableArrayBuffer(3, {maxByteLength: 5}); +let rab = new ArrayBuffer(3, {maxByteLength: 5}); let target = new Int8Array(rab); let values = [0, 1, 2]; diff --git a/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js b/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js index 660e0d6ce4b..44e056dc968 100644 --- a/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js +++ b/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-detaches-result.js @@ -32,7 +32,7 @@ includes: [detachArrayBuffer.js] features: [TypedArray] ---*/ -let ab = new SendableArrayBuffer(3); +let ab = new ArrayBuffer(3); let target = new Int8Array(ab); target.set([0, 1, 2]); diff --git a/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js b/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js index 46d353fc344..614ad6bcbda 100644 --- a/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/from/from-typedarray-into-itself-mapper-makes-result-out-of-bounds.js @@ -31,7 +31,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new SendableArrayBuffer(3, {maxByteLength: 5}); +let rab = new ArrayBuffer(3, {maxByteLength: 5}); let target = new Int8Array(rab); target.set([0, 1, 2]); diff --git a/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-detaches-result.js b/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-detaches-result.js index 0275af591e5..51ff48e9180 100644 --- a/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-detaches-result.js +++ b/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-detaches-result.js @@ -32,7 +32,7 @@ includes: [detachArrayBuffer.js] features: [TypedArray] ---*/ -let ab = new SendableArrayBuffer(3); +let ab = new ArrayBuffer(3); let target = new Int8Array(ab); let values = new Int8Array([0, 1, 2]); diff --git a/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js b/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js index 241ec7a1ad1..a874ab3e2f0 100644 --- a/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/from/from-typedarray-mapper-makes-result-out-of-bounds.js @@ -31,7 +31,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new SendableArrayBuffer(3, {maxByteLength: 5}); +let rab = new ArrayBuffer(3, {maxByteLength: 5}); let target = new Int8Array(rab); let values = new Int8Array([0, 1, 2]); diff --git a/test/sendable/builtins/TypedArray/invoked.js b/test/sendable/builtins/TypedArray/invoked.js index 2a174db6f75..cd4387f5ef4 100644 --- a/test/sendable/builtins/TypedArray/invoked.js +++ b/test/sendable/builtins/TypedArray/invoked.js @@ -69,7 +69,7 @@ assert.throws(TypeError, function() { new SendableTypedArray(typedArray); }); -var buffer = new SendableArrayBuffer(4); +var buffer = new ArrayBuffer(4); assert.throws(TypeError, function() { SendableTypedArray(buffer); }); diff --git a/test/sendable/builtins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js b/test/sendable/builtins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js index 716ff7fdfc1..223b88d4a58 100644 --- a/test/sendable/builtins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js +++ b/test/sendable/builtins/TypedArray/of/resized-with-out-of-bounds-and-in-bounds-indices.js @@ -29,7 +29,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new SendableArrayBuffer(3, {maxByteLength: 4}); +let rab = new ArrayBuffer(3, {maxByteLength: 4}); let ta = new Int8Array(rab); let one = { diff --git a/test/sendable/builtins/TypedArray/out-of-bounds-behaves-like-detached.js b/test/sendable/builtins/TypedArray/out-of-bounds-behaves-like-detached.js index 7f82eb6ed8a..9997bf55059 100644 --- a/test/sendable/builtins/TypedArray/out-of-bounds-behaves-like-detached.js +++ b/test/sendable/builtins/TypedArray/out-of-bounds-behaves-like-detached.js @@ -22,7 +22,7 @@ includes: [resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableSendableArrayBuffer(16, 40); +const rab = CreateResizableArrayBuffer(16, 40); const i8a = new Int8Array(rab, 0, 4); i8a.__proto__ = { 2: 'wrong value' }; i8a[2] = 10; diff --git a/test/sendable/builtins/TypedArray/out-of-bounds-get-and-set.js b/test/sendable/builtins/TypedArray/out-of-bounds-get-and-set.js index e3db7c04db1..88ccef49bfa 100644 --- a/test/sendable/builtins/TypedArray/out-of-bounds-get-and-set.js +++ b/test/sendable/builtins/TypedArray/out-of-bounds-get-and-set.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 40 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 40 * ctor.BYTES_PER_ELEMENT); const array = new ctor(rab, 0, 4); // Initial values for (let i = 0; i < 4; ++i) { diff --git a/test/sendable/builtins/TypedArray/out-of-bounds-has.js b/test/sendable/builtins/TypedArray/out-of-bounds-has.js index 142b7ebee40..f72d12ddbed 100644 --- a/test/sendable/builtins/TypedArray/out-of-bounds-has.js +++ b/test/sendable/builtins/TypedArray/out-of-bounds-has.js @@ -28,7 +28,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 40 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 40 * ctor.BYTES_PER_ELEMENT); const array = new ctor(rab, 0, 4); // Within-bounds read for (let i = 0; i < 4; ++i) { diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js index d8eecbc8a92..43fb2310380 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js @@ -27,7 +27,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, Symbol.toStringTag, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample[Symbol.toStringTag], TA.name); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js index addac178a79..46675c89dfa 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js @@ -28,7 +28,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var ta = new TA(); assert.sameValue(ta[Symbol.toStringTag], TA.name, "property value"); }); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js index bd540beb3dc..384265f33f1 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js @@ -35,8 +35,8 @@ var getter = Object.getOwnPropertyDescriptor( assert.sameValue(getter.call({}), undefined); assert.sameValue(getter.call([]), undefined); -assert.sameValue(getter.call(new SendableArrayBuffer(8)), undefined); +assert.sameValue(getter.call(new ArrayBuffer(8)), undefined); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); var dv = new DataView(ab, 0, 1); assert.sameValue(getter.call(dv), undefined); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js index 37cc807c3b0..de5a3cf937c 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js @@ -27,7 +27,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [Symbol.toStringTag, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample[Symbol.toStringTag], TA.name); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js index cf728a44a6d..a07325c4c4d 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js @@ -28,7 +28,7 @@ includes: [testTypedArray.js] features: [Symbol.toStringTag, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var ta = new TA(); assert.sameValue(ta[Symbol.toStringTag], TA.name, "property value"); }); diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js index 9e77c155051..ea29a5ba5b0 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js @@ -35,8 +35,8 @@ var getter = Object.getOwnPropertyDescriptor( assert.sameValue(getter.call({}), undefined); assert.sameValue(getter.call([]), undefined); -assert.sameValue(getter.call(new SendableArrayBuffer(8)), undefined); +assert.sameValue(getter.call(new ArrayBuffer(8)), undefined); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); var dv = new DataView(ab, 0, 1); assert.sameValue(getter.call(dv), undefined); diff --git a/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js index ff52fe8b2e8..fbfc42e609f 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.at description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, SendableTypedArray.prototype.at, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, SendableTypedArray.prototype.at, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/at/coerced-index-resize.js b/test/sendable/builtins/TypedArray/prototype/at/coerced-index-resize.js index f768e429d1a..9fc2f5e20cf 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/coerced-index-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/at/coerced-index-resize.js @@ -28,7 +28,7 @@ function SendableTypedArrayAtHelper(ta, index) { } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { valueOf: () => { @@ -40,7 +40,7 @@ for (let ctor of ctors) { } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); let evil = { valueOf: () => { diff --git a/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js b/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js index cd8e7d5b6a4..136873f80d9 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js @@ -31,7 +31,7 @@ assert.sameValue( 'The value of `typeof SendableTypedArray.prototype.at` is "function"' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"'); let valueOfCallCount = 0; let index = { diff --git a/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js index 70106a6bc94..e7b5c04b1cd 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js +++ b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js @@ -31,7 +31,7 @@ assert.sameValue( 'The value of `typeof SendableTypedArray.prototype.at` is "function"' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"'); let a = new TA([0,1,2,3]); diff --git a/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js index b5d81219458..c8cd033253e 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js @@ -31,7 +31,7 @@ assert.sameValue( 'The value of `typeof SendableTypedArray.prototype.at` is "function"' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"'); let a = new TA([0,1,2,3]); diff --git a/test/sendable/builtins/TypedArray/prototype/at/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/at/resizable-buffer.js index 5817f286b0d..09b5036ef27 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/at/resizable-buffer.js @@ -27,7 +27,7 @@ function SendableTypedArrayAtHelper(ta, index) { } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js index 25a7319a0a9..d15cce81cc6 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js index 35fede39d03..f731b94a0b6 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js +++ b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js @@ -40,7 +40,7 @@ assert.throws(TypeError, () => { SendableTypedArray.prototype.at.call(null); }); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"'); assert.throws(TypeError, () => { diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js b/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js index db4d6ba2307..1bd5b6c7885 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js @@ -40,7 +40,7 @@ assert.sameValue( 'The value of `typeof SendableTypedArray.prototype.at` is "function"' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { let a = new TA([1, 2, 3, 4, 5]); assert.sameValue(a.at(0), 1, 'a.at(0) must return 1'); assert.sameValue(a.at(-1), 5, 'a.at(-1) must return 5'); diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-item.js b/test/sendable/builtins/TypedArray/prototype/at/returns-item.js index e3f4ea7e85d..64ac38e58f7 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/returns-item.js +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-item.js @@ -40,7 +40,7 @@ assert.sameValue( 'The value of `typeof SendableTypedArray.prototype.at` is "function"' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"'); let a = new TA([1, 2, 3, 4]); diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js index fff1315b3f2..4adb1ff22b7 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js @@ -40,7 +40,7 @@ assert.sameValue( 'The value of `typeof SendableTypedArray.prototype.at` is "function"' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { let a = new TA([0, 1, , 3, 4, , 6]); let filler = 0; if (TA.name.startsWith('Float')) { diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js index 1e7dc7edd3b..5d332081e71 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js @@ -31,7 +31,7 @@ assert.sameValue( 'The value of `typeof SendableTypedArray.prototype.at` is "function"' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { assert.sameValue(typeof TA.prototype.at, 'function', 'The value of `typeof TA.prototype.at` is "function"'); let a = new TA([]); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/detached-buffer.js index 15c4c2b82f5..9ffd1182eb2 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/detached-buffer.js @@ -20,14 +20,14 @@ info: | 22.2.3.1 get %SendableTypedArray%.prototype.buffer ... - 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 5. Return buffer. includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { - var buffer = new SendableArrayBuffer(8); +testWithBigIntTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(8); var sample = new TA(buffer, 0, 1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.buffer, buffer); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/return-buffer.js b/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/return-buffer.js index cc9705da69c..9b86ce6ce7c 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/return-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/BigInt/return-buffer.js @@ -16,19 +16,19 @@ /*--- esid: sec-get-%typedarray%.prototype.buffer description: > - Return buffer from [[ViewedSendableArrayBuffer]] internal slot + Return buffer from [[ViewedArrayBuffer]] internal slot info: | 22.2.3.1 get %SendableTypedArray%.prototype.buffer ... - 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 5. Return buffer. includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { - var buffer = new SendableArrayBuffer(TA.BYTES_PER_ELEMENT); +testWithBigIntTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT); var ta = new TA(buffer); assert.sameValue(ta.buffer, buffer); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js index b88de349994..3c79a94c2cf 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js @@ -20,14 +20,14 @@ info: | 22.2.3.1 get %SendableTypedArray%.prototype.buffer ... - 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 5. Return buffer. includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { - var buffer = new SendableArrayBuffer(8); +testWithTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(8); var sample = new TA(buffer, 0, 1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.buffer, buffer); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js index 575ca9a54d6..314b0e1238e 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js @@ -16,13 +16,13 @@ /*--- esid: sec-get-%typedarray%.prototype.buffer description: > - Requires this value to have a [[ViewedSendableArrayBuffer]] internal slot + Requires this value to have a [[ViewedArrayBuffer]] internal slot info: | 22.2.3.1 get %SendableTypedArray%.prototype.buffer 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. - 3. If O does not have a [[ViewedSendableArrayBuffer]] internal slot, throw a TypeError + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError exception. ... includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js index 1f4e9c2f45b..7ecc1c79a5a 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. - 3. If O does not have a [[ViewedSendableArrayBuffer]] internal slot, throw a TypeError + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError exception. ... includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js b/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js index 953760053b3..1dec12f37d6 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js @@ -16,19 +16,19 @@ /*--- esid: sec-get-%typedarray%.prototype.buffer description: > - Return buffer from [[ViewedSendableArrayBuffer]] internal slot + Return buffer from [[ViewedArrayBuffer]] internal slot info: | 22.2.3.1 get %SendableTypedArray%.prototype.buffer ... - 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 5. Return buffer. includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { - var buffer = new SendableArrayBuffer(TA.BYTES_PER_ELEMENT); +testWithTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT); var ta = new TA(buffer); assert.sameValue(ta.buffer, buffer); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js index 8675fc203f1..7074f46fe09 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js @@ -43,12 +43,12 @@ assert.throws(TypeError, function() { getter.call([]); }); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { getter.call(ab); }); -var dv = new DataView(new SendableArrayBuffer(8), 0); +var dv = new DataView(new ArrayBuffer(8), 0); assert.throws(TypeError, function() { getter.call(dv); }); diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/this-inherits-typedarray.js b/test/sendable/builtins/TypedArray/prototype/buffer/this-inherits-typedarray.js index b759b9d5f49..2ae208a2b27 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/this-inherits-typedarray.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/this-inherits-typedarray.js @@ -35,7 +35,7 @@ var getter = Object.getOwnPropertyDescriptor( SendableTypedArrayPrototype, "buffer" ).get; -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var typedArray = new TA(5); var o = {}; Object.setPrototypeOf(o, typedArray); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js index 878342117b6..73882533db9 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/detached-buffer.js @@ -20,14 +20,14 @@ info: | 22.2.3.2 get %SendableTypedArray%.prototype.byteLength ... - 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 5. If IsDetachedBuffer(buffer) is true, return 0. ... includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.byteLength, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js index fb7a18284b1..e63951cd231 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-auto.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.byteoffset description: | - reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE); var expected = BPE * 3; diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js index 096ddde6cdb..56226551ce8 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/resizable-array-buffer-fixed.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.bytelength description: | - reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); assert.sameValue(array.byteLength, BPE * 2); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js index a6632944348..b7e08500bfc 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/BigInt/return-bytelength.js @@ -27,7 +27,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var bytesPerElement = TA.BYTES_PER_ELEMENT; var ta1 = new TA(); assert.sameValue(ta1.byteLength, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js index feff892351e..1dab40c5f72 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js @@ -20,14 +20,14 @@ info: | 22.2.3.2 get %SendableTypedArray%.prototype.byteLength ... - 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 5. If IsDetachedBuffer(buffer) is true, return 0. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.byteLength, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js index aeed5c2355b..dff0d9cdffc 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js @@ -16,13 +16,13 @@ /*--- esid: sec-get-%typedarray%.prototype.bytelength description: > - Requires this value to have a [[ViewedSendableArrayBuffer]] internal slot + Requires this value to have a [[ViewedArrayBuffer]] internal slot info: | 22.2.3.2 get %SendableTypedArray%.prototype.byteLength 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. - 3. If O does not have a [[ViewedSendableArrayBuffer]] internal slot, throw a TypeError + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError exception. ... includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js index b6ba3adbcd5..62885ee8c13 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. - 3. If O does not have a [[ViewedSendableArrayBuffer]] internal slot, throw a TypeError + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError exception. ... includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js index 62ed958b2a1..926c58a33cf 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.byteoffset description: | - reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE); var expected = BPE * 3; diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js index 324f4fc4e61..42a1cff676e 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.bytelength description: | - reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); assert.sameValue(array.byteLength, BPE * 2); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-buffer-assorted.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-buffer-assorted.js index 8f3db193209..80be3aedb16 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-buffer-assorted.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-buffer-assorted.js @@ -22,7 +22,7 @@ includes: [compareArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableSendableArrayBuffer(40, 80); +const rab = CreateResizableArrayBuffer(40, 80); for (let ctor of ctors) { const ta = new ctor(rab, 0, 3); assert.compareArray(ta.buffer, rab); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-1.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-1.js index b3d8f40aca0..e53a44c8689 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-1.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-1.js @@ -22,7 +22,7 @@ includes: [compareArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableSendableArrayBuffer(16, 40); +const rab = CreateResizableArrayBuffer(16, 40); // Create TAs which cover the bytes 0-7. let tas_and_lengths = []; diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-2.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-2.js index e7a6e5c6b85..d1d64451f0e 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-2.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resized-out-of-bounds-2.js @@ -22,7 +22,7 @@ includes: [compareArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableSendableArrayBuffer(20, 40); +const rab = CreateResizableArrayBuffer(20, 40); // Create TAs with offset, which cover the bytes 8-15. let tas_and_lengths = []; diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/return-bytelength.js b/test/sendable/builtins/TypedArray/prototype/byteLength/return-bytelength.js index 6eee0fdfdc5..c536b8c79f9 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/return-bytelength.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/return-bytelength.js @@ -27,7 +27,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var bytesPerElement = TA.BYTES_PER_ELEMENT; var ta1 = new TA(); assert.sameValue(ta1.byteLength, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js index 4174339b26a..378633a1100 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js @@ -43,12 +43,12 @@ assert.throws(TypeError, function() { getter.call([]); }); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { getter.call(ab); }); -var dv = new DataView(new SendableArrayBuffer(8), 0); +var dv = new DataView(new ArrayBuffer(8), 0); assert.throws(TypeError, function() { getter.call(dv); }); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js index a6aed18d04b..32f72ac5dac 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js @@ -20,15 +20,15 @@ info: | 22.2.3.3 get %SendableTypedArray%.prototype.byteOffset ... - 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 5. If IsDetachedBuffer(buffer) is true, return 0. ... includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { - var buffer = new SendableArrayBuffer(128); +testWithBigIntTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(128); var sample = new TA(buffer, 8, 1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.byteOffset, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js index 5d451fee29a..c15818608fa 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.byteoffset description: | - reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE); assert.sameValue(array.byteOffset, BPE); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js index 05618c17959..2e0295270aa 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.byteoffset description: | - reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); assert.sameValue(array.byteOffset, BPE); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js index 15110557146..3487eb36d74 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js @@ -27,17 +27,17 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var ta1 = new TA(); assert.sameValue(ta1.byteOffset, 0, "Regular typedArray"); var offset = 4 * TA.BYTES_PER_ELEMENT; - var buffer1 = new SendableArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var buffer1 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); var ta2 = new TA(buffer1, offset); assert.sameValue(ta2.byteOffset, offset, "TA(buffer, offset)"); - var buffer2 = new SendableArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var buffer2 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); var sample = new TA(buffer2, offset); var ta3 = new TA(sample); assert.sameValue(ta3.byteOffset, 0, "TA(typedArray)"); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js index ee7bf4ad486..95bc09426ba 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js @@ -20,15 +20,15 @@ info: | 22.2.3.3 get %SendableTypedArray%.prototype.byteOffset ... - 4. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 5. If IsDetachedBuffer(buffer) is true, return 0. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { - var buffer = new SendableArrayBuffer(128); +testWithTypedArrayConstructors(function(TA) { + var buffer = new ArrayBuffer(128); var sample = new TA(buffer, 8, 1); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.byteOffset, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js index f8b60246fa5..9c159226ac3 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js @@ -16,13 +16,13 @@ /*--- esid: sec-get-%typedarray%.prototype.byteoffset description: > - Requires this value to have a [[ViewedSendableArrayBuffer]] internal slot + Requires this value to have a [[ViewedArrayBuffer]] internal slot info: | 22.2.3.3 get %SendableTypedArray%.prototype.byteOffset 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. - 3. If O does not have a [[ViewedSendableArrayBuffer]] internal slot, throw a TypeError + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError exception. ... includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js index 30592d357ac..180da3b738a 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. - 3. If O does not have a [[ViewedSendableArrayBuffer]] internal slot, throw a TypeError + 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError exception. ... includes: [testTypedArray.js] diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js index 12f844e8a37..f647532d899 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.byteoffset description: | - reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE); assert.sameValue(array.byteOffset, BPE); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js index 9ea2440eb5a..bb4e5c2bd38 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.byteoffset description: | - reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); assert.sameValue(array.byteOffset, BPE); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/resized-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/resized-out-of-bounds.js index 6e5c84c953b..ba5338bf20a 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/resized-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/resized-out-of-bounds.js @@ -22,7 +22,7 @@ includes: [compareArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableSendableArrayBuffer(20, 40); +const rab = CreateResizableArrayBuffer(20, 40); // Create TAs which cover the bytes 8-15. let tas_and_lengths = []; diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js index 455d017400a..a90d86703b9 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js @@ -27,17 +27,17 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var ta1 = new TA(); assert.sameValue(ta1.byteOffset, 0, "Regular typedArray"); var offset = 4 * TA.BYTES_PER_ELEMENT; - var buffer1 = new SendableArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var buffer1 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); var ta2 = new TA(buffer1, offset); assert.sameValue(ta2.byteOffset, offset, "TA(buffer, offset)"); - var buffer2 = new SendableArrayBuffer(8 * TA.BYTES_PER_ELEMENT); + var buffer2 = new ArrayBuffer(8 * TA.BYTES_PER_ELEMENT); var sample = new TA(buffer2, offset); var ta3 = new TA(sample); assert.sameValue(ta3.byteOffset, 0, "TA(typedArray)"); diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js index aa21f08edab..d91b35e4685 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js @@ -43,12 +43,12 @@ assert.throws(TypeError, function() { getter.call([]); }); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { getter.call(ab); }); -var dv = new DataView(new SendableArrayBuffer(8), 0); +var dv = new DataView(new ArrayBuffer(8), 0); assert.throws(TypeError, function() { getter.call(dv); }); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js index 68c28608451..f55b794fb99 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-end.js @@ -39,7 +39,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0n, 1n, 2n, 3n]).copyWithin(1, 0, null), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js index 2787a0ca2ce..2ad353417f5 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-start.js @@ -38,7 +38,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0n, 1n, 2n, 3n]).copyWithin(1, undefined), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js index a4e180af0c2..c353b382640 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/coerced-values-target.js @@ -38,7 +38,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0n, 1n, 2n, 3n]).copyWithin(undefined, 1), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js index 6ff7498ac2a..d2b4cf807ce 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/detached-buffer.js @@ -38,7 +38,7 @@ var obj = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js index 80a64f5de41..160e86be7fa 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js @@ -44,7 +44,7 @@ Object.defineProperty(SendableTypedArray.prototype, "length", { } }); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { Object.defineProperty(TA.prototype, "length", { get: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-end.js index 9f336524273..c6f5f08dee9 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-end.js @@ -41,7 +41,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -1), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js index 523e421e153..e38fd82312b 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-end.js @@ -41,7 +41,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, -10), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js index 34eb4aef0fe..8770c8611c0 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-start.js @@ -39,7 +39,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0n, 1n, 2n, 3n]).copyWithin(0, -10), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js index b00c23fb957..fc3cd28fa8c 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-out-of-bounds-target.js @@ -39,7 +39,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0n, 1n, 2n, 3n]).copyWithin(-10, 0), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-start.js index 0d6d34e327a..15b7bfc02d7 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-start.js @@ -39,7 +39,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0n, 1n, 2n, 3n]).copyWithin(0, -1), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-target.js index 78e21adbf67..081458a0911 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/negative-target.js @@ -39,7 +39,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0n, 1n, 2n, 3n]).copyWithin(-1, 0), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js index fb0cd7dc9e9..1bd12738a02 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-end.js @@ -32,7 +32,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, 6), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js index 92bbfea753d..95071c954f7 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-out-of-bounds-target-and-start.js @@ -32,7 +32,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0n, 1n, 2n, 3n, 4n, 5n]).copyWithin(6, 0), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js index 20c34e1e4eb..1217bd2c6d9 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-and-start.js @@ -32,7 +32,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA([1n, 2n, 3n, 4n, 5n, 6n]).copyWithin(0, 0), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js index e3daa32a35d..8069308d4da 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/non-negative-target-start-and-end.js @@ -32,7 +32,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0n, 1n, 2n, 3n]).copyWithin(0, 0, 0), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js index ca30734eecc..e700a3d6d6b 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end-is-symbol.js @@ -41,7 +41,7 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol(1); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { sample.copyWithin(0, 0, s); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js index 63c2816e96d..b2003fe6751 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-end.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var o1 = { valueOf: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js index 2279a7919b9..5fecd579003 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start-is-symbol.js @@ -40,7 +40,7 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol(1); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { sample.copyWithin(0, s); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js index 03fc7206579..5234c083ba8 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-start.js @@ -50,7 +50,7 @@ var err = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { sample.copyWithin(0, o, err); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js index f6c84ed6312..991f8a1c3da 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target-is-symbol.js @@ -40,7 +40,7 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol(1); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { sample.copyWithin(s, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js index 9d48c3f4d51..8f583d25e60 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-target.js @@ -44,7 +44,7 @@ var o = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { sample.copyWithin(o); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js index dcd160f560f..0d6f2b3023f 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.copywithin description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-this.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-this.js index 6d75b7a5ee4..499c55ed60b 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-this.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-this.js @@ -36,7 +36,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample1 = new TA(); var result1 = sample1.copyWithin(0, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js index 1b988619941..843aae8eeda 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/undefined-end.js @@ -39,7 +39,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0n, 1n, 2n, 3n]).copyWithin(0, 1, undefined), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js index e84c445f91b..b2798f3dca0 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js @@ -53,4 +53,4 @@ function body(FloatArray) { assert(compareArray(originalBytes, copiedBytes)); } -testWithSendableTypedArrayConstructors(body, floatArrayConstructors); +testWithTypedArrayConstructors(body, floatArrayConstructors); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js index d4d28bcada8..e556ccc5913 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var ta = new TA([0, 1, 2, 3]); assert.compareArray( new TA(ta.buffer, TA.BYTES_PER_ELEMENT).copyWithin(2, 0), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-end-shrink.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-end-shrink.js index cf1c1634cd5..f736b7bcba1 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-end-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-end-shrink.js @@ -22,7 +22,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const evil = { valueOf: () => { @@ -43,7 +43,7 @@ for (let ctor of ctors) { }); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i); @@ -67,7 +67,7 @@ for (let ctor of ctors) { ]); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-grow.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-grow.js index c5b55f87466..e9f412cd658 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-target-start-grow.js @@ -22,7 +22,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js index 39001e4a3c5..7a6d9a72fbc 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js @@ -27,14 +27,14 @@ info: | 10. Let count be min(final - from, len - to). 11. If count > 0, then a. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data. - b. Let buffer be O.[[ViewedSendableArrayBuffer]]. + b. Let buffer be O.[[ViewedArrayBuffer]]. c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var ta; var array = []; diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js index 74cb365314c..ce028c52d96 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js @@ -27,14 +27,14 @@ info: | 10. Let count be min(final - from, len - to). 11. If count > 0, then a. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data. - b. Let buffer be O.[[ViewedSendableArrayBuffer]]. + b. Let buffer be O.[[ViewedArrayBuffer]]. c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var ta; function detachAndReturnIndex(){ $DETACHBUFFER(ta.buffer); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js index 19eb5f66690..8387ba61737 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js @@ -39,7 +39,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0, 1, 2, 3]).copyWithin(1, 0, null), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js index 3b56a5b92ae..68da3256a81 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js @@ -27,14 +27,14 @@ info: | 10. Let count be min(final - from, len - to). 11. If count > 0, then a. NOTE: The copying must be performed in a manner that preserves the bit-level encoding of the source data. - b. Let buffer be O.[[ViewedSendableArrayBuffer]]. + b. Let buffer be O.[[ViewedArrayBuffer]]. c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var ta; function detachAndReturnIndex(){ $DETACHBUFFER(ta.buffer); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js index 9524f2ae7d5..315d9552a8e 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js @@ -38,7 +38,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0, 1, 2, 3]).copyWithin(1, undefined), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js index 2ad93d64fbd..ae98819d33d 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js @@ -38,7 +38,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0, 1, 2, 3]).copyWithin(undefined, 1), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js index 8c9d34a9be0..c47ee41a999 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js @@ -38,7 +38,7 @@ var obj = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js index 3ac21fffe7e..15eeeb35be3 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js @@ -44,7 +44,7 @@ Object.defineProperty(SendableTypedArray.prototype, "length", { } }); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { Object.defineProperty(TA.prototype, "length", { get: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js index e9964e82de7..690bd8d87f7 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js @@ -41,7 +41,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0, 1, 2, 3]).copyWithin(0, 1, -1), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js index 0a354b19c4e..a730aaec183 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js @@ -41,7 +41,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0, 1, 2, 3]).copyWithin(0, 1, -10), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js index b58ef3b4420..d0ddcba8d20 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js @@ -39,7 +39,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0, 1, 2, 3]).copyWithin(0, -10), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js index 6885d2aed2a..77c4093000a 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js @@ -39,7 +39,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0, 1, 2, 3]).copyWithin(-10, 0), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js index ac9aa9f719e..153520760f8 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js @@ -39,7 +39,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0, 1, 2, 3]).copyWithin(0, -1), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js index 503bdd17535..456d7e6b752 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js @@ -39,7 +39,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0, 1, 2, 3]).copyWithin(-1, 0), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js index 579f4fedee4..2006c5b3bde 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js @@ -32,7 +32,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0, 1, 2, 3]).copyWithin(0, 1, 6), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js index 4ee87cea4e1..48e97de674a 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js @@ -32,7 +32,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0, 1, 2, 3, 4, 5]).copyWithin(6, 0), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js index 9c181feedab..955e4d4787f 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js @@ -32,7 +32,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA([1, 2, 3, 4, 5, 6]).copyWithin(0, 0), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js index e372fd7ce14..a07df245006 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js @@ -32,7 +32,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0, 1, 2, 3]).copyWithin(0, 0, 0), diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/resizable-buffer.js index f66dedf23fa..ce9a3e17c13 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js index 66ebaeda73e..730c1f42d87 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js @@ -41,7 +41,7 @@ features: [Symbol, TypedArray] var s = Symbol(1); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { sample.copyWithin(0, 0, s); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js index 3f44560e2d0..4e23e041ac2 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var o1 = { valueOf: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js index 892e50239d2..1a9fe6d2f7a 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js @@ -40,7 +40,7 @@ features: [Symbol, TypedArray] var s = Symbol(1); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { sample.copyWithin(0, s); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js index 5dda85d9d4d..669461e5faf 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js @@ -50,7 +50,7 @@ var err = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { sample.copyWithin(0, o, err); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js index f310efc51a8..8ddad88eedf 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js @@ -40,7 +40,7 @@ features: [Symbol, TypedArray] var s = Symbol(1); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { sample.copyWithin(s, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js index 4cab84b69f6..b65cfef896c 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js @@ -44,7 +44,7 @@ var o = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { sample.copyWithin(o); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js index 4923c75fc6a..9bdf6ba5f3d 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js index 43f76ef31e2..ad8172ee571 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js @@ -36,7 +36,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample1 = new TA(); var result1 = sample1.copyWithin(0, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js index b11d4efdacf..99c53e8180d 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { copyWithin.call([], 0, 0); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { copyWithin.call(ab, 0, 0); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { copyWithin.call(dv, 0, 0); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js index 8053d705fdf..cabb8f7ff0c 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js @@ -39,7 +39,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA([0, 1, 2, 3]).copyWithin(0, 1, undefined), diff --git a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js index 95a8586723c..b4928bba49d 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js @@ -31,7 +31,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/iter-prototype.js index cf6d8f1d7eb..6ec4797b1ff 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/iter-prototype.js @@ -28,7 +28,7 @@ features: [BigInt, Symbol.iterator, TypedArray] var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([0n, 42n, 64n]); var iter = sample.entries(); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js index b1a66816a95..73b1163a743 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.entries description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-itor.js b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-itor.js index 13f44246924..f90280a747c 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-itor.js @@ -25,7 +25,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var typedArray = new TA([0n, 42n, 64n]); var itor = typedArray.entries(); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js index 19468243978..eab5da76774 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js @@ -31,7 +31,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js index b4dd4cbac2e..52eba02ba0d 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js @@ -28,7 +28,7 @@ features: [Symbol.iterator, TypedArray] var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([0, 42, 64]); var iter = sample.entries(); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer.js index a6698383eec..4c4756b3f39 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/resizable-buffer.js @@ -34,7 +34,7 @@ function ValuesFromSendableTypedArrayEntries(ta) { } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js index b856e793e3b..52cebd722cd 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js b/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js index d5130ad94d9..f7809af1c01 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js @@ -27,7 +27,7 @@ features: [TypedArray] var sample = [0, 42, 64]; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var typedArray = new TA(sample); var itor = typedArray.entries(); diff --git a/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js index b500e911114..1878d4236bb 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js @@ -46,12 +46,12 @@ assert.throws(TypeError, function() { entries.call([]); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { entries.call(ab); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { entries.call(dv); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js index 84e281942f8..6f198d9411d 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-with-thisarg.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js index 3ce7f8e5661..5248247a684 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-arguments-without-thisarg.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js index d7745a45fb0..ea8a0d1f60a 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-detachbuffer.js @@ -38,7 +38,7 @@ includes: [detachArrayBuffer.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js index 92bb1f4471b..6e40195c3bd 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-no-interaction-over-non-integer.js @@ -31,7 +31,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([7n, 8n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js index cd404fc8b56..88eaaed767d 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-callable-throws.js @@ -33,7 +33,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js index 374b8fef758..4117c1209bb 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-not-called-on-empty.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var called = 0; new TA().every(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js index b12c0376638..c021130519f 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-return-does-not-change-instance.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n]); sample.every(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js index 82307437d19..af61aa3ab9e 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-returns-abrupt.js @@ -37,7 +37,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js index c3db0a5ff24..d5dbe8ae0a2 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-set-value-during-interaction.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Reflect.set, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var newVal = 0n; diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-this.js index 8f689c2e306..6c2c2bff2a8 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/callbackfn-this.js @@ -43,7 +43,7 @@ features: [BigInt, TypedArray] var expected = (function() { return this; })(); var thisArg = {}; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); var results1 = []; diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/detached-buffer.js index ed39703a3ef..be303d48a7d 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/detached-buffer.js @@ -36,7 +36,7 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js index 23442513f1e..c383bad5b2b 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js @@ -43,7 +43,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n]); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js index 6c2baf7e1eb..bfef0b3b3ca 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.every description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js index e9f265ffc63..6b6f95f400a 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-false-if-any-cb-returns-false.js @@ -33,7 +33,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(42); [ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js index 955c3ea1917..3870a7ad3db 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/returns-true-if-every-cb-returns-true.js @@ -33,7 +33,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var called = 0; var values = [ true, diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/values-are-not-cached.js index c4e7be9f6d7..d8c301fafe1 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/values-are-not-cached.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); sample.every(function(v, i) { diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js index 83b95c96df0..2fc564816ef 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js index 49db00244a2..3eb667610a3 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js index ac0055c1e13..21564442900 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js @@ -38,7 +38,7 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js index 67eb0975edd..49f67632387 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js @@ -31,7 +31,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([7, 8]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js index 5dd8c8f62c0..95fea23fe1c 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js @@ -33,7 +33,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js index d46882a9b8f..91713cb6068 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var called = 0; new TA().every(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js index e243973c1c9..513b5f1ede2 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js @@ -21,14 +21,14 @@ features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js index 9a65acfea58..409f7dba1f8 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42]); sample.every(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js index 0bd927c490a..703c9678358 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js @@ -37,7 +37,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js index beeea7e5746..c7da59ae966 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [Reflect.set, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var newVal = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js index b082b5aa09e..c0759615406 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js @@ -43,7 +43,7 @@ features: [TypedArray] var expected = (function() { return this; })(); var thisArg = {}; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); var results1 = []; diff --git a/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js index b5be092e98c..4fab0451cd1 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js @@ -36,7 +36,7 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js index d19d0d7f1f6..4e3502c6e05 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js @@ -43,7 +43,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43]); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer.js index 3545f4c4872..7d9bd6036ee 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js index ee3252361f9..0fea952b636 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js b/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js index 420a81ccb42..ad529d73e19 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js @@ -33,7 +33,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(42); [ diff --git a/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js b/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js index cc0dc8a4475..1d28903bbbf 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js @@ -33,7 +33,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var called = 0; var values = [ true, diff --git a/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js index 8a0ad5cd215..2212e8a2133 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { every.call([], callbackfn); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { every.call(ab, callbackfn); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { every.call(dv, callbackfn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js index 6ad7094dcde..4efde1249b8 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); sample.every(function(v, i) { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/coerced-indexes.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/coerced-indexes.js index a5b3b2bd679..ef8a08449a6 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/coerced-indexes.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/coerced-indexes.js @@ -44,7 +44,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray(new TA([0n, 0n]).fill(1n, undefined), [1n, 1n]), '`undefined` start coerced to 0' diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/detached-buffer.js index c704df83bae..3c108af2aee 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/detached-buffer.js @@ -38,7 +38,7 @@ var obj = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js index 8e65038d939..ecb209433aa 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-conversion-once.js @@ -28,7 +28,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var n = 1n; diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js index 1c8637d5aaa..ab50201c747 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-custom-start-and-end.js @@ -46,7 +46,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert(compareArray(new TA([0n, 0n, 0n]).fill(8n, 1, 2), [0n, 8n, 0n])); assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -3, 4), [0n, 0n, 8n, 8n, 0n])); assert(compareArray(new TA([0n, 0n, 0n, 0n, 0n]).fill(8n, -2, -1), [0n, 0n, 0n, 8n, 0n])); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js index 3c53b2dae53..24197713100 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric-throw.js @@ -33,7 +33,7 @@ info: | If relativeEnd is -Infinity, let final be 0. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). Else, let final be min(relativeEnd, len). - If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. Repeat, while k < final, Let Pk be ! ToString(F(k)). Perform ! Set(O, Pk, value, true). @@ -45,7 +45,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedSendableArrayBuffer]]. + Let buffer be O.[[ViewedArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. @@ -60,7 +60,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA([42n]); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js index a4ab9ec324c..5b0fceaae09 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-non-numeric.js @@ -33,7 +33,7 @@ info: | If relativeEnd is -Infinity, let final be 0. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). Else, let final be min(relativeEnd, len). - If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. Repeat, while k < final, Let Pk be ! ToString(F(k)). Perform ! Set(O, Pk, value, true). @@ -45,7 +45,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedSendableArrayBuffer]]. + Let buffer be O.[[ViewedArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. @@ -59,7 +59,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA([42n]); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js index 8fcc142fde8..d889ed80f1e 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-end.js @@ -43,7 +43,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray(new TA([0n, 0n, 0n]).fill(8n, 0, 1), [8n, 0n, 0n]), "Fill elements from custom end position" diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js index bda20643be0..fb96a7be17a 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-relative-start.js @@ -41,7 +41,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray(new TA([0n, 0n, 0n]).fill(8n, 1), [0n, 8n, 8n]), "Fill elements from custom start position" diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js index bf4770a9374..98c5d56cefb 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values-symbol-throws.js @@ -33,7 +33,7 @@ info: | If relativeEnd is -Infinity, let final be 0. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). Else, let final be min(relativeEnd, len). - If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. Repeat, while k < final, Let Pk be ! ToString(F(k)). Perform ! Set(O, Pk, value, true). @@ -45,7 +45,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedSendableArrayBuffer]]. + Let buffer be O.[[ViewedArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. @@ -62,7 +62,7 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol('1'); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values.js index ede79153e26..6e5eb9fd854 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/fill-values.js @@ -41,7 +41,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { assert( compareArray( new TA().fill(8n), diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js index aaa00c906b4..543e1488723 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js @@ -46,7 +46,7 @@ Object.defineProperty(SendableTypedArray.prototype, "length", { } }); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { Object.defineProperty(TA.prototype, "length", { get: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js index a244569d38e..b971db3c52b 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end-as-symbol.js @@ -43,7 +43,7 @@ features: [BigInt, Symbol, TypedArray] var end = Symbol(1); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { sample.fill(1n, 0, end); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js index c714e60167d..c9b4da6595c 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-end.js @@ -47,7 +47,7 @@ var end = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { sample.fill(1n, 0, end); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js index d2603c2374a..0c63a002e07 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-set-value.js @@ -33,7 +33,7 @@ info: | If relativeEnd is -Infinity, let final be 0. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). Else, let final be min(relativeEnd, len). - If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. Repeat, while k < final, Let Pk be ! ToString(F(k)). Perform ! Set(O, Pk, value, true). @@ -45,7 +45,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedSendableArrayBuffer]]. + Let buffer be O.[[ViewedArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. @@ -60,7 +60,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n]); var obj = { valueOf: function() { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js index 5921bfb41c2..9f163792de1 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start-as-symbol.js @@ -42,7 +42,7 @@ features: [BigInt, Symbol, TypedArray] var start = Symbol(1); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { sample.fill(1n, start); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js index b98a7bba1ee..a92f3edd281 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-start.js @@ -46,7 +46,7 @@ var start = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { sample.fill(1n, start); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js index 21f2d1cc5fd..0e5833c4313 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.fill description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-this.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-this.js index ebb178c8cba..6ef854fe04e 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-this.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-this.js @@ -21,7 +21,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample1 = new TA(); var result1 = sample1.fill(1n); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js b/test/sendable/builtins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js index 047ce0b38f2..9f13ee55a91 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/absent-indices-computed-from-initial-length.js @@ -36,7 +36,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new SendableArrayBuffer(1, {maxByteLength: 4}); +let rab = new ArrayBuffer(1, {maxByteLength: 4}); let ta = new Int8Array(rab); let value = { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js index 1446d7988a7..7ddc9bb7fa4 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js @@ -21,13 +21,13 @@ info: | 22.2.3.8 %SendableTypedArray%.prototype.fill (value [ , start [ , end ] ] ) 9. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len). - 10. If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. + 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(10); function detachAndReturnIndex(){ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js index 4080e4935d3..bf1f5ce4c9d 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js @@ -44,7 +44,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray(new TA([0, 0]).fill(1, undefined), [1, 1]), '`undefined` start coerced to 0' diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js index 0b5312682ac..e926f2a9350 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js @@ -22,13 +22,13 @@ info: | 6. Let relativeStart be ? ToInteger(start). ... - 10. If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. + 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(10); function detachAndReturnIndex(){ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js index 744081bd942..9db68a2c4e1 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js @@ -22,13 +22,13 @@ info: | 5. Otherwise, set value to ? ToNumber(value). ... - 10. If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. + 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(10); function detachAndReturnIndex(){ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-start-end-resize.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-start-end-resize.js index 845f9157783..b3d192310af 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-start-end-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-start-end-resize.js @@ -31,7 +31,7 @@ function SendableTypedArrayFillHelper(ta, n, start, end) { } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const evil = { valueOf: () => { @@ -44,7 +44,7 @@ for (let ctor of ctors) { }); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const evil = { valueOf: () => { @@ -57,7 +57,7 @@ for (let ctor of ctors) { }); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const evil = { valueOf: () => { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js index 52a28e2bedb..d7e275091f8 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js @@ -38,7 +38,7 @@ var obj = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js index 6c5811146b3..122f4b0a08c 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js @@ -27,7 +27,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var n = 1; diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js index 021432ee980..e1aafccf36e 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js @@ -85,7 +85,7 @@ includes: [nans.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(FA) { +testWithTypedArrayConstructors(function(FA) { var precision = floatSendableTypedArrayConstructorPrecision(FA); var samples = new FA(3); var controls, idx, aNaN; diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js index 40777457a7f..bbff3e1dcc9 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js @@ -46,7 +46,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert(compareArray(new TA([0, 0, 0]).fill(8, 1, 2), [0, 8, 0])); assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -3, 4), [0, 0, 8, 8, 0])); assert(compareArray(new TA([0, 0, 0, 0, 0]).fill(8, -2, -1), [0, 0, 0, 8, 0])); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js index 71bbf3dbfd5..2089d2e55d3 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js @@ -33,7 +33,7 @@ info: | If relativeEnd is -Infinity, let final be 0. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). Else, let final be min(relativeEnd, len). - If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. Repeat, while k < final, Let Pk be ! ToString(F(k)). Perform ! Set(O, Pk, value, true). @@ -45,7 +45,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedSendableArrayBuffer]]. + Let buffer be O.[[ViewedArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. @@ -60,7 +60,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA([42]); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js index ac59e14a13e..be13bf139d8 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js @@ -43,7 +43,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray(new TA([0, 0, 0]).fill(8, 0, 1), [8, 0, 0]), "Fill elements from custom end position" diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js index 7a2bd11ce17..7bc2970448b 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js @@ -41,7 +41,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray(new TA([0, 0, 0]).fill(8, 1), [0, 8, 8]), "Fill elements from custom start position" diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js index 1fe0eb4cf8c..097e35cfa72 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js @@ -33,7 +33,7 @@ info: | If relativeEnd is -Infinity, let final be 0. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). Else, let final be min(relativeEnd, len). - If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. Repeat, while k < final, Let Pk be ! ToString(F(k)). Perform ! Set(O, Pk, value, true). @@ -45,7 +45,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedSendableArrayBuffer]]. + Let buffer be O.[[ViewedArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. @@ -62,7 +62,7 @@ features: [Symbol, TypedArray] var s = Symbol('1'); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js index 15a7e2396c0..c9608503266 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js @@ -41,7 +41,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { assert( compareArray( new TA().fill(8), diff --git a/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js index ce57bfd8b42..43afa62a1e3 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js @@ -46,7 +46,7 @@ Object.defineProperty(SendableTypedArray.prototype, "length", { } }); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { Object.defineProperty(TA.prototype, "length", { get: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/fill/resizable-buffer.js index 8e2ce25d6b9..23aed70d3a1 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/resizable-buffer.js @@ -40,7 +40,7 @@ function SendableTypedArrayFillHelper(ta, n, start, end) { } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js index 5106304f51c..cd46f7712b4 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js @@ -43,7 +43,7 @@ features: [Symbol, TypedArray] var end = Symbol(1); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { sample.fill(1, 0, end); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js index 6e6f58f648e..554dd400e1f 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js @@ -47,7 +47,7 @@ var end = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { sample.fill(1, 0, end); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js index b5882acc25c..72c207a74da 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js @@ -33,7 +33,7 @@ info: | If relativeEnd is -Infinity, let final be 0. Else if relativeEnd < 0, let final be max(len + relativeEnd, 0). Else, let final be min(relativeEnd, len). - If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. Repeat, while k < final, Let Pk be ! ToString(F(k)). Perform ! Set(O, Pk, value, true). @@ -45,7 +45,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedSendableArrayBuffer]]. + Let buffer be O.[[ViewedArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. @@ -60,7 +60,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42]); var obj = { valueOf: function() { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js index d545699126c..c3222fb0107 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js @@ -42,7 +42,7 @@ features: [Symbol, TypedArray] var start = Symbol(1); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { sample.fill(1, start); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js index 18d3da40835..ec09a78740b 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js @@ -46,7 +46,7 @@ var start = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { sample.fill(1, start); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js index a543925a375..d7cb3690d0b 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-this.js b/test/sendable/builtins/TypedArray/prototype/fill/return-this.js index 106481375c0..7be32b1da49 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-this.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-this.js @@ -21,7 +21,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample1 = new TA(); var result1 = sample1.fill(1); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js index 95578ca769f..e7570e28b8f 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { fill.call([], 0); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { fill.call(ab, 0); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { fill.call(dv, 0); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js index db4a7f851ba..46fd240b337 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js @@ -36,7 +36,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(4); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js index e706b43c84b..43c8811659f 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-with-thisarg.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js index f3924fe8aaf..889f275079a 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-arguments-without-thisarg.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js index 021531c3f86..7c9aa7fff3c 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-ctor.js @@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var length = 42; var sample = new TA(length); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js index 9496b5a96d7..89ac7d5f609 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-called-before-species.js @@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var length = 42; var sample = new TA(length); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js index 50610e89fd9..8cf5fe42592 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js @@ -30,7 +30,7 @@ includes: [detachArrayBuffer.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js index 9c3f2ffce3d..30aee4f5d2d 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-no-iteration-over-non-integer.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([7n, 8n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js index dfcd5741d99..c8e196402fd 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-callable-throws.js @@ -26,7 +26,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(4); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js index 2701ed3e464..9a1db8b8cc7 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-not-called-on-empty.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var called = 0; new TA().filter(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js index 92ddae69b0e..3b4d74898f8 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-return-does-not-change-instance.js @@ -21,7 +21,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample1 = new TA(3); sample1[1] = 1n; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js index 8d22092a6ed..7522678381c 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-returns-abrupt.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js index fd72aac31ad..11680d0e49a 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-set-value-during-iteration.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Reflect.set, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var newVal = 0n; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-this.js index e9ee24e5219..c912206fbf5 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-this.js @@ -34,7 +34,7 @@ features: [BigInt, TypedArray] var expected = (function() { return this; })(); var thisArg = {}; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); var results1 = []; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/detached-buffer.js index d2124643524..12ed1cc9065 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/detached-buffer.js @@ -36,7 +36,7 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js index 8a0b4e64364..086dbf13e86 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-does-not-share-buffer.js @@ -28,7 +28,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n]); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js index dfaa571afa7..c657bf0732e 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-empty-callbackfn-returns-false.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); [ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js index 82b40ec7a0a..dda6b5bca43 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/result-full-callbackfn-returns-true.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n]); [ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js index 8b916389eeb..57a1a0e2d38 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.filter description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-destination-resizable.js index 36560fbd3cb..44c44ca8c87 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-destination-resizable.js @@ -40,10 +40,10 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { - const rab1 = new SendableArrayBuffer(8, {maxByteLength: 100}); +testWithBigIntTypedArrayConstructors(function(TA) { + const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); const ta = new TA(rab1); - const rab2 = new SendableArrayBuffer(10, {maxByteLength: 20}); + const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab2); rab2.resize(0); ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js index b6006fa20c8..bc49fc49c07 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-abrupt.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); Object.defineProperty(sample, "constructor", { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js index 05f2b3521ed..a099d9ccab2 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-inherited.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js index eccbfb4523a..1e7bf06ebe4 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor-returns-throws.js @@ -43,7 +43,7 @@ features: [BigInt, Symbol, TypedArray] var callbackfn = function() { return true; }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); sample.constructor = 42; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js index 00c3e8240e2..08101a2dba5 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-ctor.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js index 27e10f046ce..2b9aa443b0c 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-abrupt.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js index 032ab01cf45..7b30f556bee 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-invocation.js @@ -49,7 +49,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 42n, 42n]); var result, ctorThis; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index 8c27ddb1091..315ba7414e0 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -40,9 +40,9 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); - const rab = new SendableArrayBuffer(10, {maxByteLength: 20}); + const rab = new ArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab); sample.constructor = {}; sample.constructor[Symbol.species] = function() { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js index 9058f162f1d..0634c019202 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length-throws.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js index c790ac2ecfe..4eb36c182eb 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-length.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var customCount, result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js index 3b27ce7d7e8..9540da808da 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -49,7 +49,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n]); var otherTA = TA === BigInt64Array ? BigUint64Array : BigInt64Array; var other = new otherTA([1n, 0n, 1n]); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js index 00725953d8d..641135030a1 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor-throws.js @@ -47,7 +47,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js index db2c20914dc..bbe6d772567 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-custom-ctor.js @@ -49,7 +49,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n]); var calls = 0; var other, result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js index d91877d175d..750652fe39b 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-returns-throws.js @@ -42,7 +42,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js index 94a9c346c31..5214bce1b90 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species-use-default-ctor.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js index 5c1f0c840d5..96f9e1e1b82 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/speciesctor-get-species.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js index 008d1deae66..d034efa19c4 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-not-cached.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); sample.filter(function(v, i) { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-set.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-set.js index 185e0583846..0b46e2136e2 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-set.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/values-are-set.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([41n, 1n, 42n, 7n]); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js index 93e203643aa..79828f5e299 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js @@ -36,7 +36,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(4); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js index 788a8cab209..f848709dddc 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js index 6714f4f8afc..e2224e8071d 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js index afb4bbdd198..2326db0a583 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var length = 42; var sample = new TA(length); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js index 96482032861..1cdda61ac8a 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var length = 42; var sample = new TA(length); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js index 1e22c861f2a..ac98b50069f 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js @@ -30,7 +30,7 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js index 855feaa90dd..3ed9a62a80b 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([7, 8]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js index 5644dc1bebc..07688146999 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js @@ -26,7 +26,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(4); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js index e0b6b0a6157..bc2f78e14d3 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var called = 0; new TA().filter(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js index 22c6f0ff265..bf9f91b2a94 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js @@ -21,15 +21,15 @@ features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; var NaNvalue = isFloatSendableTypedArrayConstructor(TA) ? NaN : 0; - var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, finalResult, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js index d97f7e610f3..ae90606f568 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js @@ -21,7 +21,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample1 = new TA(3); sample1[1] = 1; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js index 9d60e5ecd74..6eae8eac053 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js index bb90c1ac644..9741a9efc99 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js] features: [Reflect.set, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var newVal = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js index 1e9e25db6b4..db91fb779cd 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js @@ -34,7 +34,7 @@ features: [TypedArray] var expected = (function() { return this; })(); var thisArg = {}; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); var results1 = []; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js index c4155ce1ac5..e2f736ea9f2 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js @@ -36,7 +36,7 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer.js index 69627eef937..cb903fc33fe 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js index fb6a545a4a7..44d0642068e 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js @@ -28,7 +28,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42]); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js b/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js index ae25a9ffb22..81258ce02c1 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); [ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js b/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js index 968d669e788..53db492e614 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js, compareArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42]); [ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js index d615388e699..bf5a05eae23 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js index b340770279b..f8913da540b 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js @@ -40,10 +40,10 @@ includes: [testTypedArray.js] features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { - const rab1 = new SendableArrayBuffer(8, {maxByteLength: 100}); +testWithTypedArrayConstructors(function(TA) { + const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); const ta = new TA(rab1); - const rab2 = new SendableArrayBuffer(10, {maxByteLength: 20}); + const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab2); rab2.resize(0); ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js index 775b0d5e95f..280480c8ca3 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); Object.defineProperty(sample, "constructor", { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js index 766ac4ed41b..fb398b9c270 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js index 58fe22e7f25..ba14d2c60e3 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js @@ -43,7 +43,7 @@ features: [Symbol, TypedArray] var callbackfn = function() { return true; }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); sample.constructor = 42; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js index 110f213487d..d979a188b37 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js index 4bebf086548..f8ce0c5a6cc 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js index 0975335f30c..0c923be4c34 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js @@ -49,7 +49,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 42, 42]); var result, ctorThis; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index 13a6db6617d..a7c4a2cd8ef 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -40,9 +40,9 @@ includes: [testTypedArray.js] features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); - const rab = new SendableArrayBuffer(10, {maxByteLength: 20}); + const rab = new ArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab); sample.constructor = {}; sample.constructor[Symbol.species] = function() { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js index b0f634a1606..b8881c7af68 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js index 1681221bd10..0feded854e2 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var customCount, result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js index 71b89c10e2d..951ae3a46cc 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -49,7 +49,7 @@ includes: [testTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40]); var otherTA = TA === Int8Array ? Int16Array : Int8Array; var other = new otherTA([1, 0, 1]); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js index 2ca18b4b67a..32580e45f3e 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js @@ -47,7 +47,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js index 03996c21d22..dae1f2f6793 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js @@ -49,7 +49,7 @@ includes: [testTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42]); var calls = 0; var other, result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js index d8b48236355..90b6c7b4a79 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js @@ -42,7 +42,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js index bc747ca1431..b0bcacd4624 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js index c5da28fcb1e..c18c95406e1 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js index 403c1cc5513..8f39352f8dd 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js @@ -47,12 +47,12 @@ assert.throws(TypeError, function() { filter.call([], callbackfn); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { filter.call(ab, callbackfn); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { filter.call(dv, callbackfn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js index fd64adc2977..70422b007c3 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); sample.filter(function(v, i) { diff --git a/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js b/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js index fe4550f09d1..6c16baa74f5 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([41, 1, 42, 7]); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/detached-buffer.js index 818a3c19522..9f7692d1d51 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/detached-buffer.js @@ -36,7 +36,7 @@ var predicate = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js index 1ce4f8eeba2..6f7a19de20d 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js @@ -44,7 +44,7 @@ Object.defineProperty(SendableTypedArray.prototype, "length", { } }); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { Object.defineProperty(TA.prototype, "length", { get: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js index cd6b76dc003..5f02d662402 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-changes-value.js @@ -42,7 +42,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var arr = [1n, 2n, 3n]; var sample; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js index a48c1c1d869..8dafd4ece5d 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-parameters.js @@ -42,7 +42,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([39n, 2n, 62n]); var results = []; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js index 4e5e2bcce26..6a95abd387f 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-non-strict.js @@ -45,7 +45,7 @@ features: [BigInt, TypedArray] var T = this; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-strict.js index 44a83915738..3bb6873eeae 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-call-this-strict.js @@ -43,7 +43,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js index 99b8d1a0924..9bfa6dc579b 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-is-not-callable-throws.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js index d4a8a0a3023..f997d4f91ca 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-may-detach-buffer.js @@ -48,14 +48,14 @@ info: | IntegerIndexedElementGet ( O, index ) ... - Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js index 8d2617e61a3..15c7834e2b6 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/predicate-not-called-on-empty-array.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); var called = false; diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js index 4eea0c3025f..27019a22fee 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-predicate-call.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); var predicate = function() { diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js index f39a4b83c56..1ff33109e0f 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.find description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js index 4595e8d8ec7..b037e77d1a7 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-found-value-predicate-result-is-true.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([39n, 2n, 62n]); var called, result; diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js index 9519c80fdd9..a67c918a52b 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-undefined-if-predicate-returns-false-value.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); var called = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js index 607fde4ee38..298f8ec5995 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js @@ -21,14 +21,14 @@ features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js index 0d26c336c9c..bdabd9fb03a 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js @@ -36,7 +36,7 @@ var predicate = function() { throw new Test262Error(); }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js index 439e9ecbab5..6898af21297 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js @@ -44,7 +44,7 @@ Object.defineProperty(SendableTypedArray.prototype, "length", { } }); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { Object.defineProperty(TA.prototype, "length", { get: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js index bb4c1691937..abc268d4b7d 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js @@ -42,7 +42,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var arr = [1, 2, 3]; var sample; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js index c98d8e4c4ec..01d3ddad58d 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js @@ -42,7 +42,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([39, 2, 62]); var results = []; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js index dfd5f783fa6..3c48f799a91 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js @@ -45,7 +45,7 @@ features: [TypedArray] var T = this; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js index 22252d5e621..53898d7f8cf 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js @@ -43,7 +43,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js index 4d61560fcb6..eaac7fea1d1 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js index 1c8c918a6c0..77a045fed8e 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js @@ -48,14 +48,14 @@ info: | IntegerIndexedElementGet ( O, index ) ... - Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js index 9c7fc711109..f797dcd7de1 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); var called = false; diff --git a/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer.js index c11c238c22f..5942f421719 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/find/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js index 185c124d50e..3a2e28aba16 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); var predicate = function() { diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js index 4789586547b..8cb9e206a28 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js index 37273089a65..8acdd2ad937 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([39, 2, 62]); var called, result; diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js index 8f0c4a4d442..ba9ac258ec2 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); var called = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js index 969880dbcf5..dc924b4cde0 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { find.call([], predicate); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { find.call(ab, predicate); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { find.call(dv, predicate); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js index 271d70b0411..e25bc0e87d1 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/detached-buffer.js @@ -36,7 +36,7 @@ var predicate = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js index c8b91bfe1b3..572bbdf38b2 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js @@ -42,7 +42,7 @@ Object.defineProperty(SendableTypedArray.prototype, "length", { } }); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { Object.defineProperty(TA.prototype, "length", { get: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js index c19c0bf59cc..94dcb2df541 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-changes-value.js @@ -38,7 +38,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var arr = [10n, 20n, 30n]; var sample; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js index 15dd2b3ad29..d60183624ba 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-parameters.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([39n, 2n, 62n]); var results = []; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js index 952cc84cdbf..370d70b3941 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js @@ -43,7 +43,7 @@ features: [BigInt, TypedArray] var T = this; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict.js index e5126ad4e2f..87f43cb329d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-strict.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js index a4b87ca0278..9c7dd86f098 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-is-not-callable-throws.js @@ -36,7 +36,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { sample.findIndex({}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js index 0422761cac4..f1974442c33 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js @@ -39,14 +39,14 @@ info: | 9.4.5.8 IntegerIndexedElementGet ( O, index ) ... - 3. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + 3. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var loops = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js index e6190884597..e6640ba4681 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-not-called-on-empty-array.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); var called = false; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js index 2e8b382c1e3..06eb505ab24 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-predicate-call.js @@ -43,7 +43,7 @@ var predicate = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(Test262Error, function() { sample.findIndex(predicate); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js index a766744a718..af70fd686c5 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.findindex description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js index 0cac30c67a6..c7d3c3f991a 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-index-predicate-result-is-true.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([39n, 3n, 9n]); var called = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js index c120f7df039..e361c7fae77 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([1n, 2n, 3n]); var called = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js index b307bc28aa0..d38d26ffb87 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js @@ -21,14 +21,14 @@ features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js index adf2ffdcb83..5f785cb7709 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js @@ -36,7 +36,7 @@ var predicate = function() { throw new Test262Error(); }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js index 2e8972fc609..f83d77d25c5 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js @@ -42,7 +42,7 @@ Object.defineProperty(SendableTypedArray.prototype, "length", { } }); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { Object.defineProperty(TA.prototype, "length", { get: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js index d891dbd598c..af5748409a9 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js @@ -38,7 +38,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var arr = [10, 20, 30]; var sample; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js index 2c743ab07e9..13cb4752f87 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([39, 2, 62]); var results = []; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js index 74cd8dea116..4b55f40dccf 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js @@ -43,7 +43,7 @@ features: [TypedArray] var T = this; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js index 9dba29e8469..dfb3061e075 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js index 6c449cccd0d..f4e24de54e0 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js @@ -36,7 +36,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { sample.findIndex({}); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js index 05c28a15e8b..e90400a2d0b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js @@ -37,14 +37,14 @@ info: | IntegerIndexedElementGet ( O, index ) - Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var loops = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js index a29c4690859..0b7925c032b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); var called = false; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer.js index 00cee504fed..3c472987206 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js index 13d694bec45..1422fabc778 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js @@ -43,7 +43,7 @@ var predicate = function() { throw new Test262Error(); }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(Test262Error, function() { sample.findIndex(predicate); diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js index c2c999868c4..8bde234d8eb 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js index d9b82044dee..46ee513ac63 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([39, 3, 9]); var called = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js index f4aef2d5c58..1a51cfe14f2 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([1, 2, 3]); var called = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js index fbdf72a9596..d2c9fb3c3ed 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { findIndex.call([], predicate); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { findIndex.call(ab, predicate); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { findIndex.call(dv, predicate); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/detached-buffer.js index 5623c1f2ae8..2ca1044eb06 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/detached-buffer.js @@ -34,7 +34,7 @@ var predicate = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js index 1cf9e43f41e..85279af8845 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js @@ -33,7 +33,7 @@ Object.defineProperty(SendableTypedArray.prototype, "length", { } }); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { Object.defineProperty(TA.prototype, "length", { get: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js index d48dd8c884a..57d80144094 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-changes-value.js @@ -30,7 +30,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var arr = [1n, 2n, 3n]; var sample; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js index d1e19a9b6af..b7e6b7c4d6d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-parameters.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([39n, 2n, 62n]); var results = []; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js index 1389fbe0319..7bfd22ed864 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js @@ -31,7 +31,7 @@ features: [BigInt, SendableTypedArray, array-find-from-last] var T = this; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict.js index 2d7af1778f8..732fd2a653b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-strict.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js index dfac2ea30b1..b21559fa735 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-is-not-callable-throws.js @@ -27,7 +27,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js index 01f2e878adb..7759d963767 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js @@ -30,14 +30,14 @@ info: | IntegerIndexedElementGet ( O, index ) ... - Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js index da6868d68ca..cde5b85b2e0 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-not-called-on-empty-array.js @@ -28,7 +28,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); var called = false; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js index b3c7a3b7a99..ed410e2d0ed 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-predicate-call.js @@ -28,7 +28,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); var predicate = function() { diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js index 9cdc9f31276..6b5ca651a39 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.findlast description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, array-find-from-last, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, array-find-from-last, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js index 1e9ec140629..720796074ad 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-found-value-predicate-result-is-true.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([39n, 2n, 62n]); var called, result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js index b17b8299fba..09090889f93 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-undefined-if-predicate-returns-false-value.js @@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); var called = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js index 7a89e1c68ee..7bbce3b0f27 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js @@ -21,14 +21,14 @@ features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var secondElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js index 02dd8fa3a7c..37042b1f9b0 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js @@ -34,7 +34,7 @@ var predicate = function() { throw new Test262Error(); }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js index d30cf2ca1b7..a568d7cb01c 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js @@ -32,7 +32,7 @@ Object.defineProperty(SendableTypedArray.prototype, "length", { } }); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { Object.defineProperty(TA.prototype, "length", { get: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js index 99f70a5a8bf..79850e6cf3d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js @@ -30,7 +30,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var arr = [1, 2, 3]; var sample; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js index 0ac4e56db1e..07510070b87 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([39, 2, 62]); var results = []; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js index d96849c1964..1cb954881fb 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js @@ -31,7 +31,7 @@ features: [TypedArray, array-find-from-last] var T = this; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js index 842832d7b60..a8be0a4bc94 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js index 1f31e09159d..d1274b65542 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js @@ -27,7 +27,7 @@ includes: [testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js index f5d6066fb6f..969014edeba 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js @@ -30,14 +30,14 @@ info: | IntegerIndexedElementGet ( O, index ) ... - Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js index d4e0150d095..90b0ccb9624 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js @@ -28,7 +28,7 @@ includes: [testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); var called = false; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer.js index 5c97ec610b8..9273ca06006 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js index fe2000d0439..485cf4ef296 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js @@ -28,7 +28,7 @@ includes: [testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); var predicate = function() { diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js index d1b6a957323..6cbd1bf89ca 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js index 875ed9c1e7d..cc9c7a2ca0b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js] features: [Symbol, SendableTypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([39, 2, 62]); var called, result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js index 4d0e7a0fc82..d1394d6bd73 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [Symbol, SendableTypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); var called = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js index 61ff1e0ca17..b830c252f51 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js @@ -43,12 +43,12 @@ assert.throws(TypeError, function() { findlast.call([], predicate); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { findlast.call(ab, predicate); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { findlast.call(dv, predicate); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js index 5a4e4efda4f..bc3da86ce8f 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js @@ -36,7 +36,7 @@ var predicate = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js index c75f03a3f81..43de6a866f7 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js @@ -33,7 +33,7 @@ Object.defineProperty(SendableTypedArray.prototype, "length", { } }); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { Object.defineProperty(TA.prototype, "length", { get: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js index 1cdea936b4a..6ab335a3177 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-changes-value.js @@ -29,7 +29,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var arr = [10n, 20n, 30n]; var sample; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js index f967a1278a4..9b8931ddb20 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-parameters.js @@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([39n, 2n, 62n]); var results = []; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js index 709cdf02dc3..18fbfbedb05 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js @@ -33,7 +33,7 @@ features: [BigInt, SendableTypedArray, array-find-from-last] var T = this; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict.js index aa0b6e11462..26fb4fad80e 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-strict.js @@ -31,7 +31,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js index 9a4ac7297f1..f5fa2aa1199 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-is-not-callable-throws.js @@ -27,7 +27,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { sample.findLastIndex({}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js index b98f9a29b4f..a037ac1a245 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js @@ -29,14 +29,14 @@ info: | IntegerIndexedElementGet ( O, index ) - Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var loops = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js index a389b9102a9..743f4b0099d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-not-called-on-empty-array.js @@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); var called = false; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js index adba841a034..af348d51026 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-predicate-call.js @@ -34,7 +34,7 @@ var predicate = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(Test262Error, function() { sample.findLastIndex(predicate); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js index c36007ad173..ace5d4b9875 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.findlastindex description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, array-find-from-last, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, array-find-from-last, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js index 5a0532baaee..e030426cdb6 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-index-predicate-result-is-true.js @@ -31,7 +31,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([39n, 3n, 9n]); var called = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js index 553b6d54174..cccc55af459 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-negative-one-if-predicate-returns-false-value.js @@ -31,7 +31,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([1n, 2n, 3n]); var called = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js index 91bef630442..74ff46cfb48 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js @@ -21,14 +21,14 @@ features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var secondElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js index c9b6d6d99c8..8a1b88d8930 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js @@ -36,7 +36,7 @@ var predicate = function() { throw new Test262Error(); }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js index 0613a9fd03d..7ef9f96901e 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js @@ -33,7 +33,7 @@ Object.defineProperty(SendableTypedArray.prototype, "length", { } }); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { Object.defineProperty(TA.prototype, "length", { get: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js index 4811f00dd1f..6cae90618e4 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js @@ -29,7 +29,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var arr = [10, 20, 30]; var sample; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js index a8d5df611f6..6eaff86fcdc 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([39, 2, 62]); var results = []; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js index ebed22fe8f5..b483310b7c2 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js @@ -33,7 +33,7 @@ features: [TypedArray, array-find-from-last] var T = this; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js index 91e4150d242..1186825a747 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js @@ -31,7 +31,7 @@ includes: [testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js index 56004040415..39b192480be 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js @@ -27,7 +27,7 @@ includes: [testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { sample.findLastIndex({}); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js index 143848f51f7..0025e34ef64 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js @@ -29,14 +29,14 @@ info: | IntegerIndexedElementGet ( O, index ) - Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var loops = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js index 896e55b8452..2761cda4fac 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); var called = false; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer.js index 9c8ad827b17..c78c04848a2 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js index bf19545c1b6..f7c5cfc7048 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js @@ -34,7 +34,7 @@ var predicate = function() { throw new Test262Error(); }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(Test262Error, function() { sample.findLastIndex(predicate); diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js index aae3f0dc2d7..80eb992a846 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js index 2f60ffde4db..a4567c3183b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js @@ -31,7 +31,7 @@ includes: [testTypedArray.js] features: [Symbol, SendableTypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([39, 3, 9]); var called = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js index a75d3f96556..e871d2669f2 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js @@ -31,7 +31,7 @@ includes: [testTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([1, 2, 3]); var called = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js index 51a85d09c4e..04fdb37d95a 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { findLastIndex.call([], predicate); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { findLastIndex.call(ab, predicate); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { findLastIndex.call(dv, predicate); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js index b8c8cb92232..3eb40e69276 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/arraylength-internal.js @@ -28,7 +28,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample1 = new TA(42); var loop = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js index aeeffd24978..41a58bb2469 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-with-thisarg.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js index bb6c56625b0..84c798c2f6a 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-arguments-without-thisarg.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js index a9b4a87c854..a8bcab95e6e 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-detachbuffer.js @@ -38,7 +38,7 @@ includes: [detachArrayBuffer.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js index 29a496b4f4e..3fc179f2f55 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-is-not-callable.js @@ -34,7 +34,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js index 5b31f0d069a..d1d4946c699 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-no-interaction-over-non-integer.js @@ -31,7 +31,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([7n, 8n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js index 98222e7cd5c..2695f5843d9 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-not-called-on-empty.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var called = 0; new TA().forEach(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js index 92b2c069a58..013d2f6f71d 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-return-does-not-change-instance.js @@ -28,7 +28,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample1 = new TA(3); sample1[1] = 1n; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js index 2a4e5edd65c..53024452bd6 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-returns-abrupt.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js index c8282741f9a..c06a2f8739f 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-set-value-during-interaction.js @@ -28,7 +28,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Reflect.set, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var newVal = 0n; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js index ccaae25443d..7dd8ffa0554 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/callbackfn-this.js @@ -43,7 +43,7 @@ features: [BigInt, TypedArray] var expected = (function() { return this; })(); var thisArg = {}; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); var results1 = []; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/detached-buffer.js index fb106d8524f..a1cb8a9cf5a 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/detached-buffer.js @@ -36,7 +36,7 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js index 3f22b3af59c..83f944e3c79 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.foreach description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/returns-undefined.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/returns-undefined.js index bc60afafca0..1db950520aa 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/returns-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/returns-undefined.js @@ -28,7 +28,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample1 = new TA(42); var result1 = sample1.forEach(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js index 387f1358926..93582128b1b 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/values-are-not-cached.js @@ -28,7 +28,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); sample.forEach(function(v, i) { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js index e2fc16c34f6..1003e2e8419 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js @@ -28,7 +28,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample1 = new TA(42); var loop = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js index 93dd31cf2ba..73794c531a9 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js index fa9dbc67263..56d86fe0d69 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js index cef3c231e9a..938ce7c704c 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js @@ -38,7 +38,7 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js index 9990c375035..48af07517ea 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js @@ -34,7 +34,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js index e7f257781e2..737cf370005 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js @@ -31,7 +31,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([7, 8]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js index 940691237c7..5370be35fda 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var called = 0; new TA().forEach(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js index 4e938d4b93d..d77f43ef399 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js @@ -21,14 +21,14 @@ features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js index 00c3ebfcaad..b8cc7887a8e 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js @@ -28,7 +28,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample1 = new TA(3); sample1[1] = 1; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js index b45bd9ac9dd..c5c228dfad5 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js index 8c0c91d370e..5f78d9a25d4 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js @@ -28,7 +28,7 @@ includes: [testTypedArray.js] features: [Reflect.set, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var newVal = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js index 7e4d648c2e4..4f1097d045f 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js @@ -43,7 +43,7 @@ features: [TypedArray] var expected = (function() { return this; })(); var thisArg = {}; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); var results1 = []; diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js index 3c4adfe4a6c..34c08f97b47 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js @@ -36,7 +36,7 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer.js index bb8c6aa3def..8900ee3b3fd 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js index 664f34e2320..2abf87fe0de 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js b/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js index 0664b4c4128..be8d61fd01f 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js @@ -28,7 +28,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample1 = new TA(42); var result1 = sample1.forEach(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js index e02e41dc53f..2190aa884d0 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { forEach.call([], callbackfn); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { forEach.call(ab, callbackfn); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { forEach.call(dv, callbackfn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js index 69e33c1f859..f815237d520 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js @@ -28,7 +28,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); sample.forEach(function(v, i) { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js index 16980a0f4a0..e5b6d41965d 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-false-for-zero.js @@ -46,7 +46,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { const sample = new TA(1); const fromIndex = { valueOf() { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js index 95679e44e5f..5b27672ab78 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer-during-fromIndex-returns-true-for-undefined.js @@ -47,7 +47,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { const sample = new TA(1); const fromIndex = { valueOf() { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer.js index 3a091ab6b96..ba07e0335f5 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/detached-buffer.js @@ -32,7 +32,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js index b13d8349354..057c9a679e3 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-equal-or-greater-length-returns-false.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA(42); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js index cb382781844..0c045216f5d 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-infinity.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 43n, 41n]); assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js index ff121da9a41..e7119d04b9c 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/fromIndex-minus-zero.js @@ -36,7 +36,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA([42n, 43n]); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js index a6f2654bd32..7fd9ac35ed8 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js @@ -35,7 +35,7 @@ features: [BigInt, TypedArray] Object.defineProperty(SendableTypedArray.prototype, "length", {value: 0}); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([7n]); Object.defineProperty(TA.prototype, "length", {value: 0}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js index 6b1ce7eceff..90c0b8b0104 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/length-zero-returns-false.js @@ -40,7 +40,7 @@ var fromIndex = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.sameValue(sample.includes(0), false, "returns false"); assert.sameValue(sample.includes(), false, "returns false - no arg"); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js index a6dbaf75e51..28edbae3aac 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.includes description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js index 14104c0866c..a58d1bc0bf5 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex-symbol.js @@ -36,7 +36,7 @@ features: [BigInt, Symbol, TypedArray] var fromIndex = Symbol("1"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([7n]); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js index 4fa2df002d1..7e388beaab8 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-tointeger-fromindex.js @@ -40,7 +40,7 @@ var fromIndex = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([7n]); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js index 40379665d03..1f3f9ed3923 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-found-returns-true.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 42n, 41n]); assert.sameValue(sample.includes(42n), true, "includes(42)"); assert.sameValue(sample.includes(43n), true, "includes(43)"); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js index 91a2ee6b15f..9171b1ffa95 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/search-not-found-returns-false.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA([42n, 43n, 42n, 41n]); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js index b24702d5e73..e6105734b40 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/tointeger-fromindex.js @@ -47,7 +47,7 @@ var obj = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA([42n, 43n]); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/coerced-searchelement-fromindex-resize.js b/test/sendable/builtins/TypedArray/prototype/includes/coerced-searchelement-fromindex-resize.js index ab2d653cb30..c01138d2190 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/coerced-searchelement-fromindex-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/coerced-searchelement-fromindex-resize.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer, Array.prototype.includes] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { valueOf: () => { @@ -36,7 +36,7 @@ for (let ctor of ctors) { assert(fixedLength.includes(undefined, evil)); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { valueOf: () => { @@ -50,7 +50,7 @@ for (let ctor of ctors) { assert(!fixedLength.includes(n0, evil)); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); let evil = { valueOf: () => { @@ -63,7 +63,7 @@ for (let ctor of ctors) { assert(lengthTracking.includes(undefined, evil)); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, 1); @@ -80,7 +80,7 @@ for (let ctor of ctors) { assert(!lengthTracking.includes(n0, evil)); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); lengthTracking[0] = MayNeedBigInt(lengthTracking, 1); let evil = { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js index 4b6cbd23899..92c5698c16c 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js @@ -47,7 +47,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { const sample = new TA(1); const fromIndex = { valueOf() { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js index ee595c972dc..7b667e50042 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js @@ -47,7 +47,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { const sample = new TA(1); const fromIndex = { valueOf() { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js index c2fc8fbff9c..81a45329e84 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js @@ -32,7 +32,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js index bcd6216229b..f3da36c8c04 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA(42); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js index 90b546351ad..c1fb8892588 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 43, 41]); assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js index a47bf2d66eb..34bb880991b 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js @@ -36,7 +36,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA([42, 43]); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js index 948b4299ca0..8bc41698b6d 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js @@ -35,7 +35,7 @@ features: [TypedArray] Object.defineProperty(SendableTypedArray.prototype, "length", {value: 0}); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([7]); Object.defineProperty(TA.prototype, "length", {value: 0}); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js index 10a076f2748..fcc2ff61a9f 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length-out-of-bounds.js @@ -35,7 +35,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new SendableArrayBuffer(4, {maxByteLength: 20}); +let rab = new ArrayBuffer(4, {maxByteLength: 20}); // Uses byteOffset to make typed array out-of-bounds when shrinking size to zero. let byteOffset = 1; diff --git a/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length.js b/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length.js index 48bed4510ee..041bf90cd81 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/index-compared-against-initial-length.js @@ -35,7 +35,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new SendableArrayBuffer(4, {maxByteLength: 20}); +let rab = new ArrayBuffer(4, {maxByteLength: 20}); let ta = new Int8Array(rab); let index = { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js index 6ecc486bd48..54ef23bc92c 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js @@ -40,7 +40,7 @@ var fromIndex = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.sameValue(sample.includes(0), false, "returns false"); assert.sameValue(sample.includes(), false, "returns false - no arg"); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer-special-float-values.js b/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer-special-float-values.js index 8e5badda738..b48d15f0b55 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer-special-float-values.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer-special-float-values.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer, Array.prototype.includes] ---*/ for (let ctor of floatCtors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); lengthTracking[0] = -Infinity; lengthTracking[1] = Infinity; diff --git a/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer.js index 966d2c4e220..e32bbbdf2db 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer, Array.prototype.includes] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js index 60ec96b2383..601d1b96a44 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js index 7e517793220..14c6556e237 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js @@ -36,7 +36,7 @@ features: [Symbol, TypedArray] var fromIndex = Symbol("1"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([7]); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js index 1c64db0f548..8a15b008dc7 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js @@ -40,7 +40,7 @@ var fromIndex = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([7]); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js b/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js index da43b0f5660..cdc7f90a3a0 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js @@ -36,7 +36,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 0, 1, undefined]); assert.sameValue(sample.includes(), false, "no arg"); assert.sameValue(sample.includes(undefined), false, "undefined"); @@ -50,7 +50,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert.sameValue(sample.includes(""), false, "empty string"); }); -testWithSendableTypedArrayConstructors(function(FloatArray) { +testWithTypedArrayConstructors(function(FloatArray) { var sample = new FloatArray([42, 0, 1, undefined, NaN]); assert.sameValue(sample.includes(NaN), true, "NaN"); }, floatArrayConstructors); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js b/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js index cf725cedf79..a1a2ebd7a45 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 42, 41]); assert.sameValue(sample.includes(42), true, "includes(42)"); assert.sameValue(sample.includes(43), true, "includes(43)"); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js index fdbd16b64b5..003edd49396 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA([42, 43, 42, 41]); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js b/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js index dbe9872c82b..f1a9b09ed3d 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js @@ -31,7 +31,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(10); function throwFunc(){ throw Test262Error() diff --git a/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js index 31e97666da9..e09a0f3f19b 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { includes.call([], 42); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { includes.call(ab, 42); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { includes.call(dv, 42); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js index f32a3d7363d..6432aad9cbb 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js @@ -47,7 +47,7 @@ var obj = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA([42, 43]); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index 840564acdfb..b7583199da8 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -49,7 +49,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { const sample = new TA(1); const fromIndex = { valueOf() { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index 9bb06c44a06..dcee961c3ed 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -49,7 +49,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { const sample = new TA(1); const fromIndex = { valueOf() { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js index efb1b0d9591..7dff374fcb9 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/detached-buffer.js @@ -32,7 +32,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js index 57f1039e7c7..53bf0823475 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-equal-or-greater-length-returns-minus-one.js @@ -34,7 +34,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA(42); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js index 8690f73f20e..5f05c472344 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-infinity.js @@ -44,7 +44,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 43n, 41n]); assert.sameValue(sample.indexOf(43n, Infinity), -1, "indexOf(43, Infinity)"); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js index df532469410..10b2364a875 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/fromIndex-minus-zero.js @@ -34,7 +34,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA([42n, 43n]); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js index 59434ae057a..9a36898ab37 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js @@ -35,7 +35,7 @@ features: [BigInt, TypedArray] Object.defineProperty(SendableTypedArray.prototype, "length", {value: 0}); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([7n]); Object.defineProperty(TA.prototype, "length", {value: 0}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js index b63eb9f3fa9..b7456ad2147 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/length-zero-returns-minus-one.js @@ -40,7 +40,7 @@ var fromIndex = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.sameValue(sample.indexOf(0n), -1, "returns -1"); assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/no-arg.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/no-arg.js index 27089238321..c134e273733 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/no-arg.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/no-arg.js @@ -33,7 +33,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var ta1 = new TA(); assert.sameValue(ta1.indexOf(), -1); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js index 109f32b4105..8b0c04fc0b2 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.indexof description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js index 03f528bfacb..71454a440d0 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js @@ -36,7 +36,7 @@ features: [BigInt, Symbol, TypedArray] var fromIndex = Symbol("1"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js index 7763aa7aa2b..37c559ea771 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-tointeger-fromindex.js @@ -40,7 +40,7 @@ var fromIndex = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js index 70f94cf088f..491f73ca711 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-found-returns-index.js @@ -44,7 +44,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 42n, 41n]); assert.sameValue(sample.indexOf(42n), 0, "indexOf(42)"); assert.sameValue(sample.indexOf(43n), 1, "indexOf(43)"); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js index 2ee8bafda61..419db05fe23 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/search-not-found-returns-minus-one.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA([42n, 43n, 42n, 41n]); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js index cb70c9d8505..28aea42a465 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/tointeger-fromindex.js @@ -40,7 +40,7 @@ var obj = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA([42n, 43n]); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-grow.js b/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-grow.js index 2d59a411894..2ba98305b7e 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-grow.js @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // Growing + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, 1); @@ -43,7 +43,7 @@ for (let ctor of ctors) { // Growing + length-tracking TA, index conversion. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); lengthTracking[0] = MayNeedBigInt(lengthTracking, 1); let evil = { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-shrink.js b/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-shrink.js index e3ebaac62dd..4ec4529b8f5 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/coerced-searchelement-fromindex-shrink.js @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // Shrinking + fixed-length TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { valueOf: () => { @@ -38,7 +38,7 @@ for (let ctor of ctors) { assert.sameValue(fixedLength.indexOf(n0, evil), -1); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { valueOf: () => { @@ -54,7 +54,7 @@ for (let ctor of ctors) { // Shrinking + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index 140232716b9..0e93c17a9b9 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -49,7 +49,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { const sample = new TA(1); const fromIndex = { valueOf() { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index 6cdf4107777..3b32ed2c12a 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -49,7 +49,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { const sample = new TA(1); const fromIndex = { valueOf() { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js index 5a23869ce3d..9971111f943 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js @@ -32,7 +32,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js index a1ddfe9c292..1515b7dd4a3 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js @@ -34,7 +34,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA(42); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js index 60e39d69937..b9000479a91 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js @@ -44,7 +44,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 43, 41]); assert.sameValue(sample.indexOf(43, Infinity), -1, "indexOf(43, Infinity)"); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js index 330958a51f8..d9756dc8208 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js @@ -34,7 +34,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA([42, 43]); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js index 71570178934..b71ea7ba6f8 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js @@ -35,7 +35,7 @@ features: [TypedArray] Object.defineProperty(SendableTypedArray.prototype, "length", {value: 0}); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([7]); Object.defineProperty(TA.prototype, "length", {value: 0}); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js index 370b603de90..5369205d139 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js @@ -40,7 +40,7 @@ var fromIndex = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.sameValue(sample.indexOf(0), -1, "returns -1"); assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js b/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js index ecdee218d4e..450d5fc0a6f 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js @@ -33,7 +33,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var ta1 = new TA(); assert.sameValue(ta1.indexOf(), -1); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer-special-float-values.js b/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer-special-float-values.js index 79545a5ee8f..6b663679576 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer-special-float-values.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer-special-float-values.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer, Array.prototype.includes] ---*/ for (let ctor of floatCtors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); lengthTracking[0] = -Infinity; lengthTracking[1] = -Infinity; diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer.js index aef1b2222f3..ca25edfa599 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js index 622870658bc..75f90c0e2b8 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js index 324d3033f77..2e1bdc92eb3 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js @@ -36,7 +36,7 @@ features: [Symbol, TypedArray] var fromIndex = Symbol("1"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js index 89da9814db4..49fd3d8262c 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js @@ -40,7 +40,7 @@ var fromIndex = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js b/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js index 4fdc919cada..c04f2a39204 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js @@ -44,7 +44,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 42, 41]); assert.sameValue(sample.indexOf(42), 0, "indexOf(42)"); assert.sameValue(sample.indexOf(43), 1, "indexOf(43)"); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js index 367b1c95fd3..fc5e8eaa158 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA([42, 43, 42, 41]); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js b/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js index 213b596d7ca..b89431ebc89 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 0, 1, undefined, NaN]); assert.sameValue(sample.indexOf("42"), -1, "'42'"); assert.sameValue(sample.indexOf([42]), -1, "[42]"); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js index 6c84e3e4836..2a40fa43c6d 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { indexOf.call([], 42); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { indexOf.call(ab, 42); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { indexOf.call(dv, 42); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js index 84955b9b99c..ae91f34ff5f 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js @@ -40,7 +40,7 @@ var obj = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA([42, 43]); diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js index ae020285b97..44e4de57e00 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/custom-separator-result-from-tostring-on-each-simple-value.js @@ -42,7 +42,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([1n, 0n, 2n, 3n, 42n, 127n]); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js index 8909a261d89..dfd691cad21 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer-during-fromIndex-returns-single-comma.js @@ -42,7 +42,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { const sample = new TA([1n,2n,3n]); const separator = { toString() { diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer.js index 097b5a1ed87..21e774f050f 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/detached-buffer.js @@ -37,7 +37,7 @@ let obj = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { let sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, () => { diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js index 74718f29d14..102e17aaac4 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/empty-instance-empty-string.js @@ -34,7 +34,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.sameValue(sample.join(), ""); diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js index 31fb0f7b26a..9fbde2fd21d 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js @@ -45,7 +45,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n]); Object.defineProperty(TA.prototype, "length", desc); diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js index a48d4e9b7e2..aa6721fcf88 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/result-from-tostring-on-each-simple-value.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([1n, 0n, 2n, 3n, 42n, 127n]); var result = sample.join(); diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js index 2c2a87af075..5bf3e211819 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator-symbol.js @@ -36,7 +36,7 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol(""); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js index 113bb909968..88722e7bd82 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-separator.js @@ -40,7 +40,7 @@ var obj = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js index 1668736e5c6..fd27dfa0f74 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.join description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-grow.js b/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-grow.js index 1b9d0f4cf82..bad18fa5a28 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-grow.js @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // Growing + fixed-length TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { toString: () => { @@ -37,7 +37,7 @@ for (let ctor of ctors) { // Growing + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); let evil = { toString: () => { diff --git a/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-shrink.js b/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-shrink.js index 2a10f3b6889..da86fd705c2 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/join/coerced-separator-shrink.js @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // Shrinking + fixed-length TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { toString: () => { @@ -40,7 +40,7 @@ for (let ctor of ctors) { // Shrinking + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); let evil = { toString: () => { diff --git a/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js index 986864797bc..283f8875c68 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js @@ -42,7 +42,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([1, 0, 2, 3, 42, 127]); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js index 03a46ecc966..92d34428934 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js @@ -44,7 +44,7 @@ features: [TypedArray] var arr = [-2, Infinity, NaN, -Infinity, 0.6, 9007199254740992]; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(arr); var result, separator, expected; diff --git a/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js index 610e7275d1b..0da3e4c6e56 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js +++ b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js @@ -42,7 +42,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { const sample = new TA([1,2,3]); const separator = { toString() { diff --git a/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js index 877e2b17a3b..91891e49a81 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js @@ -37,7 +37,7 @@ let obj = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { let sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, () => { diff --git a/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js b/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js index a2e3f5ca33f..148996e1bb5 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js +++ b/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js @@ -34,7 +34,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.sameValue(sample.join(), ""); diff --git a/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js index 418b5836747..16f214b6e2e 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js @@ -45,7 +45,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43]); Object.defineProperty(TA.prototype, "length", desc); diff --git a/test/sendable/builtins/TypedArray/prototype/join/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/join/resizable-buffer.js index c45c35f66c8..3cabaaa3471 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/join/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js index dc85cf2ca9f..89828a16fd1 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([1, 0, 2, 3, 42, 127]); var result = sample.join(); diff --git a/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js index 590613be4ec..26bf20ca6a6 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js @@ -43,7 +43,7 @@ features: [TypedArray] var arr = [-2, Infinity, NaN, -Infinity, 0.6, 9007199254740992]; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(arr); // Use converted values using Array methods as helpers diff --git a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js index a8bc3977d5d..8397fda6d89 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js @@ -36,7 +36,7 @@ features: [Symbol, TypedArray] var s = Symbol(""); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js index f3eb9394d46..fcd35578522 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js +++ b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js @@ -40,7 +40,7 @@ var obj = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js index 139de343028..1b8b4a33215 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/join/separator-tostring-once-after-resized.js b/test/sendable/builtins/TypedArray/prototype/join/separator-tostring-once-after-resized.js index 3b136b9eaf1..0d2627a14ef 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/separator-tostring-once-after-resized.js +++ b/test/sendable/builtins/TypedArray/prototype/join/separator-tostring-once-after-resized.js @@ -30,7 +30,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new SendableArrayBuffer(3, {maxByteLength: 5}); +let rab = new ArrayBuffer(3, {maxByteLength: 5}); let ta = new Int8Array(rab); let callCount = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js index 1f2b462b4d4..adee1fd151e 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { join.call([], ""); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { join.call(ab, ""); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { join.call(dv, ""); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/detached-buffer.js index 3bd55d78c23..fd4069f1d12 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/detached-buffer.js @@ -31,7 +31,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/iter-prototype.js index 595baa6adab..97b254c93eb 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/iter-prototype.js @@ -28,7 +28,7 @@ features: [BigInt, Symbol.iterator, TypedArray] var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([0n, 42n, 64n]); var iter = sample.keys(); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js index 14a14f60c2c..588d1ccce68 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.keys description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-itor.js b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-itor.js index 935c357552d..f5d9fd6c7ad 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-itor.js @@ -27,7 +27,7 @@ features: [BigInt, TypedArray] var sample = [0n, 42n, 64n]; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var typedArray = new TA(sample); var itor = typedArray.keys(); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js index 4efd73cfebb..e9ebc9b9280 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js @@ -31,7 +31,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js index 73b8250fb00..325ea7b4181 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js @@ -28,7 +28,7 @@ features: [Symbol.iterator, TypedArray] var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([0, 42, 64]); var iter = sample.keys(); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer.js index 13002e0773a..807666f2068 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js index b11c1d43b90..3bd227f3ae5 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js b/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js index 3568f0039da..652243ea132 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js @@ -27,7 +27,7 @@ features: [TypedArray] var sample = [0, 42, 64]; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var typedArray = new TA(sample); var itor = typedArray.keys(); diff --git a/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js index 5cbde78d5a9..eec98e03624 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js @@ -46,12 +46,12 @@ assert.throws(TypeError, function() { keys.call([]); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { keys.call(ab); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { keys.call(dv); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index e9a7b18f3b5..e67cca0064e 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -46,7 +46,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { const sample = new TA(1); const fromIndex = { valueOf() { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index 673b709bd1c..37d9bf93dbf 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -46,7 +46,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { const sample = new TA(1); const fromIndex = { valueOf() { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js index 27100f8c96d..f44633e2961 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/detached-buffer.js @@ -32,7 +32,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js index b4ad5335913..e8d7520ecef 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-infinity.js @@ -37,7 +37,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 43n, 41n]); assert.sameValue(sample.lastIndexOf(43n, Infinity), 2, "lastIndexOf(43, Infinity)"); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js index 1a6d65e9554..94ff4ef2d7e 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/fromIndex-minus-zero.js @@ -34,7 +34,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA([42n, 43n]); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js index 2788e86411b..71d94789262 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js @@ -35,7 +35,7 @@ features: [BigInt, TypedArray] Object.defineProperty(SendableTypedArray.prototype, "length", {value: 0}); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([7n]); Object.defineProperty(TA.prototype, "length", {value: 0}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js index a7b20696b3d..5fc5afd8ee5 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/length-zero-returns-minus-one.js @@ -40,7 +40,7 @@ var fromIndex = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.sameValue(sample.lastIndexOf(0), -1, "returns -1"); assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js index bffff533ec1..d6080337a43 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/no-arg.js @@ -33,7 +33,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var ta1 = new TA(); assert.sameValue(ta1.lastIndexOf(), -1); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js index 4be062841cc..f3d8de2c7fc 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.lastindexof description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js index 360aa1f6d21..4a2f5ce214c 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex-symbol.js @@ -36,7 +36,7 @@ features: [BigInt, Symbol, TypedArray] var fromIndex = Symbol("1"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js index d13d7195edd..dd37f4d30c4 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-tointeger-fromindex.js @@ -40,7 +40,7 @@ var fromIndex = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js index 4dcf2d6a780..58b841a9ed2 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-found-returns-index.js @@ -43,7 +43,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 42n, 41n]); assert.sameValue(sample.lastIndexOf(42n), 2, "lastIndexOf(42)"); assert.sameValue(sample.lastIndexOf(43n), 1, "lastIndexOf(43)"); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js index 8b3ad8d3223..bace53fa44b 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/search-not-found-returns-minus-one.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA([42n, 43n, 42n, 41n]); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js index f3dfb9b0c6d..e8ebf61b2da 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/tointeger-fromindex.js @@ -40,7 +40,7 @@ var obj = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA([42n, 43n]); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-grow.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-grow.js index 4dfe58e889e..f99802a95a1 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-grow.js @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // Growing + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, 1); @@ -46,7 +46,7 @@ for (let ctor of ctors) { // Growing + length-tracking TA, index conversion. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); let evil = { valueOf: () => { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-shrink.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-shrink.js index 705d79d2b7a..5da326a35c7 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/coerced-position-shrink.js @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // Shrinking + fixed-length TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { valueOf: () => { @@ -38,7 +38,7 @@ for (let ctor of ctors) { assert.sameValue(fixedLength.lastIndexOf(n0, evil), -1); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let evil = { valueOf: () => { @@ -54,7 +54,7 @@ for (let ctor of ctors) { // Shrinking + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index 864ae25ae5e..2a395748411 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -46,7 +46,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { const sample = new TA(1); const fromIndex = { valueOf() { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index 2fef7d4ac97..b886ba1f3fe 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -46,7 +46,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { const sample = new TA(1); const fromIndex = { valueOf() { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js index 722d6109877..d28e206ee2d 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js @@ -32,7 +32,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js index f8110e1240b..e349f998bfc 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js @@ -37,7 +37,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 43, 41]); assert.sameValue(sample.lastIndexOf(43, Infinity), 2, "lastIndexOf(43, Infinity)"); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js index c0c4ee69797..26d7283836b 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js @@ -34,7 +34,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA([42, 43]); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js index c94f209a628..0371d9b78b4 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js @@ -35,7 +35,7 @@ features: [TypedArray] Object.defineProperty(SendableTypedArray.prototype, "length", {value: 0}); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([7]); Object.defineProperty(TA.prototype, "length", {value: 0}); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js index a965012ef09..9b4387a3aff 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js @@ -40,7 +40,7 @@ var fromIndex = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.sameValue(sample.lastIndexOf(0), -1, "returns -1"); assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js index d247f360d98..9463d900e26 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js @@ -33,7 +33,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var ta1 = new TA(); assert.sameValue(ta1.lastIndexOf(), -1); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer-special-float-values.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer-special-float-values.js index 48c30d995c0..31041e957dd 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer-special-float-values.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer-special-float-values.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer, Array.prototype.includes] ---*/ for (let ctor of floatCtors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); lengthTracking[0] = -Infinity; lengthTracking[1] = -Infinity; diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer.js index 842bc6c2746..131f1fab026 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js index 34e56243e33..18a555a8706 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.lastindexof description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js index 8a70c1e5835..21acf7926c1 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js @@ -36,7 +36,7 @@ features: [Symbol, TypedArray] var fromIndex = Symbol("1"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js index f5adf6128e0..62438fee3c7 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js @@ -40,7 +40,7 @@ var fromIndex = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js index 4c2ec9b1f24..98546f88d1b 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js @@ -43,7 +43,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 42, 41]); assert.sameValue(sample.lastIndexOf(42), 2, "lastIndexOf(42)"); assert.sameValue(sample.lastIndexOf(43), 1, "lastIndexOf(43)"); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js index 7824fa53433..b941407017d 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA([42, 43, 42, 41]); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js index 7bc4ad9706b..36b347e2004 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, undefined, NaN, 0, 1]); assert.sameValue(sample.lastIndexOf("42"), -1, "'42'"); assert.sameValue(sample.lastIndexOf([42]), -1, "[42]"); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js index bc896f0ba3b..7f71858ea51 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { lastIndexOf.call([], 42); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { lastIndexOf.call(ab, 42); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { lastIndexOf.call(dv, 42); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js index 959afab2346..871dd8b620a 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js @@ -40,7 +40,7 @@ var obj = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA([42, 43]); diff --git a/test/sendable/builtins/TypedArray/prototype/length/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/length/BigInt/detached-buffer.js index 7109d19f73c..666ef39e92e 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/length/BigInt/detached-buffer.js @@ -20,14 +20,14 @@ info: | 22.2.3.18 get %SendableTypedArray%.prototype.length ... - 5. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + 5. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 6. If IsDetachedBuffer(buffer) is true, return 0. ... includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(42); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.length, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js index 002a1fdd2f8..5016ca9b666 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-auto.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.length description: | - reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE); var expected = 3; diff --git a/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js index b34baf532f1..d76ed7a649d 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/length/BigInt/resizable-array-buffer-fixed.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.length description: | - reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); assert.sameValue(array.length, 2, "initial value"); diff --git a/test/sendable/builtins/TypedArray/prototype/length/BigInt/return-length.js b/test/sendable/builtins/TypedArray/prototype/length/BigInt/return-length.js index 57729f6e671..cdb44e28d1a 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/BigInt/return-length.js +++ b/test/sendable/builtins/TypedArray/prototype/length/BigInt/return-length.js @@ -32,7 +32,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var ta1 = new TA(); assert.sameValue(ta1.length, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js index 24d1ccc8af2..b1041d229ec 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js @@ -20,14 +20,14 @@ info: | 22.2.3.18 get %SendableTypedArray%.prototype.length ... - 5. Let buffer be the value of O's [[ViewedSendableArrayBuffer]] internal slot. + 5. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 6. If IsDetachedBuffer(buffer) is true, return 0. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(42); $DETACHBUFFER(sample.buffer); assert.sameValue(sample.length, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js index 1948de0fb70..ae4057279f7 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js @@ -16,7 +16,7 @@ /*--- esid: sec-get-%typedarray%.prototype.length description: > - Requires this value to have a [[ViewedSendableArrayBuffer]] internal slot + Requires this value to have a [[ViewedArrayBuffer]] internal slot info: | 22.2.3.17 get %SendableTypedArray%.prototype.length diff --git a/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js index ecfbe40b030..d8a3f402dfa 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.length description: | - reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE); var expected = 3; diff --git a/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js index d69be677095..7045ab8d062 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js @@ -16,21 +16,21 @@ /*--- esid: sec-get-%typedarray%.prototype.length description: | - reset to 0 if the underlying SendableArrayBuffer is resized beyond the boundary of + reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance includes: [testTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, "function"); +assert.sameValue(typeof ArrayBuffer.prototype.resize, "function"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); assert.sameValue(array.length, 2, "initial value"); diff --git a/test/sendable/builtins/TypedArray/prototype/length/resizable-buffer-assorted.js b/test/sendable/builtins/TypedArray/prototype/length/resizable-buffer-assorted.js index 9c5229771b6..4831e2d5775 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/resizable-buffer-assorted.js +++ b/test/sendable/builtins/TypedArray/prototype/length/resizable-buffer-assorted.js @@ -22,7 +22,7 @@ includes: [compareArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableSendableArrayBuffer(40, 80); +const rab = CreateResizableArrayBuffer(40, 80); for (let ctor of ctors) { const ta = new ctor(rab, 0, 3); assert.compareArray(ta.buffer, rab); diff --git a/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-1.js b/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-1.js index 2ffaadfd77f..0d4e1f8b36f 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-1.js +++ b/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-1.js @@ -22,7 +22,7 @@ includes: [compareArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableSendableArrayBuffer(16, 40); +const rab = CreateResizableArrayBuffer(16, 40); // Create TAs which cover the bytes 0-7. let tas_and_lengths = []; diff --git a/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-2.js b/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-2.js index 39cb0696be4..853f6391616 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-2.js +++ b/test/sendable/builtins/TypedArray/prototype/length/resized-out-of-bounds-2.js @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // Like resized-out-of-bounds-1.js but with offsets. -const rab = CreateResizableSendableArrayBuffer(20, 40); +const rab = CreateResizableArrayBuffer(20, 40); // Create TAs with offset, which cover the bytes 8-15. let tas_and_lengths = []; diff --git a/test/sendable/builtins/TypedArray/prototype/length/return-length.js b/test/sendable/builtins/TypedArray/prototype/length/return-length.js index 0f9af41a95a..1d36b2cc017 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/return-length.js +++ b/test/sendable/builtins/TypedArray/prototype/length/return-length.js @@ -32,7 +32,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var ta1 = new TA(); assert.sameValue(ta1.length, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js index 9a0a0128b0f..5852412a6e3 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js @@ -43,12 +43,12 @@ assert.throws(TypeError, function() { getter.call([]); }); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { getter.call(ab); }); -var dv = new DataView(new SendableArrayBuffer(8), 0); +var dv = new DataView(new ArrayBuffer(8), 0); assert.throws(TypeError, function() { getter.call(dv); }); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/arraylength-internal.js index d31da56662f..95c798bb1ac 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/arraylength-internal.js @@ -27,7 +27,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample1 = new TA(42); var loop = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js index 352e297353a..e1f07b5073d 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-with-thisarg.js @@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js index abf1c2273ef..076915e7770 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-arguments-without-thisarg.js @@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js index 531be9e6710..4233a03f1ea 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-detachbuffer.js @@ -30,7 +30,7 @@ includes: [detachArrayBuffer.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js index bad3a355e65..58ff9345b58 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-is-not-callable.js @@ -27,7 +27,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js index 3a3bfff72f3..f6025e8a64e 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-no-interaction-over-non-integer-properties.js @@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([7n, 8n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js index 9b74b4403f4..b67f086aea7 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-not-called-on-empty.js @@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var called = 0; new TA().map(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js index e6c820f52db..91abe46191b 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-affects-returned-object.js @@ -32,7 +32,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([1n, 2n, 4n]); var result = sample.map(function(v) { return v * 3n; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js index 926f1bbc568..394a4895f8f 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-change-instance.js @@ -23,7 +23,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample1 = new TA(3); sample1[1] = 1n; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js index cf69d929812..e176bc5b6fc 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-return-does-not-copy-non-integer-properties.js @@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([7n, 8n]); var bar = Symbol("1"); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js index ff490b2c719..b995c01245a 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-returns-abrupt.js @@ -24,7 +24,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js index a67387ade45..d141ad44d32 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-set-value-during-interaction.js @@ -23,7 +23,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Reflect.set, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var newVal = 0n; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-this.js index 021a346ea9a..3704267d186 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/callbackfn-this.js @@ -34,7 +34,7 @@ features: [BigInt, TypedArray] var expected = (function() { return this; })(); var thisArg = {}; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); var results1 = []; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/detached-buffer.js index 2c2c2c645ec..403b0973a60 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/detached-buffer.js @@ -36,7 +36,7 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js index 912a0785ea1..c6cb3deda6b 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.map description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js index 36ce72bb9fb..8291a905546 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-empty-length.js @@ -33,7 +33,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(0); var result = sample.map(function() {}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js index 17ef4f0dbf9..71e6a77048e 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-new-typedarray-from-positive-length.js @@ -33,7 +33,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); var result = sample.map(function(v) { diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-destination-resizable.js index b70a94f8db6..65abd0e870b 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-destination-resizable.js @@ -40,10 +40,10 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { - const rab1 = new SendableArrayBuffer(8, {maxByteLength: 100}); +testWithBigIntTypedArrayConstructors(function(TA) { + const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); const ta = new TA(rab1); - const rab2 = new SendableArrayBuffer(10, {maxByteLength: 20}); + const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab2); rab2.resize(0); ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js index 144807ecee9..6b43292e067 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-abrupt.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); var callCount = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js index 9f783e5b055..d4f8221bc11 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-inherited.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js index 9f9eb1f9814..2ed299f9a3a 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor-returns-throws.js @@ -43,7 +43,7 @@ features: [BigInt, Symbol, TypedArray] var callbackfn = function() { return 0n; }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); sample.constructor = 42; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js index 058b5e15d74..1945cc1db74 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-ctor.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js index f1e044305c1..f79442c3ec3 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-abrupt.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js index 98497c089fd..7b61bb19b01 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-invocation.js @@ -49,7 +49,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 42n, 42n]); var result, ctorThis; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index f604dc1510c..d923aa60333 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -40,9 +40,9 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { const sample = new TA(2); - const rab = new SendableArrayBuffer(10, {maxByteLength: 20}); + const rab = new ArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab); rab.resize(0); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js index 50143698fbb..0dc42863d4d 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length-throws.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js index 95c76a6b904..07a33b218cc 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-length.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var customCount, result; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js index 8a112bb94ba..c2896edc634 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -49,7 +49,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n]); var otherTA = TA === BigInt64Array ? BigUint64Array : BigInt64Array; var other = new otherTA([1n, 0n, 1n]); diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js index 05c7b78ff59..33b1e007591 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor-throws.js @@ -47,7 +47,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js index 32233257501..f8d44b67de6 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-custom-ctor.js @@ -49,7 +49,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n]); var calls = 0; var other, result; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js index babf827f91f..3a1ce20eb62 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-returns-throws.js @@ -42,7 +42,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js index 1bfcec3713b..beda5e72df6 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species-use-default-ctor.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js index 38f0a298ff1..e6b0fc66a47 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/speciesctor-get-species.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/values-are-not-cached.js index c495060d1f3..8227f925f35 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/values-are-not-cached.js @@ -23,7 +23,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); sample.map(function(v, i) { diff --git a/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js index 5f2754fc90b..0d0ee638b51 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js @@ -27,7 +27,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample1 = new TA(42); var loop = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js index 2bc552b73bf..b128222b262 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js index 6b4a754fe41..ee4b4513586 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js index 3a6a68b4aab..8031c36f980 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js @@ -30,7 +30,7 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js index 683f0339cbd..714cff6bf20 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js @@ -27,7 +27,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js index f3df1a68cef..facb1959e1e 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([7, 8]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js index a771196f5ea..4156caac76d 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var called = 0; new TA().map(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js index 51693a8416e..98c9cfc22c4 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js @@ -21,15 +21,15 @@ features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; var NaNvalue = isFloatSendableTypedArrayConstructor(TA) ? NaN : 0; - var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js index b79e4ab6620..47ea9990b94 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js @@ -32,7 +32,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([1, 2, 4]); var result = sample.map(function(v) { return v * 3; diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js index bdbdf423165..95deab0a95b 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js @@ -23,7 +23,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample1 = new TA(3); sample1[1] = 1; diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js index 22f9ece3336..22b4aabf10e 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([7, 8]); var bar = Symbol("1"); diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js index 290bf265d01..7dd9b4a9628 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js @@ -24,7 +24,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js index b57d1285633..7c33ef56dce 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js @@ -23,7 +23,7 @@ includes: [testTypedArray.js] features: [Reflect.set, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var newVal = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js index 5798a117844..714f8918ada 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js @@ -34,7 +34,7 @@ features: [TypedArray] var expected = (function() { return this; })(); var thisArg = {}; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); var results1 = []; diff --git a/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js index 8806833aae7..1af717dc160 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js @@ -36,7 +36,7 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer.js index 1344805bb0d..0dbff508023 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js index 3a3f73bcbed..49d086fbd64 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.map description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js index 063f8f90dc2..0177b2002cc 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js @@ -30,7 +30,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedSendableArrayBuffer]]. + Let buffer be O.[[ViewedArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. @@ -81,4 +81,4 @@ function body(FloatArray) { assert(compareArray(sampleBytes, resultBytes)); } -testWithSendableTypedArrayConstructors(body, floatArrayConstructors); +testWithTypedArrayConstructors(body, floatArrayConstructors); diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js index e9c6f9573df..bc6eecd8616 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js @@ -31,7 +31,7 @@ info: | Assert: O is an Integer-Indexed exotic object. If O.[[ContentType]] is BigInt, let numValue be ? ToBigInt(value). Otherwise, let numValue be ? ToNumber(value). - Let buffer be O.[[ViewedSendableArrayBuffer]]. + Let buffer be O.[[ViewedArrayBuffer]]. If IsDetachedBuffer(buffer) is false and ! IsValidIntegerIndex(O, index) is true, then Let offset be O.[[ByteOffset]]. Let arrayTypeName be the String value of O.[[TypedArrayName]]. diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js index 5eca79eafad..b76c7af38d9 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js @@ -33,7 +33,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(0); var result = sample.map(function() {}); diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js index b6946752484..e81d4d01aed 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js @@ -33,7 +33,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); var result = sample.map(function(v) { diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js index 456ed8e3268..1c24e146b8e 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js @@ -40,10 +40,10 @@ includes: [testTypedArray.js] features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { - const rab1 = new SendableArrayBuffer(8, {maxByteLength: 100}); +testWithTypedArrayConstructors(function(TA) { + const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); const ta = new TA(rab1); - const rab2 = new SendableArrayBuffer(10, {maxByteLength: 20}); + const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab2); rab2.resize(0); ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js index 510527aeb88..b41f6a83487 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); var callCount = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js index aeffe520d94..3d36f1e53c0 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js index 7fd3b9aba3c..b89ac9a7e40 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js @@ -43,7 +43,7 @@ features: [Symbol, TypedArray] var callbackfn = function() { return 0; }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); sample.constructor = 42; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js index 1d66f242462..069e857f8e3 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js index a082af3c5da..9e7446abdc3 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js index bfa7f5bbeb8..70fe4e1bcff 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js @@ -49,7 +49,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 42, 42]); var result, ctorThis; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index 8487610bf83..466a642e993 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -40,9 +40,9 @@ includes: [testTypedArray.js] features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { const sample = new TA(2); - const rab = new SendableArrayBuffer(10, {maxByteLength: 20}); + const rab = new ArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab); rab.resize(0); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js index 8229f215fd2..5a9a1e2cf00 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js index 9ba6f9b537c..82aae24970f 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var customCount, result; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js index 33cda479bb0..430a5dc9bc5 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -49,7 +49,7 @@ includes: [testTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40]); var otherTA = TA === Int8Array ? Int16Array : Int8Array; var other = new otherTA([1, 0, 1]); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js index 0134d64abb2..df39054360d 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js @@ -47,7 +47,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js index 17041b7f132..20a6d998772 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js @@ -49,7 +49,7 @@ includes: [testTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42]); var calls = 0; var other, result; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js index 0d2b069b8af..3b0f1649fe9 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js @@ -42,7 +42,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js index 095fb841b3e..5a4afbbc0cb 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js index 99fd886c1d8..196ecd858c1 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-grow.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-grow.js index 8c75785281a..81e9ddbd63c 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-grow.js @@ -41,7 +41,7 @@ function CollectWithUndefined(values) { } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const taWrite = new ctor(rab); for (let i = 0; i < 4; ++i) { taWrite[i] = MayNeedBigInt(taWrite, i); @@ -68,7 +68,7 @@ for (let ctor of ctors) { assert.sameValue(rab.byteLength, 6 * ctor.BYTES_PER_ELEMENT); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const taWrite = new ctor(rab); for (let i = 0; i < 4; ++i) { taWrite[i] = MayNeedBigInt(taWrite, i); diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-shrink.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-shrink.js index 35c4bcdaf3c..fc2eba27e6a 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-resizable-buffer-shrink.js @@ -41,7 +41,7 @@ function CollectWithUndefined(values) { } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); let resizeWhenConstructorCalled = false; class MyArray extends ctor { constructor(...params) { @@ -65,7 +65,7 @@ for (let ctor of ctors) { assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const taWrite = new ctor(rab); for (let i = 0; i < 4; ++i) { taWrite[i] = MayNeedBigInt(taWrite, i); diff --git a/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js index 8df30bfa45e..d41afb6ceaa 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { map.call([], callbackfn); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { map.call(ab, callbackfn); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { map.call(dv, callbackfn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js index bc4d4687905..b67820124aa 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js @@ -23,7 +23,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); sample.map(function(v, i) { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js index 3959cbb1ed1..25d92c990d3 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-custom-accumulator.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js index 604ecb9a5ad..f02383a6112 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-arguments-default-accumulator.js @@ -46,7 +46,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js index b132e5b482c..2ac487bd7d8 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-detachbuffer.js @@ -39,7 +39,7 @@ includes: [detachArrayBuffer.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js index 2cf35a071eb..be3833c4d84 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-is-not-callable-throws.js @@ -35,7 +35,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js index cf8390d9b2f..ccc8362d315 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-no-iteration-over-non-integer-properties.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([7n, 8n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js index 466450aec0b..e2a6d206096 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-not-called-on-empty.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var called = 0; new TA().reduce(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js index 1b89460398f..7c981ac565d 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-return-does-not-change-instance.js @@ -21,7 +21,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([0n, 1n, 0n]); sample.reduce(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js index 31fac08e3f3..59847f4d879 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-returns-abrupt.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js index 675a29fbcb6..ad9b9bf5217 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-set-value-during-iteration.js @@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Reflect.set, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var newVal = 0n; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js index 822202614e4..fa1d277ce8b 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/callbackfn-this.js @@ -41,7 +41,7 @@ features: [BigInt, TypedArray] var expected = (function() { return this; })(); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/detached-buffer.js index 9f64bd46861..e772df9a52e 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/detached-buffer.js @@ -36,7 +36,7 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js index cd2370572c3..20a7bfb845f 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-return-initialvalue.js @@ -43,7 +43,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var called = false; var result = new TA().reduce(function() { called = true; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js index c277b187d7a..2ff522b5834 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/empty-instance-with-no-initialvalue-throws.js @@ -34,7 +34,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var called = 0; assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js index 1c60e728447..754ac305f18 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js @@ -43,7 +43,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n]); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js index 387bbe1259e..47f53bcf4b4 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-is-last-callbackfn-return.js @@ -47,7 +47,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var calls, result; calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js index e381496c881..d7b088f8d26 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/result-of-any-type.js @@ -47,7 +47,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); [ ["test262", "string"], diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js index bbf05df36a6..296c2c0f55b 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.reduce description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js index 8275660e298..be1526999f0 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-first-value-without-callbackfn.js @@ -44,7 +44,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var called = false; var result = new TA([42n]).reduce(function() { called = true; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js index e883ae181ea..ac8b5b4310b 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/values-are-not-cached.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); sample.reduce(function(a, v, i) { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js index 223a41c9858..586e4f8efaf 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js index 1928c4d082a..3c088751f33 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js @@ -46,7 +46,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js index 466222143f2..6743c13aff3 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js @@ -39,7 +39,7 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js index ee38745b2f9..fc858df398a 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js @@ -35,7 +35,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js index 2440fb3f788..13aefd990b7 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([7, 8]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js index ef459de13fd..30a8fb490ff 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var called = 0; new TA().reduce(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js index 3a6ec1915eb..0d5245365ed 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js @@ -20,9 +20,9 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 3}); + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 3}); var sample = new TA(buffer); var finalNext, expectedPrevs, expectedNexts, expectedIndices, expectedArrays; var prevs, nexts, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js index bc6eb468bfb..b7bede57c6e 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js @@ -21,7 +21,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([0, 1, 0]); sample.reduce(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js index a1dd3424ab6..b047c9cc725 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js index c1c7be34851..b14c6e9fb06 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [Reflect.set, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var newVal = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js index 4a3c16b4523..d5b2a13849f 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js @@ -41,7 +41,7 @@ features: [TypedArray] var expected = (function() { return this; })(); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js index 6932201fe39..efb23c54d5a 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js @@ -36,7 +36,7 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js index 8c0a2b3f7bf..738954ff75d 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js @@ -43,7 +43,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var called = false; var result = new TA().reduce(function() { called = true; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js index fa02c933292..40427b79148 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js @@ -34,7 +34,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var called = 0; assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js index fbc17566c50..2314e94c652 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js @@ -43,7 +43,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43]); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer.js index f73a09c5d0e..78be73db3ff 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js b/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js index fe312115d55..ac4c5dcd444 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js @@ -47,7 +47,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var calls, result; calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js b/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js index 639fa397987..a6bb34c8cb8 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js @@ -47,7 +47,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); [ ["test262", "string"], diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js index 81b32b9b5d8..62325e74bb9 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.reduce description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js b/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js index 16f0d9bd193..9234fd8ac8f 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js @@ -44,7 +44,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var called = false; var result = new TA([42]).reduce(function() { called = true; diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js index d40e62435c7..bcfd5856759 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { reduce.call([], callbackfn); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { reduce.call(ab, callbackfn); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { reduce.call(dv, callbackfn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js index 1258b865eeb..3bfa7098d9f 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); sample.reduce(function(a, v, i) { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js index 0693424da55..0f3b520f278 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-custom-accumulator.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js index 84d317442ad..1d0626f56af 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-arguments-default-accumulator.js @@ -49,7 +49,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js index 4287349e835..cc3a270e5fb 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-detachbuffer.js @@ -39,7 +39,7 @@ includes: [detachArrayBuffer.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js index 4b4a9250777..708277c12c2 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-is-not-callable-throws.js @@ -35,7 +35,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js index a8c63164a0f..ca28b55c7f1 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-no-iteration-over-non-integer-properties.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([7n, 8n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js index f25a28d0598..9286bffbefc 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-not-called-on-empty.js @@ -42,7 +42,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var called = 0; new TA().reduceRight(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js index 68d293f6bbc..2048de957f1 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-return-does-not-change-instance.js @@ -21,7 +21,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([0n, 1n, 0n]); sample.reduceRight(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js index 69d2cb91bd5..afa4fb77083 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-returns-abrupt.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js index c031ff1f94e..f9761399a70 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-set-value-during-iteration.js @@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Reflect.set, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var newVal = 0n; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js index 5f09bd22462..58ea6af60c2 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/callbackfn-this.js @@ -42,7 +42,7 @@ features: [BigInt, TypedArray] var expected = (function() { return this; })(); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js index 3e8160a1564..4574c7e43c4 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/detached-buffer.js @@ -36,7 +36,7 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js index f802420ade4..8cac4a855ce 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-return-initialvalue.js @@ -44,7 +44,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var called = false; var result = new TA().reduceRight(function() { called = true; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js index bcaf40fc1c9..a5ca021869d 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/empty-instance-with-no-initialvalue-throws.js @@ -34,7 +34,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var called = 0; assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js index b1cf4f25d0e..a42d356a5e7 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js @@ -43,7 +43,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n]); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js index 753ec8cdcb0..badaefc1dad 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-is-last-callbackfn-return.js @@ -49,7 +49,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var calls, result; calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js index 27b0940f12f..066294989df 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/result-of-any-type.js @@ -49,7 +49,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); [ ["test262", "string"], diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js index ef9861400ad..fea17212ad6 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.reduceright description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js index 118fd31dabd..2b0e3108ee0 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-first-value-without-callbackfn.js @@ -45,7 +45,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var called = false; var result = new TA([42n]).reduceRight(function() { called = true; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js index e6f35db6bca..48cf996f292 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/values-are-not-cached.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([44n, 43n, 42n]); sample.reduceRight(function(a, v, i) { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js index fd4d430089d..59ae6f58da6 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js index 429f000b103..504a1519533 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js @@ -49,7 +49,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js index 06915052112..32f1602c2f8 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js @@ -39,7 +39,7 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js index 0f2c1a25015..586a6a56c76 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js @@ -35,7 +35,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js index 582f15b5892..f7d9f30d39a 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([7, 8]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js index a9a0a53d84d..4aca03052cb 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js @@ -42,7 +42,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var called = 0; new TA().reduceRight(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js index c298d6ecc60..7357bbacc95 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js @@ -20,9 +20,9 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 3}); + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 3}); var sample = new TA(buffer); var secondNext, expectedPrevs, expectedNexts, expectedIndices, expectedArrays; var prevs, nexts, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js index 2122aaf6bf0..41f6aaebdda 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js @@ -21,7 +21,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([0, 1, 0]); sample.reduceRight(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js index 36c34044450..51f0558c454 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js index ee9d3a73336..71044af53ee 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [Reflect.set, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var newVal = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js index 86a04c0eee0..df218241a22 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js @@ -42,7 +42,7 @@ features: [TypedArray] var expected = (function() { return this; })(); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js index 8e6e1688d11..452567c9802 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js @@ -36,7 +36,7 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js index 3a9994b0aec..614001d3b19 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js @@ -44,7 +44,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var called = false; var result = new TA().reduceRight(function() { called = true; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js index b87b7ff5921..aa8df89e7bf 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js @@ -34,7 +34,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var called = 0; assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js index 81c0ab53016..2b5a6c51a1e 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js @@ -43,7 +43,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43]); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer.js index e4e784e4721..f2d4358b68e 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js index 4b12a0d0303..61dab386e54 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js @@ -49,7 +49,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var calls, result; calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js index d5a3fb921fb..f0c6b28e051 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js @@ -49,7 +49,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); [ ["test262", "string"], diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js index 945ae4051af..b34716a9fcf 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.reduceright description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js index b5667f55bfd..7074c434f1f 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js @@ -45,7 +45,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var called = false; var result = new TA([42]).reduceRight(function() { called = true; diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js index 01eabdedd1f..0807f5da8b4 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { reduceRight.call([], callbackfn); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { reduceRight.call(ab, callbackfn); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { reduceRight.call(dv, callbackfn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js index ddf4e9297b5..34d29464fca 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([44, 43, 42]); sample.reduceRight(function(a, v, i) { diff --git a/test/sendable/builtins/TypedArray/prototype/resizable-and-fixed-have-same-prototype.js b/test/sendable/builtins/TypedArray/prototype/resizable-and-fixed-have-same-prototype.js index 6ef857e5bc1..ab5b3e85cb1 100644 --- a/test/sendable/builtins/TypedArray/prototype/resizable-and-fixed-have-same-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/resizable-and-fixed-have-same-prototype.js @@ -22,8 +22,8 @@ includes: [resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableSendableArrayBuffer(40, 80); -const ab = new SendableArrayBuffer(80); +const rab = CreateResizableArrayBuffer(40, 80); +const ab = new ArrayBuffer(80); for (let ctor of ctors) { const ta_rab = new ctor(rab, 0, 3); const ta_ab = new ctor(ab, 0, 3); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/detached-buffer.js index 245f2f062a7..524d78e3420 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/detached-buffer.js @@ -32,7 +32,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js index 662bcd8c22c..1a2b04e1e6d 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js @@ -43,7 +43,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n]); Object.defineProperty(TA.prototype, "length", desc); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js index 7e92c083e14..4297785b1d0 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/preserves-non-numeric-properties.js @@ -34,7 +34,7 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol("1"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample, result; sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js index d81ee679e5f..332cee2054a 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.reverse description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/returns-original-object.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/returns-original-object.js index 2844522d7d8..ec2c26cf1ca 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/returns-original-object.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/returns-original-object.js @@ -32,9 +32,9 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -var buffer = new SendableArrayBuffer(64); +var buffer = new ArrayBuffer(64); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample, result, expectedLength; sample = new TA(buffer, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/reverts.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/reverts.js index ce8abdb9356..869ced4576a 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/reverts.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/reverts.js @@ -32,9 +32,9 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -var buffer = new SendableArrayBuffer(64); +var buffer = new ArrayBuffer(64); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(buffer, 0, 4); var other = new TA(buffer, 0, 5); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js index f7e0caa2253..939d126ce9e 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js @@ -32,7 +32,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js index 2e3f9a51b49..a946b158bba 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js @@ -43,7 +43,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43]); Object.defineProperty(TA.prototype, "length", desc); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js b/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js index afba7793b91..65d35f2a618 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js @@ -34,7 +34,7 @@ features: [Symbol, TypedArray] var s = Symbol("1"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample, result; sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/reverse/resizable-buffer.js index a99c2c04bab..8d61aeb82ab 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js index 77997210d7d..5853aa07843 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js b/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js index 4e804a32c62..626255e3d5f 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js @@ -32,9 +32,9 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -var buffer = new SendableArrayBuffer(64); +var buffer = new ArrayBuffer(64); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample, result, expectedLength; sample = new TA(buffer, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js b/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js index e103d7d1d10..e2053ca6847 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js @@ -32,9 +32,9 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -var buffer = new SendableArrayBuffer(64); +var buffer = new ArrayBuffer(64); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(buffer, 0, 4); var other = new TA(buffer, 0, 5); diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js index e40bd7cb71a..476b5fe0554 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { reverse.call([]); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { reverse.call(ab); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { reverse.call(dv); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js index 355b1b24a89..2dc8d381c8e 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-negative-integer-offset-throws.js @@ -31,7 +31,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(4); assert.throws(RangeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js index 95ea6044c27..89bd0951372 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-offset-tointeger.js @@ -31,7 +31,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA([1n, 2n]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js index eeea0a84c70..fd5776362e7 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-primitive-toobject.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, SendableTypedArray, Symbol] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var ta1 = new TA([1n, 2n, 3n, 4n]); ta1.set("567"); assert.compareArray(ta1, [5n, 6n, 7n, 4n], "string"); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js index 9607189edad..b8285ea456d 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-length.js @@ -37,7 +37,7 @@ Object.defineProperty(obj, "length", { } }); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([1n, 2n, 3n]); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js index 4cb0a686007..31bda64db76 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-get-value.js @@ -35,7 +35,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var obj = { length: 4, "0": 42n, diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js index f1aa5794662..4b74474955a 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length-symbol.js @@ -34,7 +34,7 @@ var obj = { length: Symbol("1") }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([1n, 2n, 3n]); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js index 64ad6c0c81e..b54286ab708 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-length.js @@ -46,7 +46,7 @@ var obj2 = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([1n, 2n, 3n]); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js index bec32c94f82..c1f03ee64ab 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value-symbol.js @@ -35,7 +35,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var obj = { length: 4, "0": 42n, diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js index 4172819051e..7f9769098a5 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-src-tonumber-value.js @@ -35,7 +35,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var obj = { length: 4, "0": 42n, diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js index 99cef969c2d..8ea6f3cc343 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -31,7 +31,7 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol("1"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js index adaff35f18e..045b8b5cb48 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-tointeger-offset.js @@ -41,7 +41,7 @@ var obj2 = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js index 8f7d20990fc..0f96928606a 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-return-abrupt-from-toobject-offset.js @@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([1n, 2n, 3n]); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js index 03b3d357196..15de4ceb8f6 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values-in-order.js @@ -35,7 +35,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(5); var calls = []; var obj = { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values.js index 6569d003d2a..b3b65a13dc1 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-set-values.js @@ -35,7 +35,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var src = [42n, 43n]; var srcObj = { length: 2, diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js index aff5bca47d2..93c85671ccd 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-tonumber-value-type-conversions.js @@ -35,7 +35,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var obj1 = { valueOf: function() { return 42n; diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js index 8e7abd92581..b9f8c02f5bd 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-src-values-are-not-cached.js @@ -35,7 +35,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(5); var obj = { length: 5, diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js index b58669a8416..be1b1d42048 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js @@ -42,7 +42,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); Object.defineProperty(TA.prototype, "length", desc); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js index 2d65ebd1f52..e8ab57c1c15 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js @@ -26,7 +26,7 @@ info: | ... 6. Let targetOffset be ? ToInteger(offset). ... - 8. Let targetBuffer be the value of target's [[ViewedSendableArrayBuffer]] internal + 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal slot. 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. ... @@ -34,7 +34,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var calledOffset = 0; var obj = { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js index 902107b4ee4..0d6ed664799 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-targetbuffer-detached-throws.js @@ -24,7 +24,7 @@ info: | [[TypedArrayName]] internal slot. If it is such an Object, the definition in 22.2.3.23.2 applies. ... - 8. Let targetBuffer be the value of target's [[ViewedSendableArrayBuffer]] internal + 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal slot. 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. ... @@ -42,7 +42,7 @@ Object.defineProperty(obj, "length", { } }); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); $DETACHBUFFER(sample.buffer); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/boolean-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/boolean-tobigint.js index 1ef8c0a6a1a..8cc77e7e895 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/boolean-tobigint.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/boolean-tobigint.js @@ -50,7 +50,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var typedArray = new TA(2); typedArray.set([false, true]) diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/null-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/null-tobigint.js index db148722f34..4f127c55796 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/null-tobigint.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/null-tobigint.js @@ -50,7 +50,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var typedArray = new TA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/number-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/number-tobigint.js index ad99d47d029..e7316a118a7 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/number-tobigint.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/number-tobigint.js @@ -51,7 +51,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var typedArray = new TA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-big.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-big.js index 02ea3034a44..078707835bd 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-big.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-big.js @@ -36,11 +36,11 @@ var srcSendableTypedArray; var targetSendableTypedArray; var testValue = 42n; -testWithBigIntSendableTypedArrayConstructors(function(BTA1) { +testWithBigIntTypedArrayConstructors(function(BTA1) { srcSendableTypedArray = new BTA1([testValue]); - testWithBigIntSendableTypedArrayConstructors(function(BTA2) { + testWithBigIntTypedArrayConstructors(function(BTA2) { targetSendableTypedArray = new BTA2(1); targetSendableTypedArray.set(srcSendableTypedArray); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js index 096df4816e2..18dbf1b5c58 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js @@ -35,11 +35,11 @@ features: [BigInt, TypedArray] var bigSendableTypedArray; var littleSendableTypedArray; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { littleSendableTypedArray = new TA([1]); - testWithBigIntSendableTypedArrayConstructors(function(BTA) { + testWithBigIntTypedArrayConstructors(function(BTA) { bigSendableTypedArray = new BTA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js index 585dd3199c0..a2e46efd6c9 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-nan-tobigint.js @@ -53,7 +53,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var typedArray = new TA(1); assert.throws(SyntaxError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-tobigint.js index aae55b05fb3..04995724aef 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-tobigint.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/string-tobigint.js @@ -53,7 +53,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var typedArray = new TA(2); typedArray.set(['', '1']) diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/symbol-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/symbol-tobigint.js index 8b870ac29c5..701d0503444 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/symbol-tobigint.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/symbol-tobigint.js @@ -53,7 +53,7 @@ features: [BigInt, SendableTypedArray, Symbol] var s = Symbol() -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var typedArray = new TA(1) assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js index f80d3fb2240..cbf5812efb7 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-negative-integer-offset-throws.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(RangeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js index 27b020eec0a..8b41c64771e 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-offset-tointeger.js @@ -28,7 +28,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; var src = new TA([42n]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js index 14ae9b687a2..c482cfdd0bc 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -30,7 +30,7 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol("1"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js index b99358f4cdd..cebac1155c7 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-return-abrupt-from-tointeger-offset.js @@ -40,7 +40,7 @@ var obj2 = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js index 5248ebd7539..ce890267aa1 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type-sab.js @@ -19,11 +19,11 @@ description: > Set values from different instances using the different buffer and different type. includes: [testBigIntTypedArray.js, compareArray.js] -features: [BigInt, SharedSendableArrayBuffer, TypedArray] +features: [BigInt, SharedArrayBuffer, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { - var sab = new SharedSendableArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT); +testWithBigIntTypedArrayConstructors(function(TA) { + var sab = new SharedArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT); var otherCtor = TA === BigInt64Array ? BigUint64Array : BigInt64Array; var src = new otherCtor(sab); src[0] = 42n; @@ -47,7 +47,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { src = new BigInt64Array([42n, 43n]); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -57,7 +57,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42n, 43n, 3n, 4n]), "sample is SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -67,7 +67,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1n, 42n, 43n, 4n]), "sample is SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -77,13 +77,13 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1n, 2n, 42n, 43n]), "sample is SAB-backed, offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - var sab1 = new SharedSendableArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT); + var sab1 = new SharedArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT); src = new BigInt64Array(sab1); src[0] = 42n; src[1] = 43n; var sab2; - sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1n; sample[1] = 2n; @@ -93,7 +93,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src and sample are SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1n; sample[1] = 2n; @@ -103,7 +103,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src and sample are SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1n; sample[1] = 2n; diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js index 5a824bbef50..3ebeb20ff5c 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-other-type.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array; var src = new other([42n, 43n]); var sample, result; diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js index 13c6a469ce7..a4c7c59d8a0 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type-sab.js @@ -19,13 +19,13 @@ description: > Set values from different instances using the different buffer and same constructor. srcBuffer values are cached. includes: [testBigIntTypedArray.js, compareArray.js] -features: [BigInt, SharedSendableArrayBuffer, TypedArray] +features: [BigInt, SharedArrayBuffer, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample, result; - var sab = new SharedSendableArrayBuffer(2 * TA.BYTES_PER_ELEMENT); + var sab = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT); var src = new TA(sab); src[0] = 42n; src[1] = 43n; @@ -47,7 +47,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { src = new TA([42n, 43n]); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -57,7 +57,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1n, 42n, 43n, 4n]), "sample is SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -67,7 +67,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42n, 43n, 3n, 4n]), "sample is SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -78,13 +78,13 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert.sameValue(result, undefined, "returns undefined"); - var sab1 = new SharedSendableArrayBuffer(2 * TA.BYTES_PER_ELEMENT); + var sab1 = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT); src = new TA(sab1); src[0] = 42n; src[1] = 43n; var sab2; - sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1n; sample[1] = 2n; @@ -94,7 +94,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1n, 42n, 43n, 4n]), "src and sample are SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1n; sample[1] = 2n; @@ -104,7 +104,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42n, 43n, 3n, 4n]), "src and sample are SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1n; sample[1] = 2n; diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js index 5c07c8a06ee..a350c0dacb3 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-diff-buffer-same-type.js @@ -42,7 +42,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample, result; var src = new TA([42n, 43n]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js index 47012f18a3e..6a5d3f5079c 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-resized.js @@ -17,20 +17,20 @@ esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the same buffer and same - constructor when underlying SendableArrayBuffer has been resized + constructor when underlying ArrayBuffer has been resized includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var source = new TA(ab); var target = new TA(ab); var expected = [10, 20, 30, 40]; diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js index c1f705b7b8b..f1f1971c28f 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type-sab.js @@ -19,13 +19,13 @@ description: > Set values from different instances using the same buffer and same constructor. srcBuffer values are cached. includes: [testBigIntTypedArray.js, compareArray.js] -features: [BigInt, SharedSendableArrayBuffer, TypedArray] +features: [BigInt, SharedArrayBuffer, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample, src, result, sab; - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -36,7 +36,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1n, 2n, 3n, 4n]), "offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; @@ -47,7 +47,7 @@ testWithBigIntSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1n, 1n, 2n, 4n]), "offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1n; sample[1] = 2n; diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js index 9a84e0f9330..3a2330441be 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-set-values-same-buffer-same-type.js @@ -25,9 +25,9 @@ info: | the definition in 22.2.3.23.1 applies. ... 23. If SameValue(srcBuffer, targetBuffer) is true, then - a. Let srcBuffer be ? CloneSendableArrayBuffer(srcBuffer, srcByteOffset, srcLength, - %SendableArrayBuffer%). - b. NOTE: %SendableArrayBuffer% is used to clone srcBuffer because is it known to not + a. Let srcBuffer be ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength, + %ArrayBuffer%). + b. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not have any observable side-effects. ... ... @@ -43,7 +43,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample, src, result; sample = new TA([1n, 2n, 3n, 4n]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js index a785f020450..96d7449055f 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js @@ -41,7 +41,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var src = new TA([42n, 43n]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js index 74722f8f1e6..97bb10df938 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js @@ -38,7 +38,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "byteOffset", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var src = new TA([42n, 43n]); var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array; diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js index d4792b5a043..d3d51c4e762 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js @@ -35,7 +35,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample, src; sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js index 4c9997e38ae..0f52982d4df 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js @@ -25,7 +25,7 @@ info: | ... 6. Let targetOffset be ? ToInteger(offset). ... - 11. Let srcBuffer be the value of typedArray's [[ViewedSendableArrayBuffer]] internal + 11. Let srcBuffer be the value of typedArray's [[ViewedArrayBuffer]] internal slot. 12. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception. ... @@ -33,7 +33,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); var target = new TA(); var calledOffset = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js index c1f4aa40192..6a47d698cc5 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js @@ -42,7 +42,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var src = new TA([42n, 43n]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js index 912aa697a64..609172280eb 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js @@ -39,7 +39,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "byteOffset", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var src = new TA([42n, 43n]); var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array; diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js index 18339e4572f..b16fc551dbf 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js @@ -27,16 +27,16 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 4}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 4}); var target = new TA(ab, 0, 4); - var source = new TA(new SendableArrayBuffer(BPE * 4)); + var source = new TA(new ArrayBuffer(BPE * 4)); var expectedError; try { diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js index b9c88b02e35..b6dbd2cfe3b 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js @@ -25,7 +25,7 @@ info: | ... 6. Let targetOffset be ? ToInteger(offset). ... - 8. Let targetBuffer be the value of target's [[ViewedSendableArrayBuffer]] internal + 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal slot. 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. ... @@ -33,7 +33,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var src = new TA(1); var calledOffset = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/undefined-tobigint.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/undefined-tobigint.js index 0b83e27f046..40637c41daf 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/undefined-tobigint.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/undefined-tobigint.js @@ -50,7 +50,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var typedArray = new TA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js index 941da95950c..0fe1eae3b89 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js @@ -31,7 +31,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(4); assert.throws(RangeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js index 01397f0320c..b02265da28d 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js @@ -31,7 +31,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA([1, 2]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js index 660fdf91ab3..e3516157f2b 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, Symbol] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var ta1 = new TA([1, 2, 3, 4, 5]); ta1.set("678", 1); assert.compareArray(ta1, [1, 6, 7, 8, 5], "string"); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js index fd1b672cc09..52b3eebaa44 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js @@ -37,7 +37,7 @@ Object.defineProperty(obj, "length", { } }); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([1, 2, 3]); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js index b5e5897e5ae..6a8a8ec7987 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js @@ -35,7 +35,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var obj = { length: 4, "0": 42, diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js index f6dbd2d3377..211e8f31b14 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js @@ -34,7 +34,7 @@ var obj = { length: Symbol("1") }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([1, 2, 3]); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js index 8eae5217957..a1b4e6ac575 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js @@ -46,7 +46,7 @@ var obj2 = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([1, 2, 3]); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js index 1237d41536b..23c66eb3c77 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js @@ -35,7 +35,7 @@ includes: [testTypedArray.js, compareArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var obj = { length: 4, "0": 42, diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js index 1fb7da2bf62..28aef8bfdb8 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js @@ -35,7 +35,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var obj = { length: 4, "0": 42, diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js index 69746683c72..deb09569e18 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -31,7 +31,7 @@ features: [Symbol, TypedArray] var s = Symbol("1"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js index a57ca6acade..20e71ee308c 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js @@ -41,7 +41,7 @@ var obj2 = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js index 5b8e37aa969..7293efdc44d 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([1, 2, 3]); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js index 747c8e39bcc..49950eb2adb 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js @@ -35,7 +35,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(5); var calls = []; var obj = { diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js index 0c42a5297db..6da3af15778 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js @@ -35,7 +35,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var src = [42, 43]; var srcObj = { length: 2, diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js index fb7d89f83c8..069027d9b26 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js @@ -35,7 +35,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var obj1 = { valueOf: function() { return 42; diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js index de495fb6148..c2112663cd4 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js @@ -35,7 +35,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(5); var obj = { length: 5, diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js index 5f8f7c9404a..a530b5eca1e 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js @@ -42,7 +42,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); Object.defineProperty(TA.prototype, "length", desc); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js index 89921f37226..aba47a6fa46 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js @@ -21,7 +21,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([1, 2, 3]); var obj = { length: 3, diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js index b9c59f18163..325392dc7b2 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js @@ -26,7 +26,7 @@ info: | ... 6. Let targetOffset be ? ToInteger(offset). ... - 8. Let targetBuffer be the value of target's [[ViewedSendableArrayBuffer]] internal + 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal slot. 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. ... @@ -34,7 +34,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var calledOffset = 0; var obj = { diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js index 6b966c1f157..6ab3e470a9a 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js @@ -24,7 +24,7 @@ info: | [[TypedArrayName]] internal slot. If it is such an Object, the definition in 22.2.3.23.2 applies. ... - 8. Let targetBuffer be the value of target's [[ViewedSendableArrayBuffer]] internal + 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal slot. 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. ... @@ -42,7 +42,7 @@ Object.defineProperty(obj, "length", { } }); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); $DETACHBUFFER(sample.buffer); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-value-conversion-resizes-array-buffer.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-value-conversion-resizes-array-buffer.js index 3c5381c1bc4..0257f785381 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-value-conversion-resizes-array-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-value-conversion-resizes-array-buffer.js @@ -31,7 +31,7 @@ features: [resizable-arraybuffer] includes: [compareArray.js] ---*/ -var rab = new SendableArrayBuffer(5, {maxByteLength: 10}); +var rab = new ArrayBuffer(5, {maxByteLength: 10}); var typedArray = new Int8Array(rab); var log = []; diff --git a/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js b/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js index 3cef5d9dba9..3898560c0f3 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js +++ b/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js @@ -45,4 +45,4 @@ function body(FA) { assert(compareArray(sourceBytes, targetBytes)) } -testWithSendableTypedArrayConstructors(body, floatArrayConstructors); +testWithTypedArrayConstructors(body, floatArrayConstructors); diff --git a/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js b/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js index d49f5b17c13..a36b693f208 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js @@ -35,11 +35,11 @@ features: [BigInt, TypedArray] var bigSendableTypedArray; var littleSendableTypedArray; -testWithBigIntSendableTypedArrayConstructors(function(BTA) { +testWithBigIntTypedArrayConstructors(function(BTA) { bigSendableTypedArray = new BTA([1n]); - testWithSendableTypedArrayConstructors(function(TA) { + testWithTypedArrayConstructors(function(TA) { littleSendableTypedArray = new TA(1); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/this-backed-by-resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/set/this-backed-by-resizable-buffer.js index 7692172f13b..e1a66790668 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/this-backed-by-resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/set/this-backed-by-resizable-buffer.js @@ -36,7 +36,7 @@ function SetNumOrBigInt(target, source, offset) { } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js index 49a9e75c4b1..45f701fd5e8 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js @@ -40,12 +40,12 @@ assert.throws(TypeError, function() { set.call([], []); }, "this is an Array"); -var ab1 = new SendableArrayBuffer(8); +var ab1 = new ArrayBuffer(8); assert.throws(TypeError, function() { set.call(ab1, []); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv1 = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv1 = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { set.call(dv1, []); }, "this is a DataView instance"); @@ -58,12 +58,12 @@ assert.throws(TypeError, function() { set.call([], new Int8Array()); }, "this is an Array"); -var ab2 = new SendableArrayBuffer(8); +var ab2 = new ArrayBuffer(8); assert.throws(TypeError, function() { set.call(ab2, new Int8Array()); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv2 = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv2 = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { set.call(dv2, new Int8Array()); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js index 6dd0207a400..4bb2132d22d 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(RangeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js index 8da3fd56fac..ad733879292 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js @@ -28,7 +28,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; var src = new TA([42]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js index 43c73308a2e..349349224de 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -30,7 +30,7 @@ features: [Symbol, TypedArray] var s = Symbol("1"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js index be0750d8ac1..952721549bd 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js @@ -40,7 +40,7 @@ var obj2 = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js index 215a4cc1d11..27daec8d851 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js @@ -18,7 +18,7 @@ esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set converted values from different buffer of different types and different type instances includes: [byteConversionValues.js, testTypedArray.js] -features: [SharedSendableArrayBuffer] +features: [SharedArrayBuffer] ---*/ testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { @@ -31,7 +31,7 @@ testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expe var sab, src, target; - sab = new SharedSendableArrayBuffer(4); + sab = new SharedArrayBuffer(4); src = new Int32Array(sab); src[0] = value; target = new TA([initial]); @@ -40,7 +40,7 @@ testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expe assert.sameValue(target[0], expected, "src is SAB-backed"); - sab = new SharedSendableArrayBuffer(4); + sab = new SharedArrayBuffer(4); src = new Int32Array([value]); target = new TA(sab); target[0] = initial; @@ -49,8 +49,8 @@ testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expe assert.sameValue(target[0], expected, "target is SAB-backed"); - var sab1 = new SharedSendableArrayBuffer(4); - var sab2 = new SharedSendableArrayBuffer(4); + var sab1 = new SharedArrayBuffer(4); + var sab2 = new SharedArrayBuffer(4); src = new Int32Array(sab1); src[0] = value; target = new TA(sab2); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js index a632b47c845..8e28d9abda4 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js @@ -19,14 +19,14 @@ description: > Set values from different instances using the different buffer and different type. includes: [testTypedArray.js, compareArray.js] -features: [SharedSendableArrayBuffer, TypedArray] +features: [SharedArrayBuffer, TypedArray] ---*/ var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var other = Int32Array; - var sab = new SharedSendableArrayBuffer(2 * other.BYTES_PER_ELEMENT); + var sab = new SharedArrayBuffer(2 * other.BYTES_PER_ELEMENT); var src = new other(sab); src[0] = 42; src[1] = 43; @@ -50,7 +50,7 @@ testWithSendableTypedArrayConstructors(function(TA) { src = new other([42, 43]); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -60,7 +60,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42, 43, 3, 4]), "sample is SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -70,7 +70,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1, 42, 43, 4]), "sample is SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -80,13 +80,13 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1, 2, 42, 43]), "sample is SAB-backed, offset: 2, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - var sab1 = new SharedSendableArrayBuffer(2 * other.BYTES_PER_ELEMENT); + var sab1 = new SharedArrayBuffer(2 * other.BYTES_PER_ELEMENT); src = new other(sab1); src[0] = 42; src[1] = 43; var sab2; - sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1; sample[1] = 2; @@ -96,7 +96,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42, 43, 3, 4]), "src and sample are SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1; sample[1] = 2; @@ -106,7 +106,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1, 42, 43, 4]), "src and sample are SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1; sample[1] = 2; diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js index 659c49ae088..cd9273c949e 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var other = TA === Float32Array ? Float64Array : Float32Array; var src = new other([42, 43]); var sample, result; diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js index bd750a4e4a0..51440535281 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js @@ -19,15 +19,15 @@ description: > Set values from different instances using the different buffer and same constructor. srcBuffer values are cached. includes: [testTypedArray.js, compareArray.js] -features: [SharedSendableArrayBuffer, TypedArray] +features: [SharedArrayBuffer, TypedArray] ---*/ var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample, result; - var sab = new SharedSendableArrayBuffer(2 * TA.BYTES_PER_ELEMENT); + var sab = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT); var src = new TA(sab); src[0] = 42; src[1] = 43; @@ -50,7 +50,7 @@ testWithSendableTypedArrayConstructors(function(TA) { src = new TA([42, 43]); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -60,7 +60,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1, 42, 43, 4]), "sample is SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -70,7 +70,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42, 43, 3, 4]), "sample is SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -81,13 +81,13 @@ testWithSendableTypedArrayConstructors(function(TA) { assert.sameValue(result, undefined, "returns undefined"); - var sab1 = new SharedSendableArrayBuffer(2 * TA.BYTES_PER_ELEMENT); + var sab1 = new SharedArrayBuffer(2 * TA.BYTES_PER_ELEMENT); src = new TA(sab1); src[0] = 42; src[1] = 43; var sab2; - sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1; sample[1] = 2; @@ -97,7 +97,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1, 42, 43, 4]), "src and sample are SAB-backed, offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1; sample[1] = 2; @@ -107,7 +107,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [42, 43, 3, 4]), "src and sample are SAB-backed, offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab2 = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab2 = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab2); sample[0] = 1; sample[1] = 2; diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js index 0a05f884ef7..5195a55becb 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js @@ -42,7 +42,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample, result; var src = new TA([42, 43]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js index 2a0ce84d80a..1ec2fc0391a 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js @@ -25,9 +25,9 @@ info: | the definition in 22.2.3.23.1 applies. ... 23. If SameValue(srcBuffer, targetBuffer) is true, then - a. Let srcBuffer be ? CloneSendableArrayBuffer(srcBuffer, srcByteOffset, srcLength, - %SendableArrayBuffer%). - b. NOTE: %SendableArrayBuffer% is used to clone srcBuffer because is it known to not + a. Let srcBuffer be ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength, + %ArrayBuffer%). + b. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not have any observable side-effects. ... ... @@ -57,7 +57,7 @@ var expected = { Uint8ClampedArray: [0, 42, 0, 66, 5, 6, 7, 8] }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var other = TA === Float32Array ? Float64Array : Float32Array; var sample = new TA([1, 2, 3, 4, 5, 6, 7, 8]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js index 7df5a9077f2..556e0b8d77d 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js @@ -17,20 +17,20 @@ esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the same buffer and same - constructor when underlying SendableArrayBuffer has been resized + constructor when underlying ArrayBuffer has been resized includes: [testTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var source = new TA(ab); var target = new TA(ab); var expected = [10, 20, 30, 40]; diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js index 7b1dfc1ed96..b71f810d46e 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js @@ -19,15 +19,15 @@ description: > Set values from different instances using the same buffer and same constructor. srcBuffer values are cached. includes: [testTypedArray.js, compareArray.js] -features: [SharedSendableArrayBuffer, TypedArray] +features: [SharedArrayBuffer, TypedArray] ---*/ var int_views = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array]; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample, src, result, sab; - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -38,7 +38,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1, 2, 3, 4]), "offset: 0, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; @@ -49,7 +49,7 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [1, 1, 2, 4]), "offset: 1, result: " + sample); assert.sameValue(result, undefined, "returns undefined"); - sab = new SharedSendableArrayBuffer(4 * TA.BYTES_PER_ELEMENT); + sab = new SharedArrayBuffer(4 * TA.BYTES_PER_ELEMENT); sample = new TA(sab); sample[0] = 1; sample[1] = 2; diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js index c1f8705664b..c54d72ce63f 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js @@ -25,9 +25,9 @@ info: | the definition in 22.2.3.23.1 applies. ... 23. If SameValue(srcBuffer, targetBuffer) is true, then - a. Let srcBuffer be ? CloneSendableArrayBuffer(srcBuffer, srcByteOffset, srcLength, - %SendableArrayBuffer%). - b. NOTE: %SendableArrayBuffer% is used to clone srcBuffer because is it known to not + a. Let srcBuffer be ? CloneArrayBuffer(srcBuffer, srcByteOffset, srcLength, + %ArrayBuffer%). + b. NOTE: %ArrayBuffer% is used to clone srcBuffer because is it known to not have any observable side-effects. ... ... @@ -43,7 +43,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample, src, result; sample = new TA([1, 2, 3, 4]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js index befe8894369..aae739fbd14 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js @@ -41,7 +41,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var src = new TA([42, 43]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-backed-by-resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-backed-by-resizable-buffer.js index a6e5b4a3599..8ad1ccf7d7f 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-backed-by-resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-backed-by-resizable-buffer.js @@ -45,7 +45,7 @@ for (let targetIsResizable of [ ]) { for (let targetCtor of ctors) { for (let sourceCtor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * sourceCtor.BYTES_PER_ELEMENT, 8 * sourceCtor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * sourceCtor.BYTES_PER_ELEMENT, 8 * sourceCtor.BYTES_PER_ELEMENT); const fixedLength = new sourceCtor(rab, 0, 4); const fixedLengthWithOffset = new sourceCtor(rab, 2 * sourceCtor.BYTES_PER_ELEMENT, 2); const lengthTracking = new sourceCtor(rab, 0); @@ -63,7 +63,7 @@ for (let targetIsResizable of [ // [1, 2, 3, 4, ...] << lengthTracking // [3, 4, ...] << lengthTrackingWithOffset - const targetAb = targetIsResizable ? new SendableArrayBuffer(6 * targetCtor.BYTES_PER_ELEMENT) : new SendableArrayBuffer(6 * targetCtor.BYTES_PER_ELEMENT, { maxByteLength: 8 * targetCtor.BYTES_PER_ELEMENT }); + const targetAb = targetIsResizable ? new ArrayBuffer(6 * targetCtor.BYTES_PER_ELEMENT) : new ArrayBuffer(6 * targetCtor.BYTES_PER_ELEMENT, { maxByteLength: 8 * targetCtor.BYTES_PER_ELEMENT }); const target = new targetCtor(targetAb); if (IsBigIntSendableTypedArray(target) != IsBigIntSendableTypedArray(taFull)) { // Can't mix BigInt and non-BigInt types. diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js index d5fed20564e..fc0e6c71203 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js @@ -38,7 +38,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "byteOffset", desc); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var src = new TA([42, 43]); var differentTA = TA === Uint8Array ? Int8Array : Uint8Array; diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js index eae41d72e6a..53d449fde92 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js @@ -35,7 +35,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample, src; sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js index 2ebb9f535b3..db416bb0ac0 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js @@ -25,7 +25,7 @@ info: | ... 6. Let targetOffset be ? ToInteger(offset). ... - 11. Let srcBuffer be the value of typedArray's [[ViewedSendableArrayBuffer]] internal + 11. Let srcBuffer be the value of typedArray's [[ViewedArrayBuffer]] internal slot. 12. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception. ... @@ -33,7 +33,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); var target = new TA(); var calledOffset = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js index 0980d39db76..20376afcfab 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js @@ -42,7 +42,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var src = new TA([42, 43]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js index 04177bddaf1..607762daece 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js @@ -39,7 +39,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "byteOffset", desc); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var src = new TA([42, 43]); var differentTA = TA === Uint8Array ? Int8Array : Uint8Array; diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js index 7faa679b263..c83e7d3168c 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js @@ -27,16 +27,16 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 4}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 4}); var target = new TA(ab, 0, 4); - var source = new TA(new SendableArrayBuffer(BPE * 4)); + var source = new TA(new ArrayBuffer(BPE * 4)); var expectedError; try { diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js index ac007b30172..aa82eaee097 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js @@ -25,7 +25,7 @@ info: | ... 6. Let targetOffset be ? ToInteger(offset). ... - 8. Let targetBuffer be the value of target's [[ViewedSendableArrayBuffer]] internal + 8. Let targetBuffer be the value of target's [[ViewedArrayBuffer]] internal slot. 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. ... @@ -33,7 +33,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var src = new TA(1); var calledOffset = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js index 1223f19d366..bb3a38dfcc6 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js @@ -36,7 +36,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n]); Object.defineProperty(TA.prototype, "length", desc); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js index d66767235bd..a38e7534c9e 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-other-targettype.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.slice description: > - Throws a TypeError if _O_.[[ViewedSendableArrayBuffer]] is detached during create with custom constructor (other targetType) + Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during create with custom constructor (other targetType) info: | %SendableTypedArray%.prototype.slice ( start, end ) @@ -35,8 +35,8 @@ info: | The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: Perform ? RequireInternalSlot(O, [[TypedArrayName]]). - Assert: O has a [[ViewedSendableArrayBuffer]] internal slot. - Let buffer be O.[[ViewedSendableArrayBuffer]]. + Assert: O has a [[ViewedArrayBuffer]] internal slot. + Let buffer be O.[[ViewedArrayBuffer]]. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... @@ -44,7 +44,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { let counter = 0; var sample = new TA(1); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js index d6405aca26b..723f4eca227 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-custom-ctor-same-targettype.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.slice description: > - Throws a TypeError if _O_.[[ViewedSendableArrayBuffer]] is detached during create with custom constructor. + Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during create with custom constructor. info: | %SendableTypedArray%.prototype.slice ( start, end ) @@ -35,8 +35,8 @@ info: | The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: Perform ? RequireInternalSlot(O, [[TypedArrayName]]). - Assert: O has a [[ViewedSendableArrayBuffer]] internal slot. - Let buffer be O.[[ViewedSendableArrayBuffer]]. + Assert: O has a [[ViewedArrayBuffer]] internal slot. + Let buffer be O.[[ViewedArrayBuffer]]. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... @@ -44,7 +44,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { let counter = 0; let sample = new TA(1); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js index e0a92558973..1d31d4a51ce 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-get-ctor.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.slice description: > - Throws a TypeError if _O_.[[ViewedSendableArrayBuffer]] is detached during Get custom constructor. + Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached during Get custom constructor. info: | %SendableTypedArray%.prototype.slice ( start, end ) @@ -35,8 +35,8 @@ info: | The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: Perform ? RequireInternalSlot(O, [[TypedArrayName]]). - Assert: O has a [[ViewedSendableArrayBuffer]] internal slot. - Let buffer be O.[[ViewedSendableArrayBuffer]]. + Assert: O has a [[ViewedArrayBuffer]] internal slot. + Let buffer be O.[[ViewedArrayBuffer]]. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... @@ -44,7 +44,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { let counter = 0; let sample = new TA(1); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js index 1da68db48da..bc18e14a582 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-speciesctor-get-species-custom-ctor-throws.js @@ -34,8 +34,8 @@ info: | The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: Perform ? RequireInternalSlot(O, [[TypedArrayName]]). - Assert: O has a [[ViewedSendableArrayBuffer]] internal slot. - Let buffer be O.[[ViewedSendableArrayBuffer]]. + Assert: O has a [[ViewedArrayBuffer]] internal slot. + Let buffer be O.[[ViewedArrayBuffer]]. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... @@ -43,7 +43,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { let counter = 0; let sample = new TA(1); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js index 9793843f3eb..14027137080 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-other-targettype.js @@ -30,7 +30,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { let counter = 0; let sample, result, Other, other; let ctor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js index b721f9a905a..4019654e39a 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer-zero-count-custom-ctor-same-targettype.js @@ -29,7 +29,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { let counter = 0; let sample, result, other; let ctor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer.js index 0e55e240e9a..f2a9ad9cbd8 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/detached-buffer.js @@ -37,7 +37,7 @@ var obj = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/infinity.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/infinity.js index e772572bb38..0fe15fc7b32 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/infinity.js @@ -20,7 +20,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); assert( diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/minus-zero.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/minus-zero.js index 4724598233c..46349f19120 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/minus-zero.js @@ -22,7 +22,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); assert( diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js index 89a9c9be585..5fe2a37c50b 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/result-does-not-copy-ordinary-properties.js @@ -22,7 +22,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([41n, 42n, 43n, 44n]); sample.foo = 42; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-different-length.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-different-length.js index f8422373ef1..9fbe1c25170 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-different-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-different-length.js @@ -20,7 +20,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); function testRes(result, expected, msg) { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js index 763d5dc9483..82527e556b6 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-empty-length.js @@ -20,7 +20,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); function testRes(result, msg) { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-same-length.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-same-length.js index 40bbe839155..d6a8999d704 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-same-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/results-with-same-length.js @@ -20,7 +20,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); function testRes(result, msg) { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js index c3e9023af08..7984e8fa152 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end-symbol.js @@ -29,7 +29,7 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol("1"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js index ad88ecad3b8..1c5a22db0ee 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-end.js @@ -39,7 +39,7 @@ var o2 = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js index a11a8eaa82f..51511261181 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start-symbol.js @@ -28,7 +28,7 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol("1"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js index 3d4a6e9240a..6733e406e3c 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-start.js @@ -38,7 +38,7 @@ var o2 = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js index 9d8ab5f590f..0235df9f9ab 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js index ed9accb838f..dd6389d1e36 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/set-values-from-different-ctor-type.js @@ -45,7 +45,7 @@ features: [BigInt, Symbol.species, TypedArray] var arr = [42n, 43n, 44n]; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(arr); var other = TA === BigInt64Array ? BigUint64Array : BigInt64Array; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-destination-resizable.js index f0d4bc303ab..77084761c3a 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-destination-resizable.js @@ -40,10 +40,10 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { - const rab1 = new SendableArrayBuffer(8, {maxByteLength: 100}); +testWithBigIntTypedArrayConstructors(function(TA) { + const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); const ta = new TA(rab1); - const rab2 = new SendableArrayBuffer(10, {maxByteLength: 20}); + const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab2); rab2.resize(0); ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js index fcefb45906f..563916cd33e 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-abrupt.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); Object.defineProperty(sample, "constructor", { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js index a83263fc5b0..7380e234618 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-inherited.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js index cf7d0735ddc..7702ca871fc 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor-returns-throws.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); sample.constructor = 42; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js index 061205ae3ee..c23341329d0 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-ctor.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js index c34eb2d2880..03435644566 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-abrupt.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js index e62b54bb45d..60522991933 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-invocation.js @@ -49,7 +49,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n]); var result, ctorThis; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index 303207b1463..0410ef9c0a7 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -41,9 +41,9 @@ features: [BigInt, Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { const sample = new TA(2); - const rab = new SendableArrayBuffer(10, {maxByteLength: 20}); + const rab = new ArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab); rab.resize(0); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js index 36c0038e29e..6c4845ef4d5 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length-throws.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js index 5c59e265947..dc8760ed1b9 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-length.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var customCount, result; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js index 63f07f4669e..216b9f4f07c 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -49,7 +49,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n]); var other = new BigInt64Array([1n, 0n, 1n]); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js index 09e6b0cbf22..f3a04cd369f 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor-throws.js @@ -47,7 +47,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var ctor = function() {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js index 3bf553febfe..ab0b9bd52f0 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-custom-ctor.js @@ -49,7 +49,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js index 20086b1812d..aac62486903 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-returns-throws.js @@ -42,7 +42,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js index 531b54eff6c..fbb037b8284 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species-use-default-ctor.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js index 9e1d3faa3ea..75e17ad6fb3 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/speciesctor-get-species.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-end.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-end.js index 2fd552dcb9b..b9101a22ef0 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-end.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-end.js @@ -33,7 +33,7 @@ var obj = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); assert(compareArray(sample.slice(0, false), []), "false"); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-start.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-start.js index c238253a4e4..126ec0d2260 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-start.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/tointeger-start.js @@ -32,7 +32,7 @@ var obj = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); assert(compareArray(sample.slice(false), [40n, 41n, 42n, 43n]), "false"); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js index 21230225c69..2579007b9fe 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js @@ -36,7 +36,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43]); Object.defineProperty(TA.prototype, "length", desc); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js b/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js index 6b6b2eaeb8e..bbef4721744 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js @@ -49,4 +49,4 @@ function body(FloatArray) { assert(compareArray(subjectBytes, slicedBytes)); } -testWithSendableTypedArrayConstructors(body, floatArrayConstructors); +testWithTypedArrayConstructors(body, floatArrayConstructors); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-grow.js b/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-grow.js index 39ed0fbc209..ae0228b3b37 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-grow.js @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // The start argument grows the resizable array buffer rab. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); @@ -46,7 +46,7 @@ for (let ctor of ctors) { // The end argument grows the resizable array buffer rab. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-shrink.js b/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-shrink.js index e9aa6ea492d..39eb4c19617 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/coerced-start-end-shrink.js @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // The start argument shrinks the resizable array buffer rab. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const evil = { valueOf: () => { @@ -38,7 +38,7 @@ for (let ctor of ctors) { assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); @@ -64,7 +64,7 @@ for (let ctor of ctors) { // The end argument shrinks the resizable array buffer rab. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const evil = { valueOf: () => { @@ -78,7 +78,7 @@ for (let ctor of ctors) { assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); for (let i = 0; i < 4; ++i) { lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js index 6cfbc5a41b2..f0668c31b18 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.slice description: > - Throws a TypeError if _O_.[[ViewedSendableArrayBuffer]] is detached. Using other + Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached. Using other targetType info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) @@ -24,13 +24,13 @@ info: | ... Let A be ? SendableTypedArraySpeciesCreate(O, « count »). If count > 0, then - If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { let counter = 0; var sample = new TA(1); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js index b904bd0f484..ab7a09b45b3 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js @@ -15,20 +15,20 @@ /*--- esid: sec-%sendableTypedArray%.prototype.slice -description: Throws a TypeError if _O_.[[ViewedSendableArrayBuffer]] is detached on Get custom constructor. +description: Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached on Get custom constructor. info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) ... Let A be ? SendableTypedArraySpeciesCreate(O, « count »). If count > 0, then - If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { let counter = 0; let sample = new TA(1); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js index ee8c04f23a6..1d470be7e3d 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js @@ -15,20 +15,20 @@ /*--- esid: sec-%sendableTypedArray%.prototype.slice -description: Throws a TypeError if _O_.[[ViewedSendableArrayBuffer]] is detached. +description: Throws a TypeError if _O_.[[ViewedArrayBuffer]] is detached. info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) ... Let A be ? SendableTypedArraySpeciesCreate(O, « count »). If count > 0, then - If IsDetachedBuffer(O.[[ViewedSendableArrayBuffer]]) is true, throw a TypeError exception. + If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. ... includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { let counter = 0; let sample = new TA(1); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js index 5f597d6a1e8..c0616467b0b 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js @@ -34,8 +34,8 @@ info: | The abstract operation ValidateSendableTypedArray takes argument O. It performs the following steps when called: Perform ? RequireInternalSlot(O, [[TypedArrayName]]). - Assert: O has a [[ViewedSendableArrayBuffer]] internal slot. - Let buffer be O.[[ViewedSendableArrayBuffer]]. + Assert: O has a [[ViewedArrayBuffer]] internal slot. + Let buffer be O.[[ViewedArrayBuffer]]. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... @@ -43,7 +43,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { let counter = 0; let sample = new TA(1); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js index bb1feea522d..0ee1ab9e5a8 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { let counter = 0; let sample, result, Other, other; let ctor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js index 79c211b4887..25f52ae7e08 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { let counter = 0; let sample, result, other; let ctor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js index 552b459dcaa..1d62a03d659 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js @@ -37,7 +37,7 @@ var obj = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/infinity.js b/test/sendable/builtins/TypedArray/prototype/slice/infinity.js index a1a1eda6251..d26048e4e63 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/infinity.js @@ -20,7 +20,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); assert( diff --git a/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js b/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js index b613d67bc96..1bc789baabc 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js @@ -22,7 +22,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); assert( diff --git a/test/sendable/builtins/TypedArray/prototype/slice/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/slice/resizable-buffer.js index 2c0618c6849..76c02f9f912 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js b/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js index 35c549167ef..2d9cad4462f 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js @@ -22,7 +22,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([41, 42, 43, 44]); sample.foo = 42; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js b/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js index 86e0461e50f..b6745b51c5f 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js @@ -20,7 +20,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); function testRes(result, expected, msg) { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js b/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js index 00597893ffb..c54750c9a2e 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js @@ -20,7 +20,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); function testRes(result, msg) { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js b/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js index 543c19cbe4f..fa97885227c 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js @@ -20,7 +20,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); function testRes(result, msg) { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js index 79e9c95d86b..0dfb499235d 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js @@ -29,7 +29,7 @@ features: [Symbol, TypedArray] var s = Symbol("1"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js index e610a1e2268..6af2c9cbeef 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js @@ -39,7 +39,7 @@ var o2 = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js index 538d9bc222e..32479284900 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js @@ -28,7 +28,7 @@ features: [Symbol, TypedArray] var s = Symbol("1"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js index 4a55d6877b5..fb0aa97867b 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js @@ -38,7 +38,7 @@ var o2 = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js index 122b7ea846c..4160c213a8d 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js b/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js index d0b628fca3e..a58eaa5e9f2 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js @@ -45,7 +45,7 @@ features: [Symbol.species, TypedArray] var arr = [42, 43, 44]; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(arr); var other = TA === Int8Array ? Uint8Array : Int8Array; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js index 0fd50fdbb77..e6b31d17573 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js @@ -40,10 +40,10 @@ includes: [testTypedArray.js] features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { - const rab1 = new SendableArrayBuffer(8, {maxByteLength: 100}); +testWithTypedArrayConstructors(function(TA) { + const rab1 = new ArrayBuffer(8, {maxByteLength: 100}); const ta = new TA(rab1); - const rab2 = new SendableArrayBuffer(10, {maxByteLength: 20}); + const rab2 = new ArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab2); rab2.resize(0); ta.constructor = { [Symbol.species]: function() { return lengthTracking; } }; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js index 4757c763400..f29f173cfeb 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); Object.defineProperty(sample, "constructor", { diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js index 25b0b078af5..e18b11b0386 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js index 6348efb5cff..800e450f5e8 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); sample.constructor = 42; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js index f7e501ec029..ffb0ae5ccc8 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js index 26e3bddadd5..757981b8ab3 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js index 5a979a56f7a..9426fc491fa 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js @@ -49,7 +49,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42]); var result, ctorThis; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index 598947b7742..2c4ed5429d9 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -41,9 +41,9 @@ features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { const sample = new TA(2); - const rab = new SendableArrayBuffer(10, {maxByteLength: 20}); + const rab = new ArrayBuffer(10, {maxByteLength: 20}); const lengthTracking = new TA(rab); rab.resize(0); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js index 79898cc18a9..9f81509ceae 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js index 3e0133f01a1..f98b6a24c62 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var customCount, result; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js index d89d1f6c5c9..74b6b7184c6 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -49,7 +49,7 @@ includes: [testTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40]); var other = new Int8Array([1, 0, 1]); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js index f092c7ae5f2..c43ae8ea254 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js @@ -47,7 +47,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var ctor = function() {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js index 29c4903c906..4aa4bb85275 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js @@ -49,7 +49,7 @@ includes: [testTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js index 8b620842c8d..ea1778bf819 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js @@ -42,7 +42,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js index 3dcbb181833..75bdc38e040 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js index 31acbe8d384..a6ae743c403 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-resize.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-resize.js index d56ca882789..56f1dc20760 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-resize.js @@ -26,7 +26,7 @@ features: [resizable-arraybuffer] // doesn't call the species constructor if the "original array" is not an Array. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); let resizeWhenConstructorCalled = false; class MyArray extends ctor { constructor(...params) { @@ -45,7 +45,7 @@ for (let ctor of ctors) { assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const taWrite = new ctor(rab); for (let i = 0; i < 4; ++i) { taWrite[i] = MayNeedBigInt(taWrite, 1); @@ -78,7 +78,7 @@ for (let ctor of ctors) { // Test that the (start, end) parameters are computed based on the original // length. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const taWrite = new ctor(rab); for (let i = 0; i < 4; ++i) { taWrite[i] = MayNeedBigInt(taWrite, 1); @@ -108,7 +108,7 @@ for (let ctor of ctors) { // Test where the buffer gets resized "between elements". { - const rab = CreateResizableSendableArrayBuffer(8, 16); + const rab = CreateResizableArrayBuffer(8, 16); const taWrite = new Uint8Array(rab); for (let i = 0; i < 8; ++i) { taWrite[i] = MayNeedBigInt(taWrite, 255); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js index c7b6c2c1104..3b496fb73b7 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js @@ -46,12 +46,12 @@ assert.throws(TypeError, function() { slice.call([], 0, 0); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { slice.call(ab, 0, 0); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { slice.call(dv, 0, 0); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js index 855e75d225f..e8ab0dd3aa2 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js @@ -33,7 +33,7 @@ var obj = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); assert(compareArray(sample.slice(0, false), []), "false"); diff --git a/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js index 6898537eb7b..8ce56e1f25b 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js @@ -32,7 +32,7 @@ var obj = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); assert(compareArray(sample.slice(false), [40, 41, 42, 43]), "false"); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js index 1635c76c2b2..39e00fe9f02 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-with-thisarg.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js index 9a1cb3f0cc8..3826c67f4bd 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-arguments-without-thisarg.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js index 36f4073bb5b..e0c3827a0e9 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-detachbuffer.js @@ -38,7 +38,7 @@ includes: [detachArrayBuffer.js, testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js index 935c283aa14..4650a42111f 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-no-interaction-over-non-integer.js @@ -31,7 +31,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([7n, 8n]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js index 670d93456dd..88d25e94a51 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-callable-throws.js @@ -33,7 +33,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js index 47af0c2a6ba..f4a68ea484b 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-not-called-on-empty.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var called = 0; new TA().some(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js index 641e2023e34..c2ba0c6f507 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-return-does-not-change-instance.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n]); sample.some(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js index 42705924b82..7b7f57bb1f5 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-returns-abrupt.js @@ -37,7 +37,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js index bedb28d3356..78e7ad36e52 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-set-value-during-interaction.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Reflect.set, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); var newVal = 0n; diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-this.js index 4283f78a3eb..bdef2f1cf32 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/callbackfn-this.js @@ -43,7 +43,7 @@ features: [BigInt, TypedArray] var expected = (function() { return this; })(); var thisArg = {}; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(3); var results1 = []; diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/detached-buffer.js index 162d24ea59f..092c39bb55d 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/detached-buffer.js @@ -36,7 +36,7 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js index 16852de601c..554a395f608 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js @@ -43,7 +43,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n]); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js index 5765585b66a..ee93b737cc7 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.some description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js index 6b306ba74ae..cb5068dcdb0 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-false-if-every-cb-returns-false.js @@ -33,7 +33,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(42); [ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js index 1eb222db4a7..86dcd64b957 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/returns-true-if-any-cb-returns-true.js @@ -41,7 +41,7 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol("1"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(42); [ true, diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/values-are-not-cached.js index 10c5551a6f4..231a27aad10 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/values-are-not-cached.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n]); sample.some(function(v, i) { diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js index 565538ec995..eec7784980c 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js index a8b4bc84bf6..a3c6a4c4083 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js index 0664e3646de..72e014616c0 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js @@ -38,7 +38,7 @@ includes: [detachArrayBuffer.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var loops = 0; var sample = new TA(2); diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js index 1ce474d7768..9331d1efd6e 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js @@ -31,7 +31,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([7, 8]); var results = []; diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js index c8ea61df252..e5c984ebe77 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js @@ -33,7 +33,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js index ea3ff51ab49..4171119f4ce 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var called = 0; new TA().some(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js index a0ee8b3f0e5..9470791ce32 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js @@ -21,14 +21,14 @@ features: [TypedArray, resizable-arraybuffer] ---*/ // If the host chooses to throw as allowed by the specification, the observed -// behavior will be identical to the case where `SendableArrayBuffer.prototype.resize` +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` // has not been implemented. The following assertion prevents this test from // passing in runtimes which have not implemented the method. -assert.sameValue(typeof SendableArrayBuffer.prototype.resize, 'function'); +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var BPE = TA.BYTES_PER_ELEMENT; - var buffer = new SendableArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); var sample = new TA(buffer); var finalElement, expectedElements, expectedIndices, expectedArrays; var elements, indices, arrays, result; diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js index 93ac61c059b..7cc1f955053 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42]); sample.some(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js index c47604d9117..e0621d9f8ed 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js @@ -37,7 +37,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js index 5da445a7cdb..f0881d4e469 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [Reflect.set, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); var newVal = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js index 097c58faf13..741c7adaf55 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js @@ -43,7 +43,7 @@ features: [TypedArray] var expected = (function() { return this; })(); var thisArg = {}; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(3); var results1 = []; diff --git a/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js index e4d78d1d229..66e4b10a95d 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js @@ -36,7 +36,7 @@ var callbackfn = function() { throw new Test262Error(); }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js index 5b9bdb84a66..153a5dd6b92 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js @@ -43,7 +43,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43]); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer.js index 250d3ddf1b1..46c502abcf5 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/resizable-buffer.js @@ -22,7 +22,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js index 66ac3d571f3..e1ce18565de 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.some description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js b/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js index a6615c913d3..29a3b284b7f 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js @@ -33,7 +33,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(42); [ diff --git a/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js b/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js index c1ffbe330de..5e9c030d190 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js @@ -41,7 +41,7 @@ features: [Symbol, TypedArray] var s = Symbol("1"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(42); [ true, diff --git a/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js index 6c0e2285f19..c2fe61c312f 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { some.call([], callbackfn); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { some.call(ab, callbackfn); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { some.call(dv, callbackfn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js index b10ef123ba0..fb082cf8c5e 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44]); sample.some(function(v, i) { diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js index a3aceae3b7e..3b428c8f6ab 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js @@ -35,7 +35,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 42n, 42n]); getCalls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js index 0ebbb007f63..b1d8db5c918 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-call-throws.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n, 45n, 46n]); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-calls.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-calls.js index de2c12c5374..e79a995d637 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-calls.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-calls.js @@ -35,7 +35,7 @@ var expectedThis = (function() { return this; })(); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 42n, 42n, 42n, 42n]); var calls = []; diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js index 73a09dab54b..76d6add2bcf 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-is-undefined.js @@ -26,7 +26,7 @@ includes: [compareArray.js, testBigIntTypedArray.js] features: [TypedArray, BigInt] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { let sample = new TA([42n, 44n, 46n, 43n, 45n]); let explicit = sample.sort(undefined); let implicit = sample.sort(); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js index 389246fdc38..41c4b9d83bc 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/comparefn-nonfunction-call-throws.js @@ -31,7 +31,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n, 44n, 45n, 46n]); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/detached-buffer.js index f2e500dee1f..534d09edf5d 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/detached-buffer.js @@ -35,7 +35,7 @@ var comparefn = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js index e7e1fe40a58..2799fe8861e 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.sort description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-same-instance.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-same-instance.js index 51debbda8b4..431a00c4c17 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-same-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-same-instance.js @@ -27,7 +27,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([2n, 1n]); var result = sample.sort(); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js index 4cb902b9a5c..09b9a2b6859 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js @@ -36,7 +36,7 @@ BigInt.prototype.toString = function() { toStringCalled = true; } -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([20n, 100n, 3n]); var result = sample.sort(); assert.sameValue(toStringCalled, false, "BigInt.prototype.toString will not be called"); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sorted-values.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sorted-values.js index 220df48a2d3..321e845c378 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sorted-values.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/sorted-values.js @@ -27,7 +27,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample; sample = new TA([4n, 3n, 2n, 1n]).sort(); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js index 0962f84b06a..010a83a25a9 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js @@ -35,7 +35,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 42, 42]); getCalls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js index 07ddf7c8ff3..3fbbee905f2 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44, 45, 46]); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js index a583d663d01..6e640c7d0c7 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js @@ -35,7 +35,7 @@ var expectedThis = (function() { return this; })(); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 42, 42, 42, 42]); var calls = []; diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-grow.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-grow.js index 36f61ffb308..a80692780b6 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-grow.js @@ -45,7 +45,7 @@ function WriteUnsortedData(taFull) { // Fixed length TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const resizeTo = 6 * ctor.BYTES_PER_ELEMENT; const fixedLength = new ctor(rab, 0, 4); const taFull = new ctor(rab, 0); @@ -64,7 +64,7 @@ for (let ctor of ctors) { // Length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const resizeTo = 6 * ctor.BYTES_PER_ELEMENT; const lengthTracking = new ctor(rab, 0); const taFull = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js index aaa7af17e02..48747bf8342 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js @@ -26,7 +26,7 @@ includes: [compareArray.js, testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { let sample = new TA([42, 44, 46, 43, 45]); let explicit = sample.sort(undefined); let implicit = sample.sort(); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js index 2865251c080..be36553ec50 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js @@ -31,7 +31,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([42, 43, 44, 45, 46]); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-resizable-buffer.js index 9fc5f77352e..4d49dcf5519 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-shrink.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-shrink.js index 445bf36ff52..be19ce298d9 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-shrink.js @@ -45,7 +45,7 @@ function WriteUnsortedData(taFull) { // Fixed length TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const resizeTo = 2 * ctor.BYTES_PER_ELEMENT; const fixedLength = new ctor(rab, 0, 4); const taFull = new ctor(rab, 0); @@ -60,7 +60,7 @@ for (let ctor of ctors) { // Length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const resizeTo = 2 * ctor.BYTES_PER_ELEMENT; const lengthTracking = new ctor(rab, 0); const taFull = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js index dfaeb627556..6d9053d4355 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js @@ -35,7 +35,7 @@ var comparefn = function() { throw new Test262Error(); }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/sort/resizable-buffer-default-comparator.js b/test/sendable/builtins/TypedArray/prototype/sort/resizable-buffer-default-comparator.js index 938b3b71db0..bb13c5ce723 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/resizable-buffer-default-comparator.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/resizable-buffer-default-comparator.js @@ -25,7 +25,7 @@ features: [resizable-arraybuffer] // Array.prototype.sort, since the default sorting functions differ. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js index 04a4ddfdd70..25ebd4c21ad 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.sort description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js b/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js index e8db33130f9..5b8c9eb2580 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js @@ -27,7 +27,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([2, 1]); var result = sample.sort(); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js b/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js index 0157658e80c..4426d9892ea 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js @@ -29,7 +29,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var ta = new TA(4); var ab = ta.buffer; diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js b/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js index f40bcb46501..89ac227caa4 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js @@ -36,7 +36,7 @@ Number.prototype.toString = function() { toStringCalled = true; } -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([20, 100, 3]); var result = sample.sort(); assert.sameValue(toStringCalled, false, "Number.prototype.toString will not be called"); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js index 657c201129f..872ebdbca16 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA([2, NaN, NaN, 0, 1]).sort(); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js index fd2a4269e02..7dd233bff4e 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js @@ -27,7 +27,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA([4, 3, 2, 1]).sort(); @@ -40,22 +40,22 @@ testWithSendableTypedArrayConstructors(function(TA) { assert(compareArray(sample, [0, 1, 1, 2, 3, 3, 4]), "repeating numbers"); }); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([1, 0, -0, 2]).sort(); assert(compareArray(sample, [-0, 0, 1, 2]), "0s"); }, floatArrayConstructors); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([1, 0, -0, 2]).sort(); assert(compareArray(sample, [0, 0, 1, 2]), "0s"); }, intArrayConstructors); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([-4, 3, 4, -3, 2, -2, 1, 0]).sort(); assert(compareArray(sample, [-4, -3, -2, 0, 1, 2, 3, 4]), "negative values"); }, floatArrayConstructors.concat([Int8Array, Int16Array, Int32Array])); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample; sample = new TA([0.5, 0, 1.5, 1]).sort(); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/stability.js b/test/sendable/builtins/TypedArray/prototype/sort/stability.js index 5e9f9083af1..e49ce69010a 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/stability.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/stability.js @@ -25,7 +25,7 @@ features: [TypedArray] // Treat 0..3, 4..7, etc. as equal. const compare = (a, b) => (a / 4 | 0) - (b / 4 | 0); -testWithSendableTypedArrayConstructors((TA) => { +testWithTypedArrayConstructors((TA) => { // Create an array of the form `[0, 1, …, 126, 127]`. const array = Array.from({ length: 128 }, (_, i) => i); diff --git a/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js index 66a0b24d887..3cb238a7013 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js @@ -45,12 +45,12 @@ assert.throws(TypeError, function() { sort.call([], comparefn); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { sort.call(ab, comparefn); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { sort.call(dv, comparefn); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/detached-buffer.js index b0e3fea9198..239413af454 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/detached-buffer.js @@ -63,7 +63,7 @@ var o2 = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); begin = false; end = false; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/infinity.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/infinity.js index cd36b1fa3d5..7076c1c6a25 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/infinity.js @@ -22,7 +22,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); assert( diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/minus-zero.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/minus-zero.js index 629c9f4f23e..69392abba8f 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/minus-zero.js @@ -22,7 +22,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); assert( diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js index fd54157b068..e685189f64e 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-does-not-copy-ordinary-properties.js @@ -25,7 +25,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([41n, 42n, 43n, 44n]); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js index 9bb0693c2d2..938b3900c61 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-from-same-ctor.js @@ -25,7 +25,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); var result = sample.subarray(1); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js index 9c1f3588534..f3685a2fe03 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/result-is-new-instance-with-shared-buffer.js @@ -25,7 +25,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); var buffer = sample.buffer; var result = sample.subarray(1); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js index a5ba9767f8e..bbf69b82e07 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-different-length.js @@ -25,7 +25,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); function testRes(result, expected, msg) { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js index 7dd0cf1113a..9af79be796a 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-empty-length.js @@ -25,7 +25,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); function testRes(result, msg) { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js index 21bdd848efb..3ced22c914d 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/results-with-same-length.js @@ -25,7 +25,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); function testRes(result, msg) { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js index 1fd34587646..e22390b7c48 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin-symbol.js @@ -28,7 +28,7 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol("1"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js index c808a3737a7..c55130521b0 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-begin.js @@ -38,7 +38,7 @@ var o2 = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js index d46b09dbc35..33e6644272e 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end-symbol.js @@ -29,7 +29,7 @@ features: [BigInt, Symbol, TypedArray] var s = Symbol("1"); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js index 050cc2f5cff..a1f19534a08 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/return-abrupt-from-end.js @@ -39,7 +39,7 @@ var o2 = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js index 9a21e294467..5f4804cfc09 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-abrupt.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); Object.defineProperty(sample, "constructor", { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js index 04a523cfcdf..1b1d3394392 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-inherited.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js index cd5e08ff683..618f964c073 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor-returns-throws.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); sample.constructor = 42; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js index 1d7ca140eb8..d5ea86fc515 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-ctor.js @@ -38,7 +38,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js index b3b966f6855..7a9951b117a 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-abrupt.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js index e7daad8b15d..92ef14fc7b8 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-invocation.js @@ -48,7 +48,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n]); var expectedOffset = TA.BYTES_PER_ELEMENT; var result, ctorThis; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js index 1ec60b8cbdf..15de2327d61 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -48,7 +48,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n]); var other = new BigInt64Array([1n, 0n, 1n]); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js index 14571786371..19397dfb61d 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor-throws.js @@ -46,7 +46,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var ctor = function() {}; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js index b09a188b4d3..c3d7aa34f34 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-custom-ctor.js @@ -48,7 +48,7 @@ includes: [testBigIntTypedArray.js, compareArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js index 8451ded2a57..1cf5341f6c3 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-returns-throws.js @@ -41,7 +41,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js index b3c41553139..928eb7ad700 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species-use-default-ctor.js @@ -39,7 +39,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js index 859764f0321..15d93c81928 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/speciesctor-get-species.js @@ -40,7 +40,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, Symbol.species, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(2); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js index de7ff9531b7..67045228a33 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-begin.js @@ -32,7 +32,7 @@ var obj = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); assert(compareArray(sample.subarray(false), [40n, 41n, 42n, 43n]), "false"); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-end.js b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-end.js index 6be6d65bae4..e8213ee11b2 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-end.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/BigInt/tointeger-end.js @@ -33,7 +33,7 @@ var obj = { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([40n, 41n, 42n, 43n]); assert(compareArray(sample.subarray(0, false), []), "false"); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js index fe8128e881f..b514e2de1f8 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js @@ -63,7 +63,7 @@ var o2 = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); begin = false; end = false; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js b/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js index 69e4f19e658..6f10ef847e2 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js @@ -22,7 +22,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); assert( diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js b/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js index a3c59f2f052..7f68cf4bdd1 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js @@ -22,7 +22,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); assert( diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/resizable-buffer.js index 0bed1275c06..8da78b2bc43 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js index 250bfe3e309..0fa3b607bbe 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-byteOffset-from-out-of-bounds.js @@ -33,7 +33,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new SendableArrayBuffer(10, {maxByteLength: 10}); +let rab = new ArrayBuffer(10, {maxByteLength: 10}); let autoLength = new Int8Array(rab, 4); let withLength = new Int8Array(rab, 4, 2); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js index 989a5601e95..33579b67538 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js @@ -25,7 +25,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([41, 42, 43, 44]); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js index 54f410fb699..2fd026f4854 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js @@ -25,7 +25,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); var result = sample.subarray(1); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js index 2bf11b61e15..55a5b505459 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js @@ -25,7 +25,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); var buffer = sample.buffer; var result = sample.subarray(1); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js index 14a2f1135f1..b9b78e460da 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js @@ -25,7 +25,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); function testRes(result, expected, msg) { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js index 4dce41a2d1b..901cf14adca 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js @@ -25,7 +25,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); function testRes(result, msg) { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js index 9e06f67be5f..ea63f85b391 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js @@ -25,7 +25,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); function testRes(result, msg) { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js index edf2ffcf915..08f8dfd8b02 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js @@ -28,7 +28,7 @@ features: [Symbol, TypedArray] var s = Symbol("1"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js index 3854d8608d1..5df298ef382 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js @@ -38,7 +38,7 @@ var o2 = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js index bea2c25ecf5..19c714db506 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js @@ -29,7 +29,7 @@ features: [Symbol, TypedArray] var s = Symbol("1"); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js index c7e49d7aff3..309eb897e58 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js @@ -39,7 +39,7 @@ var o2 = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js index 3690fb95052..77e7dcfb22e 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); Object.defineProperty(sample, "constructor", { diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js index f5368ac4fe0..8369837b1e0 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js index a63cc1a5e4e..31fb6df527e 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [Symbol, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); sample.constructor = 42; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js index 5c8cb06d8fb..88a5b22c324 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js @@ -38,7 +38,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js index 52c29de4737..cbecde94d05 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js index 68f57d8fb10..a9c2958a6d5 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js @@ -48,7 +48,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42]); var expectedOffset = TA.BYTES_PER_ELEMENT; var result, ctorThis; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js index 82a65103c81..3bc7d9bc1ea 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -48,7 +48,7 @@ includes: [testTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40]); var other = new Int8Array([1, 0, 1]); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js index 2c9394ffedc..818d47fe7bb 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js @@ -46,7 +46,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var ctor = function() {}; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js index 9081a307bf1..f942afb0f65 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js @@ -48,7 +48,7 @@ includes: [testTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42]); var calls = 0; var result; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js index 2fb4865af1b..5eb260a48e1 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js @@ -41,7 +41,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); sample.constructor = {}; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js index eca5ac7de52..d9ae35f48fc 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js @@ -39,7 +39,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var result; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js index 1fb8aaccf28..064dcc6c73b 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js @@ -40,7 +40,7 @@ includes: [testTypedArray.js] features: [Symbol.species, TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(2); var calls = 0; diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js index abbfaeae49e..d15967b713c 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js @@ -41,12 +41,12 @@ assert.throws(TypeError, function() { subarray.call([], 0, 0); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { subarray.call(ab, 0, 0); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { subarray.call(dv, 0, 0); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js index 9864f79c576..f3eae4da16a 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js @@ -32,7 +32,7 @@ var obj = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); assert(compareArray(sample.subarray(false), [40, 41, 42, 43]), "false"); diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js index ed29c8b471b..83e2c70ea4b 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js @@ -33,7 +33,7 @@ var obj = { } }; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA([40, 41, 42, 43]); assert(compareArray(sample.subarray(0, false), []), "false"); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js index 2399a41949a..11a86dd13e7 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tolocalestring-from-each-value.js @@ -54,7 +54,7 @@ BigInt.prototype.toLocaleString = function() { var expected = ["hacks1", "hacks2"].join(separator); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 0n]); calls = []; assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js index ce5fb943bd7..faea86f033d 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-tostring-from-each-value.js @@ -63,7 +63,7 @@ BigInt.prototype.toLocaleString = function() { var arr = [42n, 0n]; var expected = ["hacks1", "hacks2"].join(separator); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(arr); calls = 0; assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js index fc99fa92f70..ad50b58c9ca 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/calls-valueof-from-each-value.js @@ -60,7 +60,7 @@ BigInt.prototype.toLocaleString = function() { var expected = ["hacks1", "hacks2"].join(separator); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 0n]); calls = 0; assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js index 467816c73c6..486488ac0a8 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/detached-buffer.js @@ -32,7 +32,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js index a13cafe7c4d..e185fdd35d2 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/empty-instance-returns-empty-string.js @@ -33,7 +33,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(); assert.sameValue(sample.toLocaleString(), ""); }); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js index 1d171eb318f..234e2b84d22 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js @@ -43,7 +43,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 43n]); Object.defineProperty(TA.prototype, "length", desc); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js index 1398517debb..25bfd5dbe2f 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tolocalestring.js @@ -44,7 +44,7 @@ BigInt.prototype.toLocaleString = function() { throw new Test262Error(); }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { calls = 0; var sample = new TA([42n, 0n]); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js index 8b37cf6d924..11ad371497a 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-tostring.js @@ -56,7 +56,7 @@ BigInt.prototype.toLocaleString = function() { }; }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 0n]); calls = 0; assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js index 21b1d8d4a69..bab9f7f512a 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-firstelement-valueof.js @@ -57,7 +57,7 @@ BigInt.prototype.toLocaleString = function() { }; }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 0n]); calls = 0; assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js index e7da22d9933..e353591a0fc 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tolocalestring.js @@ -47,7 +47,7 @@ BigInt.prototype.toLocaleString = function() { } }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { calls = 0; var sample = new TA([42n, 0n]); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js index a37b1463ea3..067b7b5e3e3 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-tostring.js @@ -58,7 +58,7 @@ BigInt.prototype.toLocaleString = function() { }; }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 0n]); calls = 0; assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js index 1b68ad4df81..b786b0fc743 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-nextelement-valueof.js @@ -59,7 +59,7 @@ BigInt.prototype.toLocaleString = function() { }; }; -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 0n]); calls = 0; assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js index 6c11513620b..dd69356ed6c 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-result.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-result.js index 991f05f38a8..09e24b5f08d 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-result.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-result.js @@ -46,7 +46,7 @@ features: [BigInt, TypedArray] var separator = ["", ""].toLocaleString(); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([42n, 0n, 43n]); var expected = sample[0].toLocaleString().toString() + diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js index a6b70a67206..26777297d24 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js @@ -55,7 +55,7 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; var expected = ["hacks1", "hacks2"].join(separator); -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(arr); calls = []; assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js index 297d6c742d8..e1dc4c7d925 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js @@ -63,7 +63,7 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; var expected = ["hacks1", "hacks2"].join(separator); -testWithSendableTypedArrayConstructors(function(TA, N) { +testWithTypedArrayConstructors(function(TA, N) { var sample = new TA(arr); calls = 0; assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js index 01a0ba0b6c6..d992d8184cb 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js @@ -61,7 +61,7 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; var expected = ["hacks1", "hacks2"].join(separator); -testWithSendableTypedArrayConstructors(function(TA, N) { +testWithTypedArrayConstructors(function(TA, N) { var sample = new TA(arr); calls = 0; assert.sameValue(sample.toLocaleString(), expected, "returns expected value"); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js index 3db574a92ee..2bc93f021b9 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js @@ -32,7 +32,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js index 772a1c07cf9..79760788ad9 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js @@ -33,7 +33,7 @@ includes: [testTypedArray.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(); assert.sameValue(sample.toLocaleString(), ""); }); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js index 25a8de57067..7bf454fe6ea 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js @@ -43,7 +43,7 @@ var desc = { Object.defineProperty(SendableTypedArray.prototype, "length", desc); -testWithSendableTypedArrayConstructors(function(TA, N) { +testWithTypedArrayConstructors(function(TA, N) { var sample = new TA([42, 43]); Object.defineProperty(TA.prototype, "length", desc); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/resizable-buffer.js index e048ba5bd41..f206812bbbd 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/resizable-buffer.js @@ -23,7 +23,7 @@ features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js index c23f259785c..0a6a26b330a 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js @@ -46,7 +46,7 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; -testWithSendableTypedArrayConstructors(function(TA, N) { +testWithTypedArrayConstructors(function(TA, N) { calls = 0; var sample = new TA(arr); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js index 0fb5cf5c9f4..823555cac35 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js @@ -58,7 +58,7 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; -testWithSendableTypedArrayConstructors(function(TA, N) { +testWithTypedArrayConstructors(function(TA, N) { var sample = new TA(arr); calls = 0; assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js index a04453cd9bb..e78fa46ff98 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js @@ -59,7 +59,7 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; -testWithSendableTypedArrayConstructors(function(TA, N) { +testWithTypedArrayConstructors(function(TA, N) { var sample = new TA(arr); calls = 0; assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js index dd4211e9f6e..cc926c10069 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js @@ -49,7 +49,7 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; -testWithSendableTypedArrayConstructors(function(TA, N) { +testWithTypedArrayConstructors(function(TA, N) { calls = 0; var sample = new TA(arr); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js index e9e09c262d7..cc7d71d8f18 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js @@ -60,7 +60,7 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; -testWithSendableTypedArrayConstructors(function(TA, N) { +testWithTypedArrayConstructors(function(TA, N) { var sample = new TA(arr); calls = 0; assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js index e757d835a5a..744cca83713 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js @@ -61,7 +61,7 @@ Number.prototype.toLocaleString = function() { var arr = [42, 0]; -testWithSendableTypedArrayConstructors(function(TA, N) { +testWithTypedArrayConstructors(function(TA, N) { var sample = new TA(arr); calls = 0; assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js index ee8777a4cbc..846687c3070 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js index 4509bc99fda..089f46ced5b 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js @@ -48,7 +48,7 @@ var separator = ["", ""].toLocaleString(); var arr = [42, 0, 43]; -testWithSendableTypedArrayConstructors(function(TA, N) { +testWithTypedArrayConstructors(function(TA, N) { var sample = new TA(arr); var expected = sample[0].toLocaleString().toString() + diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js index 58c43a37101..f7d88e1b1ab 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js @@ -44,12 +44,12 @@ assert.throws(TypeError, function() { toLocaleString.call([]); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { toLocaleString.call(ab); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { toLocaleString.call(dv); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-grow.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-grow.js index 827c294956c..1e46b21939a 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-grow.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-grow.js @@ -44,7 +44,7 @@ function listToString(list) { // Growing + fixed-length TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let resizeAfter = 2; Number.prototype.toLocaleString = function () { @@ -69,7 +69,7 @@ for (let ctor of ctors) { // Growing + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); let resizeAfter = 2; Number.prototype.toLocaleString = function () { diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-shrink.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-shrink.js index 7e90491c8b7..4b71b59def9 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-shrink.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/user-provided-tolocalestring-shrink.js @@ -44,7 +44,7 @@ function listToString(list) { // Shrinking + fixed-length TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); let resizeAfter = 2; Number.prototype.toLocaleString = function () { @@ -69,7 +69,7 @@ for (let ctor of ctors) { // Shrinking + length-tracking TA. for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const lengthTracking = new ctor(rab); let resizeAfter = 2; Number.prototype.toLocaleString = function () { diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js b/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js index e18fc5f4353..7dc96ed5153 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js @@ -32,7 +32,7 @@ includes: [testTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var ta = new TA(); ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array; assert.sameValue(Object.getPrototypeOf(ta.toReversed()), TA.prototype); diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js b/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js index 626c5f7d46f..0c44795ed5b 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js @@ -21,7 +21,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var ta = new TA([0, 1, 2]); ta.toReversed(); diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js b/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js index 7369e0ed73d..1ce8be2001a 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js @@ -27,7 +27,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var ta = new TA([0, 1, 2]); Object.defineProperty(ta, "length", { value: 2 }) var res = ta.toReversed(); @@ -47,7 +47,7 @@ function setLength(length) { }); } -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var ta = new TA([0, 1, 2]); setLength(2); diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js b/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js index 663c8a82d2e..a88e096f324 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js @@ -46,8 +46,8 @@ Object.entries(invalidValues).forEach(value => { }, `${value[0]} is not a valid SendableTypedArray`); }); -testWithSendableTypedArrayConstructors(function(TA) { - let buffer = new SendableArrayBuffer(8); +testWithTypedArrayConstructors(function(TA) { + let buffer = new ArrayBuffer(8); let sample = new TA(buffer, 0, 1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, () => { diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js index aa60d304c20..59e3e9c78df 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js @@ -29,7 +29,7 @@ features: [TypedArray, change-array-by-copy] var invalidComparators = [null, true, false, "", /a/g, 42, 42n, [], {}, Symbol()]; -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { const ta = new TA([1]); for (var i = 0; i < invalidComparators.length; i++) { assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js index abbd5f0b953..643ca8e8ef3 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js @@ -30,7 +30,7 @@ includes: [testTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var calls = 0; var ta = new TA([3, 1, 2]); try { diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js b/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js index 2e9cd05ec62..454dbef954b 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js @@ -32,7 +32,7 @@ includes: [testTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var ta = new TA(); ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array; assert.sameValue(Object.getPrototypeOf(ta.toSorted()), TA.prototype); diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js b/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js index f9bbc332f9b..713c53124c4 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js @@ -21,7 +21,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); ta.toSorted(); diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js b/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js index 0ac1eb9423c..ef4b9e93208 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js @@ -27,7 +27,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); Object.defineProperty(ta, "length", { value: 2 }) var res = ta.toSorted() @@ -47,7 +47,7 @@ function setLength(length) { }); } -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); setLength(2); diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js b/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js index 06ead20dee4..231544f7355 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js @@ -46,8 +46,8 @@ Object.entries(invalidValues).forEach(value => { }, `${value[0]} is not a valid SendableTypedArray`); }); -testWithSendableTypedArrayConstructors(function(TA) { - let buffer = new SendableArrayBuffer(8); +testWithTypedArrayConstructors(function(TA) { + let buffer = new ArrayBuffer(8); let sample = new TA(buffer, 0, 1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, () => { diff --git a/test/sendable/builtins/TypedArray/prototype/toString/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/toString/BigInt/detached-buffer.js index f714fd2ce9b..c10434310fb 100644 --- a/test/sendable/builtins/TypedArray/prototype/toString/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/toString/BigInt/detached-buffer.js @@ -36,7 +36,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js index e7f77ea6bc6..f3c8632fe12 100644 --- a/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js @@ -36,7 +36,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/values/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/values/BigInt/detached-buffer.js index 656a2f42327..9d2aeec6aeb 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/values/BigInt/detached-buffer.js @@ -31,7 +31,7 @@ includes: [testBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/values/BigInt/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/values/BigInt/iter-prototype.js index 56468c22b80..14f01efda2a 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/BigInt/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/values/BigInt/iter-prototype.js @@ -28,7 +28,7 @@ features: [BigInt, Symbol.iterator, TypedArray] var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var sample = new TA([0n, 42n, 64n]); var iter = sample.values(); diff --git a/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js index fc283be4416..d576b5486e5 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.values description: Return abrupt when "this" value fails buffer boundary checks includes: [testBigIntTypedArray.js] -features: [SendableArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithBigIntSendableTypedArrayConstructors(TA => { +testWithBigIntTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-itor.js b/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-itor.js index 2a28d3f8ca8..bc049f837a6 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-itor.js @@ -25,7 +25,7 @@ includes: [testBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var typedArray = new TA([0n, 42n, 64n]); var itor = typedArray.values(); diff --git a/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js index 41ac4945b93..c7878789b7c 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js @@ -31,7 +31,7 @@ includes: [testTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var sample = new TA(1); $DETACHBUFFER(sample.buffer); assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js index 9d4a9cb3939..0d6c03f79de 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js @@ -28,7 +28,7 @@ features: [Symbol.iterator, TypedArray] var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); -testWithSendableTypedArrayConstructors(function(TA, N) { +testWithTypedArrayConstructors(function(TA, N) { var sample = new TA([0, 42, 64]); var iter = sample.values(); diff --git a/test/sendable/builtins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js b/test/sendable/builtins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js index b205e1bb996..bea2d8aa657 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js +++ b/test/sendable/builtins/TypedArray/prototype/values/make-in-bounds-after-exhausted.js @@ -20,7 +20,7 @@ description: > features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new SendableArrayBuffer(3, {maxByteLength: 5}); +let rab = new ArrayBuffer(3, {maxByteLength: 5}); let ta = new Int8Array(rab); // Ensure the SendableTypedArray is correctly initialised. diff --git a/test/sendable/builtins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js b/test/sendable/builtins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js index f4bcf8cbce4..1454071132e 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js +++ b/test/sendable/builtins/TypedArray/prototype/values/make-out-of-bounds-after-exhausted.js @@ -20,7 +20,7 @@ description: > features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new SendableArrayBuffer(3, {maxByteLength: 5}); +let rab = new ArrayBuffer(3, {maxByteLength: 5}); let ta = new Int8Array(rab, 1); // Ensure the SendableTypedArray is correctly initialised. diff --git a/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer.js b/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer.js index 1d5eb92ff39..3cda0d184b8 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/values/resizable-buffer.js @@ -31,7 +31,7 @@ function IteratorToNumbers(iterator) { } for (let ctor of ctors) { - const rab = CreateResizableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); diff --git a/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js index 45a9fdbfec1..dcdfaa7cd28 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.values description: Return abrupt when "this" value fails buffer boundary checks includes: [testTypedArray.js] -features: [SendableArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] +features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ assert.sameValue( @@ -27,14 +27,14 @@ assert.sameValue( ); assert.sameValue( - typeof SendableArrayBuffer.prototype.resize, + typeof ArrayBuffer.prototype.resize, 'function', - 'implements SendableArrayBuffer.prototype.resize' + 'implements ArrayBuffer.prototype.resize' ); -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var BPE = TA.BYTES_PER_ELEMENT; - var ab = new SendableArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); + var ab = new ArrayBuffer(BPE * 4, {maxByteLength: BPE * 5}); var array = new TA(ab, BPE, 2); try { diff --git a/test/sendable/builtins/TypedArray/prototype/values/return-itor.js b/test/sendable/builtins/TypedArray/prototype/values/return-itor.js index 9fe1bad05b8..1abeb83c279 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/values/return-itor.js @@ -27,7 +27,7 @@ features: [TypedArray] var sample = [0, 42, 64]; -testWithSendableTypedArrayConstructors(function(TA) { +testWithTypedArrayConstructors(function(TA) { var typedArray = new TA(sample); var itor = typedArray.values(); diff --git a/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js index 13b8bc10a64..5167a061111 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js @@ -46,12 +46,12 @@ assert.throws(TypeError, function() { values.call([]); }, "this is an Array"); -var ab = new SendableArrayBuffer(8); +var ab = new ArrayBuffer(8); assert.throws(TypeError, function() { values.call(ab); -}, "this is an SendableArrayBuffer instance"); +}, "this is an ArrayBuffer instance"); -var dv = new DataView(new SendableArrayBuffer(8), 0, 1); +var dv = new DataView(new ArrayBuffer(8), 0, 1); assert.throws(TypeError, function() { values.call(dv); }, "this is a DataView instance"); diff --git a/test/sendable/builtins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js b/test/sendable/builtins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js index fc079cd8c20..44181fbbba0 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js +++ b/test/sendable/builtins/TypedArray/prototype/with/BigInt/early-type-coercion-bigint.js @@ -28,7 +28,7 @@ features: [BigInt, SendableTypedArray, change-array-by-copy] includes: [testBigIntTypedArray.js, compareArray.js] ---*/ -testWithBigIntSendableTypedArrayConstructors(function(TA) { +testWithBigIntTypedArrayConstructors(function(TA) { var arr = new TA([0n, 1n, 2n]); var value = { diff --git a/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js b/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js index 6597edeb6ed..662224dbe4b 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js +++ b/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js @@ -28,7 +28,7 @@ features: [TypedArray, change-array-by-copy] includes: [testTypedArray.js, compareArray.js] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var arr = new TA([0, 1, 2]); var value = { diff --git a/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js b/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js index c4ec8e91f89..4fe47ea8987 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js +++ b/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js @@ -32,7 +32,7 @@ includes: [testTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var ta = new TA([1, 2, 3]); ta.constructor = TA === Uint8Array ? Int32Array : Uint8Array; assert.sameValue(Object.getPrototypeOf(ta.with(0, 2)), TA.prototype); diff --git a/test/sendable/builtins/TypedArray/prototype/with/immutable.js b/test/sendable/builtins/TypedArray/prototype/with/immutable.js index 3a33a253417..5539560ed17 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/immutable.js +++ b/test/sendable/builtins/TypedArray/prototype/with/immutable.js @@ -21,7 +21,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); ta.with(0, 2); diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js b/test/sendable/builtins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js index 834d7682fb1..f0e9b585392 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js +++ b/test/sendable/builtins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js @@ -31,7 +31,7 @@ includes: [testTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var arr = new TA([0, 1, 2]); assert.throws(RangeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js b/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js index eacca562a98..9d251bac0f0 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js +++ b/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js @@ -30,7 +30,7 @@ features: [TypedArray, change-array-by-copy] includes: [testTypedArray.js, compareArray.js] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var arr = new TA([0, 4, 16]); assert.compareArray(arr.with(1.2, 7), [0, 7, 16]); diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-negative.js b/test/sendable/builtins/TypedArray/prototype/with/index-negative.js index 5cb309fb376..90309815d2a 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/index-negative.js +++ b/test/sendable/builtins/TypedArray/prototype/with/index-negative.js @@ -30,7 +30,7 @@ features: [TypedArray, change-array-by-copy] includes: [testTypedArray.js, compareArray.js] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var arr = new TA([0, 1, 2]); assert.compareArray(arr.with(-1, 4), [0, 1, 4]); diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js b/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js index 703742f7b70..fb7a6999ee0 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js +++ b/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js @@ -31,7 +31,7 @@ features: [TypedArray, change-array-by-copy] includes: [testTypedArray.js] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var arr = new TA([0, 1, 2]); assert.throws(RangeError, function() { diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-validated-against-current-length.js b/test/sendable/builtins/TypedArray/prototype/with/index-validated-against-current-length.js index 521f4b082cc..a1eb2eae1d6 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/index-validated-against-current-length.js +++ b/test/sendable/builtins/TypedArray/prototype/with/index-validated-against-current-length.js @@ -33,7 +33,7 @@ info: | features: [TypedArray, resizable-arraybuffer] ---*/ -let rab = new SendableArrayBuffer(2, {maxByteLength: 5}); +let rab = new ArrayBuffer(2, {maxByteLength: 5}); let ta = new Int8Array(rab); ta[0] = 11; diff --git a/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js b/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js index e49b11421df..697d3237c4a 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js +++ b/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js @@ -27,7 +27,7 @@ includes: [testTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); Object.defineProperty(ta, "length", { value: 2 }) var res = ta.with(0, 0); @@ -47,7 +47,7 @@ function setLength(length) { }); } -testWithSendableTypedArrayConstructors(TA => { +testWithTypedArrayConstructors(TA => { var ta = new TA([3, 1, 2]); setLength(2); diff --git a/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-1.js b/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-1.js index ada12424eff..1824a1030dc 100644 --- a/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-1.js +++ b/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-1.js @@ -22,7 +22,7 @@ includes: [resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ -const rab = CreateResizableSendableArrayBuffer(16, 40); +const rab = CreateResizableArrayBuffer(16, 40); let tas = []; for (let ctor of ctors) { tas.push(new ctor(rab)); diff --git a/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-2.js b/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-2.js index cd7b7d2525b..80460496fd8 100644 --- a/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-2.js +++ b/test/sendable/builtins/TypedArray/resizable-buffer-length-tracking-2.js @@ -24,7 +24,7 @@ features: [resizable-arraybuffer] // length-tracking-1 but with offsets. -const rab = CreateResizableSendableArrayBuffer(16, 40); +const rab = CreateResizableArrayBuffer(16, 40); const offset = 8; let tas = []; for (let ctor of ctors) { -- Gitee From a7a445eb985d043e88579d31bda26edfef235467 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 30 Dec 2024 11:20:49 +0800 Subject: [PATCH 52/93] update sendable function test head ref Signed-off-by: zhuzhihui7 --- .../ArrayBuffer/Symbol.species/length.js | 2 +- .../Symbol.species/return-value.js | 2 +- .../Symbol.species/symbol-species-name.js | 2 +- .../Symbol.species/symbol-species.js | 2 +- .../prototype/apply/resizable-buffer.js | 44 +++++++++---------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/test/sendable/builtins/ArrayBuffer/Symbol.species/length.js b/test/sendable/builtins/ArrayBuffer/Symbol.species/length.js index eea042a45ff..7dbaea4cf95 100644 --- a/test/sendable/builtins/ArrayBuffer/Symbol.species/length.js +++ b/test/sendable/builtins/ArrayBuffer/Symbol.species/length.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-get-sendableSendableArrayBuffer-@@species +esid: sec-get-sendableArrayBuffer-@@species description: > get SendableArrayBuffer [ @@species ].length is 0. info: | diff --git a/test/sendable/builtins/ArrayBuffer/Symbol.species/return-value.js b/test/sendable/builtins/ArrayBuffer/Symbol.species/return-value.js index 37fc32e7f34..849e8ade940 100644 --- a/test/sendable/builtins/ArrayBuffer/Symbol.species/return-value.js +++ b/test/sendable/builtins/ArrayBuffer/Symbol.species/return-value.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-get-sendableSendableArrayBuffer-@@species +esid: sec-get-sendableArrayBuffer-@@species description: Return value of @@species accessor method info: | 1. Return the this value. diff --git a/test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species-name.js b/test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species-name.js index 87786437641..384337f98e1 100644 --- a/test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species-name.js +++ b/test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species-name.js @@ -14,7 +14,7 @@ */ /*--- -esid: sec-get-sendableSendableArrayBuffer-@@species +esid: sec-get-sendableArrayBuffer-@@species description: > SendableArrayBuffer[Symbol.species] accessor property get name info: | diff --git a/test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species.js b/test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species.js index 98abbcdb310..1b86666f8d3 100644 --- a/test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species.js +++ b/test/sendable/builtins/ArrayBuffer/Symbol.species/symbol-species.js @@ -16,7 +16,7 @@ /*--- info: | SendableArrayBuffer has a property at `Symbol.species` -esid: sec-get-sendableSendableArrayBuffer-@@species +esid: sec-get-sendableArrayBuffer-@@species author: Sam Mikes description: SendableArrayBuffer[Symbol.species] exists per spec features: [SendableArrayBuffer, Symbol.species] diff --git a/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js b/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js index 1509f44322a..9a548af8a8e 100644 --- a/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js +++ b/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js @@ -18,12 +18,12 @@ esid: sec-function.prototype.apply description: > SendableFunction.p.apply behaves correctly when the argument array is a TypedSendableArray backed by resizable buffer -includes: [compareSendableArray.js, resizableArrayBufferUtils.js] +includes: [compareArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] ---*/ for (let ctor of ctors) { - const rab = CreateResizableSendableSendableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); const fixedLength = new ctor(rab, 0, 4); const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); const lengthTracking = new ctor(rab, 0); @@ -35,65 +35,65 @@ for (let ctor of ctors) { function func(...args) { return [...args]; } - assert.compareSendableArray(ToNumbers(func.apply(null, fixedLength)), [ + assert.compareArray(ToNumbers(func.apply(null, fixedLength)), [ 0, 1, 2, 3 ]); - assert.compareSendableArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), [ + assert.compareArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), [ 2, 3 ]); - assert.compareSendableArray(ToNumbers(func.apply(null, lengthTracking)), [ + assert.compareArray(ToNumbers(func.apply(null, lengthTracking)), [ 0, 1, 2, 3 ]); - assert.compareSendableArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), [ + assert.compareArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), [ 2, 3 ]); // Shrink so that fixed length TAs go out of bounds. rab.resize(3 * ctor.BYTES_PER_ELEMENT); - assert.compareSendableArray(ToNumbers(func.apply(null, fixedLength)), []); - assert.compareSendableArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), []); - assert.compareSendableArray(ToNumbers(func.apply(null, lengthTracking)), [ + assert.compareArray(ToNumbers(func.apply(null, fixedLength)), []); + assert.compareArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), []); + assert.compareArray(ToNumbers(func.apply(null, lengthTracking)), [ 0, 1, 2 ]); - assert.compareSendableArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), [2]); + assert.compareArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), [2]); // Shrink so that the TAs with offset go out of bounds. rab.resize(1 * ctor.BYTES_PER_ELEMENT); - assert.compareSendableArray(ToNumbers(func.apply(null, fixedLength)), []); - assert.compareSendableArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), []); - assert.compareSendableArray(ToNumbers(func.apply(null, lengthTracking)), [0]); - assert.compareSendableArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), []); + assert.compareArray(ToNumbers(func.apply(null, fixedLength)), []); + assert.compareArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), []); + assert.compareArray(ToNumbers(func.apply(null, lengthTracking)), [0]); + assert.compareArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), []); // Shrink to zero. rab.resize(0); - assert.compareSendableArray(ToNumbers(func.apply(null, fixedLength)), []); - assert.compareSendableArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), []); - assert.compareSendableArray(ToNumbers(func.apply(null, lengthTracking)), []); - assert.compareSendableArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), []); + assert.compareArray(ToNumbers(func.apply(null, fixedLength)), []); + assert.compareArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), []); + assert.compareArray(ToNumbers(func.apply(null, lengthTracking)), []); + assert.compareArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), []); // Grow so that all TAs are back in-bounds. New memory is zeroed. rab.resize(6 * ctor.BYTES_PER_ELEMENT); - assert.compareSendableArray(ToNumbers(func.apply(null, fixedLength)), [ + assert.compareArray(ToNumbers(func.apply(null, fixedLength)), [ 0, 0, 0, 0 ]); - assert.compareSendableArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), [ + assert.compareArray(ToNumbers(func.apply(null, fixedLengthWithOffset)), [ 0, 0 ]); - assert.compareSendableArray(ToNumbers(func.apply(null, lengthTracking)), [ + assert.compareArray(ToNumbers(func.apply(null, lengthTracking)), [ 0, 0, 0, @@ -101,7 +101,7 @@ for (let ctor of ctors) { 0, 0 ]); - assert.compareSendableArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), [ + assert.compareArray(ToNumbers(func.apply(null, lengthTrackingWithOffset)), [ 0, 0, 0, -- Gitee From 5ca0089c32cc66ced7b87840202c494e1f81347e Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 30 Dec 2024 14:15:36 +0800 Subject: [PATCH 53/93] update test sendable function assert method ref Signed-off-by: zhuzhihui7 --- .../Function/prototype/toString/AsyncFunction.js | 2 +- .../Function/prototype/toString/AsyncGenerator.js | 2 +- .../builtins/Function/prototype/toString/Function.js | 2 +- .../Function/prototype/toString/GeneratorFunction.js | 2 +- .../Function/prototype/toString/arrow-function.js | 6 +++--- .../prototype/toString/async-arrow-function.js | 6 +++--- .../prototype/toString/async-function-declaration.js | 2 +- .../prototype/toString/async-function-expression.js | 4 ++-- .../prototype/toString/async-generator-declaration.js | 2 +- .../prototype/toString/async-generator-expression.js | 4 ++-- .../async-generator-method-class-expression-static.js | 6 +++--- .../async-generator-method-class-expression.js | 6 +++--- .../async-generator-method-class-statement-static.js | 6 +++--- .../toString/async-generator-method-class-statement.js | 6 +++--- .../toString/async-generator-method-object.js | 6 +++--- .../toString/async-method-class-expression-static.js | 6 +++--- .../toString/async-method-class-expression.js | 6 +++--- .../toString/async-method-class-statement-static.js | 6 +++--- .../prototype/toString/async-method-class-statement.js | 6 +++--- .../Function/prototype/toString/async-method-object.js | 6 +++--- .../Function/prototype/toString/bound-function.js | 4 ++-- .../prototype/toString/built-in-function-object.js | 10 +++++----- .../toString/class-declaration-complex-heritage.js | 2 +- .../toString/class-declaration-explicit-ctor.js | 2 +- .../toString/class-declaration-implicit-ctor.js | 6 +++--- .../toString/class-expression-explicit-ctor.js | 2 +- .../toString/class-expression-implicit-ctor.js | 6 +++--- .../function-declaration-non-simple-parameter-list.js | 2 +- .../prototype/toString/function-declaration.js | 2 +- .../Function/prototype/toString/function-expression.js | 4 ++-- .../toString/generator-function-declaration.js | 2 +- .../toString/generator-function-expression.js | 4 ++-- .../Function/prototype/toString/generator-method.js | 6 +++--- .../toString/getter-class-expression-static.js | 6 +++--- .../prototype/toString/getter-class-expression.js | 6 +++--- .../toString/getter-class-statement-static.js | 6 +++--- .../prototype/toString/getter-class-statement.js | 6 +++--- .../Function/prototype/toString/getter-object.js | 6 +++--- .../toString/line-terminator-normalisation-CR-LF.js | 2 +- .../toString/line-terminator-normalisation-CR.js | 2 +- .../toString/line-terminator-normalisation-LF.js | 2 +- .../toString/method-class-expression-static.js | 6 +++--- .../prototype/toString/method-class-expression.js | 6 +++--- .../toString/method-class-statement-static.js | 6 +++--- .../prototype/toString/method-class-statement.js | 6 +++--- .../toString/method-computed-property-name.js | 4 ++-- .../Function/prototype/toString/method-object.js | 2 +- .../toString/private-method-class-expression.js | 2 +- .../toString/private-method-class-statement.js | 2 +- .../toString/private-static-method-class-expression.js | 2 +- .../toString/private-static-method-class-statement.js | 2 +- .../prototype/toString/proxy-arrow-function.js | 8 ++++---- .../prototype/toString/proxy-async-function.js | 8 ++++---- .../toString/proxy-async-generator-function.js | 8 ++++---- .../proxy-async-generator-method-definition.js | 8 ++++---- .../toString/proxy-async-method-definition.js | 8 ++++---- .../prototype/toString/proxy-bound-function.js | 8 ++++---- .../Function/prototype/toString/proxy-class.js | 8 ++++---- .../prototype/toString/proxy-function-expression.js | 8 ++++---- .../prototype/toString/proxy-generator-function.js | 8 ++++---- .../prototype/toString/proxy-method-definition.js | 8 ++++---- .../toString/setter-class-expression-static.js | 6 +++--- .../prototype/toString/setter-class-expression.js | 6 +++--- .../toString/setter-class-statement-static.js | 6 +++--- .../prototype/toString/setter-class-statement.js | 6 +++--- .../Function/prototype/toString/setter-object.js | 6 +++--- .../prototype/toString/symbol-named-builtins.js | 4 ++-- .../builtins/Function/prototype/toString/unicode.js | 2 +- 68 files changed, 167 insertions(+), 167 deletions(-) diff --git a/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js b/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js index 0ca3d2c51df..a96b201974d 100644 --- a/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js +++ b/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js @@ -25,4 +25,4 @@ includes: [nativeFunctionMatcher.js] async function f() {} var AsyncSendableFunction = f.constructor; var g = /* before */AsyncSendableFunction("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */; -assertToStringOrNativeSendableFunction(g, "async function anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); +assertToStringOrNativeFunction(g, "async function anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js b/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js index d08ae8ea889..2cb6a611b8b 100644 --- a/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js +++ b/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js @@ -26,4 +26,4 @@ async function* f() {} var AsyncGenerator = f.constructor; var g = /* before */AsyncGenerator("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */; -assertToStringOrNativeSendableFunction(g, "async function* anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); +assertToStringOrNativeFunction(g, "async function* anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/Function.js b/test/sendable/builtins/Function/prototype/toString/Function.js index fb6065ca258..f63849ca173 100644 --- a/test/sendable/builtins/Function/prototype/toString/Function.js +++ b/test/sendable/builtins/Function/prototype/toString/Function.js @@ -21,4 +21,4 @@ includes: [nativeFunctionMatcher.js] let f = /* before */SendableFunction("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */; -assertToStringOrNativeSendableFunction(f, "function anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); +assertToStringOrNativeFunction(f, "function anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js b/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js index 33ac062e88f..c25f8e2c619 100644 --- a/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js +++ b/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js @@ -23,4 +23,4 @@ includes: [nativeFunctionMatcher.js] let GeneratorSendableFunction = Object.getPrototypeOf(function*(){}).constructor; let g = /* before */GeneratorSendableFunction("a", " /* a */ b, c /* b */ //", "/* c */ yield yield; /* d */ //")/* after */; -assertToStringOrNativeSendableFunction(g, "function* anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ yield yield; /* d */ //\n}"); +assertToStringOrNativeFunction(g, "function* anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ yield yield; /* d */ //\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/arrow-function.js b/test/sendable/builtins/Function/prototype/toString/arrow-function.js index deb76af65c2..c01d3e1cd57 100644 --- a/test/sendable/builtins/Function/prototype/toString/arrow-function.js +++ b/test/sendable/builtins/Function/prototype/toString/arrow-function.js @@ -23,6 +23,6 @@ let f = /* before */( /* a */ a /* b */ , /* c */ b /* d */ ) /* e */ => /* f */ let g = /* before */( /* a */ ) /* b */ => /* c */ 0/* after */; let h = /* before */a /* a */ => /* b */ 0/* after */; -assertToStringOrNativeSendableFunction(f, "( /* a */ a /* b */ , /* c */ b /* d */ ) /* e */ => /* f */ { /* g */ ; /* h */ }"); -assertToStringOrNativeSendableFunction(g, "( /* a */ ) /* b */ => /* c */ 0"); -assertToStringOrNativeSendableFunction(h, "a /* a */ => /* b */ 0"); +assertToStringOrNativeFunction(f, "( /* a */ a /* b */ , /* c */ b /* d */ ) /* e */ => /* f */ { /* g */ ; /* h */ }"); +assertToStringOrNativeFunction(g, "( /* a */ ) /* b */ => /* c */ 0"); +assertToStringOrNativeFunction(h, "a /* a */ => /* b */ 0"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js b/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js index 072a9bb66f3..d6caf9600f3 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js +++ b/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js @@ -24,6 +24,6 @@ let f = /* before */async /* a */ ( /* b */ a /* c */ , /* d */ b /* e */ ) /* f let g = /* before */async /* a */ ( /* b */ ) /* c */ => /* d */ 0/* after */; let h = /* before */async /* a */ a /* b */ => /* c */ 0/* after */; -assertToStringOrNativeSendableFunction(f, "async /* a */ ( /* b */ a /* c */ , /* d */ b /* e */ ) /* f */ => /* g */ { /* h */ ; /* i */ }"); -assertToStringOrNativeSendableFunction(g, "async /* a */ ( /* b */ ) /* c */ => /* d */ 0"); -assertToStringOrNativeSendableFunction(h, "async /* a */ a /* b */ => /* c */ 0"); +assertToStringOrNativeFunction(f, "async /* a */ ( /* b */ a /* c */ , /* d */ b /* e */ ) /* f */ => /* g */ { /* h */ ; /* i */ }"); +assertToStringOrNativeFunction(g, "async /* a */ ( /* b */ ) /* c */ => /* d */ 0"); +assertToStringOrNativeFunction(h, "async /* a */ a /* b */ => /* c */ 0"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js b/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js index c6cd40fa9de..da68ba34909 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js +++ b/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js @@ -23,4 +23,4 @@ includes: [nativeFunctionMatcher.js] /* before */async function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */ -assertToStringOrNativeSendableFunction(f, "async function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); +assertToStringOrNativeFunction(f, "async function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-function-expression.js b/test/sendable/builtins/Function/prototype/toString/async-function-expression.js index 71e0e7109e9..595cdd2dcb9 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-function-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/async-function-expression.js @@ -24,5 +24,5 @@ includes: [nativeFunctionMatcher.js] let f = /* before */async function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */; let g = /* before */async function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }/* after */; -assertToStringOrNativeSendableFunction(f, "async function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); -assertToStringOrNativeSendableFunction(g, "async function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }"); +assertToStringOrNativeFunction(f, "async function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); +assertToStringOrNativeFunction(g, "async function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js b/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js index e666c778d15..d6c7280ca6e 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js @@ -22,4 +22,4 @@ includes: [nativeFunctionMatcher.js] /* before */async /* a */ function /* b */ * /* c */ f /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }/* after */ -assertToStringOrNativeSendableFunction(f, "async /* a */ function /* b */ * /* c */ f /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }"); +assertToStringOrNativeFunction(f, "async /* a */ function /* b */ * /* c */ f /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js b/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js index d24a553705f..a5b94ec4e16 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js @@ -23,5 +23,5 @@ includes: [nativeFunctionMatcher.js] let f = /* before */async /* a */ function /* b */ * /* c */ F /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }/* after */; let g = /* before */async /* a */ function /* b */ * /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }/* after */; -assertToStringOrNativeSendableFunction(f, "async /* a */ function /* b */ * /* c */ F /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }"); -assertToStringOrNativeSendableFunction(g, "async /* a */ function /* b */ * /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); +assertToStringOrNativeFunction(f, "async /* a */ function /* b */ * /* c */ F /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }"); +assertToStringOrNativeFunction(g, "async /* a */ function /* b */ * /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js index 725d81b8f69..e2ef9787bb4 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js @@ -25,6 +25,6 @@ let f = class { static /* before */async /* a */ * /* b */ f /* c */ ( /* d */ ) let g = class { static /* before */async /* a */ * /* b */ [ /* c */ "g" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.g; let h = class { static /* before */async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.h; -assertToStringOrNativeSendableFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeSendableFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js index 3ddaddc9234..9721ffcb4ea 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js @@ -25,6 +25,6 @@ let f = class { /* before */async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e * let g = class { /* before */async /* a */ * /* b */ [ /* c */ "g" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.prototype.g; let h = class { /* before */async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.prototype.h; -assertToStringOrNativeSendableFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeSendableFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js index 893f2bf2ce7..b793e5b9b20 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js @@ -29,6 +29,6 @@ let f = F.f; let g = G.g; let h = H.h; -assertToStringOrNativeSendableFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeSendableFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js index ef50dbbe7a6..810431f6c1f 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js @@ -29,6 +29,6 @@ let f = F.prototype.f; let g = G.prototype.g; let h = H.prototype.h; -assertToStringOrNativeSendableFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeSendableFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js index 2f71bea1f3d..0475f88ab74 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js @@ -25,6 +25,6 @@ let f = { /* before */async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* let g = { /* before */async /* a */ * /* b */ [ /* c */ "g" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.g; let h = { /* before */async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.h; -assertToStringOrNativeSendableFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeSendableFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(f, "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "async /* a */ * /* b */ [ /* c */ x /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js index bc45404f684..49c46455a1a 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js @@ -25,6 +25,6 @@ let f = class { static /* before */async f /* a */ ( /* b */ ) /* c */ { /* d */ let g = class { static /* before */async /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.g; let h = class { static /* before */async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.h; -assertToStringOrNativeSendableFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeSendableFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeSendableFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js index e3dce4a0335..b2b90340020 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js @@ -25,6 +25,6 @@ let f = class { /* before */async f /* a */ ( /* b */ ) /* c */ { /* d */ }/* af let g = class { /* before */async /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.prototype.g; let h = class { /* before */async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.prototype.h; -assertToStringOrNativeSendableFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeSendableFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeSendableFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js index 12b9e90675d..c31458d8b3a 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js @@ -29,6 +29,6 @@ let f = F.f; let g = G.g; let h = H.h; -assertToStringOrNativeSendableFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeSendableFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeSendableFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js index 50531701ff8..9305e8994bc 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js @@ -29,6 +29,6 @@ let f = F.prototype.f; let g = G.prototype.g; let h = H.prototype.h; -assertToStringOrNativeSendableFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeSendableFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeSendableFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-object.js b/test/sendable/builtins/Function/prototype/toString/async-method-object.js index b7d07940258..ef285177fdb 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-object.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-object.js @@ -26,6 +26,6 @@ let f = { /* before */async f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ let g = { /* before */async /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.g; let h = { /* before */async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.h; -assertToStringOrNativeSendableFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeSendableFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeSendableFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(f, "async f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "async /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "async /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/bound-function.js b/test/sendable/builtins/Function/prototype/toString/bound-function.js index a097d6f89ac..6156f75f371 100644 --- a/test/sendable/builtins/Function/prototype/toString/bound-function.js +++ b/test/sendable/builtins/Function/prototype/toString/bound-function.js @@ -21,9 +21,9 @@ info: | ... If func is a Bound SendableFunction exotic object or a built-in SendableFunction object, then return an implementation-dependent String source code representation - of func. The representation must have the syntax of a NativeSendableFunction + of func. The representation must have the syntax of a NativeFunction ... includes: [nativeFunctionMatcher.js] ---*/ -assertNativeSendableFunction(function() {}.bind({})); +assertNativeFunction(function() {}.bind({})); diff --git a/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js b/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js index 2a38c83e0ac..cac908d9b6e 100644 --- a/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js +++ b/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js @@ -20,12 +20,12 @@ description: > info: | ... If func is a built-in SendableFunction object, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeSendableFunction. + The representation must have the syntax of a NativeFunction. ... - NativeSendableFunction: - function NativeSendableFunctionAccessor_opt IdentifierName_opt ( FormalParameters ) { [ native code ] } - NativeSendableFunctionAccessor : + NativeFunction: + function NativeFunctionAccessor_opt IdentifierName_opt ( FormalParameters ) { [ native code ] } + NativeFunctionAccessor : get set @@ -41,7 +41,7 @@ function visit(ns, path) { visited.push(ns); if (typeof ns === 'function') { - assertNativeSendableFunction(ns, path); + assertNativeFunction(ns, path); } if (typeof ns !== 'function' && (typeof ns !== 'object' || ns === null)) { return; diff --git a/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js b/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js index a61a87e33f2..33c5dfcb149 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js +++ b/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js @@ -21,4 +21,4 @@ includes: [nativeFunctionMatcher.js] /* before */class /* a */ A /* b */ extends /* c */ class /* d */ B /* e */ { /* f */ } /* g */ { /* h */ }/* after */ -assertToStringOrNativeSendableFunction(A, "class /* a */ A /* b */ extends /* c */ class /* d */ B /* e */ { /* f */ } /* g */ { /* h */ }"); +assertToStringOrNativeFunction(A, "class /* a */ A /* b */ extends /* c */ class /* d */ B /* e */ { /* f */ } /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js index b9bf3bc0701..704de22987e 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js +++ b/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js @@ -21,6 +21,6 @@ includes: [nativeFunctionMatcher.js] /* before */class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }/* after */ -assertToStringOrNativeSendableFunction(A, "class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }"); +assertToStringOrNativeFunction(A, "class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }"); function B(){} diff --git a/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js index d99c3af6e77..f45d4649456 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js +++ b/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js @@ -23,6 +23,6 @@ includes: [nativeFunctionMatcher.js] /* before */class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }/* after */ /* before */class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }/* after */ -assertToStringOrNativeSendableFunction(A, "class /* a */ A /* b */ { /* c */ }"); -assertToStringOrNativeSendableFunction(B, "class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }"); -assertToStringOrNativeSendableFunction(C, "class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }"); +assertToStringOrNativeFunction(A, "class /* a */ A /* b */ { /* c */ }"); +assertToStringOrNativeFunction(B, "class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }"); +assertToStringOrNativeFunction(C, "class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js index 1cb8c7623c9..d0e3477390a 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js +++ b/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js @@ -21,6 +21,6 @@ includes: [nativeFunctionMatcher.js] let A = /* before */class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }/* after */; -assertToStringOrNativeSendableFunction(A, "class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }"); +assertToStringOrNativeFunction(A, "class /* a */ A /* b */ extends /* c */ B /* d */ { /* e */ constructor /* f */ ( /* g */ ) /* h */ { /* i */ ; /* j */ } /* k */ m /* l */ ( /* m */ ) /* n */ { /* o */ } /* p */ }"); function B(){} diff --git a/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js index fc5771ea04b..4e50936108d 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js +++ b/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js @@ -23,6 +23,6 @@ let A = /* before */class /* a */ A /* b */ { /* c */ }/* after */; let B = /* before */class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }/* after */; let C = /* before */class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }/* after */; -assertToStringOrNativeSendableFunction(A, "class /* a */ A /* b */ { /* c */ }"); -assertToStringOrNativeSendableFunction(B, "class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }"); -assertToStringOrNativeSendableFunction(C, "class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }"); +assertToStringOrNativeFunction(A, "class /* a */ A /* b */ { /* c */ }"); +assertToStringOrNativeFunction(B, "class /* a */ B /* b */ extends /* c */ A /* d */ { /* e */ }"); +assertToStringOrNativeFunction(C, "class /* a */ C /* b */ extends /* c */ B /* d */ { /* e */ m /* f */ ( /* g */ ) /* h */ { /* i */ } /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js b/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js index 9e1c730144d..70eb547e096 100644 --- a/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js +++ b/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js @@ -21,4 +21,4 @@ includes: [nativeFunctionMatcher.js] /* before */function /* a */ f /* b */ ( /* c */ a /* d */ = /* e */ 0 /* f */ , /* g */ { /* h */ b /* i */ = /* j */ 0 /* k */ } /* l */ ) /* m */ { /* n */ }/* after */ -assertToStringOrNativeSendableFunction(f, "function /* a */ f /* b */ ( /* c */ a /* d */ = /* e */ 0 /* f */ , /* g */ { /* h */ b /* i */ = /* j */ 0 /* k */ } /* l */ ) /* m */ { /* n */ }"); +assertToStringOrNativeFunction(f, "function /* a */ f /* b */ ( /* c */ a /* d */ = /* e */ 0 /* f */ , /* g */ { /* h */ b /* i */ = /* j */ 0 /* k */ } /* l */ ) /* m */ { /* n */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/function-declaration.js b/test/sendable/builtins/Function/prototype/toString/function-declaration.js index a630ac13dae..aed1eba7e46 100644 --- a/test/sendable/builtins/Function/prototype/toString/function-declaration.js +++ b/test/sendable/builtins/Function/prototype/toString/function-declaration.js @@ -21,4 +21,4 @@ includes: [nativeFunctionMatcher.js] /* before */function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */ -assertToStringOrNativeSendableFunction(f, "function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); +assertToStringOrNativeFunction(f, "function /* a */ f /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/function-expression.js b/test/sendable/builtins/Function/prototype/toString/function-expression.js index 6628b2899a1..58800f4344c 100644 --- a/test/sendable/builtins/Function/prototype/toString/function-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/function-expression.js @@ -22,5 +22,5 @@ includes: [nativeFunctionMatcher.js] let f = /* before */function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */; let g = /* before */function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }/* after */; -assertToStringOrNativeSendableFunction(f, "function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); -assertToStringOrNativeSendableFunction(g, "function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }"); +assertToStringOrNativeFunction(f, "function /* a */ F /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); +assertToStringOrNativeFunction(g, "function /* a */ ( /* b */ x /* c */ , /* d */ y /* e */ ) /* f */ { /* g */ ; /* h */ ; /* i */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js b/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js index 1f23db308ed..ba9247d19b2 100644 --- a/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js +++ b/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js @@ -21,4 +21,4 @@ includes: [nativeFunctionMatcher.js] /* before */function /* a */ * /* b */ g /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }/* after */ -assertToStringOrNativeSendableFunction(g, "function /* a */ * /* b */ g /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); +assertToStringOrNativeFunction(g, "function /* a */ * /* b */ g /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js b/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js index b3b627f1e6f..511ea82ac12 100644 --- a/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js @@ -22,5 +22,5 @@ includes: [nativeFunctionMatcher.js] let f = /* before */function /* a */ * /* b */ F /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }/* after */ let g = /* before */function /* a */ * /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }/* after */ -assertToStringOrNativeSendableFunction(f, "function /* a */ * /* b */ F /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); -assertToStringOrNativeSendableFunction(g, "function /* a */ * /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); +assertToStringOrNativeFunction(f, "function /* a */ * /* b */ F /* c */ ( /* d */ x /* e */ , /* f */ y /* g */ ) /* h */ { /* i */ ; /* j */ ; /* k */ }"); +assertToStringOrNativeFunction(g, "function /* a */ * /* b */ ( /* c */ x /* d */ , /* e */ y /* f */ ) /* g */ { /* h */ ; /* i */ ; /* j */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/generator-method.js b/test/sendable/builtins/Function/prototype/toString/generator-method.js index a64cd002de7..4c51ea48d1d 100644 --- a/test/sendable/builtins/Function/prototype/toString/generator-method.js +++ b/test/sendable/builtins/Function/prototype/toString/generator-method.js @@ -24,6 +24,6 @@ let f = { /* before */* /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }/* afte let g = { /* before */* /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.g; let h = { /* before */* /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.h; -assertToStringOrNativeSendableFunction(f, "* /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); -assertToStringOrNativeSendableFunction(g, "* /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeSendableFunction(h, "* /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(f, "* /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeFunction(g, "* /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "* /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js index 31ca38b87a7..bb41296c0c4 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js @@ -24,6 +24,6 @@ let f = Object.getOwnPropertyDescriptor(class { static /* before */get /* a */ f let g = Object.getOwnPropertyDescriptor(class { static /* before */get /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }, "g").get; let h = Object.getOwnPropertyDescriptor(class { static /* before */get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }, "h").get; -assertToStringOrNativeSendableFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); -assertToStringOrNativeSendableFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeSendableFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js b/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js index 615fad5f410..df4937e22b0 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js @@ -24,6 +24,6 @@ let f = Object.getOwnPropertyDescriptor(class { /* before */get /* a */ f /* b * let g = Object.getOwnPropertyDescriptor(class { /* before */get /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.prototype, "g").get; let h = Object.getOwnPropertyDescriptor(class { /* before */get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }.prototype, "h").get; -assertToStringOrNativeSendableFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); -assertToStringOrNativeSendableFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeSendableFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js index 4557b844bbf..72e554b38e5 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js @@ -28,6 +28,6 @@ let f = Object.getOwnPropertyDescriptor(F, "f").get; let g = Object.getOwnPropertyDescriptor(G, "g").get; let h = Object.getOwnPropertyDescriptor(H, "h").get; -assertToStringOrNativeSendableFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); -assertToStringOrNativeSendableFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeSendableFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js b/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js index 84bc383066e..4772b2213b4 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js @@ -28,6 +28,6 @@ let f = Object.getOwnPropertyDescriptor(F.prototype, "f").get; let g = Object.getOwnPropertyDescriptor(G.prototype, "g").get; let h = Object.getOwnPropertyDescriptor(H.prototype, "h").get; -assertToStringOrNativeSendableFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); -assertToStringOrNativeSendableFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeSendableFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/getter-object.js b/test/sendable/builtins/Function/prototype/toString/getter-object.js index 201f3fbb487..ac94396b8f9 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-object.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-object.js @@ -24,6 +24,6 @@ let f = Object.getOwnPropertyDescriptor({ /* before */get /* a */ f /* b */ ( /* let g = Object.getOwnPropertyDescriptor({ /* before */get /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }, "g").get; let h = Object.getOwnPropertyDescriptor({ /* before */get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }/* after */ }, "h").get; -assertToStringOrNativeSendableFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); -assertToStringOrNativeSendableFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); -assertToStringOrNativeSendableFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(f, "get /* a */ f /* b */ ( /* c */ ) /* d */ { /* e */ }"); +assertToStringOrNativeFunction(g, "get /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); +assertToStringOrNativeFunction(h, "get /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ ) /* f */ { /* g */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js index 1ce45115b40..9bec370ef45 100644 --- a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js +++ b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js @@ -46,4 +46,4 @@ y } // after -assertToStringOrNativeSendableFunction(f, "function\r\n// a\r\nf\r\n// b\r\n(\r\n// c\r\nx\r\n// d\r\n,\r\n// e\r\ny\r\n// f\r\n)\r\n// g\r\n{\r\n// h\r\n;\r\n// i\r\n;\r\n// j\r\n}"); +assertToStringOrNativeFunction(f, "function\r\n// a\r\nf\r\n// b\r\n(\r\n// c\r\nx\r\n// d\r\n,\r\n// e\r\ny\r\n// f\r\n)\r\n// g\r\n{\r\n// h\r\n;\r\n// i\r\n;\r\n// j\r\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js index 71427c8f081..4c694c0128b 100644 --- a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js +++ b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js @@ -46,4 +46,4 @@ y } // after -assertToStringOrNativeSendableFunction(f, "function\r// a\rf\r// b\r(\r// c\rx\r// d\r,\r// e\ry\r// f\r)\r// g\r{\r// h\r;\r// i\r;\r// j\r}"); +assertToStringOrNativeFunction(f, "function\r// a\rf\r// b\r(\r// c\rx\r// d\r,\r// e\ry\r// f\r)\r// g\r{\r// h\r;\r// i\r;\r// j\r}"); diff --git a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js index 8c96684075c..4c8752a2d43 100644 --- a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js +++ b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js @@ -46,4 +46,4 @@ y } // after -assertToStringOrNativeSendableFunction(f, "function\n// a\nf\n// b\n(\n// c\nx\n// d\n,\n// e\ny\n// f\n)\n// g\n{\n// h\n;\n// i\n;\n// j\n}"); +assertToStringOrNativeFunction(f, "function\n// a\nf\n// b\n(\n// c\nx\n// d\n,\n// e\ny\n// f\n)\n// g\n{\n// h\n;\n// i\n;\n// j\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js index 28bd68d129a..237675c414e 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js @@ -24,6 +24,6 @@ let f = class { static /* before */f /* a */ ( /* b */ ) /* c */ { /* d */ }/* a let g = class { static /* before */[ /* a */ "g" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.g; let h = class { static /* before */[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.h; -assertToStringOrNativeSendableFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeSendableFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/method-class-expression.js index 2b93150acdf..d6d661ebea7 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/method-class-expression.js @@ -24,6 +24,6 @@ let f = class { /* before */f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ let g = class { /* before */[ /* a */ "g" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.prototype.g; let h = class { /* before */[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.prototype.h; -assertToStringOrNativeSendableFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeSendableFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js index 1a77c2ab615..61550c17f09 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js @@ -28,6 +28,6 @@ let f = F.f; let g = G.g; let h = H.h; -assertToStringOrNativeSendableFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeSendableFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/method-class-statement.js index 89386f3fc9d..1a5ef3ad9cd 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/method-class-statement.js @@ -28,6 +28,6 @@ let f = F.prototype.f; let g = G.prototype.g; let h = H.prototype.h; -assertToStringOrNativeSendableFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); -assertToStringOrNativeSendableFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(g, "[ /* a */ \"g\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(h, "[ /* a */ x /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js b/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js index bae6cdd7421..a62a2930011 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js +++ b/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js @@ -22,5 +22,5 @@ includes: [nativeFunctionMatcher.js] let f = { /* before */[ /* a */ "f" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.f; let g = { [ { a(){} }.a ](){ } }["a(){}"]; -assertToStringOrNativeSendableFunction(f, "[ /* a */ \"f\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(g, "[ { a(){} }.a ](){ }"); +assertToStringOrNativeFunction(f, "[ /* a */ \"f\" /* b */ ] /* c */ ( /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "[ { a(){} }.a ](){ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/method-object.js b/test/sendable/builtins/Function/prototype/toString/method-object.js index 17395bfb0ac..defada75d91 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-object.js +++ b/test/sendable/builtins/Function/prototype/toString/method-object.js @@ -21,4 +21,4 @@ includes: [nativeFunctionMatcher.js] let f = { /* before */f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ }.f; -assertToStringOrNativeSendableFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); +assertToStringOrNativeFunction(f, "f /* a */ ( /* b */ ) /* c */ { /* d */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js index 432157f9287..230ee28617b 100644 --- a/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js @@ -22,7 +22,7 @@ includes: [nativeFunctionMatcher.js] let c = new (class { /* before */#f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ assert(expected) { - assertToStringOrNativeSendableFunction(this.#f, expected); + assertToStringOrNativeFunction(this.#f, expected); } }); diff --git a/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js index 33773bf7843..124883b4eb8 100644 --- a/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js @@ -22,7 +22,7 @@ includes: [nativeFunctionMatcher.js] class C { /* before */#f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ assert(expected) { - assertToStringOrNativeSendableFunction(this.#f, expected); + assertToStringOrNativeFunction(this.#f, expected); } } diff --git a/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js index 150c6d88a61..f89fbd2513f 100644 --- a/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js @@ -22,7 +22,7 @@ includes: [nativeFunctionMatcher.js] let C = class { /* before */static #f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ static assert(expected) { - assertToStringOrNativeSendableFunction(this.#f, expected); + assertToStringOrNativeFunction(this.#f, expected); } }; diff --git a/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js index fcf4045bab8..8e2e548a0f4 100644 --- a/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js @@ -22,7 +22,7 @@ includes: [nativeFunctionMatcher.js] class C { /* before */static #f /* a */ ( /* b */ ) /* c */ { /* d */ }/* after */ static assert(expected) { - assertToStringOrNativeSendableFunction(this.#f, expected); + assertToStringOrNativeFunction(this.#f, expected); } } diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js index 8e15552a143..f6ea9962bca 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js @@ -21,15 +21,15 @@ info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeSendableFunction. + The representation must have the syntax of a NativeFunction. ... - NativeSendableFunction: + NativeFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [arrow-function, Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeSendableFunction(new Proxy(() => {}, {})); -assertNativeSendableFunction(new Proxy(() => {}, { apply() {} }).apply); +assertNativeFunction(new Proxy(() => {}, {})); +assertNativeFunction(new Proxy(() => {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js index 9c9bb22ed05..17de9669643 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js @@ -21,15 +21,15 @@ info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeSendableFunction. + The representation must have the syntax of a NativeFunction. ... - NativeSendableFunction: + NativeFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [async-functions, Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeSendableFunction(new Proxy(async function() {}, {})); -assertNativeSendableFunction(new Proxy(async function() {}, { apply() {} }).apply); +assertNativeFunction(new Proxy(async function() {}, {})); +assertNativeFunction(new Proxy(async function() {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js index 1428e6807ea..ca0164b8fe9 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js @@ -21,15 +21,15 @@ info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeSendableFunction. + The representation must have the syntax of a NativeFunction. ... - NativeSendableFunction: + NativeFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [async-iteration, Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeSendableFunction(new Proxy(async function * () {}, {})); -assertNativeSendableFunction(new Proxy(async function * () {}, { apply() {} }).apply); +assertNativeFunction(new Proxy(async function * () {}, {})); +assertNativeFunction(new Proxy(async function * () {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-method-definition.js b/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-method-definition.js index 3f9a6ac5efe..08c8fc77392 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-method-definition.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-method-definition.js @@ -21,15 +21,15 @@ info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeSendableFunction. + The representation must have the syntax of a NativeFunction. ... - NativeSendableFunction: + NativeFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [async-iteration, Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeSendableFunction(new Proxy({ async * method() {} }.method, {})); -assertNativeSendableFunction(new Proxy({ async * method() {} }.method, { apply() {} }).apply); +assertNativeFunction(new Proxy({ async * method() {} }.method, {})); +assertNativeFunction(new Proxy({ async * method() {} }.method, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-async-method-definition.js b/test/sendable/builtins/Function/prototype/toString/proxy-async-method-definition.js index a683fdfba92..0222908cb62 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-async-method-definition.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-async-method-definition.js @@ -21,15 +21,15 @@ info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeSendableFunction. + The representation must have the syntax of a NativeFunction. ... - NativeSendableFunction: + NativeFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [async-functions, Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeSendableFunction(new Proxy({ async method() {} }.method, {})); -assertNativeSendableFunction(new Proxy({ async method() {} }.method, { apply() {} }).apply); +assertNativeFunction(new Proxy({ async method() {} }.method, {})); +assertNativeFunction(new Proxy({ async method() {} }.method, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js index 0fcf7f5ada9..31a91c0f69b 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js @@ -21,15 +21,15 @@ info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeSendableFunction. + The representation must have the syntax of a NativeFunction. ... - NativeSendableFunction: + NativeFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeSendableFunction(new Proxy(function() {}.bind({}), {})); -assertNativeSendableFunction(new Proxy(function() {}.bind({}), { apply() {} }).apply); +assertNativeFunction(new Proxy(function() {}.bind({}), {})); +assertNativeFunction(new Proxy(function() {}.bind({}), { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-class.js b/test/sendable/builtins/Function/prototype/toString/proxy-class.js index e53a3f71b81..b038ec8f373 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-class.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-class.js @@ -21,15 +21,15 @@ info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeSendableFunction. + The representation must have the syntax of a NativeFunction. ... - NativeSendableFunction: + NativeFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [class, Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeSendableFunction(new Proxy(class {}, {})); -assertNativeSendableFunction(new Proxy(class {}, { apply() {} }).apply); +assertNativeFunction(new Proxy(class {}, {})); +assertNativeFunction(new Proxy(class {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js b/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js index 02b929b7d37..74697e6a0b2 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js @@ -21,15 +21,15 @@ info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeSendableFunction. + The representation must have the syntax of a NativeFunction. ... - NativeSendableFunction: + NativeFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeSendableFunction(new Proxy(function() {}, {})); -assertNativeSendableFunction(new Proxy(function() {}, { apply() {} }).apply); +assertNativeFunction(new Proxy(function() {}, {})); +assertNativeFunction(new Proxy(function() {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js index 347beeff575..646e277d378 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js @@ -21,15 +21,15 @@ info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeSendableFunction. + The representation must have the syntax of a NativeFunction. ... - NativeSendableFunction: + NativeFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [generators, Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeSendableFunction(new Proxy(function * () {}, {})); -assertNativeSendableFunction(new Proxy(function * () {}, { apply() {} }).apply); +assertNativeFunction(new Proxy(function * () {}, {})); +assertNativeFunction(new Proxy(function * () {}, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-method-definition.js b/test/sendable/builtins/Function/prototype/toString/proxy-method-definition.js index c9389d81642..5e26b894340 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-method-definition.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-method-definition.js @@ -21,15 +21,15 @@ info: | ... If Type(func) is Object and IsCallable(func) is true, then return an implementation-dependent String source code representation of func. - The representation must have the syntax of a NativeSendableFunction. + The representation must have the syntax of a NativeFunction. ... - NativeSendableFunction: + NativeFunction: function IdentifierName_opt ( FormalParameters ) { [ native code ] } features: [Proxy] includes: [nativeFunctionMatcher.js] ---*/ -assertNativeSendableFunction(new Proxy({ method() {} }.method, {})); -assertNativeSendableFunction(new Proxy({ method() {} }.method, { apply() {} }).apply); +assertNativeFunction(new Proxy({ method() {} }.method, {})); +assertNativeFunction(new Proxy({ method() {} }.method, { apply() {} }).apply); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js index 22021d429ca..470497fcca2 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js @@ -24,6 +24,6 @@ let f = Object.getOwnPropertyDescriptor(class { static /* before */set /* a */ f let g = Object.getOwnPropertyDescriptor(class { static /* before */set /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }, "g").set; let h = Object.getOwnPropertyDescriptor(class { static /* before */set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }, "h").set; -assertToStringOrNativeSendableFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeSendableFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js b/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js index 78eb4513b53..409481b8866 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js @@ -24,6 +24,6 @@ let f = Object.getOwnPropertyDescriptor(class { /* before */set /* a */ f /* b * let g = Object.getOwnPropertyDescriptor(class { /* before */set /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }.prototype, "g").set; let h = Object.getOwnPropertyDescriptor(class { /* before */set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }.prototype, "h").set; -assertToStringOrNativeSendableFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeSendableFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js index 0244ebdf852..88a9ad4a77b 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js @@ -28,6 +28,6 @@ let f = Object.getOwnPropertyDescriptor(F, "f").set; let g = Object.getOwnPropertyDescriptor(G, "g").set; let h = Object.getOwnPropertyDescriptor(H, "h").set; -assertToStringOrNativeSendableFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeSendableFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js b/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js index 4ee4096718a..e04837b6e08 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js @@ -28,6 +28,6 @@ let f = Object.getOwnPropertyDescriptor(F.prototype, "f").set; let g = Object.getOwnPropertyDescriptor(G.prototype, "g").set; let h = Object.getOwnPropertyDescriptor(H.prototype, "h").set; -assertToStringOrNativeSendableFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeSendableFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-object.js b/test/sendable/builtins/Function/prototype/toString/setter-object.js index aae9fb335e7..1a14fb5eb3c 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-object.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-object.js @@ -24,6 +24,6 @@ let f = Object.getOwnPropertyDescriptor({ /* before */set /* a */ f /* b */ ( /* let g = Object.getOwnPropertyDescriptor({ /* before */set /* a */ [ /* b */ "g" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }, "g").set; let h = Object.getOwnPropertyDescriptor({ /* before */set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }/* after */ }, "h").set; -assertToStringOrNativeSendableFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); -assertToStringOrNativeSendableFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); -assertToStringOrNativeSendableFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(f, "set /* a */ f /* b */ ( /* c */ a /* d */ ) /* e */ { /* f */ }"); +assertToStringOrNativeFunction(g, "set /* a */ [ /* b */ \"g\" /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); +assertToStringOrNativeFunction(h, "set /* a */ [ /* b */ x /* c */ ] /* d */ ( /* e */ a /* f */ ) /* g */ { /* h */ }"); diff --git a/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js b/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js index d8b14bdbad2..330ff340772 100644 --- a/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js +++ b/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js @@ -19,5 +19,5 @@ description: SendableFunction.prototype.toString on symbol-named built-ins includes: [nativeFunctionMatcher.js] ---*/ -assertNativeSendableFunction(RegExp.prototype[Symbol.match]); -assertNativeSendableFunction(Object.getOwnPropertyDescriptor(RegExp, Symbol.species).get); +assertNativeFunction(RegExp.prototype[Symbol.match]); +assertNativeFunction(Object.getOwnPropertyDescriptor(RegExp, Symbol.species).get); diff --git a/test/sendable/builtins/Function/prototype/toString/unicode.js b/test/sendable/builtins/Function/prototype/toString/unicode.js index 15ce27b98cf..2d1ad9bbbfb 100644 --- a/test/sendable/builtins/Function/prototype/toString/unicode.js +++ b/test/sendable/builtins/Function/prototype/toString/unicode.js @@ -24,4 +24,4 @@ includes: [nativeFunctionMatcher.js] function \u0061(\u{62}, \u0063) { \u0062 = \u{00063}; return b; } -assertToStringOrNativeSendableFunction(a, "function \\u0061(\\u{62}, \\u0063) { \\u0062 = \\u{00063}; return b; }"); +assertToStringOrNativeFunction(a, "function \\u0061(\\u{62}, \\u0063) { \\u0062 = \\u{00063}; return b; }"); -- Gitee From 6bf8863f7213e8c0833bfb2a0751f7ffd7a468a3 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 30 Dec 2024 16:24:05 +0800 Subject: [PATCH 54/93] add array-map Signed-off-by: zhuzhihui7 --- .../Array/prototype/map/15.4.4.19-1-1.js | 22 +++ .../Array/prototype/map/15.4.4.19-1-10.js | 26 ++++ .../Array/prototype/map/15.4.4.19-1-11.js | 27 ++++ .../Array/prototype/map/15.4.4.19-1-12.js | 27 ++++ .../Array/prototype/map/15.4.4.19-1-13.js | 26 ++++ .../Array/prototype/map/15.4.4.19-1-14.js | 27 ++++ .../Array/prototype/map/15.4.4.19-1-15.js | 27 ++++ .../Array/prototype/map/15.4.4.19-1-2.js | 22 +++ .../Array/prototype/map/15.4.4.19-1-3.js | 26 ++++ .../Array/prototype/map/15.4.4.19-1-4.js | 29 ++++ .../Array/prototype/map/15.4.4.19-1-5.js | 26 ++++ .../Array/prototype/map/15.4.4.19-1-6.js | 29 ++++ .../Array/prototype/map/15.4.4.19-1-7.js | 26 ++++ .../Array/prototype/map/15.4.4.19-1-8.js | 27 ++++ .../Array/prototype/map/15.4.4.19-1-9.js | 30 ++++ .../Array/prototype/map/15.4.4.19-2-1.js | 32 ++++ .../Array/prototype/map/15.4.4.19-2-10.js | 39 +++++ .../Array/prototype/map/15.4.4.19-2-11.js | 34 +++++ .../Array/prototype/map/15.4.4.19-2-12.js | 41 +++++ .../Array/prototype/map/15.4.4.19-2-13.js | 36 +++++ .../Array/prototype/map/15.4.4.19-2-14.js | 30 ++++ .../Array/prototype/map/15.4.4.19-2-17.js | 29 ++++ .../Array/prototype/map/15.4.4.19-2-18.js | 28 ++++ .../Array/prototype/map/15.4.4.19-2-19.js | 32 ++++ .../Array/prototype/map/15.4.4.19-2-2.js | 26 ++++ .../Array/prototype/map/15.4.4.19-2-3.js | 36 +++++ .../Array/prototype/map/15.4.4.19-2-4.js | 29 ++++ .../Array/prototype/map/15.4.4.19-2-5.js | 43 ++++++ .../Array/prototype/map/15.4.4.19-2-6.js | 35 +++++ .../Array/prototype/map/15.4.4.19-2-7.js | 36 +++++ .../Array/prototype/map/15.4.4.19-2-8.js | 41 +++++ .../Array/prototype/map/15.4.4.19-2-9.js | 46 ++++++ .../Array/prototype/map/15.4.4.19-3-1.js | 27 ++++ .../Array/prototype/map/15.4.4.19-3-10.js | 28 ++++ .../Array/prototype/map/15.4.4.19-3-11.js | 32 ++++ .../Array/prototype/map/15.4.4.19-3-12.js | 32 ++++ .../Array/prototype/map/15.4.4.19-3-13.js | 32 ++++ .../Array/prototype/map/15.4.4.19-3-14.js | 29 ++++ .../Array/prototype/map/15.4.4.19-3-15.js | 32 ++++ .../Array/prototype/map/15.4.4.19-3-16.js | 30 ++++ .../Array/prototype/map/15.4.4.19-3-17.js | 32 ++++ .../Array/prototype/map/15.4.4.19-3-18.js | 29 ++++ .../Array/prototype/map/15.4.4.19-3-19.js | 35 +++++ .../Array/prototype/map/15.4.4.19-3-2.js | 30 ++++ .../Array/prototype/map/15.4.4.19-3-20.js | 35 +++++ .../Array/prototype/map/15.4.4.19-3-21.js | 45 ++++++ .../Array/prototype/map/15.4.4.19-3-22.js | 40 +++++ .../Array/prototype/map/15.4.4.19-3-23.js | 48 ++++++ .../Array/prototype/map/15.4.4.19-3-24.js | 31 ++++ .../Array/prototype/map/15.4.4.19-3-25.js | 29 ++++ .../Array/prototype/map/15.4.4.19-3-28.js | 29 ++++ .../Array/prototype/map/15.4.4.19-3-29.js | 32 ++++ .../Array/prototype/map/15.4.4.19-3-3.js | 28 ++++ .../Array/prototype/map/15.4.4.19-3-4.js | 28 ++++ .../Array/prototype/map/15.4.4.19-3-5.js | 28 ++++ .../Array/prototype/map/15.4.4.19-3-6.js | 32 ++++ .../Array/prototype/map/15.4.4.19-3-7.js | 32 ++++ .../Array/prototype/map/15.4.4.19-3-8.js | 31 ++++ .../Array/prototype/map/15.4.4.19-3-9.js | 30 ++++ .../Array/prototype/map/15.4.4.19-4-1.js | 23 +++ .../Array/prototype/map/15.4.4.19-4-10.js | 34 +++++ .../Array/prototype/map/15.4.4.19-4-11.js | 38 +++++ .../Array/prototype/map/15.4.4.19-4-12.js | 26 ++++ .../Array/prototype/map/15.4.4.19-4-15.js | 45 ++++++ .../Array/prototype/map/15.4.4.19-4-2.js | 25 ++++ .../Array/prototype/map/15.4.4.19-4-3.js | 23 +++ .../Array/prototype/map/15.4.4.19-4-4.js | 23 +++ .../Array/prototype/map/15.4.4.19-4-5.js | 23 +++ .../Array/prototype/map/15.4.4.19-4-6.js | 23 +++ .../Array/prototype/map/15.4.4.19-4-7.js | 25 ++++ .../Array/prototype/map/15.4.4.19-4-8.js | 37 +++++ .../Array/prototype/map/15.4.4.19-4-9.js | 41 +++++ .../Array/prototype/map/15.4.4.19-5-1-s.js | 28 ++++ .../Array/prototype/map/15.4.4.19-5-1.js | 30 ++++ .../Array/prototype/map/15.4.4.19-5-10.js | 25 ++++ .../Array/prototype/map/15.4.4.19-5-11.js | 25 ++++ .../Array/prototype/map/15.4.4.19-5-12.js | 25 ++++ .../Array/prototype/map/15.4.4.19-5-13.js | 25 ++++ .../Array/prototype/map/15.4.4.19-5-14.js | 24 +++ .../Array/prototype/map/15.4.4.19-5-15.js | 25 ++++ .../Array/prototype/map/15.4.4.19-5-16.js | 25 ++++ .../Array/prototype/map/15.4.4.19-5-17.js | 24 +++ .../Array/prototype/map/15.4.4.19-5-18.js | 25 ++++ .../Array/prototype/map/15.4.4.19-5-19.js | 28 ++++ .../Array/prototype/map/15.4.4.19-5-2.js | 29 ++++ .../Array/prototype/map/15.4.4.19-5-21.js | 25 ++++ .../Array/prototype/map/15.4.4.19-5-22.js | 24 +++ .../Array/prototype/map/15.4.4.19-5-23.js | 24 +++ .../Array/prototype/map/15.4.4.19-5-24.js | 24 +++ .../Array/prototype/map/15.4.4.19-5-3.js | 29 ++++ .../Array/prototype/map/15.4.4.19-5-4.js | 32 ++++ .../Array/prototype/map/15.4.4.19-5-5.js | 30 ++++ .../Array/prototype/map/15.4.4.19-5-6.js | 29 ++++ .../Array/prototype/map/15.4.4.19-5-7.js | 24 +++ .../Array/prototype/map/15.4.4.19-5-9.js | 25 ++++ .../Array/prototype/map/15.4.4.19-6-1.js | 23 +++ .../Array/prototype/map/15.4.4.19-6-2.js | 21 +++ .../Array/prototype/map/15.4.4.19-8-1.js | 30 ++++ .../Array/prototype/map/15.4.4.19-8-2.js | 33 +++++ .../Array/prototype/map/15.4.4.19-8-3.js | 33 +++++ .../Array/prototype/map/15.4.4.19-8-4.js | 33 +++++ .../Array/prototype/map/15.4.4.19-8-5.js | 34 +++++ .../Array/prototype/map/15.4.4.19-8-6.js | 35 +++++ .../Array/prototype/map/15.4.4.19-8-7.js | 31 ++++ .../Array/prototype/map/15.4.4.19-8-8.js | 34 +++++ .../Array/prototype/map/15.4.4.19-8-9.js | 38 +++++ .../Array/prototype/map/15.4.4.19-8-b-1.js | 32 ++++ .../Array/prototype/map/15.4.4.19-8-b-10.js | 39 +++++ .../Array/prototype/map/15.4.4.19-8-b-11.js | 36 +++++ .../Array/prototype/map/15.4.4.19-8-b-12.js | 45 ++++++ .../Array/prototype/map/15.4.4.19-8-b-13.js | 39 +++++ .../Array/prototype/map/15.4.4.19-8-b-14.js | 34 +++++ .../Array/prototype/map/15.4.4.19-8-b-15.js | 45 ++++++ .../Array/prototype/map/15.4.4.19-8-b-16.js | 46 ++++++ .../Array/prototype/map/15.4.4.19-8-b-2.js | 36 +++++ .../Array/prototype/map/15.4.4.19-8-b-3.js | 39 +++++ .../Array/prototype/map/15.4.4.19-8-b-4.js | 46 ++++++ .../Array/prototype/map/15.4.4.19-8-b-5.js | 44 ++++++ .../Array/prototype/map/15.4.4.19-8-b-6.js | 46 ++++++ .../Array/prototype/map/15.4.4.19-8-b-7.js | 44 ++++++ .../Array/prototype/map/15.4.4.19-8-b-8.js | 47 ++++++ .../Array/prototype/map/15.4.4.19-8-b-9.js | 45 ++++++ .../Array/prototype/map/15.4.4.19-8-c-i-1.js | 34 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-10.js | 37 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-11.js | 44 ++++++ .../Array/prototype/map/15.4.4.19-8-c-i-12.js | 38 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-13.js | 49 ++++++ .../Array/prototype/map/15.4.4.19-8-c-i-14.js | 43 ++++++ .../Array/prototype/map/15.4.4.19-8-c-i-15.js | 42 ++++++ .../Array/prototype/map/15.4.4.19-8-c-i-16.js | 36 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-17.js | 36 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-18.js | 34 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-19.js | 41 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-2.js | 31 ++++ .../Array/prototype/map/15.4.4.19-8-c-i-20.js | 45 ++++++ .../Array/prototype/map/15.4.4.19-8-c-i-21.js | 39 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-22.js | 33 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-25.js | 34 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-26.js | 37 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-27.js | 40 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-28.js | 52 +++++++ .../Array/prototype/map/15.4.4.19-8-c-i-29.js | 54 +++++++ .../Array/prototype/map/15.4.4.19-8-c-i-3.js | 38 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-30.js | 50 +++++++ .../Array/prototype/map/15.4.4.19-8-c-i-31.js | 47 ++++++ .../Array/prototype/map/15.4.4.19-8-c-i-4.js | 31 ++++ .../Array/prototype/map/15.4.4.19-8-c-i-5.js | 46 ++++++ .../Array/prototype/map/15.4.4.19-8-c-i-6.js | 36 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-7.js | 37 +++++ .../Array/prototype/map/15.4.4.19-8-c-i-8.js | 30 ++++ .../Array/prototype/map/15.4.4.19-8-c-i-9.js | 39 +++++ .../Array/prototype/map/15.4.4.19-8-c-ii-1.js | 32 ++++ .../prototype/map/15.4.4.19-8-c-ii-10.js | 24 +++ .../prototype/map/15.4.4.19-8-c-ii-11.js | 24 +++ .../prototype/map/15.4.4.19-8-c-ii-12.js | 24 +++ .../prototype/map/15.4.4.19-8-c-ii-13.js | 26 ++++ .../prototype/map/15.4.4.19-8-c-ii-16.js | 30 ++++ .../prototype/map/15.4.4.19-8-c-ii-17.js | 30 ++++ .../prototype/map/15.4.4.19-8-c-ii-18.js | 30 ++++ .../prototype/map/15.4.4.19-8-c-ii-19.js | 37 +++++ .../Array/prototype/map/15.4.4.19-8-c-ii-2.js | 31 ++++ .../prototype/map/15.4.4.19-8-c-ii-20.js | 34 +++++ .../prototype/map/15.4.4.19-8-c-ii-21.js | 38 +++++ .../prototype/map/15.4.4.19-8-c-ii-22.js | 38 +++++ .../prototype/map/15.4.4.19-8-c-ii-23.js | 30 ++++ .../Array/prototype/map/15.4.4.19-8-c-ii-4.js | 34 +++++ .../Array/prototype/map/15.4.4.19-8-c-ii-5.js | 42 ++++++ .../Array/prototype/map/15.4.4.19-8-c-ii-6.js | 32 ++++ .../Array/prototype/map/15.4.4.19-8-c-ii-7.js | 40 +++++ .../Array/prototype/map/15.4.4.19-8-c-ii-8.js | 34 +++++ .../Array/prototype/map/15.4.4.19-8-c-ii-9.js | 24 +++ .../prototype/map/15.4.4.19-8-c-iii-1.js | 35 +++++ .../prototype/map/15.4.4.19-8-c-iii-2.js | 32 ++++ .../prototype/map/15.4.4.19-8-c-iii-3.js | 33 +++++ .../prototype/map/15.4.4.19-8-c-iii-4.js | 39 +++++ .../prototype/map/15.4.4.19-8-c-iii-5.js | 34 +++++ .../Array/prototype/map/15.4.4.19-9-1.js | 32 ++++ .../Array/prototype/map/15.4.4.19-9-10.js | 36 +++++ .../Array/prototype/map/15.4.4.19-9-11.js | 40 +++++ .../Array/prototype/map/15.4.4.19-9-12.js | 43 ++++++ .../Array/prototype/map/15.4.4.19-9-13.js | 33 +++++ .../Array/prototype/map/15.4.4.19-9-2.js | 32 ++++ .../Array/prototype/map/15.4.4.19-9-3.js | 27 ++++ .../Array/prototype/map/15.4.4.19-9-4.js | 29 ++++ .../Array/prototype/map/15.4.4.19-9-5.js | 31 ++++ .../Array/prototype/map/15.4.4.19-9-6.js | 30 ++++ .../Array/prototype/map/15.4.4.19-9-7.js | 32 ++++ .../Array/prototype/map/15.4.4.19-9-8.js | 32 ++++ .../Array/prototype/map/15.4.4.19-9-9.js | 32 ++++ .../Array/prototype/map/call-with-boolean.js | 30 ++++ .../map/callbackfn-resize-arraybuffer.js | 79 ++++++++++ .../prototype/map/create-ctor-non-object.js | 48 ++++++ .../prototype/map/create-ctor-poisoned.js | 33 +++++ .../map/create-non-array-invalid-len.js | 34 +++++ .../Array/prototype/map/create-non-array.js | 33 +++++ .../map/create-proto-from-ctor-realm-array.js | 34 +++++ .../create-proto-from-ctor-realm-non-array.js | 35 +++++ .../Array/prototype/map/create-proxy.js | 27 ++++ .../prototype/map/create-revoked-proxy.js | 36 +++++ .../prototype/map/create-species-abrupt.js | 33 +++++ .../prototype/map/create-species-non-ctor.js | 36 +++++ .../prototype/map/create-species-null.js | 27 ++++ .../prototype/map/create-species-poisoned.js | 34 +++++ .../map/create-species-undef-invalid-len.js | 49 ++++++ .../prototype/map/create-species-undef.js | 28 ++++ .../Array/prototype/map/create-species.js | 37 +++++ .../builtins/Array/prototype/map/length.js | 39 +++++ .../builtins/Array/prototype/map/name.js | 36 +++++ .../Array/prototype/map/not-a-constructor.js | 35 +++++ .../builtins/Array/prototype/map/prop-desc.js | 33 +++++ .../resizable-buffer-grow-mid-iteration.js | 92 ++++++++++++ .../resizable-buffer-shrink-mid-iteration.js | 89 +++++++++++ .../Array/prototype/map/resizable-buffer.js | 140 ++++++++++++++++++ .../map/target-array-non-extensible.js | 31 ++++ ...et-array-with-non-configurable-property.js | 35 +++++ ...target-array-with-non-writable-property.js | 33 +++++ 216 files changed, 7439 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-1.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-10.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-11.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-12.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-13.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-14.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-15.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-2.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-3.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-4.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-5.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-6.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-7.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-8.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-1-9.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-1.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-10.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-11.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-12.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-13.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-14.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-17.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-18.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-19.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-2.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-3.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-4.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-5.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-6.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-7.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-8.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-2-9.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-1.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-10.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-11.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-12.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-13.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-14.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-15.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-16.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-17.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-18.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-19.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-2.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-20.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-21.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-22.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-23.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-24.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-25.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-28.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-29.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-3.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-4.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-5.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-6.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-7.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-8.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-3-9.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-4-1.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-4-10.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-4-11.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-4-12.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-4-15.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-4-2.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-4-3.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-4-4.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-4-5.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-4-6.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-4-7.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-4-8.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-4-9.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-1-s.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-1.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-10.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-11.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-12.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-13.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-14.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-15.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-16.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-17.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-18.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-19.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-2.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-21.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-22.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-23.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-24.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-3.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-4.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-5.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-6.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-7.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-5-9.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-6-1.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-6-2.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-1.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-2.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-3.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-4.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-5.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-6.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-7.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-8.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-9.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-1.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-10.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-11.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-12.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-13.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-14.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-15.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-16.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-2.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-3.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-4.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-5.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-6.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-7.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-8.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-9.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-1.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-10.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-11.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-12.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-13.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-14.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-15.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-16.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-17.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-18.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-19.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-2.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-20.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-21.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-22.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-25.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-26.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-27.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-28.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-29.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-3.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-30.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-31.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-4.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-5.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-6.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-7.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-8.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-9.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-1.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-10.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-11.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-12.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-13.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-16.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-17.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-18.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-19.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-2.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-20.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-21.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-22.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-23.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-4.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-5.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-6.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-7.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-8.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-9.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-1.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-2.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-3.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-4.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-5.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-9-1.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-9-10.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-9-11.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-9-12.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-9-13.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-9-2.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-9-3.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-9-4.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-9-5.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-9-6.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-9-7.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-9-8.js create mode 100644 test/sendable/builtins/Array/prototype/map/15.4.4.19-9-9.js create mode 100644 test/sendable/builtins/Array/prototype/map/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/map/callbackfn-resize-arraybuffer.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-ctor-non-object.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-ctor-poisoned.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-non-array-invalid-len.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-non-array.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-proto-from-ctor-realm-array.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-proto-from-ctor-realm-non-array.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-proxy.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-revoked-proxy.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-species-abrupt.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-species-non-ctor.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-species-null.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-species-poisoned.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-species-undef-invalid-len.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-species-undef.js create mode 100644 test/sendable/builtins/Array/prototype/map/create-species.js create mode 100644 test/sendable/builtins/Array/prototype/map/length.js create mode 100644 test/sendable/builtins/Array/prototype/map/name.js create mode 100644 test/sendable/builtins/Array/prototype/map/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/map/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/map/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/map/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/map/resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/map/target-array-non-extensible.js create mode 100644 test/sendable/builtins/Array/prototype/map/target-array-with-non-configurable-property.js create mode 100644 test/sendable/builtins/Array/prototype/map/target-array-with-non-writable-property.js diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-1.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-1.js new file mode 100644 index 00000000000..343e6696bb3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to undefined +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.map.call(undefined); // TypeError is thrown if value is undefined +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-10.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-10.js new file mode 100644 index 00000000000..b39026ed263 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-10.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to the Math object +---*/ + +function callbackfn(val, idx, obj) { + return ('[object Math]' === Object.prototype.toString.call(obj)); +} +Math.length = 1; +Math[0] = 1; +var testResult = SendableArray.prototype.map.call(Math, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-11.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-11.js new file mode 100644 index 00000000000..0118974634a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-11.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to Date object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Date; +} +var obj = new Date(0); +obj.length = 1; +obj[0] = 1; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-12.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-12.js new file mode 100644 index 00000000000..e7c67a5c273 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-12.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to RegExp object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof RegExp; +} +var obj = new RegExp(); +obj.length = 1; +obj[0] = 1; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-13.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-13.js new file mode 100644 index 00000000000..b142983b388 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-13.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to the JSON object +---*/ + +function callbackfn(val, idx, obj) { + return ('[object JSON]' === Object.prototype.toString.call(obj)); +} +JSON.length = 1; +JSON[0] = 1; +var testResult = SendableArray.prototype.map.call(JSON, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-14.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-14.js new file mode 100644 index 00000000000..96fe6bc724b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-14.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to Error object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Error; +} +var obj = new Error(); +obj.length = 1; +obj[0] = 1; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-15.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-15.js new file mode 100644 index 00000000000..81809a75a99 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-15.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to the Arguments object +---*/ + +function callbackfn(val, idx, obj) { + return ('[object Arguments]' === Object.prototype.toString.call(obj)); +} +var obj = (function() { + return arguments; +}("a", "b")); +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[1], true, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-2.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-2.js new file mode 100644 index 00000000000..1f0efaab4b5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-2.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to null +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.map.call(null); // TypeError is thrown if value is null +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-3.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-3.js new file mode 100644 index 00000000000..1d8ef8163f7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-3.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to boolean primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Boolean; +} +Boolean.prototype[0] = true; +Boolean.prototype.length = 1; +var testResult = SendableArray.prototype.map.call(false, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-4.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-4.js new file mode 100644 index 00000000000..aafe38a1012 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-4.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to Boolean object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Boolean; +} +var obj = new Boolean(true); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-5.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-5.js new file mode 100644 index 00000000000..d313d71d201 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-5.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to number primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Number; +} +Number.prototype[0] = 1; +Number.prototype.length = 1; +var testResult = SendableArray.prototype.map.call(2.5, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-6.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-6.js new file mode 100644 index 00000000000..fa94129c90c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-6.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to Number object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Number; +} +var obj = new Number(-128); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-7.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-7.js new file mode 100644 index 00000000000..606033542b8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-7.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to string primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof String; +} +var testResult = SendableArray.prototype.map.call("abc", callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); +assert.sameValue(testResult[2], true, 'testResult[2]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-8.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-8.js new file mode 100644 index 00000000000..e185c02ec3b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-8.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to String object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof String; +} +var obj = new String("abc"); +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); +assert.sameValue(testResult[2], true, 'testResult[2]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-9.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-9.js new file mode 100644 index 00000000000..8d86c91e928 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-1-9.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - applied to Function object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Function; +} +var obj = function(a, b) { + return a + b; +}; +obj[0] = 11; +obj[1] = 9; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-1.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-1.js new file mode 100644 index 00000000000..f8b81ce8544 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-1.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object when 'length' + is an own data property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2 +}; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult.length, 2, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-10.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-10.js new file mode 100644 index 00000000000..cd9cfcec898 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-10.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object, 'length' is an + inherited accessor property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; +var testResult = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(testResult.length, 2, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-11.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-11.js new file mode 100644 index 00000000000..8494261cb87 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-11.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object when 'length' + is an own accessor property without a get function +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult.length, 0, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-12.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-12.js new file mode 100644 index 00000000000..22585f2f444 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-12.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to the Array-like object when + 'length' is own accessor property without a get function that + overrides an inherited accessor property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var obj = { + 0: 12, + 1: 11 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult.length, 0, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-13.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-13.js new file mode 100644 index 00000000000..768d558f6d3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-13.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to the Array-like object when + 'length' is inherited accessor property without a get function +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 11; +child[1] = 12; +var testResult = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(testResult.length, 0, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-14.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-14.js new file mode 100644 index 00000000000..1bd364b618f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-14.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to the Array-like object that + 'length' property doesn't exist +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + 0: 11, + 1: 12 +}; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult.length, 0, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-17.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-17.js new file mode 100644 index 00000000000..1b786da20ca --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-17.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Arguments object, which + implements its own property get method +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var func = function(a, b) { + return SendableArray.prototype.map.call(arguments, callbackfn); +}; +var testResult = func(12, 11); +assert.sameValue(testResult.length, 2, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-18.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-18.js new file mode 100644 index 00000000000..d16334e7839 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-18.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to String object, which implements + its own property get method +---*/ + +function callbackfn(val, idx, obj) { + return parseInt(val, 10) > 1; +} +var str = new String("432"); +String.prototype[3] = "1"; +var testResult = SendableArray.prototype.map.call(str, callbackfn); +assert.sameValue(testResult.length, 3, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-19.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-19.js new file mode 100644 index 00000000000..4918732e010 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-19.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Function object, which implements + its own property get method +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var fun = function(a, b) { + return a + b; +}; +fun[0] = 12; +fun[1] = 11; +fun[2] = 9; +var testResult = SendableArray.prototype.map.call(fun, callbackfn); +assert.sameValue(testResult.length, 2, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-2.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-2.js new file mode 100644 index 00000000000..a4b2e8d59d3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-2.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - when 'length' is own data property on an + Array +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var testResult = [12, 11].map(callbackfn); +assert.sameValue(testResult.length, 2, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-3.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-3.js new file mode 100644 index 00000000000..36288a96c1b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-3.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object, 'length' is an + own data property that overrides an inherited data property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var proto = { + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +child[0] = 12; +child[1] = 11; +child[2] = 9; +var testResult = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(testResult.length, 2, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-4.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-4.js new file mode 100644 index 00000000000..bee2c86c743 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-4.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - when 'length' is own data property that + overrides an inherited data property on an Array +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var arrProtoLen; +arrProtoLen = SendableArray.prototype.length; +SendableArray.prototype.length = 0; +var testResult = [12, 11].map(callbackfn); +assert.sameValue(testResult.length, 2, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-5.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-5.js new file mode 100644 index 00000000000..ff2fe7df398 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-5.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object, 'length' is an + own data property that overrides an inherited accessor property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +var testResult = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(testResult.length, 2, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-6.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-6.js new file mode 100644 index 00000000000..01925321404 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object, 'length' is an + inherited data property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var proto = { + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; +var testResult = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(testResult.length, 2, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-7.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-7.js new file mode 100644 index 00000000000..29885713bb0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-7.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object, 'length' is an + own accessor property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); +obj[0] = 12; +obj[1] = 11; +obj[2] = 9; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult.length, 2, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-8.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-8.js new file mode 100644 index 00000000000..4aec2c1de21 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-8.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object, 'length' is an + own accessor property that overrides an inherited data property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var proto = { + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +var testResult = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(testResult.length, 2, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-9.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-9.js new file mode 100644 index 00000000000..25edd74128a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-2-9.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - applied to Array-like object when 'length' + is an own accessor property that overrides an inherited accessor + property +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +var testResult = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(testResult.length, 2, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-1.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-1.js new file mode 100644 index 00000000000..6a59c6a8408 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-1.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - value of 'length' is undefined +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + length: undefined +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-10.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-10.js new file mode 100644 index 00000000000..1bbc9105ecc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-10.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - value of 'length' is a number (value is NaN) +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var obj = { + 0: 9, + length: NaN +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-11.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-11.js new file mode 100644 index 00000000000..71b43caae94 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-11.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'length' is a string containing a positive + number +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var obj = { + 0: 11, + 1: 9, + 2: 12, + length: "2" +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-12.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-12.js new file mode 100644 index 00000000000..7e292bfcfbe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-12.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'length' is a string containing a negative + number +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var obj = { + 0: 11, + 1: 9, + 2: 12, + length: "-4294967294" +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-13.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-13.js new file mode 100644 index 00000000000..b1e4525c79d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-13.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is string that is able to + convert to number primitive (value is a decimal number) +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var obj = { + 0: 11, + 1: 9, + 2: 12, + length: "2.5" +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-14.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-14.js new file mode 100644 index 00000000000..ac8090f57fb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-14.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - 'length' is a string containing Infinity +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var obj = { + 0: 9, + length: "Infinity" +}; +assert.throws(RangeError, function() { + SendableArray.prototype.map.call(obj, callbackfn); +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-15.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-15.js new file mode 100644 index 00000000000..d866fb04f1d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-15.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'length' is a string containing an + exponential number +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var obj = { + 0: 11, + 1: 9, + 2: 12, + length: "2E0" +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-16.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-16.js new file mode 100644 index 00000000000..2688ee3d1a9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-16.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - 'length' is a string containing a hex number +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var obj = { + 0: 11, + 1: 9, + 2: 12, + length: "0x0002" +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-17.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-17.js new file mode 100644 index 00000000000..a71a6217f17 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-17.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - when 'length' is a string containing a + number with leading zeros +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var obj = { + 0: 11, + 1: 9, + 2: 12, + length: "0002.00" +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-18.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-18.js new file mode 100644 index 00000000000..92ca86c5f66 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-18.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is a string that can't + convert to a number +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + length: "asdf!_" +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-19.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-19.js new file mode 100644 index 00000000000..ed3306cd351 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-19.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is an Object which has an + own toString method +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var obj = { + 0: 11, + 1: 9, + length: { + toString: function() { + return '2'; + } + } +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-2.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-2.js new file mode 100644 index 00000000000..3cacbe880dc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-2.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map on an Array-like object if 'length' is 1 + (length overridden to true(type conversion)) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + 0: 11, + length: true +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 1, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-20.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-20.js new file mode 100644 index 00000000000..3436c95edb3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-20.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is an Object which has an + own valueOf method +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var obj = { + 0: 11, + 1: 9, + length: { + valueOf: function() { + return 2; + } + } +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-21.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-21.js new file mode 100644 index 00000000000..27c50df52d5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-21.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'length' is an object that has an own + valueOf method that returns an object and toString method that + returns a string +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var firstStepOccured = false; +var secondStepOccured = false; +var obj = { + 0: 11, + 1: 9, + length: { + valueOf: function() { + firstStepOccured = true; + return {}; + }, + toString: function() { + secondStepOccured = true; + return '2'; + } + } +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert(firstStepOccured, 'firstStepOccured !== true'); +assert(secondStepOccured, 'secondStepOccured !== true'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-22.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-22.js new file mode 100644 index 00000000000..f00bb79559e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-22.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map throws TypeError exception when 'length' is an + object with toString and valueOf methods that don�t return + primitive values +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + 1: 11, + 2: 12, + length: { + valueOf: function() { + return {}; + }, + toString: function() { + return {}; + } + } +}; +assert.throws(TypeError, function() { + SendableArray.prototype.map.call(obj, callbackfn); +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-23.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-23.js new file mode 100644 index 00000000000..f5fcd830e7a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-23.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map uses inherited valueOf method when 'length' is + an object with an own toString and inherited valueOf methods +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var valueOfAccessed = false; +var toStringAccessed = false; +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return '1'; +}; +var obj = { + 0: 11, + 1: 9, + length: child +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-24.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-24.js new file mode 100644 index 00000000000..abbe8ff835e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-24.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is a positive non-integer, + ensure truncation occurs in the proper direction +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var obj = { + 0: 11, + 1: 9, + length: 2.685 +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-25.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-25.js new file mode 100644 index 00000000000..337545b7998 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-25.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - value of 'length' is a negative non-integer +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var obj = { + 0: 11, + 1: 9, + length: -4294967294.5 +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-28.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-28.js new file mode 100644 index 00000000000..66c62712510 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-28.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - value of 'length' is boundary value (2^32) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + 0: 12, + length: 4294967296 +}; +assert.throws(RangeError, function() { + var newArr = SendableArray.prototype.map.call(obj, callbackfn); +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-29.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-29.js new file mode 100644 index 00000000000..4ce3eabeff3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-29.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is boundary value (2^32 + + 1) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + 0: 11, + 1: 9, + length: 4294967297 +}; +assert.throws(RangeError, function() { + var newArr = SendableArray.prototype.map.call(obj, callbackfn); +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-3.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-3.js new file mode 100644 index 00000000000..0bcd083e67c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-3.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - value of 'length' is a number (value is 0) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + 0: 11, + length: 0 +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-4.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-4.js new file mode 100644 index 00000000000..0d870f63dd7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - value of 'length' is a number (value is +0) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + 0: 11, + length: +0 +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-5.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-5.js new file mode 100644 index 00000000000..7ce32bad9aa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-5.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - value of 'length' is a number (value is -0) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + 0: 11, + length: -0 +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-6.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-6.js new file mode 100644 index 00000000000..d675e6f341e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-6.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'length' is a string containing a positive + number +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + 0: 10, + 1: 12, + 2: 9, + length: 2 +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 2, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-7.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-7.js new file mode 100644 index 00000000000..c0c9b0a262e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-7.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'length' is a string containing a negative + number +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + 0: 10, + 1: 12, + 2: 9, + length: -4294967294 +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-8.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-8.js new file mode 100644 index 00000000000..62c092a0cef --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-8.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is a number (value is + Infinity) +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var obj = { + 0: 9, + length: Infinity +}; +assert.throws(RangeError, function() { + SendableArray.prototype.map.call(obj, callbackfn); +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-9.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-9.js new file mode 100644 index 00000000000..8e8f12aac01 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-3-9.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of 'length' is a number (value is + -Infinity) +---*/ + +function callbackfn(val, idx, obj) { + return val < 10; +} +var obj = { + 0: 9, + length: -Infinity +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr.length, 0, 'newArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-1.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-1.js new file mode 100644 index 00000000000..22943e976f5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map throws TypeError if callbackfn is undefined +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.map(); +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-10.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-10.js new file mode 100644 index 00000000000..9061d48d67f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-10.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - the exception is not thrown if exception was + thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.map.call(obj, undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-11.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-11.js new file mode 100644 index 00000000000..3d7cca5eb7f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-11.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - the exception is not thrown if exception was + thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.map.call(obj, undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-12.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-12.js new file mode 100644 index 00000000000..2c32531c341 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-12.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - 'callbackfn' is a function +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var testResult = [11, 9].map(callbackfn); +assert.sameValue(testResult.length, 2, 'testResult.length'); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], false, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-15.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-15.js new file mode 100644 index 00000000000..9a2f897515c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-15.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - calling with no callbackfn is the same as + passing undefined for callbackfn +---*/ + +var obj = { + 10: 10 +}; +var lengthAccessed = false; +var loopAccessed = false; +Object.defineProperty(obj, "length", { + get: function() { + lengthAccessed = true; + return 20; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + loopAccessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.map.call(obj); +}); +assert(lengthAccessed, 'lengthAccessed !== true'); +assert.sameValue(loopAccessed, false, 'loopAccessed'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-2.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-2.js new file mode 100644 index 00000000000..f96ea0a1690 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map throws ReferenceError if callbackfn is + unreferenced +---*/ + +var arr = new SendableArray(10); +assert.throws(ReferenceError, function() { + arr.map(foo); +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-3.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-3.js new file mode 100644 index 00000000000..97f196b7eab --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map throws TypeError if callbackfn is null +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.map(null); +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-4.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-4.js new file mode 100644 index 00000000000..f0f6276e3f5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-4.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map throws TypeError if callbackfn is boolean +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.map(true); +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-5.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-5.js new file mode 100644 index 00000000000..84b84478d1d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-5.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map throws TypeError if callbackfn is number +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.map(5); +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-6.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-6.js new file mode 100644 index 00000000000..0ed16b1fb85 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-6.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map throws TypeError if callbackfn is string +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.map("abc"); +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-7.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-7.js new file mode 100644 index 00000000000..45f927c9afc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-7.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map throws TypeError if callbackfn is Object + without Call internal method +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.map(new Object()); +}); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-8.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-8.js new file mode 100644 index 00000000000..8298d182a56 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-8.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - Side effects produced by step 2 are visible + when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.map.call(obj, null); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-9.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-9.js new file mode 100644 index 00000000000..4bbaaeda409 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-4-9.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - Side effects produced by step 3 are visible + when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.map.call(obj, null); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-1-s.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-1-s.js new file mode 100644 index 00000000000..d4d87d55639 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-1-s.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - thisArg not passed to strict callbackfn +flags: [noStrict] +---*/ + +var innerThisCorrect = false; +function callbackfn(val, idx, obj) { + "use strict"; + innerThisCorrect = this === undefined; + return true; +} +[1].map(callbackfn); +assert(innerThisCorrect, 'innerThisCorrect !== true'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-1.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-1.js new file mode 100644 index 00000000000..c22ac913576 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - thisArg not passed +flags: [noStrict] +---*/ + +this._15_4_4_19_5_1 = true; +(function() { + var _15_4_4_19_5_1 = false; + function callbackfn(val, idx, obj) { + return this._15_4_4_19_5_1; + } + var srcArr = [1]; + var resArr = srcArr.map(callbackfn); + assert.sameValue(resArr[0], true, 'resArr[0]'); +})(); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-10.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-10.js new file mode 100644 index 00000000000..5bff68f1dd1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-10.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - Array object can be used as thisArg +---*/ + +var objArray = new SendableArray(2); +function callbackfn(val, idx, obj) { + return this === objArray; +} +var testResult = [11].map(callbackfn, objArray); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-11.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-11.js new file mode 100644 index 00000000000..4745d9b9018 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-11.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - String object can be used as thisArg +---*/ + +var objString = new String(); +function callbackfn(val, idx, obj) { + return this === objString; +} +var testResult = [11].map(callbackfn, objString); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-12.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-12.js new file mode 100644 index 00000000000..c0be695624d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-12.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - Boolean object can be used as thisArg +---*/ + +var objBoolean = new Boolean(); +function callbackfn(val, idx, obj) { + return this === objBoolean; +} +var testResult = [11].map(callbackfn, objBoolean); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-13.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-13.js new file mode 100644 index 00000000000..5c633cefa57 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-13.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - Number object can be used as thisArg +---*/ + +var objNumber = new Number(); +function callbackfn(val, idx, obj) { + return this === objNumber; +} +var testResult = [11].map(callbackfn, objNumber); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-14.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-14.js new file mode 100644 index 00000000000..35e7c9a01c1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-14.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - the Math object can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this === Math; +} +var testResult = [11].map(callbackfn, Math); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-15.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-15.js new file mode 100644 index 00000000000..fd6f53185de --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-15.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - Date object can be used as thisArg +---*/ + +var objDate = new Date(0); +function callbackfn(val, idx, obj) { + return this === objDate; +} +var testResult = [11].map(callbackfn, objDate); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-16.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-16.js new file mode 100644 index 00000000000..62dd30517ee --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-16.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - RegExp object can be used as thisArg +---*/ + +var objRegExp = new RegExp(); +function callbackfn(val, idx, obj) { + return this === objRegExp; +} +var testResult = [11].map(callbackfn, objRegExp); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-17.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-17.js new file mode 100644 index 00000000000..b608b5f159e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-17.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - the JSON object can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this === JSON; +} +var testResult = [11].map(callbackfn, JSON); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-18.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-18.js new file mode 100644 index 00000000000..5121b3a05f4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-18.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - Error object can be used as thisArg +---*/ + +var objError = new RangeError(); +function callbackfn(val, idx, obj) { + return this === objError; +} +var testResult = [11].map(callbackfn, objError); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-19.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-19.js new file mode 100644 index 00000000000..0e762cebf2d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-19.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - the Arguments object can be used as thisArg +---*/ + +var arg; +function callbackfn(val, idx, obj) { + return this === arg; +} +arg = (function() { + return arguments; +}(1, 2, 3)); +var testResult = [11].map(callbackfn, arg); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-2.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-2.js new file mode 100644 index 00000000000..3fe63c685a3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-2.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - thisArg is Object +---*/ + +var res = false; +var o = new Object(); +o.res = true; +function callbackfn(val, idx, obj) +{ + return this.res; +} +var srcArr = [1]; +var resArr = srcArr.map(callbackfn, o); +assert.sameValue(resArr[0], true, 'resArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-21.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-21.js new file mode 100644 index 00000000000..94bfb1e8cbb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-21.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - the global object can be used as thisArg +---*/ + +var global = this; +function callbackfn(val, idx, obj) { + return this === global; +} +var testResult = [11].map(callbackfn, this); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-22.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-22.js new file mode 100644 index 00000000000..937b28ac8b5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-22.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - boolean primitive can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === false; +} +var testResult = [11].map(callbackfn, false); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-23.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-23.js new file mode 100644 index 00000000000..6f7fd731072 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-23.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - number primitive can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === 101; +} +var testResult = [11].map(callbackfn, 101); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-24.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-24.js new file mode 100644 index 00000000000..2f5141adfad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-24.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - string primitive can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === "abc"; +} +var testResult = [11].map(callbackfn, "abc"); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-3.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-3.js new file mode 100644 index 00000000000..c5d3e15bc1c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-3.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - thisArg is Array +---*/ + +var res = false; +var a = new SendableArray(); +a.res = true; +function callbackfn(val, idx, obj) +{ + return this.res; +} +var srcArr = [1]; +var resArr = srcArr.map(callbackfn, a); +assert.sameValue(resArr[0], true, 'resArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-4.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-4.js new file mode 100644 index 00000000000..86186d1716f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-4.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - thisArg is object from object + template(prototype) +---*/ + +var res = false; +function callbackfn(val, idx, obj) +{ + return this.res; +} +function foo() {} +foo.prototype.res = true; +var f = new foo(); +var srcArr = [1]; +var resArr = srcArr.map(callbackfn, f); +assert.sameValue(resArr[0], true, 'resArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-5.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-5.js new file mode 100644 index 00000000000..99822f75dbf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-5.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - thisArg is object from object template +---*/ + +var res = false; +function callbackfn(val, idx, obj) +{ + return this.res; +} +function foo() {} +var f = new foo(); +f.res = true; +var srcArr = [1]; +var resArr = srcArr.map(callbackfn, f); +assert.sameValue(resArr[0], true, 'resArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-6.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-6.js new file mode 100644 index 00000000000..1751e1a0ebc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-6.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - thisArg is function +---*/ + +var res = false; +function callbackfn(val, idx, obj) +{ + return this.res; +} +function foo() {} +foo.res = true; +var srcArr = [1]; +var resArr = srcArr.map(callbackfn, foo); +assert.sameValue(resArr[0], true, 'resArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-7.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-7.js new file mode 100644 index 00000000000..aeab8eb9fd5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-7.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - built-in functions can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this === eval; +} +var testResult = [11].map(callbackfn, eval); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-9.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-9.js new file mode 100644 index 00000000000..78d45b7bc11 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-5-9.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - Function object can be used as thisArg +---*/ + +var objFunction = function() {}; +function callbackfn(val, idx, obj) { + return this === objFunction; +} +var testResult = [11].map(callbackfn, objFunction); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-6-1.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-6-1.js new file mode 100644 index 00000000000..e03a2bed634 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-6-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - Array.isArray returns true when input + argument is the ourput array +---*/ + +var newArr = [11].map(function() {}); +assert(SendableArray.isArray(newArr), 'SendableArray.isArray(newArr) !== true'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-6-2.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-6-2.js new file mode 100644 index 00000000000..8684f98b380 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-6-2.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - the returned array is instanceof Array +---*/ + +var newArr = [11].map(function() {}); +assert(newArr instanceof SendableArray, 'newArr instanceof SendableArray !== true'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-1.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-1.js new file mode 100644 index 00000000000..b01a984f2bb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map doesn't consider new elements added to array + after it is called +---*/ + +function callbackfn(val, idx, obj) +{ + srcArr[2] = 3; + srcArr[5] = 6; + return 1; +} +var srcArr = [1, 2, , 4, 5]; +var resArr = srcArr.map(callbackfn); +assert.sameValue(resArr.length, 5, 'resArr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-2.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-2.js new file mode 100644 index 00000000000..dc7cf046513 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-2.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map considers new value of elements in array after + it is called +---*/ + +function callbackfn(val, idx, obj) +{ + srcArr[4] = -1; + if (val > 0) + return 1; + else + return 0; +} +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.map(callbackfn); +assert.sameValue(resArr.length, 5, 'resArr.length'); +assert.sameValue(resArr[4], 0, 'resArr[4]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-3.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-3.js new file mode 100644 index 00000000000..d8f5994aabd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-3.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map doesn't visit deleted elements in array after + the call +---*/ + +function callbackfn(val, idx, obj) +{ + delete srcArr[4]; + if (val > 0) + return 1; + else + return 0; +} +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.map(callbackfn); +assert.sameValue(resArr.length, 5, 'resArr.length'); +assert.sameValue(resArr[4], undefined, 'resArr[4]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-4.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-4.js new file mode 100644 index 00000000000..cda5618c374 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-4.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map doesn't visit deleted elements when + Array.length is decreased +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + srcArr.length = 2; + callCnt++; + return 1; +} +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.map(callbackfn); +assert.sameValue(resArr.length, 5, 'resArr.length'); +assert.sameValue(callCnt, 2, 'callCnt'); +assert.sameValue(resArr[2], undefined, 'resArr[2]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-5.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-5.js new file mode 100644 index 00000000000..586c9d3ee99 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-5.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map doesn't consider newly added elements in + sparse array +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + srcArr[1000] = 3; + callCnt++; + return val; +} +var srcArr = new SendableArray(10); +srcArr[1] = 1; +srcArr[2] = 2; +var resArr = srcArr.map(callbackfn); +assert.sameValue(resArr.length, 10, 'resArr.length'); +assert.sameValue(callCnt, 2, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-6.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-6.js new file mode 100644 index 00000000000..f6273a8302b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map visits deleted element in array after the call + when same index is also present in prototype +---*/ + +function callbackfn(val, idx, obj) +{ + delete srcArr[4]; + if (val > 0) + return 1; + else + return 0; +} +SendableArray.prototype[4] = 5; +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.map(callbackfn); +delete SendableArray.prototype[4]; +assert.sameValue(resArr.length, 5, 'resArr.length'); +assert.sameValue(resArr[4], 1, 'resArr[4]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-7.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-7.js new file mode 100644 index 00000000000..22f442415c3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-7.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map successful to delete the object in callbackfn +---*/ + +var obj = {}; +obj.srcArr = [1, 2, 3, 4, 5]; +function callbackfn(val, idx, obj) { + delete obj.srcArr; + if (val > 0) + return 1; + else + return 0; +} +var resArr = obj.srcArr.map(callbackfn); +assert.sameValue(resArr.toString(), "1,1,1,1,1", 'resArr.toString()'); +assert.sameValue(obj.hasOwnProperty("arr"), false, 'obj.hasOwnProperty("arr")'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-8.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-8.js new file mode 100644 index 00000000000..0c6fe8eb017 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-8.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - no observable effects occur if length is 0 + on an Array-like object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + 1: 12, + length: 0 +}; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult.length, 0, 'testResult.length'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-9.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-9.js new file mode 100644 index 00000000000..0b921716bee --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-9.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - modifications to length don't change number + of iterations on an Array +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called += 1; + return val > 10; +} +var arr = [9, , 12]; +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 8; + }, + configurable: true +}); +var testResult = arr.map(callbackfn); +assert.sameValue(testResult.length, 3, 'testResult.length'); +assert.sameValue(called, 2, 'called'); +assert.sameValue(typeof testResult[2], "undefined", 'typeof testResult[2]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-1.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-1.js new file mode 100644 index 00000000000..8025c7f8e75 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-1.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - callbackfn not called for indexes never been + assigned values +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + callCnt++; + return 1; +} +var srcArr = new SendableArray(10); +srcArr[1] = undefined; //explicitly assigning a value +var resArr = srcArr.map(callbackfn); +assert.sameValue(resArr.length, 10, 'resArr.length'); +assert.sameValue(callCnt, 1, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-10.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-10.js new file mode 100644 index 00000000000..20f8049d265 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-10.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - deleting property of prototype causes + prototype index property not to be visited on an Array-like Object +---*/ + +function callbackfn(val, idx, obj) { + return idx === 1 && typeof val === "undefined"; +} +var obj = { + 2: 2, + length: 20 +}; +Object.defineProperty(obj, "0", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult.length, 20, 'testResult.length'); +assert.sameValue(typeof testResult[1], "undefined", 'typeof testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-11.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-11.js new file mode 100644 index 00000000000..e4f82bdb559 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-11.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - deleting property of prototype causes + prototype index property not to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + return idx === 1 && typeof val === "undefined"; +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + delete SendableArray.prototype[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +var testResult = arr.map(callbackfn); +assert.sameValue(testResult.length, 3, 'testResult.length'); +assert.sameValue(typeof testResult[1], "undefined", 'typeof testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-12.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-12.js new file mode 100644 index 00000000000..14278e80291 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-12.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 3) { + return false; + } else { + return true; + } +} +var obj = { + 0: 0, + 1: 1, + 2: 2, + length: 10 +}; +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 3; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[1], false, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-13.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-13.js new file mode 100644 index 00000000000..ef7a85a13d7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-13.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 3) { + return false; + } else { + return true; + } +} +var arr = [0, 1, 2]; +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 3; +var testResult = arr.map(callbackfn); +assert.sameValue(testResult[1], false, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-14.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-14.js new file mode 100644 index 00000000000..547ec269c32 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-14.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - decreasing length of array causes index + property not to be visited +---*/ + +function callbackfn(val, idx, obj) { + return idx === 3 && typeof val === "undefined"; +} +var arr = [0, 1, 2, "last"]; +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); +var testResult = arr.map(callbackfn); +assert.sameValue(typeof testResult[3], "undefined", 'typeof testResult[3]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-15.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-15.js new file mode 100644 index 00000000000..c49c1ec67e4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-15.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - decreasing length of array with prototype + property causes prototype index property to be visited +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "prototype") { + return false; + } else { + return true; + } +} +var arr = [0, 1, 2]; +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +var testResult = arr.map(callbackfn); +assert.sameValue(testResult.length, 3, 'testResult.length'); +assert.sameValue(testResult[2], false, 'testResult[2]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-16.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-16.js new file mode 100644 index 00000000000..a5664729428 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-16.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - decreasing length of array does not delete + non-configurable properties +flags: [noStrict] +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "unconfigurable") { + return false; + } else { + return true; + } +} +var arr = [0, 1, 2]; +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +var testResult = arr.map(callbackfn); +assert.sameValue(testResult.length, 3, 'testResult.length'); +assert.sameValue(testResult[2], false, 'testResult[2]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-2.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-2.js new file mode 100644 index 00000000000..be76261e5be --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-2.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - added properties in step 2 are visible here +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "length") { + return false; + } else { + return true; + } +} +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + obj[2] = "length"; + return 3; + }, + configurable: true +}); +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[2], false, 'testResult[2]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-3.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-3.js new file mode 100644 index 00000000000..185a026cb20 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-3.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - deleted properties in step 2 are visible here +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2) { + return false; + } else { + return true; + } +} +var obj = { + 2: 6.99, + 8: 19 +}; +Object.defineProperty(obj, "length", { + get: function() { + delete obj[2]; + return 10; + }, + configurable: true +}); +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(typeof testResult[2], "undefined", 'typeof testResult[2]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-4.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-4.js new file mode 100644 index 00000000000..5e67a4d7b2e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-4.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - properties added into own object after + current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return false; + } else { + return true; + } +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(obj, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], false, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-5.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-5.js new file mode 100644 index 00000000000..abd3347e9ee --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-5.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - properties added into own object after + current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return false; + } else { + return true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +var testResult = arr.map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], false, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-6.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-6.js new file mode 100644 index 00000000000..1a041ac0bfc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-6.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - properties can be added to prototype after + current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + return false; + } else { + return true; + } +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], false, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-7.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-7.js new file mode 100644 index 00000000000..9e280e566ba --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-7.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - properties can be added to prototype after + current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + return false; + } else { + return true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +var testResult = arr.map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], false, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-8.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-8.js new file mode 100644 index 00000000000..c6e103ed472 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-8.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - deleting own property causes index property + not to be visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return false; + } else { + return true; + } +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(typeof testResult[1], "undefined", 'typeof testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-9.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-9.js new file mode 100644 index 00000000000..7c62ead31d5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-b-9.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - deleting own property causes index property + not to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return false; + } else { + return true; + } +} +var arr = [1, 2]; +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +var testResult = arr.map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(typeof testResult[1], "undefined", 'typeof testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-1.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-1.js new file mode 100644 index 00000000000..b0375373131 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-1.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own data property + on an Array-like object +---*/ + +var kValue = {}; +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val === kValue; + } + return false; +} +var obj = { + 5: kValue, + length: 100 +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr[5], true, 'newArr[5]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-10.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-10.js new file mode 100644 index 00000000000..a8bb50da76b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-10.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property on an Array +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} +var arr = []; +Object.defineProperty(arr, "0", { + get: function() { + return kValue; + }, + configurable: true +}); +var testResult = arr.map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-11.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-11.js new file mode 100644 index 00000000000..e4be9a79c06 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-11.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} +var proto = { + 0: 5, + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "0", { + get: function() { + return kValue; + }, + configurable: true +}); +var testResult = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-12.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-12.js new file mode 100644 index 00000000000..fb69ac99daf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-12.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} +var arr = []; +SendableArray.prototype[0] = 11; +Object.defineProperty(arr, "0", { + get: function() { + return kValue; + }, + configurable: true +}); +var testResult = arr.map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-13.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-13.js new file mode 100644 index 00000000000..d37d7bd15e3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-13.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} +var proto = { + length: 2 +}; +Object.defineProperty(proto, "0", { + get: function() { + return 5; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "0", { + get: function() { + return kValue; + }, + configurable: true +}); +var testResult = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-14.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-14.js new file mode 100644 index 00000000000..ac2a713e9a3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-14.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} +var arr = []; +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 11; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + return kValue; + }, + configurable: true +}); +var testResult = arr.map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-15.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-15.js new file mode 100644 index 00000000000..f60c2577aa4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-15.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} +var proto = { + length: 2 +}; +Object.defineProperty(proto, "0", { + get: function() { + return kValue; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +var testResult = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-16.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-16.js new file mode 100644 index 00000000000..993732551cb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-16.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is inherited + accessor property on an Array +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return kValue; + }, + configurable: true +}); +var testResult = [, ].map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-17.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-17.js new file mode 100644 index 00000000000..5f26cced3b0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-17.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return typeof val === "undefined"; + } + return false; +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[1], true, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-18.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-18.js new file mode 100644 index 00000000000..5d48577357c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-18.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return typeof val === "undefined"; + } + return false; +} +var arr = []; +Object.defineProperty(arr, "1", { + set: function() {}, + configurable: true +}); +var testResult = arr.map(callbackfn); +assert.sameValue(testResult[1], true, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-19.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-19.js new file mode 100644 index 00000000000..7f2a5a11f1c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-19.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return typeof val === "undefined"; + } + return false; +} +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 100; + }, + configurable: true +}); +var testResult = arr.map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-2.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-2.js new file mode 100644 index 00000000000..745b1154b77 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-2.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own data property + on an Array +---*/ + +var kValue = {}; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} +var arr = [kValue]; +var newArr = arr.map(callbackfn); +assert.sameValue(newArr[0], true, 'newArr[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-20.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-20.js new file mode 100644 index 00000000000..452ada7b9da --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-20.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return typeof val === "undefined"; + } + return false; +} +var proto = {}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +Object.defineProperty(child, "0", { + set: function() {}, + configurable: true +}); +Object.defineProperty(proto, "0", { + get: function() { + return 100; + }, + configurable: true +}); +var testResult = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-21.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-21.js new file mode 100644 index 00000000000..01962fa53ee --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-21.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return typeof val === "undefined"; + } + return false; +} +var proto = { + length: 2 +}; +Object.defineProperty(proto, "0", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +var testResult = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-22.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-22.js new file mode 100644 index 00000000000..ecff84f58c9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-22.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return typeof val === "undefined"; + } + return false; +} +Object.defineProperty(SendableArray.prototype, "0", { + set: function() {}, + configurable: true +}); +var testResult = [, ].map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-25.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-25.js new file mode 100644 index 00000000000..446c8976302 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-25.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - This object is the Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 9; + } else { + return false; + } +} +var func = function(a, b) { + return SendableArray.prototype.map.call(arguments, callbackfn); +}; +var testResult = func(9); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-26.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-26.js new file mode 100644 index 00000000000..dc7ddd47c3f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-26.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - This object is the Arguments object which + implements its own property get method (number of arguments equals + number of parameters) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 9; + } else if (idx === 1) { + return val === 11; + } else { + return false; + } +} +var func = function(a, b) { + return SendableArray.prototype.map.call(arguments, callbackfn); +}; +var testResult = func(9, 11); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-27.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-27.js new file mode 100644 index 00000000000..042132f6572 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-27.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - This object is the Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 9; + } else if (idx === 1) { + return val === 11; + } else if (idx === 2) { + return val === 12; + } else { + return false; + } +} +var func = function(a, b) { + return SendableArray.prototype.map.call(arguments, callbackfn); +}; +var testResult = func(9, 11, 12); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); +assert.sameValue(testResult[2], true, 'testResult[2]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-28.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-28.js new file mode 100644 index 00000000000..d69769e4ea6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-28.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element changed by getter on previous + iterations is observed on an Array +---*/ + +var preIterVisible = false; +var arr = []; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } else if (idx === 1) { + return val === 9; + } else { + return false; + } +} +Object.defineProperty(arr, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 11; + } + }, + configurable: true +}); +var testResult = arr.map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-29.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-29.js new file mode 100644 index 00000000000..87e20134ebe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-29.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element changed by getter on previous + iterations is observed on an Array-like object +---*/ + +var preIterVisible = false; +var obj = { + length: 2 +}; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } else if (idx === 1) { + return val === 9; + } else { + return false; + } +} +Object.defineProperty(obj, "0", { + get: function() { + preIterVisible = true; + return 11; + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 9; + } else { + return 11; + } + }, + configurable: true +}); +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-3.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-3.js new file mode 100644 index 00000000000..069951033e6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-3.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own data property + that overrides an inherited data property on an Array-like object +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val === kValue; + } + return false; +} +var proto = { + 5: 12, + length: 10 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[5] = kValue; +var testResult = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(testResult[5], true, 'testResult[5]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-30.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-30.js new file mode 100644 index 00000000000..286c0aafb0c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-30.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - unhandled exceptions happened in getter + terminate iteration on an Array-like object +---*/ + +var obj = { + 0: 11, + 5: 10, + 10: 8, + length: 20 +}; +var accessed = false; +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } +} +Object.defineProperty(obj, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +Object.defineProperty(obj, "2", { + get: function() { + accessed = true; + return 100; + }, + configurable: true +}); +assert.throws(RangeError, function() { + SendableArray.prototype.map.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-31.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-31.js new file mode 100644 index 00000000000..e1fd36d9235 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-31.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - unhandled exceptions happened in getter + terminate iteration on an Array +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } +} +var arr = []; +arr[5] = 10; +arr[10] = 100; +Object.defineProperty(arr, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +Object.defineProperty(arr, "2", { + get: function() { + accessed = true; + return 100; + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.map(callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-4.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-4.js new file mode 100644 index 00000000000..61ba63ccdda --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-4.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own data property + that overrides an inherited data property on an Array +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} +SendableArray.prototype[0] = 11; +var testResult = [kValue].map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-5.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-5.js new file mode 100644 index 00000000000..a3da94fb035 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-5.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own data property + that overrides an inherited accessor property on an Array-like + object +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val === kValue; + } + return false; +} +var proto = {}; +Object.defineProperty(proto, "5", { + get: function() { + return 11; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 10; +Object.defineProperty(child, "5", { + value: kValue, + configurable: true +}); +var testResult = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(testResult[5], true, 'testResult[5]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-6.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-6.js new file mode 100644 index 00000000000..520c6a13200 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-6.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own data property + that overrides an inherited accessor property on an Array +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 9; + }, + configurable: true +}); +var testResult = [kValue].map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-7.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-7.js new file mode 100644 index 00000000000..19e12d20293 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-7.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is inherited data + property on an Array-like object +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val === kValue; + } + return false; +} +var proto = { + 5: kValue, + length: 10 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +var newArr = SendableArray.prototype.map.call(child, callbackfn); +assert.sameValue(newArr[5], true, 'newArr[5]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-8.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-8.js new file mode 100644 index 00000000000..afab8102737 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-8.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is inherited data + property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === 13; + } + return false; +} +SendableArray.prototype[1] = 13; +var newArr = [, , , ].map(callbackfn); +assert.sameValue(newArr[1], true, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-9.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-9.js new file mode 100644 index 00000000000..fd9aafdcdd7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-i-9.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element to be retrieved is own accessor + property on an Array-like object +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "0", { + get: function() { + return kValue; + }, + configurable: true +}); +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-1.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-1.js new file mode 100644 index 00000000000..91881cda2e9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-1.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - callbackfn called with correct parameters +---*/ + +var bPar = true; +var bCalled = false; +function callbackfn(val, idx, obj) +{ + bCalled = true; + if (obj[idx] !== val) + bPar = false; +} +var srcArr = [0, 1, true, null, new Object(), "five"]; +srcArr[999999] = -6.6; +var resArr = srcArr.map(callbackfn); +assert.sameValue(bCalled, true, 'bCalled'); +assert.sameValue(bPar, true, 'bPar'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-10.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-10.js new file mode 100644 index 00000000000..465fe0571bb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-10.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - callbackfn is called with 1 formal parameter +---*/ + +function callbackfn(val) { + return val > 10; +} +var testResult = [11].map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-11.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-11.js new file mode 100644 index 00000000000..a3603d784d5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-11.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - callbackfn is called with 2 formal parameters +---*/ + +function callbackfn(val, idx) { + return (val > 10 && arguments[2][idx] === val); +} +var testResult = [11].map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-12.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-12.js new file mode 100644 index 00000000000..9ac3cbc1581 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-12.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - callbackfn is called with 3 formal parameters +---*/ + +function callbackfn(val, idx, obj) { + return (val > 10 && obj[idx] === val); +} +var testResult = [11].map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-13.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-13.js new file mode 100644 index 00000000000..f3107b7765a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-13.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - callbackfn that uses arguments object to get + parameter value +---*/ + +function callbackfn() { + return arguments[2][arguments[1]] === arguments[0]; +} +var testResult = [11].map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-16.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-16.js new file mode 100644 index 00000000000..e96a605ce31 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-16.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'this' object when T is not an object (T is + a boolean primitive) +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === false; +} +var obj = { + 0: 11, + length: 2 +}; +var testResult = SendableArray.prototype.map.call(obj, callbackfn, false); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-17.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-17.js new file mode 100644 index 00000000000..9c59baa795e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-17.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'this' object when T is not an object (T is + a number) +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === 5; +} +var obj = { + 0: 11, + length: 2 +}; +var testResult = SendableArray.prototype.map.call(obj, callbackfn, 5); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-18.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-18.js new file mode 100644 index 00000000000..6c6b75365fb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-18.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - 'this' object when T is not an object (T is + a string primitive) +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === "hello!"; +} +var obj = { + 0: 11, + length: 2 +}; +var testResult = SendableArray.prototype.map.call(obj, callbackfn, "hello!"); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-19.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-19.js new file mode 100644 index 00000000000..4360c641361 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-19.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - non-indexed properties are not called. +---*/ + +var called = 0; +var result = false; +function callbackfn(val, idx, obj) { + called++; + if (val === 11) { + result = true; + } + return true; +} +var obj = { + 0: 9, + non_index_property: 11, + length: 20 +}; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(result, false, 'result'); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(called, 1, 'called'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-2.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-2.js new file mode 100644 index 00000000000..140b446f5f1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-2.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - callbackfn takes 3 arguments +---*/ + +var parCnt = 3; +var bCalled = false +function callbackfn(val, idx, obj) +{ + bCalled = true; + if (arguments.length !== 3) + parCnt = arguments.length; //verify if callbackfn was called with 3 parameters +} +var srcArr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +var resArr = srcArr.map(callbackfn); +assert.sameValue(bCalled, true, 'bCalled'); +assert.sameValue(parCnt, 3, 'parCnt'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-20.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-20.js new file mode 100644 index 00000000000..55b3f887080 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-20.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - callbackfn called with correct parameters + (thisArg is correct) +---*/ + +function callbackfn(val, idx, obj) { + return this.threshold === 10; +} +var thisArg = { + threshold: 10 +}; +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +var testResult = SendableArray.prototype.map.call(obj, callbackfn, thisArg); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-21.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-21.js new file mode 100644 index 00000000000..f3c8c32844d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-21.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - callbackfn called with correct parameters + (kValue is correct) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } + if (idx === 1) { + return val === 12; + } + return false; +} +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-22.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-22.js new file mode 100644 index 00000000000..e7006535a8a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-22.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - callbackfn called with correct parameters + (the index k is correct) +---*/ + +function callbackfn(val, idx, obj) { + if (val === 11) { + return idx === 0; + } + if (val === 12) { + return idx === 1; + } + return false; +} +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); +assert.sameValue(testResult[1], true, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-23.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-23.js new file mode 100644 index 00000000000..199b05166bf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-23.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - callbackfn called with correct parameters + (this object O is correct) +---*/ + +var obj = { + 0: 11, + length: 2 +}; +function callbackfn(val, idx, o) { + return obj === o; +} +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-4.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-4.js new file mode 100644 index 00000000000..396242145a5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-4.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - k values are passed in acending numeric order +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +var lastIdx = 0; +var called = 0; +var result = true; +function callbackfn(val, idx, o) { + called++; + if (lastIdx !== idx) { + result = false; + } else { + lastIdx++; + } +} +arr.map(callbackfn); +assert(result, 'result !== true'); +assert.sameValue(arr.length, called, 'arr.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-5.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-5.js new file mode 100644 index 00000000000..d80a0bfa65a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-5.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - k values are accessed during each iteration + and not prior to starting the loop. +---*/ + +var kIndex = []; +//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(val, idx, obj) { + //Each position should be visited one time, which means k is accessed one time during iterations. + if (typeof kIndex[idx] === "undefined") { + //when current position is visited, its previous index should has been visited. + if (idx !== 0 && typeof kIndex[idx - 1] === "undefined") { + return true; + } + kIndex[idx] = 1; + return false; + } else { + return true; + } +} +var testResult = [11, 12, 13, 14].map(callbackfn); +assert.sameValue(testResult.length, 4, 'testResult.length'); +assert.sameValue(testResult[0], false, 'testResult[0]'); +assert.sameValue(testResult[1], false, 'testResult[1]'); +assert.sameValue(testResult[2], false, 'testResult[2]'); +assert.sameValue(testResult[3], false, 'testResult[3]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-6.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-6.js new file mode 100644 index 00000000000..e6e7ead38b6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-6.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - arguments to callbackfn are self consistent. +---*/ + +var obj = { + 0: 11, + length: 1 +}; +var thisArg = {}; +function callbackfn() { + return this === thisArg && + arguments[0] === 11 && + arguments[1] === 0 && + arguments[2] === obj; +} +var testResult = SendableArray.prototype.map.call(obj, callbackfn, thisArg); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-7.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-7.js new file mode 100644 index 00000000000..2d7bab70fcf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-7.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - unhandled exceptions happened in callbackfn + terminate iteration +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + if (idx > 0) { + accessed = true; + } + if (idx === 0) { + throw new Error("Exception occurred in callbackfn"); + } +} +var obj = { + 0: 11, + 4: 10, + 10: 8, + length: 20 +}; +assert.throws(Error, function() { + SendableArray.prototype.map.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-8.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-8.js new file mode 100644 index 00000000000..0e6aebf5f5c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-8.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - element changed by callbackfn on previous + iterations is observed +---*/ + +var obj = { + 0: 9, + 1: 12, + length: 2 +}; +function callbackfn(val, idx, o) { + if (idx === 0) { + obj[idx + 1] = 8; + } + return val > 10; +} +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult[1], false, 'testResult[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-9.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-9.js new file mode 100644 index 00000000000..6c466e4e6e3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-ii-9.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - callbackfn with 0 formal parameter +---*/ + +function callbackfn() { + return true; +} +var testResult = [11].map(callbackfn); +assert.sameValue(testResult[0], true, 'testResult[0]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-1.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-1.js new file mode 100644 index 00000000000..bc7af570289 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-1.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - getOwnPropertyDescriptor(all true) of + returned array element +---*/ + +function callbackfn(val, idx, obj) { + if (val % 2) + return (2 * val + 1); + else + return (val / 2); +} +var srcArr = [0, 1, 2, 3, 4]; +var resArr = srcArr.map(callbackfn); +assert(resArr.length > 0, 'resArr.length > 0'); +var desc = Object.getOwnPropertyDescriptor(resArr, 1); +assert.sameValue(desc.value, 3, 'desc.value'); //srcArr[1] = 2*1+1 = 3 +assert.sameValue(desc.writable, true, 'desc.writable'); +assert.sameValue(desc.enumerable, true, 'desc.enumerable'); +assert.sameValue(desc.configurable, true, 'desc.configurable'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-2.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-2.js new file mode 100644 index 00000000000..c05dda2542c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-2.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of returned array element equals to + 'mappedValue' +---*/ + +function callbackfn(val, idx, obj) { + return val; +} +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(newArr[0], obj[0], 'newArr[0]'); +assert.sameValue(newArr[1], obj[1], 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-3.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-3.js new file mode 100644 index 00000000000..fd6e209a9c5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-3.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of returned array element can be + overwritten +---*/ + +function callbackfn(val, idx, obj) { + return 11; +} +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +var tempVal = newArr[1]; +newArr[1] += 1; +assert.notSameValue(newArr[1], tempVal, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-4.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-4.js new file mode 100644 index 00000000000..ccceaa99452 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-4.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of returned array element can be + enumerated +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 0: 11, + length: 2 +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +var prop; +var enumerable = false; +for (prop in newArr) { + if (newArr.hasOwnProperty(prop)) { + if (prop === "0") { + enumerable = true; + } + } +} +assert(enumerable, 'enumerable !== true'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-5.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-5.js new file mode 100644 index 00000000000..9d15257369f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-8-c-iii-5.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - value of returned array element can be + changed or deleted +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +var newArr = SendableArray.prototype.map.call(obj, callbackfn); +var tempVal = newArr[1]; +delete newArr[1]; +assert.notSameValue(tempVal, undefined, 'tempVal'); +assert.sameValue(newArr[1], undefined, 'newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-1.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-1.js new file mode 100644 index 00000000000..7b7ebcb439f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-1.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map doesn't mutate the Array on which it is called + on +---*/ + +function callbackfn(val, idx, obj) +{ + return true; +} +var srcArr = [1, 2, 3, 4, 5]; +srcArr.map(callbackfn); +assert.sameValue(srcArr[0], 1, 'srcArr[0]'); +assert.sameValue(srcArr[1], 2, 'srcArr[1]'); +assert.sameValue(srcArr[2], 3, 'srcArr[2]'); +assert.sameValue(srcArr[3], 4, 'srcArr[3]'); +assert.sameValue(srcArr[4], 5, 'srcArr[4]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-10.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-10.js new file mode 100644 index 00000000000..d1446698734 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-10.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - empty array to be returned if 'length' is 0 + (subclassed Array, length overridden with obj with valueOf) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var Foo = function() {}; +Foo.prototype = [1, 2, 3]; +var obj = new Foo(); +obj.length = { + valueOf: function() { + return 0; + } +}; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult.length, 0, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-11.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-11.js new file mode 100644 index 00000000000..c42f3e287f6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-11.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - returns an empty array if 'length' is 0 + (subclassed Array, length overridden with obj w/o valueOf + (toString)) +---*/ + +function Foo() {} +Foo.prototype = [1, 2, 3]; +var f = new Foo(); +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +function cb() {} +var a = SendableArray.prototype.map.call(f, cb); +assert(SendableArray.isArray(a), 'SendableArray.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-12.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-12.js new file mode 100644 index 00000000000..a9d76e4246d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-12.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - returns an empty array if 'length' is 0 + (subclassed Array, length overridden with []) +---*/ + +function Foo() {} +Foo.prototype = [1, 2, 3]; +var f = new Foo(); +f.length = []; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. + +function cb() {} +var a = SendableArray.prototype.map.call(f, cb); +assert(SendableArray.isArray(a), 'SendableArray.isArray(a) !== true'); +assert.sameValue(a.length, 0, 'a.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-13.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-13.js new file mode 100644 index 00000000000..ed8186fe9b6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-13.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - if there are no side effects of the + functions, O is unmodified +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + return val > 2; +} +var arr = [1, 2, 3, 4]; +arr.map(callbackfn); +assert.sameValue(arr[0], 1, 'arr[0]'); +assert.sameValue(arr[1], 2, 'arr[1]'); +assert.sameValue(arr[2], 3, 'arr[2]'); +assert.sameValue(arr[3], 4, 'arr[3]'); +assert.sameValue(called, 4, 'called'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-2.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-2.js new file mode 100644 index 00000000000..0b857cfaac3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-2.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map returns new Array with same number of elements + and values the result of callbackfn +---*/ + +function callbackfn(val, idx, obj) +{ + return val + 10; +} +var srcArr = [1, 2, 3, 4, 5]; +var resArr = srcArr.map(callbackfn); +assert.sameValue(resArr[0], 11, 'resArr[0]'); +assert.sameValue(resArr[1], 12, 'resArr[1]'); +assert.sameValue(resArr[2], 13, 'resArr[2]'); +assert.sameValue(resArr[3], 14, 'resArr[3]'); +assert.sameValue(resArr[4], 15, 'resArr[4]'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-3.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-3.js new file mode 100644 index 00000000000..4449e3eea05 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-3.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map - subclassed array when length is reduced +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = 1; +function cb() {} +var a = f.map(cb); +assert(SendableArray.isArray(a), 'SendableArray.isArray(a) !== true'); +assert.sameValue(a.length, 1, 'a.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-4.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-4.js new file mode 100644 index 00000000000..93c456634c4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-4.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map doesn't visit expandos +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + callCnt++; +} +var srcArr = [1, 2, 3, 4, 5]; +srcArr["i"] = 10; +srcArr[true] = 11; +var resArr = srcArr.map(callbackfn); +assert.sameValue(callCnt, 5, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-5.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-5.js new file mode 100644 index 00000000000..40187b122e6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-5.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - empty array to be returned if 'length' is 0 + (empty array) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var obj = { + 0: 9, + 1: 8, + length: 0 +}; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult.length, 0, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-6.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-6.js new file mode 100644 index 00000000000..8a3f5406313 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-6.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - empty array to be returned if 'length' is 0 + (subclassed Array, length overridden to null (type conversion)) +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +var Foo = function() {}; +Foo.prototype = [1, 2, 3]; +var obj = new Foo(); +obj.length = null; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult.length, 0, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-7.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-7.js new file mode 100644 index 00000000000..250f46ae481 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-7.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - empty array to be returned if 'length' is 0 + (subclassed Array, length overridden to false (type conversion)) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var Foo = function() {}; +Foo.prototype = [1, 2, 3]; +var obj = new Foo(); +obj.length = false; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult.length, 0, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-8.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-8.js new file mode 100644 index 00000000000..3437685ff6d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-8.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - empty array to be returned if 'length' is 0 + (subclassed Array, length overridden to 0 (type conversion)) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var Foo = function() {}; +Foo.prototype = [1, 2, 3]; +var obj = new Foo(); +obj.length = 0; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult.length, 0, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-9.js b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-9.js new file mode 100644 index 00000000000..1fddf891af0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/15.4.4.19-9-9.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map - empty array to be returned if 'length' is 0 + (subclassed Array, length overridden to '0' (type conversion)) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var Foo = function() {}; +Foo.prototype = [1, 2, 3]; +var obj = new Foo(); +obj.length = '0'; +var testResult = SendableArray.prototype.map.call(obj, callbackfn); +assert.sameValue(testResult.length, 0, 'testResult.length'); diff --git a/test/sendable/builtins/Array/prototype/map/call-with-boolean.js b/test/sendable/builtins/Array/prototype/map/call-with-boolean.js new file mode 100644 index 00000000000..fedb672daad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/call-with-boolean.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Array.prototype.map applied to boolean primitive +includes: [compareArray.js] +---*/ + +assert.compareArray( + SendableArray.prototype.map.call(true, () => {}), + [], + 'SendableArray.prototype.map.call(true, () => {}) must return []' +); +assert.compareArray( + SendableArray.prototype.map.call(false, () => {}), + [], + 'SendableArray.prototype.map.call(false, () => {}) must return []' +); diff --git a/test/sendable/builtins/Array/prototype/map/callbackfn-resize-arraybuffer.js b/test/sendable/builtins/Array/prototype/map/callbackfn-resize-arraybuffer.js new file mode 100644 index 00000000000..f071873ea1c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/callbackfn-resize-arraybuffer.js @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var finalResult, expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + elements = []; + indices = []; + arrays = []; + result = Array.prototype.map.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + finalResult = undefined; + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + finalResult = 2; + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + elements.push(element); + indices.push(index); + arrays.push(array); + return index; + }); + + assert.compareArray(elements, expectedElements, 'elements (shrink)'); + assert.compareArray(indices, expectedIndices, 'indices (shrink)'); + assert.compareArray(arrays, expectedArrays, 'arrays (shrink)'); + assert.compareArray(result, [0, 1, finalResult], 'result (shrink)'); + elements = []; + indices = []; + arrays = []; + result = Array.prototype.map.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + elements.push(element); + indices.push(index); + arrays.push(array); + return index; + }); + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.compareArray(result, expectedIndices, 'result (grow)'); +}); diff --git a/test/sendable/builtins/Array/prototype/map/create-ctor-non-object.js b/test/sendable/builtins/Array/prototype/map/create-ctor-non-object.js new file mode 100644 index 00000000000..304d988559d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-ctor-non-object.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Behavior when `constructor` property is neither an Object nor undefined +---*/ + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 0; +}; +a.constructor = null; +assert.throws(TypeError, function() { + a.map(cb); +}, 'null value'); +assert.sameValue(callCount, 0, 'callback not invoked (null value)'); +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.map(cb); +}, 'number value'); +assert.sameValue(callCount, 0, 'callback not invoked (number value)'); +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.map(cb); +}, 'string value'); +assert.sameValue(callCount, 0, 'callback not invoked (string value)'); +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.map(cb); +}, 'boolean value'); +assert.sameValue(callCount, 0, 'callback not invoked (boolean value)'); diff --git a/test/sendable/builtins/Array/prototype/map/create-ctor-poisoned.js b/test/sendable/builtins/Array/prototype/map/create-ctor-poisoned.js new file mode 100644 index 00000000000..d846811cf5a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-ctor-poisoned.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Abrupt completion from `constructor` property access +---*/ + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 1; +}; +Object.defineProperty(a, 'constructor', { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + a.map(cb); +}); +assert.sameValue(callCount, 0); diff --git a/test/sendable/builtins/Array/prototype/map/create-non-array-invalid-len.js b/test/sendable/builtins/Array/prototype/map/create-non-array-invalid-len.js new file mode 100644 index 00000000000..9cb5725cad8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-non-array-invalid-len.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Abrupt completion from creating a new array +---*/ + +var callCount = 0; +var obj = { + length: Math.pow(2, 32) +}; +var cb = function() { + callCount += 1; +}; +assert.throws(RangeError, function() { + SendableArray.prototype.map.call(obj, cb); +}); +assert.sameValue( + callCount, + 0, + 'RangeError thrown during SendableArray creation, not property modification' +); diff --git a/test/sendable/builtins/Array/prototype/map/create-non-array.js b/test/sendable/builtins/Array/prototype/map/create-non-array.js new file mode 100644 index 00000000000..62200bb6ade --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-non-array.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Constructor is ignored for non-Array values +---*/ + +var obj = { + length: 0 +}; +var callCount = 0; +var result; +Object.defineProperty(obj, 'constructor', { + get: function() { + callCount += 1; + } +}); +result = SendableArray.prototype.map.call(obj, function() {}); +assert.sameValue(callCount, 0, '`constructor` property not accessed'); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert(SendableArray.isArray(result), 'result is an SendableArray exotic object'); diff --git a/test/sendable/builtins/Array/prototype/map/create-proto-from-ctor-realm-array.js b/test/sendable/builtins/Array/prototype/map/create-proto-from-ctor-realm-array.js new file mode 100644 index 00000000000..1703def6510 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-proto-from-ctor-realm-array.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Prefer Array constructor of current realm record +---*/ + +var array = []; +var callCount = 0; +var OArray = $262.createRealm().global.Array; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OArray; +Object.defineProperty(Array, Symbol.species, speciesDesc); +Object.defineProperty(OArray, Symbol.species, speciesDesc); +result = SendableArray.map(function() {}); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert.sameValue(callCount, 0, 'Species constructor is not referenced'); diff --git a/test/sendable/builtins/Array/prototype/map/create-proto-from-ctor-realm-non-array.js b/test/sendable/builtins/Array/prototype/map/create-proto-from-ctor-realm-non-array.js new file mode 100644 index 00000000000..0846cebee52 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-proto-from-ctor-realm-non-array.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Accept non-Array constructors from other realms +---*/ + +var array = []; +var callCount = 0; +var CustomCtor = function() {}; +var OObject = $262.createRealm().global.Object; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OObject; +OObject[Symbol.species] = CustomCtor; +Object.defineProperty(Array, Symbol.species, speciesDesc); +result = SendableArray.map(function() {}); +assert.sameValue(Object.getPrototypeOf(result), CustomCtor.prototype); +assert.sameValue(callCount, 0, 'SendableArray species constructor is not referenced'); diff --git a/test/sendable/builtins/Array/prototype/map/create-proxy.js b/test/sendable/builtins/Array/prototype/map/create-proxy.js new file mode 100644 index 00000000000..9f313342381 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-proxy.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Species constructor of a Proxy object whose target is an array +---*/ + +var array = []; +var proxy = new Proxy(new Proxy(array, {}), {}); +var Ctor = function() {}; +var result; +array.constructor = function() {}; +array.constructor[Symbol.species] = Ctor; +result = SendableArray.prototype.map.call(proxy, function() {}); +assert.sameValue(Object.getPrototypeOf(result), Ctor.prototype); diff --git a/test/sendable/builtins/Array/prototype/map/create-revoked-proxy.js b/test/sendable/builtins/Array/prototype/map/create-revoked-proxy.js new file mode 100644 index 00000000000..96ae4890f11 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-revoked-proxy.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Abrupt completion from constructor that is a revoked Proxy object +---*/ + +var o = Proxy.revocable([], {}); +var ctorCount = 0; +var cbCount = 0; +var cb = function() { + cbCount += 1; +}; +Object.defineProperty(o.proxy, 'constructor', { + get: function() { + ctorCount += 1; + } +}); +o.revoke(); +assert.throws(TypeError, function() { + SendableArray.prototype.map.call(o.proxy, cb); +}); +assert.sameValue(ctorCount, 0, '`constructor` property not accessed'); +assert.sameValue(cbCount, 0, 'callback not invoked'); diff --git a/test/sendable/builtins/Array/prototype/map/create-species-abrupt.js b/test/sendable/builtins/Array/prototype/map/create-species-abrupt.js new file mode 100644 index 00000000000..163a020c95d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-species-abrupt.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Species constructor returns an abrupt completion +---*/ + +var Ctor = function() { + throw new Test262Error(); +}; +var callCount = 0; +var cb = function() { + callCount += 1; +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; +assert.throws(Test262Error, function() { + a.map(cb); +}); +assert.sameValue(callCount, 0); diff --git a/test/sendable/builtins/Array/prototype/map/create-species-non-ctor.js b/test/sendable/builtins/Array/prototype/map/create-species-non-ctor.js new file mode 100644 index 00000000000..1c818adc324 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-species-non-ctor.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Behavior when the @@species attribute is a non-constructor object +---*/ + +assert.sameValue( + isConstructor(parseInt), + false, + 'precondition: isConstructor(parseInt) must return false' +); +var a = []; +var callCount = 0; +var cb = function() { + callCount += 1; +}; +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; +assert.throws(TypeError, function() { + a.map(cb); +}, 'a.map(cb) throws a TypeError exception'); +assert.sameValue(callCount, 0); diff --git a/test/sendable/builtins/Array/prototype/map/create-species-null.js b/test/sendable/builtins/Array/prototype/map/create-species-null.js new file mode 100644 index 00000000000..1714c7e76e0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-species-null.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + A null value for the @@species constructor is interpreted as `undefined` +---*/ + +var a = []; +var result; +a.constructor = {}; +a.constructor[Symbol.species] = null; +result = a.map(function() {}); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert(SendableArray.isArray(result), 'result is an SendableArray exotic object'); diff --git a/test/sendable/builtins/Array/prototype/map/create-species-poisoned.js b/test/sendable/builtins/Array/prototype/map/create-species-poisoned.js new file mode 100644 index 00000000000..83dc6daaa54 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-species-poisoned.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Abrupt completion from `@@species` property access +---*/ + +var a = []; +var callCount = 0; +var cb = function() { + callCount += 1; +}; +a.constructor = {}; +Object.defineProperty(a.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + a.map(cb); +}); +assert.sameValue(callCount, 0); diff --git a/test/sendable/builtins/Array/prototype/map/create-species-undef-invalid-len.js b/test/sendable/builtins/Array/prototype/map/create-species-undef-invalid-len.js new file mode 100644 index 00000000000..b838ca1b1fa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-species-undef-invalid-len.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + An undefined value for the @@species constructor triggers the creation of + an Array exotic object +---*/ + +var array = []; +var maxLength = Math.pow(2, 32); +var cbCount = 0; +var setCount = 0; +var cb = function() { + cbCount += 1; +}; +var proxy = new Proxy(array, { + get: function(_, name) { + if (name === 'length') { + return maxLength; + } + return array[name]; + }, + set: function() { + setCount += 1; + return true; + } +}); +assert.throws(RangeError, function() { + SendableArray.prototype.map.call(proxy, cb); +}); +assert.sameValue( + setCount, + 0, + 'RangeError thrown during array creation, not property modification' +); +assert.sameValue(cbCount, 0, 'callback function not invoked'); diff --git a/test/sendable/builtins/Array/prototype/map/create-species-undef.js b/test/sendable/builtins/Array/prototype/map/create-species-undef.js new file mode 100644 index 00000000000..a243b50bf95 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-species-undef.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + An undefined value for the @@species constructor triggers the creation of + an Array exotic object +---*/ + +var a = []; +var result; +a.constructor = {}; +a.constructor[Symbol.species] = undefined; +result = a.map(function() {}); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert(SendableArray.isArray(result), 'result is an SendableArray exotic object'); diff --git a/test/sendable/builtins/Array/prototype/map/create-species.js b/test/sendable/builtins/Array/prototype/map/create-species.js new file mode 100644 index 00000000000..d66d09d59d6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/create-species.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: Species constructor is used to create a new instance +---*/ + +var thisValue, args, result; +var callCount = 0; +var instance = []; +var Ctor = function() { + callCount += 1; + thisValue = this; + args = arguments; + return instance; +}; +var a = [1, 2, 3, 4, 5]; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; +result = a.map(function() {}); +assert.sameValue(callCount, 1, 'Constructor invoked exactly once'); +assert.sameValue(Object.getPrototypeOf(thisValue), Ctor.prototype); +assert.sameValue(args.length, 1, 'Constructor invoked with a single argument'); +assert.sameValue(args[0], 5); +assert.sameValue(result, instance); diff --git a/test/sendable/builtins/Array/prototype/map/length.js b/test/sendable/builtins/Array/prototype/map/length.js new file mode 100644 index 00000000000..89b66af8c7f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/length.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + The "length" property of Array.prototype.map +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.map, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/map/name.js b/test/sendable/builtins/Array/prototype/map/name.js new file mode 100644 index 00000000000..bfd2d52e509 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Array.prototype.map.name is "map". +info: | + Array.prototype.map ( callbackfn [ , thisArg ] ) + 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(SendableArray.prototype.map, "name", { + value: "map", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/map/not-a-constructor.js b/test/sendable/builtins/Array/prototype/map/not-a-constructor.js new file mode 100644 index 00000000000..9c60dab664a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/not-a-constructor.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.map 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(SendableArray.prototype.map), false, 'isConstructor(SendableArray.prototype.map) must return false'); +assert.throws(TypeError, () => { + new SendableArray.prototype.map(() => {}); +}); + diff --git a/test/sendable/builtins/Array/prototype/map/prop-desc.js b/test/sendable/builtins/Array/prototype/map/prop-desc.js new file mode 100644 index 00000000000..0f2595e810e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/prop-desc.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + "map" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.map, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "map", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/map/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/Array/prototype/map/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..94d90688e69 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.map +description: > + Array.p.map behaves correctly when the resizable buffer is grown mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return n; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.map.call(fixedLength, ResizeMidIteration); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.map.call(fixedLengthWithOffset, ResizeMidIteration); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.map.call(lengthTracking, ResizeMidIteration); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.map.call(lengthTrackingWithOffset, ResizeMidIteration); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/map/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/Array/prototype/map/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..7d514e8b54f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.map +description: > + Array.p.map behaves correctly when the resizable buffer is shrunk mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. This version can deal with the undefined values +// resulting by shrinking rab. +function ShrinkMidIteration(n, ix, ta) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + // We still need to return a valid BigInt / non-BigInt, even if + // n is `undefined`. + if (ta instanceof BigInt64Array || ta instanceof BigUint64Array) { + return 0n; + } + return 0; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.map.call(fixedLength, ShrinkMidIteration); + assert.compareArray(values, [ + 0, + 2 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.map.call(fixedLengthWithOffset, ShrinkMidIteration); + assert.compareArray(values, [4]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.map.call(lengthTracking, ShrinkMidIteration); + assert.compareArray(values, [ + 0, + 2, + 4 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.map.call(lengthTrackingWithOffset, ShrinkMidIteration); + assert.compareArray(values, [4]); +} diff --git a/test/sendable/builtins/Array/prototype/map/resizable-buffer.js b/test/sendable/builtins/Array/prototype/map/resizable-buffer.js new file mode 100644 index 00000000000..6da359670d1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/resizable-buffer.js @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.map +description: > + Array.p.map behaves as expected on TypedArrays backed by resizable buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < taWrite.length; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + function MapGatherCompare(array) { + const values = []; + function GatherValues(n, ix) { + assert.sameValue(ix, values.length); + values.push(n); + if (typeof n == 'bigint') { + return n + 1n; + } + return n + 1; + } + const newValues = SendableArray.prototype.map.call(array, GatherValues); + for (let i = 0; i < values.length; ++i) { + if (typeof values[i] == 'bigint') { + assert.sameValue(values[i] + 1n, newValues[i]); + } else { + assert.sameValue(values[i] + 1, newValues[i]); + } + } + return ToNumbers(values); + } + assert.compareArray(MapGatherCompare(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(MapGatherCompare(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(MapGatherCompare(lengthTracking), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(MapGatherCompare(lengthTrackingWithOffset), [ + 4, + 6 + ]); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + assert.compareArray(MapGatherCompare(fixedLength), []); + assert.compareArray(MapGatherCompare(fixedLengthWithOffset), []); + assert.compareArray(MapGatherCompare(lengthTracking), [ + 0, + 2, + 4 + ]); + assert.compareArray(MapGatherCompare(lengthTrackingWithOffset), [4]); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.compareArray(MapGatherCompare(fixedLength), []); + assert.compareArray(MapGatherCompare(fixedLengthWithOffset), []); + assert.compareArray(MapGatherCompare(lengthTrackingWithOffset), []); + assert.compareArray(MapGatherCompare(lengthTracking), [0]); + // Shrink to zero. + rab.resize(0); + assert.compareArray(MapGatherCompare(fixedLength), []); + assert.compareArray(MapGatherCompare(fixedLengthWithOffset), []); + assert.compareArray(MapGatherCompare(lengthTrackingWithOffset), []); + assert.compareArray(MapGatherCompare(lengthTracking), []); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + assert.compareArray(MapGatherCompare(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(MapGatherCompare(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(MapGatherCompare(lengthTracking), [ + 0, + 2, + 4, + 6, + 8, + 10 + ]); + assert.compareArray(MapGatherCompare(lengthTrackingWithOffset), [ + 4, + 6, + 8, + 10 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/map/target-array-non-extensible.js b/test/sendable/builtins/Array/prototype/map/target-array-non-extensible.js new file mode 100644 index 00000000000..d47c62b8d95 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/target-array-non-extensible.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible) +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.map(function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/map/target-array-with-non-configurable-property.js b/test/sendable/builtins/Array/prototype/map/target-array-with-non-configurable-property.js new file mode 100644 index 00000000000..242143d6861 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/target-array-with-non-configurable-property.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable) +info: | + Array.prototype.map ( callbackfn [ , thisArg ] ) +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + set: function(_value) {}, + configurable: false, + }); +}; +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.map(function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/map/target-array-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/map/target-array-with-non-writable-property.js new file mode 100644 index 00000000000..0f9d11738b1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/map/target-array-with-non-writable-property.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.map +description: > + Non-writable properties are overwritten by CreateDataPropertyOrThrow. +---*/ + +var a = [1]; +a.constructor = {}; +a.constructor[Symbol.species] = function(len) { + var q = new Array(0); + Object.defineProperty(q, 0, { + value: 0, writable: false, configurable: true, enumerable: false, + }); + return q; +}; +var r = a.map(function(){ return 2; }); +verifyProperty(r, 0, { + value: 2, writable: true, configurable: true, enumerable: true, +}); -- Gitee From 543c7f37385fe40ccf66d5599b8c08c326bd4191 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 30 Dec 2024 16:41:18 +0800 Subject: [PATCH 55/93] add harness file Signed-off-by: zhuzhihui7 --- harness/verifyProperty-arguments.js | 31 +++++++++ harness/verifyProperty-configurable-object.js | 29 +++++++++ harness/verifyProperty-desc-is-not-object.js | 42 ++++++++++++ harness/verifyProperty-noproperty.js | 27 ++++++++ .../verifyProperty-restore-accessor-symbol.js | 55 ++++++++++++++++ harness/verifyProperty-restore-accessor.js | 54 ++++++++++++++++ harness/verifyProperty-restore-symbol.js | 46 +++++++++++++ harness/verifyProperty-restore.js | 45 +++++++++++++ harness/verifyProperty-same-value.js | 31 +++++++++ harness/verifyProperty-string-prop.js | 63 ++++++++++++++++++ harness/verifyProperty-symbol-prop.js | 64 +++++++++++++++++++ harness/verifyProperty-undefined-desc.js | 37 +++++++++++ harness/verifyProperty-value-error.js | 51 +++++++++++++++ harness/verifyProperty-value.js | 63 ++++++++++++++++++ 14 files changed, 638 insertions(+) create mode 100644 harness/verifyProperty-arguments.js create mode 100644 harness/verifyProperty-configurable-object.js create mode 100644 harness/verifyProperty-desc-is-not-object.js create mode 100644 harness/verifyProperty-noproperty.js create mode 100644 harness/verifyProperty-restore-accessor-symbol.js create mode 100644 harness/verifyProperty-restore-accessor.js create mode 100644 harness/verifyProperty-restore-symbol.js create mode 100644 harness/verifyProperty-restore.js create mode 100644 harness/verifyProperty-same-value.js create mode 100644 harness/verifyProperty-string-prop.js create mode 100644 harness/verifyProperty-symbol-prop.js create mode 100644 harness/verifyProperty-undefined-desc.js create mode 100644 harness/verifyProperty-value-error.js create mode 100644 harness/verifyProperty-value.js diff --git a/harness/verifyProperty-arguments.js b/harness/verifyProperty-arguments.js new file mode 100644 index 00000000000..5cc2efce7b1 --- /dev/null +++ b/harness/verifyProperty-arguments.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + verifyProperty should receive at least 3 arguments: obj, name, and descriptor +includes: [propertyHelper.js] +---*/ +assert.throws(Test262Error, () => { + verifyProperty(); +}, "0 arguments"); + +assert.throws(Test262Error, () => { + verifyProperty(Object); +}, "1 argument"); + +assert.throws(Test262Error, () => { + verifyProperty(Object, 'foo'); +}, "2 arguments"); diff --git a/harness/verifyProperty-configurable-object.js b/harness/verifyProperty-configurable-object.js new file mode 100644 index 00000000000..2376ba9f810 --- /dev/null +++ b/harness/verifyProperty-configurable-object.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Objects whose specified property is configurable satisfy the assertion. +includes: [propertyHelper.js] +---*/ + +Object.defineProperty(this, 'Object', { + configurable: true, + value: Object +}); + +verifyProperty(this, 'Object', { + configurable: true +}); diff --git a/harness/verifyProperty-desc-is-not-object.js b/harness/verifyProperty-desc-is-not-object.js new file mode 100644 index 00000000000..415e13079e0 --- /dev/null +++ b/harness/verifyProperty-desc-is-not-object.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + The desc argument should be an object or undefined +includes: [propertyHelper.js] +features: [Symbol] +---*/ +var sample = { foo: 42 }; + +assert.throws(Test262Error, () => { + verifyProperty(sample, "foo", 'configurable'); +}, "string"); + +assert.throws(Test262Error, () => { + verifyProperty(sample, 'foo', true); +}, "boolean"); + +assert.throws(Test262Error, () => { + verifyProperty(sample, 'foo', 42); +}, "number"); + +assert.throws(Test262Error, () => { + verifyProperty(sample, 'foo', null); +}, "null"); + +assert.throws(Test262Error, () => { + verifyProperty(sample, 'foo', Symbol(1)); +}, "symbol"); diff --git a/harness/verifyProperty-noproperty.js b/harness/verifyProperty-noproperty.js new file mode 100644 index 00000000000..674d64090c5 --- /dev/null +++ b/harness/verifyProperty-noproperty.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + The first argument should have an own property +includes: [propertyHelper.js] +---*/ +assert.throws(Test262Error, () => { + verifyProperty(Object, 'JeanPaulSartre', {}); +}, "inexisting property"); + +assert.throws(Test262Error, () => { + verifyProperty({}, 'hasOwnProperty', {}); +}, "inexisting own property"); diff --git a/harness/verifyProperty-restore-accessor-symbol.js b/harness/verifyProperty-restore-accessor-symbol.js new file mode 100644 index 00000000000..12e5464f15b --- /dev/null +++ b/harness/verifyProperty-restore-accessor-symbol.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + verifyProperty allows restoring the original accessor descriptor +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var obj; +var prop = Symbol(1); +var desc = { enumerable: true, configurable: true, get() { return 42; }, set() {} }; + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + false +); + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc, { restore: true }); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + true +); +assert.sameValue(obj[prop], 42); +assert.sameValue( + Object.getOwnPropertyDescriptor(obj, prop).get, + desc.get +); + +assert.sameValue( + Object.getOwnPropertyDescriptor(obj, prop).set, + desc.set +); diff --git a/harness/verifyProperty-restore-accessor.js b/harness/verifyProperty-restore-accessor.js new file mode 100644 index 00000000000..c1c437a8169 --- /dev/null +++ b/harness/verifyProperty-restore-accessor.js @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + verifyProperty allows restoring the original accessor descriptor +includes: [propertyHelper.js] +---*/ + +var obj; +var prop = "prop"; +var desc = { enumerable: true, configurable: true, get() { return 42; }, set() {} }; + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + false +); + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc, { restore: true }); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + true +); +assert.sameValue(obj[prop], 42); +assert.sameValue( + Object.getOwnPropertyDescriptor(obj, prop).get, + desc.get +); + +assert.sameValue( + Object.getOwnPropertyDescriptor(obj, prop).set, + desc.set +); diff --git a/harness/verifyProperty-restore-symbol.js b/harness/verifyProperty-restore-symbol.js new file mode 100644 index 00000000000..fcd4a80202b --- /dev/null +++ b/harness/verifyProperty-restore-symbol.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + verifyProperty allows restoring the original descriptor +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var obj; +var prop = Symbol(1); +var desc = { enumerable: true, configurable: true, writable: true, value: 42 }; + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + false +); + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc, { restore: true }); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + true +); +assert.sameValue(obj[prop], 42); diff --git a/harness/verifyProperty-restore.js b/harness/verifyProperty-restore.js new file mode 100644 index 00000000000..64a5da3960c --- /dev/null +++ b/harness/verifyProperty-restore.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + verifyProperty allows restoring the original descriptor +includes: [propertyHelper.js] +---*/ + +var obj; +var prop = 'prop'; +var desc = { enumerable: true, configurable: true, writable: true, value: 42 }; + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + false +); + +obj = {}; +Object.defineProperty(obj, prop, desc); + +verifyProperty(obj, prop, desc, { restore: true }); + +assert.sameValue( + Object.prototype.hasOwnProperty.call(obj, prop), + true +); +assert.sameValue(obj[prop], 42); diff --git a/harness/verifyProperty-same-value.js b/harness/verifyProperty-same-value.js new file mode 100644 index 00000000000..644aeff7d18 --- /dev/null +++ b/harness/verifyProperty-same-value.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + verifyProperty uses SameValue for value comparison. +includes: [propertyHelper.js] +---*/ + +var obj = { + a: NaN, + b: -0, +}; + +assert(verifyProperty(obj, 'a', { value: NaN })); +assert(verifyProperty(obj, 'b', { value: -0 })); + +assert.throws(Test262Error, function() { + verifyProperty(obj, 'b', { value: 0 }); +}); diff --git a/harness/verifyProperty-string-prop.js b/harness/verifyProperty-string-prop.js new file mode 100644 index 00000000000..b717d7efec5 --- /dev/null +++ b/harness/verifyProperty-string-prop.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Verify property descriptor +includes: [propertyHelper.js] +---*/ + +var obj; +var prop = 'prop'; + +function reset(desc) { + obj = {}; + Object.defineProperty(obj, prop, desc); +} + +function checkDesc(desc) { + reset(desc); + assert(verifyProperty(obj, prop, desc)); + + reset(desc); + assert(verifyProperty(obj, prop, { enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { writable: desc.writable })); + + reset(desc); + assert(verifyProperty(obj, prop, { configurable: desc.configurable })); + + reset(desc); + assert(verifyProperty(obj, prop, { configurable: desc.configurable, enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { configurable: desc.configurable, writable: desc.writable })); + + reset(desc); + assert(verifyProperty(obj, prop, { writable: desc.writable, enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { enumerable: desc.enumerable, configurable: desc.configurable })); +} + +checkDesc({ enumerable: true, configurable: true, writable: true }); +checkDesc({ enumerable: false, writable: false, configurable: false }); +checkDesc({ enumerable: true, writable: false, configurable: false }); +checkDesc({ enumerable: false, writable: true, configurable: false }); +checkDesc({ enumerable: false, writable: false, configurable: true }); +checkDesc({ enumerable: true, writable: false, configurable: true }); +checkDesc({ enumerable: true, writable: true, configurable: false }); +checkDesc({ enumerable: false, writable: true, configurable: true }); diff --git a/harness/verifyProperty-symbol-prop.js b/harness/verifyProperty-symbol-prop.js new file mode 100644 index 00000000000..a8a40a6c3e2 --- /dev/null +++ b/harness/verifyProperty-symbol-prop.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Verify symbol named property descriptor +includes: [propertyHelper.js] +features: [Symbol] +---*/ + +var obj; +var prop = Symbol(1); + +function reset(desc) { + obj = {}; + Object.defineProperty(obj, prop, desc); +} + +function checkDesc(desc) { + reset(desc); + assert(verifyProperty(obj, prop, desc)); + + reset(desc); + assert(verifyProperty(obj, prop, { enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { writable: desc.writable })); + + reset(desc); + assert(verifyProperty(obj, prop, { configurable: desc.configurable })); + + reset(desc); + assert(verifyProperty(obj, prop, { configurable: desc.configurable, enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { configurable: desc.configurable, writable: desc.writable })); + + reset(desc); + assert(verifyProperty(obj, prop, { writable: desc.writable, enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { enumerable: desc.enumerable, configurable: desc.configurable })); +} + +checkDesc({ enumerable: true, configurable: true, writable: true }); +checkDesc({ enumerable: false, writable: false, configurable: false }); +checkDesc({ enumerable: true, writable: false, configurable: false }); +checkDesc({ enumerable: false, writable: true, configurable: false }); +checkDesc({ enumerable: false, writable: false, configurable: true }); +checkDesc({ enumerable: true, writable: false, configurable: true }); +checkDesc({ enumerable: true, writable: true, configurable: false }); +checkDesc({ enumerable: false, writable: true, configurable: true }); diff --git a/harness/verifyProperty-undefined-desc.js b/harness/verifyProperty-undefined-desc.js new file mode 100644 index 00000000000..1c910b727dd --- /dev/null +++ b/harness/verifyProperty-undefined-desc.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: > + Verify an undefined descriptor +includes: [propertyHelper.js] +---*/ +var sample = { + bar: undefined, + get baz() {} +}; + +assert.sameValue( + verifyProperty(sample, "foo", undefined), + true, + "returns true if desc and property descriptor are both undefined" +); + +assert.throws(Test262Error, () => { + verifyProperty(sample, 'bar', undefined); +}, "dataDescriptor value is undefined"); + +assert.throws(Test262Error, () => { + verifyProperty(sample, 'baz', undefined); +}, "accessor returns undefined"); diff --git a/harness/verifyProperty-value-error.js b/harness/verifyProperty-value-error.js new file mode 100644 index 00000000000..9b44e6ee10f --- /dev/null +++ b/harness/verifyProperty-value-error.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Including propertyHelper.js will expose: + + verifyProperty() + ... + +includes: [propertyHelper.js] +---*/ + +var threw = false; +var object = Object.defineProperty({}, "prop", { + value: 1 +}); + +try { + verifyProperty(object, "prop", { + value: 2 + }); +} catch(err) { + threw = true; + if (err.constructor !== Test262Error) { + throw new Error( + 'Expected a Test262Error, but a "' + err.constructor.name + + '" was thrown.' + ); + } + + if (err.message !== 'descriptor value should be 2; object value should be 2') { + throw new Error('The error thrown did not define the specified message'); + } +} + +if (threw === false) { + throw new Error('Expected a Test262Error, but no error was thrown.'); +} diff --git a/harness/verifyProperty-value.js b/harness/verifyProperty-value.js new file mode 100644 index 00000000000..fbdf2862543 --- /dev/null +++ b/harness/verifyProperty-value.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +description: > + Verify property descriptor +includes: [propertyHelper.js] +---*/ + +var obj; +var prop = 'prop'; + +function reset(desc) { + desc.value = prop; + obj = Object.defineProperty({}, prop, desc); +} + +function checkDesc(desc) { + reset(desc); + assert(verifyProperty(obj, prop, desc)); + + reset(desc); + assert(verifyProperty(obj, prop, { value: 'prop', enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { value: 'prop', writable: desc.writable })); + + reset(desc); + assert(verifyProperty(obj, prop, { value: 'prop', configurable: desc.configurable })); + + reset(desc); + assert(verifyProperty(obj, prop, { value: 'prop', configurable: desc.configurable, enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { value: 'prop', configurable: desc.configurable, writable: desc.writable })); + + reset(desc); + assert(verifyProperty(obj, prop, { value: 'prop', writable: desc.writable, enumerable: desc.enumerable })); + + reset(desc); + assert(verifyProperty(obj, prop, { value: 'prop', enumerable: desc.enumerable, configurable: desc.configurable })); +} + +checkDesc({ enumerable: true, configurable: true, writable: true }); +checkDesc({ enumerable: false, writable: false, configurable: false }); +checkDesc({ enumerable: true, writable: false, configurable: false }); +checkDesc({ enumerable: false, writable: true, configurable: false }); +checkDesc({ enumerable: false, writable: false, configurable: true }); +checkDesc({ enumerable: true, writable: false, configurable: true }); +checkDesc({ enumerable: true, writable: true, configurable: false }); +checkDesc({ enumerable: false, writable: true, configurable: true }); -- Gitee From 4e4d96a5c1a7a6d1cce0b60c2de9765775eb0b54 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 30 Dec 2024 16:53:41 +0800 Subject: [PATCH 56/93] rollback files Signed-off-by: zhuzhihui7 --- .../harness/verifyProperty-arguments.js | 31 --------- .../verifyProperty-configurable-object.js | 29 --------- .../verifyProperty-desc-is-not-object.js | 42 ------------ .../harness/verifyProperty-noproperty.js | 27 -------- .../verifyProperty-restore-accessor-symbol.js | 55 ---------------- .../verifyProperty-restore-accessor.js | 54 ---------------- .../harness/verifyProperty-restore-symbol.js | 46 ------------- .../harness/verifyProperty-restore.js | 45 ------------- .../harness/verifyProperty-same-value.js | 31 --------- .../harness/verifyProperty-string-prop.js | 63 ------------------ .../harness/verifyProperty-symbol-prop.js | 64 ------------------- .../harness/verifyProperty-undefined-desc.js | 37 ----------- .../harness/verifyProperty-value-error.js | 51 --------------- test/sendable/harness/verifyProperty-value.js | 63 ------------------ 14 files changed, 638 deletions(-) delete mode 100644 test/sendable/harness/verifyProperty-arguments.js delete mode 100644 test/sendable/harness/verifyProperty-configurable-object.js delete mode 100644 test/sendable/harness/verifyProperty-desc-is-not-object.js delete mode 100644 test/sendable/harness/verifyProperty-noproperty.js delete mode 100644 test/sendable/harness/verifyProperty-restore-accessor-symbol.js delete mode 100644 test/sendable/harness/verifyProperty-restore-accessor.js delete mode 100644 test/sendable/harness/verifyProperty-restore-symbol.js delete mode 100644 test/sendable/harness/verifyProperty-restore.js delete mode 100644 test/sendable/harness/verifyProperty-same-value.js delete mode 100644 test/sendable/harness/verifyProperty-string-prop.js delete mode 100644 test/sendable/harness/verifyProperty-symbol-prop.js delete mode 100644 test/sendable/harness/verifyProperty-undefined-desc.js delete mode 100644 test/sendable/harness/verifyProperty-value-error.js delete mode 100644 test/sendable/harness/verifyProperty-value.js diff --git a/test/sendable/harness/verifyProperty-arguments.js b/test/sendable/harness/verifyProperty-arguments.js deleted file mode 100644 index 5cc2efce7b1..00000000000 --- a/test/sendable/harness/verifyProperty-arguments.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*--- -description: > - verifyProperty should receive at least 3 arguments: obj, name, and descriptor -includes: [propertyHelper.js] ----*/ -assert.throws(Test262Error, () => { - verifyProperty(); -}, "0 arguments"); - -assert.throws(Test262Error, () => { - verifyProperty(Object); -}, "1 argument"); - -assert.throws(Test262Error, () => { - verifyProperty(Object, 'foo'); -}, "2 arguments"); diff --git a/test/sendable/harness/verifyProperty-configurable-object.js b/test/sendable/harness/verifyProperty-configurable-object.js deleted file mode 100644 index 2376ba9f810..00000000000 --- a/test/sendable/harness/verifyProperty-configurable-object.js +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*--- -description: > - Objects whose specified property is configurable satisfy the assertion. -includes: [propertyHelper.js] ----*/ - -Object.defineProperty(this, 'Object', { - configurable: true, - value: Object -}); - -verifyProperty(this, 'Object', { - configurable: true -}); diff --git a/test/sendable/harness/verifyProperty-desc-is-not-object.js b/test/sendable/harness/verifyProperty-desc-is-not-object.js deleted file mode 100644 index 415e13079e0..00000000000 --- a/test/sendable/harness/verifyProperty-desc-is-not-object.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*--- -description: > - The desc argument should be an object or undefined -includes: [propertyHelper.js] -features: [Symbol] ----*/ -var sample = { foo: 42 }; - -assert.throws(Test262Error, () => { - verifyProperty(sample, "foo", 'configurable'); -}, "string"); - -assert.throws(Test262Error, () => { - verifyProperty(sample, 'foo', true); -}, "boolean"); - -assert.throws(Test262Error, () => { - verifyProperty(sample, 'foo', 42); -}, "number"); - -assert.throws(Test262Error, () => { - verifyProperty(sample, 'foo', null); -}, "null"); - -assert.throws(Test262Error, () => { - verifyProperty(sample, 'foo', Symbol(1)); -}, "symbol"); diff --git a/test/sendable/harness/verifyProperty-noproperty.js b/test/sendable/harness/verifyProperty-noproperty.js deleted file mode 100644 index 674d64090c5..00000000000 --- a/test/sendable/harness/verifyProperty-noproperty.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*--- -description: > - The first argument should have an own property -includes: [propertyHelper.js] ----*/ -assert.throws(Test262Error, () => { - verifyProperty(Object, 'JeanPaulSartre', {}); -}, "inexisting property"); - -assert.throws(Test262Error, () => { - verifyProperty({}, 'hasOwnProperty', {}); -}, "inexisting own property"); diff --git a/test/sendable/harness/verifyProperty-restore-accessor-symbol.js b/test/sendable/harness/verifyProperty-restore-accessor-symbol.js deleted file mode 100644 index 12e5464f15b..00000000000 --- a/test/sendable/harness/verifyProperty-restore-accessor-symbol.js +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*--- -description: > - verifyProperty allows restoring the original accessor descriptor -includes: [propertyHelper.js] -features: [Symbol] ----*/ - -var obj; -var prop = Symbol(1); -var desc = { enumerable: true, configurable: true, get() { return 42; }, set() {} }; - -obj = {}; -Object.defineProperty(obj, prop, desc); - -verifyProperty(obj, prop, desc); - -assert.sameValue( - Object.prototype.hasOwnProperty.call(obj, prop), - false -); - -obj = {}; -Object.defineProperty(obj, prop, desc); - -verifyProperty(obj, prop, desc, { restore: true }); - -assert.sameValue( - Object.prototype.hasOwnProperty.call(obj, prop), - true -); -assert.sameValue(obj[prop], 42); -assert.sameValue( - Object.getOwnPropertyDescriptor(obj, prop).get, - desc.get -); - -assert.sameValue( - Object.getOwnPropertyDescriptor(obj, prop).set, - desc.set -); diff --git a/test/sendable/harness/verifyProperty-restore-accessor.js b/test/sendable/harness/verifyProperty-restore-accessor.js deleted file mode 100644 index c1c437a8169..00000000000 --- a/test/sendable/harness/verifyProperty-restore-accessor.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*--- -description: > - verifyProperty allows restoring the original accessor descriptor -includes: [propertyHelper.js] ----*/ - -var obj; -var prop = "prop"; -var desc = { enumerable: true, configurable: true, get() { return 42; }, set() {} }; - -obj = {}; -Object.defineProperty(obj, prop, desc); - -verifyProperty(obj, prop, desc); - -assert.sameValue( - Object.prototype.hasOwnProperty.call(obj, prop), - false -); - -obj = {}; -Object.defineProperty(obj, prop, desc); - -verifyProperty(obj, prop, desc, { restore: true }); - -assert.sameValue( - Object.prototype.hasOwnProperty.call(obj, prop), - true -); -assert.sameValue(obj[prop], 42); -assert.sameValue( - Object.getOwnPropertyDescriptor(obj, prop).get, - desc.get -); - -assert.sameValue( - Object.getOwnPropertyDescriptor(obj, prop).set, - desc.set -); diff --git a/test/sendable/harness/verifyProperty-restore-symbol.js b/test/sendable/harness/verifyProperty-restore-symbol.js deleted file mode 100644 index fcd4a80202b..00000000000 --- a/test/sendable/harness/verifyProperty-restore-symbol.js +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*--- -description: > - verifyProperty allows restoring the original descriptor -includes: [propertyHelper.js] -features: [Symbol] ----*/ - -var obj; -var prop = Symbol(1); -var desc = { enumerable: true, configurable: true, writable: true, value: 42 }; - -obj = {}; -Object.defineProperty(obj, prop, desc); - -verifyProperty(obj, prop, desc); - -assert.sameValue( - Object.prototype.hasOwnProperty.call(obj, prop), - false -); - -obj = {}; -Object.defineProperty(obj, prop, desc); - -verifyProperty(obj, prop, desc, { restore: true }); - -assert.sameValue( - Object.prototype.hasOwnProperty.call(obj, prop), - true -); -assert.sameValue(obj[prop], 42); diff --git a/test/sendable/harness/verifyProperty-restore.js b/test/sendable/harness/verifyProperty-restore.js deleted file mode 100644 index 64a5da3960c..00000000000 --- a/test/sendable/harness/verifyProperty-restore.js +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*--- -description: > - verifyProperty allows restoring the original descriptor -includes: [propertyHelper.js] ----*/ - -var obj; -var prop = 'prop'; -var desc = { enumerable: true, configurable: true, writable: true, value: 42 }; - -obj = {}; -Object.defineProperty(obj, prop, desc); - -verifyProperty(obj, prop, desc); - -assert.sameValue( - Object.prototype.hasOwnProperty.call(obj, prop), - false -); - -obj = {}; -Object.defineProperty(obj, prop, desc); - -verifyProperty(obj, prop, desc, { restore: true }); - -assert.sameValue( - Object.prototype.hasOwnProperty.call(obj, prop), - true -); -assert.sameValue(obj[prop], 42); diff --git a/test/sendable/harness/verifyProperty-same-value.js b/test/sendable/harness/verifyProperty-same-value.js deleted file mode 100644 index 644aeff7d18..00000000000 --- a/test/sendable/harness/verifyProperty-same-value.js +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*--- -description: > - verifyProperty uses SameValue for value comparison. -includes: [propertyHelper.js] ----*/ - -var obj = { - a: NaN, - b: -0, -}; - -assert(verifyProperty(obj, 'a', { value: NaN })); -assert(verifyProperty(obj, 'b', { value: -0 })); - -assert.throws(Test262Error, function() { - verifyProperty(obj, 'b', { value: 0 }); -}); diff --git a/test/sendable/harness/verifyProperty-string-prop.js b/test/sendable/harness/verifyProperty-string-prop.js deleted file mode 100644 index b717d7efec5..00000000000 --- a/test/sendable/harness/verifyProperty-string-prop.js +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*--- -description: > - Verify property descriptor -includes: [propertyHelper.js] ----*/ - -var obj; -var prop = 'prop'; - -function reset(desc) { - obj = {}; - Object.defineProperty(obj, prop, desc); -} - -function checkDesc(desc) { - reset(desc); - assert(verifyProperty(obj, prop, desc)); - - reset(desc); - assert(verifyProperty(obj, prop, { enumerable: desc.enumerable })); - - reset(desc); - assert(verifyProperty(obj, prop, { writable: desc.writable })); - - reset(desc); - assert(verifyProperty(obj, prop, { configurable: desc.configurable })); - - reset(desc); - assert(verifyProperty(obj, prop, { configurable: desc.configurable, enumerable: desc.enumerable })); - - reset(desc); - assert(verifyProperty(obj, prop, { configurable: desc.configurable, writable: desc.writable })); - - reset(desc); - assert(verifyProperty(obj, prop, { writable: desc.writable, enumerable: desc.enumerable })); - - reset(desc); - assert(verifyProperty(obj, prop, { enumerable: desc.enumerable, configurable: desc.configurable })); -} - -checkDesc({ enumerable: true, configurable: true, writable: true }); -checkDesc({ enumerable: false, writable: false, configurable: false }); -checkDesc({ enumerable: true, writable: false, configurable: false }); -checkDesc({ enumerable: false, writable: true, configurable: false }); -checkDesc({ enumerable: false, writable: false, configurable: true }); -checkDesc({ enumerable: true, writable: false, configurable: true }); -checkDesc({ enumerable: true, writable: true, configurable: false }); -checkDesc({ enumerable: false, writable: true, configurable: true }); diff --git a/test/sendable/harness/verifyProperty-symbol-prop.js b/test/sendable/harness/verifyProperty-symbol-prop.js deleted file mode 100644 index a8a40a6c3e2..00000000000 --- a/test/sendable/harness/verifyProperty-symbol-prop.js +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*--- -description: > - Verify symbol named property descriptor -includes: [propertyHelper.js] -features: [Symbol] ----*/ - -var obj; -var prop = Symbol(1); - -function reset(desc) { - obj = {}; - Object.defineProperty(obj, prop, desc); -} - -function checkDesc(desc) { - reset(desc); - assert(verifyProperty(obj, prop, desc)); - - reset(desc); - assert(verifyProperty(obj, prop, { enumerable: desc.enumerable })); - - reset(desc); - assert(verifyProperty(obj, prop, { writable: desc.writable })); - - reset(desc); - assert(verifyProperty(obj, prop, { configurable: desc.configurable })); - - reset(desc); - assert(verifyProperty(obj, prop, { configurable: desc.configurable, enumerable: desc.enumerable })); - - reset(desc); - assert(verifyProperty(obj, prop, { configurable: desc.configurable, writable: desc.writable })); - - reset(desc); - assert(verifyProperty(obj, prop, { writable: desc.writable, enumerable: desc.enumerable })); - - reset(desc); - assert(verifyProperty(obj, prop, { enumerable: desc.enumerable, configurable: desc.configurable })); -} - -checkDesc({ enumerable: true, configurable: true, writable: true }); -checkDesc({ enumerable: false, writable: false, configurable: false }); -checkDesc({ enumerable: true, writable: false, configurable: false }); -checkDesc({ enumerable: false, writable: true, configurable: false }); -checkDesc({ enumerable: false, writable: false, configurable: true }); -checkDesc({ enumerable: true, writable: false, configurable: true }); -checkDesc({ enumerable: true, writable: true, configurable: false }); -checkDesc({ enumerable: false, writable: true, configurable: true }); diff --git a/test/sendable/harness/verifyProperty-undefined-desc.js b/test/sendable/harness/verifyProperty-undefined-desc.js deleted file mode 100644 index 1c910b727dd..00000000000 --- a/test/sendable/harness/verifyProperty-undefined-desc.js +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/*--- -description: > - Verify an undefined descriptor -includes: [propertyHelper.js] ----*/ -var sample = { - bar: undefined, - get baz() {} -}; - -assert.sameValue( - verifyProperty(sample, "foo", undefined), - true, - "returns true if desc and property descriptor are both undefined" -); - -assert.throws(Test262Error, () => { - verifyProperty(sample, 'bar', undefined); -}, "dataDescriptor value is undefined"); - -assert.throws(Test262Error, () => { - verifyProperty(sample, 'baz', undefined); -}, "accessor returns undefined"); diff --git a/test/sendable/harness/verifyProperty-value-error.js b/test/sendable/harness/verifyProperty-value-error.js deleted file mode 100644 index 9b44e6ee10f..00000000000 --- a/test/sendable/harness/verifyProperty-value-error.js +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*--- -description: > - Including propertyHelper.js will expose: - - verifyProperty() - ... - -includes: [propertyHelper.js] ----*/ - -var threw = false; -var object = Object.defineProperty({}, "prop", { - value: 1 -}); - -try { - verifyProperty(object, "prop", { - value: 2 - }); -} catch(err) { - threw = true; - if (err.constructor !== Test262Error) { - throw new Error( - 'Expected a Test262Error, but a "' + err.constructor.name + - '" was thrown.' - ); - } - - if (err.message !== 'descriptor value should be 2; object value should be 2') { - throw new Error('The error thrown did not define the specified message'); - } -} - -if (threw === false) { - throw new Error('Expected a Test262Error, but no error was thrown.'); -} diff --git a/test/sendable/harness/verifyProperty-value.js b/test/sendable/harness/verifyProperty-value.js deleted file mode 100644 index fbdf2862543..00000000000 --- a/test/sendable/harness/verifyProperty-value.js +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/*--- -description: > - Verify property descriptor -includes: [propertyHelper.js] ----*/ - -var obj; -var prop = 'prop'; - -function reset(desc) { - desc.value = prop; - obj = Object.defineProperty({}, prop, desc); -} - -function checkDesc(desc) { - reset(desc); - assert(verifyProperty(obj, prop, desc)); - - reset(desc); - assert(verifyProperty(obj, prop, { value: 'prop', enumerable: desc.enumerable })); - - reset(desc); - assert(verifyProperty(obj, prop, { value: 'prop', writable: desc.writable })); - - reset(desc); - assert(verifyProperty(obj, prop, { value: 'prop', configurable: desc.configurable })); - - reset(desc); - assert(verifyProperty(obj, prop, { value: 'prop', configurable: desc.configurable, enumerable: desc.enumerable })); - - reset(desc); - assert(verifyProperty(obj, prop, { value: 'prop', configurable: desc.configurable, writable: desc.writable })); - - reset(desc); - assert(verifyProperty(obj, prop, { value: 'prop', writable: desc.writable, enumerable: desc.enumerable })); - - reset(desc); - assert(verifyProperty(obj, prop, { value: 'prop', enumerable: desc.enumerable, configurable: desc.configurable })); -} - -checkDesc({ enumerable: true, configurable: true, writable: true }); -checkDesc({ enumerable: false, writable: false, configurable: false }); -checkDesc({ enumerable: true, writable: false, configurable: false }); -checkDesc({ enumerable: false, writable: true, configurable: false }); -checkDesc({ enumerable: false, writable: false, configurable: true }); -checkDesc({ enumerable: true, writable: false, configurable: true }); -checkDesc({ enumerable: true, writable: true, configurable: false }); -checkDesc({ enumerable: false, writable: true, configurable: true }); -- Gitee From 0967e98e3fcd2ae9d22b9322fb7a0cc1d2d433bd Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 30 Dec 2024 16:55:47 +0800 Subject: [PATCH 57/93] rollback again Signed-off-by: zhuzhihui7 --- {harness => test/sendable/harness}/verifyProperty-arguments.js | 0 .../sendable/harness}/verifyProperty-configurable-object.js | 0 .../sendable/harness}/verifyProperty-desc-is-not-object.js | 0 {harness => test/sendable/harness}/verifyProperty-noproperty.js | 0 .../sendable/harness}/verifyProperty-restore-accessor-symbol.js | 0 .../sendable/harness}/verifyProperty-restore-accessor.js | 0 .../sendable/harness}/verifyProperty-restore-symbol.js | 0 {harness => test/sendable/harness}/verifyProperty-restore.js | 0 {harness => test/sendable/harness}/verifyProperty-same-value.js | 0 {harness => test/sendable/harness}/verifyProperty-string-prop.js | 0 {harness => test/sendable/harness}/verifyProperty-symbol-prop.js | 0 .../sendable/harness}/verifyProperty-undefined-desc.js | 0 {harness => test/sendable/harness}/verifyProperty-value-error.js | 0 {harness => test/sendable/harness}/verifyProperty-value.js | 0 14 files changed, 0 insertions(+), 0 deletions(-) rename {harness => test/sendable/harness}/verifyProperty-arguments.js (100%) rename {harness => test/sendable/harness}/verifyProperty-configurable-object.js (100%) rename {harness => test/sendable/harness}/verifyProperty-desc-is-not-object.js (100%) rename {harness => test/sendable/harness}/verifyProperty-noproperty.js (100%) rename {harness => test/sendable/harness}/verifyProperty-restore-accessor-symbol.js (100%) rename {harness => test/sendable/harness}/verifyProperty-restore-accessor.js (100%) rename {harness => test/sendable/harness}/verifyProperty-restore-symbol.js (100%) rename {harness => test/sendable/harness}/verifyProperty-restore.js (100%) rename {harness => test/sendable/harness}/verifyProperty-same-value.js (100%) rename {harness => test/sendable/harness}/verifyProperty-string-prop.js (100%) rename {harness => test/sendable/harness}/verifyProperty-symbol-prop.js (100%) rename {harness => test/sendable/harness}/verifyProperty-undefined-desc.js (100%) rename {harness => test/sendable/harness}/verifyProperty-value-error.js (100%) rename {harness => test/sendable/harness}/verifyProperty-value.js (100%) diff --git a/harness/verifyProperty-arguments.js b/test/sendable/harness/verifyProperty-arguments.js similarity index 100% rename from harness/verifyProperty-arguments.js rename to test/sendable/harness/verifyProperty-arguments.js diff --git a/harness/verifyProperty-configurable-object.js b/test/sendable/harness/verifyProperty-configurable-object.js similarity index 100% rename from harness/verifyProperty-configurable-object.js rename to test/sendable/harness/verifyProperty-configurable-object.js diff --git a/harness/verifyProperty-desc-is-not-object.js b/test/sendable/harness/verifyProperty-desc-is-not-object.js similarity index 100% rename from harness/verifyProperty-desc-is-not-object.js rename to test/sendable/harness/verifyProperty-desc-is-not-object.js diff --git a/harness/verifyProperty-noproperty.js b/test/sendable/harness/verifyProperty-noproperty.js similarity index 100% rename from harness/verifyProperty-noproperty.js rename to test/sendable/harness/verifyProperty-noproperty.js diff --git a/harness/verifyProperty-restore-accessor-symbol.js b/test/sendable/harness/verifyProperty-restore-accessor-symbol.js similarity index 100% rename from harness/verifyProperty-restore-accessor-symbol.js rename to test/sendable/harness/verifyProperty-restore-accessor-symbol.js diff --git a/harness/verifyProperty-restore-accessor.js b/test/sendable/harness/verifyProperty-restore-accessor.js similarity index 100% rename from harness/verifyProperty-restore-accessor.js rename to test/sendable/harness/verifyProperty-restore-accessor.js diff --git a/harness/verifyProperty-restore-symbol.js b/test/sendable/harness/verifyProperty-restore-symbol.js similarity index 100% rename from harness/verifyProperty-restore-symbol.js rename to test/sendable/harness/verifyProperty-restore-symbol.js diff --git a/harness/verifyProperty-restore.js b/test/sendable/harness/verifyProperty-restore.js similarity index 100% rename from harness/verifyProperty-restore.js rename to test/sendable/harness/verifyProperty-restore.js diff --git a/harness/verifyProperty-same-value.js b/test/sendable/harness/verifyProperty-same-value.js similarity index 100% rename from harness/verifyProperty-same-value.js rename to test/sendable/harness/verifyProperty-same-value.js diff --git a/harness/verifyProperty-string-prop.js b/test/sendable/harness/verifyProperty-string-prop.js similarity index 100% rename from harness/verifyProperty-string-prop.js rename to test/sendable/harness/verifyProperty-string-prop.js diff --git a/harness/verifyProperty-symbol-prop.js b/test/sendable/harness/verifyProperty-symbol-prop.js similarity index 100% rename from harness/verifyProperty-symbol-prop.js rename to test/sendable/harness/verifyProperty-symbol-prop.js diff --git a/harness/verifyProperty-undefined-desc.js b/test/sendable/harness/verifyProperty-undefined-desc.js similarity index 100% rename from harness/verifyProperty-undefined-desc.js rename to test/sendable/harness/verifyProperty-undefined-desc.js diff --git a/harness/verifyProperty-value-error.js b/test/sendable/harness/verifyProperty-value-error.js similarity index 100% rename from harness/verifyProperty-value-error.js rename to test/sendable/harness/verifyProperty-value-error.js diff --git a/harness/verifyProperty-value.js b/test/sendable/harness/verifyProperty-value.js similarity index 100% rename from harness/verifyProperty-value.js rename to test/sendable/harness/verifyProperty-value.js -- Gitee From 86fa5d4776276950f29b9f534bac845ed280c0e9 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 31 Dec 2024 09:50:18 +0800 Subject: [PATCH 58/93] add array-pop Signed-off-by: zhuzhihui7 --- .../Array/prototype/pop/S15.4.4.6_A1.1_T1.js | 39 ++++++ .../Array/prototype/pop/S15.4.4.6_A1.2_T1.js | 60 +++++++++ .../Array/prototype/pop/S15.4.4.6_A2_T1.js | 53 ++++++++ .../Array/prototype/pop/S15.4.4.6_A2_T2.js | 78 +++++++++++ .../Array/prototype/pop/S15.4.4.6_A2_T3.js | 42 ++++++ .../Array/prototype/pop/S15.4.4.6_A2_T4.js | 127 ++++++++++++++++++ .../Array/prototype/pop/S15.4.4.6_A3_T1.js | 38 ++++++ .../Array/prototype/pop/S15.4.4.6_A3_T2.js | 38 ++++++ .../Array/prototype/pop/S15.4.4.6_A3_T3.js | 34 +++++ .../Array/prototype/pop/S15.4.4.6_A4_T1.js | 52 +++++++ .../Array/prototype/pop/S15.4.4.6_A4_T2.js | 53 ++++++++ .../Array/prototype/pop/call-with-boolean.js | 21 +++ .../prototype/pop/clamps-to-integer-limit.js | 33 +++++ .../pop/length-near-integer-limit.js | 49 +++++++ .../builtins/Array/prototype/pop/length.js | 38 ++++++ .../builtins/Array/prototype/pop/name.js | 36 +++++ .../Array/prototype/pop/not-a-constructor.js | 34 +++++ .../builtins/Array/prototype/pop/prop-desc.js | 33 +++++ .../pop/set-length-array-is-frozen.js | 48 +++++++ ...set-length-array-length-is-non-writable.js | 33 +++++ .../pop/set-length-zero-array-is-frozen.js | 25 ++++ ...ength-zero-array-length-is-non-writable.js | 25 ++++ .../pop/throws-with-string-receiver.js | 26 ++++ 23 files changed, 1015 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A1.1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A1.2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T3.js create mode 100644 test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T4.js create mode 100644 test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A3_T1.js create mode 100644 test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A3_T2.js create mode 100644 test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A3_T3.js create mode 100644 test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A4_T1.js create mode 100644 test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A4_T2.js create mode 100644 test/sendable/builtins/Array/prototype/pop/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/pop/clamps-to-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/pop/length-near-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/pop/length.js create mode 100644 test/sendable/builtins/Array/prototype/pop/name.js create mode 100644 test/sendable/builtins/Array/prototype/pop/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/pop/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/pop/set-length-array-is-frozen.js create mode 100644 test/sendable/builtins/Array/prototype/pop/set-length-array-length-is-non-writable.js create mode 100644 test/sendable/builtins/Array/prototype/pop/set-length-zero-array-is-frozen.js create mode 100644 test/sendable/builtins/Array/prototype/pop/set-length-zero-array-length-is-non-writable.js create mode 100644 test/sendable/builtins/Array/prototype/pop/throws-with-string-receiver.js diff --git a/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A1.1_T1.js b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A1.1_T1.js new file mode 100644 index 00000000000..7fa56d2f3c5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A1.1_T1.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If length equal zero, call the [[Put]] method of this object + with arguments "length" and 0 and return undefined +esid: sec-array.prototype.pop +description: Checking this algorithm +---*/ + +var x = new SendableArray(); +var pop = x.pop(); +if (pop !== undefined) { + throw new Test262Error('#1: var x = new SendableArray(); x.pop() === undefined. Actual: ' + (pop)); +} +if (x.length !== 0) { + throw new Test262Error('#2: var x = new SendableArray(); x.pop(); x.length === 0. Actual: ' + (x.length)); +} +var x = SendableArray(1, 2, 3); +x.length = 0; +var pop = x.pop(); +if (pop !== undefined) { + throw new Test262Error('#2: var x = SendableArray(1,2,3); x.length = 0; x.pop() === undefined. Actual: ' + (pop)); +} +if (x.length !== 0) { + throw new Test262Error('#4: var x = new SendableArray(1,2,3); x.length = 0; x.pop(); x.length === 0. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A1.2_T1.js b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A1.2_T1.js new file mode 100644 index 00000000000..e0f669f3ba4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A1.2_T1.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The last element of the array is removed from the array + and returned +esid: sec-array.prototype.pop +description: Checking this use new Array() and [] +---*/ + +var x = new SendableArray(0, 1, 2, 3); +var pop = x.pop(); +if (pop !== 3) { + throw new Test262Error('#1: x = new SendableArray(0,1,2,3); x.pop() === 3. Actual: ' + (pop)); +} +if (x.length !== 3) { + throw new Test262Error('#2: x = new SendableArray(0,1,2,3); x.pop(); x.length == 3'); +} +if (x[3] !== undefined) { + throw new Test262Error('#3: x = new SendableArray(0,1,2,3); x.pop(); x[3] == undefined'); +} +if (x[2] !== 2) { + throw new Test262Error('#4: x = new SendableArray(0,1,2,3); x.pop(); x[2] == 2'); +} +x = []; +x[0] = 0; +x[3] = 3; +var pop = x.pop(); +if (pop !== 3) { + throw new Test262Error('#5: x = []; x[0] = 0; x[3] = 3; x.pop() === 3. Actual: ' + (pop)); +} +if (x.length !== 3) { + throw new Test262Error('#6: x = []; x[0] = 0; x[3] = 3; x.pop(); x.length == 3'); +} +if (x[3] !== undefined) { + throw new Test262Error('#7: x = []; x[0] = 0; x[3] = 3; x.pop(); x[3] == undefined'); +} +if (x[2] !== undefined) { + throw new Test262Error('#8: x = []; x[0] = 0; x[3] = 3; x.pop(); x[2] == undefined'); +} +x.length = 1; +var pop = x.pop(); +if (pop !== 0) { + throw new Test262Error('#9: x = []; x[0] = 0; x[3] = 3; x.pop(); x.length = 1; x.pop() === 0. Actual: ' + (pop)); +} +if (x.length !== 0) { + throw new Test262Error('#10: x = []; x[0] = 0; x[3] = 3; x.pop(); x.length = 1; x.pop(); x.length === 0. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T1.js b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T1.js new file mode 100644 index 00000000000..4b8d2d20e49 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T1.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The pop function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.pop +description: > + If ToUint32(length) equal zero, call the [[Put]] method of this + object with arguments "length" and 0 and return undefined +---*/ + +var obj = {}; +obj.pop = SendableArray.prototype.pop; +if (obj.length !== undefined) { + throw new Test262Error('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + var pop = obj.pop(); + if (pop !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.pop = SendableArray.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); + } + if (obj.length !== 0) { + throw new Test262Error('#2: var obj = {}; obj.pop = SendableArray.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); + } +} +obj.length = undefined; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#3: var obj = {}; obj.length = undefined; obj.pop = SendableArray.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} +if (obj.length !== 0) { + throw new Test262Error('#4: var obj = {}; obj.length = undefined; obj.pop = SendableArray.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} +obj.length = null +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.length = null; obj.pop = SendableArray.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} +if (obj.length !== 0) { + throw new Test262Error('#6: var obj = {}; obj.length = null; obj.pop = SendableArray.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} diff --git a/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T2.js b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T2.js new file mode 100644 index 00000000000..41a56f74a88 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T2.js @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The pop function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.pop +description: > + If ToUint32(length) equal zero, call the [[Put]] method of this + object with arguments "length" and 0 and return undefined +---*/ + +var obj = {}; +obj.pop = SendableArray.prototype.pop; +obj.length = NaN; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.length = NaN; obj.pop = SendableArray.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} +if (obj.length !== 0) { + throw new Test262Error('#2: var obj = {}; obj.length = NaN; obj.pop = SendableArray.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} +obj.length = Number.POSITIVE_INFINITY; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#3: var obj = {}; obj.length = Number.POSITIVE_INFINITY; obj.pop = SendableArray.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} +if (obj.length !== 9007199254740990) { + throw new Test262Error('#4: var obj = {}; obj.length = Number.POSITIVE_INFINITY; obj.pop = SendableArray.prototype.pop; obj.pop(); obj.length === 9007199254740990. Actual: ' + (obj.length)); +} +obj.length = Number.NEGATIVE_INFINITY; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.pop = SendableArray.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} +if (obj.length !== 0) { + throw new Test262Error('#6: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.pop = SendableArray.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} +obj.length = -0; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#7: var obj = {}; obj.length = -0; obj.pop = SendableArray.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} +if (obj.length !== 0) { + throw new Test262Error('#8: var obj = {}; obj.length = -0; obj.pop = SendableArray.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} else { + if (1 / obj.length !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#8: var obj = {}; obj.length = -0; obj.pop = SendableArray.prototype.pop; obj.pop(); obj.length === +0. Actual: ' + (obj.length)); + } +} +obj.length = 0.5; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#9: var obj = {}; obj.length = 0.5; obj.pop = SendableArray.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} +if (obj.length !== 0) { + throw new Test262Error('#10: var obj = {}; obj.length = 0.5; obj.pop = SendableArray.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} +obj.length = new Number(0); +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#11: var obj = {}; obj.length = new Number(0); obj.pop = SendableArray.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} +if (obj.length !== 0) { + throw new Test262Error('#12: var obj = {}; obj.length = new Number(0); obj.pop = SendableArray.prototype.pop; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} diff --git a/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T3.js b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T3.js new file mode 100644 index 00000000000..fbe7040468d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T3.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The pop function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.pop +description: > + The last element ToUint32(length) - 1 of the array is removed from + the array and returned +---*/ + +var obj = {}; +obj.pop = SendableArray.prototype.pop; +obj.length = 2.5; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.length = 2.5; obj.pop = SendableArray.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} +if (obj.length !== 1) { + throw new Test262Error('#2: var obj = {}; obj.length = 2.5; obj.pop = SendableArray.prototype.pop; obj.pop(); obj.length === 1. Actual: ' + (obj.length)); +} +obj.length = new Number(2); +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#11: var obj = {}; obj.length = new Number(2); obj.pop = SendableArray.prototype.pop; obj.pop() === undefined. Actual: ' + (pop)); +} +if (obj.length !== 1) { + throw new Test262Error('#12: var obj = {}; obj.length = new Number(2); obj.pop = SendableArray.prototype.pop; obj.pop(); obj.length === 1. Actual: ' + (obj.length)); +} diff --git a/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T4.js b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T4.js new file mode 100644 index 00000000000..e855ba3d09f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A2_T4.js @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The pop function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.pop +description: > + Operator use ToNumber from length. If Type(value) is Object, + evaluate ToPrimitive(value, Number) +---*/ + +var obj = {}; +obj.pop = SendableArray.prototype.pop; +obj[0] = -1; +obj.length = { + valueOf() { + return 1 + } +}; +var pop = obj.pop(); +assert.sameValue(pop, -1, 'The value of pop is expected to be -1'); +obj[0] = -1; +obj.length = { + valueOf() { + return 1 + }, + toString() { + return 0 + } +}; +var pop = obj.pop(); +assert.sameValue(pop, -1, 'The value of pop is expected to be -1'); +obj[0] = -1; +obj.length = { + valueOf() { + return 1 + }, + toString() { + return {} + } +}; +var pop = obj.pop(); +assert.sameValue(pop, -1, 'The value of pop is expected to be -1'); +try { + obj[0] = -1; + obj.length = { + valueOf() { + return 1 + }, + toString() { + throw "error" + } + }; + var pop = obj.pop(); + assert.sameValue(pop, -1, 'The value of pop is expected to be -1'); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} +obj[0] = -1; +obj.length = { + toString() { + return 0 + } +}; +var pop = obj.pop(); +assert.sameValue(pop, undefined, 'The value of pop is expected to equal undefined'); +obj[0] = -1; +obj.length = { + valueOf() { + return {} + }, + toString() { + return 0 + } +} +var pop = obj.pop(); +assert.sameValue(pop, undefined, 'The value of pop is expected to equal undefined'); +try { + obj[0] = -1; + obj.length = { + valueOf() { + throw "error" + }, + toString() { + return 0 + } + }; + var pop = obj.pop(); + throw new Test262Error('#7.1: obj[0] = -1; obj.length = {valueOf() {throw "error"}, toString() {return 0}}; obj.pop() throw "error". Actual: ' + (pop)); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} +try { + obj[0] = -1; + obj.length = { + valueOf() { + return {} + }, + toString() { + return {} + } + }; + var pop = obj.pop(); + throw new Test262Error('#8.1: obj[0] = -1; obj.length = {valueOf() {return {}}, toString() {return {}}} obj.pop() throw TypeError. Actual: ' + (pop)); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A3_T1.js b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A3_T1.js new file mode 100644 index 00000000000..98228ad51ac --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A3_T1.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.pop +description: length = 4294967296 +---*/ + +var obj = {}; +obj.pop = SendableArray.prototype.pop; +obj[0] = "x"; +obj[4294967295] = "y"; +obj.length = 4294967296; +var pop = obj.pop(); +if (pop !== "y") { + throw new Test262Error('#1: var obj = {}; obj.pop = SendableArray.prototype.pop; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; obj.pop() === "y". Actual: ' + (pop)); +} +if (obj.length !== 4294967295) { + throw new Test262Error('#2: var obj = {}; obj.pop = SendableArray.prototype.pop; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; obj.pop(); obj.length === 4294967295. Actual: ' + (obj.length)); +} +if (obj[0] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.pop = SendableArray.prototype.pop; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; obj.pop(); obj[0] === "x". Actual: ' + (obj[0])); +} +if (obj[4294967295] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.pop = SendableArray.prototype.pop; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; obj.pop(); obj[4294967295] === undefined. Actual: ' + (obj[4294967295])); +} diff --git a/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A3_T2.js b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A3_T2.js new file mode 100644 index 00000000000..d5aa3208805 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A3_T2.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.pop +description: length = 4294967297 +---*/ + +var obj = {}; +obj.pop = SendableArray.prototype.pop; +obj[0] = "x"; +obj[4294967296] = "y"; +obj.length = 4294967297; +var pop = obj.pop(); +if (pop !== "y") { + throw new Test262Error('#1: var obj = {}; obj.pop = SendableArray.prototype.pop; obj[0] = "x"; obj[4294967296] = "y"; obj.length = 4294967297; obj.pop() === "y". Actual: ' + (pop)); +} +if (obj.length !== 4294967296) { + throw new Test262Error('#2: var obj = {}; obj.pop = SendableArray.prototype.pop; obj[0] = "x"; obj[4294967296] = "y"; obj.length = 4294967297; obj.pop(); obj.length === 4294967296. Actual: ' + (obj.length)); +} +if (obj[0] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.pop = SendableArray.prototype.pop; obj[0] = "x"; obj[4294967296] = "y"; obj.length = 4294967297; obj.pop(); obj[0] === "x". Actual: ' + (obj[0])); +} +if (obj[4294967296] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.pop = SendableArray.prototype.pop; obj[0] = "x"; obj[4294967296] = "y"; obj.length = 4294967297; obj.pop(); obj[4294967296] === undefined. Actual: ' + (obj[4294967296])); +} diff --git a/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A3_T3.js b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A3_T3.js new file mode 100644 index 00000000000..e69dce538a1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A3_T3.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.pop +description: length = -1 +---*/ + +var obj = {}; +obj.pop = SendableArray.prototype.pop; +obj[4294967294] = "x"; +obj.length = -1; +var pop = obj.pop(); +if (pop !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.pop = SendableArray.prototype.pop; obj[4294967294] = "x"; obj.length = -1; obj.pop() === undefined. Actual: ' + (pop)); +} +if (obj.length !== 0) { + throw new Test262Error('#2: var obj = {}; obj.pop = SendableArray.prototype.pop; obj[4294967294] = "x"; obj.length = -1; obj.pop(); obj.length === 0. Actual: ' + (obj.length)); +} +if (obj[4294967294] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.pop = SendableArray.prototype.pop; obj[4294967294] = "x"; obj.length = -1; obj.pop(); obj[4294967294] === "x". Actual: ' + (obj[4294967294])); +} diff --git a/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A4_T1.js b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A4_T1.js new file mode 100644 index 00000000000..6d467b7f79e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A4_T1.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.pop +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +SendableArray.prototype[1] = 1; +var x = [0]; +x.length = 2; +var pop = x.pop(); +if (pop !== 1) { + throw new Test262Error('#1: SendableArray.prototype[1] = 1; x = [0]; x.length = 2; x.pop() === 1. Actual: ' + (pop)); +} +if (x[1] !== 1) { + throw new Test262Error('#2: SendableArray.prototype[1] = 1; x = [0]; x.length = 2; x.pop(); x[1] === 1. Actual: ' + (x[1])); +} +Object.prototype[1] = 1; +Object.prototype.length = 2; +Object.prototype.pop = SendableArray.prototype.pop; +x = { + 0: 0 +}; +var pop = x.pop(); +if (pop !== 1) { + throw new Test262Error('#3: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.pop = SendableArray.prototype.pop; x = {0:0}; x.pop() === 1. Actual: ' + (pop)); +} +if (x[1] !== 1) { + throw new Test262Error('#4: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.pop = SendableArray.prototype.pop; x = {0:0}; x.pop(); x[1] === 1. Actual: ' + (x[1])); +} +if (x.length !== 1) { + throw new Test262Error('#6: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.pop = SendableArray.prototype.pop; x = {0:0}; x.pop(); x.length === 1. Actual: ' + (x.length)); +} +delete x.length; +if (x.length !== 2) { + throw new Test262Error('#7: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.pop = SendableArray.prototype.pop; x = {0:0}; x.pop(); delete x; x.length === 2. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A4_T2.js b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A4_T2.js new file mode 100644 index 00000000000..9065d83e3a8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/S15.4.4.6_A4_T2.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.pop +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +SendableArray.prototype[1] = -1; +var x = [0, 1]; +x.length = 2; +var pop = x.pop(); +if (pop !== 1) { + throw new Test262Error('#1: SendableArray.prototype[1] = -1; x = [0,1]; x.length = 2; x.pop() === 1. Actual: ' + (pop)); +} +if (x[1] !== -1) { + throw new Test262Error('#2: SendableArray.prototype[1] = -1; x = [0,1]; x.length = 2; x.pop(); x[1] === -1. Actual: ' + (x[1])); +} +Object.prototype[1] = -1; +Object.prototype.length = 2; +Object.prototype.pop = SendableArray.prototype.pop; +x = { + 0: 0, + 1: 1 +}; +var pop = x.pop(); +if (pop !== 1) { + throw new Test262Error('#3: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.pop = SendableArray.prototype.pop; x = {0:0,1:1}; x.pop() === 1. Actual: ' + (pop)); +} +if (x[1] !== -1) { + throw new Test262Error('#4: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.pop = SendableArray.prototype.pop; x = {0:0,1:1}; x.pop(); x[1] === -1. Actual: ' + (x[1])); +} +if (x.length !== 1) { + throw new Test262Error('#6: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.pop = SendableArray.prototype.pop; x = {0:0,1:1}; x.pop(); x.length === 1. Actual: ' + (x.length)); +} +delete x.length; +if (x.length !== 2) { + throw new Test262Error('#7: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.pop = SendableArray.prototype.pop; x = {0:0,1:1}; x.pop(); delete x; x.length === 2. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/pop/call-with-boolean.js b/test/sendable/builtins/Array/prototype/pop/call-with-boolean.js new file mode 100644 index 00000000000..2df83544f64 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/call-with-boolean.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.pop +description: Array.prototype.pop applied to boolean primitive +---*/ + +assert.sameValue(SendableArray.prototype.pop.call(true), undefined, 'SendableArray.prototype.pop.call(true) must return undefined'); +assert.sameValue(SendableArray.prototype.pop.call(false), undefined, 'SendableArray.prototype.pop.call(false) must return undefined'); diff --git a/test/sendable/builtins/Array/prototype/pop/clamps-to-integer-limit.js b/test/sendable/builtins/Array/prototype/pop/clamps-to-integer-limit.js new file mode 100644 index 00000000000..4e4cfb784c2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/clamps-to-integer-limit.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.pop +description: > + Length values exceeding 2^53-1 are clamped to 2^53-1. +---*/ + +var arrayLike = {}; +arrayLike.length = 2 ** 53 - 1; +SendableArray.prototype.pop.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 2, "Length is 2**53 - 1"); +arrayLike.length = 2 ** 53; +SendableArray.prototype.pop.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 2, "Length is 2**53"); +arrayLike.length = 2 ** 53 + 2; +SendableArray.prototype.pop.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 2, "Length is 2**53 + 2"); +arrayLike.length = Infinity; +SendableArray.prototype.pop.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 2, "Length is Infinity"); diff --git a/test/sendable/builtins/Array/prototype/pop/length-near-integer-limit.js b/test/sendable/builtins/Array/prototype/pop/length-near-integer-limit.js new file mode 100644 index 00000000000..66c3958fc1a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/length-near-integer-limit.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.pop +description: > + A value is removed from an array-like object whose length property is near the integer limit. +info: | + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... + 4. Else len > 0, + a. Let newLen be len-1. + b. Let index be ! ToString(newLen). + c. Let element be ? Get(O, index). + d. Perform ? DeletePropertyOrThrow(O, index). + e. Perform ? Set(O, "length", newLen, true). + f. Return element. +features: [exponentiation] +---*/ + +var arrayLike = { + "9007199254740989": "9007199254740989", + "9007199254740990": "9007199254740990", + "9007199254740991": "9007199254740991", + length: 2 ** 53 - 1 +}; +var value = SendableArray.prototype.pop.call(arrayLike); +assert.sameValue(value, "9007199254740990", + "arrayLike['9007199254740990'] is returned from pop()"); +assert.sameValue(arrayLike.length, 2 ** 53 - 2, + "New arrayLike.length is 2**53 - 2"); +assert.sameValue(arrayLike["9007199254740989"], "9007199254740989", + "arrayLike['9007199254740989'] is unchanged"); +assert.sameValue("9007199254740990" in arrayLike, false, + "arrayLike['9007199254740990'] is removed"); +assert.sameValue(arrayLike["9007199254740991"], "9007199254740991", + "arrayLike['9007199254740991'] is unchanged"); diff --git a/test/sendable/builtins/Array/prototype/pop/length.js b/test/sendable/builtins/Array/prototype/pop/length.js new file mode 100644 index 00000000000..7d778106d4f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/length.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.pop +description: > + The "length" property of Array.prototype.pop +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.pop, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/pop/name.js b/test/sendable/builtins/Array/prototype/pop/name.js new file mode 100644 index 00000000000..9687fe70793 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.pop +description: > + Array.prototype.pop.name is "pop". +info: | + Array.prototype.pop ( ) + 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(SendableArray.prototype.pop, "name", { + value: "pop", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/pop/not-a-constructor.js b/test/sendable/builtins/Array/prototype/pop/not-a-constructor.js new file mode 100644 index 00000000000..b2a020af332 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/not-a-constructor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.pop 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(SendableArray.prototype.pop), false, 'isConstructor(SendableArray.prototype.pop) must return false'); +assert.throws(TypeError, () => { + new SendableArray.prototype.pop(); +}); + diff --git a/test/sendable/builtins/Array/prototype/pop/prop-desc.js b/test/sendable/builtins/Array/prototype/pop/prop-desc.js new file mode 100644 index 00000000000..651e58f9c5e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/prop-desc.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.pop +description: > + "pop" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.pop, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "pop", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/pop/set-length-array-is-frozen.js b/test/sendable/builtins/Array/prototype/pop/set-length-array-is-frozen.js new file mode 100644 index 00000000000..8a4c3b88a8a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/set-length-array-is-frozen.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.pop +description: > + A TypeError is thrown when "length" is [[Set]] on a frozen array. +info: | + Array.prototype.pop ( ) + 4. Else, + a. Assert: len > 0. + b. Let newLen be 𝔽(len - 1). + c. Let index be ! ToString(newLen). + d. Let element be ? Get(O, index). + e. Perform ? DeletePropertyOrThrow(O, index). + f. Perform ? Set(O, "length", newLen, true). + OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) + 2. If IsDataDescriptor(ownDesc) is true, then + a. If ownDesc.[[Writable]] is false, return false. + Set ( O, P, V, Throw ) + 1. Let success be ? O.[[Set]](P, V, O). + 2. If success is false and Throw is true, throw a TypeError exception. +---*/ + +var SendableArray = new SendableArray(1); +var arrayPrototypeGet0Calls = 0; +Object.defineProperty(SendableArray.prototype, "0", { + get() { + Object.freeze(SendableArray); + arrayPrototypeGet0Calls++; + }, +}); +assert.throws(TypeError, function() { + SendableArray.pop(); +}); +assert.sameValue(SendableArray.length, 1); +assert.sameValue(arrayPrototypeGet0Calls, 1); diff --git a/test/sendable/builtins/Array/prototype/pop/set-length-array-length-is-non-writable.js b/test/sendable/builtins/Array/prototype/pop/set-length-array-length-is-non-writable.js new file mode 100644 index 00000000000..447a8c44573 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/set-length-array-length-is-non-writable.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.pop +description: > + A TypeError is thrown when "length" is [[Set]] on an array with non-writable "length". +---*/ + +var SendableArray = new SendableArray(1); +var arrayPrototypeGet0Calls = 0; +Object.defineProperty(SendableArray.prototype, "0", { + get() { + Object.defineProperty(SendableArray, "length", { writable: false }); + arrayPrototypeGet0Calls++; + }, +}); +assert.throws(TypeError, function() { + SendableArray.pop(); +}); +assert.sameValue(SendableArray.length, 1); +assert.sameValue(arrayPrototypeGet0Calls, 1); diff --git a/test/sendable/builtins/Array/prototype/pop/set-length-zero-array-is-frozen.js b/test/sendable/builtins/Array/prototype/pop/set-length-zero-array-is-frozen.js new file mode 100644 index 00000000000..640513fea97 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/set-length-zero-array-is-frozen.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.pop +description: > + A TypeError is thrown when "length" is [[Set]] on an empty frozen array. +---*/ + +var SendableArray = []; +Object.freeze(SendableArray); +assert.throws(TypeError, function() { + SendableArray.pop(); +}); diff --git a/test/sendable/builtins/Array/prototype/pop/set-length-zero-array-length-is-non-writable.js b/test/sendable/builtins/Array/prototype/pop/set-length-zero-array-length-is-non-writable.js new file mode 100644 index 00000000000..ce07d1d4419 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/set-length-zero-array-length-is-non-writable.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.pop +description: > + A TypeError is thrown when "length" is [[Set]] on an empty array with non-writable "length". +---*/ + +var SendableArray = []; +Object.defineProperty(SendableArray, "length", { writable: false }); +assert.throws(TypeError, function() { + SendableArray.pop(); +}); diff --git a/test/sendable/builtins/Array/prototype/pop/throws-with-string-receiver.js b/test/sendable/builtins/Array/prototype/pop/throws-with-string-receiver.js new file mode 100644 index 00000000000..b426e5cb693 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/pop/throws-with-string-receiver.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.pop +description: > + Array#pop throws TypeError upon attempting to modify a string +---*/ + +assert.throws(TypeError, () => { + SendableArray.prototype.pop.call(''); +}, "SendableArray.prototype.pop.call('')"); +assert.throws(TypeError, () => { + SendableArray.prototype.pop.call('abc'); +}, "SendableArray.prototype.pop.call('abc')"); -- Gitee From 353407ebf06976556dff025123c7478bacd38b81 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 31 Dec 2024 10:14:47 +0800 Subject: [PATCH 59/93] test/sendable/builtins/Array/prototype/pop/ update case Signed-off-by: zhuzhihui7 --- .../prototype/pop/clamps-to-integer-limit.js | 1 + .../pop/length-near-integer-limit.js | 11 --------- .../builtins/Array/prototype/pop/prop-desc.js | 3 +-- .../pop/set-length-array-is-frozen.js | 23 ++++--------------- ...set-length-array-length-is-non-writable.js | 8 +++---- .../pop/set-length-zero-array-is-frozen.js | 6 ++--- ...ength-zero-array-length-is-non-writable.js | 6 ++--- 7 files changed, 16 insertions(+), 42 deletions(-) diff --git a/test/sendable/builtins/Array/prototype/pop/clamps-to-integer-limit.js b/test/sendable/builtins/Array/prototype/pop/clamps-to-integer-limit.js index 4e4cfb784c2..43c1ea25697 100644 --- a/test/sendable/builtins/Array/prototype/pop/clamps-to-integer-limit.js +++ b/test/sendable/builtins/Array/prototype/pop/clamps-to-integer-limit.js @@ -16,6 +16,7 @@ esid: sec-array.prototype.pop description: > Length values exceeding 2^53-1 are clamped to 2^53-1. +features: [exponentiation] ---*/ var arrayLike = {}; diff --git a/test/sendable/builtins/Array/prototype/pop/length-near-integer-limit.js b/test/sendable/builtins/Array/prototype/pop/length-near-integer-limit.js index 66c3958fc1a..fffa0235bc2 100644 --- a/test/sendable/builtins/Array/prototype/pop/length-near-integer-limit.js +++ b/test/sendable/builtins/Array/prototype/pop/length-near-integer-limit.js @@ -16,17 +16,6 @@ esid: sec-array.prototype.pop description: > A value is removed from an array-like object whose length property is near the integer limit. -info: | - ... - 2. Let len be ? ToLength(? Get(O, "length")). - ... - 4. Else len > 0, - a. Let newLen be len-1. - b. Let index be ! ToString(newLen). - c. Let element be ? Get(O, index). - d. Perform ? DeletePropertyOrThrow(O, index). - e. Perform ? Set(O, "length", newLen, true). - f. Return element. features: [exponentiation] ---*/ diff --git a/test/sendable/builtins/Array/prototype/pop/prop-desc.js b/test/sendable/builtins/Array/prototype/pop/prop-desc.js index 651e58f9c5e..6cd0bddc1a3 100644 --- a/test/sendable/builtins/Array/prototype/pop/prop-desc.js +++ b/test/sendable/builtins/Array/prototype/pop/prop-desc.js @@ -18,8 +18,7 @@ description: > "pop" property of Array.prototype info: | 17 ECMAScript Standard Built-in Objects - - Every other data property described in clauses 18 through 26 and in Annex B.2 + 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] diff --git a/test/sendable/builtins/Array/prototype/pop/set-length-array-is-frozen.js b/test/sendable/builtins/Array/prototype/pop/set-length-array-is-frozen.js index 8a4c3b88a8a..93fe86b4b43 100644 --- a/test/sendable/builtins/Array/prototype/pop/set-length-array-is-frozen.js +++ b/test/sendable/builtins/Array/prototype/pop/set-length-array-is-frozen.js @@ -16,33 +16,18 @@ esid: sec-array.prototype.pop description: > A TypeError is thrown when "length" is [[Set]] on a frozen array. -info: | - Array.prototype.pop ( ) - 4. Else, - a. Assert: len > 0. - b. Let newLen be 𝔽(len - 1). - c. Let index be ! ToString(newLen). - d. Let element be ? Get(O, index). - e. Perform ? DeletePropertyOrThrow(O, index). - f. Perform ? Set(O, "length", newLen, true). - OrdinarySetWithOwnDescriptor ( O, P, V, Receiver, ownDesc ) - 2. If IsDataDescriptor(ownDesc) is true, then - a. If ownDesc.[[Writable]] is false, return false. - Set ( O, P, V, Throw ) - 1. Let success be ? O.[[Set]](P, V, O). - 2. If success is false and Throw is true, throw a TypeError exception. ---*/ -var SendableArray = new SendableArray(1); +var array = new SendableArray(1); var arrayPrototypeGet0Calls = 0; Object.defineProperty(SendableArray.prototype, "0", { get() { - Object.freeze(SendableArray); + Object.freeze(array); arrayPrototypeGet0Calls++; }, }); assert.throws(TypeError, function() { - SendableArray.pop(); + array.pop(); }); -assert.sameValue(SendableArray.length, 1); +assert.sameValue(array.length, 1); assert.sameValue(arrayPrototypeGet0Calls, 1); diff --git a/test/sendable/builtins/Array/prototype/pop/set-length-array-length-is-non-writable.js b/test/sendable/builtins/Array/prototype/pop/set-length-array-length-is-non-writable.js index 447a8c44573..af856dfde6f 100644 --- a/test/sendable/builtins/Array/prototype/pop/set-length-array-length-is-non-writable.js +++ b/test/sendable/builtins/Array/prototype/pop/set-length-array-length-is-non-writable.js @@ -18,16 +18,16 @@ description: > A TypeError is thrown when "length" is [[Set]] on an array with non-writable "length". ---*/ -var SendableArray = new SendableArray(1); +var array = new SendableArray(1); var arrayPrototypeGet0Calls = 0; Object.defineProperty(SendableArray.prototype, "0", { get() { - Object.defineProperty(SendableArray, "length", { writable: false }); + Object.defineProperty(array, "length", { writable: false }); arrayPrototypeGet0Calls++; }, }); assert.throws(TypeError, function() { - SendableArray.pop(); + array.pop(); }); -assert.sameValue(SendableArray.length, 1); +assert.sameValue(array.length, 1); assert.sameValue(arrayPrototypeGet0Calls, 1); diff --git a/test/sendable/builtins/Array/prototype/pop/set-length-zero-array-is-frozen.js b/test/sendable/builtins/Array/prototype/pop/set-length-zero-array-is-frozen.js index 640513fea97..266ba03b8f9 100644 --- a/test/sendable/builtins/Array/prototype/pop/set-length-zero-array-is-frozen.js +++ b/test/sendable/builtins/Array/prototype/pop/set-length-zero-array-is-frozen.js @@ -18,8 +18,8 @@ description: > A TypeError is thrown when "length" is [[Set]] on an empty frozen array. ---*/ -var SendableArray = []; -Object.freeze(SendableArray); +var array = []; +Object.freeze(array); assert.throws(TypeError, function() { - SendableArray.pop(); + array.pop(); }); diff --git a/test/sendable/builtins/Array/prototype/pop/set-length-zero-array-length-is-non-writable.js b/test/sendable/builtins/Array/prototype/pop/set-length-zero-array-length-is-non-writable.js index ce07d1d4419..7e403eadef3 100644 --- a/test/sendable/builtins/Array/prototype/pop/set-length-zero-array-length-is-non-writable.js +++ b/test/sendable/builtins/Array/prototype/pop/set-length-zero-array-length-is-non-writable.js @@ -18,8 +18,8 @@ description: > A TypeError is thrown when "length" is [[Set]] on an empty array with non-writable "length". ---*/ -var SendableArray = []; -Object.defineProperty(SendableArray, "length", { writable: false }); +var array = []; +Object.defineProperty(array, "length", { writable: false }); assert.throws(TypeError, function() { - SendableArray.pop(); + array.pop(); }); -- Gitee From d07b135281a79d9e521f9b88101cc4b104d843be Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 31 Dec 2024 10:58:07 +0800 Subject: [PATCH 60/93] add array-push Signed-off-by: zhuzhihui7 --- .../Array/prototype/push/S15.4.4.7_A1_T1.js | 48 +++++++ .../Array/prototype/push/S15.4.4.7_A1_T2.js | 53 ++++++++ .../Array/prototype/push/S15.4.4.7_A2_T1.js | 63 ++++++++++ .../Array/prototype/push/S15.4.4.7_A2_T2.js | 92 ++++++++++++++ .../Array/prototype/push/S15.4.4.7_A2_T3.js | 119 ++++++++++++++++++ .../Array/prototype/push/S15.4.4.7_A3.js | 36 ++++++ .../Array/prototype/push/S15.4.4.7_A4_T1.js | 58 +++++++++ .../Array/prototype/push/S15.4.4.7_A4_T2.js | 39 ++++++ .../Array/prototype/push/S15.4.4.7_A4_T3.js | 48 +++++++ .../Array/prototype/push/S15.4.4.7_A5_T1.js | 46 +++++++ .../Array/prototype/push/call-with-boolean.js | 21 ++++ .../prototype/push/clamps-to-integer-limit.js | 41 ++++++ .../length-near-integer-limit-set-failure.js | 36 ++++++ .../push/length-near-integer-limit.js | 35 ++++++ .../builtins/Array/prototype/push/length.js | 40 ++++++ .../builtins/Array/prototype/push/name.js | 36 ++++++ .../Array/prototype/push/not-a-constructor.js | 34 +++++ .../Array/prototype/push/prop-desc.js | 32 +++++ .../push/set-length-array-is-frozen.js | 34 +++++ ...set-length-array-length-is-non-writable.js | 34 +++++ .../push/set-length-zero-array-is-frozen.js | 27 ++++ ...ength-zero-array-length-is-non-writable.js | 27 ++++ .../push/throws-if-integer-limit-exceeded.js | 37 ++++++ .../push/throws-with-string-receiver.js | 32 +++++ 24 files changed, 1068 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/push/S15.4.4.7_A1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/push/S15.4.4.7_A1_T2.js create mode 100644 test/sendable/builtins/Array/prototype/push/S15.4.4.7_A2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/push/S15.4.4.7_A2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/push/S15.4.4.7_A2_T3.js create mode 100644 test/sendable/builtins/Array/prototype/push/S15.4.4.7_A3.js create mode 100644 test/sendable/builtins/Array/prototype/push/S15.4.4.7_A4_T1.js create mode 100644 test/sendable/builtins/Array/prototype/push/S15.4.4.7_A4_T2.js create mode 100644 test/sendable/builtins/Array/prototype/push/S15.4.4.7_A4_T3.js create mode 100644 test/sendable/builtins/Array/prototype/push/S15.4.4.7_A5_T1.js create mode 100644 test/sendable/builtins/Array/prototype/push/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/push/clamps-to-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/push/length-near-integer-limit-set-failure.js create mode 100644 test/sendable/builtins/Array/prototype/push/length-near-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/push/length.js create mode 100644 test/sendable/builtins/Array/prototype/push/name.js create mode 100644 test/sendable/builtins/Array/prototype/push/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/push/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/push/set-length-array-is-frozen.js create mode 100644 test/sendable/builtins/Array/prototype/push/set-length-array-length-is-non-writable.js create mode 100644 test/sendable/builtins/Array/prototype/push/set-length-zero-array-is-frozen.js create mode 100644 test/sendable/builtins/Array/prototype/push/set-length-zero-array-length-is-non-writable.js create mode 100644 test/sendable/builtins/Array/prototype/push/throws-if-integer-limit-exceeded.js create mode 100644 test/sendable/builtins/Array/prototype/push/throws-with-string-receiver.js diff --git a/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A1_T1.js b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A1_T1.js new file mode 100644 index 00000000000..b12a2282bb1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A1_T1.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The arguments are appended to the end of the array, in + the order in which they appear. The new length of the array is returned + as the result of the call +esid: sec-array.prototype.push +description: Checking case when push is given no arguments or one argument +---*/ + +var x = new SendableArray(); +var push = x.push(1); +if (push !== 1) { + throw new Test262Error('#1: x = new SendableArray(); x.push(1) === 1. Actual: ' + (push)); +} +if (x[0] !== 1) { + throw new Test262Error('#2: x = new SendableArray(); x.push(1); x[0] === 1. Actual: ' + (x[0])); +} +var push = x.push(); +if (push !== 1) { + throw new Test262Error('#3: x = new SendableArray(); x.push(1); x.push() === 1. Actual: ' + (push)); +} +if (x[1] !== undefined) { + throw new Test262Error('#4: x = new SendableArray(); x.push(1); x.push(); x[1] === unedfined. Actual: ' + (x[1])); +} +var push = x.push(-1); +if (push !== 2) { + throw new Test262Error('#5: x = new SendableArray(); x.push(1); x.push(); x.push(-1) === 2. Actual: ' + (push)); +} +if (x[1] !== -1) { + throw new Test262Error('#6: x = new SendableArray(); x.push(1); x.push(-1); x[1] === -1. Actual: ' + (x[1])); +} +if (x.length !== 2) { + throw new Test262Error('#7: x = new SendableArray(); x.push(1); x.push(); x.push(-1); x.length === 2. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A1_T2.js b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A1_T2.js new file mode 100644 index 00000000000..934cd9908d4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A1_T2.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The arguments are appended to the end of the array, in + the order in which they appear. The new length of the array is returned + as the result of the call +esid: sec-array.prototype.push +description: Checking case when push is given many arguments +---*/ + +var x = []; +if (x.length !== 0) { + throw new Test262Error('#1: x = []; x.length === 0. Actual: ' + (x.length)); +} +x[0] = 0; +var push = x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); +if (push !== 6) { + throw new Test262Error('#2: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1) === 6. Actual: ' + (push)); +} +if (x[0] !== 0) { + throw new Test262Error('#3: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== true) { + throw new Test262Error('#4: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[1] === true. Actual: ' + (x[1])); +} +if (x[2] !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#5: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[2] === Number.POSITIVE_INFINITY. Actual: ' + (x[2])); +} +if (x[3] !== "NaN") { + throw new Test262Error('#6: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[3] === "NaN". Actual: ' + (x[3])); +} +if (x[4] !== "1") { + throw new Test262Error('#7: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[4] === "1". Actual: ' + (x[4])); +} +if (x[5] !== -1) { + throw new Test262Error('#8: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[5] === -1. Actual: ' + (x[5])); +} +if (x.length !== 6) { + throw new Test262Error('#9: x = []; x[0] = 0; x.push(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x.length === 6. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A2_T1.js b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A2_T1.js new file mode 100644 index 00000000000..f5df7fab862 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A2_T1.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The push function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.push +description: > + The arguments are appended to the end of the array, in the order + in which they appear. The new length of the array is returned as + the result of the call +---*/ + +var obj = {}; +obj.push = SendableArray.prototype.push; +if (obj.length !== undefined) { + throw new Test262Error('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + var push = obj.push(-1); + if (push !== 1) { + throw new Test262Error('#1: var obj = {}; obj.push = SendableArray.prototype.push; obj.push(-1) === 1. Actual: ' + (push)); + } + if (obj.length !== 1) { + throw new Test262Error('#2: var obj = {}; obj.push = SendableArray.prototype.push; obj.push(-1); obj.length === 1. Actual: ' + (obj.length)); + } + if (obj["0"] !== -1) { + throw new Test262Error('#3: var obj = {}; obj.push = SendableArray.prototype.push; obj.push(-1); obj["0"] === -1. Actual: ' + (obj["0"])); + } +} +obj.length = undefined; +var push = obj.push(-4); +if (push !== 1) { + throw new Test262Error('#4: var obj = {}; obj.length = undefined; obj.push = SendableArray.prototype.push; obj.push(-4) === 1. Actual: ' + (push)); +} +if (obj.length !== 1) { + throw new Test262Error('#5: var obj = {}; obj.length = undefined; obj.push = SendableArray.prototype.push; obj.push(-4); obj.length === 1. Actual: ' + (obj.length)); +} +if (obj["0"] !== -4) { + throw new Test262Error('#6: var obj = {}; obj.length = undefined; obj.push = SendableArray.prototype.push; obj.push(-4); obj["0"] === -4. Actual: ' + (obj["0"])); +} +obj.length = null +var push = obj.push(-7); +if (push !== 1) { + throw new Test262Error('#7: var obj = {}; obj.length = null; obj.push = SendableArray.prototype.push; obj.push(-7) === 1. Actual: ' + (push)); +} +if (obj.length !== 1) { + throw new Test262Error('#8: var obj = {}; obj.length = null; obj.push = SendableArray.prototype.push; obj.push(-7); obj.length === 1. Actual: ' + (obj.length)); +} +if (obj["0"] !== -7) { + throw new Test262Error('#9: var obj = {}; obj.length = null; obj.push = SendableArray.prototype.push; obj.push(-7); obj["0"] === -7. Actual: ' + (obj["0"])); +} diff --git a/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A2_T2.js b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A2_T2.js new file mode 100644 index 00000000000..eed2edccc5d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A2_T2.js @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The push function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.push +description: > + The arguments are appended to the end of the array, in the order + in which they appear. The new length of the array is returned as + the result of the call +---*/ + +var obj = {}; +obj.push = SendableArray.prototype.push; +obj.length = NaN; +var push = obj.push(-1); +if (push !== 1) { + throw new Test262Error('#1: var obj = {}; obj.length = NaN; obj.push = SendableArray.prototype.push; obj.push(-1) === 1. Actual: ' + (push)); +} +if (obj.length !== 1) { + throw new Test262Error('#2: var obj = {}; obj.length = NaN; obj.push = SendableArray.prototype.push; obj.push(-1); obj.length === 1. Actual: ' + (obj.length)); +} +if (obj["0"] !== -1) { + throw new Test262Error('#3: var obj = {}; obj.length = NaN; obj.push = SendableArray.prototype.push; obj.push(-1); obj["0"] === -1. Actual: ' + (obj["0"])); +} +obj.length = Number.POSITIVE_INFINITY; +assert.throws(TypeError, function() { + obj.push(-4); +}); +if (obj.length !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#6: var obj = {}; obj.length = Number.POSITIVE_INFINITY; obj.push = SendableArray.prototype.push; obj.push(-4); obj.length === Number.POSITIVE_INFINITY. Actual: ' + (obj.length)); +} +if (obj[9007199254740991] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.length = Number.POSITIVE_INFINITY; obj.push = SendableArray.prototype.push; obj.push(-4); obj[9007199254740991] === undefined. Actual: ' + (obj["9007199254740991"])); +} +obj.length = Number.NEGATIVE_INFINITY; +var push = obj.push(-7); +if (push !== 1) { + throw new Test262Error('#7: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.push = SendableArray.prototype.push; obj.push(-7) === 1. Actual: ' + (push)); +} +if (obj.length !== 1) { + throw new Test262Error('#8: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.push = SendableArray.prototype.push; obj.push(-7); obj.length === 1. Actual: ' + (obj.length)); +} +if (obj["0"] !== -7) { + throw new Test262Error('#9: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.push = SendableArray.prototype.push; obj.push(-7); obj["0"] === -7. Actual: ' + (obj["0"])); +} +obj.length = 0.5; +var push = obj.push(-10); +if (push !== 1) { + throw new Test262Error('#10: var obj = {}; obj.length = 0.5; obj.push = SendableArray.prototype.push; obj.push(-10) === 1. Actual: ' + (push)); +} +if (obj.length !== 1) { + throw new Test262Error('#11: var obj = {}; obj.length = 0.5; obj.push = SendableArray.prototype.push; obj.push(-10); obj.length === 1. Actual: ' + (obj.length)); +} +if (obj["0"] !== -10) { + throw new Test262Error('#12: var obj = {}; obj.length = 0.5; obj.push = SendableArray.prototype.push; obj.push(-10); obj["0"] === -10. Actual: ' + (obj["0"])); +} +obj.length = 1.5; +var push = obj.push(-13); +if (push !== 2) { + throw new Test262Error('#13: var obj = {}; obj.length = 1.5; obj.push = SendableArray.prototype.push; obj.push(-13) === 2. Actual: ' + (push)); +} +if (obj.length !== 2) { + throw new Test262Error('#14: var obj = {}; obj.length = 1.5; obj.push = SendableArray.prototype.push; obj.push(-13); obj.length === 2. Actual: ' + (obj.length)); +} +if (obj["1"] !== -13) { + throw new Test262Error('#15: var obj = {}; obj.length = 1.5; obj.push = SendableArray.prototype.push; obj.push(-13); obj["1"] === -13. Actual: ' + (obj["1"])); +} +obj.length = new Number(0); +var push = obj.push(-16); +if (push !== 1) { + throw new Test262Error('#16: var obj = {}; obj.length = new Number(0); obj.push = SendableArray.prototype.push; obj.push(-16) === 1. Actual: ' + (push)); +} +if (obj.length !== 1) { + throw new Test262Error('#17: var obj = {}; obj.length = new Number(0); obj.push = SendableArray.prototype.push; obj.push(-16); obj.length === 1. Actual: ' + (obj.length)); +} +if (obj["0"] !== -16) { + throw new Test262Error('#18: var obj = {}; obj.length = new Number(0); obj.push = SendableArray.prototype.push; obj.push(-16); obj["0"] === -16. Actual: ' + (obj["0"])); +} diff --git a/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A2_T3.js b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A2_T3.js new file mode 100644 index 00000000000..45162788e0d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A2_T3.js @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The push function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.push +description: > + Operator use ToNumber from length. If Type(value) is Object, + evaluate ToPrimitive(value, Number) +---*/ + +var obj = {}; +obj.push = SendableArray.prototype.push; +obj.length = { + valueOf() { + return 3 + } +}; +var push = obj.push(); +assert.sameValue(push, 3, 'The value of push is expected to be 3'); +obj.length = { + valueOf() { + return 3 + }, + toString() { + return 1 + } +}; +var push = obj.push(); +assert.sameValue(push, 3, 'The value of push is expected to be 3'); +obj.length = { + valueOf() { + return 3 + }, + toString() { + return {} + } +}; +var push = obj.push(); +assert.sameValue(push, 3, 'The value of push is expected to be 3'); +try { + obj.length = { + valueOf() { + return 3 + }, + toString() { + throw "error" + } + }; + var push = obj.push(); + assert.sameValue(push, 3, 'The value of push is expected to be 3'); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} +obj.length = { + toString() { + return 1 + } +}; +var push = obj.push(); +assert.sameValue(push, 1, 'The value of push is expected to be 1'); +obj.length = { + valueOf() { + return {} + }, + toString() { + return 1 + } +} +var push = obj.push(); +assert.sameValue(push, 1, 'The value of push is expected to be 1'); +try { + obj.length = { + valueOf() { + throw "error" + }, + toString() { + return 1 + } + }; + var push = obj.push(); + throw new Test262Error('#7.1: obj.length = {valueOf() {throw "error"}, toString() {return 1}}; obj.push() throw "error". Actual: ' + (push)); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} +try { + obj.length = { + valueOf() { + return {} + }, + toString() { + return {} + } + }; + var push = obj.push(); + throw new Test262Error('#8.1: obj.length = {valueOf() {return {}}, toString() {return {}}} obj.push() throw TypeError. Actual: ' + (push)); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A3.js b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A3.js new file mode 100644 index 00000000000..0e521add8d3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A3.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for Array object +esid: sec-array.prototype.push +description: If ToUint32(length) !== length, throw RangeError +---*/ + +var x = []; +x.length = 4294967295; +var push = x.push(); +assert.sameValue(push, 4294967295, 'The value of push is expected to be 4294967295'); +try { + x.push("x"); + throw new Test262Error('#2.1: x = []; x.length = 4294967295; x.push("x") throw RangeError. Actual: ' + (push)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} +assert.sameValue(x[4294967295], "x", 'The value of x[4294967295] is expected to be "x"'); +assert.sameValue(x.length, 4294967295, 'The value of x.length is expected to be 4294967295'); diff --git a/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A4_T1.js b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A4_T1.js new file mode 100644 index 00000000000..4a03a774691 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A4_T1.js @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.push +description: length = 4294967296 +---*/ + +var obj = {}; +obj.push = SendableArray.prototype.push; +obj.length = 4294967296; +var push = obj.push("x", "y", "z"); +if (push !== 4294967299) { + throw new Test262Error('#1: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z") === 4294967299. Actual: ' + (push)); +} +if (obj.length !== 4294967299) { + throw new Test262Error('#2: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj.length === 4294967299. Actual: ' + (obj.length)); +} +if (obj[0] !== undefined) { + throw new Test262Error('#3: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[0] === undefined. Actual: ' + (obj[0])); +} +if (obj[1] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[1] === undefined. Actual: ' + (obj[1])); +} +if (obj[2] !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[2] === undefined. Actual: ' + (obj[2])); +} +if (obj[4294967296] !== "x") { + throw new Test262Error('#6: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[4294967296] === "x". Actual: ' + (obj[4294967296])); +} +if (obj[4294967297] !== "y") { + throw new Test262Error('#7: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[4294967297] === "y". Actual: ' + (obj[4294967297])); +} +if (obj[4294967298] !== "z") { + throw new Test262Error('#8: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967296; obj.push("x", "y", "z"); obj[4294967298] === "z". Actual: ' + (obj[4294967298])); +} +var obj = {}; +obj.push = SendableArray.prototype.push; +obj.length = 4294967296; +var push = obj.push(); +if (push !== 4294967296) { + throw new Test262Error('#9: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967296; obj.push() === 4294967296. Actual: ' + (push)); +} +if (obj.length !== 4294967296) { + throw new Test262Error('#10: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967296; obj.push(); obj.length === 4294967296. Actual: ' + (obj.length)); +} diff --git a/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A4_T2.js b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A4_T2.js new file mode 100644 index 00000000000..a7797a439ff --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A4_T2.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.push +description: length = 4294967295 +---*/ + +var obj = {}; +obj.push = SendableArray.prototype.push; +obj.length = 4294967295; +var push = obj.push("x", "y", "z"); +if (push !== 4294967298) { + throw new Test262Error('#1: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z") === 4294967298. Actual: ' + (push)); +} +if (obj.length !== 4294967298) { + throw new Test262Error('#2: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z"); obj.length === 4294967298. Actual: ' + (obj.length)); +} +if (obj[4294967295] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z"); obj[4294967295] === "x". Actual: ' + (obj[4294967295])); +} +if (obj[4294967296] !== "y") { + throw new Test262Error('#4: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z"); obj[4294967296] === "y". Actual: ' + (obj[4294967296])); +} +if (obj[4294967297] !== "z") { + throw new Test262Error('#5: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = 4294967295; obj.push("x", "y", "z"); obj[4294967297] === "z". Actual: ' + (obj[4294967297])); +} diff --git a/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A4_T3.js b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A4_T3.js new file mode 100644 index 00000000000..d5fbbd909a1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A4_T3.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.push +description: length = -1 +---*/ + +var obj = {}; +obj.push = SendableArray.prototype.push; +obj.length = -1; +var push = obj.push("x", "y", "z"); +if (push !== 3) { + throw new Test262Error('#1: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = -1; obj.push("x", "y", "z") === 3. Actual: ' + (push)); +} +if (obj.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj.length === 3. Actual: ' + (obj.length)); +} +if (obj[4294967295] !== undefined) { + throw new Test262Error('#3: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[4294967295] === undefined. Actual: ' + (obj[4294967295])); +} +if (obj[4294967296] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[4294967296] === undefined. Actual: ' + (obj[4294967296])); +} +if (obj[4294967297] !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[4294967297] === undefined. Actual: ' + (obj[4294967297])); +} +if (obj[0] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[0] === "x". Actual: ' + (obj[0])); +} +if (obj[1] !== "y") { + throw new Test262Error('#4: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[1] === "y". Actual: ' + (obj[1])); +} +if (obj[2] !== "z") { + throw new Test262Error('#5: var obj = {}; obj.push = SendableArray.prototype.push; obj.length = -1; obj.push("x", "y", "z"); obj[2] === "z". Actual: ' + (obj[2])); +} diff --git a/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A5_T1.js b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A5_T1.js new file mode 100644 index 00000000000..b15fe6fafa1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/S15.4.4.7_A5_T1.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]] from not an inherited property" +esid: sec-array.prototype.push +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +Object.prototype[1] = -1; +Object.prototype.length = 1; +Object.prototype.push = SendableArray.prototype.push; +var x = { + 0: 0 +}; +var push = x.push(1); +if (push !== 2) { + throw new Test262Error('#1: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = SendableArray.prototype.push; x = {0:0}; x.push(1) === 2. Actual: ' + (push)); +} +if (x.length !== 2) { + throw new Test262Error('#2: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = SendableArray.prototype.push; x = {0:0}; x.push(1); x.length === 2. Actual: ' + (x.length)); +} +if (x[1] !== 1) { + throw new Test262Error('#3: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = SendableArray.prototype.push; x = {0:0}; x.push(1); x[1] === 1. Actual: ' + (x[1])); +} +delete x[1]; +if (x[1] !== -1) { + throw new Test262Error('#4: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = SendableArray.prototype.push; x = {0:0}; x.push(1); delete x[1]; x[1] === -1. Actual: ' + (x[1])); +} +delete x.length; +if (x.length !== 1) { + throw new Test262Error('#5: Object.prototype[1] = 1; Object.prototype.length = -1; Object.prototype.push = SendableArray.prototype.push; x = {0:0}; delete x; x.push(1); x.length === 1. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/push/call-with-boolean.js b/test/sendable/builtins/Array/prototype/push/call-with-boolean.js new file mode 100644 index 00000000000..7aebcaa7c5f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/call-with-boolean.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.push +description: Array.prototype.push applied to boolean primitive +---*/ + +assert.sameValue(SendableArray.prototype.push.call(true), 0, 'SendableArray.prototype.push.call(true) must return 0'); +assert.sameValue(SendableArray.prototype.push.call(false), 0, 'SendableArray.prototype.push.call(false) must return 0'); diff --git a/test/sendable/builtins/Array/prototype/push/clamps-to-integer-limit.js b/test/sendable/builtins/Array/prototype/push/clamps-to-integer-limit.js new file mode 100644 index 00000000000..c982980ca8a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/clamps-to-integer-limit.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.push +description: > + Length values exceeding 2^53-1 are clamped to 2^53-1. +info: | + 1. ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let items be a List whose elements are, in left to right order, the arguments + that were passed to this function invocation. + 4. Let argCount be the number of elements in items. + 7. Perform ? Set(O, "length", len, true). +features: [exponentiation] +---*/ + +var arrayLike = {}; +arrayLike.length = 2 ** 53 - 1; +SendableArray.prototype.push.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53 - 1"); +arrayLike.length = 2 ** 53; +SendableArray.prototype.push.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53"); +arrayLike.length = 2 ** 53 + 2; +SendableArray.prototype.push.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53 + 2"); +arrayLike.length = Infinity; +SendableArray.prototype.push.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is Infinity"); diff --git a/test/sendable/builtins/Array/prototype/push/length-near-integer-limit-set-failure.js b/test/sendable/builtins/Array/prototype/push/length-near-integer-limit-set-failure.js new file mode 100644 index 00000000000..3866e04fc6a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/length-near-integer-limit-set-failure.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.push +description: > + A value is inserted in an array-like object whose length property is near the integer limit. + Unsuccessful [[Set]] raises a TypeError. +---*/ + +var arrayLike = { + length: Number.MAX_SAFE_INTEGER - 3, +}; +Object.defineProperty(arrayLike, Number.MAX_SAFE_INTEGER - 1, { + value: 33, + writable: false, + enumerable: true, + configurable: true, +}); +assert.throws(TypeError, function() { + SendableArray.prototype.push.call(arrayLike, 1, 2, 3); +}); +assert.sameValue(arrayLike[Number.MAX_SAFE_INTEGER - 3], 1); +assert.sameValue(arrayLike[Number.MAX_SAFE_INTEGER - 2], 2); +assert.sameValue(arrayLike[Number.MAX_SAFE_INTEGER - 1], 33); diff --git a/test/sendable/builtins/Array/prototype/push/length-near-integer-limit.js b/test/sendable/builtins/Array/prototype/push/length-near-integer-limit.js new file mode 100644 index 00000000000..3490cb3f6fe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/length-near-integer-limit.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.push +description: > + A value is inserted in an array-like object whose length property is near the integer limit. +---*/ + +var arrayLike = { + "9007199254740989": "9007199254740989", + /* "9007199254740990": empty */ + "9007199254740991": "9007199254740991", + length: 2 ** 53 - 2 +}; +SendableArray.prototype.push.call(arrayLike, "new-value"); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, + "New arrayLike.length is 2**53 - 1"); +assert.sameValue(arrayLike["9007199254740989"], "9007199254740989", + "arrayLike['9007199254740989'] is unchanged"); +assert.sameValue(arrayLike["9007199254740990"], "new-value", + "arrayLike['9007199254740990'] has new value"); +assert.sameValue(arrayLike["9007199254740991"], "9007199254740991", + "arrayLike['9007199254740991'] is unchanged"); diff --git a/test/sendable/builtins/Array/prototype/push/length.js b/test/sendable/builtins/Array/prototype/push/length.js new file mode 100644 index 00000000000..ee90f1c6a2b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/length.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.push +description: > + The "length" property of Array.prototype.push +info: | + 22.1.3.18 Array.prototype.push ( ...items ) + The length property of the push method is 1. + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.push, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/push/name.js b/test/sendable/builtins/Array/prototype/push/name.js new file mode 100644 index 00000000000..14734659d09 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.push +description: > + Array.prototype.push.name is "push". +info: | + Array.prototype.push ( ...items ) + 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(SendableArray.prototype.push, "name", { + value: "push", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/push/not-a-constructor.js b/test/sendable/builtins/Array/prototype/push/not-a-constructor.js new file mode 100644 index 00000000000..1d94c9932e9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/not-a-constructor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.push 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(SendableArray.prototype.push), false, 'isConstructor(SendableArray.prototype.push) must return false'); +assert.throws(TypeError, () => { + new SendableArray.prototype.push(); +}); + diff --git a/test/sendable/builtins/Array/prototype/push/prop-desc.js b/test/sendable/builtins/Array/prototype/push/prop-desc.js new file mode 100644 index 00000000000..1e03d764218 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.push +description: > + "push" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.push, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "push", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/push/set-length-array-is-frozen.js b/test/sendable/builtins/Array/prototype/push/set-length-array-is-frozen.js new file mode 100644 index 00000000000..db7c629d220 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/set-length-array-is-frozen.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.push +description: > + A TypeError is thrown when "length" is [[Set]] on a frozen array. +---*/ + +var array = []; +var arrayPrototypeSet0Calls = 0; +Object.defineProperty(SendableArray.prototype, "0", { + set(_val) { + Object.freeze(array); + arrayPrototypeSet0Calls++; + }, +}); +assert.throws(TypeError, function() { + array.push(1); +}); +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); +assert.sameValue(arrayPrototypeSet0Calls, 1); diff --git a/test/sendable/builtins/Array/prototype/push/set-length-array-length-is-non-writable.js b/test/sendable/builtins/Array/prototype/push/set-length-array-length-is-non-writable.js new file mode 100644 index 00000000000..466335b785d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/set-length-array-length-is-non-writable.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.push +description: > + A TypeError is thrown when "length" is [[Set]] on an array with non-writable "length". +---*/ + +var array = []; +var arrayPrototypeSet0Calls = 0; +Object.defineProperty(SendableArray.prototype, "0", { + set(_val) { + Object.defineProperty(array, "length", { writable: false }); + arrayPrototypeSet0Calls++; + }, +}); +assert.throws(TypeError, function() { + array.push(1); +}); +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); +assert.sameValue(arrayPrototypeSet0Calls, 1); diff --git a/test/sendable/builtins/Array/prototype/push/set-length-zero-array-is-frozen.js b/test/sendable/builtins/Array/prototype/push/set-length-zero-array-is-frozen.js new file mode 100644 index 00000000000..2e3a1a2090e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/set-length-zero-array-is-frozen.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.push +description: > + A TypeError is thrown when "length" is [[Set]] on an empty frozen array. +---*/ + +var array = []; +Object.freeze(array); +assert.throws(TypeError, function() { + array.push(); +}); +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); diff --git a/test/sendable/builtins/Array/prototype/push/set-length-zero-array-length-is-non-writable.js b/test/sendable/builtins/Array/prototype/push/set-length-zero-array-length-is-non-writable.js new file mode 100644 index 00000000000..0540a8f9027 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/set-length-zero-array-length-is-non-writable.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.push +description: > + A TypeError is thrown when "length" is [[Set]] on an empty array with non-writable "length". +---*/ + +var array = []; +Object.defineProperty(array, "length", { writable: false }); +assert.throws(TypeError, function() { + array.push(); +}); +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); diff --git a/test/sendable/builtins/Array/prototype/push/throws-if-integer-limit-exceeded.js b/test/sendable/builtins/Array/prototype/push/throws-if-integer-limit-exceeded.js new file mode 100644 index 00000000000..ba9ba819c08 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/throws-if-integer-limit-exceeded.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.push +description: > + A TypeError is thrown if the new length exceeds 2^53-1. +---*/ + +var arrayLike = {}; +arrayLike.length = 2 ** 53 - 1; +assert.throws(TypeError, function() { + SendableArray.prototype.push.call(arrayLike, null); +}, "Length is 2**53 - 1"); +arrayLike.length = 2 ** 53; +assert.throws(TypeError, function() { + SendableArray.prototype.push.call(arrayLike, null); +}, "Length is 2**53"); +arrayLike.length = 2 ** 53 + 2; +assert.throws(TypeError, function() { + SendableArray.prototype.push.call(arrayLike, null); +}, "Length is 2**53 + 2"); +arrayLike.length = Infinity; +assert.throws(TypeError, function() { + SendableArray.prototype.push.call(arrayLike, null); +}, "Length is Infinity"); diff --git a/test/sendable/builtins/Array/prototype/push/throws-with-string-receiver.js b/test/sendable/builtins/Array/prototype/push/throws-with-string-receiver.js new file mode 100644 index 00000000000..62bed7f155d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/push/throws-with-string-receiver.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.push +description: > + Array#push throws TypeError upon attempting to modify a string +---*/ + +assert.throws(TypeError, () => { + SendableArray.prototype.push.call(''); +}, "SendableArray.prototype.push.call('')"); +assert.throws(TypeError, () => { + SendableArray.prototype.push.call('', 1); +}, "SendableArray.prototype.push.call('', 1)"); +assert.throws(TypeError, () => { + SendableArray.prototype.push.call('abc'); +}, "SendableArray.prototype.push.call('abc')"); +assert.throws(TypeError, () => { + SendableArray.prototype.push.call('abc', 1); +}, "SendableArray.prototype.push.call('abc', 1)"); -- Gitee From 512a13c0f5369d300d2fbbe4bfd3b98012ae7d9e Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 31 Dec 2024 15:08:19 +0800 Subject: [PATCH 61/93] add array-reduce Signed-off-by: zhuzhihui7 --- .../Array/prototype/reduce/15.4.4.21-1-1.js | 22 ++++ .../Array/prototype/reduce/15.4.4.21-1-10.js | 25 ++++ .../Array/prototype/reduce/15.4.4.21-1-11.js | 26 ++++ .../Array/prototype/reduce/15.4.4.21-1-12.js | 26 ++++ .../Array/prototype/reduce/15.4.4.21-1-13.js | 25 ++++ .../Array/prototype/reduce/15.4.4.21-1-14.js | 26 ++++ .../Array/prototype/reduce/15.4.4.21-1-15.js | 26 ++++ .../Array/prototype/reduce/15.4.4.21-1-2.js | 22 ++++ .../Array/prototype/reduce/15.4.4.21-1-3.js | 25 ++++ .../Array/prototype/reduce/15.4.4.21-1-4.js | 27 ++++ .../Array/prototype/reduce/15.4.4.21-1-5.js | 25 ++++ .../Array/prototype/reduce/15.4.4.21-1-6.js | 27 ++++ .../Array/prototype/reduce/15.4.4.21-1-7.js | 23 ++++ .../Array/prototype/reduce/15.4.4.21-1-8.js | 24 ++++ .../Array/prototype/reduce/15.4.4.21-1-9.js | 28 ++++ .../Array/prototype/reduce/15.4.4.21-10-1.js | 32 +++++ .../Array/prototype/reduce/15.4.4.21-10-2.js | 27 ++++ .../Array/prototype/reduce/15.4.4.21-10-3.js | 24 ++++ .../Array/prototype/reduce/15.4.4.21-10-4.js | 26 ++++ .../Array/prototype/reduce/15.4.4.21-10-5.js | 27 ++++ .../Array/prototype/reduce/15.4.4.21-10-6.js | 28 ++++ .../Array/prototype/reduce/15.4.4.21-10-7.js | 28 ++++ .../Array/prototype/reduce/15.4.4.21-10-8.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-2-1.js | 31 +++++ .../Array/prototype/reduce/15.4.4.21-2-10.js | 38 ++++++ .../Array/prototype/reduce/15.4.4.21-2-11.js | 35 +++++ .../Array/prototype/reduce/15.4.4.21-2-12.js | 42 ++++++ .../Array/prototype/reduce/15.4.4.21-2-13.js | 37 ++++++ .../Array/prototype/reduce/15.4.4.21-2-14.js | 31 +++++ .../Array/prototype/reduce/15.4.4.21-2-17.js | 29 ++++ .../Array/prototype/reduce/15.4.4.21-2-18.js | 26 ++++ .../Array/prototype/reduce/15.4.4.21-2-19.js | 31 +++++ .../Array/prototype/reduce/15.4.4.21-2-2.js | 23 ++++ .../Array/prototype/reduce/15.4.4.21-2-3.js | 35 +++++ .../Array/prototype/reduce/15.4.4.21-2-4.js | 28 ++++ .../Array/prototype/reduce/15.4.4.21-2-5.js | 42 ++++++ .../Array/prototype/reduce/15.4.4.21-2-6.js | 34 +++++ .../Array/prototype/reduce/15.4.4.21-2-7.js | 35 +++++ .../Array/prototype/reduce/15.4.4.21-2-8.js | 40 ++++++ .../Array/prototype/reduce/15.4.4.21-2-9.js | 45 +++++++ .../Array/prototype/reduce/15.4.4.21-3-1.js | 31 +++++ .../Array/prototype/reduce/15.4.4.21-3-10.js | 32 +++++ .../Array/prototype/reduce/15.4.4.21-3-11.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-3-12.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-3-13.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-3-14.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-3-15.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-3-16.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-3-17.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-3-18.js | 32 +++++ .../Array/prototype/reduce/15.4.4.21-3-19.js | 34 +++++ .../Array/prototype/reduce/15.4.4.21-3-2.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-3-20.js | 34 +++++ .../Array/prototype/reduce/15.4.4.21-3-21.js | 44 +++++++ .../Array/prototype/reduce/15.4.4.21-3-22.js | 49 +++++++ .../Array/prototype/reduce/15.4.4.21-3-23.js | 47 +++++++ .../Array/prototype/reduce/15.4.4.21-3-24.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-3-25.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-3-3.js | 31 +++++ .../Array/prototype/reduce/15.4.4.21-3-4.js | 32 +++++ .../Array/prototype/reduce/15.4.4.21-3-5.js | 32 +++++ .../Array/prototype/reduce/15.4.4.21-3-6.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-3-7.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-3-9.js | 31 +++++ .../Array/prototype/reduce/15.4.4.21-4-1.js | 23 ++++ .../Array/prototype/reduce/15.4.4.21-4-10.js | 34 +++++ .../Array/prototype/reduce/15.4.4.21-4-11.js | 38 ++++++ .../Array/prototype/reduce/15.4.4.21-4-12.js | 26 ++++ .../Array/prototype/reduce/15.4.4.21-4-15.js | 46 +++++++ .../Array/prototype/reduce/15.4.4.21-4-2.js | 25 ++++ .../Array/prototype/reduce/15.4.4.21-4-3.js | 23 ++++ .../Array/prototype/reduce/15.4.4.21-4-4.js | 23 ++++ .../Array/prototype/reduce/15.4.4.21-4-5.js | 23 ++++ .../Array/prototype/reduce/15.4.4.21-4-6.js | 23 ++++ .../Array/prototype/reduce/15.4.4.21-4-7.js | 25 ++++ .../Array/prototype/reduce/15.4.4.21-4-8.js | 37 ++++++ .../Array/prototype/reduce/15.4.4.21-4-9.js | 41 ++++++ .../Array/prototype/reduce/15.4.4.21-5-1.js | 25 ++++ .../Array/prototype/reduce/15.4.4.21-5-10.js | 40 ++++++ .../Array/prototype/reduce/15.4.4.21-5-11.js | 44 +++++++ .../Array/prototype/reduce/15.4.4.21-5-12.js | 37 ++++++ .../Array/prototype/reduce/15.4.4.21-5-13.js | 41 ++++++ .../Array/prototype/reduce/15.4.4.21-5-2.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-5-3.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-5-4.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-5-5.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-5-6.js | 35 +++++ .../Array/prototype/reduce/15.4.4.21-5-7.js | 40 ++++++ .../Array/prototype/reduce/15.4.4.21-5-8.js | 42 ++++++ .../Array/prototype/reduce/15.4.4.21-5-9.js | 27 ++++ .../Array/prototype/reduce/15.4.4.21-7-1.js | 23 ++++ .../Array/prototype/reduce/15.4.4.21-7-10.js | 21 +++ .../Array/prototype/reduce/15.4.4.21-7-11.js | 21 +++ .../Array/prototype/reduce/15.4.4.21-7-2.js | 28 ++++ .../Array/prototype/reduce/15.4.4.21-7-3.js | 28 ++++ .../Array/prototype/reduce/15.4.4.21-7-4.js | 28 ++++ .../Array/prototype/reduce/15.4.4.21-7-5.js | 28 ++++ .../Array/prototype/reduce/15.4.4.21-7-6.js | 33 +++++ .../Array/prototype/reduce/15.4.4.21-7-7.js | 38 ++++++ .../Array/prototype/reduce/15.4.4.21-7-8.js | 41 ++++++ .../Array/prototype/reduce/15.4.4.21-7-9.js | 41 ++++++ .../Array/prototype/reduce/15.4.4.21-8-b-1.js | 34 +++++ .../Array/prototype/reduce/15.4.4.21-8-b-2.js | 37 ++++++ .../Array/prototype/reduce/15.4.4.21-8-b-3.js | 48 +++++++ .../prototype/reduce/15.4.4.21-8-b-ii-1.js | 30 +++++ .../prototype/reduce/15.4.4.21-8-b-ii-2.js | 33 +++++ .../prototype/reduce/15.4.4.21-8-b-iii-1-1.js | 35 +++++ .../reduce/15.4.4.21-8-b-iii-1-10.js | 36 +++++ .../reduce/15.4.4.21-8-b-iii-1-11.js | 45 +++++++ .../reduce/15.4.4.21-8-b-iii-1-12.js | 37 ++++++ .../reduce/15.4.4.21-8-b-iii-1-13.js | 50 +++++++ .../reduce/15.4.4.21-8-b-iii-1-14.js | 42 ++++++ .../reduce/15.4.4.21-8-b-iii-1-15.js | 43 ++++++ .../reduce/15.4.4.21-8-b-iii-1-16.js | 36 +++++ .../reduce/15.4.4.21-8-b-iii-1-17.js | 38 ++++++ .../reduce/15.4.4.21-8-b-iii-1-18.js | 34 +++++ .../reduce/15.4.4.21-8-b-iii-1-19.js | 40 ++++++ .../prototype/reduce/15.4.4.21-8-b-iii-1-2.js | 30 +++++ .../reduce/15.4.4.21-8-b-iii-1-20.js | 36 +++++ .../reduce/15.4.4.21-8-b-iii-1-21.js | 41 ++++++ .../reduce/15.4.4.21-8-b-iii-1-22.js | 34 +++++ .../reduce/15.4.4.21-8-b-iii-1-25.js | 33 +++++ .../reduce/15.4.4.21-8-b-iii-1-26.js | 34 +++++ .../reduce/15.4.4.21-8-b-iii-1-27.js | 35 +++++ .../reduce/15.4.4.21-8-b-iii-1-28.js | 30 +++++ .../reduce/15.4.4.21-8-b-iii-1-29.js | 36 +++++ .../prototype/reduce/15.4.4.21-8-b-iii-1-3.js | 42 ++++++ .../reduce/15.4.4.21-8-b-iii-1-30.js | 48 +++++++ .../reduce/15.4.4.21-8-b-iii-1-31.js | 51 +++++++ .../reduce/15.4.4.21-8-b-iii-1-32.js | 45 +++++++ .../reduce/15.4.4.21-8-b-iii-1-33.js | 41 ++++++ .../prototype/reduce/15.4.4.21-8-b-iii-1-4.js | 30 +++++ .../prototype/reduce/15.4.4.21-8-b-iii-1-5.js | 46 +++++++ .../prototype/reduce/15.4.4.21-8-b-iii-1-6.js | 35 +++++ .../prototype/reduce/15.4.4.21-8-b-iii-1-7.js | 39 ++++++ .../prototype/reduce/15.4.4.21-8-b-iii-1-8.js | 32 +++++ .../prototype/reduce/15.4.4.21-8-b-iii-1-9.js | 40 ++++++ .../Array/prototype/reduce/15.4.4.21-8-c-1.js | 27 ++++ .../Array/prototype/reduce/15.4.4.21-8-c-2.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-8-c-3.js | 32 +++++ .../Array/prototype/reduce/15.4.4.21-8-c-4.js | 28 ++++ .../Array/prototype/reduce/15.4.4.21-8-c-5.js | 34 +++++ .../Array/prototype/reduce/15.4.4.21-8-c-6.js | 38 ++++++ .../Array/prototype/reduce/15.4.4.21-8-c-7.js | 31 +++++ .../Array/prototype/reduce/15.4.4.21-8-c-8.js | 35 +++++ .../Array/prototype/reduce/15.4.4.21-9-1.js | 28 ++++ .../Array/prototype/reduce/15.4.4.21-9-10.js | 28 ++++ .../Array/prototype/reduce/15.4.4.21-9-2.js | 29 ++++ .../Array/prototype/reduce/15.4.4.21-9-3.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-9-4.js | 28 ++++ .../Array/prototype/reduce/15.4.4.21-9-5.js | 30 +++++ .../Array/prototype/reduce/15.4.4.21-9-6.js | 33 +++++ .../Array/prototype/reduce/15.4.4.21-9-7.js | 29 ++++ .../Array/prototype/reduce/15.4.4.21-9-8.js | 37 ++++++ .../Array/prototype/reduce/15.4.4.21-9-9.js | 37 ++++++ .../Array/prototype/reduce/15.4.4.21-9-b-1.js | 25 ++++ .../prototype/reduce/15.4.4.21-9-b-10.js | 45 +++++++ .../prototype/reduce/15.4.4.21-9-b-11.js | 41 ++++++ .../prototype/reduce/15.4.4.21-9-b-12.js | 44 +++++++ .../prototype/reduce/15.4.4.21-9-b-13.js | 39 ++++++ .../prototype/reduce/15.4.4.21-9-b-14.js | 40 ++++++ .../prototype/reduce/15.4.4.21-9-b-15.js | 43 ++++++ .../prototype/reduce/15.4.4.21-9-b-16.js | 44 +++++++ .../prototype/reduce/15.4.4.21-9-b-17.js | 44 +++++++ .../prototype/reduce/15.4.4.21-9-b-18.js | 42 ++++++ .../prototype/reduce/15.4.4.21-9-b-19.js | 44 +++++++ .../Array/prototype/reduce/15.4.4.21-9-b-2.js | 37 ++++++ .../prototype/reduce/15.4.4.21-9-b-20.js | 42 ++++++ .../prototype/reduce/15.4.4.21-9-b-21.js | 49 +++++++ .../prototype/reduce/15.4.4.21-9-b-22.js | 46 +++++++ .../prototype/reduce/15.4.4.21-9-b-23.js | 44 +++++++ .../prototype/reduce/15.4.4.21-9-b-24.js | 41 ++++++ .../prototype/reduce/15.4.4.21-9-b-25.js | 44 +++++++ .../prototype/reduce/15.4.4.21-9-b-26.js | 38 ++++++ .../prototype/reduce/15.4.4.21-9-b-27.js | 40 ++++++ .../prototype/reduce/15.4.4.21-9-b-28.js | 43 ++++++ .../prototype/reduce/15.4.4.21-9-b-29.js | 44 +++++++ .../Array/prototype/reduce/15.4.4.21-9-b-3.js | 43 ++++++ .../Array/prototype/reduce/15.4.4.21-9-b-4.js | 44 +++++++ .../Array/prototype/reduce/15.4.4.21-9-b-5.js | 42 ++++++ .../Array/prototype/reduce/15.4.4.21-9-b-6.js | 44 +++++++ .../Array/prototype/reduce/15.4.4.21-9-b-7.js | 43 ++++++ .../Array/prototype/reduce/15.4.4.21-9-b-8.js | 49 +++++++ .../Array/prototype/reduce/15.4.4.21-9-b-9.js | 40 ++++++ .../Array/prototype/reduce/15.4.4.21-9-c-1.js | 31 +++++ .../prototype/reduce/15.4.4.21-9-c-i-1.js | 36 +++++ .../prototype/reduce/15.4.4.21-9-c-i-10.js | 37 ++++++ .../prototype/reduce/15.4.4.21-9-c-i-11.js | 46 +++++++ .../prototype/reduce/15.4.4.21-9-c-i-12.js | 38 ++++++ .../prototype/reduce/15.4.4.21-9-c-i-13.js | 51 +++++++ .../prototype/reduce/15.4.4.21-9-c-i-14.js | 43 ++++++ .../prototype/reduce/15.4.4.21-9-c-i-15.js | 44 +++++++ .../prototype/reduce/15.4.4.21-9-c-i-16.js | 37 ++++++ .../prototype/reduce/15.4.4.21-9-c-i-17.js | 39 ++++++ .../prototype/reduce/15.4.4.21-9-c-i-18.js | 35 +++++ .../prototype/reduce/15.4.4.21-9-c-i-19.js | 46 +++++++ .../prototype/reduce/15.4.4.21-9-c-i-2.js | 31 +++++ .../prototype/reduce/15.4.4.21-9-c-i-20.js | 42 ++++++ .../prototype/reduce/15.4.4.21-9-c-i-21.js | 42 ++++++ .../prototype/reduce/15.4.4.21-9-c-i-22.js | 35 +++++ .../prototype/reduce/15.4.4.21-9-c-i-25.js | 34 +++++ .../prototype/reduce/15.4.4.21-9-c-i-26.js | 34 +++++ .../prototype/reduce/15.4.4.21-9-c-i-27.js | 34 +++++ .../prototype/reduce/15.4.4.21-9-c-i-28.js | 31 +++++ .../prototype/reduce/15.4.4.21-9-c-i-29.js | 37 ++++++ .../prototype/reduce/15.4.4.21-9-c-i-3.js | 43 ++++++ .../prototype/reduce/15.4.4.21-9-c-i-30.js | 49 +++++++ .../prototype/reduce/15.4.4.21-9-c-i-31.js | 52 ++++++++ .../prototype/reduce/15.4.4.21-9-c-i-32.js | 46 +++++++ .../prototype/reduce/15.4.4.21-9-c-i-33.js | 42 ++++++ .../prototype/reduce/15.4.4.21-9-c-i-4.js | 31 +++++ .../prototype/reduce/15.4.4.21-9-c-i-5.js | 47 +++++++ .../prototype/reduce/15.4.4.21-9-c-i-6.js | 36 +++++ .../prototype/reduce/15.4.4.21-9-c-i-7.js | 40 ++++++ .../prototype/reduce/15.4.4.21-9-c-i-8.js | 33 +++++ .../prototype/reduce/15.4.4.21-9-c-i-9.js | 41 ++++++ .../prototype/reduce/15.4.4.21-9-c-ii-1.js | 30 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-10.js | 27 ++++ .../prototype/reduce/15.4.4.21-9-c-ii-11.js | 27 ++++ .../prototype/reduce/15.4.4.21-9-c-ii-12.js | 27 ++++ .../prototype/reduce/15.4.4.21-9-c-ii-13.js | 27 ++++ .../prototype/reduce/15.4.4.21-9-c-ii-14.js | 25 ++++ .../prototype/reduce/15.4.4.21-9-c-ii-16.js | 41 ++++++ .../prototype/reduce/15.4.4.21-9-c-ii-17.js | 35 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-18.js | 35 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-19.js | 33 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-2.js | 34 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-20.js | 30 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-21.js | 30 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-22.js | 32 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-23.js | 32 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-24.js | 32 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-25.js | 31 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-26.js | 31 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-27.js | 31 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-28.js | 31 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-29.js | 31 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-3.js | 31 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-30.js | 30 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-31.js | 31 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-32.js | 31 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-33.js | 30 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-34.js | 31 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-35.js | 36 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-37.js | 33 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-4-s.js | 31 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-4.js | 36 +++++ .../prototype/reduce/15.4.4.21-9-c-ii-5.js | 41 ++++++ .../prototype/reduce/15.4.4.21-9-c-ii-7.js | 40 ++++++ .../prototype/reduce/15.4.4.21-9-c-ii-8.js | 37 ++++++ .../prototype/reduce/15.4.4.21-9-c-ii-9.js | 27 ++++ .../prototype/reduce/call-with-boolean.js | 29 ++++ .../reduce/callbackfn-resize-arraybuffer.js | 79 +++++++++++ .../builtins/Array/prototype/reduce/length.js | 38 ++++++ .../builtins/Array/prototype/reduce/name.js | 36 +++++ .../prototype/reduce/not-a-constructor.js | 39 ++++++ .../Array/prototype/reduce/prop-desc.js | 32 +++++ .../resizable-buffer-grow-mid-iteration.js | 94 +++++++++++++ .../resizable-buffer-shrink-mid-iteration.js | 88 +++++++++++++ .../prototype/reduce/resizable-buffer.js | 124 ++++++++++++++++++ 260 files changed, 9241 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-14.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-15.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-14.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-17.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-18.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-19.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-14.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-15.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-16.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-17.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-18.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-19.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-20.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-21.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-22.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-23.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-24.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-25.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-15.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-ii-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-ii-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-14.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-15.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-16.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-17.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-18.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-19.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-20.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-21.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-22.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-25.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-26.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-27.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-28.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-29.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-30.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-31.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-32.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-33.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-14.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-15.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-16.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-17.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-18.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-19.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-20.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-21.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-22.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-23.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-24.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-25.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-26.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-27.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-28.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-29.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-14.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-15.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-16.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-17.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-18.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-19.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-20.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-21.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-22.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-25.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-26.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-27.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-28.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-29.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-30.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-31.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-32.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-33.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-14.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-16.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-17.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-18.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-19.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-20.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-21.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-22.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-23.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-24.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-25.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-26.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-27.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-28.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-29.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-30.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-31.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-32.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-33.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-34.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-35.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-37.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-4-s.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/length.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/name.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/reduce/resizable-buffer.js diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-1.js new file mode 100644 index 00000000000..6c2572926d8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to undefined +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.reduce.call(undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-10.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-10.js new file mode 100644 index 00000000000..7b42b58c95f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-10.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to the Math object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return ('[object Math]' === Object.prototype.toString.call(obj)); +} +Math.length = 1; +Math[0] = 1; +assert(SendableArray.prototype.reduce.call(Math, callbackfn, 1), 'SendableArray.prototype.reduce.call(Math, callbackfn, 1) !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-11.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-11.js new file mode 100644 index 00000000000..8867b3bbf42 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-11.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to Date object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof Date; +} +var obj = new Date(0); +obj.length = 1; +obj[0] = 1; +assert(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 'SendableArray.prototype.reduce.call(obj, callbackfn, 1) !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-12.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-12.js new file mode 100644 index 00000000000..4c81d4e41eb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-12.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to RegExp object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof RegExp; +} +var obj = new RegExp(); +obj.length = 1; +obj[0] = 1; +assert(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 'SendableArray .prototype.reduce.call(obj, callbackfn, 1) !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-13.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-13.js new file mode 100644 index 00000000000..9d0c5706c57 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-13.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to the JSON object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return ('[object JSON]' === Object.prototype.toString.call(obj)); +} +JSON.length = 1; +JSON[0] = 1; +assert(SendableArray.prototype.reduce.call(JSON, callbackfn, 1), 'SendableArray.prototype.reduce.call(JSON, callbackfn, 1) !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-14.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-14.js new file mode 100644 index 00000000000..b81206dbdab --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-14.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to Error object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof Error; +} +var obj = new Error(); +obj.length = 1; +obj[0] = 1; +assert(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 'SendableArray.prototype.reduce.call(obj, callbackfn, 1) !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-15.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-15.js new file mode 100644 index 00000000000..077e04a2c3e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-15.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to the Arguments object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return ('[object Arguments]' === Object.prototype.toString.call(obj)); +} +var obj = (function() { + return arguments; +}("a", "b")); +assert(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 'SendableArray.prototype.reduce.call(obj, callbackfn, 1) !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-2.js new file mode 100644 index 00000000000..0a80491747f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-2.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to null +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.reduce.call(null); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-3.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-3.js new file mode 100644 index 00000000000..095ec6589ef --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to boolean primitive +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof Boolean; +} +Boolean.prototype[0] = true; +Boolean.prototype.length = 1; +assert(SendableArray.prototype.reduce.call(false, callbackfn, 1), 'SendableArray.prototype.reduce.call(false, callbackfn, 1) !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-4.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-4.js new file mode 100644 index 00000000000..c1a571bb7b2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-4.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to Boolean object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof Boolean; +} +var obj = new Boolean(true); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; +assert(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 'SendableArray.prototype.reduce.call(obj, callbackfn, 1) !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-5.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-5.js new file mode 100644 index 00000000000..fe7cbeeb14c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-5.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to number primitive +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof Number; +} +Number.prototype[0] = 1; +Number.prototype.length = 1; +assert(SendableArray.prototype.reduce.call(2.5, callbackfn, 1), 'SendableArray.prototype.reduce.call(2.5, callbackfn, 1) !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-6.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-6.js new file mode 100644 index 00000000000..bbcd565ef5b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-6.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to Number object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof Number; +} +var obj = new Number(-128); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; +assert(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 'SendableArray.prototype.reduce.call(obj, callbackfn, 1) !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-7.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-7.js new file mode 100644 index 00000000000..4db741def01 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-7.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to string primitive +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof String; +} +assert(SendableArray.prototype.reduce.call("abc", callbackfn, 1), 'SendableArray.prototype.reduce.call("abc", callbackfn, 1) !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-8.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-8.js new file mode 100644 index 00000000000..8781a1eab9c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-8.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to String object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof String; +} +var obj = new String("abc"); +assert(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 'SendableArray.prototype.reduce.call(obj, callbackfn, 1) !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-9.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-9.js new file mode 100644 index 00000000000..7f9f79c2da5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-1-9.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to Function object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return obj instanceof Function; +} +var obj = function(a, b) { + return a + b; +}; +obj[0] = 11; +obj[1] = 9; +assert(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 'SendableArray.prototype.reduce.call(obj, callbackfn, 1) !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-1.js new file mode 100644 index 00000000000..71ce0632e20 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-1.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce doesn't mutate the Array on which it is + called on +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + return 1; +} +var srcArr = [1, 2, 3, 4, 5]; +srcArr.reduce(callbackfn); +assert.sameValue(srcArr[0], 1, 'srcArr[0]'); +assert.sameValue(srcArr[1], 2, 'srcArr[1]'); +assert.sameValue(srcArr[2], 3, 'srcArr[2]'); +assert.sameValue(srcArr[3], 4, 'srcArr[3]'); +assert.sameValue(srcArr[4], 5, 'srcArr[4]'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-2.js new file mode 100644 index 00000000000..7e7839556e2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-2.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce reduces the array in ascending order of + indices +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + return prevVal + curVal; +} +var srcArr = ['1', '2', '3', '4', '5']; +assert.sameValue(srcArr.reduce(callbackfn), '12345', 'srcArr.reduce(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-3.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-3.js new file mode 100644 index 00000000000..79878ddb06d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-3.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - subclassed array of length 1 +---*/ + +foo.prototype = [1]; +function foo() {} +var f = new foo(); +function cb() {} +assert.sameValue(f.reduce(cb), 1, 'f.reduce(cb)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-4.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-4.js new file mode 100644 index 00000000000..1cd409d2181 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-4.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - subclassed array with length more than 1 +---*/ + +foo.prototype = new SendableArray(1, 2, 3, 4); +function foo() {} +var f = new foo(); +function cb(prevVal, curVal, idx, obj) { + return prevVal + curVal; +} +assert.sameValue(f.reduce(cb), 10, 'f.reduce(cb)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-5.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-5.js new file mode 100644 index 00000000000..b5b1c0e152a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-5.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce reduces the array in ascending order of + indices(initialvalue present) +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + return prevVal + curVal; +} +var srcArr = ['1', '2', '3', '4', '5']; +assert.sameValue(srcArr.reduce(callbackfn, '0'), '012345', 'srcArr.reduce(callbackfn,"0")'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-6.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-6.js new file mode 100644 index 00000000000..e87522ff7a7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-6.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - subclassed array when initialvalue + provided +---*/ + +foo.prototype = [1, 2, 3, 4]; +function foo() {} +var f = new foo(); +function cb(prevVal, curVal, idx, obj) { + return prevVal + curVal; +} +assert.sameValue(f.reduce(cb, -1), 9, 'f.reduce(cb,-1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-7.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-7.js new file mode 100644 index 00000000000..dde44809895 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-7.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - subclassed array with length 1 and + initialvalue provided +---*/ + +foo.prototype = [1]; +function foo() {} +var f = new foo(); +function cb(prevVal, curVal, idx, obj) { + return prevVal + curVal; +} +assert.sameValue(f.reduce(cb, -1), 0, 'f.reduce(cb,-1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-8.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-8.js new file mode 100644 index 00000000000..569129ec706 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-10-8.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce doesn't visit expandos +---*/ + +var callCnt = 0; +function callbackfn(prevVal, curVal, idx, obj) +{ + callCnt++; + return curVal; +} +var srcArr = ['1', '2', '3', '4', '5']; +srcArr["i"] = 10; +srcArr[true] = 11; +srcArr.reduce(callbackfn); +assert.sameValue(callCnt, 4, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-1.js new file mode 100644 index 00000000000..347c05c5332 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is own data property on an + Array-like object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-10.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-10.js new file mode 100644 index 00000000000..660d8385404 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-10.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object, 'length' is + an inherited accessor property +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert.sameValue(SendableArray.prototype.reduce.call(child, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(child, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-11.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-11.js new file mode 100644 index 00000000000..b110de8dbc2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-11.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object, 'length' is + an own accessor property without a get function +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-12.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-12.js new file mode 100644 index 00000000000..c3606ac6b78 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-12.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is own accessor property without + a get function that overrides an inherited accessor property on an + Array +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var obj = { + 0: 12, + 1: 11 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-13.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-13.js new file mode 100644 index 00000000000..5da86d5a2cb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-13.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object that 'length' + is inherited accessor property without a get function +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 11; +child[1] = 12; +assert.sameValue(SendableArray.prototype.reduce.call(child, callbackfn, 1), 1, 'SendableArray.prototype.reduce.call(child, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-14.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-14.js new file mode 100644 index 00000000000..23420fc200d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-14.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to the Array-like object that + 'length' property doesn't exist +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} +var obj = { + 0: 11, + 1: 12 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-17.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-17.js new file mode 100644 index 00000000000..915108cdc67 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-17.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to the Arguments object, which + implements its own property get method +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} +var func = function(a, b) { + arguments[2] = 9; + return SendableArray.prototype.reduce.call(arguments, callbackfn, 1); +}; +assert.sameValue(func(12, 11), true, 'func(12, 11)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-18.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-18.js new file mode 100644 index 00000000000..519d52ceb52 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-18.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to String object, which implements + its own property get method +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 3); +} +var str = new String("012"); +assert.sameValue(SendableArray.prototype.reduce.call(str, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(str, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-19.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-19.js new file mode 100644 index 00000000000..ce7ec8af708 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-19.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Function object, which + implements its own property get method +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} +var fun = function(a, b) { + return a + b; +}; +fun[0] = 12; +fun[1] = 11; +fun[2] = 9; +assert.sameValue(SendableArray.prototype.reduce.call(fun, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(fun, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-2.js new file mode 100644 index 00000000000..05c1a97c630 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-2.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - 'length' is own data property on an Array +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} +assert.sameValue([12, 11].reduce(callbackfn, 1), true, '[12, 11].reduce(callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-3.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-3.js new file mode 100644 index 00000000000..1bb95f3176c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-3.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is an own data property that + overrides an inherited data property on an Array-like object +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} +var proto = { + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert.sameValue(SendableArray.prototype.reduce.call(child, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(child, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-4.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-4.js new file mode 100644 index 00000000000..1a4e1a86f9a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is own data property that + overrides an inherited data property on an Array +---*/ + +var storeProtoLength; +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} +storeProtoLength = SendableArray.prototype.length; +SendableArray.prototype.length = 0; +assert.sameValue([12, 11].reduce(callbackfn, 1), true, '[12, 11].reduce(callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-5.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-5.js new file mode 100644 index 00000000000..552c68c0402 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-5.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object, 'length' is + an own data property that overrides an inherited accessor property +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert.sameValue(SendableArray.prototype.reduce.call(child, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(child, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-6.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-6.js new file mode 100644 index 00000000000..073ba0ee2f9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-6.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object, 'length' is + an inherited data property +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} +var proto = { + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert.sameValue(SendableArray.prototype.reduce.call(child, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(child, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-7.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-7.js new file mode 100644 index 00000000000..a6ab3bdabd7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-7.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object, 'length' is + an own accessor property +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); +obj[0] = 12; +obj[1] = 11; +obj[2] = 9; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-8.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-8.js new file mode 100644 index 00000000000..3ababd7fa3b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-8.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object, 'length' is + an own accessor property that overrides an inherited data property +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} +var proto = { + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert.sameValue(SendableArray.prototype.reduce.call(child, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(child, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-9.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-9.js new file mode 100644 index 00000000000..046c4b5df93 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-2-9.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce applied to Array-like object, 'length' is + an own accessor property that overrides an inherited accessor + property +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (obj.length === 2); +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert.sameValue(SendableArray.prototype.reduce.call(child, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(child, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-1.js new file mode 100644 index 00000000000..b87e54ed704 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - value of 'length' is undefined +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return 2; +} +var obj = { + 0: 0, + 1: 1, + length: undefined +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-10.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-10.js new file mode 100644 index 00000000000..940c916e94d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-10.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is number primitive + (value is NaN) +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return 2; +} +var obj = { + 0: 9, + length: NaN +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-11.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-11.js new file mode 100644 index 00000000000..c9fe6900660 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-11.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is a string containing a + positive number +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} +var obj = { + 1: 11, + 2: 9, + length: "2" +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-12.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-12.js new file mode 100644 index 00000000000..13df83f7db8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-12.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is a string containing a + negative number +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} +var obj = { + 1: 11, + 2: 9, + length: "-4294967294" +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-13.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-13.js new file mode 100644 index 00000000000..321d96a3c7a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-13.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is a string containing a decimal + number +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} +var obj = { + 1: 11, + 2: 9, + length: "2.5" +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-14.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-14.js new file mode 100644 index 00000000000..157c6e6f1a6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-14.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - 'length' is a string containing -Infinity +---*/ + +var accessed2 = false; +function callbackfn2(prevVal, curVal, idx, obj) { + accessed2 = true; + return 2; +} +var obj2 = { + 0: 9, + length: "-Infinity" +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj2, callbackfn2, 1), 1, 'SendableArray.prototype.reduce.call(obj2, callbackfn2, 1)'); +assert.sameValue(accessed2, false, 'accessed2'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-15.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-15.js new file mode 100644 index 00000000000..a8dcbbab7bf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-15.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is a string containing an + exponential number +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} +var obj = { + 1: 11, + 2: 9, + length: "2E0" +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-16.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-16.js new file mode 100644 index 00000000000..b42a6783318 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-16.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is a string containing a hex + number +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} +var obj = { + 1: 11, + 2: 9, + length: "0x0002" +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-17.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-17.js new file mode 100644 index 00000000000..5bc9d90b702 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-17.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is a string containing a number + with leading zeros +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} +var obj = { + 1: 11, + 2: 9, + length: "0002.00" +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-18.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-18.js new file mode 100644 index 00000000000..6c0f7051a48 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-18.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a string that can't + convert to a number +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return 2; +} +var obj = { + 0: 9, + length: "asdf!_" +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-19.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-19.js new file mode 100644 index 00000000000..5464f5f7c29 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-19.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is an Object which has + an own toString method +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} +var obj = { + 1: 11, + 2: 9, + length: { + toString: function() { + return '2'; + } + } +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-2.js new file mode 100644 index 00000000000..950663198a4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-2.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a boolean (value is + true) +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 0); +} +var obj = { + 0: 11, + 1: 9, + length: true +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-20.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-20.js new file mode 100644 index 00000000000..6f097e6a866 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-20.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is an object which has + an own valueOf method +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} +var obj = { + 1: 11, + 2: 9, + length: { + valueOf: function() { + return 2; + } + } +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-21.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-21.js new file mode 100644 index 00000000000..778a85ff69d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-21.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'length' is an object that has an own + valueOf method that returns an object and toString method that + returns a string +---*/ + +var valueOfOccured = false; +var toStringOccured = false; +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} +var obj = { + 1: 11, + 2: 9, + length: { + valueOf: function() { + valueOfOccured = true; + return {}; + }, + toString: function() { + toStringOccured = true; + return '2'; + } + } +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); +assert(valueOfOccured, 'valueOfOccured !== true'); +assert(toStringOccured, 'toStringOccured !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-22.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-22.js new file mode 100644 index 00000000000..2dbd8a53452 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-22.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError exception - 'length' is an + object with toString and valueOf methods that don�t return + primitive values +---*/ + +var accessed = false; +var valueOfAccessed = false; +var toStringAccessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return true; +} +var obj = { + 1: 11, + 2: 12, + length: { + valueOf: function() { + valueOfAccessed = true; + return {}; + }, + toString: function() { + toStringAccessed = true; + return {}; + } + } +}; +assert.throws(TypeError, function() { + SendableArray.prototype.reduce.call(obj, callbackfn, 1); +}); +assert.sameValue(accessed, false, 'accessed'); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-23.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-23.js new file mode 100644 index 00000000000..62cf997aafc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-23.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce uses inherited valueOf method - 'length' is + an object with an own toString and inherited valueOf methods +---*/ + +var valueOfAccessed = false; +var toStringAccessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return '1'; +}; +var obj = { + 1: 11, + 2: 9, + length: child +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-24.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-24.js new file mode 100644 index 00000000000..199fbc04281 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-24.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} +var obj = { + 1: 11, + 2: 9, + length: 2.685 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-25.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-25.js new file mode 100644 index 00000000000..35865b96100 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-25.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a negative + non-integer +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} +var obj = { + 1: 11, + 2: 9, + length: -4294967294.5 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-3.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-3.js new file mode 100644 index 00000000000..7e512f157f7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-3.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - value of 'length' is a number (value is 0) +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return 2; +} +var obj = { + 0: 1, + 1: 1, + length: 0 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-4.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-4.js new file mode 100644 index 00000000000..0376cfe97ab --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-4.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a number (value is + +0) +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return 2; +} +var obj = { + 0: 11, + length: +0 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-5.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-5.js new file mode 100644 index 00000000000..d7f67e707cd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-5.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a number (value is + -0) +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return 2; +} +var obj = { + 0: 11, + length: -0 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-6.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-6.js new file mode 100644 index 00000000000..4ae4c1b6791 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-6.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a number (value is + positive) +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} +var obj = { + 1: 11, + 2: 9, + length: 2 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-7.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-7.js new file mode 100644 index 00000000000..897f09991a8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-7.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a number (value is + negative) +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal === 11 && idx === 1); +} +var obj = { + 1: 11, + 2: 9, + length: -4294967294 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-9.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-9.js new file mode 100644 index 00000000000..6ea0098d439 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-3-9.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'length' is a number (value is + -Infinity) +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} +var obj = { + 0: 9, + length: -Infinity +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduce.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-1.js new file mode 100644 index 00000000000..e2bd5d998d9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce throws TypeError if callbackfn is undefined +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.reduce(); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-10.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-10.js new file mode 100644 index 00000000000..b6685945038 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-10.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the exception is not thrown if exception + was thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.reduce.call(obj, undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-11.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-11.js new file mode 100644 index 00000000000..597dfb0d677 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-11.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the exception is not thrown if exception + was thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.reduce.call(obj, undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-12.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-12.js new file mode 100644 index 00000000000..8e01409b106 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-12.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - 'callbackfn' is a function +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return curVal > 10; +} +assert.sameValue([11, 9].reduce(callbackfn, 1), false, '[11, 9].reduce(callbackfn, 1)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-15.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-15.js new file mode 100644 index 00000000000..da9847dd14c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-15.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - calling with no callbackfn is the same as + passing undefined for callbackfn +---*/ + +var obj = { + 10: 10 +}; +var lengthAccessed = false; +var loopAccessed = false; + +Object.defineProperty(obj, "length", { + get: function() { + lengthAccessed = true; + return 20; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + loopAccessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduce.call(obj); +}); +assert(lengthAccessed, 'lengthAccessed !== true'); +assert.sameValue(loopAccessed, false, 'loopAccessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-2.js new file mode 100644 index 00000000000..10eb8447979 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws ReferenceError if callbackfn is + unreferenced +---*/ + +var arr = new SendableArray(10); +assert.throws(ReferenceError, function() { + arr.reduce(foo); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-3.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-3.js new file mode 100644 index 00000000000..42ec092ff90 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce throws TypeError if callbackfn is null +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.reduce(null); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-4.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-4.js new file mode 100644 index 00000000000..f6ea36a8713 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-4.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce throws TypeError if callbackfn is boolean +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.reduce(true); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-5.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-5.js new file mode 100644 index 00000000000..aec2c3a3aa8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-5.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce throws TypeError if callbackfn is number +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.reduce(5); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-6.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-6.js new file mode 100644 index 00000000000..29cf12f87e8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-6.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce throws TypeError if callbackfn is string +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.reduce("abc"); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-7.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-7.js new file mode 100644 index 00000000000..e9859c06cfb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-7.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if callbackfn is Object + without [[Call]] internal method +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.reduce(new Object()); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-8.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-8.js new file mode 100644 index 00000000000..1e27748d816 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-8.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduce.call(obj, null); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-9.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-9.js new file mode 100644 index 00000000000..dd6be35fd2c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-4-9.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduce.call(obj, null); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-1.js new file mode 100644 index 00000000000..014b2deb053 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 (empty + array), no initVal +---*/ + +function cb() {} +assert.throws(TypeError, function() { + [].reduce(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-10.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-10.js new file mode 100644 index 00000000000..7bf7c272565 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-10.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - if exception occurs, it occurs after any + side-effects that might be produced by step 2 +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal > 10); +} +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 0; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduce.call(obj, callbackfn); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-11.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-11.js new file mode 100644 index 00000000000..4c7764edeb0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-11.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - if the exception occurs, it occurs after + any side-effects that might be produced by step 3 +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal > 10); +} +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "0"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduce.call(obj, callbackfn); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-12.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-12.js new file mode 100644 index 00000000000..1dc086388f5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-12.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the exception is not thrown if exception + was thrown by step 2 +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal > 10); +} +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.reduce.call(obj, callbackfn); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-13.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-13.js new file mode 100644 index 00000000000..2033d58152f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-13.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the exception is not thrown if exception + was thrown by step 3 +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return (curVal > 10); +} +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.reduce.call(obj, callbackfn); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-2.js new file mode 100644 index 00000000000..3e4e3e8a8bc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-2.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 + (subclassed Array, length overridden to null (type conversion)), + no initVal +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = null; +function cb() {} +assert.throws(TypeError, function() { + f.reduce(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-3.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-3.js new file mode 100644 index 00000000000..cfcf306c01b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-3.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 + (subclassed Array, length overridden to false (type conversion)), + no initVal +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = false; +function cb() {} +assert.throws(TypeError, function() { + f.reduce(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-4.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-4.js new file mode 100644 index 00000000000..634d7f11b21 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 + (subclassed Array, length overridden to 0 (type conversion)), no + initVal +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = 0; +function cb() {} +assert.throws(TypeError, function() { + f.reduce(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-5.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-5.js new file mode 100644 index 00000000000..84f66fb512d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-5.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 + (subclassed Array, length overridden to '0' (type conversion)), no + initVal +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = '0'; +function cb() {} +assert.throws(TypeError, function() { + f.reduce(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-6.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-6.js new file mode 100644 index 00000000000..22f09eb15d2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 + (subclassed Array, length overridden with obj with valueOf), no + initVal +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; +function cb() {} +assert.throws(TypeError, function() { + f.reduce(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-7.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-7.js new file mode 100644 index 00000000000..ea8a88846a8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-7.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 + (subclassed Array, length overridden with obj w/o valueOf + (toString)), no initVal +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +function cb() {} +assert.throws(TypeError, function() { + f.reduce(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-8.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-8.js new file mode 100644 index 00000000000..d62c4d85aa3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-8.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError if 'length' is 0 + (subclassed Array, length overridden with []), no initVal +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = []; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +function cb() {} +assert.throws(TypeError, function() { + f.reduce(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-9.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-9.js new file mode 100644 index 00000000000..4d86473168e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-5-9.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'initialValue' is returned if 'len' is 0 + and 'initialValue' is present +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} +assert.sameValue([].reduce(callbackfn, 3), 3, '[].reduce(callbackfn, 3)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-1.js new file mode 100644 index 00000000000..66abaac79b0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (empty array) +---*/ + +function cb() {} +assert.sameValue([].reduce(cb, 1), 1, '[].reduce(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-10.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-10.js new file mode 100644 index 00000000000..41a95c9d139 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-10.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - 'initialValue' is present +---*/ + +var str = "initialValue is present"; +assert.sameValue([].reduce(function() {}, str), str, '[].reduce(function () { }, str)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-11.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-11.js new file mode 100644 index 00000000000..2745ab152c6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-11.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - 'initialValue' is not present +---*/ + +var str = "initialValue is not present"; +assert.sameValue([str].reduce(function() {}), str, '[str].reduce(function () { })'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-2.js new file mode 100644 index 00000000000..98f257b2ff3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden to + null (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = null; +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-3.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-3.js new file mode 100644 index 00000000000..2298b55cc0a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-3.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden to + false (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = false; +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-4.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-4.js new file mode 100644 index 00000000000..17b1407f93a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden to 0 + (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = 0; +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-5.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-5.js new file mode 100644 index 00000000000..e7c67581ca2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-5.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden to + '0' (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = '0'; +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-6.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-6.js new file mode 100644 index 00000000000..566ebc0aba5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-6.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden with + obj with valueOf) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-7.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-7.js new file mode 100644 index 00000000000..61f662a35e2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-7.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden with + obj w/o valueOf (toString)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-8.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-8.js new file mode 100644 index 00000000000..dd3138a9cf4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-8.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden with + []) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = []; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-9.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-9.js new file mode 100644 index 00000000000..ce6126733fc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-7-9.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialValue if 'length' is 0 and + initialValue is present (subclassed Array, length overridden with + [0]) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = [0]; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +function cb() {} +assert.sameValue(f.reduce(cb, 1), 1, 'f.reduce(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-1.js new file mode 100644 index 00000000000..b40c37f51b7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-1.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - no observable effects occur if 'len' is 0 +---*/ + +var accessed = false; +var obj = { + length: 0 +}; +Object.defineProperty(obj, "0", { + get: function() { + accessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduce.call(obj, function() {}); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-2.js new file mode 100644 index 00000000000..ef43ebcde55 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-2.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - modifications to length don't change + number of iterations in step 9 +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + return idx; +} +var obj = { + 3: 12, + 4: 9, + length: 4 +}; +Object.defineProperty(obj, "2", { + get: function() { + obj.length = 10; + return 11; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn), 3, 'SendableArray.prototype.reduce.call(obj, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-3.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-3.js new file mode 100644 index 00000000000..84a0971b6b4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-3.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - loop is broken once 'kPresent' is true +---*/ + +var called = 0; +var testResult = false; +var firstCalled = 0; +var secondCalled = 0; +function callbackfn(prevVal, val, idx, obj) { + if (called === 0) { + testResult = (idx === 1); + } + called++; +} +var arr = [, , ]; +Object.defineProperty(arr, "0", { + get: function() { + firstCalled++; + return 11; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + secondCalled++; + return 9; + }, + configurable: true +}); +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); +assert.sameValue(firstCalled, 1, 'firstCalled'); +assert.sameValue(secondCalled, 1, 'secondCalled'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-ii-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-ii-1.js new file mode 100644 index 00000000000..be5b1303ef9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-ii-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - added properties in step 2 are visible + here +---*/ + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + obj[1] = "accumulator"; + return 3; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.reduce.call(obj, function() {}), "accumulator", 'SendableArray.prototype.reduce.call(obj, function () { })'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-ii-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-ii-2.js new file mode 100644 index 00000000000..5545bba0d26 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-ii-2.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleted properties in step 2 are visible + here +---*/ + +var obj = { + 1: "accumulator", + 2: "another" +}; +Object.defineProperty(obj, "length", { + get: function() { + delete obj[1]; + return 3; + }, + configurable: true +}); +assert.notSameValue(SendableArray.prototype.reduce.call(obj, function() {}), "accumulator", 'SendableArray.prototype.reduce.call(obj, function () { })'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-1.js new file mode 100644 index 00000000000..e70f3b43398 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-1.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} +var obj = { + 0: 0, + 1: 1, + 2: 2, + length: 2 +}; +SendableArray.prototype.reduce.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-10.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-10.js new file mode 100644 index 00000000000..2cd00b96ceb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-10.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - when element to be retrieved is own + accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} +var arr = [, 1, 2]; +Object.defineProperty(arr, "0", { + get: function() { + return 0; + }, + configurable: true +}); +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-11.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-11.js new file mode 100644 index 00000000000..80c04f0a9c3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-11.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "9"); + } +} +var proto = { + 0: 0, + 1: 1, + 2: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +Object.defineProperty(child, "0", { + get: function() { + return "9"; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-12.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-12.js new file mode 100644 index 00000000000..62c5c6da61a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-12.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "9"); + } +} +SendableArray.prototype[0] = 0; +var arr = [, 1, 2]; +Object.defineProperty(arr, "0", { + get: function() { + return "9"; + }, + configurable: true +}); +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-13.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-13.js new file mode 100644 index 00000000000..c2f65173a12 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-13.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "9"); + } +} +var proto = { + 1: 1, + 2: 2 +}; +Object.defineProperty(proto, "0", { + get: function() { + return 0; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +Object.defineProperty(child, "0", { + get: function() { + return "9"; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-14.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-14.js new file mode 100644 index 00000000000..97e2f63ad09 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-14.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "9"); + } +} +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 0; + }, + configurable: true +}); +var arr = [, 1, 2]; +Object.defineProperty(arr, "0", { + get: function() { + return "9"; + }, + configurable: true +}); +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-15.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-15.js new file mode 100644 index 00000000000..af51fdb801e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-15.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} +var proto = { + 1: 1, + 2: 2 +}; +Object.defineProperty(proto, "0", { + get: function() { + return 0; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +SendableArray.prototype.reduce.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-16.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-16.js new file mode 100644 index 00000000000..948291a4ac9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-16.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 0; + }, + configurable: true +}); +var arr = [, 1, 2]; +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-17.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-17.js new file mode 100644 index 00000000000..ff760fdbd25 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-17.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === undefined); + } +} +var obj = { + 1: 1, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "0", { + set: function() {}, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-18.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-18.js new file mode 100644 index 00000000000..8623565c076 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-18.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === undefined); + } +} +var arr = [, 1, 2]; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-19.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-19.js new file mode 100644 index 00000000000..84936da3d70 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-19.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === undefined); + } +} +Object.prototype[0] = 0; +var obj = { + 1: 1, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "0", { + set: function() {}, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-2.js new file mode 100644 index 00000000000..9dd26130d8a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-2.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} +var arr = [0, 1, 2]; +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-20.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-20.js new file mode 100644 index 00000000000..e16081bbc79 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-20.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === undefined); + } +} +SendableArray.prototype[0] = 0; +var arr = [, 1, 2]; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-21.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-21.js new file mode 100644 index 00000000000..d506b62a193 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-21.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === undefined); + } +} +var proto = { + 1: 1, + 2: 2 +}; +Object.defineProperty(proto, "0", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +SendableArray.prototype.reduce.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-22.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-22.js new file mode 100644 index 00000000000..45cfa457e4f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-22.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === undefined); + } +} +Object.defineProperty(SendableArray.prototype, "0", { + set: function() {}, + configurable: true +}); +var arr = [, 1, 2]; +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-25.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-25.js new file mode 100644 index 00000000000..54c44238618 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-25.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - This object is the Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} +var func = function(a, b, c) { + SendableArray.prototype.reduce.call(arguments, callbackfn); +}; +func(0, 1); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-26.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-26.js new file mode 100644 index 00000000000..634c26af23d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-26.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - This object is the Arguments object which + implements its own property get method (number of arguments equals + number of parameters) +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2) { + testResult = (prevVal === 1); + } +} +var func = function(a, b, c) { + delete arguments[0]; + SendableArray.prototype.reduce.call(arguments, callbackfn); +}; +func(0, 1, 2); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-27.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-27.js new file mode 100644 index 00000000000..6185b26ffad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-27.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - This object is the Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 3) { + testResult = (prevVal === 2); + } +} +var func = function(a, b, c) { + delete arguments[0]; + delete arguments[1]; + SendableArray.prototype.reduce.call(arguments, callbackfn); +}; +func(0, 1, 2, 3); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-28.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-28.js new file mode 100644 index 00000000000..03eb033029d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-28.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - applied to String object, which + implements its own property get method +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "0"); + } +} +var str = new String("012"); +SendableArray.prototype.reduce.call(str, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-29.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-29.js new file mode 100644 index 00000000000..81864e2780b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-29.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - applied to Function object which + implements its own property get method +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} +var obj = function(a, b, c) { + return a + b + c; +}; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +SendableArray.prototype.reduce.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-3.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-3.js new file mode 100644 index 00000000000..5fb1cbff7e0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-3.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "9"); + } +} +var proto = { + 0: 0, + 1: 1, + 2: 2, + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = "9"; +child[1] = "1"; +child.length = 3; +SendableArray.prototype.reduce.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-30.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-30.js new file mode 100644 index 00000000000..2279635b7db --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-30.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element changed by getter on current + iterations is observed in subsequent iterations on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var arr = [, , 2]; +var preIterVisible = false; +Object.defineProperty(arr, "0", { + get: function() { + preIterVisible = true; + return 0; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return 100; + } + }, + configurable: true +}); +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-31.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-31.js new file mode 100644 index 00000000000..0c98a17bb28 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-31.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element changed by getter on current + iterations is observed in subsequent iterations on an Array-like + object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var obj = { + length: 2 +}; +var preIterVisible = false; +Object.defineProperty(obj, "0", { + get: function() { + preIterVisible = true; + return 0; + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return 100; + } + }, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-32.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-32.js new file mode 100644 index 00000000000..50b3b8ce0d1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-32.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - exception in getter terminates iteration + on an Array-like object +---*/ + +var accessed = false; +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx >= 1) { + accessed = true; + testResult = (prevVal === 0); + } +} +var obj = { + 2: 2, + 1: 1, + length: 3 +}; +Object.defineProperty(obj, "0", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + SendableArray.prototype.reduce.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(testResult, false, 'testResult'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-33.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-33.js new file mode 100644 index 00000000000..154e4a7dafd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-33.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - exception in getter terminates iteration + on an Array +---*/ + +var accessed = false; +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx >= 1) { + accessed = true; + testResult = (prevVal === 0); + } +} +var arr = [, 1, 2]; +Object.defineProperty(arr, "0", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.reduce(callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(testResult, false, 'testResult'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-4.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-4.js new file mode 100644 index 00000000000..2b51ba04e23 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} +SendableArray.prototype[0] = "9"; +[0, 1, 2].reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-5.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-5.js new file mode 100644 index 00000000000..36ac7658aa3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-5.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "9"); + } +} +var proto = {}; +Object.defineProperty(proto, "0", { + get: function() { + return 0; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +Object.defineProperty(child, "0", { + value: "9", + configurable: true +}); +child[1] = "1"; +SendableArray.prototype.reduce.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-6.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-6.js new file mode 100644 index 00000000000..14d40cf153d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return "5"; + }, + configurable: true +}); +[0, 1, 2].reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-7.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-7.js new file mode 100644 index 00000000000..b7eae96b8c9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-7.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited data + property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} +var proto = { + 0: 0, + 1: 1, + 2: 2, + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +SendableArray.prototype.reduce.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-8.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-8.js new file mode 100644 index 00000000000..8c5162d8315 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-8.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited data + property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} +SendableArray.prototype[0] = 0; +SendableArray.prototype[1] = 1; +SendableArray.prototype[2] = 2; +[, , , ].reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-9.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-9.js new file mode 100644 index 00000000000..e0f97e2e2d9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-b-iii-1-9.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 0); + } +} +var obj = { + 1: 1, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "0", { + get: function() { + return 0; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-1.js new file mode 100644 index 00000000000..4ea20161ad7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-1.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError when Array is empty and + initialValue is not present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.reduce(callbackfn); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-2.js new file mode 100644 index 00000000000..cec800b6e1e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-2.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError when elements assigned + values are deleted by reducing array length and initialValue is + not present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} +var arr = new SendableArray(10); +arr[9] = 1; +arr.length = 5; +assert.throws(TypeError, function() { + arr.reduce(callbackfn); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-3.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-3.js new file mode 100644 index 00000000000..d99f243f476 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-3.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce throws TypeError when elements assigned + values are deleted and initialValue is not present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} +var arr = [1, 2, 3, 4, 5]; +delete arr[0]; +delete arr[1]; +delete arr[2]; +delete arr[3]; +delete arr[4]; +assert.throws(TypeError, function() { + arr.reduce(callbackfn); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-4.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-4.js new file mode 100644 index 00000000000..34c8373a3e7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce doesn't throw error when array has no own + properties but prototype contains a single property +---*/ + +var arr = [, , , ]; +try { + SendableArray.prototype[1] = "prototype"; + arr.reduce(function() {}); +} finally { + delete SendableArray.prototype[1]; +} diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-5.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-5.js new file mode 100644 index 00000000000..2681664e504 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-5.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - if exception occurs, it occurs after any + side-effects that might be produced by step 2 +---*/ + +var obj = {}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduce.call(obj, function() {}); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-6.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-6.js new file mode 100644 index 00000000000..404c0b3a450 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-6.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - if exception occurs, it occurs after any + side-effects that might be produced by step 3 +---*/ + +var obj = {}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduce.call(obj, function() {}); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-7.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-7.js new file mode 100644 index 00000000000..8dcc92cb4e5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-7.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the exception is not thrown if exception + was thrown by step 2 +---*/ + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.reduce.call(obj, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-8.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-8.js new file mode 100644 index 00000000000..ea37dab3633 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-8-c-8.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the exception is not thrown if exception + was thrown by step 3 +---*/ + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.reduce.call(obj, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-1.js new file mode 100644 index 00000000000..63bd18ae3d0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-1.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce doesn't consider new elements added to + array after it is called +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + arr[5] = 6; + arr[2] = 3; + return prevVal + curVal; +} +var arr = [1, 2, , 4, '5']; +assert.sameValue(arr.reduce(callbackfn), "105", 'arr.reduce(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-10.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-10.js new file mode 100644 index 00000000000..bf5d3f1095d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-10.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce called with an initial value doesn't + consider new elements added to array after it is called +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + arr[5] = 6; + arr[2] = 3; + return prevVal + curVal; +} +var arr = [1, 2, , 4, '5']; +assert.sameValue(arr.reduce(callbackfn, ""), "12345", 'arr.reduce(callbackfn, "")'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-2.js new file mode 100644 index 00000000000..77e3945499a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-2.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce considers new value of elements in array + after it is called +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + arr[3] = -2; + arr[4] = -1; + return prevVal + curVal; +} +var arr = [1, 2, 3, 4, 5]; +assert.sameValue(arr.reduce(callbackfn), 3, 'arr.reduce(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-3.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-3.js new file mode 100644 index 00000000000..a3db68e10be --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-3.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce doesn't visit deleted elements in array + after the call +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + delete arr[3]; + delete arr[4]; + return prevVal + curVal; +} +var arr = ['1', 2, 3, 4, 5]; +// two elements deleted +assert.sameValue(arr.reduce(callbackfn), "123", 'arr.reduce(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-4.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-4.js new file mode 100644 index 00000000000..31752c18005 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce doesn't visit deleted elements when + Array.length is decreased +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + arr.length = 2; + return prevVal + curVal; +} +var arr = [1, 2, 3, 4, 5]; +assert.sameValue(arr.reduce(callbackfn), 3, 'arr.reduce(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-5.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-5.js new file mode 100644 index 00000000000..5976cb236d6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-5.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn not called for array with one + element +---*/ + +var callCnt = 0; +function callbackfn(prevVal, curVal, idx, obj) +{ + callCnt++; + return 2; +} +var arr = [1]; +assert.sameValue(arr.reduce(callbackfn), 1, 'arr.reduce(callbackfn)'); +assert.sameValue(callCnt, 0, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-6.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-6.js new file mode 100644 index 00000000000..870fabf61fc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-6.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce visits deleted element in array after the + call when same index is also present in prototype +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + delete arr[3]; + delete arr[4]; + return prevVal + curVal; +} +SendableArray.prototype[4] = 5; +var arr = ['1', 2, 3, 4, 5]; +var res = arr.reduce(callbackfn); +delete SendableArray.prototype[4]; +//one element acually deleted +assert.sameValue(res, "1235", 'res'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-7.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-7.js new file mode 100644 index 00000000000..0226cb97622 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-7.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce stops calling callbackfn once the array is + deleted during the call +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + delete o.arr; + return prevVal + curVal; +} +var o = new Object(); +o.arr = ['1', 2, 3, 4, 5]; +assert.sameValue(o.arr.reduce(callbackfn), "12345", 'o.arr.reduce(callbackfn)'); +assert.sameValue(o.hasOwnProperty("arr"), false, 'o.hasOwnProperty("arr")'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-8.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-8.js new file mode 100644 index 00000000000..fa9118186a2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-8.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - no observable effects occur if 'len' is 0 +---*/ + +var accessed = false; +var callbackAccessed = false; +function callbackfn() { + callbackAccessed = true; +} +var obj = { + length: 0 +}; +Object.defineProperty(obj, "0", { + get: function() { + accessed = true; + return 10; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn, "initialValue"); +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(callbackAccessed, false, 'callbackAccessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-9.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-9.js new file mode 100644 index 00000000000..67500633822 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-9.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - modifications to length don't change + number of iterations in step 9 +---*/ + +var called = 0; +function callbackfn(accum, val, idx, obj) { + called++; + return accum + val; +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 2; + return 0; + }, + configurable: true +}); +var newAccum = arr.reduce(callbackfn, "initialValue"); +assert.sameValue(newAccum, "initialValue01", 'newAccum'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-1.js new file mode 100644 index 00000000000..adba265cce3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce returns initialvalue when Array is empty + and initialValue is present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} +var arr = new SendableArray(10); +assert.sameValue(arr.reduce(callbackfn, 5), 5, 'arr.reduce(callbackfn,5)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-10.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-10.js new file mode 100644 index 00000000000..49bb0eb9d1b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-10.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting property of prototype in step 8 + causes deleted index property not to be visited on an Array-like + Object +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 3) { + testResult = false; + } +} +var obj = { + 2: 2, + length: 20 +}; +Object.defineProperty(obj, "0", { + get: function() { + delete Object.prototype[3]; + return 0; + }, + configurable: true +}); +Object.prototype[3] = 1; +SendableArray.prototype.reduce.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-11.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-11.js new file mode 100644 index 00000000000..1c254574957 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-11.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting property of prototype in step 8 + causes deleted index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var arr = [, , , 3]; +Object.defineProperty(arr, "0", { + get: function() { + delete SendableArray.prototype[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-12.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-12.js new file mode 100644 index 00000000000..0f6a1257269 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-12.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property with prototype + property in step 8 causes prototype index property to be visited + on an Array-like object +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} +var obj = { + 0: 0, + 1: 111, + 4: 10, + length: 10 +}; +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +SendableArray.prototype.reduce.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-13.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-13.js new file mode 100644 index 00000000000..48f3a949e3b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-13.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property with prototype + property in step 8 causes prototype index property to be visited + on an Array +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} +var arr = [0, 111]; +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-14.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-14.js new file mode 100644 index 00000000000..8380e16ac63 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-14.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - decreasing length of array in step 8 + causes deleted index property not to be visited +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 2) { + testResult = false; + } +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 2; + return 0; + }, + configurable: true +}); +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-15.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-15.js new file mode 100644 index 00000000000..95908f0c98d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-15.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - decreasing length of array with prototype + property in step 8 causes prototype index property to be visited +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 2 && val === "prototype") { + testResult = true; + } +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-16.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-16.js new file mode 100644 index 00000000000..2ebf137a178 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-16.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - decreasing length of array in step 8 does + not delete non-configurable properties +flags: [noStrict] +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 2 && val === "unconfigurable") { + testResult = true; + } +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-17.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-17.js new file mode 100644 index 00000000000..5d23b3caddc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-17.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties added into own object are + visited on an Array-like object +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 3 && val === 3) { + testResult = true; + } +} +var obj = { + length: 5 +}; +Object.defineProperty(obj, "1", { + get: function() { + Object.defineProperty(obj, "3", { + get: function() { + return 3; + }, + configurable: true + }); + return 1; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-18.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-18.js new file mode 100644 index 00000000000..7332ce9966b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-18.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties added into own object are + visited on an Array +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +arr.reduce(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-19.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-19.js new file mode 100644 index 00000000000..724876740ae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-19.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties added to prototype are visited + on an Array-like object +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 6.99) { + testResult = true; + } +} +var obj = { + length: 6 +}; +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-2.js new file mode 100644 index 00000000000..ba533609fcd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-2.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - added properties in step 2 are visible + here +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 2 && val === "2") { + testResult = true; + } +} +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + obj[2] = "2"; + return 3; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-20.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-20.js new file mode 100644 index 00000000000..07c7706dcd1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-20.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties can be added to prototype are + visited on an Array +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 6.99) { + testResult = true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +arr.reduce(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-21.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-21.js new file mode 100644 index 00000000000..2992af8e2f1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-21.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property causes deleted + index property not to be visited on an Array-like object +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var obj = { + 5: 10, + length: 10 +}; +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-22.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-22.js new file mode 100644 index 00000000000..0e5bc8d948e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-22.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property causes deleted + index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var arr = [1, 2, 4]; +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +arr.reduce(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-23.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-23.js new file mode 100644 index 00000000000..bacaaac8dde --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-23.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting property of prototype causes + deleted index property not to be visited on an Array-like Object +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 3) { + testResult = false; + } +} +var obj = { + 2: 2, + length: 20 +}; +Object.defineProperty(obj, "0", { + get: function() { + delete Object.prototype[3]; + return 0; + }, + configurable: true +}); +Object.prototype[3] = 1; +SendableArray.prototype.reduce.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-24.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-24.js new file mode 100644 index 00000000000..c0993087d54 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-24.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting property of prototype causes + deleted index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var arr = [0, , , 3]; +Object.defineProperty(arr, "0", { + get: function() { + delete SendableArray.prototype[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +arr.reduce(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-25.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-25.js new file mode 100644 index 00000000000..ed369e6b129 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-25.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} +var obj = { + 0: 0, + 1: 111, + 4: 10, + length: 10 +}; +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +SendableArray.prototype.reduce.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-26.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-26.js new file mode 100644 index 00000000000..f06aa2c5bf1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-26.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} +var arr = [0, 111]; +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +arr.reduce(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-27.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-27.js new file mode 100644 index 00000000000..758d8bdcb5b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-27.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - decreasing length of array causes deleted + index property not to be visited +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 2) { + testResult = false; + } +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 2; + return 0; + }, + configurable: true +}); +arr.reduce(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-28.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-28.js new file mode 100644 index 00000000000..abef7bea4fb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-28.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - decreasing length of array with prototype + property causes prototype index property to be visited +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 2 && val === "prototype") { + testResult = true; + } +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +arr.reduce(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-29.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-29.js new file mode 100644 index 00000000000..600ce8c02df --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-29.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - decreasing length of array does not + delete non-configurable properties +flags: [noStrict] +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 2 && val === "unconfigurable") { + testResult = true; + } +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +arr.reduce(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-3.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-3.js new file mode 100644 index 00000000000..dce3dfffb97 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-3.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleted properties in step 2 are visible + here +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 2) { + testResult = false; + } +} +var obj = { + 2: "2", + 3: 10 +}; +Object.defineProperty(obj, "length", { + get: function() { + delete obj[2]; + return 5; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn, "initialValue"); +assert(accessed, 'accessed !== true'); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-4.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-4.js new file mode 100644 index 00000000000..f5d3f15ccba --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-4.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties added into own object in step + 8 are visited on an Array-like object +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 3 && val === 3) { + testResult = true; + } +} +var obj = { + length: 5 +}; +Object.defineProperty(obj, "1", { + get: function() { + Object.defineProperty(obj, "3", { + get: function() { + return 3; + }, + configurable: true + }); + return 1; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-5.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-5.js new file mode 100644 index 00000000000..203a5b5e7bf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-5.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties added into own object in step + 8 are visited on an Array +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 1) { + testResult = true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-6.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-6.js new file mode 100644 index 00000000000..6fd012f9aa7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-6.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties added to prototype in step 8 + are visited on an Array-like object +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 6.99) { + testResult = true; + } +} +var obj = { + length: 6 +}; +Object.defineProperty(obj, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-7.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-7.js new file mode 100644 index 00000000000..fa3bf912bd7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-7.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - properties added to prototype in step 8 + are visited on an Array +---*/ + +var testResult = false; +function callbackfn(accum, val, idx, obj) { + if (idx === 1 && val === 6.99) { + testResult = true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-8.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-8.js new file mode 100644 index 00000000000..f0c698fa625 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-8.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property in step 8 causes + deleted index property not to be visited on an Array-like object +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var obj = { + 5: 10, + length: 10 +}; +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-9.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-9.js new file mode 100644 index 00000000000..eccaacdd4e4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-b-9.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - deleting own property in step 8 causes + deleted index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(accum, val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var arr = [1, 2, 4]; +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +arr.reduce(callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-1.js new file mode 100644 index 00000000000..9fd40de4f9a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn not called for indexes never + been assigned values +---*/ + +var callCnt = 0; +function callbackfn(prevVal, curVal, idx, obj) +{ + callCnt++; + return curVal; +} +var arr = new SendableArray(10); +arr[0] = arr[1] = undefined; //explicitly assigning a value +assert.sameValue(arr.reduce(callbackfn), undefined, 'arr.reduce(callbackfn)'); +assert.sameValue(callCnt, 1, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-1.js new file mode 100644 index 00000000000..f28cdbcf7ee --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-1.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var obj = { + 0: 0, + 1: 1, + 2: 2, + length: 2 +}; +SendableArray.prototype.reduce.call(obj, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-10.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-10.js new file mode 100644 index 00000000000..dbd076afc77 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-10.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property on an Array +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true +}); +arr.reduce(callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-11.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-11.js new file mode 100644 index 00000000000..2a251665355 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-11.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "11"); + } +} +var proto = { + 0: 0, + 1: 1, + 2: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +Object.defineProperty(child, "1", { + get: function() { + return "11"; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(child, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-12.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-12.js new file mode 100644 index 00000000000..449f26ed06a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-12.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "11"); + } +} +SendableArray.prototype[1] = 1; +var arr = [0, , 2]; +Object.defineProperty(arr, "1", { + get: function() { + return "11"; + }, + configurable: true +}); +arr.reduce(callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-13.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-13.js new file mode 100644 index 00000000000..4536d2f6a74 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-13.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "11"); + } +} +var proto = { + 0: 0, + 2: 2 +}; +Object.defineProperty(proto, "1", { + get: function() { + return 1; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +Object.defineProperty(child, "1", { + get: function() { + return "11"; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(child, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-14.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-14.js new file mode 100644 index 00000000000..e6a1fddc869 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-14.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "11"); + } +} +Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 1; + }, + configurable: true +}); +var arr = [0, , 2]; +Object.defineProperty(arr, "1", { + get: function() { + return "11"; + }, + configurable: true +}); +arr.reduce(callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-15.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-15.js new file mode 100644 index 00000000000..019cd0d14e1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-15.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var proto = { + 0: 0, + 2: 2 +}; +Object.defineProperty(proto, "1", { + get: function() { + return 1; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +SendableArray.prototype.reduce.call(child, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-16.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-16.js new file mode 100644 index 00000000000..a676d4229c8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-16.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property on an Array +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 1; + }, + configurable: true +}); +var arr = [0, , 2, ]; +arr.reduce(callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-17.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-17.js new file mode 100644 index 00000000000..156e9dcbe01 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-17.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === undefined); + } +} +var obj = { + 0: 0, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-18.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-18.js new file mode 100644 index 00000000000..0fcae67fafe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-18.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === undefined); + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "1", { + set: function() {}, + configurable: true +}); +arr.reduce(callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-19.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-19.js new file mode 100644 index 00000000000..fffeb699f4d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-19.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === undefined); + } +} +Object.defineProperty(Object.prototype, "1", { + get: function() { + return 1; + }, + configurable: true +}); +var obj = { + 0: 0, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-2.js new file mode 100644 index 00000000000..8efa2f6fbc7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-2.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property on an Array +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var arr = [0, 1]; +arr.reduce(callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-20.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-20.js new file mode 100644 index 00000000000..9026ff0eed7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-20.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === undefined); + } +} +Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 11; + }, + configurable: true +}); +var arr = [0, , 2]; +Object.defineProperty(arr, "1", { + set: function() {}, + configurable: true +}); +arr.reduce(callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-21.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-21.js new file mode 100644 index 00000000000..9423d00330b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-21.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === undefined); + } +} +var proto = { + 0: 0, + 2: 2 +}; +Object.defineProperty(proto, "1", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +SendableArray.prototype.reduce.call(child, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-22.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-22.js new file mode 100644 index 00000000000..b4bd37feefc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-22.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === undefined); + } +} +Object.defineProperty(SendableArray.prototype, "1", { + set: function() {}, + configurable: true +}); +var arr = [0, , 2]; +arr.reduce(callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-25.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-25.js new file mode 100644 index 00000000000..734a47d5d03 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-25.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - This object is the Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var func = function(a, b, c) { + SendableArray.prototype.reduce.call(arguments, callbackfn, initialValue); +}; +func(0, 1); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-26.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-26.js new file mode 100644 index 00000000000..7ae03c84caf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-26.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - This object is the Arguments object which + implements its own property get method (number of arguments equals + number of parameters) +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2) { + testResult = (curVal === 2); + } +} +var func = function(a, b, c) { + SendableArray.prototype.reduce.call(arguments, callbackfn, initialValue); +}; +func(0, 1, 2); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-27.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-27.js new file mode 100644 index 00000000000..269fa614b15 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-27.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - This object is the Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 3) { + testResult = (curVal === 3); + } +} +var func = function(a, b, c) { + SendableArray.prototype.reduce.call(arguments, callbackfn, initialValue); +}; +func(0, 1, 2, 3); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-28.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-28.js new file mode 100644 index 00000000000..62fbdfda9e5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-28.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - applied to String object, which + implements its own property get method +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "1"); + } +} +var str = new String("012"); +SendableArray.prototype.reduce.call(str, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-29.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-29.js new file mode 100644 index 00000000000..9c5d30b68d8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-29.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - applied to Function object which + implements its own property get method +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var obj = function(a, b, c) { + return a + b + c; +}; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +SendableArray.prototype.reduce.call(obj, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-3.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-3.js new file mode 100644 index 00000000000..3b4c088ad16 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-3.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "11"); + } +} +var proto = { + 0: 0, + 1: 1, + 2: 2, + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[1] = "11"; +child[2] = "22"; +child.length = 3; +SendableArray.prototype.reduce.call(child, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-30.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-30.js new file mode 100644 index 00000000000..1b13b170286 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-30.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element changed by getter on previous + iterations is observed on an Array +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var arr = [, , 2]; +var preIterVisible = false; +Object.defineProperty(arr, "0", { + get: function() { + preIterVisible = true; + return 0; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return 100; + } + }, + configurable: true +}); +arr.reduce(callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-31.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-31.js new file mode 100644 index 00000000000..5ef2d806f8e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-31.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element changed by getter on previous + iterations is observed on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var obj = { + 2: 2, + length: 3 +}; +var preIterVisible = false; +Object.defineProperty(obj, "0", { + get: function() { + preIterVisible = true; + return 0; + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return "11"; + } + }, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-32.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-32.js new file mode 100644 index 00000000000..d2c0579a5c4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-32.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - unnhandled exceptions happened in getter + terminate iteration on an Array-like object +---*/ + +var accessed = false; +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx >= 1) { + accessed = true; + testResult = (curVal >= 1); + } +} +var obj = { + 0: 0, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + SendableArray.prototype.reduce.call(obj, callbackfn, initialValue); +}); +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(testResult, false, 'testResult'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-33.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-33.js new file mode 100644 index 00000000000..ef1d204031b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-33.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - unnhandled exceptions happened in getter + terminate iteration on an Array +---*/ + +var accessed = false; +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx >= 1) { + accessed = true; + testResult = (curVal >= 1); + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.reduce(callbackfn, initialValue); +}); +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(testResult, false, 'testResult'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-4.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-4.js new file mode 100644 index 00000000000..16b0c4e1d58 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-4.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +SendableArray.prototype[1] = "3"; +[0, 1, 2].reduce(callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-5.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-5.js new file mode 100644 index 00000000000..6d68b1727fa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-5.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0) { + testResult = (curVal === "9"); + } +} +var proto = {}; +Object.defineProperty(proto, "0", { + get: function() { + return 0; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +Object.defineProperty(child, "0", { + value: "9", + configurable: true +}); +child[1] = "1"; +SendableArray.prototype.reduce.call(child, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-6.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-6.js new file mode 100644 index 00000000000..5e953eb3a8c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-6.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return "9"; + }, + configurable: true +}); +[0, 1, 2].reduce(callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-7.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-7.js new file mode 100644 index 00000000000..bf7071f8505 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-7.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited data + property on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var proto = { + 0: 0, + 1: 1, + 2: 2, + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +SendableArray.prototype.reduce.call(child, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-8.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-8.js new file mode 100644 index 00000000000..356a54797c3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-8.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is inherited data + property on an Array +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +SendableArray.prototype[0] = 0; +SendableArray.prototype[1] = 1; +SendableArray.prototype[2] = 2; +[, , , ].reduce(callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-9.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-9.js new file mode 100644 index 00000000000..fcefb49b9e9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-i-9.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element to be retrieved is own accessor + property on an Array-like object +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var obj = { + 0: 0, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "1", { + get: function() { + return 1; + }, + configurable: true +}); +SendableArray.prototype.reduce.call(obj, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-1.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-1.js new file mode 100644 index 00000000000..97ea846a2d2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn called with correct parameters + (initialvalue not passed) +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + if (idx > 0 && obj[idx] === curVal && obj[idx - 1] === prevVal) + return curVal; + else + return false; +} +var arr = [0, 1, true, null, new Object(), "five"]; +assert.sameValue(arr.reduce(callbackfn), "five", 'arr.reduce(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-10.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-10.js new file mode 100644 index 00000000000..9d4682245fa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-10.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn is called with 1 formal + parameter +---*/ + +var result = false; +function callbackfn(prevVal) { + result = (prevVal === 1); +} +[11].reduce(callbackfn, 1); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-11.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-11.js new file mode 100644 index 00000000000..fc50e408a2f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-11.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn is called with 2 formal + parameter +---*/ + +var result = false; +function callbackfn(prevVal, curVal) { + result = (curVal > 10 && 1 === prevVal); +} +[11].reduce(callbackfn, 1); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-12.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-12.js new file mode 100644 index 00000000000..a6e8aa7fdf6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-12.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn is called with 3 formal + parameter +---*/ + +var result = false; +function callbackfn(prevVal, curVal, idx) { + result = (prevVal === 1 && arguments[3][idx] === curVal); +} +[11].reduce(callbackfn, 1); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-13.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-13.js new file mode 100644 index 00000000000..c8bb251cd2c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-13.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn is called with 4 formal + parameter +---*/ + +var result = false; +function callbackfn(prevVal, curVal, idx, obj) { + result = (prevVal === 1 && obj[idx] === curVal); +} +[11].reduce(callbackfn, 1); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-14.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-14.js new file mode 100644 index 00000000000..bf6f36e34a0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-14.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - callbackfn that uses arguments +---*/ + +var result = false; +function callbackfn() { + result = (arguments[0] === 1 && arguments[3][arguments[2]] === arguments[1]); +} +[11].reduce(callbackfn, 1); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-16.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-16.js new file mode 100644 index 00000000000..aefd1c8481f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-16.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - non-indexed properties are not called +---*/ + +var accessed = false; +var result1 = true; +var result2 = true; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (curVal === 8) { + result1 = false; + } + if (prevVal === 8) { + result2 = false; + } +} +var obj = { + 0: 11, + 10: 12, + non_index_property: 8, + length: 20 +}; +SendableArray.prototype.reduce.call(obj, callbackfn, 1); +assert(result1, 'result1 !== true'); +assert(result2, 'result2 !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-17.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-17.js new file mode 100644 index 00000000000..73d179cea9e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-17.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - 'accumulator' used for current iteration + is the result of previous iteration on an Array +---*/ + +var result = true; +var accessed = false; +var preIteration = 1; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (preIteration !== prevVal) { + result = false; + } + preIteration = curVal; + return curVal; +} +[11, 12, 13].reduce(callbackfn, 1); +assert(result, 'result !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-18.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-18.js new file mode 100644 index 00000000000..c30e6b2ec73 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-18.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'accumulator' used for first + iteration is the value of 'initialValue' when it is present on an + Array-like object +---*/ + +var result = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0) { + result = (arguments[0] === 1); + } +} +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +SendableArray.prototype.reduce.call(obj, callbackfn, 1); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-19.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-19.js new file mode 100644 index 00000000000..4e7dc7401c1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-19.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - value of 'accumulator' used for first + iteration is the value of least index property which is not + undefined when 'initialValue' is not present on an Array +---*/ + +var called = 0; +var result = false; +function callbackfn(prevVal, curVal, idx, obj) { + called++; + if (idx === 1) { + result = (prevVal === 11) && curVal === 9; + } +} +[11, 9].reduce(callbackfn); +assert(result, 'result !== true'); +assert.sameValue(called, 1, 'called'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-2.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-2.js new file mode 100644 index 00000000000..68fafffdd9c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-2.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn called with correct parameters + (initialvalue passed) +---*/ + +var bParCorrect = false; +function callbackfn(prevVal, curVal, idx, obj) +{ + if (idx === 0 && obj[idx] === curVal && prevVal === initialValue) + return curVal; + else if (idx > 0 && obj[idx] === curVal && obj[idx - 1] === prevVal) + return curVal; + else + return false; +} +var arr = [0, 1, true, null, new Object(), "five"]; +var initialValue = 5.5; +assert.sameValue(arr.reduce(callbackfn, initialValue), "five", 'arr.reduce(callbackfn,initialValue)'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-20.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-20.js new file mode 100644 index 00000000000..da4fb9aa75f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-20.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - undefined can be used as accumulator +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return typeof prevVal === "undefined"; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, undefined), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, undefined)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-21.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-21.js new file mode 100644 index 00000000000..559a1ae916d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-21.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - null can be used as accumulator +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === null; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, null), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, null)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-22.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-22.js new file mode 100644 index 00000000000..b45310ef1f8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-22.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - boolean primitive can be used as + accumulator +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === false; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, false), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, false)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-23.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-23.js new file mode 100644 index 00000000000..bbd39fb9295 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-23.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - number primitive can be used as + accumulator +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === 12; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, 12), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, 12)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-24.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-24.js new file mode 100644 index 00000000000..1008aa41ca2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-24.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - string primitive can be used as + accumulator +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === "hello_"; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, "hello_"), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, "hello_")'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-25.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-25.js new file mode 100644 index 00000000000..f18dd30bb65 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-25.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - Function object can be used as accumulator +---*/ + +var objFunction = function() {}; +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objFunction; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, objFunction), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, objFunction)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-26.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-26.js new file mode 100644 index 00000000000..f8ff88de4fb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-26.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - Array object can be used as accumulator +---*/ + +var objArray = new SendableArray(10); +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objArray; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, objArray), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, objArray)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-27.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-27.js new file mode 100644 index 00000000000..92983bde6b7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-27.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - String object can be used as accumulator +---*/ + +var objString = new String(); +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objString; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, objString), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, objString)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-28.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-28.js new file mode 100644 index 00000000000..64357e0cc90 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-28.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - Boolean object can be used as accumulator +---*/ + +var objBoolean = new Boolean(); +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objBoolean; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, objBoolean), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, objBoolean)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-29.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-29.js new file mode 100644 index 00000000000..9048373df5e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-29.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - Number object can be used as accumulator +---*/ + +var objNumber = new Number(); +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objNumber; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, objNumber), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, objNumber)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-3.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-3.js new file mode 100644 index 00000000000..94d2eafb87d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-3.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - callbackfn takes 4 arguments +---*/ + +var bCalled = false; +function callbackfn(prevVal, curVal, idx, obj) +{ + bCalled = true; + if (prevVal === true && arguments.length === 4) + return true; + else + return false; +} +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +assert.sameValue(arr.reduce(callbackfn, true), true, 'arr.reduce(callbackfn,true)'); +assert.sameValue(bCalled, true, 'bCalled'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-30.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-30.js new file mode 100644 index 00000000000..882a8c11758 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-30.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - the Math object can be used as accumulator +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === Math; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, Math), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, Math)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-31.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-31.js new file mode 100644 index 00000000000..fa9760fc213 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-31.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - Date object can be used as accumulator +---*/ + +var objDate = new Date(0); +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objDate; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, objDate), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, objDate)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-32.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-32.js new file mode 100644 index 00000000000..997413a3008 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-32.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - RegExp object can be used as accumulator +---*/ + +var objRegExp = new RegExp(); +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objRegExp; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, objRegExp), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, objRegExp)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-33.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-33.js new file mode 100644 index 00000000000..6f8adb65281 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-33.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - the JSON can be used as accumulator +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === JSON; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, JSON), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, JSON)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-34.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-34.js new file mode 100644 index 00000000000..e14a735e1d5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-34.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce - Error object can be used as accumulator +---*/ + +var objError = new RangeError(); +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objError; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, objError), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, objError)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-35.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-35.js new file mode 100644 index 00000000000..c9dbc582e2b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-35.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the Arguments object can be used as + accumulator +---*/ + +var accessed = false; +var arg; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === arg; +} +var obj = { + 0: 11, + length: 1 +}; +(function fun() { + arg = arguments; +}(10, 11, 12, 13)); +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, arg), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, arg)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-37.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-37.js new file mode 100644 index 00000000000..0c77456085f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-37.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - the global object can be used as + accumulator +---*/ + +var global = this; +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === global; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduce.call(obj, callbackfn, this), true, 'SendableArray.prototype.reduce.call(obj, callbackfn, this)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-4-s.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-4-s.js new file mode 100644 index 00000000000..77b786cccc2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-4-s.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - undefined passed as thisValue to strict + callbackfn +flags: [noStrict] +---*/ + +var innerThisCorrect = false; +function callbackfn(prevVal, curVal, idx, obj) +{ + "use strict"; + innerThisCorrect = this === undefined; + return true; +} +[0].reduce(callbackfn, true); +assert(innerThisCorrect, 'innerThisCorrect !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-4.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-4.js new file mode 100644 index 00000000000..468ff655579 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-4.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - k values are passed in acending numeric + order on an Array +---*/ + +var arr = [0, 1, 2]; +var lastIdx = 0; +var result = true; +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (lastIdx !== idx) { + result = false; + } else { + lastIdx++; + } +} +arr.reduce(callbackfn, 11); +assert(result, 'result !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-5.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-5.js new file mode 100644 index 00000000000..b4309300aae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-5.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - k values are accessed during each + iteration and not prior to starting the loop on an Array +---*/ + +var result = true; +var kIndex = []; +var called = 0; +//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(prevVal, curVal, idx, obj) { + //Each position should be visited one time, which means k is accessed one time during iterations. + called++; + if (typeof kIndex[idx] === "undefined") { + //when current position is visited, its previous index should has been visited. + if (idx !== 0 && typeof kIndex[idx - 1] === "undefined") { + result = false; + } + kIndex[idx] = 1; + } else { + result = false; + } +} +[11, 12, 13, 14].reduce(callbackfn, 1); +assert(result, 'result !== true'); +assert.sameValue(called, 4, 'called'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-7.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-7.js new file mode 100644 index 00000000000..545ce25b1bd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-7.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - unhandled exceptions happened in + callbackfn terminate iteration +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 0) { + accessed = true; + } + if (idx === 0) { + throw new Error("Exception occurred in callbackfn"); + } +} +var obj = { + 0: 11, + 4: 10, + 10: 8, + length: 20 +}; +assert.throws(Error, function() { + SendableArray.prototype.reduce.call(obj, callbackfn, 1); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-8.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-8.js new file mode 100644 index 00000000000..5e74f7b9ada --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-8.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - element changed by callbackfn on previous + iterations is observed +---*/ + +var result = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0) { + obj[idx + 1] = 8; + } + if (idx === 1) { + result = (curVal === 8); + } +} +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +SendableArray.prototype.reduce.call(obj, callbackfn, 1); +assert(result, 'result !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-9.js b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-9.js new file mode 100644 index 00000000000..c169843eb92 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/15.4.4.21-9-c-ii-9.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce - callbackfn is called with 0 formal + parameter +---*/ + +var called = 0; +function callbackfn() { + called++; +} +[11, 12].reduce(callbackfn, 1); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/reduce/call-with-boolean.js b/test/sendable/builtins/Array/prototype/reduce/call-with-boolean.js new file mode 100644 index 00000000000..2a9edfae6c6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/call-with-boolean.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: Array.prototype.reduce applied to boolean primitive +---*/ + +assert.sameValue( + SendableArray.prototype.reduce.call(true, () => {}, -1), + -1, + 'SendableArray.prototype.reduce.call(true, () => {}, -1) must return -1' +); +assert.sameValue( + SendableArray.prototype.reduce.call(false, () => {}, -1), + -1, + 'SendableArray.prototype.reduce.call(false, () => {}, -1) must return -1' +); diff --git a/test/sendable/builtins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js b/test/sendable/builtins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js new file mode 100644 index 00000000000..49a1e48b6e8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/callbackfn-resize-arraybuffer.js @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 3}); + var sample = new TA(buffer); + var expectedPrevs, expectedNexts, expectedIndices, expectedArrays; + var prevs, nexts, indices, arrays, result; + prevs = []; + nexts = []; + indices = []; + arrays = []; + result = SendableArray.prototype.reduce.call(sample, function(prev, next, index, array) { + if (prevs.length === 0) { + try { + buffer.resize(2 * BPE); + expectedPrevs = [262, 0]; + expectedNexts = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + expectedPrevs = [262, 0, 1]; + expectedNexts = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + prevs.push(prev); + nexts.push(next); + indices.push(index); + arrays.push(array); + return index; + }, 262); + assert.compareArray(prevs, expectedPrevs, 'prevs (shrink)'); + assert.compareArray(nexts, expectedNexts, 'nexts (shrink)'); + assert.compareArray(indices, expectedIndices, 'indices (shrink)'); + assert.compareArray(arrays, expectedArrays, 'arrays (shrink)'); + assert.sameValue(result, expectedIndices[expectedIndices.length - 1], 'result (shrink)'); + prevs = []; + nexts = []; + indices = []; + arrays = []; + result = SendableArray.prototype.reduce.call(sample, function(prev, next, index, array) { + if (prevs.length === 0) { + try { + buffer.resize(3 * BPE); + } catch (_) {} + } + prevs.push(prev); + nexts.push(next); + indices.push(index); + arrays.push(array); + return index; + }, 262); + assert.compareArray(prevs, expectedPrevs, 'prevs (grow)'); + assert.compareArray(nexts, expectedNexts, 'nexts (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, expectedIndices[expectedIndices.length - 1], 'result (grow)'); +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/length.js b/test/sendable/builtins/Array/prototype/reduce/length.js new file mode 100644 index 00000000000..126eb3b5a19 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/length.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + The "length" property of Array.prototype.reduce +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.reduce, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/name.js b/test/sendable/builtins/Array/prototype/reduce/name.js new file mode 100644 index 00000000000..3fd5ef6efc3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.prototype.reduce.name is "reduce". +info: | + Array.prototype.reduce ( callbackfn [ , initialValue ] ) + 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(SendableArray.prototype.reduce, "name", { + value: "reduce", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/not-a-constructor.js b/test/sendable/builtins/Array/prototype/reduce/not-a-constructor.js new file mode 100644 index 00000000000..4bc3c2cb892 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/not-a-constructor.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.reduce 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(SendableArray.prototype.reduce), + false, + 'isConstructor(SendableArray.prototype.reduce) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.reduce(() => {}, []); +}); + diff --git a/test/sendable/builtins/Array/prototype/reduce/prop-desc.js b/test/sendable/builtins/Array/prototype/reduce/prop-desc.js new file mode 100644 index 00000000000..8c1ce914c03 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + "reduce" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.reduce, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "reduce", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/reduce/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/Array/prototype/reduce/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..f7b7cdfecaa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.p.reduce behaves correctly when the resizable buffer is grown + mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(acc, n) { + // Returns true by default. + return CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +// Test for reduce. +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduce.call(fixedLength, ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduce.call(fixedLengthWithOffset, ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduce.call(lengthTracking, ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduce.call(lengthTrackingWithOffset, ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/reduce/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/Array/prototype/reduce/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..53df79662d8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-%array%.prototype.reduce +description: > + Array.p.reduce behaves correctly when the backing resizable buffer is shrunk + mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(acc, n) { + // Returns true by default. + return CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduce.call(fixedLength, ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 0, + 2 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduce.call(fixedLengthWithOffset, ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 4 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduce.call(lengthTracking, ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 0, + 2, + 4 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduce.call(lengthTrackingWithOffset, ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 4 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/reduce/resizable-buffer.js b/test/sendable/builtins/Array/prototype/reduce/resizable-buffer.js new file mode 100644 index 00000000000..a078dc2e8f0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduce/resizable-buffer.js @@ -0,0 +1,124 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduce +description: > + Array.p.reduce behaves correctly on TypedArrays backed by resizable buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + function ReduceCollecting(array) { + const reduceValues = []; + SendableArray.prototype.reduce.call(array, (acc, n) => { + reduceValues.push(n); + }, 'initial value'); + return ToNumbers(reduceValues); + } + assert.compareArray(ReduceCollecting(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ReduceCollecting(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(ReduceCollecting(lengthTracking), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ReduceCollecting(lengthTrackingWithOffset), [ + 4, + 6 + ]); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + assert.compareArray(ReduceCollecting(fixedLength), []); + assert.compareArray(ReduceCollecting(fixedLengthWithOffset), []); + assert.compareArray(ReduceCollecting(lengthTracking), [ + 0, + 2, + 4 + ]); + assert.compareArray(ReduceCollecting(lengthTrackingWithOffset), [4]); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.compareArray(ReduceCollecting(fixedLength), []); + assert.compareArray(ReduceCollecting(fixedLengthWithOffset), []); + assert.compareArray(ReduceCollecting(lengthTracking), [0]); + // Shrink to zero. + rab.resize(0); + assert.compareArray(ReduceCollecting(fixedLength), []); + assert.compareArray(ReduceCollecting(fixedLengthWithOffset), []); + assert.compareArray(ReduceCollecting(lengthTrackingWithOffset), []); + assert.compareArray(ReduceCollecting(lengthTracking), []); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + assert.compareArray(ReduceCollecting(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ReduceCollecting(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(ReduceCollecting(lengthTracking), [ + 0, + 2, + 4, + 6, + 8, + 10 + ]); + assert.compareArray(ReduceCollecting(lengthTrackingWithOffset), [ + 4, + 6, + 8, + 10 + ]); +} -- Gitee From ab942b5421bbac25b6250ceaea88192ccaa85e33 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 2 Jan 2025 14:23:52 +0800 Subject: [PATCH 62/93] add array-reduceright Signed-off-by: zhuzhihui7 --- .../prototype/reduceRight/15.4.4.22-1-1.js | 22 +++ .../prototype/reduceRight/15.4.4.22-1-10.js | 28 ++++ .../prototype/reduceRight/15.4.4.22-1-11.js | 29 ++++ .../prototype/reduceRight/15.4.4.22-1-12.js | 29 ++++ .../prototype/reduceRight/15.4.4.22-1-13.js | 28 ++++ .../prototype/reduceRight/15.4.4.22-1-14.js | 29 ++++ .../prototype/reduceRight/15.4.4.22-1-15.js | 29 ++++ .../prototype/reduceRight/15.4.4.22-1-2.js | 22 +++ .../prototype/reduceRight/15.4.4.22-1-3.js | 28 ++++ .../prototype/reduceRight/15.4.4.22-1-4.js | 30 +++++ .../prototype/reduceRight/15.4.4.22-1-5.js | 28 ++++ .../prototype/reduceRight/15.4.4.22-1-6.js | 30 +++++ .../prototype/reduceRight/15.4.4.22-1-7.js | 26 ++++ .../prototype/reduceRight/15.4.4.22-1-8.js | 27 ++++ .../prototype/reduceRight/15.4.4.22-1-9.js | 31 +++++ .../prototype/reduceRight/15.4.4.22-10-1.js | 32 +++++ .../prototype/reduceRight/15.4.4.22-10-2.js | 27 ++++ .../prototype/reduceRight/15.4.4.22-10-3.js | 24 ++++ .../prototype/reduceRight/15.4.4.22-10-4.js | 28 ++++ .../prototype/reduceRight/15.4.4.22-10-5.js | 27 ++++ .../prototype/reduceRight/15.4.4.22-10-6.js | 28 ++++ .../prototype/reduceRight/15.4.4.22-10-7.js | 28 ++++ .../prototype/reduceRight/15.4.4.22-10-8.js | 29 ++++ .../prototype/reduceRight/15.4.4.22-2-1.js | 34 +++++ .../prototype/reduceRight/15.4.4.22-2-10.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-2-11.js | 36 +++++ .../prototype/reduceRight/15.4.4.22-2-12.js | 43 ++++++ .../prototype/reduceRight/15.4.4.22-2-13.js | 38 ++++++ .../prototype/reduceRight/15.4.4.22-2-14.js | 32 +++++ .../prototype/reduceRight/15.4.4.22-2-17.js | 33 +++++ .../prototype/reduceRight/15.4.4.22-2-18.js | 30 +++++ .../prototype/reduceRight/15.4.4.22-2-19.js | 34 +++++ .../prototype/reduceRight/15.4.4.22-2-2.js | 28 ++++ .../prototype/reduceRight/15.4.4.22-2-3.js | 38 ++++++ .../prototype/reduceRight/15.4.4.22-2-4.js | 31 +++++ .../prototype/reduceRight/15.4.4.22-2-5.js | 46 +++++++ .../prototype/reduceRight/15.4.4.22-2-6.js | 37 +++++ .../prototype/reduceRight/15.4.4.22-2-7.js | 38 ++++++ .../prototype/reduceRight/15.4.4.22-2-8.js | 44 ++++++ .../prototype/reduceRight/15.4.4.22-2-9.js | 48 +++++++ .../prototype/reduceRight/15.4.4.22-3-1.js | 29 ++++ .../prototype/reduceRight/15.4.4.22-3-10.js | 31 +++++ .../prototype/reduceRight/15.4.4.22-3-11.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-3-12.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-3-13.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-3-14.js | 31 +++++ .../prototype/reduceRight/15.4.4.22-3-15.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-3-16.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-3-17.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-3-18.js | 32 +++++ .../prototype/reduceRight/15.4.4.22-3-19.js | 53 ++++++++ .../prototype/reduceRight/15.4.4.22-3-2.js | 31 +++++ .../prototype/reduceRight/15.4.4.22-3-20.js | 48 +++++++ .../prototype/reduceRight/15.4.4.22-3-21.js | 55 ++++++++ .../prototype/reduceRight/15.4.4.22-3-22.js | 48 +++++++ .../prototype/reduceRight/15.4.4.22-3-23.js | 61 +++++++++ .../prototype/reduceRight/15.4.4.22-3-24.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-3-25.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-3-3.js | 31 +++++ .../prototype/reduceRight/15.4.4.22-3-4.js | 31 +++++ .../prototype/reduceRight/15.4.4.22-3-5.js | 31 +++++ .../prototype/reduceRight/15.4.4.22-3-6.js | 40 ++++++ .../prototype/reduceRight/15.4.4.22-3-7.js | 40 ++++++ .../prototype/reduceRight/15.4.4.22-3-9.js | 31 +++++ .../prototype/reduceRight/15.4.4.22-4-1.js | 25 ++++ .../prototype/reduceRight/15.4.4.22-4-10.js | 34 +++++ .../prototype/reduceRight/15.4.4.22-4-11.js | 38 ++++++ .../prototype/reduceRight/15.4.4.22-4-12.js | 25 ++++ .../prototype/reduceRight/15.4.4.22-4-15.js | 45 +++++++ .../prototype/reduceRight/15.4.4.22-4-2.js | 25 ++++ .../prototype/reduceRight/15.4.4.22-4-3.js | 23 ++++ .../prototype/reduceRight/15.4.4.22-4-4.js | 25 ++++ .../prototype/reduceRight/15.4.4.22-4-5.js | 25 ++++ .../prototype/reduceRight/15.4.4.22-4-6.js | 25 ++++ .../prototype/reduceRight/15.4.4.22-4-7.js | 25 ++++ .../prototype/reduceRight/15.4.4.22-4-8.js | 37 +++++ .../prototype/reduceRight/15.4.4.22-4-9.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-5-1.js | 25 ++++ .../prototype/reduceRight/15.4.4.22-5-10.js | 37 +++++ .../prototype/reduceRight/15.4.4.22-5-11.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-5-12.js | 34 +++++ .../prototype/reduceRight/15.4.4.22-5-13.js | 38 ++++++ .../prototype/reduceRight/15.4.4.22-5-2.js | 30 +++++ .../prototype/reduceRight/15.4.4.22-5-3.js | 30 +++++ .../prototype/reduceRight/15.4.4.22-5-4.js | 30 +++++ .../prototype/reduceRight/15.4.4.22-5-5.js | 30 +++++ .../prototype/reduceRight/15.4.4.22-5-6.js | 35 +++++ .../prototype/reduceRight/15.4.4.22-5-7.js | 40 ++++++ .../prototype/reduceRight/15.4.4.22-5-8.js | 42 ++++++ .../prototype/reduceRight/15.4.4.22-5-9.js | 23 ++++ .../prototype/reduceRight/15.4.4.22-7-1.js | 23 ++++ .../prototype/reduceRight/15.4.4.22-7-10.js | 21 +++ .../prototype/reduceRight/15.4.4.22-7-11.js | 21 +++ .../prototype/reduceRight/15.4.4.22-7-2.js | 28 ++++ .../prototype/reduceRight/15.4.4.22-7-3.js | 28 ++++ .../prototype/reduceRight/15.4.4.22-7-4.js | 28 ++++ .../prototype/reduceRight/15.4.4.22-7-5.js | 28 ++++ .../prototype/reduceRight/15.4.4.22-7-6.js | 33 +++++ .../prototype/reduceRight/15.4.4.22-7-7.js | 38 ++++++ .../prototype/reduceRight/15.4.4.22-7-8.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-7-9.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-8-b-1.js | 36 +++++ .../prototype/reduceRight/15.4.4.22-8-b-2.js | 37 +++++ .../prototype/reduceRight/15.4.4.22-8-b-3.js | 50 +++++++ .../reduceRight/15.4.4.22-8-b-ii-1.js | 31 +++++ .../reduceRight/15.4.4.22-8-b-ii-2.js | 33 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-1.js | 34 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-10.js | 36 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-11.js | 45 +++++++ .../reduceRight/15.4.4.22-8-b-iii-1-12.js | 38 ++++++ .../reduceRight/15.4.4.22-8-b-iii-1-13.js | 50 +++++++ .../reduceRight/15.4.4.22-8-b-iii-1-14.js | 43 ++++++ .../reduceRight/15.4.4.22-8-b-iii-1-15.js | 43 ++++++ .../reduceRight/15.4.4.22-8-b-iii-1-16.js | 36 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-17.js | 38 ++++++ .../reduceRight/15.4.4.22-8-b-iii-1-18.js | 34 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-19.js | 40 ++++++ .../reduceRight/15.4.4.22-8-b-iii-1-2.js | 30 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-20.js | 36 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-21.js | 41 ++++++ .../reduceRight/15.4.4.22-8-b-iii-1-22.js | 34 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-25.js | 33 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-26.js | 33 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-27.js | 33 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-28.js | 30 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-29.js | 35 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-3.js | 42 ++++++ .../reduceRight/15.4.4.22-8-b-iii-1-30.js | 48 +++++++ .../reduceRight/15.4.4.22-8-b-iii-1-31.js | 51 +++++++ .../reduceRight/15.4.4.22-8-b-iii-1-32.js | 42 ++++++ .../reduceRight/15.4.4.22-8-b-iii-1-33.js | 38 ++++++ .../reduceRight/15.4.4.22-8-b-iii-1-4.js | 30 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-5.js | 47 +++++++ .../reduceRight/15.4.4.22-8-b-iii-1-6.js | 35 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-7.js | 38 ++++++ .../reduceRight/15.4.4.22-8-b-iii-1-8.js | 32 +++++ .../reduceRight/15.4.4.22-8-b-iii-1-9.js | 40 ++++++ .../prototype/reduceRight/15.4.4.22-8-c-1.js | 27 ++++ .../prototype/reduceRight/15.4.4.22-8-c-2.js | 30 +++++ .../prototype/reduceRight/15.4.4.22-8-c-3.js | 32 +++++ .../prototype/reduceRight/15.4.4.22-8-c-4.js | 28 ++++ .../prototype/reduceRight/15.4.4.22-8-c-5.js | 34 +++++ .../prototype/reduceRight/15.4.4.22-8-c-6.js | 38 ++++++ .../prototype/reduceRight/15.4.4.22-8-c-7.js | 31 +++++ .../prototype/reduceRight/15.4.4.22-8-c-8.js | 35 +++++ .../prototype/reduceRight/15.4.4.22-9-1.js | 30 +++++ .../prototype/reduceRight/15.4.4.22-9-2.js | 29 ++++ .../prototype/reduceRight/15.4.4.22-9-3.js | 30 +++++ .../prototype/reduceRight/15.4.4.22-9-4.js | 28 ++++ .../prototype/reduceRight/15.4.4.22-9-5.js | 30 +++++ .../prototype/reduceRight/15.4.4.22-9-6.js | 33 +++++ .../prototype/reduceRight/15.4.4.22-9-7.js | 29 ++++ .../prototype/reduceRight/15.4.4.22-9-8.js | 39 ++++++ .../prototype/reduceRight/15.4.4.22-9-9.js | 34 +++++ .../prototype/reduceRight/15.4.4.22-9-b-1.js | 25 ++++ .../prototype/reduceRight/15.4.4.22-9-b-10.js | 45 +++++++ .../prototype/reduceRight/15.4.4.22-9-b-11.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-12.js | 43 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-13.js | 39 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-14.js | 40 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-15.js | 44 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-16.js | 44 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-17.js | 44 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-18.js | 42 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-19.js | 44 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-2.js | 37 +++++ .../prototype/reduceRight/15.4.4.22-9-b-20.js | 42 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-21.js | 49 +++++++ .../prototype/reduceRight/15.4.4.22-9-b-22.js | 46 +++++++ .../prototype/reduceRight/15.4.4.22-9-b-23.js | 45 +++++++ .../prototype/reduceRight/15.4.4.22-9-b-24.js | 41 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-25.js | 44 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-26.js | 38 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-27.js | 40 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-28.js | 43 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-29.js | 44 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-3.js | 43 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-4.js | 44 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-5.js | 42 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-6.js | 44 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-7.js | 42 ++++++ .../prototype/reduceRight/15.4.4.22-9-b-8.js | 50 +++++++ .../prototype/reduceRight/15.4.4.22-9-b-9.js | 46 +++++++ .../prototype/reduceRight/15.4.4.22-9-c-1.js | 31 +++++ .../reduceRight/15.4.4.22-9-c-i-1.js | 35 +++++ .../reduceRight/15.4.4.22-9-c-i-10.js | 36 +++++ .../reduceRight/15.4.4.22-9-c-i-11.js | 45 +++++++ .../reduceRight/15.4.4.22-9-c-i-12.js | 38 ++++++ .../reduceRight/15.4.4.22-9-c-i-13.js | 50 +++++++ .../reduceRight/15.4.4.22-9-c-i-14.js | 43 ++++++ .../reduceRight/15.4.4.22-9-c-i-15.js | 43 ++++++ .../reduceRight/15.4.4.22-9-c-i-16.js | 36 +++++ .../reduceRight/15.4.4.22-9-c-i-17.js | 38 ++++++ .../reduceRight/15.4.4.22-9-c-i-18.js | 34 +++++ .../reduceRight/15.4.4.22-9-c-i-19.js | 40 ++++++ .../reduceRight/15.4.4.22-9-c-i-2.js | 30 +++++ .../reduceRight/15.4.4.22-9-c-i-20.js | 36 +++++ .../reduceRight/15.4.4.22-9-c-i-21.js | 41 ++++++ .../reduceRight/15.4.4.22-9-c-i-22.js | 34 +++++ .../reduceRight/15.4.4.22-9-c-i-25.js | 33 +++++ .../reduceRight/15.4.4.22-9-c-i-26.js | 33 +++++ .../reduceRight/15.4.4.22-9-c-i-27.js | 33 +++++ .../reduceRight/15.4.4.22-9-c-i-28.js | 30 +++++ .../reduceRight/15.4.4.22-9-c-i-29.js | 37 +++++ .../reduceRight/15.4.4.22-9-c-i-3.js | 42 ++++++ .../reduceRight/15.4.4.22-9-c-i-30.js | 48 +++++++ .../reduceRight/15.4.4.22-9-c-i-31.js | 50 +++++++ .../reduceRight/15.4.4.22-9-c-i-32.js | 42 ++++++ .../reduceRight/15.4.4.22-9-c-i-33.js | 38 ++++++ .../reduceRight/15.4.4.22-9-c-i-4.js | 30 +++++ .../reduceRight/15.4.4.22-9-c-i-5.js | 46 +++++++ .../reduceRight/15.4.4.22-9-c-i-6.js | 35 +++++ .../reduceRight/15.4.4.22-9-c-i-7.js | 38 ++++++ .../reduceRight/15.4.4.22-9-c-i-8.js | 32 +++++ .../reduceRight/15.4.4.22-9-c-i-9.js | 40 ++++++ .../reduceRight/15.4.4.22-9-c-ii-1.js | 30 +++++ .../reduceRight/15.4.4.22-9-c-ii-10.js | 28 ++++ .../reduceRight/15.4.4.22-9-c-ii-11.js | 30 +++++ .../reduceRight/15.4.4.22-9-c-ii-12.js | 32 +++++ .../reduceRight/15.4.4.22-9-c-ii-13.js | 32 +++++ .../reduceRight/15.4.4.22-9-c-ii-14.js | 23 ++++ .../reduceRight/15.4.4.22-9-c-ii-16.js | 35 +++++ .../reduceRight/15.4.4.22-9-c-ii-17.js | 34 +++++ .../reduceRight/15.4.4.22-9-c-ii-18.js | 33 +++++ .../reduceRight/15.4.4.22-9-c-ii-19.js | 32 +++++ .../reduceRight/15.4.4.22-9-c-ii-2.js | 33 +++++ .../reduceRight/15.4.4.22-9-c-ii-20.js | 30 +++++ .../reduceRight/15.4.4.22-9-c-ii-21.js | 30 +++++ .../reduceRight/15.4.4.22-9-c-ii-22.js | 32 +++++ .../reduceRight/15.4.4.22-9-c-ii-23.js | 32 +++++ .../reduceRight/15.4.4.22-9-c-ii-24.js | 32 +++++ .../reduceRight/15.4.4.22-9-c-ii-25.js | 33 +++++ .../reduceRight/15.4.4.22-9-c-ii-26.js | 33 +++++ .../reduceRight/15.4.4.22-9-c-ii-27.js | 33 +++++ .../reduceRight/15.4.4.22-9-c-ii-28.js | 33 +++++ .../reduceRight/15.4.4.22-9-c-ii-29.js | 33 +++++ .../reduceRight/15.4.4.22-9-c-ii-3.js | 31 +++++ .../reduceRight/15.4.4.22-9-c-ii-30.js | 32 +++++ .../reduceRight/15.4.4.22-9-c-ii-31.js | 33 +++++ .../reduceRight/15.4.4.22-9-c-ii-32.js | 33 +++++ .../reduceRight/15.4.4.22-9-c-ii-33.js | 30 +++++ .../reduceRight/15.4.4.22-9-c-ii-34.js | 33 +++++ .../reduceRight/15.4.4.22-9-c-ii-35.js | 36 +++++ .../reduceRight/15.4.4.22-9-c-ii-36.js | 33 +++++ .../reduceRight/15.4.4.22-9-c-ii-4.js | 36 +++++ .../reduceRight/15.4.4.22-9-c-ii-5.js | 42 ++++++ .../reduceRight/15.4.4.22-9-c-ii-6.js | 31 +++++ .../reduceRight/15.4.4.22-9-c-ii-7.js | 40 ++++++ .../reduceRight/15.4.4.22-9-c-ii-8.js | 36 +++++ .../reduceRight/15.4.4.22-9-c-ii-9.js | 28 ++++ .../reduceRight/call-with-boolean.js | 29 ++++ .../callbackfn-resize-arraybuffer.js | 84 ++++++++++++ .../reduceRight/length-near-integer-limit.js | 51 +++++++ .../Array/prototype/reduceRight/length.js | 39 ++++++ .../Array/prototype/reduceRight/name.js | 36 +++++ .../reduceRight/not-a-constructor.js | 38 ++++++ .../Array/prototype/reduceRight/prop-desc.js | 32 +++++ .../resizable-buffer-grow-mid-iteration.js | 92 +++++++++++++ .../resizable-buffer-shrink-mid-iteration.js | 104 ++++++++++++++ .../prototype/reduceRight/resizable-buffer.js | 127 ++++++++++++++++++ 260 files changed, 9505 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-14.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-15.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-14.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-17.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-18.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-19.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-14.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-15.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-16.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-17.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-18.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-19.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-20.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-21.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-22.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-23.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-24.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-25.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-15.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-14.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-15.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-16.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-17.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-18.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-19.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-20.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-21.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-22.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-25.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-26.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-27.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-28.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-29.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-30.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-31.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-32.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-33.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-14.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-15.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-16.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-17.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-18.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-19.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-20.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-21.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-22.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-23.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-24.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-25.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-26.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-27.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-28.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-29.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-14.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-15.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-16.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-17.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-18.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-19.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-20.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-21.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-22.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-25.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-26.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-27.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-28.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-29.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-30.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-31.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-32.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-33.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-1.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-10.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-11.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-12.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-13.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-14.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-16.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-17.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-18.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-19.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-2.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-20.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-21.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-22.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-23.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-24.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-25.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-26.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-27.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-28.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-29.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-3.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-30.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-31.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-32.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-33.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-34.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-35.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-36.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-4.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-5.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-6.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-7.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-8.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-9.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/callbackfn-resize-arraybuffer.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/length-near-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/length.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/name.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/reduceRight/resizable-buffer.js diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-1.js new file mode 100644 index 00000000000..6a2777f17d7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to undefined throws a TypeError +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.reduceRight.call(undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-10.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-10.js new file mode 100644 index 00000000000..88742cd6dc7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-10.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to the Math object +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return '[object Math]' === Object.prototype.toString.call(obj); +} +Math.length = 1; +Math[0] = 1; +assert(SendableArray.prototype.reduceRight.call(Math, callbackfn, 1), 'SendableArray.prototype.reduceRight.call(Math, callbackfn, 1) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-11.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-11.js new file mode 100644 index 00000000000..30ed4f1f01b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-11.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to Date object +---*/ + +var obj = new Date(0); +obj.length = 1; +obj[0] = 1; +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj instanceof Date; +} +assert(SendableArray.prototype.reduceRight.call(obj, callbackfn, 1), 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 1) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-12.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-12.js new file mode 100644 index 00000000000..5be042555fb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-12.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to RegExp object +---*/ + +var obj = new RegExp(); +obj.length = 1; +obj[0] = 1; +var accessed = false; +function callbackfn(prevVal, curVal, idx, o) { + accessed = true; + return o instanceof RegExp; +} +assert(SendableArray.prototype.reduceRight.call(obj, callbackfn, 1), 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 1) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-13.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-13.js new file mode 100644 index 00000000000..97409ec46ce --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-13.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to the JSON object +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return ('[object JSON]' === Object.prototype.toString.call(obj)); +} +JSON.length = 1; +JSON[0] = 1; +assert(SendableArray.prototype.reduceRight.call(JSON, callbackfn, 1), 'SendableArray.prototype.reduceRight.call(JSON, callbackfn, 1) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-14.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-14.js new file mode 100644 index 00000000000..bc82cd62011 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-14.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to Error object +---*/ + +var obj = new Error(); +obj.length = 1; +obj[0] = 1; +var accessed = false; +function callbackfn(prevVal, curVal, idx, o) { + accessed = true; + return o instanceof Error; +} +assert(SendableArray.prototype.reduceRight.call(obj, callbackfn, 1), 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 1) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-15.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-15.js new file mode 100644 index 00000000000..be5236f3ec6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-15.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to the Arguments object +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return '[object Arguments]' === Object.prototype.toString.call(obj); +} +var obj = (function() { + return arguments; +}("a", "b")); +assert(SendableArray.prototype.reduceRight.call(obj, callbackfn, "a"), 'SendableArray.prototype.reduceRight.call(obj, callbackfn, "a") !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-2.js new file mode 100644 index 00000000000..12b44c97e85 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-2.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to null throws a TypeError +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.reduceRight.call(null); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-3.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-3.js new file mode 100644 index 00000000000..c5303d0eddd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-3.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to boolean primitive +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj instanceof Boolean; +} +Boolean.prototype[0] = 1; +Boolean.prototype.length = 1; +assert(SendableArray.prototype.reduceRight.call(false, callbackfn, 1), 'SendableArray.prototype.reduceRight.call(false, callbackfn, 1) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-4.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-4.js new file mode 100644 index 00000000000..596a897ccc5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to Boolean object +---*/ + +var obj = new Boolean(true); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj instanceof Boolean; +} +assert(SendableArray.prototype.reduceRight.call(obj, callbackfn, 11), 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-5.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-5.js new file mode 100644 index 00000000000..90382626886 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-5.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to number primitive +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj instanceof Number; +} +Number.prototype[0] = 1; +Number.prototype.length = 1; +assert(SendableArray.prototype.reduceRight.call(2.5, callbackfn, 1), 'SendableArray.prototype.reduceRight.call(2.5, callbackfn, 1) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-6.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-6.js new file mode 100644 index 00000000000..20c18f6b8f9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-6.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to Number object +---*/ + +var obj = new Number(-128); +obj.length = 2; +obj[0] = 11; +obj[1] = 12; +var accessed = false; +function callbackfn(prevVal, curVal, idx, o) { + accessed = true; + return o instanceof Number; +} +assert(SendableArray.prototype.reduceRight.call(obj, callbackfn, 11), 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-7.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-7.js new file mode 100644 index 00000000000..e93a91ef610 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-7.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to string primitive +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj instanceof String; +} +assert(SendableArray.prototype.reduceRight.call("hello\nworld\\!", callbackfn, "h"), 'SendableArray.prototype.reduceRight.call("hello\nworld\\!", callbackfn, "h") !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-8.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-8.js new file mode 100644 index 00000000000..c0b5d1c2d99 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-8.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to String object +---*/ + +var obj = new String("hello\nworld\\!"); +var accessed = false; +function callbackfn(prevVal, curVal, idx, o) { + accessed = true; + return o instanceof String; +} +assert(SendableArray.prototype.reduceRight.call(obj, callbackfn, "h"), 'SendableArray.prototype.reduceRight.call(obj, callbackfn, "h") !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-9.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-9.js new file mode 100644 index 00000000000..e465096ea33 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-1-9.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight applied to Function object +---*/ + +var obj = function(a, b) { + return a + b; +}; +obj[0] = 11; +obj[1] = 9; +var accessed = false; +function callbackfn(prevVal, curVal, idx, o) { + accessed = true; + return o instanceof Function; +} +assert(SendableArray.prototype.reduceRight.call(obj, callbackfn, 11), 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-1.js new file mode 100644 index 00000000000..195181e7eb7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-1.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight doesn't mutate the Array on which it + is called on +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + return 1; +} +var srcArr = [1, 2, 3, 4, 5]; +srcArr.reduceRight(callbackfn); +assert.sameValue(srcArr[0], 1, 'srcArr[0]'); +assert.sameValue(srcArr[1], 2, 'srcArr[1]'); +assert.sameValue(srcArr[2], 3, 'srcArr[2]'); +assert.sameValue(srcArr[3], 4, 'srcArr[3]'); +assert.sameValue(srcArr[4], 5, 'srcArr[4]'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-2.js new file mode 100644 index 00000000000..50595c80355 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-2.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight reduces array in descending order of + indices +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + return prevVal + curVal; +} +var srcArr = ['1', '2', '3', '4', '5']; +assert.sameValue(srcArr.reduceRight(callbackfn), '54321', 'srcArr.reduceRight(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-3.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-3.js new file mode 100644 index 00000000000..01a2427747b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-3.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - subclassed array with length 1 +---*/ + +foo.prototype = [1]; +function foo() {} +var f = new foo(); +function cb() {} +assert.sameValue(f.reduceRight(cb), 1, 'f.reduceRight(cb)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-4.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-4.js new file mode 100644 index 00000000000..a588aee865b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - subclassed array with length more + than 1 +---*/ + +foo.prototype = new SendableArray(0, 1, 2, 3); +function foo() {} +var f = new foo(); +function cb(prevVal, curVal, idx, obj) { + return prevVal + curVal; +} +assert.sameValue(f.reduceRight(cb), 6, 'f.reduceRight(cb)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-5.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-5.js new file mode 100644 index 00000000000..520e9bb40e4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-5.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight reduces array in descending order of + indices(initialvalue present) +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + return prevVal + curVal; +} +var srcArr = ['1', '2', '3', '4', '5']; +assert.sameValue(srcArr.reduceRight(callbackfn, '6'), '654321', 'srcArr.reduceRight(callbackfn,"6")'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-6.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-6.js new file mode 100644 index 00000000000..c33a922cd56 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-6.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - subclassed array when initialvalue + provided +---*/ + +foo.prototype = new SendableArray(0, 1, 2, 3); +function foo() {} +var f = new foo(); +function cb(prevVal, curVal, idx, obj) { + return prevVal + curVal; +} +assert.sameValue(f.reduceRight(cb, "4"), "43210", 'f.reduceRight(cb,"4")'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-7.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-7.js new file mode 100644 index 00000000000..a07f910eb9f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-7.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - subclassed array when length to 1 + and initialvalue provided +---*/ + +foo.prototype = [1]; +function foo() {} +var f = new foo(); +function cb(prevVal, curVal, idx, obj) { + return prevVal + curVal; +} +assert.sameValue(f.reduceRight(cb, "4"), "41", 'f.reduceRight(cb,"4")'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-8.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-8.js new file mode 100644 index 00000000000..51455e879a2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-10-8.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight doesn't visit expandos +---*/ + +var callCnt = 0; +function callbackfn(prevVal, curVal, idx, obj) +{ + callCnt++; +} +var srcArr = ['1', '2', '3', '4', '5']; +srcArr["i"] = 10; +srcArr[true] = 11; +srcArr.reduceRight(callbackfn); +assert.sameValue(callCnt, 4, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-1.js new file mode 100644 index 00000000000..fcbcb1b3145 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-1.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an own data property +---*/ + +var accessed = false; +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2 +}; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} +assert(SendableArray.prototype.reduceRight.call(obj, callbackfn, 11), 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-10.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-10.js new file mode 100644 index 00000000000..44212fc35c8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-10.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an inherited accessor property +---*/ + +var accessed = false; +var Con = function() {}; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); +Con.prototype = proto; +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert(SendableArray.prototype.reduceRight.call(child, callbackfn, 11), 'SendableArray.prototype.reduceRight.call(child, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-11.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-11.js new file mode 100644 index 00000000000..7d1c1c6bbd7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-11.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an own accessor property without a get function +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return typeof obj.length === "undefined"; +} +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, 111), 111, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 111)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-12.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-12.js new file mode 100644 index 00000000000..48c8349ff99 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-12.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - 'length' is own accessor property + without a get function that overrides an inherited accessor + property +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return typeof obj.length === "undefined"; +} +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var obj = { + 0: 12, + 1: 13 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, 11), 11, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 11)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-13.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-13.js new file mode 100644 index 00000000000..ab3e333d579 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-13.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to the Array-like object that + 'length' is inherited accessor property without a get function +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return curVal > 10; +} +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 11; +child[1] = 12; +assert.sameValue(SendableArray.prototype.reduceRight.call(child, callbackfn, 111), 111, 'SendableArray.prototype.reduceRight.call(child, callbackfn, 111)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-14.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-14.js new file mode 100644 index 00000000000..233a6e1010d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-14.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to the Array-like object that + 'length' property doesn't exist +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return curVal > 10; +} +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, 111), 111, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 111)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-17.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-17.js new file mode 100644 index 00000000000..c651da04613 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-17.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to the Arguments object, which + implements its own property get method +---*/ + +var arg; +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} +var func = function(a, b) { + arg = arguments; + return SendableArray.prototype.reduceRight.call(arguments, callbackfn, 11); +}; +assert(func(12, 11), 'func(12, 11) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-18.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-18.js new file mode 100644 index 00000000000..19b1b13dcad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-18.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to String object, which + implements its own property get method +---*/ + +var accessed = false; +var str = new String("432"); +function callbackfn(preVal, curVal, idx, obj) { + accessed = true; + return obj.length === 3; +} +String.prototype[3] = "1"; +assert(SendableArray.prototype.reduceRight.call(str, callbackfn, 111), 'SendableArray.prototype.reduceRight.call(str, callbackfn, 111) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-19.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-19.js new file mode 100644 index 00000000000..e2ff07d0bb1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-19.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Function object, which + implements its own property get method +---*/ + +var accessed = false; +var fun = function(a, b) { + return a + b; +}; +fun[0] = 12; +fun[1] = 11; +fun[2] = 9; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} +assert(SendableArray.prototype.reduceRight.call(fun, callbackfn, 11), 'SendableArray.prototype.reduceRight.call(fun, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-2.js new file mode 100644 index 00000000000..9f51ff63dde --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - 'length' is own data property on an + Array +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} +assert([12, 11].reduceRight(callbackfn, 11), '[12, 11].reduceRight(callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-3.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-3.js new file mode 100644 index 00000000000..e5e570fc9a5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-3.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an own data property that overrides an inherited data property +---*/ + +var accessed = true; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} +var proto = { + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert(SendableArray.prototype.reduceRight.call(child, callbackfn), 'SendableArray.prototype.reduceRight.call(child, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-4.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-4.js new file mode 100644 index 00000000000..e8470f7c99d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-4.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - 'length' is own data property that + overrides an inherited data property on an Array +---*/ + +var accessed = false; +var arrProtoLen; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} +arrProtoLen = SendableArray.prototype.length; +SendableArray.prototype.length = 0; +assert([12, 11].reduceRight(callbackfn, 11), '[12, 11].reduceRight(callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-5.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-5.js new file mode 100644 index 00000000000..cd2f944a0b9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-5.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an own data property that overrides an inherited accessor + property +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert(SendableArray.prototype.reduceRight.call(child, callbackfn), 'SendableArray.prototype.reduceRight.call(child, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-6.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-6.js new file mode 100644 index 00000000000..8ebb401e66c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-6.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an inherited data property +---*/ + +var accessed = false; +var proto = { + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 12; +child[1] = 11; +child[2] = 9; +function callbackfn1(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} +assert(SendableArray.prototype.reduceRight.call(child, callbackfn1, 11), 'SendableArray.prototype.reduceRight.call(child, callbackfn1, 11) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-7.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-7.js new file mode 100644 index 00000000000..c2db4dd7128 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-7.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an own accessor property +---*/ + +var accessed = true; +var obj = {}; +obj[0] = 12; +obj[1] = 11; +obj[2] = 9; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); +assert(SendableArray.prototype.reduceRight.call(obj, callbackfn, 11), 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-8.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-8.js new file mode 100644 index 00000000000..4d2e0e4f213 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-8.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an own accessor property that overrides an inherited data + property +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} +var proto = { + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert(SendableArray.prototype.reduceRight.call(child, callbackfn, 11), 'SendableArray.prototype.reduceRight.call(child, callbackfn, 11) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-9.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-9.js new file mode 100644 index 00000000000..1179a8156f4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-2-9.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Array-like object, 'length' + is an own accessor property that overrides an inherited accessor + property +---*/ + +var accessed = false; +function callbackfn1(prevVal, curVal, idx, obj) { + accessed = true; + return obj.length === 2; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 12; +child[1] = 11; +child[2] = 9; +assert(SendableArray.prototype.reduceRight.call(child, callbackfn1, 111), 'SendableArray.prototype.reduceRight.call(child, callbackfn1, 111) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-1.js new file mode 100644 index 00000000000..624d13b5291 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-1.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - value of 'length' is undefined +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} +var obj = { + 0: 9, + length: undefined +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-10.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-10.js new file mode 100644 index 00000000000..1bfca3a272a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-10.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a number (value + is NaN) +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} +var obj = { + 0: 9, + length: NaN +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-11.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-11.js new file mode 100644 index 00000000000..ca992186d07 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-11.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string + containing a positive number +---*/ + +var testResult1 = true; +var testResult2 = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + if (idx === 1) { + testResult2 = true; + } + return false; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "2" +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-12.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-12.js new file mode 100644 index 00000000000..61c51837a5b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-12.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string + containing a negative number +---*/ + +var testResult1 = true; +var testResult2 = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + if (idx === 1) { + testResult2 = true; + } + return false; +} +var obj = { + 0: 11, + 1: 12, + 2: 9, + length: "-4294967294" +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +assert(testResult1, 'testResult1 !== true'); +assert.sameValue(testResult2, false, 'testResult2'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-13.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-13.js new file mode 100644 index 00000000000..52d574a0ed6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-13.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string + containing a decimal number +---*/ + +var testResult1 = true; +var testResult2 = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + if (idx === 1) { + testResult2 = true; + } + return false; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "2.5" +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-14.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-14.js new file mode 100644 index 00000000000..9cc8125f136 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-14.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string + containing -Infinity +---*/ + +var accessed2 = false; +function callbackfn2(prevVal, curVal, idx, obj) { + accessed2 = true; +} +var obj2 = { + 0: 9, + length: "-Infinity" +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj2, callbackfn2, 2), 2, 'SendableArray.prototype.reduceRight.call(obj2, callbackfn2, 2)'); +assert.sameValue(accessed2, false, 'accessed2'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-15.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-15.js new file mode 100644 index 00000000000..659530b6f3b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-15.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string + containing an exponential number +---*/ + +var testResult1 = true; +var testResult2 = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + if (idx === 1) { + testResult2 = true; + } + return false; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "2E0" +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-16.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-16.js new file mode 100644 index 00000000000..35d81a6889f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-16.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string + containing a hex number +---*/ + +var testResult1 = true; +var testResult2 = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + if (idx === 1) { + testResult2 = true; + } + return false; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "0x0002" +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-17.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-17.js new file mode 100644 index 00000000000..905837c6a8a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-17.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string + containing a number with leading zeros +---*/ + +var testResult1 = true; +var testResult2 = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + if (idx === 1) { + testResult2 = true; + } + return false; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: "0002.00" +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-18.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-18.js new file mode 100644 index 00000000000..c1e2fc50f9e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-18.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a string that + can't convert to a number +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} +var obj = { + 0: 9, + 1: 8, + length: "two" +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, 11), 11, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 11)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-19.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-19.js new file mode 100644 index 00000000000..fc13c1c7b7e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-19.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is an object which + has an own toString method +---*/ + +var testResult1 = true; +var testResult2 = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + if (idx === 1) { + testResult2 = true; + } + return false; +} +var toStringAccessed = false; +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: { + toString: function() { + toStringAccessed = true; + return '2'; + } + } +}; +// objects inherit the default valueOf() method from Object +// that simply returns itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); +assert(toStringAccessed, 'toStringAccessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-2.js new file mode 100644 index 00000000000..dd0b2930559 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-2.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to an Array-like object, + 'length' is 0 (length overridden to false(type conversion)) +---*/ + +var accessed = false; +function callbackfn(preVal, curVal, idx, obj) { + accessed = true; +} +var obj = { + 0: 9, + length: false +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-20.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-20.js new file mode 100644 index 00000000000..1ab2f64b36a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-20.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is an Object which + has an own valueOf method +---*/ + +var testResult1 = true; +var testResult2 = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + if (idx === 1) { + testResult2 = true; + } + return false; +} +var valueOfAccessed = false; +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: { + valueOf: function() { + valueOfAccessed = true; + return 2; + } + } +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-21.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-21.js new file mode 100644 index 00000000000..0ff7a07672a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-21.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - 'length' is an object that has an + own valueOf method that returns an object and toString method that + returns a string +---*/ + +var testResult1 = true; +var testResult2 = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + if (idx === 1) { + testResult2 = true; + } + return false; +} +var toStringAccessed = false; +var valueOfAccessed = false; +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: { + valueOf: function() { + valueOfAccessed = true; + return {}; + }, + toString: function() { + toStringAccessed = true; + return '2'; + } + } +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert(toStringAccessed, 'toStringAccessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-22.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-22.js new file mode 100644 index 00000000000..9bb8ad46431 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-22.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError exception when + 'length' is an object with toString and valueOf methods that don�t + return primitive values +---*/ + +var accessed = false; +var toStringAccessed = false; +var valueOfAccessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} +var obj = { + 0: 11, + 1: 12, + length: { + valueOf: function() { + valueOfAccessed = true; + return {}; + }, + toString: function() { + toStringAccessed = true; + return {}; + } + } +}; +assert.throws(TypeError, function() { + SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +}); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-23.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-23.js new file mode 100644 index 00000000000..10602e96792 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-23.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight uses inherited valueOf method when + 'length' is an object with an own toString and inherited valueOf + methods +---*/ + +var testResult1 = true; +var testResult2 = false; +var valueOfAccessed = false; +var toStringAccessed = false; +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + if (idx === 1) { + testResult2 = true; + } + return false; +} +Object.defineProperty(child, "toString", { + value: function() { + toStringAccessed = true; + return '1'; + } +}); +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: child +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-24.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-24.js new file mode 100644 index 00000000000..c816208e6d8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-24.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +var testResult1 = true; +var testResult2 = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + if (idx === 1) { + testResult2 = true; + } + return false; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: 2.685 +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-25.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-25.js new file mode 100644 index 00000000000..6a0b7d00633 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-25.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a negative + non-integer +---*/ + +var testResult1 = true; +var testResult2 = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + if (idx === 1) { + testResult2 = true; + } + return false; +} +var obj = { + 0: 12, + 1: 11, + 2: 9, + length: -4294967294.5 +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +assert(testResult1, 'testResult1 !== true'); +assert.sameValue(testResult2, false, 'testResult2'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-3.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-3.js new file mode 100644 index 00000000000..f4b1ee665f7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-3.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a number (value + is 0) +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} +var obj = { + 0: 9, + length: 0 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-4.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-4.js new file mode 100644 index 00000000000..4dcd7caa789 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-4.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a number (value + is +0) +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} +var obj = { + 0: 9, + length: +0 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-5.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-5.js new file mode 100644 index 00000000000..f52af506bae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-5.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a number (value + is -0) +---*/ + +var accessed = false; +function callbackfn(preVal, curVal, idx, obj) { + accessed = true; +} +var obj = { + 0: 9, + length: -0 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-6.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-6.js new file mode 100644 index 00000000000..03b5b8d1fe3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-6.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a number (value + is positive) +---*/ + +var testResult1 = true; +var testResult2 = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + if (idx === 1) { + testResult2 = true; + } + return false; +} +var obj = { + 1: 11, + 2: 9, + length: 2 +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +assert(testResult1, 'testResult1 !== true'); +assert(testResult2, 'testResult2 !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-7.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-7.js new file mode 100644 index 00000000000..e4b850a3b9c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-7.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a number (value + is negative) +---*/ + +var testResult1 = true; +var testResult2 = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx > 1) { + testResult1 = false; + } + if (idx === 1) { + testResult2 = true; + } + return false; +} +var obj = { + 1: 11, + 2: 9, + length: -4294967294 +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +assert(testResult1, 'testResult1 !== true'); +assert.sameValue(testResult2, false, 'testResult2'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-9.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-9.js new file mode 100644 index 00000000000..ee3f5bd7257 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-3-9.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'length' is a number (value + is -Infinity) +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; +} +var obj = { + 0: 9, + length: -Infinity +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, 1), 1, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-1.js new file mode 100644 index 00000000000..94d854e3f89 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if callbackfn is + undefined +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.reduceRight(); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-10.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-10.js new file mode 100644 index 00000000000..6c5ac7ada2e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-10.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the exception is not thrown if + exception was thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.reduceRight.call(obj, undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-11.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-11.js new file mode 100644 index 00000000000..a44c23aed23 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-11.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the exception is not thrown if + exception was thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.reduceRight.call(obj, undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-12.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-12.js new file mode 100644 index 00000000000..9358981adba --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-12.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - 'callbackfn' is a function +---*/ + +var initialValue = 0; +function callbackfn(accum, val, idx, obj) { + accum += val; + return accum; +} +assert.sameValue([11, 9].reduceRight(callbackfn, initialValue), 20, '[11, 9].reduceRight(callbackfn, initialValue)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-15.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-15.js new file mode 100644 index 00000000000..f518599e24b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-15.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - calling with no callbackfn is the + same as passing undefined for callbackfn +---*/ + +var obj = { + 10: 10 +}; +var lengthAccessed = false; +var loopAccessed = false; +Object.defineProperty(obj, "length", { + get: function() { + lengthAccessed = true; + return 20; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + loopAccessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduceRight.call(obj, undefined); +}); +assert(lengthAccessed, 'lengthAccessed !== true'); +assert.sameValue(loopAccessed, false, 'loopAccessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-2.js new file mode 100644 index 00000000000..e88027a3941 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws ReferenceError if callbackfn is + unreferenced +---*/ + +var arr = new SendableArray(10); +assert.throws(ReferenceError, function() { + arr.reduceRight(foo); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-3.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-3.js new file mode 100644 index 00000000000..fd59ac0dd90 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight throws TypeError if callbackfn is null +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.reduceRight(null); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-4.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-4.js new file mode 100644 index 00000000000..e25cf3e750f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-4.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if callbackfn is + boolean +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.reduceRight(true); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-5.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-5.js new file mode 100644 index 00000000000..981494bcd49 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-5.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if callbackfn is + number +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.reduceRight(5); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-6.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-6.js new file mode 100644 index 00000000000..2c4836e373e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-6.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if callbackfn is + string +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.reduceRight("abc"); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-7.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-7.js new file mode 100644 index 00000000000..9049367c65a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-7.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if callbackfn is + Object without [[Call]] internal method +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.reduceRight(new Object()); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-8.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-8.js new file mode 100644 index 00000000000..a99101dbb1a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-8.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduceRight.call(obj, null); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-9.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-9.js new file mode 100644 index 00000000000..6fd755c50c1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-4-9.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduceRight.call(obj, null); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-1.js new file mode 100644 index 00000000000..a54e069d6c2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (empty array), no initVal +---*/ + +function cb() {} +assert.throws(TypeError, function() { + [].reduceRight(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-10.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-10.js new file mode 100644 index 00000000000..ec343eb3b31 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-10.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - side-effects produced by step 2 when + an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 0; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduceRight.call(obj, function() {}); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-11.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-11.js new file mode 100644 index 00000000000..c22004fe129 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-11.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - side-effects produced by step 3 when + an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "0"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduceRight.call(obj, function() {}); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-12.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-12.js new file mode 100644 index 00000000000..3be3aa2a557 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-12.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the exception is not thrown if + exception was thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.reduceRight.call(obj, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-13.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-13.js new file mode 100644 index 00000000000..f58e532acbc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-13.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the exception is not thrown if + exception was thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.reduceRight.call(obj, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-2.js new file mode 100644 index 00000000000..a9cd275e1ab --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-2.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (subclassed Array, length overridden to null (type conversion)), + no initVal +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = null; +function cb() {} +assert.throws(TypeError, function() { + f.reduceRight(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-3.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-3.js new file mode 100644 index 00000000000..56f630b36e0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-3.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (subclassed Array, length overridden to false (type conversion)), + no initVal +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = false; +function cb() {} +assert.throws(TypeError, function() { + f.reduceRight(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-4.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-4.js new file mode 100644 index 00000000000..538688af144 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (subclassed Array, length overridden to 0 (type conversion)), no + initVal +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = 0; +function cb() {} +assert.throws(TypeError, function() { + f.reduceRight(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-5.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-5.js new file mode 100644 index 00000000000..3a6a56bb345 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-5.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (subclassed Array, length overridden to '0' (type conversion)), no + initVal +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = '0'; +function cb() {} +assert.throws(TypeError, function() { + f.reduceRight(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-6.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-6.js new file mode 100644 index 00000000000..6bba5583f1e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (subclassed Array, length overridden with obj with valueOf), no + initVal +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; +function cb() {} +assert.throws(TypeError, function() { + f.reduceRight(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-7.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-7.js new file mode 100644 index 00000000000..01ace1beed6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-7.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (subclassed Array, length overridden with obj w/o valueOf + (toString)), no initVal +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +function cb() {} +assert.throws(TypeError, function() { + f.reduceRight(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-8.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-8.js new file mode 100644 index 00000000000..b292dcc1fb0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-8.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError if 'length' is 0 + (subclassed Array, length overridden with []), no initVal +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = []; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +function cb() {} +assert.throws(TypeError, function() { + f.reduceRight(cb); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-9.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-9.js new file mode 100644 index 00000000000..7d516df1ee2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-5-9.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - 'initialValue' is returned if 'len' + is 0 and 'initialValue' is present +---*/ + +var initialValue = 10; +assert.sameValue([].reduceRight(function() {}, initialValue), initialValue, '[].reduceRight(function () { }, initialValue)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-1.js new file mode 100644 index 00000000000..e185d842066 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (empty array) +---*/ + +function cb() {} +assert.sameValue([].reduceRight(cb, 1), 1, '[].reduceRight(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-10.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-10.js new file mode 100644 index 00000000000..a73b2e6dcf4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-10.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - 'initialValue' is present +---*/ + +var str = "initialValue is present"; +assert.sameValue([].reduceRight(function() {}, str), str, '[].reduceRight(function () { }, str)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-11.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-11.js new file mode 100644 index 00000000000..efa90961417 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-11.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - 'initialValue' is not present +---*/ + +var str = "initialValue is not present"; +assert.sameValue([str].reduceRight(function() {}), str, '[str].reduceRight(function () { })'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-2.js new file mode 100644 index 00000000000..2d46cdec9e7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + to null (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = null; +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-3.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-3.js new file mode 100644 index 00000000000..34a57cf4caa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-3.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + to false (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = false; +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-4.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-4.js new file mode 100644 index 00000000000..480e6887885 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + to 0 (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = 0; +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-5.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-5.js new file mode 100644 index 00000000000..dae32eae32d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-5.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + to '0' (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = '0'; +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-6.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-6.js new file mode 100644 index 00000000000..c286a242a4b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-6.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + with obj with valueOf) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-7.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-7.js new file mode 100644 index 00000000000..d7acc1caefc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-7.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + with obj w/o valueOf (toString)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-8.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-8.js new file mode 100644 index 00000000000..b537aaffd8f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-8.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + with []) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = []; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-9.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-9.js new file mode 100644 index 00000000000..479092a0c4c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-7-9.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialValue if 'length' is 0 + and initialValue is present (subclassed Array, length overridden + with [0]) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = [0]; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +function cb() {} +assert.sameValue(f.reduceRight(cb, 1), 1, 'f.reduceRight(cb,1)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-1.js new file mode 100644 index 00000000000..1b1b28f7191 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-1.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - no observable effects occur if 'len' + is 0 +---*/ + +var accessed = false; +var obj = { + length: 0 +}; +Object.defineProperty(obj, "0", { + get: function() { + accessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduceRight.call(obj, function() {}); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-2.js new file mode 100644 index 00000000000..35b68af6bb2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-2.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - modifications to length don't change + number of iterations in step 9 +---*/ + +var called = 0; +function callbackfn(prevVal, curVal, idx, obj) { + called++; + return prevVal + curVal; +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "4", { + get: function() { + arr.length = 2; + return 10; + }, + configurable: true +}); +var preVal = arr.reduceRight(callbackfn); +assert.sameValue(preVal, 11, 'preVal'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-3.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-3.js new file mode 100644 index 00000000000..8e908a87c82 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-3.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - while loop is breaken once + 'kPresent' is true +---*/ + +var called = 0; +var testResult = false; +var firstCalled = 0; +var secondCalled = 0; +function callbackfn(prevVal, val, idx, obj) { + if (called === 0) { + testResult = (idx === 1); + } + called++; +} +var arr = [, , , ]; +Object.defineProperty(arr, "1", { + get: function() { + firstCalled++; + return 9; + }, + configurable: true +}); +Object.defineProperty(arr, "2", { + get: function() { + secondCalled++; + return 11; + }, + configurable: true +}); +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); +assert.sameValue(firstCalled, 1, 'firstCalled'); +assert.sameValue(secondCalled, 1, 'secondCalled'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-1.js new file mode 100644 index 00000000000..38e6c069216 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - added properties in step 2 are + visible here +---*/ + +var obj = {}; +function callbackfn(prevVal, curVal, idx, obj) {} +Object.defineProperty(obj, "length", { + get: function() { + obj[2] = "accumulator"; + return 3; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn), "accumulator", 'Array.prototype.reduceRight.call(obj, callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-2.js new file mode 100644 index 00000000000..6341909f142 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-ii-2.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleted properties in step 2 are + visible here +---*/ + +var obj = { + 2: "accumulator", + 3: "another" +}; +Object.defineProperty(obj, "length", { + get: function() { + delete obj[2]; + return 5; + }, + configurable: true +}); +assert.notSameValue(SendableArray.prototype.reduceRight.call(obj, function() {}), "accumulator", 'SendableArray.prototype.reduceRight.call(obj, function () { })'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-1.js new file mode 100644 index 00000000000..1f55460bb01 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-1.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0) { + testResult = (prevVal === 1); + } +} +var obj = { + 0: 0, + 1: 1, + length: 2 +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-10.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-10.js new file mode 100644 index 00000000000..df44993fa27 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-10.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2) { + testResult = (curVal === 2); + } +} +var arr = [0, 1, , 3]; +Object.defineProperty(arr, "2", { + get: function() { + return 2; + }, + configurable: true +}); +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-11.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-11.js new file mode 100644 index 00000000000..5c108de8106 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-11.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "20"); + } +} +var proto = { + 0: 0, + 1: 1, + 2: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +Object.defineProperty(child, "2", { + get: function() { + return "20"; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-12.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-12.js new file mode 100644 index 00000000000..7776c0008a8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-12.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited data property on an + Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "20"); + } +} +SendableArray.prototype[2] = 2; +var arr = [0, 1]; +Object.defineProperty(arr, "2", { + get: function() { + return "20"; + }, + configurable: true +}); +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-13.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-13.js new file mode 100644 index 00000000000..31a957b83b3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-13.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited accessor property on + an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "20"); + } +} +var proto = { + 0: 0, + 1: 1 +}; +Object.defineProperty(proto, "2", { + get: function() { + return 2; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +Object.defineProperty(child, "2", { + get: function() { + return "20"; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-14.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-14.js new file mode 100644 index 00000000000..87e1e2953bd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-14.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited accessor property on + an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "20"); + } +} +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return 2; + }, + configurable: true +}); +var arr = [0, 1, , ]; +Object.defineProperty(arr, "2", { + get: function() { + return "20"; + }, + configurable: true +}); +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-15.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-15.js new file mode 100644 index 00000000000..9e560791467 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-15.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} +var proto = { + 0: 0, + 1: 1 +}; +Object.defineProperty(proto, "2", { + get: function() { + return 2; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +SendableArray.prototype.reduceRight.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-16.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-16.js new file mode 100644 index 00000000000..68df5974022 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-16.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return 2; + }, + configurable: true +}); +var arr = [0, 1, , ]; +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-17.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-17.js new file mode 100644 index 00000000000..873b52dcfd9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-17.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof prevVal === "undefined"); + } +} +var obj = { + 0: 0, + 1: 1, + length: 3 +}; +Object.defineProperty(obj, "2", { + set: function() {}, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-18.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-18.js new file mode 100644 index 00000000000..2717fa89d42 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-18.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof prevVal === "undefined"); + } +} +var arr = [0, 1]; +Object.defineProperty(arr, "2", { + set: function() {}, + configurable: true +}); +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-19.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-19.js new file mode 100644 index 00000000000..61b0f7137b8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-19.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function that overrides an + inherited accessor property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof prevVal === "undefined"); + } +} +Object.prototype[2] = 2; +var obj = { + 0: 0, + 1: 1, + length: 3 +}; +Object.defineProperty(obj, "2", { + set: function() {}, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-2.js new file mode 100644 index 00000000000..5363de10f32 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-2.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} +var arr = [0, 1, 2]; +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-20.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-20.js new file mode 100644 index 00000000000..e1da6c0da2e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-20.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function that overrides an + inherited accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof prevVal === "undefined"); + } +} +SendableArray.prototype[2] = 2; +var arr = [0, 1]; +Object.defineProperty(arr, "2", { + set: function() {}, + configurable: true +}); +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-21.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-21.js new file mode 100644 index 00000000000..315b4845d85 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-21.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof prevVal === "undefined"); + } +} +var proto = { + 0: 0, + 1: 1 +}; +Object.defineProperty(proto, "2", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +SendableArray.prototype.reduceRight.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-22.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-22.js new file mode 100644 index 00000000000..1fb0ce6a563 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-22.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof prevVal === "undefined"); + } +} +Object.defineProperty(SendableArray.prototype, "2", { + set: function() {}, + configurable: true +}); +var arr = [0, 1, , ]; +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-25.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-25.js new file mode 100644 index 00000000000..2b2249800f4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-25.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - This object is the Arguments object + which implements its own property get method (number of arguments + is less than number of parameters) +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0) { + testResult = (prevVal === 1); + } +} +var func = function(a, b, c) { + SendableArray.prototype.reduceRight.call(arguments, callbackfn); +}; +func(0, 1); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-26.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-26.js new file mode 100644 index 00000000000..43c22e89dd8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-26.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - This object is the Arguments object + which implements its own property get method (number of arguments + equals number of parameters) +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} +var func = function(a, b, c) { + SendableArray.prototype.reduceRight.call(arguments, callbackfn); +}; +func(0, 1, 2); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-27.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-27.js new file mode 100644 index 00000000000..a8bf73ebe6c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-27.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - This object is the Arguments object + which implements its own property get method (number of arguments + is greater than number of parameters) +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2) { + testResult = (prevVal === 3); + } +} +var func = function(a, b, c) { + SendableArray.prototype.reduceRight.call(arguments, callbackfn); +}; +func(0, 1, 2, 3); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-28.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-28.js new file mode 100644 index 00000000000..b102f0cd1a8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-28.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to String object, which + implements its own property get method +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "2"); + } +} +var str = new String("012"); +SendableArray.prototype.reduceRight.call(str, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-29.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-29.js new file mode 100644 index 00000000000..13ec864cb27 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-29.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Function object which + implements its own property get method +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} +var obj = function(a, b, c) { + return a + b + c; +}; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +SendableArray.prototype.reduceRight.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-3.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-3.js new file mode 100644 index 00000000000..0611f34d993 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-3.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "20"); + } +} +var proto = { + 0: 0, + 1: 1, + 2: 2, + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[1] = "10"; +child[2] = "20"; +child.length = 3; +SendableArray.prototype.reduceRight.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-30.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-30.js new file mode 100644 index 00000000000..71c7e4e0242 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-30.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element changed by getter on current + iteration is observed in subsequent iterations on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1 && prevVal === 2); + } +} +var arr = [0]; +var preIterVisible = false; +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return "20"; + } + }, + configurable: true +}); +Object.defineProperty(arr, "2", { + get: function() { + preIterVisible = true; + return 2; + }, + configurable: true +}); +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-31.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-31.js new file mode 100644 index 00000000000..e1882af20b2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-31.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element changed by getter on current + iteration is observed subsequetly on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2 && curVal === 1); + } +} +var obj = { + 0: 0, + length: 3 +}; +var preIterVisible = false; +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return "20"; + } + }, + configurable: true +}); +Object.defineProperty(obj, "2", { + get: function() { + preIterVisible = true; + return 2; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-32.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-32.js new file mode 100644 index 00000000000..a011d397c0e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-32.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Exception in getter terminate + iteration on an Array-like object +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx <= 1) { + accessed = true; + } +} +var obj = { + 0: 0, + 1: 1, + length: 3 +}; +Object.defineProperty(obj, "2", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + SendableArray.prototype.reduceRight.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-33.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-33.js new file mode 100644 index 00000000000..abd31a8f98c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-33.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Exception in getter terminate + iteration on an Array +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx <= 1) { + accessed = true; + } +} +var arr = [0, 1]; +Object.defineProperty(arr, "2", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.reduceRight(callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-4.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-4.js new file mode 100644 index 00000000000..5265778bc0b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} +SendableArray.prototype[2] = "11"; +[0, 1, 2].reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-5.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-5.js new file mode 100644 index 00000000000..560f96f3727 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-5.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === "20"); + } +} +var proto = {}; +Object.defineProperty(proto, "2", { + get: function() { + return 11; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +child[0] = "0"; +child[1] = "1"; +Object.defineProperty(proto, "2", { + value: "20", + configurable: true +}); +SendableArray.prototype.reduceRight.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-6.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-6.js new file mode 100644 index 00000000000..cb2f08978d3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return "2"; + }, + configurable: true +}); +[0, 1, 2].reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-7.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-7.js new file mode 100644 index 00000000000..b32e632da57 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-7.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + data property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} +var proto = { + 0: 0, + 1: 1, + 2: 2, + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +SendableArray.prototype.reduceRight.call(child, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-8.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-8.js new file mode 100644 index 00000000000..9488ef5db9f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-8.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + data property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} +SendableArray.prototype[0] = 0; +SendableArray.prototype[1] = 1; +SendableArray.prototype[2] = 2; +[, , , ].reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-9.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-9.js new file mode 100644 index 00000000000..ad3408fc801 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-b-iii-1-9.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 2); + } +} +var obj = { + 0: 0, + 1: 1, + length: 3 +}; +Object.defineProperty(obj, "2", { + get: function() { + return 2; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-1.js new file mode 100644 index 00000000000..f85e98a8ff8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-1.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError when Array is empty + and initialValue is not present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.reduceRight(callbackfn); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-2.js new file mode 100644 index 00000000000..2bfe02085c6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-2.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError when elements + assigned values are deleted by reducign array length and + initialValue is not present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} +var arr = new SendableArray(10); +arr[9] = 1; +arr.length = 5; +assert.throws(TypeError, function() { + arr.reduceRight(callbackfn); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-3.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-3.js new file mode 100644 index 00000000000..b4d2711377b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-3.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight throws TypeError when elements + assigned values are deleted and initialValue is not present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} +var arr = [1, 2, 3, 4, 5]; +delete arr[0]; +delete arr[1]; +delete arr[2]; +delete arr[3]; +delete arr[4]; +assert.throws(TypeError, function() { + arr.reduceRight(callbackfn); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-4.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-4.js new file mode 100644 index 00000000000..f06b518690e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight doesn't throw error when array has no + own properties but prototype contains a single property +---*/ + +var arr = [, , , ]; +try { + SendableArray.prototype[1] = "prototype"; + arr.reduceRight(function() {}); +} finally { + delete SendableArray.prototype[1]; +} diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-5.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-5.js new file mode 100644 index 00000000000..4c77cc1ba6b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-5.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - side effects produced by step 2 are + visible when an exception occurs +---*/ + +var obj = {}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduceRight.call(obj, function() {}); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-6.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-6.js new file mode 100644 index 00000000000..b56c83a69a2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-6.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - side effects produced by step 3 are + visible when an exception occurs +---*/ + +var obj = {}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.reduceRight.call(obj, function() {}); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-7.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-7.js new file mode 100644 index 00000000000..3481ce46263 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-7.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the exception is not thrown if + exception was thrown by step 2 +---*/ + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.reduceRight.call(obj, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-8.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-8.js new file mode 100644 index 00000000000..aa7170d2178 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-8-c-8.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the exception is not thrown if + exception was thrown by step 3 +---*/ + +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.reduceRight.call(obj, function() {}); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-1.js new file mode 100644 index 00000000000..95e13c08937 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight doesn't consider new elements which + index is larger than array original length added to array after it + is called, consider new elements which index is smaller than array + length +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + arr[5] = 6; + arr[2] = 3; + return prevVal + curVal; +} +var arr = ['1', 2, , 4, '5']; +assert.sameValue(arr.reduceRight(callbackfn), "54321", 'arr.reduceRight(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-2.js new file mode 100644 index 00000000000..62e1104d24d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-2.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight considers new value of elements in + array after it is called +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + arr[3] = -2; + arr[0] = -1; + return prevVal + curVal; +} +var arr = [1, 2, 3, 4, 5]; +assert.sameValue(arr.reduceRight(callbackfn), 13, 'arr.reduceRight(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-3.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-3.js new file mode 100644 index 00000000000..48eeff452c2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-3.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight doesn't consider unvisited deleted + elements in array after the call +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + delete arr[1]; + delete arr[4]; + return prevVal + curVal; +} +var arr = ['1', 2, 3, 4, 5]; +// two elements deleted +assert.sameValue(arr.reduceRight(callbackfn), "121", 'arr.reduceRight(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-4.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-4.js new file mode 100644 index 00000000000..8159572549a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight doesn't consider unvisited deleted + elements when Array.length is decreased +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + arr.length = 2; + return prevVal + curVal; +} +var arr = [1, 2, 3, 4, 5]; +assert.sameValue(arr.reduceRight(callbackfn), 12, 'arr.reduceRight(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-5.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-5.js new file mode 100644 index 00000000000..f9f054972e0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-5.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn not called for array with + one element +---*/ + +var callCnt = 0; +function callbackfn(prevVal, curVal, idx, obj) +{ + callCnt++; + return 2; +} +var arr = [1]; +assert.sameValue(arr.reduceRight(callbackfn), 1, 'arr.reduceRight(callbackfn)'); +assert.sameValue(callCnt, 0, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-6.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-6.js new file mode 100644 index 00000000000..9e8288f21f0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-6.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight visits deleted element in array after + the call when same index is also present in prototype +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + delete arr[1]; + delete arr[2]; + return prevVal + curVal; +} +SendableArray.prototype[2] = 6; +var arr = ['1', 2, 3, 4, 5]; +var res = arr.reduceRight(callbackfn); +delete SendableArray.prototype[2]; +//one element deleted +assert.sameValue(res, "151", 'res'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-7.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-7.js new file mode 100644 index 00000000000..d83b491d052 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-7.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight not affect call when the array is + deleted during the call +---*/ + +function callbackfn(prevVal, curVal, idx, obj) { + delete o.arr; + return prevVal + curVal; +} +var o = new Object(); +o.arr = ['1', 2, 3, 4, 5]; +assert.sameValue(o.arr.reduceRight(callbackfn), "141", 'o.arr.reduceRight(callbackfn)'); +assert.sameValue(o.hasOwnProperty("arr"), false, 'o.hasOwnProperty("arr")'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-8.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-8.js new file mode 100644 index 00000000000..a1ae120a7a1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-8.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - no observable effects occur if 'len' + is 0 +---*/ + +var accessed = false; +var callbackAccessed = false; +function callbackfn() { + callbackAccessed = true; +} +var obj = { + length: 0 +}; +Object.defineProperty(obj, "5", { + get: function() { + accessed = true; + return 10; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +assert.sameValue(accessed, false, 'accessed'); +assert.sameValue(callbackAccessed, false, 'callbackAccessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-9.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-9.js new file mode 100644 index 00000000000..11e24e09a95 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-9.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - modifications to length will change + number of iterations +---*/ + +var called = 0; +function callbackfn(preVal, val, idx, obj) { + called++; +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "4", { + get: function() { + arr.length = 2; + }, + configurable: true +}); +arr.reduceRight(callbackfn, "initialValue"); +assert.sameValue(called, 3, 'called'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-1.js new file mode 100644 index 00000000000..aff534e37f8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight returns initialvalue when Array is + empty and initialValue is not present +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{} +var arr = new SendableArray(10); +assert.sameValue(arr.reduceRight(callbackfn, 5), 5, 'arr.reduceRight(callbackfn,5)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-10.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-10.js new file mode 100644 index 00000000000..ba64c54089a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-10.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting property of prototype in + step 8 causes deleted index property not to be visited on an + Array-like Object +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(preVal, val, idx, obj) { + accessed = true; + if (idx === 3) { + testResult = false; + } +} +var obj = { + 2: 2, + length: 20 +}; +Object.defineProperty(obj, "5", { + get: function() { + delete Object.prototype[3]; + return 0; + }, + configurable: true +}); +Object.prototype[3] = 1; +SendableArray.prototype.reduceRight.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-11.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-11.js new file mode 100644 index 00000000000..725fd9284fb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-11.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting property of prototype in + step 8 causes deleted index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var arr = [0, , , ]; +Object.defineProperty(arr, "3", { + get: function() { + delete SendableArray.prototype[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-12.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-12.js new file mode 100644 index 00000000000..43b623f3012 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-12.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property with prototype + property in step 8 causes prototype index property to be visited + on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1 && curVal === 1) { + testResult = true; + } +} +var obj = { + 0: 0, + 1: 111, + length: 10 +}; +Object.defineProperty(obj, "4", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +SendableArray.prototype.reduceRight.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-13.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-13.js new file mode 100644 index 00000000000..096661c4b3c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-13.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property with prototype + property in step 8 causes prototype index property to be visited + on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1 && curVal === 1) { + testResult = true; + } +} +var arr = [0, 111]; +Object.defineProperty(arr, "2", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-14.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-14.js new file mode 100644 index 00000000000..01064621f88 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-14.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - decreasing length of array in step 8 + causes deleted index property not to be visited +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 2) { + testResult = false; + } +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 0; + }, + configurable: true +}); +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-15.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-15.js new file mode 100644 index 00000000000..87b4f5d27bb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-15.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - decreasing length of array with + prototype property in step 8 causes prototype index property to be + visited +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2 && curVal === "prototype") { + testResult = true; + } +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-16.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-16.js new file mode 100644 index 00000000000..8ab43cf8708 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-16.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - decreasing length of array in step 8 + does not delete non-configurable properties +flags: [noStrict] +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2 && curVal === "unconfigurable") { + testResult = true; + } +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-17.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-17.js new file mode 100644 index 00000000000..3b3f5ab618f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-17.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added into own object are + visited on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0 && curVal === 0) { + testResult = true; + } +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + get: function() { + Object.defineProperty(obj, "0", { + get: function() { + return 0; + }, + configurable: true + }); + return 1; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-18.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-18.js new file mode 100644 index 00000000000..ea7308fd738 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-18.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added into own object are + visited on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1 && curVal === 1) { + testResult = true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "2", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-19.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-19.js new file mode 100644 index 00000000000..cf8c3a132ad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-19.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added to prototype are + visited on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1 && curVal === 6.99) { + testResult = true; + } +} +var obj = { + length: 6 +}; +Object.defineProperty(obj, "2", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-2.js new file mode 100644 index 00000000000..b71381ed3c9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-2.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - added properties in step 2 are + visible here +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2 && curVal === "2") { + testResult = true; + } +} +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + obj[2] = "2"; + return 3; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-20.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-20.js new file mode 100644 index 00000000000..69a427de1be --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-20.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added to prototype can be + visited on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1 && curVal === 6.99) { + testResult = true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "2", { + get: function() { + Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-21.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-21.js new file mode 100644 index 00000000000..1abcaa88f14 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-21.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property causes deleted + index property not to be visited on an Array-like object +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var obj = { + 0: 10, + length: 10 +}; +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); +Object.defineProperty(obj, "5", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-22.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-22.js new file mode 100644 index 00000000000..84d64a4eb1e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-22.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property causes deleted + index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var arr = [1, 2, 4]; +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); +Object.defineProperty(arr, "2", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-23.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-23.js new file mode 100644 index 00000000000..dbf0ab8a622 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-23.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting property of prototype + causes deleted index property not to be visited on an Array-like + Object +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 3) { + testResult = false; + } +} +var obj = { + 2: 2, + length: 20 +}; +Object.defineProperty(obj, "5", { + get: function() { + delete Object.prototype[3]; + return 0; + }, + configurable: true +}); +Object.prototype[3] = 1; +SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-24.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-24.js new file mode 100644 index 00000000000..40b1feff44b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-24.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting property of prototype + causes deleted index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var arr = [0, , , ]; +Object.defineProperty(arr, "3", { + get: function() { + delete SendableArray.prototype[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-25.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-25.js new file mode 100644 index 00000000000..3e9ef799be2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-25.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1 && curVal === 1) { + testResult = true; + } +} +var obj = { + 0: 0, + 1: 111, + 4: 10, + length: 10 +}; +Object.defineProperty(obj, "4", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-26.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-26.js new file mode 100644 index 00000000000..9996e467273 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-26.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1 && curVal === 1) { + testResult = true; + } +} +var arr = [0, 111]; +Object.defineProperty(arr, "2", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-27.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-27.js new file mode 100644 index 00000000000..e5adc799879 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-27.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - decreasing length of array causes + deleted index property not to be visited +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 2) { + testResult = false; + } +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 0; + }, + configurable: true +}); +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-28.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-28.js new file mode 100644 index 00000000000..e58c9548551 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-28.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - decreasing length of array with + prototype property causes prototype index property to be visited +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2 && curVal === "prototype") { + testResult = true; + } +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-29.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-29.js new file mode 100644 index 00000000000..15f874d1cc1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-29.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - decreasing length of array does not + delete non-configurable properties +flags: [noStrict] +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2 && curVal === "unconfigurable") { + testResult = true; + } +} +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); +Object.defineProperty(arr, "3", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-3.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-3.js new file mode 100644 index 00000000000..bd6158ccbfb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-3.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleted properties in step 2 are + visible here +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(preVal, curVal, idx, obj) { + accessed = true; + if (idx === 2) { + testResult = false; + } +} +var obj = { + 2: "2", + 3: 10 +}; +Object.defineProperty(obj, "length", { + get: function() { + delete obj[2]; + return 5; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +assert(accessed, 'accessed !== true'); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-4.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-4.js new file mode 100644 index 00000000000..f8f14183cd4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-4.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added into own object in + step 8 can be visited on an Array-like object +---*/ + +var testResult = false; +function callbackfn(preVal, curVal, idx, obj) { + if (idx === 0 && curVal === 0) { + testResult = true; + } +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + get: function() { + Object.defineProperty(obj, "0", { + get: function() { + return 0; + }, + configurable: true + }); + return 1; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-5.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-5.js new file mode 100644 index 00000000000..fc6d287de67 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-5.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added into own object in + step 8 can be visited on an Array +---*/ + +var testResult = false; +function callbackfn(preVal, curVal, idx, obj) { + if (idx === 1 && curVal === 1) { + testResult = true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "2", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-6.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-6.js new file mode 100644 index 00000000000..b2d7f315a19 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-6.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added to prototype in + step 8 visited on an Array-like object +---*/ + +var testResult = false; +function callbackfn(preVal, curVal, idx, obj) { + if (idx === 1 && curVal === 6.99) { + testResult = true; + } +} +var obj = { + length: 6 +}; +Object.defineProperty(obj, "2", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-7.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-7.js new file mode 100644 index 00000000000..370b889918d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-7.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - properties added to prototype in + step 8 visited on an Array +---*/ + +var testResult = false; +function callbackfn(preVal, curVal, idx, obj) { + if (idx === 1 && curVal === 6.99) { + testResult = true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "2", { + get: function() { + Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-8.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-8.js new file mode 100644 index 00000000000..9e87fdb900e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-8.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property in step 8 + causes deleted index property not to be visited on an Array-like + object +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(preVal, val, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var obj = { + 0: 10, + length: 10 +}; +Object.defineProperty(obj, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); +Object.defineProperty(obj, "5", { + get: function() { + delete obj[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-9.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-9.js new file mode 100644 index 00000000000..db22f1a17b7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-b-9.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - deleting own property in step 8 + causes deleted index property not to be visited on an Array +---*/ + +var accessed = false; +var testResult = true; +function callbackfn(preVal, curVal, idx, obj) { + accessed = true; + if (idx === 1) { + testResult = false; + } +} +var arr = [0]; +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); +Object.defineProperty(arr, "2", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-1.js new file mode 100644 index 00000000000..4bf6cd70837 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn not called for indexes + never been assigned values +---*/ + +var callCnt = 0; +function callbackfn(prevVal, curVal, idx, obj) +{ + callCnt++; + return curVal; +} +var arr = new SendableArray(10); +arr[0] = arr[1] = undefined; //explicitly assigning a value +assert.sameValue(arr.reduceRight(callbackfn), undefined, 'arr.reduceRight(callbackfn)'); +assert.sameValue(callCnt, 1, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-1.js new file mode 100644 index 00000000000..04d4b5a8d69 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-1.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0) { + testResult = (curVal === 0); + } +} +var obj = { + 0: 0, + 1: 1, + 2: 2, + length: 2 +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-10.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-10.js new file mode 100644 index 00000000000..7efef39e83b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-10.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true +}); +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-11.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-11.js new file mode 100644 index 00000000000..543d04f93e1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-11.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "1"); + } +} +var proto = { + 0: 0, + 1: 11, + 2: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +Object.defineProperty(child, "1", { + get: function() { + return "1"; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(child, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-12.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-12.js new file mode 100644 index 00000000000..f54f93ef725 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-12.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited data property on an + Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "1"); + } +} +SendableArray.prototype[1] = 11; +var arr = [0, , 2]; +Object.defineProperty(arr, "1", { + get: function() { + return "1"; + }, + configurable: true +}); +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-13.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-13.js new file mode 100644 index 00000000000..f9de2afd081 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-13.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited accessor property on + an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "1"); + } +} +var proto = { + 0: 0, + 2: 2 +}; +Object.defineProperty(proto, "1", { + get: function() { + return 11; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +Object.defineProperty(child, "1", { + get: function() { + return "1"; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(child, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-14.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-14.js new file mode 100644 index 00000000000..a8a54e85488 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-14.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property that overrides an inherited accessor property on + an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "1"); + } +} +Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 11; + }, + configurable: true +}); +var arr = [0, , 2]; +Object.defineProperty(arr, "1", { + get: function() { + return "1"; + }, + configurable: true +}); +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-15.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-15.js new file mode 100644 index 00000000000..35bfbc7465d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-15.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var proto = { + 0: 0, + 2: 2 +}; +Object.defineProperty(proto, "1", { + get: function() { + return 1; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +SendableArray.prototype.reduceRight.call(child, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-16.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-16.js new file mode 100644 index 00000000000..4196ca7bcea --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-16.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 1; + }, + configurable: true +}); +var arr = [0, , 2]; +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-17.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-17.js new file mode 100644 index 00000000000..bb1ca2a7983 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-17.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof curVal === "undefined"); + } +} +var obj = { + 0: 0, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-18.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-18.js new file mode 100644 index 00000000000..ea14d80f500 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-18.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof curVal === "undefined"); + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "1", { + set: function() {}, + configurable: true +}); +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-19.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-19.js new file mode 100644 index 00000000000..9e27dc23c37 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-19.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function that overrides an + inherited accessor property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof curVal === "undefined"); + } +} +Object.prototype[1] = 1; +var obj = { + 0: 0, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-2.js new file mode 100644 index 00000000000..09000956872 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-2.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var arr = [0, 1, 2]; +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-20.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-20.js new file mode 100644 index 00000000000..a79c25e8eef --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-20.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property without a get function that overrides an + inherited accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof curVal === "undefined"); + } +} +SendableArray.prototype[1] = 1; +var arr = [0, , 2]; +Object.defineProperty(arr, "1", { + set: function() {}, + configurable: true +}); +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-21.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-21.js new file mode 100644 index 00000000000..3d6dbb13dad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-21.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof curVal === "undefined"); + } +} +var proto = { + 0: 0, + 2: 2 +}; +Object.defineProperty(proto, "1", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +SendableArray.prototype.reduceRight.call(child, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-22.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-22.js new file mode 100644 index 00000000000..40b07286127 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-22.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (typeof curVal === "undefined"); + } +} +Object.defineProperty(SendableArray.prototype, "1", { + set: function() {}, + configurable: true +}); +var arr = [0, , 2]; +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-25.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-25.js new file mode 100644 index 00000000000..f0113dd47c7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-25.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - This object is the Arguments object + which implements its own property get method (number of arguments + is less than number of parameters) +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var func = function(a, b, c) { + SendableArray.prototype.reduceRight.call(arguments, callbackfn, "initialValue"); +}; +func(0, 1); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-26.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-26.js new file mode 100644 index 00000000000..eff18d70883 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-26.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - This object is the Arguments object + which implements its own property get method (number of arguments + equals number of parameters) +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2) { + testResult = (curVal === 2); + } +} +var func = function(a, b, c) { + SendableArray.prototype.reduceRight.call(arguments, callbackfn, "initialValue"); +}; +func(0, 1, 2); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-27.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-27.js new file mode 100644 index 00000000000..828ac6fa1a9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-27.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - This object is the Arguments object + which implements its own property get method (number of arguments + is greater than number of parameters) +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 3) { + testResult = (curVal === 3); + } +} +var func = function(a, b, c) { + SendableArray.prototype.reduceRight.call(arguments, callbackfn, "initialValue"); +}; +func(0, 1, 2, 3); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-28.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-28.js new file mode 100644 index 00000000000..a8ca2110782 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-28.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to String object, which + implements its own property get method +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "1"); + } +} +var str = new String("012"); +SendableArray.prototype.reduceRight.call(str, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-29.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-29.js new file mode 100644 index 00000000000..bb534724048 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-29.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight applied to Function object which + implements its own property get method +---*/ + +var testResult = false; +var initialValue = 0; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var obj = function(a, b, c) { + return a + b + c; +}; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +SendableArray.prototype.reduceRight.call(obj, callbackfn, initialValue); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-3.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-3.js new file mode 100644 index 00000000000..8e9614f1bb4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-3.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === "1"); + } +} +var proto = { + 0: 10, + 1: 11, + 2: 12, + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[1] = "1"; +child[2] = "2"; +child.length = 3; +SendableArray.prototype.reduceRight.call(child, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-30.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-30.js new file mode 100644 index 00000000000..1600327aedc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-30.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element changed by getter on + previous iterations is observed on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var arr = [, , ]; +var preIterVisible = false; +Object.defineProperty(arr, "2", { + get: function() { + preIterVisible = true; + return 0; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return "11"; + } + }, + configurable: true +}); +arr.reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-31.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-31.js new file mode 100644 index 00000000000..0c28ff48878 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-31.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element changed by getter on + previous iterations is observed on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var obj = { + length: 3 +}; +var preIterVisible = false; +Object.defineProperty(obj, "2", { + get: function() { + preIterVisible = true; + return 0; + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + if (preIterVisible) { + return 1; + } else { + return "11"; + } + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-32.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-32.js new file mode 100644 index 00000000000..a7a5f34791a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-32.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - unnhandled exceptions happened in + getter terminate iteration on an Array-like object +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx <= 1) { + accessed = true; + } +} +var obj = { + 0: 0, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-33.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-33.js new file mode 100644 index 00000000000..b6a71d7e4f6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-33.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - unnhandled exceptions happened in + getter terminate iteration on an Array +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx <= 1) { + accessed = true; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "1", { + get: function() { + throw new Test262Error("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + arr.reduceRight(callbackfn, "initialValue"); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-4.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-4.js new file mode 100644 index 00000000000..68136cc2980 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +SendableArray.prototype[1] = "11"; +[0, 1, 2].reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-5.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-5.js new file mode 100644 index 00000000000..c2866f972d1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-5.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 0) { + testResult = (curVal === "0"); + } +} +var proto = {}; +Object.defineProperty(proto, "0", { + get: function() { + return 10; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +Object.defineProperty(child, "0", { + value: "0", + configurable: true +}); +child[1] = "1"; +SendableArray.prototype.reduceRight.call(child, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-6.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-6.js new file mode 100644 index 00000000000..e68d80e5da6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return "11"; + }, + configurable: true +}); +[0, 1, 2].reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-7.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-7.js new file mode 100644 index 00000000000..0041840278c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-7.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + data property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var proto = { + 0: 0, + 1: 1, + 2: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 3; +SendableArray.prototype.reduceRight.call(child, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-8.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-8.js new file mode 100644 index 00000000000..000f9e0cc0d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-8.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is inherited + data property on an Array +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +SendableArray.prototype[0] = 0; +SendableArray.prototype[1] = 1; +SendableArray.prototype[2] = 2; +[, , , ].reduceRight(callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-9.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-9.js new file mode 100644 index 00000000000..4930eb7755a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-i-9.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element to be retrieved is own + accessor property on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (curVal === 1); + } +} +var obj = { + 0: 0, + 2: 2, + length: 3 +}; +Object.defineProperty(obj, "1", { + get: function() { + return 1; + }, + configurable: true +}); +SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-1.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-1.js new file mode 100644 index 00000000000..2391adba19d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn called with correct + parameters (initialvalue not passed) +---*/ + +function callbackfn(prevVal, curVal, idx, obj) +{ + if (idx + 1 < obj.length && obj[idx] === curVal && obj[idx + 1] === prevVal) + return curVal; + else + return false; +} +var arr = [0, 1, true, null, new Object(), "five"]; +assert.sameValue(arr.reduceRight(callbackfn), 0, 'arr.reduceRight(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-10.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-10.js new file mode 100644 index 00000000000..e9503077fb1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-10.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn is called with 1 formal + parameter +---*/ + +var called = 0; +function callbackfn(prevVal) { + called++; + return prevVal; +} +assert.sameValue([11, 12].reduceRight(callbackfn, 100), 100, '[11, 12].reduceRight(callbackfn, 100)'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-11.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-11.js new file mode 100644 index 00000000000..6a6c42f1881 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-11.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn is called with 2 formal + parameter +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal) { + if (prevVal === 100) { + testResult = true; + } + return curVal > 10; +} +assert.sameValue([11].reduceRight(callbackfn, 100), true, '[11].reduceRight(callbackfn, 100)'); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-12.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-12.js new file mode 100644 index 00000000000..9d12b907585 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-12.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn is called with 3 formal + parameter +---*/ + +var testResult = false; +var arr = [11, 12, 13]; +var initVal = 6.99; +function callbackfn(prevVal, curVal, idx) { + if (idx === 2) { + testResult = (prevVal === initVal); + } + return curVal > 10 && arguments[3][idx] === curVal; +} +assert.sameValue(arr.reduceRight(callbackfn, initVal), true, 'arr.reduceRight(callbackfn, initVal)'); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-13.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-13.js new file mode 100644 index 00000000000..5a69e5abc0b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-13.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn is called with 4 formal + parameter +---*/ + +var arr = [11, 12, 13]; +var initVal = 6.99; +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 2) { + testResult = (prevVal === initVal); + } + return curVal > 10 && obj[idx] === curVal; +} +assert.sameValue(arr.reduceRight(callbackfn, initVal), true, 'arr.reduceRight(callbackfn, initVal)'); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-14.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-14.js new file mode 100644 index 00000000000..e18aa632179 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-14.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - callbackfn uses arguments +---*/ + +function callbackfn() { + return arguments[0] === 100 && arguments[3][arguments[2]] === arguments[1]; +} +assert.sameValue([11].reduceRight(callbackfn, 100), true, '[11].reduceRight(callbackfn, 100)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-16.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-16.js new file mode 100644 index 00000000000..f953aa7ed9d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-16.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - non-indexed properties are not + called on an Array-like object +---*/ + +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (prevVal === 8 || curVal === 8) { + testResult = true; + } +} +var obj = { + 0: 11, + 10: 12, + non_index_property: 8, + length: 20 +}; +SendableArray.prototype.reduceRight.call(obj, callbackfn, "initialValue"); +assert.sameValue(testResult, false, 'testResult'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-17.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-17.js new file mode 100644 index 00000000000..bf1bff4326c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-17.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - 'accumulator' used for current + iteration is the result of previous iteration on an Array +---*/ + +var arr = [11, 12, 13]; +var testResult = true; +var initVal = 6.99; +var preResult = initVal; +function callbackfn(prevVal, curVal, idx, obj) { + if (prevVal !== preResult) { + testResult = false; + } + preResult = curVal; + return curVal; +} +arr.reduceRight(callbackfn, initVal); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-18.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-18.js new file mode 100644 index 00000000000..a8b1e6b8098 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-18.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - 'accumulator' used for first + iteration is the value of 'initialValue' when it is present on an + Array +---*/ + +var arr = [11, 12]; +var testResult = false; +var initVal = 6.99; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === initVal); + } + return curVal; +} +arr.reduceRight(callbackfn, initVal); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-19.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-19.js new file mode 100644 index 00000000000..7e32c8fced5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-19.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - value of 'accumulator' used for + first iteration is the value of max index property which is not + undefined when 'initialValue' is not present on an Array +---*/ + +var arr = [11, 12, 13]; +var testResult = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === 1) { + testResult = (prevVal === 13); + } + return curVal; +} +arr.reduceRight(callbackfn); +assert(testResult, 'testResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-2.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-2.js new file mode 100644 index 00000000000..a4dd33cad9d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-2.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn called with correct + parameters (initialvalue passed) +---*/ + +var bParCorrect = false; +var arr = [0, 1, true, null, new Object(), "five"]; +var initialValue = 5.5; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx === obj.length - 1 && obj[idx] === curVal && prevVal === initialValue) + return curVal; + else if (idx + 1 < obj.length && obj[idx] === curVal && obj[idx + 1] === prevVal) + return curVal; + else + return false; +} +assert.sameValue(arr.reduceRight(callbackfn, initialValue), 0, 'arr.reduceRight(callbackfn, initialValue)'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-20.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-20.js new file mode 100644 index 00000000000..4290381163d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-20.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - undefined can be used as accumulator +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return typeof prevVal === "undefined"; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, undefined), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, undefined)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-21.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-21.js new file mode 100644 index 00000000000..de6d28ceac4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-21.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - null can be used as accumulator +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === null; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, null), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, null)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-22.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-22.js new file mode 100644 index 00000000000..ca3c22032af --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-22.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - boolean primitive can be used as + accumulator +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === false; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, false), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, false)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-23.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-23.js new file mode 100644 index 00000000000..45466ccdc6e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-23.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - number primitive can be used as + accumulator +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === 12; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, 12), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 12)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-24.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-24.js new file mode 100644 index 00000000000..cee60ead634 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-24.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - string primitive can be used as + accumulator +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === "hello_"; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, "hello_"), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, "hello_")'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-25.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-25.js new file mode 100644 index 00000000000..24f22ea7d81 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-25.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Function Object can be used as + accumulator +---*/ + +var accessed = false; +var objFunction = function() {}; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objFunction; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, objFunction), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, objFunction)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-26.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-26.js new file mode 100644 index 00000000000..3bbc094e72f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-26.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Array Object can be used as + accumulator +---*/ + +var accessed = false; +var objArray = []; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objArray; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, objArray), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, objArray)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-27.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-27.js new file mode 100644 index 00000000000..a5cce0c30db --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-27.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - String Object can be used as + accumulator +---*/ + +var accessed = false; +var objString = new String(); +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objString; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, objString), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, objString)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-28.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-28.js new file mode 100644 index 00000000000..12df13d402e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-28.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Boolean Object can be used as + accumulator +---*/ + +var accessed = false; +var objBoolean = new Boolean(); +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objBoolean; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, objBoolean), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, objBoolean)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-29.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-29.js new file mode 100644 index 00000000000..0cbe6d3af40 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-29.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Number Object can be used as + accumulator +---*/ + +var accessed = false; +var objNumber = new Number(); +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objNumber; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, objNumber), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, objNumber)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-3.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-3.js new file mode 100644 index 00000000000..a70cc450421 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-3.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - callbackfn takes 4 arguments +---*/ + +var bCalled = false; +function callbackfn(prevVal, curVal, idx, obj) +{ + bCalled = true; + if (prevVal === true && arguments.length === 4) + return true; + else + return false; +} +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +assert.sameValue(arr.reduceRight(callbackfn, true), true, 'arr.reduceRight(callbackfn,true)'); +assert.sameValue(bCalled, true, 'bCalled'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-30.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-30.js new file mode 100644 index 00000000000..af7c0ddcd05 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-30.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the Math Object can be used as + accumulator +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === Math; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, Math), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, Math)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-31.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-31.js new file mode 100644 index 00000000000..e6f7a8eb092 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-31.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Date Object can be used as + accumulator +---*/ + +var accessed = false; +var objDate = new Date(0); +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objDate; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, objDate), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, objDate)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-32.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-32.js new file mode 100644 index 00000000000..1246cbb79ce --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-32.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - RegExp Object can be used as + accumulator +---*/ + +var accessed = false; +var objRegExp = new RegExp(); +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objRegExp; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, objRegExp), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, objRegExp)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-33.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-33.js new file mode 100644 index 00000000000..2c8543df770 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-33.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: Array.prototype.reduceRight - the JSON can be used as accumulator +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === JSON; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, JSON), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, JSON)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-34.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-34.js new file mode 100644 index 00000000000..b946013e1ec --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-34.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - Error Object can be used as + accumulator +---*/ + +var accessed = false; +var objError = new RangeError(); +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === objError; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, objError), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, objError)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-35.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-35.js new file mode 100644 index 00000000000..b1d6572c308 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-35.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the Arguments object can be used as + accumulator +---*/ + +var accessed = false; +var arg; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === arg; +} +var obj = { + 0: 11, + length: 1 +}; +(function fun() { + arg = arguments; +}(10, 11, 12, 13)); +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, arg), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, arg)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-36.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-36.js new file mode 100644 index 00000000000..df046ca4295 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-36.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - the global object can be used as + accumulator +---*/ + +var global = this; +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + return prevVal === global; +} +var obj = { + 0: 11, + length: 1 +}; +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, this), true, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, this)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-4.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-4.js new file mode 100644 index 00000000000..afd4ec09024 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-4.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - k values are passed in acending + numeric order +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +var lastIdx = arr.length - 1; +var accessed = false; +var result = true; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (lastIdx !== idx) { + result = false; + } else { + lastIdx--; + } +} +arr.reduceRight(callbackfn, 1); +assert(result, 'result !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-5.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-5.js new file mode 100644 index 00000000000..54d2c99d690 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-5.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - k values are accessed during each + iteration and not prior to starting the loop on an Array +---*/ + +var arr = [11, 12, 13, 14]; +var kIndex = []; +var result = true; +var called = 0; +//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(preVal, curVal, idx, o) { + //Each position should be visited one time, which means k is accessed one time during iterations. + called++; + if (typeof kIndex[idx] === "undefined") { + //when current position is visited, its next index should has been visited. + if (idx !== arr.length - 1 && typeof kIndex[idx + 1] === "undefined") { + result = false; + } + kIndex[idx] = 1; + } else { + result = false; + } +} +arr.reduceRight(callbackfn, 1); +assert(result, 'result !== true'); +assert.sameValue(called, 4, 'called'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-6.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-6.js new file mode 100644 index 00000000000..aa63d49089f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-6.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - undefined passed as thisValue to + strict callbackfn +flags: [noStrict] +---*/ + +var innerThisCorrect = false; +function callbackfn(prevVal, curVal, idx, obj) +{ + "use strict"; + innerThisCorrect = this === undefined; + return true; +} +[0].reduceRight(callbackfn, true); +assert(innerThisCorrect, 'innerThisCorrect !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-7.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-7.js new file mode 100644 index 00000000000..177288ad3ca --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-7.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - unhandled exceptions happened in + callbackfn terminate iteration +---*/ + +var accessed = false; +function callbackfn(prevVal, curVal, idx, obj) { + if (idx < 10) { + accessed = true; + } + if (idx === 10) { + throw new Test262Error("Exception occurred in callbackfn"); + } +} +var obj = { + 0: 11, + 4: 10, + 10: 8, + length: 20 +}; +assert.throws(Test262Error, function() { + SendableArray.prototype.reduceRight.call(obj, callbackfn, 1); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-8.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-8.js new file mode 100644 index 00000000000..c72347334d3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-8.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - element changed by callbackfn on + previous iterations is observed +---*/ + +var accessed = false; +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +function callbackfn(prevVal, curVal, idx, obj) { + accessed = true; + if (idx === 1) { + obj[idx - 1] = 8; + } + return curVal > 10; +} +assert.sameValue(SendableArray.prototype.reduceRight.call(obj, callbackfn, 1), false, 'SendableArray.prototype.reduceRight.call(obj, callbackfn, 1)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-9.js b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-9.js new file mode 100644 index 00000000000..a2f8977ac39 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/15.4.4.22-9-c-ii-9.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight - callbackfn is called with 0 formal + parameter +---*/ + +var called = 0; +function callbackfn() { + called++; + return true; +} +assert.sameValue([11, 12].reduceRight(callbackfn, 11), true, '[11, 12].reduceRight(callbackfn, 11)'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/call-with-boolean.js b/test/sendable/builtins/Array/prototype/reduceRight/call-with-boolean.js new file mode 100644 index 00000000000..7b9dd5987f6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/call-with-boolean.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceRight +description: Array.prototype.reduceRight applied to boolean primitive +---*/ + +assert.sameValue( + SendableArray.prototype.reduceRight.call(true, () => {}, -1), + -1, + 'SendableArray.prototype.reduceRight.call(true, () => {}, -1) must return -1' +); +assert.sameValue( + SendableArray.prototype.reduceRight.call(false, () => {}, -1), + -1, + 'SendableArray.prototype.reduceRight.call(false, () => {}, -1) must return -1' +); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/callbackfn-resize-arraybuffer.js b/test/sendable/builtins/Array/prototype/reduceRight/callbackfn-resize-arraybuffer.js new file mode 100644 index 00000000000..229dd6b5902 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/callbackfn-resize-arraybuffer.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 3}); + var sample = new TA(buffer); + var expectedPrevsShrink, expectedNextsShrink, expectedIndicesShrink, expectedArraysShrink; + var expectedPrevsGrow, expectedNextsGrow, expectedIndicesGrow, expectedArraysGrow; + var prevs, nexts, indices, arrays, result; + prevs = []; + nexts = []; + indices = []; + arrays = []; + result = SendableArray.prototype.reduceRight.call(sample, function(prev, next, index, array) { + if (prevs.length === 0) { + try { + buffer.resize(BPE); + expectedPrevsShrink = [262, 2]; + expectedNextsShrink = [0, 0]; + expectedIndicesShrink = [2, 0]; + expectedArraysShrink = [sample, sample]; + expectedPrevsGrow = [262]; + expectedNextsGrow = [0]; + expectedIndicesGrow = [0]; + expectedArraysGrow = [sample]; + } catch (_) { + expectedPrevsShrink = expectedPrevsGrow = [262, 2, 1]; + expectedNextsShrink = expectedNextsGrow = [0, 0, 0]; + expectedIndicesShrink = expectedIndicesGrow = [2, 1, 0]; + expectedArraysShrink = expectedArraysGrow = [sample, sample, sample]; + } + } + prevs.push(prev); + nexts.push(next); + indices.push(index); + arrays.push(array); + return index; + }, 262); + assert.compareArray(prevs, expectedPrevsShrink, 'prevs (shrink)'); + assert.compareArray(nexts, expectedNextsShrink, 'nexts (shrink)'); + assert.compareArray(indices, expectedIndicesShrink, 'indices (shrink)'); + assert.compareArray(arrays, expectedArraysShrink, 'arrays (shrink)'); + assert.sameValue(result, 0, 'result (shrink)'); + prevs = []; + nexts = []; + indices = []; + arrays = []; + result = SendableArray.prototype.reduceRight.call(sample, function(prev, next, index, array) { + if (prevs.length === 0) { + try { + buffer.resize(3 * BPE); + } catch (_) {} + } + prevs.push(prev); + nexts.push(next); + indices.push(index); + arrays.push(array); + return index; + }, 262); + assert.compareArray(prevs, expectedPrevsGrow, 'prevs (grow)'); + assert.compareArray(nexts, expectedNextsGrow, 'nexts (grow)'); + assert.compareArray(indices, expectedIndicesGrow, 'indices (grow)'); + assert.compareArray(arrays, expectedArraysGrow, 'arrays (grow)'); + assert.sameValue(result, expectedIndicesGrow[expectedIndicesGrow.length - 1], 'result (grow)'); +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/length-near-integer-limit.js b/test/sendable/builtins/Array/prototype/reduceRight/length-near-integer-limit.js new file mode 100644 index 00000000000..d47205a3f4e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/length-near-integer-limit.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Elements are processed in an array-like object + whose "length" property is near the integer limit. +---*/ + +var arrayLike = { + length: Number.MAX_SAFE_INTEGER, +}; +arrayLike[Number.MAX_SAFE_INTEGER - 1] = 1; +arrayLike[Number.MAX_SAFE_INTEGER - 3] = 3; +var accumulator = function(acc, el, index) { + acc.push([el, index]); + + if (el === 3) { + throw acc; + } + + return acc; +}; +try { + SendableArray.prototype.reduceRight.call(arrayLike, accumulator, []); + throw new Test262Error("should not be called"); +} catch (acc) { + assert.sameValue(acc.length, 2, 'The value of acc.length is expected to be 2'); + assert.compareArray( + acc[0], + [1, Number.MAX_SAFE_INTEGER - 1], + 'The value of acc[0] is expected to be [1, Number.MAX_SAFE_INTEGER - 1]' + ); + assert.compareArray( + acc[1], + [3, Number.MAX_SAFE_INTEGER - 3], + 'The value of acc[1] is expected to be [3, Number.MAX_SAFE_INTEGER - 3]' + ); +} diff --git a/test/sendable/builtins/Array/prototype/reduceRight/length.js b/test/sendable/builtins/Array/prototype/reduceRight/length.js new file mode 100644 index 00000000000..78fdb0c40a8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/length.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + The "length" property of Array.prototype.reduceRight +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.reduceRight, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/name.js b/test/sendable/builtins/Array/prototype/reduceRight/name.js new file mode 100644 index 00000000000..2c5950c8e34 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.prototype.reduceRight.name is "reduceRight". +info: | + Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) + 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(SendableArray.prototype.reduceRight, "name", { + value: "reduceRight", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/not-a-constructor.js b/test/sendable/builtins/Array/prototype/reduceRight/not-a-constructor.js new file mode 100644 index 00000000000..7cf37a5c43a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/not-a-constructor.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.reduceRight 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(SendableArray.prototype.reduceRight), + false, + 'isConstructor(SendableArray.prototype.reduceRight) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.reduceRight(() => {}, []); +}); + diff --git a/test/sendable/builtins/Array/prototype/reduceRight/prop-desc.js b/test/sendable/builtins/Array/prototype/reduceRight/prop-desc.js new file mode 100644 index 00000000000..4b5df73614c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + "reduceRight" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.reduceRight, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "reduceRight", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/reduceRight/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/Array/prototype/reduceRight/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..9caa21a0878 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.p.reduceRight behaves correctly on TypedArrays backed by resizable + buffers that are grown mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeBufferMidIteration(acc, n) { + return CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduceRight.call(fixedLength, ResizeBufferMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduceRight.call(fixedLengthWithOffset, ResizeBufferMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 4 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduceRight.call(lengthTracking, ResizeBufferMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduceRight.call(lengthTrackingWithOffset, ResizeBufferMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 4 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/reduceRight/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/Array/prototype/reduceRight/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..72a92e5bb12 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-%array%.prototype.reduceright +description: > + Array.p.reduceRight behaves correctly when the backing resizable buffer is + shrunk mid-iteration. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset before +// calling this. +function ResizeMidIteration(acc, n) { + return CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduceRight.call(fixedLength, ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 4 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduceRight.call(fixedLengthWithOffset, ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 6 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + // Unaffected by the shrinking, since we've already iterated past the point. + SendableArray.prototype.reduceRight.call(lengthTracking, ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 4, + 2, + 0 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + resizeAfter = 1; + resizeTo = 2 * ctor.BYTES_PER_ELEMENT; + SendableArray.prototype.reduceRight.call(lengthTracking, ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 2, + 0 + ]); +} +for (let ctor of ctors) { + values = []; + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + // Unaffected by the shrinking, since we've already iterated past the point. + SendableArray.prototype.reduceRight.call(lengthTrackingWithOffset, ResizeMidIteration, 'initial value'); + assert.compareArray(values, [ + 6, + 4 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/reduceRight/resizable-buffer.js b/test/sendable/builtins/Array/prototype/reduceRight/resizable-buffer.js new file mode 100644 index 00000000000..a7531ffee42 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reduceRight/resizable-buffer.js @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reduceright +description: > + Array.p.reduceRight behaves correctly on TypedArrays backed by resizable + buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + function ReduceRightCollecting(array) { + const reduceRightValues = []; + SendableArray.prototype.reduceRight.call(array, (acc, n) => { + reduceRightValues.push(n); + }, 'initial value'); + reduceRightValues.reverse(); + return ToNumbers(reduceRightValues); + } + assert.compareArray(ReduceRightCollecting(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ReduceRightCollecting(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(ReduceRightCollecting(lengthTracking), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ReduceRightCollecting(lengthTrackingWithOffset), [ + 4, + 6 + ]); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + assert.compareArray(ReduceRightCollecting(fixedLength), []); + assert.compareArray(ReduceRightCollecting(fixedLengthWithOffset), []); + assert.compareArray(ReduceRightCollecting(lengthTracking), [ + 0, + 2, + 4 + ]); + assert.compareArray(ReduceRightCollecting(lengthTrackingWithOffset), [4]); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.compareArray(ReduceRightCollecting(fixedLength), []); + assert.compareArray(ReduceRightCollecting(fixedLengthWithOffset), []); + assert.compareArray(ReduceRightCollecting(lengthTracking), [0]); + // Shrink to zero. + rab.resize(0); + assert.compareArray(ReduceRightCollecting(fixedLength), []); + assert.compareArray(ReduceRightCollecting(fixedLengthWithOffset), []); + assert.compareArray(ReduceRightCollecting(lengthTrackingWithOffset), []); + assert.compareArray(ReduceRightCollecting(lengthTracking), []); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + assert.compareArray(ReduceRightCollecting(fixedLength), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(ReduceRightCollecting(fixedLengthWithOffset), [ + 4, + 6 + ]); + assert.compareArray(ReduceRightCollecting(lengthTracking), [ + 0, + 2, + 4, + 6, + 8, + 10 + ]); + assert.compareArray(ReduceRightCollecting(lengthTrackingWithOffset), [ + 4, + 6, + 8, + 10 + ]); +} -- Gitee From 58f29de83fd867ea47953cf5b1f20cfe4b81207d Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 2 Jan 2025 15:52:42 +0800 Subject: [PATCH 63/93] add array-reserve Signed-off-by: zhuzhihui7 --- .../prototype/reverse/S15.4.4.8_A1_T1.js | 47 +++++ .../prototype/reverse/S15.4.4.8_A1_T2.js | 95 ++++++++++ .../prototype/reverse/S15.4.4.8_A2_T1.js | 99 +++++++++++ .../prototype/reverse/S15.4.4.8_A2_T2.js | 99 +++++++++++ .../prototype/reverse/S15.4.4.8_A2_T3.js | 99 +++++++++++ .../prototype/reverse/S15.4.4.8_A3_T3.js | 42 +++++ .../prototype/reverse/S15.4.4.8_A4_T1.js | 60 +++++++ .../prototype/reverse/S15.4.4.8_A4_T2.js | 61 +++++++ .../prototype/reverse/array-has-one-entry.js | 30 ++++ .../prototype/reverse/call-with-boolean.js | 29 +++ .../reverse/get_if_present_with_delete.js | 29 +++ ...gth-exceeding-integer-limit-with-object.js | 37 ++++ ...ngth-exceeding-integer-limit-with-proxy.js | 115 ++++++++++++ .../Array/prototype/reverse/length.js | 38 ++++ .../builtins/Array/prototype/reverse/name.js | 36 ++++ .../prototype/reverse/not-a-constructor.js | 38 ++++ .../Array/prototype/reverse/prop-desc.js | 32 ++++ .../prototype/reverse/resizable-buffer.js | 166 ++++++++++++++++++ 18 files changed, 1152 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A1_T2.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A2_T3.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A3_T3.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A4_T1.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A4_T2.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/array-has-one-entry.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/get_if_present_with_delete.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/length-exceeding-integer-limit-with-object.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/length-exceeding-integer-limit-with-proxy.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/length.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/name.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/reverse/resizable-buffer.js diff --git a/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A1_T1.js b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A1_T1.js new file mode 100644 index 00000000000..5faee831871 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A1_T1.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The elements of the array are rearranged so as to reverse their order. + The object is returned as the result of the call +esid: sec-array.prototype.reverse +description: Checking case when reverse is given no arguments or one argument +---*/ + +var x = []; +var reverse = x.reverse(); +if (reverse !== x) { + throw new Test262Error('#1: x = []; x.reverse() === x. Actual: ' + (reverse)); +} +x = []; +x[0] = 1; +var reverse = x.reverse(); +if (reverse !== x) { + throw new Test262Error('#2: x = []; x[0] = 1; x.reverse() === x. Actual: ' + (reverse)); +} +x = new SendableArray(1, 2); +var reverse = x.reverse(); +if (reverse !== x) { + throw new Test262Error('#3: x = new Array(1,2); x.reverse() === x. Actual: ' + (reverse)); +} +if (x[0] !== 2) { + throw new Test262Error('#4: x = new Array(1,2); x.reverse(); x[0] === 2. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#5: x = new Array(1,2); x.reverse(); x[1] === 1. Actual: ' + (x[1])); +} +if (x.length !== 2) { + throw new Test262Error('#6: x = new Array(1,2); x.reverse(); x.length === 2. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A1_T2.js b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A1_T2.js new file mode 100644 index 00000000000..2cfa17df192 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A1_T2.js @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The elements of the array are rearranged so as to reverse their order. + The object is returned as the result of the call +esid: sec-array.prototype.reverse +description: Checking this algorithm, elements are objects and primitives +---*/ + +var x = []; +x[0] = true; +x[2] = Infinity; +x[4] = undefined; +x[5] = undefined; +x[8] = "NaN"; +x[9] = "-1"; +var reverse = x.reverse(); +if (reverse !== x) { + throw new Test262Error('#1: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse() === x. Actual: ' + (reverse)); +} +if (x[0] !== "-1") { + throw new Test262Error('#2: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[0] === "-1". Actual: ' + (x[0])); +} +if (x[1] !== "NaN") { + throw new Test262Error('#3: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[1] === "NaN". Actual: ' + (x[1])); +} +if (x[2] !== undefined) { + throw new Test262Error('#4: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[2] === undefined. Actual: ' + (x[2])); +} +if (x[3] !== undefined) { + throw new Test262Error('#5: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[3] === undefined. Actual: ' + (x[3])); +} +if (x[4] !== undefined) { + throw new Test262Error('#6: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[4] === undefined. Actual: ' + (x[4])); +} +if (x[5] !== undefined) { + throw new Test262Error('#7: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[5] === undefined. Actual: ' + (x[5])); +} +if (x[6] !== undefined) { + throw new Test262Error('#8: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[6] === undefined. Actual: ' + (x[6])); +} +if (x[7] !== Infinity) { + throw new Test262Error('#9: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[7] === Infinity. Actual: ' + (x[7])); +} +if (x[8] !== undefined) { + throw new Test262Error('#10: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[8] === undefined. Actual: ' + (x[8])); +} +if (x[9] !== true) { + throw new Test262Error('#11: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x[9] === true. Actual: ' + (x[9])); +} +x.length = 9; +var reverse = x.reverse(); +if (reverse !== x) { + throw new Test262Error('#1: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse() === x. Actual: ' + (reverse)); +} +if (x[0] !== undefined) { + throw new Test262Error('#12: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[0] === undefined. Actual: ' + (x[0])); +} +if (x[1] !== Infinity) { + throw new Test262Error('#13: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[1] === Infinity. Actual: ' + (x[1])); +} +if (x[2] !== undefined) { + throw new Test262Error('#14: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[2] === undefined. Actual: ' + (x[2])); +} +if (x[3] !== undefined) { + throw new Test262Error('#15: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[3] === undefined. Actual: ' + (x[3])); +} +if (x[4] !== undefined) { + throw new Test262Error('#16: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[4] === undefined. Actual: ' + (x[4])); +} +if (x[5] !== undefined) { + throw new Test262Error('#17: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[5] === undefined. Actual: ' + (x[5])); +} +if (x[6] !== undefined) { + throw new Test262Error('#18: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[6] === undefined. Actual: ' + (x[6])); +} +if (x[7] !== "NaN") { + throw new Test262Error('#19: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[7] === "NaN". Actual: ' + (x[7])); +} +if (x[8] !== "-1") { + throw new Test262Error('#20: x = []; x[0] = true; x[2] = Infinity; x[4] = undefined; x[5] = undefined; x[8] = "NaN"; x[9] = "-1"; x.reverse(); x.length = 9; x.reverse(); x[8] === "-1". Actual: ' + (x[8])); +} diff --git a/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A2_T1.js b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A2_T1.js new file mode 100644 index 00000000000..7834e098c84 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A2_T1.js @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The reverse function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.reverse +description: > + Checking this for Object object, elements are objects and + primitives, length is integer +---*/ + +var obj = {}; +obj.length = 10; +obj.reverse = SendableArray.prototype.reverse; +obj[0] = true; +obj[2] = Infinity; +obj[4] = undefined; +obj[5] = undefined; +obj[8] = "NaN"; +obj[9] = "-1"; +var reverse = obj.reverse(); +if (reverse !== obj) { + throw new Test262Error('#1: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse() === obj. Actual: ' + (reverse)); +} +if (obj[0] !== "-1") { + throw new Test262Error('#2: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[0] === "-1". Actual: ' + (obj[0])); +} +if (obj[1] !== "NaN") { + throw new Test262Error('#3: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[1] === "NaN". Actual: ' + (obj[1])); +} +if (obj[2] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[2] === undefined. Actual: ' + (obj[2])); +} +if (obj[3] !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[3] === undefined. Actual: ' + (obj[3])); +} +if (obj[4] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[4] === undefined. Actual: ' + (obj[4])); +} +if (obj[5] !== undefined) { + throw new Test262Error('#7: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[5] === undefined. Actual: ' + (obj[5])); +} +if (obj[6] !== undefined) { + throw new Test262Error('#8: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[6] === undefined. Actual: ' + (obj[6])); +} +if (obj[7] !== Infinity) { + throw new Test262Error('#9: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[7] === Infinity. Actual: ' + (obj[7])); +} +if (obj[8] !== undefined) { + throw new Test262Error('#10: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[8] === undefined. Actual: ' + (obj[8])); +} +if (obj[9] !== true) { + throw new Test262Error('#11: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[9] === true. Actual: ' + (obj[9])); +} +obj.length = 9; +var reverse = obj.reverse(); +if (reverse !== obj) { + throw new Test262Error('#1: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse() === obj. Actual: ' + (reverse)); +} +if (obj[0] !== undefined) { + throw new Test262Error('#12: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[0] === undefined. Actual: ' + (obj[0])); +} +if (obj[1] !== Infinity) { + throw new Test262Error('#13: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[1] === Infinity. Actual: ' + (obj[1])); +} +if (obj[2] !== undefined) { + throw new Test262Error('#14: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[2] === undefined. Actual: ' + (obj[2])); +} +if (obj[3] !== undefined) { + throw new Test262Error('#15: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[3] === undefined. Actual: ' + (obj[3])); +} +if (obj[4] !== undefined) { + throw new Test262Error('#16: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[4] === undefined. Actual: ' + (obj[4])); +} +if (obj[5] !== undefined) { + throw new Test262Error('#17: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[5] === undefined. Actual: ' + (obj[5])); +} +if (obj[6] !== undefined) { + throw new Test262Error('#18: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[6] === undefined. Actual: ' + (obj[6])); +} +if (obj[7] !== "NaN") { + throw new Test262Error('#19: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[7] === "NaN". Actual: ' + (obj[7])); +} +if (obj[8] !== "-1") { + throw new Test262Error('#20: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = 9; obj.reverse(); obj[8] === "-1". Actual: ' + (obj[8])); +} diff --git a/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A2_T2.js b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A2_T2.js new file mode 100644 index 00000000000..505340119e5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A2_T2.js @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The reverse function is intentionally generic. + It does not require that its this value be an SendableArray object +esid: sec-SendableArray.prototype.reverse +description: > + Checking this for Object object, elements are objects and + primitives, length is not integer +---*/ + +var obj = {}; +obj.length = 10.5; +obj.reverse = SendableArray.prototype.reverse; +obj[0] = true; +obj[2] = Infinity; +obj[4] = undefined; +obj[5] = undefined; +obj[8] = "NaN"; +obj[9] = "-1"; +var reverse = obj.reverse(); +if (reverse !== obj) { + throw new Test262Error('#1: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse() === obj. Actual: ' + (reverse)); +} +if (obj[0] !== "-1") { + throw new Test262Error('#2: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[0] === "-1". Actual: ' + (obj[0])); +} +if (obj[1] !== "NaN") { + throw new Test262Error('#3: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[1] === "NaN". Actual: ' + (obj[1])); +} +if (obj[2] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[2] === undefined. Actual: ' + (obj[2])); +} +if (obj[3] !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[3] === undefined. Actual: ' + (obj[3])); +} +if (obj[4] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[4] === undefined. Actual: ' + (obj[4])); +} +if (obj[5] !== undefined) { + throw new Test262Error('#7: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[5] === undefined. Actual: ' + (obj[5])); +} +if (obj[6] !== undefined) { + throw new Test262Error('#8: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[6] === undefined. Actual: ' + (obj[6])); +} +if (obj[7] !== Infinity) { + throw new Test262Error('#9: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[7] === Infinity. Actual: ' + (obj[7])); +} +if (obj[8] !== undefined) { + throw new Test262Error('#10: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[8] === undefined. Actual: ' + (obj[8])); +} +if (obj[9] !== true) { + throw new Test262Error('#11: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[9] === true. Actual: ' + (obj[9])); +} +obj.length = new Number(9.5); +var reverse = obj.reverse(); +if (reverse !== obj) { + throw new Test262Error('#1: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse() === obj. Actual: ' + (reverse)); +} +if (obj[0] !== undefined) { + throw new Test262Error('#12: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[0] === undefined. Actual: ' + (obj[0])); +} +if (obj[1] !== Infinity) { + throw new Test262Error('#13: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[1] === Infinity. Actual: ' + (obj[1])); +} +if (obj[2] !== undefined) { + throw new Test262Error('#14: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[2] === undefined. Actual: ' + (obj[2])); +} +if (obj[3] !== undefined) { + throw new Test262Error('#15: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[3] === undefined. Actual: ' + (obj[3])); +} +if (obj[4] !== undefined) { + throw new Test262Error('#16: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[4] === undefined. Actual: ' + (obj[4])); +} +if (obj[5] !== undefined) { + throw new Test262Error('#17: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[5] === undefined. Actual: ' + (obj[5])); +} +if (obj[6] !== undefined) { + throw new Test262Error('#18: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[6] === undefined. Actual: ' + (obj[6])); +} +if (obj[7] !== "NaN") { + throw new Test262Error('#19: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[7] === "NaN". Actual: ' + (obj[7])); +} +if (obj[8] !== "-1") { + throw new Test262Error('#20: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = 10.5; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new Number(9.5); obj.reverse(); obj[8] === "-1". Actual: ' + (obj[8])); +} diff --git a/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A2_T3.js b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A2_T3.js new file mode 100644 index 00000000000..e329ba8611d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A2_T3.js @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The reverse function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.reverse +description: > + Checking this for Object object, elements are objects and + primitives, length is string +---*/ + +var obj = {}; +obj.length = "10"; +obj.reverse = SendableArray.prototype.reverse; +obj[0] = true; +obj[2] = Infinity; +obj[4] = undefined; +obj[5] = undefined; +obj[8] = "NaN"; +obj[9] = "-1"; +var reverse = obj.reverse(); +if (reverse !== obj) { + throw new Test262Error('#1: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse() === obj. Actual: ' + (reverse)); +} +if (obj[0] !== "-1") { + throw new Test262Error('#2: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[0] === "-1". Actual: ' + (obj[0])); +} +if (obj[1] !== "NaN") { + throw new Test262Error('#3: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[1] === "NaN". Actual: ' + (obj[1])); +} +if (obj[2] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[2] === undefined. Actual: ' + (obj[2])); +} +if (obj[3] !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[3] === undefined. Actual: ' + (obj[3])); +} +if (obj[4] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[4] === undefined. Actual: ' + (obj[4])); +} +if (obj[5] !== undefined) { + throw new Test262Error('#7: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[5] === undefined. Actual: ' + (obj[5])); +} +if (obj[6] !== undefined) { + throw new Test262Error('#8: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[6] === undefined. Actual: ' + (obj[6])); +} +if (obj[7] !== Infinity) { + throw new Test262Error('#9: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[7] === Infinity. Actual: ' + (obj[7])); +} +if (obj[8] !== undefined) { + throw new Test262Error('#10: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[8] === undefined. Actual: ' + (obj[8])); +} +if (obj[9] !== true) { + throw new Test262Error('#11: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj[9] === true. Actual: ' + (obj[9])); +} +obj.length = new String("9"); +var reverse = obj.reverse(); +if (reverse !== obj) { + throw new Test262Error('#1: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse() === obj. Actual: ' + (reverse)); +} +if (obj[0] !== undefined) { + throw new Test262Error('#12: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[0] === undefined. Actual: ' + (obj[0])); +} +if (obj[1] !== Infinity) { + throw new Test262Error('#13: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[1] === Infinity. Actual: ' + (obj[1])); +} +if (obj[2] !== undefined) { + throw new Test262Error('#14: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[2] === undefined. Actual: ' + (obj[2])); +} +if (obj[3] !== undefined) { + throw new Test262Error('#15: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[3] === undefined. Actual: ' + (obj[3])); +} +if (obj[4] !== undefined) { + throw new Test262Error('#16: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[4] === undefined. Actual: ' + (obj[4])); +} +if (obj[5] !== undefined) { + throw new Test262Error('#17: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[5] === undefined. Actual: ' + (obj[5])); +} +if (obj[6] !== undefined) { + throw new Test262Error('#18: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[6] === undefined. Actual: ' + (obj[6])); +} +if (obj[7] !== "NaN") { + throw new Test262Error('#19: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[7] === "NaN". Actual: ' + (obj[7])); +} +if (obj[8] !== "-1") { + throw new Test262Error('#20: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj.length = "10"; obj[0] = true; obj[2] = Infinity; obj[4] = undefined; obj[5] = undefined; obj[8] = "NaN"; obj[9] = "-1"; obj.reverse(); obj.length = new String("9"); obj.reverse(); obj[8] === "-1". Actual: ' + (obj[8])); +} diff --git a/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A3_T3.js b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A3_T3.js new file mode 100644 index 00000000000..761d068d887 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A3_T3.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.reverse +description: length = -4294967294 +---*/ + +var obj = {}; +obj.reverse = SendableArray.prototype.reverse; +obj[0] = "x"; +obj[1] = "y"; +obj[2] = "z"; +obj.length = -4294967294; +var reverse = obj.reverse(); +if (reverse !== obj) { + throw new Test262Error('#1: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse() === obj. Actual: ' + (reverse)); +} +if (obj.length !== -4294967294) { + throw new Test262Error('#2: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse(); obj.length === -4294967294. Actual: ' + (obj.length)); +} +if (obj[0] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse(); obj[0] === "x". Actual: ' + (obj[0])); +} +if (obj[1] !== "y") { + throw new Test262Error('#4: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse(); obj[1] === "y". Actual: ' + (obj[1])); +} +if (obj[2] !== "z") { + throw new Test262Error('#5: var obj = {}; obj.reverse = SendableArray.prototype.reverse; obj[0] = "x"; obj[1] = "y"; obj[2] = "z"; obj.length = -4294967294; obj.reverse(); obj[2] === "z". Actual: ' + (obj[2])); +} diff --git a/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A4_T1.js b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A4_T1.js new file mode 100644 index 00000000000..5c7618e60cd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A4_T1.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.reverse +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +SendableArray.prototype[1] = 1; +var x = [0]; +x.length = 2; +x.reverse(); +if (x[0] !== 1) { + throw new Test262Error('#1: SendableArray.prototype[1] = 1; x = [0]; x.length = 2; x.reverse(); x[0] === 1. Actual: ' + (x[0])); +} +if (x[1] !== 0) { + throw new Test262Error('#2: SendableArray.prototype[1] = 1; x = [0]; x.length = 2; x.reverse(); x[1] === 0. Actual: ' + (x[1])); +} +x.length = 0; +if (x[0] !== undefined) { + throw new Test262Error('#3: SendableArray.prototype[1] = 1; x = [0]; x.length = 2; x.reverse(); x.length = 0; x[0] === undefined. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#4: SendableArray.prototype[1] = 1; x = [0]; x.length = 2; x.reverse(); x.length = 0; x[1] === 1. Actual: ' + (x[1])); +} +Object.prototype[1] = 1; +Object.prototype.length = 2; +Object.prototype.reverse = SendableArray.prototype.reverse; +x = { + 0: 0 +}; +x.reverse(); +if (x[0] !== 1) { + throw new Test262Error('#5: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.reverse = SendableArray.prototype.reverse; x = {0:0}; x.reverse(); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 0) { + throw new Test262Error('#6: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.reverse = SendableArray.prototype.reverse; x = {0:0}; x.reverse(); x[1] === 0. Actual: ' + (x[1])); +} +delete x[0]; +delete x[1]; +if (x[0] !== undefined) { + throw new Test262Error('#7: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.reverse = SendableArray.prototype.reverse; x = {0:0}; x.reverse(); delete x[0]; delete x[1]; x[0] === undefined. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#8: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.reverse = SendableArray.prototype.reverse; x = {0:0}; x.reverse(); delete x[0]; delete x[1]; x[1] === 1. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A4_T2.js b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A4_T2.js new file mode 100644 index 00000000000..6fc4f4dddc5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/S15.4.4.8_A4_T2.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.reverse +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +SendableArray.prototype[1] = -1; +var x = [0, 1]; +x.length = 2; +x.reverse(); +if (x[0] !== 1) { + throw new Test262Error('#1: SendableArray.prototype[1] = -1; x = [0,1]; x.length = 2; x.reverse(); x[0] === 1. Actual: ' + (x[0])); +} +if (x[1] !== 0) { + throw new Test262Error('#2: SendableArray.prototype[1] = -1; x = [0,1]; x.length = 2; x.reverse(); x[1] === 0. Actual: ' + (x[1])); +} +x.length = 0; +if (x[0] !== undefined) { + throw new Test262Error('#3: SendableArray.prototype[1] = -1; x = [0,1]; x.length = 2; x.reverse(); x.length = 0; x[0] === undefined. Actual: ' + (x[0])); +} +if (x[1] !== -1) { + throw new Test262Error('#4: SendableArray.prototype[1] = -1; x = [0,1]; x.length = 2; x.reverse(); x.length = 0; x[1] === -1. Actual: ' + (x[1])); +} +Object.prototype[1] = -1; +Object.prototype.length = 2; +Object.prototype.reverse = SendableArray.prototype.reverse; +x = { + 0: 0, + 1: 1 +}; +x.reverse(); +if (x[0] !== 1) { + throw new Test262Error('#5: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.reverse = SendableArray.prototype.reverse; x = {0:0,1:1}; x.reverse(); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 0) { + throw new Test262Error('#6: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.reverse = SendableArray.prototype.reverse; x = {0:0,1:1}; x.reverse(); x[1] === 0. Actual: ' + (x[1])); +} +delete x[0]; +delete x[1]; +if (x[0] !== undefined) { + throw new Test262Error('#7: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.reverse = SendableArray.prototype.reverse; x = {0:0,1:1}; x.reverse(); delete x[0]; delete x[1]; x[0] === undefined. Actual: ' + (x[0])); +} +if (x[1] !== -1) { + throw new Test262Error('#8: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.reverse = SendableArray.prototype.reverse; x = {0:0,1:1}; x.reverse(); delete x[0]; delete x[1]; x[1] === -1. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/reverse/array-has-one-entry.js b/test/sendable/builtins/Array/prototype/reverse/array-has-one-entry.js new file mode 100644 index 00000000000..74f80db3f03 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/array-has-one-entry.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reverse +description: Array.prototype.reverse should not iterate items if there is only one entry +info: | + Array.prototype.reverse ( ) + Let O be ToObject(this value). + Let len be LengthOfArrayLike(O). + Let middle be floor(len / 2). + Let lower be 0. + Repeat, while lower ≠ middle, + Return O. +---*/ + +let a = [1]; +Object.freeze(a); +a.reverse(); diff --git a/test/sendable/builtins/Array/prototype/reverse/call-with-boolean.js b/test/sendable/builtins/Array/prototype/reverse/call-with-boolean.js new file mode 100644 index 00000000000..f1eb487243d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/call-with-boolean.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reverse +description: Array.prototype.reverse applied to boolean primitive +---*/ + +assert.sameValue( + SendableArray.prototype.reverse.call(true) instanceof Boolean, + true, + 'The result of `(SendableArray.prototype.reverse.call(true) instanceof Boolean)` is true' +); +assert.sameValue( + SendableArray.prototype.reverse.call(false) instanceof Boolean, + true, + 'The result of `(SendableArray.prototype.reverse.call(false) instanceof Boolean)` is true' +); diff --git a/test/sendable/builtins/Array/prototype/reverse/get_if_present_with_delete.js b/test/sendable/builtins/Array/prototype/reverse/get_if_present_with_delete.js new file mode 100644 index 00000000000..083ed13f9e7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/get_if_present_with_delete.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Array.prototype.reverse only gets present properties - delete property with getter +---*/ + +var array = ["first", "second"]; +Object.defineProperty(array, 0, { + get: function() { + array.length = 0; + return "first"; + } +}); +array.reverse(); +assert.sameValue((0 in array), false, "Indexed property '0' not present"); +assert.sameValue((1 in array), true, "Indexed property '1' present"); +assert.sameValue(array[1], "first", "Indexed property '1' value correct"); diff --git a/test/sendable/builtins/Array/prototype/reverse/length-exceeding-integer-limit-with-object.js b/test/sendable/builtins/Array/prototype/reverse/length-exceeding-integer-limit-with-object.js new file mode 100644 index 00000000000..aa4f7314e4b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/length-exceeding-integer-limit-with-object.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reverse +description: > + Ensure reverse() implementation correctly handles length exceeding 2^53-1 with plain objects. +---*/ + +function StopReverse() {} +// Object with large "length" property and no indexed properties in the uint32 range. +var arrayLike = { + get "9007199254740990" () { + throw new StopReverse(); + }, + get "9007199254740991" () { + throw new Test262Error("Get 9007199254740991"); + }, + get "9007199254740992" () { + throw new Test262Error("Get 9007199254740992"); + }, + length: 2 ** 53 + 2, +}; +assert.throws(StopReverse, function() { + SendableArray.prototype.reverse.call(arrayLike); +}); diff --git a/test/sendable/builtins/Array/prototype/reverse/length-exceeding-integer-limit-with-proxy.js b/test/sendable/builtins/Array/prototype/reverse/length-exceeding-integer-limit-with-proxy.js new file mode 100644 index 00000000000..785303b6591 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/length-exceeding-integer-limit-with-proxy.js @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reverse +description: > + Ensure correct MOP operations are called when length exceeds 2^53-1. +includes: [compareArray.js, proxyTrapsHelper.js] +features: [exponentiation] +---*/ + +function StopReverse() {} +var arrayLike = { + 0: "zero", + /* 1: hole, */ + 2: "two", + /* 3: hole, */ + get 4() { + throw new StopReverse(); + }, + 9007199254740987: "2**53-5", + /* 9007199254740988: hole, */ + /* 9007199254740989: hole, */ + 9007199254740990: "2**53-2", + length: 2 ** 53 + 2, +}; +var traps = []; +var proxy = new Proxy(arrayLike, allowProxyTraps({ + getOwnPropertyDescriptor(t, pk) { + traps.push(`GetOwnPropertyDescriptor:${String(pk)}`); + return Reflect.getOwnPropertyDescriptor(t, pk); + }, + defineProperty(t, pk, desc) { + traps.push(`DefineProperty:${String(pk)}`); + return Reflect.defineProperty(t, pk, desc); + }, + has(t, pk) { + traps.push(`Has:${String(pk)}`); + return Reflect.has(t, pk); + }, + get(t, pk, r) { + traps.push(`Get:${String(pk)}`); + return Reflect.get(t, pk, r); + }, + set(t, pk, v, r) { + traps.push(`Set:${String(pk)}`); + return Reflect.set(t, pk, v, r); + }, + deleteProperty(t, pk) { + traps.push(`Delete:${String(pk)}`); + return Reflect.deleteProperty(t, pk); + }, +})) +// Uses a separate exception than Test262Error, so that errors from allowProxyTraps +// are properly propagated. +assert.throws(StopReverse, function() { + SendableArray.prototype.reverse.call(proxy); +}, 'SendableArray.prototype.reverse.call(proxy) throws a StopReverse exception'); +assert.compareArray(traps, [ + // Initial get length operation. + "Get:length", + // Lower and upper index are both present. + "Has:0", + "Get:0", + "Has:9007199254740990", + "Get:9007199254740990", + "Set:0", + "GetOwnPropertyDescriptor:0", + "DefineProperty:0", + "Set:9007199254740990", + "GetOwnPropertyDescriptor:9007199254740990", + "DefineProperty:9007199254740990", + // Lower and upper index are both absent. + "Has:1", + "Has:9007199254740989", + // Lower index is present, upper index is absent. + "Has:2", + "Get:2", + "Has:9007199254740988", + "Delete:2", + "Set:9007199254740988", + "GetOwnPropertyDescriptor:9007199254740988", + "DefineProperty:9007199254740988", + // Lower index is absent, upper index is present. + "Has:3", + "Has:9007199254740987", + "Get:9007199254740987", + "Set:3", + "GetOwnPropertyDescriptor:3", + "DefineProperty:3", + "Delete:9007199254740987", + // Stop exception. + "Has:4", + "Get:4", +], 'The value of traps is expected to be [\n // Initial get length operation.\n "Get:length",\n\n // Lower and upper index are both present.\n "Has:0",\n "Get:0",\n "Has:9007199254740990",\n "Get:9007199254740990",\n "Set:0",\n "GetOwnPropertyDescriptor:0",\n "DefineProperty:0",\n "Set:9007199254740990",\n "GetOwnPropertyDescriptor:9007199254740990",\n "DefineProperty:9007199254740990",\n\n // Lower and upper index are both absent.\n "Has:1",\n "Has:9007199254740989",\n\n // Lower index is present, upper index is absent.\n "Has:2",\n "Get:2",\n "Has:9007199254740988",\n "Delete:2",\n "Set:9007199254740988",\n "GetOwnPropertyDescriptor:9007199254740988",\n "DefineProperty:9007199254740988",\n\n // Lower index is absent, upper index is present.\n "Has:3",\n "Has:9007199254740987",\n "Get:9007199254740987",\n "Set:3",\n "GetOwnPropertyDescriptor:3",\n "DefineProperty:3",\n "Delete:9007199254740987",\n\n // Stop exception.\n "Has:4",\n "Get:4",\n]'); +assert.sameValue(arrayLike.length, 2 ** 53 + 2, 'The value of arrayLike.length is expected to be 2 ** 53 + 2'); +assert.sameValue(arrayLike[0], "2**53-2", 'The value of arrayLike[0] is expected to be "2**53-2"'); +assert.sameValue(1 in arrayLike, false, 'The result of evaluating (1 in arrayLike) is expected to be false'); +assert.sameValue(2 in arrayLike, false, 'The result of evaluating (2 in arrayLike) is expected to be false'); +assert.sameValue(arrayLike[3], "2**53-5", 'The value of arrayLike[3] is expected to be "2**53-5"'); +assert.sameValue(9007199254740987 in arrayLike, false, 'The result of evaluating (9007199254740987 in arrayLike) is expected to be false'); +assert.sameValue(arrayLike[9007199254740988], "two", 'The value of arrayLike[9007199254740988] is expected to be "two"'); +assert.sameValue(9007199254740989 in arrayLike, false, 'The result of evaluating (9007199254740989 in arrayLike) is expected to be false'); +assert.sameValue(arrayLike[9007199254740990], "zero", 'The value of arrayLike[9007199254740990] is expected to be "zero"'); diff --git a/test/sendable/builtins/Array/prototype/reverse/length.js b/test/sendable/builtins/Array/prototype/reverse/length.js new file mode 100644 index 00000000000..42b444b3342 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/length.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reverse +description: > + The "length" property of Array.prototype.reverse +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.reverse, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/reverse/name.js b/test/sendable/builtins/Array/prototype/reverse/name.js new file mode 100644 index 00000000000..9d926ead0b0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reverse +description: > + Array.prototype.reverse.name is "reverse". +info: | + Array.prototype.reverse ( ) + 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(SendableArray.prototype.reverse, "name", { + value: "reverse", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/reverse/not-a-constructor.js b/test/sendable/builtins/Array/prototype/reverse/not-a-constructor.js new file mode 100644 index 00000000000..c4a1a573a6a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/not-a-constructor.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.reverse 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(SendableArray.prototype.reverse), + false, + 'isConstructor(SendableArray.prototype.reverse) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.reverse(); +}); + diff --git a/test/sendable/builtins/Array/prototype/reverse/prop-desc.js b/test/sendable/builtins/Array/prototype/reverse/prop-desc.js new file mode 100644 index 00000000000..f19cc81c4cb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reverse +description: > + "reverse" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.reverse, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "reverse", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/reverse/resizable-buffer.js b/test/sendable/builtins/Array/prototype/reverse/resizable-buffer.js new file mode 100644 index 00000000000..82acf932086 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/reverse/resizable-buffer.js @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.reverse +description: > + Array.p.reverse behaves correctly on TypedArrays backed by resizable buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const wholeArrayView = new ctor(rab); + function WriteData() { + // Write some data into the array. + for (let i = 0; i < wholeArrayView.length; ++i) { + wholeArrayView[i] = MayNeedBigInt(wholeArrayView, 2 * i); + } + } + WriteData(); + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + SendableArray.prototype.reverse.call(fixedLength); + assert.compareArray(ToNumbers(wholeArrayView), [ + 6, + 4, + 2, + 0 + ]); + SendableArray.prototype.reverse.call(fixedLengthWithOffset); + assert.compareArray(ToNumbers(wholeArrayView), [ + 6, + 4, + 0, + 2 + ]); + SendableArray.prototype.reverse.call(lengthTracking); + assert.compareArray(ToNumbers(wholeArrayView), [ + 2, + 0, + 4, + 6 + ]); + SendableArray.prototype.reverse.call(lengthTrackingWithOffset); + assert.compareArray(ToNumbers(wholeArrayView), [ + 2, + 0, + 6, + 4 + ]); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + WriteData(); + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + SendableArray.prototype.reverse.call(fixedLength); + assert.compareArray(ToNumbers(wholeArrayView), [ + 0, + 2, + 4 + ]); + SendableArray.prototype.reverse.call(fixedLengthWithOffset); + assert.compareArray(ToNumbers(wholeArrayView), [ + 0, + 2, + 4 + ]); + SendableArray.prototype.reverse.call(lengthTracking); + assert.compareArray(ToNumbers(wholeArrayView), [ + 4, + 2, + 0 + ]); + SendableArray.prototype.reverse.call(lengthTrackingWithOffset); + assert.compareArray(ToNumbers(wholeArrayView), [ + 4, + 2, + 0 + ]); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + WriteData(); + SendableArray.prototype.reverse.call(fixedLength); + assert.compareArray(ToNumbers(wholeArrayView), [0]); + SendableArray.prototype.reverse.call(fixedLengthWithOffset); + assert.compareArray(ToNumbers(wholeArrayView), [0]); + SendableArray.prototype.reverse.call(lengthTrackingWithOffset); + assert.compareArray(ToNumbers(wholeArrayView), [0]); + SendableArray.prototype.reverse.call(lengthTracking); + assert.compareArray(ToNumbers(wholeArrayView), [0]); + // Shrink to zero. + rab.resize(0); + SendableArray.prototype.reverse.call(fixedLength); + assert.compareArray(ToNumbers(wholeArrayView), []); + SendableArray.prototype.reverse.call(fixedLengthWithOffset); + assert.compareArray(ToNumbers(wholeArrayView), []); + SendableArray.prototype.reverse.call(lengthTrackingWithOffset); + assert.compareArray(ToNumbers(wholeArrayView), []); + SendableArray.prototype.reverse.call(lengthTracking); + assert.compareArray(ToNumbers(wholeArrayView), []); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + WriteData(); + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + SendableArray.prototype.reverse.call(fixedLength); + assert.compareArray(ToNumbers(wholeArrayView), [ + 6, + 4, + 2, + 0, + 8, + 10 + ]); + SendableArray.prototype.reverse.call(fixedLengthWithOffset); + assert.compareArray(ToNumbers(wholeArrayView), [ + 6, + 4, + 0, + 2, + 8, + 10 + ]); + SendableArray.prototype.reverse.call(lengthTracking); + assert.compareArray(ToNumbers(wholeArrayView), [ + 10, + 8, + 2, + 0, + 4, + 6 + ]); + SendableArray.prototype.reverse.call(lengthTrackingWithOffset); + assert.compareArray(ToNumbers(wholeArrayView), [ + 10, + 8, + 6, + 4, + 0, + 2 + ]); +} -- Gitee From cdc14e0148e65acc5bc13cad7d00291722fe6b37 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 2 Jan 2025 16:32:11 +0800 Subject: [PATCH 64/93] add array-shift Signed-off-by: zhuzhihui7 --- .../prototype/shift/S15.4.4.9_A1.1_T1.js | 39 ++++++ .../prototype/shift/S15.4.4.9_A1.2_T1.js | 60 +++++++++ .../Array/prototype/shift/S15.4.4.9_A2_T1.js | 53 ++++++++ .../Array/prototype/shift/S15.4.4.9_A2_T2.js | 70 ++++++++++ .../Array/prototype/shift/S15.4.4.9_A2_T3.js | 42 ++++++ .../Array/prototype/shift/S15.4.4.9_A2_T4.js | 51 +++++++ .../Array/prototype/shift/S15.4.4.9_A2_T5.js | 127 ++++++++++++++++++ .../Array/prototype/shift/S15.4.4.9_A3_T3.js | 38 ++++++ .../Array/prototype/shift/S15.4.4.9_A4_T1.js | 58 ++++++++ .../Array/prototype/shift/S15.4.4.9_A4_T2.js | 59 ++++++++ .../prototype/shift/call-with-boolean.js | 29 ++++ .../builtins/Array/prototype/shift/length.js | 38 ++++++ .../builtins/Array/prototype/shift/name.js | 36 +++++ .../prototype/shift/not-a-constructor.js | 38 ++++++ .../Array/prototype/shift/prop-desc.js | 32 +++++ .../shift/set-length-array-is-frozen.js | 33 +++++ ...set-length-array-length-is-non-writable.js | 33 +++++ .../shift/set-length-zero-array-is-frozen.js | 25 ++++ ...ength-zero-array-length-is-non-writable.js | 25 ++++ ...hen-this-value-length-is-writable-false.js | 32 +++++ 20 files changed, 918 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A1.1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A1.2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T3.js create mode 100644 test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T4.js create mode 100644 test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T5.js create mode 100644 test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A3_T3.js create mode 100644 test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A4_T1.js create mode 100644 test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A4_T2.js create mode 100644 test/sendable/builtins/Array/prototype/shift/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/shift/length.js create mode 100644 test/sendable/builtins/Array/prototype/shift/name.js create mode 100644 test/sendable/builtins/Array/prototype/shift/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/shift/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/shift/set-length-array-is-frozen.js create mode 100644 test/sendable/builtins/Array/prototype/shift/set-length-array-length-is-non-writable.js create mode 100644 test/sendable/builtins/Array/prototype/shift/set-length-zero-array-is-frozen.js create mode 100644 test/sendable/builtins/Array/prototype/shift/set-length-zero-array-length-is-non-writable.js create mode 100644 test/sendable/builtins/Array/prototype/shift/throws-when-this-value-length-is-writable-false.js diff --git a/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A1.1_T1.js b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A1.1_T1.js new file mode 100644 index 00000000000..bda77705cf8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A1.1_T1.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If length equal zero, call the [[Put]] method of this object + with arguments "length" and 0 and return undefined +esid: sec-array.prototype.shift +description: Checking this algorithm +---*/ + +var x = new SendableArray(); +var shift = x.shift(); +if (shift !== undefined) { + throw new Test262Error('#1: var x = new SendableArray(); x.shift() === undefined. Actual: ' + (shift)); +} +if (x.length !== 0) { + throw new Test262Error('#2: var x = new SendableArray(); x.shift(); x.length === 0. Actual: ' + (x.length)); +} +var x = Array(1, 2, 3); +x.length = 0; +var shift = x.shift(); +if (shift !== undefined) { + throw new Test262Error('#2: var x = SendableArray(1,2,3); x.length = 0; x.shift() === undefined. Actual: ' + (shift)); +} +if (x.length !== 0) { + throw new Test262Error('#4: var x = new SendableArray(1,2,3); x.length = 0; x.shift(); x.length === 0. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A1.2_T1.js b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A1.2_T1.js new file mode 100644 index 00000000000..0671731dbca --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A1.2_T1.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The first element of the array is removed from the array and + returned +esid: sec-array.prototype.shift +description: Checking this use new Array() and [] +---*/ + +var x = new SendableArray(0, 1, 2, 3); +var shift = x.shift(); +if (shift !== 0) { + throw new Test262Error('#1: x = new SendableArray(0,1,2,3); x.shift() === 0. Actual: ' + (shift)); +} +if (x.length !== 3) { + throw new Test262Error('#2: x = new SendableArray(0,1,2,3); x.shift(); x.length == 3'); +} +if (x[0] !== 1) { + throw new Test262Error('#3: x = new SendableArray(0,1,2,3); x.shift(); x[0] == 1'); +} +if (x[1] !== 2) { + throw new Test262Error('#4: x = new SendableArray(0,1,2,3); x.shift(); x[1] == 2'); +} +x = []; +x[0] = 0; +x[3] = 3; +var shift = x.shift(); +if (shift !== 0) { + throw new Test262Error('#5: x = []; x[0] = 0; x[3] = 3; x.shift() === 0. Actual: ' + (shift)); +} +if (x.length !== 3) { + throw new Test262Error('#6: x = []; x[0] = 0; x[3] = 3; x.shift(); x.length == 3'); +} +if (x[0] !== undefined) { + throw new Test262Error('#7: x = []; x[0] = 0; x[3] = 3; x.shift(); x[0] == undefined'); +} +if (x[12] !== undefined) { + throw new Test262Error('#8: x = []; x[0] = 0; x[3] = 3; x.shift(); x[1] == undefined'); +} +x.length = 1; +var shift = x.shift(); +if (shift !== undefined) { + throw new Test262Error('#9: x = []; x[0] = 0; x[3] = 3; x.shift(); x.length = 1; x.shift() === undefined. Actual: ' + (shift)); +} +if (x.length !== 0) { + throw new Test262Error('#10: x = []; x[0] = 0; x[3] = 3; x.shift(); x.length = 1; x.shift(); x.length === 0. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T1.js b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T1.js new file mode 100644 index 00000000000..19355c9c0ae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T1.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The shift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.shift +description: > + If ToUint32(length) equal zero, call the [[Put]] method of this + object with arguments "length" and 0 and return undefined +---*/ + +var obj = {}; +obj.shift = SendableArray.prototype.shift; +if (obj.length !== undefined) { + throw new Test262Error('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + var shift = obj.shift(); + if (shift !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.shift = SendableArray.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); + } + if (obj.length !== 0) { + throw new Test262Error('#2: var obj = {}; obj.shift = SendableArray.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); + } +} +obj.length = undefined; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#3: var obj = {}; obj.length = undefined; obj.shift = SendableArray.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} +if (obj.length !== 0) { + throw new Test262Error('#4: var obj = {}; obj.length = undefined; obj.shift = SendableArray.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} +obj.length = null +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.length = null; obj.shift = SendableArray.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} +if (obj.length !== 0) { + throw new Test262Error('#6: var obj = {}; obj.length = null; obj.shift = SendableArray.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} diff --git a/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T2.js b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T2.js new file mode 100644 index 00000000000..ea2704b6f28 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T2.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The shift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.shift +description: > + If ToUint32(length) equal zero, call the [[Put]] method of this + object with arguments "length" and 0 and return undefined +---*/ + +var obj = {}; +obj.shift = SendableArray.prototype.shift; +obj.length = NaN; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.length = NaN; obj.shift = SendableArray.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} +if (obj.length !== 0) { + throw new Test262Error('#2: var obj = {}; obj.length = NaN; obj.shift = SendableArray.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} +obj.length = Number.NEGATIVE_INFINITY; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#5: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.shift = SendableArray.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} +if (obj.length !== 0) { + throw new Test262Error('#6: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.shift = SendableArray.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} +obj.length = -0; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#7: var obj = {}; obj.length = -0; obj.shift = SendableArray.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} +if (obj.length !== 0) { + throw new Test262Error('#8: var obj = {}; obj.length = -0; obj.shift = SendableArray.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} else { + if (1 / obj.length !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#8: var obj = {}; obj.length = -0; obj.shift = SendableArray.prototype.shift; obj.shift(); obj.length === +0. Actual: ' + (obj.length)); + } +} +obj.length = 0.5; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#9: var obj = {}; obj.length = 0.5; obj.shift = SendableArray.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} +if (obj.length !== 0) { + throw new Test262Error('#10: var obj = {}; obj.length = 0.5; obj.shift = SendableArray.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} +obj.length = new Number(0); +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#11: var obj = {}; obj.length = new Number(0); obj.shift = SendableArray.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} +if (obj.length !== 0) { + throw new Test262Error('#12: var obj = {}; obj.length = new Number(0); obj.shift = SendableArray.prototype.shift; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} diff --git a/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T3.js b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T3.js new file mode 100644 index 00000000000..baa0ba259a1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T3.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The shift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.shift +description: > + The first element of the array is removed from the array and + returned +---*/ + +var obj = {}; +obj.shift = SendableArray.prototype.shift; +obj.length = 2.5; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.length = 2.5; obj.shift = SendableArray.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} +if (obj.length !== 1) { + throw new Test262Error('#2: var obj = {}; obj.length = 2.5; obj.shift = SendableArray.prototype.shift; obj.shift(); obj.length === 1. Actual: ' + (obj.length)); +} +obj.length = new Number(2); +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#11: var obj = {}; obj.length = new Number(2); obj.shift = SendableArray.prototype.shift; obj.shift() === undefined. Actual: ' + (shift)); +} +if (obj.length !== 1) { + throw new Test262Error('#12: var obj = {}; obj.length = new Number(2); obj.shift = SendableArray.prototype.shift; obj.shift(); obj.length === 1. Actual: ' + (obj.length)); +} diff --git a/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T4.js b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T4.js new file mode 100644 index 00000000000..306f3db2695 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T4.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The shift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.shift +description: > + The first element of the array is removed from the array and + returned +---*/ + +var obj = {}; +obj["0"] = 0; +obj["3"] = 3; +obj.shift = SendableArray.prototype.shift; +obj.length = 4; +var shift = obj.shift(); +if (shift !== 0) { + throw new Test262Error('#1: var obj = {}; obj["0"] = 0; obj["3"] = 3; obj.length = 4; obj.shift = SendableArray.prototype.shift; obj.shift() === 0. Actual: ' + (shift)); +} +if (obj.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj["0"] = 0; obj["3"] = 3; obj.length = 4; obj.shift = SendableArray.prototype.shift; obj.shift(); obj.length === 3. Actual: ' + (obj.length)); +} +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#3: var obj = {}; obj["0"] = 0; obj["3"] = 3; obj.length = 4; obj.shift = SendableArray.prototype.shift; obj.shift(); obj.shift() === undefined. Actual: ' + (shift)); +} +if (obj.length !== 2) { + throw new Test262Error('#4: var obj = {}; obj["0"] = 0; obj["3"] = 3; obj.length = 4; obj.shift = SendableArray.prototype.shift; obj.shift(); obj.shift(); obj.length === 2. Actual: ' + (obj.length)); +} +obj.length = 1; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#5: var obj = {}; obj["0"] = 0; obj["3"] = 3; obj.length = 4; obj.shift = SendableArray.prototype.shift; obj.shift(); obj.shift(); obj.length = 1; obj.shift() === undefined. Actual: ' + (shift)); +} +if (obj.length !== 0) { + throw new Test262Error('#6: var obj = {}; obj["0"] = 0; obj["3"] = 3; obj.length = 4; obj.shift = SendableArray.prototype.shift; obj.shift(); obj.shift(); obj.length = 1; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} diff --git a/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T5.js b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T5.js new file mode 100644 index 00000000000..510feca2996 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A2_T5.js @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The shift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.shift +description: > + Operator use ToNumber from length. If Type(value) is Object, + evaluate ToPrimitive(value, Number) +---*/ + +var obj = {}; +obj.shift = SendableArray.prototype.shift; +obj[0] = -1; +obj.length = { + valueOf() { + return 1 + } +}; +var shift = obj.shift(); +assert.sameValue(shift, -1, 'The value of shift is expected to be -1'); +obj[0] = -1; +obj.length = { + valueOf() { + return 1 + }, + toString() { + return 0 + } +}; +var shift = obj.shift(); +assert.sameValue(shift, -1, 'The value of shift is expected to be -1'); +obj[0] = -1; +obj.length = { + valueOf() { + return 1 + }, + toString() { + return {} + } +}; +var shift = obj.shift(); +assert.sameValue(shift, -1, 'The value of shift is expected to be -1'); +try { + obj[0] = -1; + obj.length = { + valueOf() { + return 1 + }, + toString() { + throw "error" + } + }; + var shift = obj.shift(); + assert.sameValue(shift, -1, 'The value of shift is expected to be -1'); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} +obj[0] = -1; +obj.length = { + toString() { + return 0 + } +}; +var shift = obj.shift(); +assert.sameValue(shift, undefined, 'The value of shift is expected to equal undefined'); +obj[0] = -1; +obj.length = { + valueOf() { + return {} + }, + toString() { + return 0 + } +} +var shift = obj.shift(); +assert.sameValue(shift, undefined, 'The value of shift is expected to equal undefined'); +try { + obj[0] = -1; + obj.length = { + valueOf() { + throw "error" + }, + toString() { + return 0 + } + }; + var shift = obj.shift(); + throw new Test262Error('#7.1: obj[0] = -1; obj.length = {valueOf() {throw "error"}, toString() {return 0}}; obj.shift() throw "error". Actual: ' + (shift)); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} +try { + obj[0] = -1; + obj.length = { + valueOf() { + return {} + }, + toString() { + return {} + } + }; + var shift = obj.shift(); + throw new Test262Error('#8.1: obj[0] = -1; obj.length = {valueOf() {return {}}, toString() {return {}}} obj.shift() throw TypeError. Actual: ' + (shift)); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A3_T3.js b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A3_T3.js new file mode 100644 index 00000000000..1c3bc5648e2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A3_T3.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.shift +description: length is arbitrarily +---*/ + +var obj = {}; +obj.shift = SendableArray.prototype.shift; +obj[0] = "x"; +obj[1] = "y"; +obj.length = -4294967294; +var shift = obj.shift(); +if (shift !== undefined) { + throw new Test262Error('#1: var obj = {}; obj.shift = SendableArray.prototype.shift; obj[0] = "x"; obj[1] = "y"; obj.length = -4294967294; obj.shift() === undefined. Actual: ' + (shift)); +} +if (obj.length !== 0) { + throw new Test262Error('#2: var obj = {}; obj.shift = SendableArray.prototype.shift; obj[0] = "x"; obj[1] = "y"; obj.length = -4294967294; obj.shift(); obj.length === 0. Actual: ' + (obj.length)); +} +if (obj[0] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.shift = SendableArray.prototype.shift; obj[0] = "x"; obj[1] = "y"; obj.length = -4294967294; obj.shift(); obj[0] === "x". Actual: ' + (obj[0])); +} +if (obj[1] !== "y") { + throw new Test262Error('#4: var obj = {}; obj.shift = SendableArray.prototype.shift; obj[0] = "x" obj[1] = "y"; obj.length = -4294967294; obj.shift(); obj[1] === "y". Actual: ' + (obj[1])); +} diff --git a/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A4_T1.js b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A4_T1.js new file mode 100644 index 00000000000..904ec174f3d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A4_T1.js @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.shift +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +SendableArray.prototype[1] = 1; +var x = [0]; +x.length = 2; +var shift = x.shift(); +if (shift !== 0) { + throw new Test262Error('#1: SendableArray.prototype[1] = 1; x = [0]; x.length = 2; x.shift() === 0. Actual: ' + (shift)); +} +if (x[0] !== 1) { + throw new Test262Error('#2: SendableArray.prototype[1] = 1; x = [0]; x.length = 2; x.shift(); x[0] === 1. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#3: SendableArray.prototype[1] = 1; x = [0]; x.length = 2; x.shift(); x[1] === 1. Actual: ' + (x[1])); +} +Object.prototype[1] = 1; +Object.prototype.length = 2; +Object.prototype.shift = SendableArray.prototype.shift; +x = { + 0: 0 +}; +var shift = x.shift(); +if (shift !== 0) { + throw new Test262Error('#4: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.shift = SendableArray.prototype.shift; x = {0:0}; x.shift() === 0. Actual: ' + (shift)); +} +if (x[0] !== 1) { + throw new Test262Error('#5: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.shift = SendableArray.prototype.shift; x = {0:0}; x.shift(); x[0] === 1. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#6: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.shift = SendableArray.prototype.shift; x = {0:0}; x.shift(); x[1] === 1. Actual: ' + (x[1])); +} +if (x.length !== 1) { + throw new Test262Error('#7: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.shift = SendableArray.prototype.shift; x = {0:0}; x.shift(); x.length === 1. Actual: ' + (x.length)); +} +delete x.length; +if (x.length !== 2) { + throw new Test262Error('#8: Object.prototype[1] = 1; Object.prototype.length = 2; Object.prototype.shift = SendableArray.prototype.shift; x = {0:0}; x.shift(); delete x; x.length === 2. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A4_T2.js b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A4_T2.js new file mode 100644 index 00000000000..07e18514a4c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/S15.4.4.9_A4_T2.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.shift +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +SendableArray.prototype[1] = -1; +var x = [0, 1]; +x.length = 2; +var shift = x.shift(); +if (shift !== 0) { + throw new Test262Error('#1: SendableArray.prototype[1] = -1; x = [0,1]; x.length = 2; x.shift() === 0. Actual: ' + (shift)); +} +if (x[0] !== 1) { + throw new Test262Error('#2: SendableArray.prototype[1] = -1; x = [0,1]; x.length = 2; x.shift(); x[0] === 1. Actual: ' + (x[0])); +} +if (x[1] !== -1) { + throw new Test262Error('#3: SendableArray.prototype[1] = -1; x = [0,1]; x.length = 2; x.shift(); x[1] === -1. Actual: ' + (x[1])); +} +Object.prototype[1] = -1; +Object.prototype.length = 2; +Object.prototype.shift = SendableArray.prototype.shift; +x = { + 0: 0, + 1: 1 +}; +var shift = x.shift(); +if (shift !== 0) { + throw new Test262Error('#4: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.shift = SendableArray.prototype.shift; x = {0:0,1:1}; x.shift() === 0. Actual: ' + (shift)); +} +if (x[0] !== 1) { + throw new Test262Error('#5: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.shift = SendableArray.prototype.shift; x = {0:0,1:1}; x.shift(); x[0] === 1. Actual: ' + (x[0])); +} +if (x[1] !== -1) { + throw new Test262Error('#6: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.shift = SendableArray.prototype.shift; x = {0:0,1:1}; x.shift(); x[1] === -1. Actual: ' + (x[1])); +} +if (x.length !== 1) { + throw new Test262Error('#7: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.shift = SendableArray.prototype.shift; x = {0:0,1:1}; x.shift(); x.length === 1. Actual: ' + (x.length)); +} +delete x.length; +if (x.length !== 2) { + throw new Test262Error('#8: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.shift = SendableArray.prototype.shift; x = {0:0,1:1}; x.shift(); delete x; x.length === 2. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/shift/call-with-boolean.js b/test/sendable/builtins/Array/prototype/shift/call-with-boolean.js new file mode 100644 index 00000000000..9d9dc975473 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/call-with-boolean.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.shift +description: Array.prototype.shift applied to boolean primitive +---*/ + +assert.sameValue( + SendableArray.prototype.shift.call(true), + undefined, + 'SendableArray.prototype.shift.call(true) must return undefined' +); +assert.sameValue( + SendableArray.prototype.shift.call(false), + undefined, + 'SendableArray.prototype.shift.call(false) must return undefined' +); diff --git a/test/sendable/builtins/Array/prototype/shift/length.js b/test/sendable/builtins/Array/prototype/shift/length.js new file mode 100644 index 00000000000..b8d8db61b7f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/length.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.shift +description: > + The "length" property of Array.prototype.shift +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.shift, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/shift/name.js b/test/sendable/builtins/Array/prototype/shift/name.js new file mode 100644 index 00000000000..612e85671bb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.shift +description: > + Array.prototype.shift.name is "shift". +info: | + Array.prototype.shift ( ) + 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(SendableArray.prototype.shift, "name", { + value: "shift", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/shift/not-a-constructor.js b/test/sendable/builtins/Array/prototype/shift/not-a-constructor.js new file mode 100644 index 00000000000..45bf3973596 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/not-a-constructor.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.shift 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(SendableArray.prototype.shift), + false, + 'isConstructor(SendableArray.prototype.shift) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.shift(); +}); + diff --git a/test/sendable/builtins/Array/prototype/shift/prop-desc.js b/test/sendable/builtins/Array/prototype/shift/prop-desc.js new file mode 100644 index 00000000000..aaf4542b76e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.shift +description: > + "shift" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.shift, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "shift", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/shift/set-length-array-is-frozen.js b/test/sendable/builtins/Array/prototype/shift/set-length-array-is-frozen.js new file mode 100644 index 00000000000..275f405ac23 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/set-length-array-is-frozen.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.shift +description: > + A TypeError is thrown when "length" is [[Set]] on a frozen array. +---*/ + +var array = new SendableArray(1); +var arrayPrototypeGet0Calls = 0; +Object.defineProperty(SendableArray.prototype, "0", { + get() { + Object.freeze(array); + arrayPrototypeGet0Calls++; + }, +}); +assert.throws(TypeError, function() { + array.shift(); +}); +assert.sameValue(array.length, 1); +assert.sameValue(arrayPrototypeGet0Calls, 1); diff --git a/test/sendable/builtins/Array/prototype/shift/set-length-array-length-is-non-writable.js b/test/sendable/builtins/Array/prototype/shift/set-length-array-length-is-non-writable.js new file mode 100644 index 00000000000..b8d0b2828a8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/set-length-array-length-is-non-writable.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.shift +description: > + A TypeError is thrown when "length" is [[Set]] on an array with non-writable "length". +---*/ + +var array = new SendableArray(1); +var arrayPrototypeGet0Calls = 0; +Object.defineProperty(SendableArray.prototype, "0", { + get() { + Object.defineProperty(array, "length", { writable: false }); + arrayPrototypeGet0Calls++; + }, +}); +assert.throws(TypeError, function() { + array.shift(); +}); +assert.sameValue(array.length, 1); +assert.sameValue(arrayPrototypeGet0Calls, 1); diff --git a/test/sendable/builtins/Array/prototype/shift/set-length-zero-array-is-frozen.js b/test/sendable/builtins/Array/prototype/shift/set-length-zero-array-is-frozen.js new file mode 100644 index 00000000000..f2cd9820dad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/set-length-zero-array-is-frozen.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.shift +description: > + A TypeError is thrown when "length" is [[Set]] on an empty frozen array. +---*/ + +var array = []; +Object.freeze(array); +assert.throws(TypeError, function() { + array.shift(); +}); diff --git a/test/sendable/builtins/Array/prototype/shift/set-length-zero-array-length-is-non-writable.js b/test/sendable/builtins/Array/prototype/shift/set-length-zero-array-length-is-non-writable.js new file mode 100644 index 00000000000..e22cac1f70a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/set-length-zero-array-length-is-non-writable.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.shift +description: > + A TypeError is thrown when "length" is [[Set]] on an empty array with non-writable "length". +---*/ + +var array = []; +Object.defineProperty(array, "length", { writable: false }); +assert.throws(TypeError, function() { + array.shift(); +}); diff --git a/test/sendable/builtins/Array/prototype/shift/throws-when-this-value-length-is-writable-false.js b/test/sendable/builtins/Array/prototype/shift/throws-when-this-value-length-is-writable-false.js new file mode 100644 index 00000000000..1907bd497fa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/shift/throws-when-this-value-length-is-writable-false.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.shift +description: > + Array#shift throws TypeError if this value's "length" property was defined with [[Writable]]: false. +---*/ + +assert.throws(TypeError, () => { + SendableArray.prototype.shift.call(''); +}, "SendableArray.prototype.shift.call('')"); +assert.throws(TypeError, () => { + SendableArray.prototype.shift.call('abc'); +}, "SendableArray.prototype.shift.call('abc')"); +assert.throws(TypeError, () => { + SendableArray.prototype.shift.call(function() {}); +}, "SendableArray.prototype.shift.call(function() {})"); +assert.throws(TypeError, () => { + SendableArray.prototype.shift.call(Object.defineProperty({}, 'length', {writable: false})); +}, "SendableArray.prototype.shift.call(Object.defineProperty({}, 'length', {writable: false}))"); -- Gitee From ea81fd19bf93178c275376b85121bc18262347e6 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 2 Jan 2025 17:21:01 +0800 Subject: [PATCH 65/93] add array-slice Signed-off-by: zhuzhihui7 --- .../prototype/slice/15.4.4.10-10-c-ii-1.js | 31 +++++ .../prototype/slice/S15.4.4.10_A1.1_T1.js | 43 ++++++ .../prototype/slice/S15.4.4.10_A1.1_T2.js | 34 +++++ .../prototype/slice/S15.4.4.10_A1.1_T3.js | 34 +++++ .../prototype/slice/S15.4.4.10_A1.1_T4.js | 34 +++++ .../prototype/slice/S15.4.4.10_A1.1_T5.js | 40 ++++++ .../prototype/slice/S15.4.4.10_A1.1_T6.js | 40 ++++++ .../prototype/slice/S15.4.4.10_A1.1_T7.js | 40 ++++++ .../prototype/slice/S15.4.4.10_A1.2_T1.js | 37 +++++ .../prototype/slice/S15.4.4.10_A1.2_T2.js | 37 +++++ .../prototype/slice/S15.4.4.10_A1.2_T3.js | 37 +++++ .../prototype/slice/S15.4.4.10_A1.2_T4.js | 49 +++++++ .../prototype/slice/S15.4.4.10_A1.3_T1.js | 43 ++++++ .../prototype/slice/S15.4.4.10_A1.3_T2.js | 34 +++++ .../prototype/slice/S15.4.4.10_A1.3_T3.js | 34 +++++ .../prototype/slice/S15.4.4.10_A1.3_T4.js | 34 +++++ .../prototype/slice/S15.4.4.10_A1.4_T1.js | 43 ++++++ .../prototype/slice/S15.4.4.10_A1.4_T2.js | 40 ++++++ .../prototype/slice/S15.4.4.10_A1.4_T3.js | 46 +++++++ .../prototype/slice/S15.4.4.10_A1.4_T4.js | 34 +++++ .../prototype/slice/S15.4.4.10_A1.5_T1.js | 38 ++++++ .../prototype/slice/S15.4.4.10_A1.5_T2.js | 38 ++++++ .../prototype/slice/S15.4.4.10_A2.1_T1.js | 38 ++++++ .../prototype/slice/S15.4.4.10_A2.1_T2.js | 41 ++++++ .../prototype/slice/S15.4.4.10_A2.1_T3.js | 32 +++++ .../prototype/slice/S15.4.4.10_A2.1_T4.js | 41 ++++++ .../prototype/slice/S15.4.4.10_A2.1_T5.js | 48 +++++++ .../prototype/slice/S15.4.4.10_A2.2_T1.js | 38 ++++++ .../prototype/slice/S15.4.4.10_A2.2_T2.js | 32 +++++ .../prototype/slice/S15.4.4.10_A2.2_T3.js | 47 +++++++ .../prototype/slice/S15.4.4.10_A2.2_T4.js | 32 +++++ .../prototype/slice/S15.4.4.10_A2.2_T5.js | 48 +++++++ .../Array/prototype/slice/S15.4.4.10_A2_T1.js | 52 +++++++ .../Array/prototype/slice/S15.4.4.10_A2_T2.js | 52 +++++++ .../Array/prototype/slice/S15.4.4.10_A2_T3.js | 52 +++++++ .../Array/prototype/slice/S15.4.4.10_A2_T4.js | 52 +++++++ .../Array/prototype/slice/S15.4.4.10_A2_T5.js | 50 +++++++ .../Array/prototype/slice/S15.4.4.10_A2_T6.js | 50 +++++++ .../Array/prototype/slice/S15.4.4.10_A3_T1.js | 28 ++++ .../Array/prototype/slice/S15.4.4.10_A3_T2.js | 28 ++++ .../Array/prototype/slice/S15.4.4.10_A3_T3.js | 31 +++++ .../Array/prototype/slice/S15.4.4.10_A4_T1.js | 33 +++++ .../prototype/slice/call-with-boolean.js | 22 +++ .../prototype/slice/coerced-start-end-grow.js | 66 +++++++++ .../slice/coerced-start-end-shrink.js | 106 ++++++++++++++ .../prototype/slice/create-ctor-non-object.js | 40 ++++++ .../prototype/slice/create-ctor-poisoned.js | 29 ++++ .../slice/create-non-array-invalid-len.js | 37 +++++ .../Array/prototype/slice/create-non-array.js | 33 +++++ .../create-proto-from-ctor-realm-array.js | 34 +++++ .../create-proto-from-ctor-realm-non-array.js | 35 +++++ .../slice/create-proxied-array-invalid-len.js | 44 ++++++ .../Array/prototype/slice/create-proxy.js | 28 ++++ .../prototype/slice/create-revoked-proxy.js | 32 +++++ .../prototype/slice/create-species-abrupt.js | 29 ++++ .../slice/create-species-neg-zero.js | 30 ++++ .../slice/create-species-non-ctor.js | 33 +++++ .../prototype/slice/create-species-null.js | 28 ++++ .../slice/create-species-poisoned.js | 30 ++++ .../prototype/slice/create-species-undef.js | 29 ++++ .../Array/prototype/slice/create-species.js | 38 ++++++ ...h-exceeding-integer-limit-proxied-array.js | 61 +++++++++ .../slice/length-exceeding-integer-limit.js | 52 +++++++ .../builtins/Array/prototype/slice/length.js | 39 ++++++ .../builtins/Array/prototype/slice/name.js | 36 +++++ .../prototype/slice/not-a-constructor.js | 38 ++++++ .../Array/prototype/slice/prop-desc.js | 32 +++++ .../Array/prototype/slice/resizable-buffer.js | 129 ++++++++++++++++++ .../slice/target-array-non-extensible.js | 32 +++++ ...et-array-with-non-configurable-property.js | 34 +++++ ...target-array-with-non-writable-property.js | 33 +++++ 71 files changed, 2874 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/slice/15.4.4.10-10-c-ii-1.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T2.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T3.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T4.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T5.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T6.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T7.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T3.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T4.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T1.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T2.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T3.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T4.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T1.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T2.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T3.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T4.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.5_T1.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.5_T2.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T2.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T3.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T4.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T5.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T3.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T4.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T5.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T3.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T4.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T5.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T6.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A3_T1.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A3_T2.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A3_T3.js create mode 100644 test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A4_T1.js create mode 100644 test/sendable/builtins/Array/prototype/slice/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/slice/coerced-start-end-grow.js create mode 100644 test/sendable/builtins/Array/prototype/slice/coerced-start-end-shrink.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-ctor-non-object.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-ctor-poisoned.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-non-array-invalid-len.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-non-array.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-proto-from-ctor-realm-array.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-proto-from-ctor-realm-non-array.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-proxied-array-invalid-len.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-proxy.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-revoked-proxy.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-species-abrupt.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-species-neg-zero.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-species-non-ctor.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-species-null.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-species-poisoned.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-species-undef.js create mode 100644 test/sendable/builtins/Array/prototype/slice/create-species.js create mode 100644 test/sendable/builtins/Array/prototype/slice/length-exceeding-integer-limit-proxied-array.js create mode 100644 test/sendable/builtins/Array/prototype/slice/length-exceeding-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/slice/length.js create mode 100644 test/sendable/builtins/Array/prototype/slice/name.js create mode 100644 test/sendable/builtins/Array/prototype/slice/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/slice/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/slice/resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/slice/target-array-non-extensible.js create mode 100644 test/sendable/builtins/Array/prototype/slice/target-array-with-non-configurable-property.js create mode 100644 test/sendable/builtins/Array/prototype/slice/target-array-with-non-writable-property.js diff --git a/test/sendable/builtins/Array/prototype/slice/15.4.4.10-10-c-ii-1.js b/test/sendable/builtins/Array/prototype/slice/15.4.4.10-10-c-ii-1.js new file mode 100644 index 00000000000..a9f9f137303 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/15.4.4.10-10-c-ii-1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + Array.prototype.slice will slice a string from start to end when + index property (read-only) exists in Array.prototype (Step 10.c.ii) +---*/ + +var arrObj = [1, 2, 3]; +Object.defineProperty(SendableArray.prototype, "0", { + value: "test", + writable: false, + configurable: true +}); +var newArr = arrObj.slice(0, 1); +assert(newArr.hasOwnProperty("0"), 'newArr.hasOwnProperty("0") !== true'); +assert.sameValue(newArr[0], 1, 'newArr[0]'); +assert.sameValue(typeof newArr[1], "undefined", 'typeof newArr[1]'); diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T1.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T1.js new file mode 100644 index 00000000000..b699d21ea69 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T1.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length > end > start = 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(0, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(0,3); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T2.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T2.js new file mode 100644 index 00000000000..4ef85956420 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T2.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length > end = start > 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(3, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(3,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(3,3); arr.length === 0. Actual: ' + (arr.length)); +} +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(3,3); arr[0] === undefined. Actual: ' + (arr[0])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T3.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T3.js new file mode 100644 index 00000000000..d2b3c39a3f8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T3.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length > start > end > 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(4, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(4,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(4,3); arr.length === 0. Actual: ' + (arr.length)); +} +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(4,3); arr[0] === undefined. Actual: ' + (arr[0])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T4.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T4.js new file mode 100644 index 00000000000..321854c70a7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T4.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length = end = start > 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(5, 5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(5,5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(5,5); arr.length === 0. Actual: ' + (arr.length)); +} +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(5,5); arr[0] === undefined. Actual: ' + (arr[0])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T5.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T5.js new file mode 100644 index 00000000000..7c03cdd83a0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T5.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length = end > start > 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(3, 5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(3,5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(3,5); arr.length === 2. Actual: ' + (arr.length)); +} +if (arr[0] !== 3) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(3,5); arr[0] === 3. Actual: ' + (arr[0])); +} +if (arr[1] !== 4) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(3,5); arr[1] === 4. Actual: ' + (arr[1])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(3,5); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T6.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T6.js new file mode 100644 index 00000000000..10a237f8ec8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T6.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length > end > start > 0; +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(2, 4); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(2,4); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(2,4); arr.length === 2. Actual: ' + (arr.length)); +} +if (arr[0] !== 2) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(2,4); arr[0] === 2. Actual: ' + (arr[0])); +} +if (arr[1] !== 3) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(2,4); arr[1] === 3. Actual: ' + (arr[1])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(2,4); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T7.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T7.js new file mode 100644 index 00000000000..b32385b55bd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.1_T7.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: end > length > start > 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(3, 6); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(3,6); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(3,6); arr.length === 2. Actual: ' + (arr.length)); +} +if (arr[0] !== 3) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(3,6); arr[0] === 3. Actual: ' + (arr[0])); +} +if (arr[1] !== 4) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(3,6); arr[1] === 4. Actual: ' + (arr[1])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(3,6); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T1.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T1.js new file mode 100644 index 00000000000..4f683025e7a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T1.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length > end = abs(start), start < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-3, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-3,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 1) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-3,3); arr.length === 1. Actual: ' + (arr.length)); +} +if (arr[0] !== 2) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-3,3); arr[0] === 2. Actual: ' + (arr[0])); +} +if (arr[1] !== undefined) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-3,3); arr[1] === undefined. Actual: ' + (arr[1])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T2.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T2.js new file mode 100644 index 00000000000..58bbc89e525 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T2.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: length = end > abs(start), start < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-1, 5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-1,5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 1) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-1,5); arr.length === 1. Actual: ' + (arr.length)); +} +if (arr[0] !== 4) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-1,5); arr[0] === 4. Actual: ' + (arr[0])); +} +if (arr[1] !== undefined) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-1,5); arr[1] === undefined. Actual: ' + (arr[1])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T3.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T3.js new file mode 100644 index 00000000000..5148721838a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T3.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: abs(start) = length > end > 0, start < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-5, 1); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-5,1); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 1) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-5,1); arr.length === 1. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-5,1); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== undefined) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-5,1); arr[1] === undefined. Actual: ' + (arr[1])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T4.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T4.js new file mode 100644 index 00000000000..8fb05b22605 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.2_T4.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is positive, use min(end, length) +esid: sec-array.prototype.slice +description: abs(start) > length = end > 0, start < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-9, 5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 5) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr.length === 5. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[3] === 3. Actual: ' + (arr[3])); +} +if (arr[4] !== 4) { + throw new Test262Error('#7: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[4] === 4. Actual: ' + (arr[4])); +} +if (arr[5] !== undefined) { + throw new Test262Error('#8: var x = [0,1,2,3,4]; var arr = x.slice(-9,5); arr[5] === undefined. Actual: ' + (arr[5])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T1.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T1.js new file mode 100644 index 00000000000..aa810dc1564 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T1.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: length > abs(end) > start = 0, end < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(0, -2); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(0,-2); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T2.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T2.js new file mode 100644 index 00000000000..acbd56b0de5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T2.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: length > abs(end) > start > 0, end < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(1, -4); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(1,-4); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(1,-4); arr.length === 0. Actual: ' + (arr.length)); +} +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(1,-4); arr[0] === undefined. Actual: ' + (arr[0])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T3.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T3.js new file mode 100644 index 00000000000..ad8b42ba98f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T3.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: length = abs(end) > start = 0, end < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(0, -5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,-5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,-5); arr.length === 0. Actual: ' + (arr.length)); +} +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,-5); arr[0] === undefined. Actual: ' + (arr[0])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T4.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T4.js new file mode 100644 index 00000000000..9dde77108a7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.3_T4.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: abs(end) > length > start > 0, end < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(4, -9); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(4,-9); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(4,-9); arr.length === 0. Actual: ' + (arr.length)); +} +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(4,-9); arr[0] === undefined. Actual: ' + (arr[0])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T1.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T1.js new file mode 100644 index 00000000000..d1eeefbf21c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T1.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: -length = start < end < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-5, -2); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(-5,-2); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T2.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T2.js new file mode 100644 index 00000000000..ee9d5ff1e0c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T2.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: -length < start < end < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-3, -1); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-3,-1); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-3,-1); arr.length === 2. Actual: ' + (arr.length)); +} +if (arr[0] !== 2) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-3,-1); arr[0] === 2. Actual: ' + (arr[0])); +} +if (arr[1] !== 3) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-3,-1); arr[1] === 3. Actual: ' + (arr[1])); +} +if (arr[2] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(-3,-1); arr[2] === undefined. Actual: ' + (arr[2])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T3.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T3.js new file mode 100644 index 00000000000..493b089c8b4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T3.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: start < -length < end < 0 +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-9, -1); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 4) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr.length === 4. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr[3] === 3. Actual: ' + (arr[3])); +} +if (arr[4] !== undefined) { + throw new Test262Error('#7: var x = [0,1,2,3,4]; var arr = x.slice(-9,-1); arr[4] === undefined. Actual: ' + (arr[4])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T4.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T4.js new file mode 100644 index 00000000000..875c65df7b2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.4_T4.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If end is negative, use max(end + length, 0) +esid: sec-array.prototype.slice +description: start = end < -length +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-6, -6); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-6,-6); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-6,-6); arr.length === 0. Actual: ' + (arr.length)); +} +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-6,-6); arr[0] === undefined. Actual: ' + (arr[0])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.5_T1.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.5_T1.js new file mode 100644 index 00000000000..bfb1e151da5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.5_T1.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: If end is undefined use length +esid: sec-array.prototype.slice +description: end === undefined +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(3, undefined); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(3, undefined); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(3, undefined); arr.length === 2. Actual: ' + (arr.length)); +} +if (arr[0] !== 3) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(3, undefined); arr[0] === 3. Actual: ' + (arr[0])); +} +if (arr[1] !== 4) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(3, undefined); arr[1] === 4. Actual: ' + (arr[1])); +} +if (arr[2] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(3, undefined); arr[2] === undefined. Actual: ' + (arr[2])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.5_T2.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.5_T2.js new file mode 100644 index 00000000000..6ece01610f5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A1.5_T2.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: If end is undefined use length +esid: sec-array.prototype.slice +description: end is absent +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(-2); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(-2); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(-2); arr.length === 2. Actual: ' + (arr.length)); +} +if (arr[0] !== 3) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(-2); arr[0] === 3. Actual: ' + (arr[0])); +} +if (arr[1] !== 4) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(-2); arr[1] === 4. Actual: ' + (arr[1])); +} +if (arr[2] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(-2); arr[2] === undefined. Actual: ' + (arr[2])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T1.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T1.js new file mode 100644 index 00000000000..3af3a1935a5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T1.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.slice +description: start is not integer +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(2.5, 4); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(2.5,4); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(2.5,4); arr.length === 2. Actual: ' + (arr.length)); +} +if (arr[0] !== 2) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(2.5,4); arr[0] === 2. Actual: ' + (arr[0])); +} +if (arr[1] !== 3) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(2.5,4); arr[1] === 3. Actual: ' + (arr[1])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(2.5,4); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T2.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T2.js new file mode 100644 index 00000000000..ed50994a044 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T2.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.slice +description: start = NaN +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(NaN, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(NaN,3); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T3.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T3.js new file mode 100644 index 00000000000..dfcf07d5935 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T3.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.slice +description: start = Infinity +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(Number.POSITIVE_INFINITY, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(Number.POSITIVE_INFINITY,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(Number.POSITIVE_INFINITY,3); arr.length === 0. Actual: ' + (arr.length)); +} +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(Number.POSITIVE_INFINITY,3); arr[0] === undefined. Actual: ' + (arr[0])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T4.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T4.js new file mode 100644 index 00000000000..8eb3c56bf88 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T4.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.slice +description: start = -Infinity +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(Number.NEGATIVE_INFINITY, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(Number.NEGATIVE_INFINITY,3); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T5.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T5.js new file mode 100644 index 00000000000..04ee6050e3d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.1_T5.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.slice +description: ToInteger use ToNumber +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice({ + valueOf: function() { + return 0 + }, + toString: function() { + return 3 + } +}, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T1.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T1.js new file mode 100644 index 00000000000..de6b7fd4c4a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T1.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from end +esid: sec-array.prototype.slice +description: end is not integer +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(2, 4.5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(2,4.5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 2) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(2,4.5); arr.length === 2. Actual: ' + (arr.length)); +} +if (arr[0] !== 2) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(2,4.5); arr[0] === 2. Actual: ' + (arr[0])); +} +if (arr[1] !== 3) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(2,4.5); arr[1] === 3. Actual: ' + (arr[1])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(2,4.5); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T2.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T2.js new file mode 100644 index 00000000000..d5c9a6d180e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T2.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from end +esid: sec-array.prototype.slice +description: end = NaN +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(0, NaN); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,NaN); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,NaN); arr.length === 0. Actual: ' + (arr.length)); +} +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,NaN); arr[0] === undefined. Actual: ' + (arr[0])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T3.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T3.js new file mode 100644 index 00000000000..d7ff39454a4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T3.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from end +esid: sec-array.prototype.slice +description: end = Infinity +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(0, Number.POSITIVE_INFINITY); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 5) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr.length === 5. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[3] === 3. Actual: ' + (arr[3])); +} +if (arr[4] !== 4) { + throw new Test262Error('#7: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[4] === 4. Actual: ' + (arr[4])); +} +if (arr[5] !== undefined) { + throw new Test262Error('#8: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.POSITIVE_INFINITY); arr[5] === undefined. Actual: ' + (arr[5])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T4.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T4.js new file mode 100644 index 00000000000..5a837ca2b69 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T4.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from end +esid: sec-array.prototype.slice +description: end = -Infinity +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(0, Number.NEGATIVE_INFINITY); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.NEGATIVE_INFINITY); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.NEGATIVE_INFINITY); arr.length === 0. Actual: ' + (arr.length)); +} +if (arr[0] !== undefined) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,Number.NEGATIVE_INFINITY); arr[0] === undefined. Actual: ' + (arr[0])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T5.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T5.js new file mode 100644 index 00000000000..9f03e5d0a30 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2.2_T5.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from end +esid: sec-array.prototype.slice +description: ToInteger use ToNumber +---*/ + +var x = [0, 1, 2, 3, 4]; +var arr = x.slice(0, { + valueOf: function() { + return 3 + }, + toString: function() { + return 0 + } +}); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3,4]; var arr = x.slice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3,4]; var arr = x.slice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3,4]; var arr = x.slice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3,4]; var arr = x.slice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3,4]; var arr = x.slice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#6: var x = [0,1,2,3,4]; var arr = x.slice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T1.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T1.js new file mode 100644 index 00000000000..cedcb9fff92 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T1.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The slice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.slice +description: > + If start is positive, use min(start, length). If end is positive, + use min(end, length) +---*/ + +var obj = {}; +obj.slice = SendableArray.prototype.slice; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +obj[4] = 4; +obj.length = 5; +var arr = obj.slice(0, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,3); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,3); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,3); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,3); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.slice = Array.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,3); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T2.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T2.js new file mode 100644 index 00000000000..32e6cfb6b35 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T2.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The slice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.slice +description: > + If start is negative, use max(start + length, 0). If end is + positive, use min(end, length) +---*/ + +var obj = {}; +obj.slice = SendableArray.prototype.slice; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +obj[4] = 4; +obj.length = 5; +var arr = obj.slice(-5, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "SendableArray" + "]") { + throw new Test262Error('#1: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,3); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,3); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,3); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,3); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,3); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T3.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T3.js new file mode 100644 index 00000000000..5a431e085c5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T3.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The slice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.slice +description: > + If start is positive, use min(start, length). If end is negative, + use max(end + length, 0) +---*/ + +var obj = {}; +obj.slice = SendableArray.prototype.slice; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +obj[4] = 4; +obj.length = 5; +var arr = obj.slice(0, -2); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "SendableArray" + "]") { + throw new Test262Error('#1: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,-2); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,-2); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,-2); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,-2); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,-2); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(0,-2); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T4.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T4.js new file mode 100644 index 00000000000..5dcaef63972 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T4.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The slice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.slice +description: > + If start is negative, use max(start + length, 0). If end is + negative, use max(end + length, 0) +---*/ + +var obj = {}; +obj.slice = SendableArray.prototype.slice; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +obj[4] = 4; +obj.length = 5; +var arr = obj.slice(-5, -2); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "SendableArray" + "]") { + throw new Test262Error('#1: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,-2); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,-2); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,-2); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,-2); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,-2); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(-5,-2); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T5.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T5.js new file mode 100644 index 00000000000..085db772698 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T5.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The slice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.slice +description: If end is undefined use length +---*/ + +var obj = {}; +obj.slice = SendableArray.prototype.slice; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +obj[4] = 4; +obj.length = 5; +var arr = obj.slice(2); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "SendableArray" + "]") { + throw new Test262Error('#1: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 2) { + throw new Test262Error('#3: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2); arr[0] === 2. Actual: ' + (arr[0])); +} +if (arr[1] !== 3) { + throw new Test262Error('#4: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2); arr[1] === 3. Actual: ' + (arr[1])); +} +if (arr[2] !== 4) { + throw new Test262Error('#5: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2); arr[2] === 4. Actual: ' + (arr[2])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T6.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T6.js new file mode 100644 index 00000000000..07399af9b4a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A2_T6.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The slice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.slice +description: If end is undefined use length +---*/ + +var obj = {}; +obj.slice = SendableArray.prototype.slice; +obj[0] = 0; +obj[1] = 1; +obj[2] = 2; +obj[3] = 3; +obj[4] = 4; +obj.length = 5; +var arr = obj.slice(2, undefined); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "SendableArray" + "]") { + throw new Test262Error('#1: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2, undefined); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2, undefined); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 2) { + throw new Test262Error('#3: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2, undefined); arr[0] === 2. Actual: ' + (arr[0])); +} +if (arr[1] !== 3) { + throw new Test262Error('#4: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2, undefined); arr[1] === 3. Actual: ' + (arr[1])); +} +if (arr[2] !== 4) { + throw new Test262Error('#5: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2, undefined); arr[2] === 4. Actual: ' + (arr[2])); +} +if (arr[3] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[0] = 0; obj[1] = 1; obj[2] = 2; obj[3] = 3; obj[4] = 4; obj.length = 5; var arr = obj.slice(2, undefined); arr[3] === undefined. Actual: ' + (arr[3])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A3_T1.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A3_T1.js new file mode 100644 index 00000000000..c1a3ec3ad07 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A3_T1.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.slice +description: length = 4294967296 +---*/ + +assert.throws(RangeError, () => { + var obj = {}; + obj.slice = SendableArray.prototype.slice; + obj[0] = "x"; + obj[4294967295] = "y"; + obj.length = 4294967296; + obj.slice(0, 4294967296); +}); diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A3_T2.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A3_T2.js new file mode 100644 index 00000000000..064dfc336be --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A3_T2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.slice +description: length = 4294967297 +---*/ + +assert.throws(RangeError, () => { + var obj = {}; + obj.slice = SendableArray.prototype.slice; + obj[0] = "x"; + obj[4294967296] = "y"; + obj.length = 4294967297; + obj.slice(0, 4294967297); +}); diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A3_T3.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A3_T3.js new file mode 100644 index 00000000000..5a111f15a1f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A3_T3.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToUint32(length) for non Array objects +esid: sec-array.prototype.slice +description: length = -1 +---*/ + +var obj = {}; +obj.slice = SendableArray.prototype.slice; +obj[4294967294] = "x"; +obj.length = -1; +var arr = obj.slice(4294967294, 4294967295); +if (arr.length !== 0) { + throw new Test262Error('#1: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[4294967294] = "x"; obj.length = 4294967295; var arr = obj.slice(4294967294,4294967295); arr.length === 0. Actual: ' + (arr.length)); +} +if (arr[0] !== undefined) { + throw new Test262Error('#3: var obj = {}; obj.slice = SendableArray.prototype.slice; obj[4294967294] = "x"; obj.length = 4294967295; var arr = obj.slice(4294967294,4294967295); arr[0] === undefined. Actual: ' + (arr[0])); +} diff --git a/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A4_T1.js b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A4_T1.js new file mode 100644 index 00000000000..e1f06243d92 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/S15.4.4.10_A4_T1.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]] from not an inherited property" +esid: sec-array.prototype.slice +description: "[[Prototype]] of Array instance is Array.prototype" +---*/ + +SendableArray.prototype[1] = 1; +var x = [0]; +x.length = 2; +var arr = x.slice(); +if (arr[0] !== 0) { + throw new Test262Error('#1: SendableArray.prototype[1] = 1; x = [0]; x.length = 2; var arr = x.slice(); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#2: SendableArray.prototype[1] = 1; x = [0]; x.length = 2; var arr = x.slice(); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr.hasOwnProperty('1') !== true) { + throw new Test262Error('#3: SendableArray.prototype[1] = 1; x = [0]; x.length = 2; var arr = x.slice(); arr.hasOwnProperty(\'1\') === true. Actual: ' + (arr.hasOwnProperty('1'))); +} diff --git a/test/sendable/builtins/Array/prototype/slice/call-with-boolean.js b/test/sendable/builtins/Array/prototype/slice/call-with-boolean.js new file mode 100644 index 00000000000..0cb879d173a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/call-with-boolean.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: Array.prototype.slice applied to boolean primitive +includes: [compareArray.js] +---*/ + +assert.compareArray(SendableArray.prototype.slice.call(true), [], 'SendableArray.prototype.slice.call(true) must return []'); +assert.compareArray(SendableArray.prototype.slice.call(false), [], 'SendableArray.prototype.slice.call(false) must return []'); diff --git a/test/sendable/builtins/Array/prototype/slice/coerced-start-end-grow.js b/test/sendable/builtins/Array/prototype/slice/coerced-start-end-grow.js new file mode 100644 index 00000000000..6c118461539 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/coerced-start-end-grow.js @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + Array.p.slice behaves correctly on TypedArrays backed by resizable buffers that + are grown by argument coercion. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// The start argument grows the resizable array buffer rab. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); + } + const evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTracking, evil)), [ + 1, + 2, + 3, + 4 + ]); + assert.sameValue(rab.byteLength, 6 * ctor.BYTES_PER_ELEMENT); +} + +// The end argument grows the resizable array buffer rab. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); + } + const evil = { + valueOf: () => { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + return 5; + } + }; + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTracking,4,evil)), [ + ]); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTracking,3,evil)), [ + 4, + 0 + ]); + assert.sameValue(rab.byteLength, 6 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/Array/prototype/slice/coerced-start-end-shrink.js b/test/sendable/builtins/Array/prototype/slice/coerced-start-end-shrink.js new file mode 100644 index 00000000000..697908655f4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/coerced-start-end-shrink.js @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + Array.p.slice behaves correctly on TypedArrays backed by resizable buffers that + are shrunk by argument coercion. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// The start argument shrinks the resizable array buffer rab. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(fixedLength, evil)), [ + undefined, + undefined, + undefined, + undefined + ]); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(fixedLength, evil)), [ + ]); + assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); + } + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 0; + } + }; + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTracking, evil)), [ + 1, + 2, + undefined, + undefined + ]); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTracking, evil)), [ + 1, + 2 + ]); + assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); +} + +// The end argument shrinks the resizable array buffer rab. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 3; + } + }; + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(fixedLength, 2, evil)), [ + undefined + ]); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(fixedLength, 2, evil)), [ + ]); + assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + for (let i = 0; i < 4; ++i) { + lengthTracking[i] = MayNeedBigInt(lengthTracking, i + 1); + } + const evil = { + valueOf: () => { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + return 3; + } + }; + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTracking, 1, evil)), [ + 2, + undefined + ]); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTracking, 1, evil)), [ + 2 + ]); + assert.sameValue(rab.byteLength, 2 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/Array/prototype/slice/create-ctor-non-object.js b/test/sendable/builtins/Array/prototype/slice/create-ctor-non-object.js new file mode 100644 index 00000000000..705f69bc76d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-ctor-non-object.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + Behavior when `constructor` property is neither an Object nor undefined +---*/ + +var a = []; +a.constructor = null; +assert.throws(TypeError, function() { + a.slice(); +}, 'null value'); +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.slice(); +}, 'number value'); +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.slice(); +}, 'string value'); +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.slice(); +}, 'boolean value'); diff --git a/test/sendable/builtins/Array/prototype/slice/create-ctor-poisoned.js b/test/sendable/builtins/Array/prototype/slice/create-ctor-poisoned.js new file mode 100644 index 00000000000..4d043896e94 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-ctor-poisoned.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: Abrupt completion from `constructor` property access +info: | +---*/ + +var a = []; +Object.defineProperty(a, 'constructor', { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + a.slice(); +}); diff --git a/test/sendable/builtins/Array/prototype/slice/create-non-array-invalid-len.js b/test/sendable/builtins/Array/prototype/slice/create-non-array-invalid-len.js new file mode 100644 index 00000000000..c3f989ec125 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-non-array-invalid-len.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: Abrupt completion from creating a new array +---*/ + +var callCount = 0; +var maxLength = Math.pow(2, 32); +var obj = Object.defineProperty({}, 'length', { + get: function() { + return maxLength; + }, + set: function() { + callCount += 1; + } +}); +assert.throws(RangeError, function() { + SendableArray.prototype.slice.call(obj); +}); +assert.sameValue( + callCount, + 0, + 'RangeError thrown during SendableArray creation, not property modification' +); diff --git a/test/sendable/builtins/Array/prototype/slice/create-non-array.js b/test/sendable/builtins/Array/prototype/slice/create-non-array.js new file mode 100644 index 00000000000..d90eaf51c7d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-non-array.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: Constructor is ignored for non-Array values +---*/ + +var obj = { + length: 0 +}; +var callCount = 0; +var result; +Object.defineProperty(obj, 'constructor', { + get: function() { + callCount += 1; + } +}); +result = SendableArray.prototype.slice.call(obj); +assert.sameValue(callCount, 0, '`constructor` property not accessed'); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert(SendableArray.isArray(result), 'result is an SendableArray exotic object'); diff --git a/test/sendable/builtins/Array/prototype/slice/create-proto-from-ctor-realm-array.js b/test/sendable/builtins/Array/prototype/slice/create-proto-from-ctor-realm-array.js new file mode 100644 index 00000000000..a6cd13db7da --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-proto-from-ctor-realm-array.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: Prefer Array constructor of current realm record +---*/ + +var array = []; +var callCount = 0; +var OArray = $262.createRealm().global.SendableArray; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OArray; +Object.defineProperty(SendableArray, Symbol.species, speciesDesc); +Object.defineProperty(OArray, Symbol.species, speciesDesc); +result = array.slice(); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert.sameValue(callCount, 0, 'Species constructor is not referenced'); diff --git a/test/sendable/builtins/Array/prototype/slice/create-proto-from-ctor-realm-non-array.js b/test/sendable/builtins/Array/prototype/slice/create-proto-from-ctor-realm-non-array.js new file mode 100644 index 00000000000..695af42dcda --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-proto-from-ctor-realm-non-array.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: Accept non-Array constructors from other realms +---*/ + +var array = []; +var callCount = 0; +var CustomCtor = function() {}; +var OObject = $262.createRealm().global.Object; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OObject; +OObject[Symbol.species] = CustomCtor; +Object.defineProperty(SendableArray, Symbol.species, speciesDesc); +result = array.slice(); +assert.sameValue(Object.getPrototypeOf(result), CustomCtor.prototype); +assert.sameValue(callCount, 0, 'SendableArray species constructor is not referenced'); diff --git a/test/sendable/builtins/Array/prototype/slice/create-proxied-array-invalid-len.js b/test/sendable/builtins/Array/prototype/slice/create-proxied-array-invalid-len.js new file mode 100644 index 00000000000..21bf227b04f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-proxied-array-invalid-len.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + Ensure a RangeError is thrown when a proxied array returns an invalid array length. +features: [Proxy] +---*/ + +var array = []; +var maxLength = Math.pow(2, 32); +var callCount = 0; +var proxy = new Proxy(array, { + get: function(_, name) { + if (name === 'length') { + return maxLength; + } + return array[name]; + }, + set: function() { + callCount += 1; + return true; + } +}); +assert.throws(RangeError, function() { + SendableArray.prototype.slice.call(proxy); +}); +assert.sameValue( + callCount, + 0, + 'RangeError thrown during array creation, not property modification' +); diff --git a/test/sendable/builtins/Array/prototype/slice/create-proxy.js b/test/sendable/builtins/Array/prototype/slice/create-proxy.js new file mode 100644 index 00000000000..0c1de8e21cb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-proxy.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: Species constructor of a Proxy object whose target is an array +features: [Proxy, Symbol.species] +---*/ + +var array = []; +var proxy = new Proxy(new Proxy(array, {}), {}); +var Ctor = function() {}; +var result; +array.constructor = function() {}; +array.constructor[Symbol.species] = Ctor; +result = SendableArray.prototype.slice.call(proxy); +assert.sameValue(Object.getPrototypeOf(result), Ctor.prototype); diff --git a/test/sendable/builtins/Array/prototype/slice/create-revoked-proxy.js b/test/sendable/builtins/Array/prototype/slice/create-revoked-proxy.js new file mode 100644 index 00000000000..8472c56935f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-revoked-proxy.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: Abrupt completion from constructor that is a revoked Proxy object +features: [Proxy] +---*/ + +var o = Proxy.revocable([], {}); +var callCount = 0; +Object.defineProperty(o.proxy, 'constructor', { + get: function() { + callCount += 1; + } +}); +o.revoke(); +assert.throws(TypeError, function() { + SendableArray.prototype.slice.call(o.proxy); +}); +assert.sameValue(callCount, 0, '`constructor` property not accessed'); diff --git a/test/sendable/builtins/Array/prototype/slice/create-species-abrupt.js b/test/sendable/builtins/Array/prototype/slice/create-species-abrupt.js new file mode 100644 index 00000000000..e2676dc658b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-species-abrupt.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: Species constructor returns an abrupt completion +features: [Symbol.species] +---*/ + +var Ctor = function() { + throw new Test262Error(); +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; +assert.throws(Test262Error, function() { + a.slice(); +}); diff --git a/test/sendable/builtins/Array/prototype/slice/create-species-neg-zero.js b/test/sendable/builtins/Array/prototype/slice/create-species-neg-zero.js new file mode 100644 index 00000000000..1007d2fd3d8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-species-neg-zero.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: The value `-0` is converted to `0` +features: [Symbol.species] +---*/ + +var args; +var Ctor = function() { + args = arguments; +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; +a.slice(0, -0); +assert.sameValue(args.length, 1); +assert.sameValue(args[0], 0); diff --git a/test/sendable/builtins/Array/prototype/slice/create-species-non-ctor.js b/test/sendable/builtins/Array/prototype/slice/create-species-non-ctor.js new file mode 100644 index 00000000000..225fa13f511 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-species-non-ctor.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + Behavior when the @@species attribute is a non-constructor object +includes: [isConstructor.js] +features: [Symbol.species, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(parseInt), + false, + 'precondition: isConstructor(parseInt) must return false' +); +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; +assert.throws(TypeError, function() { + a.slice(); +}, 'a.slice() throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/slice/create-species-null.js b/test/sendable/builtins/Array/prototype/slice/create-species-null.js new file mode 100644 index 00000000000..e0e0f48e3be --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-species-null.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + A null value for the @@species constructor is interpreted as `undefined` +features: [Symbol.species] +---*/ + +var a = []; +var result; +a.constructor = {}; +a.constructor[Symbol.species] = null; +result = a.slice(); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert(SendableArray.isArray(result), 'result is an SendableArray exotic object'); diff --git a/test/sendable/builtins/Array/prototype/slice/create-species-poisoned.js b/test/sendable/builtins/Array/prototype/slice/create-species-poisoned.js new file mode 100644 index 00000000000..4b7fe9b9c5e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-species-poisoned.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: Abrupt completion from `@@species` property access +features: [Symbol.species] +---*/ + +var a = []; +a.constructor = {}; +Object.defineProperty(a.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + a.slice(); +}); diff --git a/test/sendable/builtins/Array/prototype/slice/create-species-undef.js b/test/sendable/builtins/Array/prototype/slice/create-species-undef.js new file mode 100644 index 00000000000..871f2163fe8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-species-undef.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + An undefined value for the @@species constructor triggers the creation of + an Array exotic object +features: [Symbol.species] +---*/ + +var a = []; +var result; +a.constructor = {}; +a.constructor[Symbol.species] = undefined; +result = a.slice(); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert(SendableArray.isArray(result), 'result is an SendableArray exotic object'); diff --git a/test/sendable/builtins/Array/prototype/slice/create-species.js b/test/sendable/builtins/Array/prototype/slice/create-species.js new file mode 100644 index 00000000000..b51f823644a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/create-species.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: Species constructor is used to create a new instance +features: [Symbol.species] +---*/ + +var thisValue, args, result; +var callCount = 0; +var instance = []; +var Ctor = function() { + callCount += 1; + thisValue = this; + args = arguments; + return instance; +}; +var a = [1, 2, 3, 4, 5]; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; +result = a.slice(1, -1); +assert.sameValue(callCount, 1, 'Constructor invoked exactly once'); +assert.sameValue(Object.getPrototypeOf(thisValue), Ctor.prototype); +assert.sameValue(args.length, 1, 'Constructor invoked with a single argument'); +assert.sameValue(args[0], 3); +assert.sameValue(result, instance); diff --git a/test/sendable/builtins/Array/prototype/slice/length-exceeding-integer-limit-proxied-array.js b/test/sendable/builtins/Array/prototype/slice/length-exceeding-integer-limit-proxied-array.js new file mode 100644 index 00000000000..1a370a78024 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/length-exceeding-integer-limit-proxied-array.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.slice +description: > + Length property is clamped to 2^53-1, test with indices near 2^53-1 and negative indices + and a proxy to an array. +info: | + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let relativeStart be ? ToInteger(start). + 4. If relativeStart < 0, let k be max((len + relativeStart), 0); + else let k be min(relativeStart, len). + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). + 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); + else let final be min(relativeEnd, len). +includes: [compareArray.js] +features: [exponentiation] +---*/ + +var array = []; +array["9007199254740988"] = "9007199254740988"; +array["9007199254740989"] = "9007199254740989"; +array["9007199254740990"] = "9007199254740990"; +array["9007199254740991"] = "9007199254740991"; +// Create a proxy to an array object, so IsArray returns true, but we can still +// return a length value exceeding the integer limit. +var proxy = new Proxy(array, { + get(t, pk, r) { + if (pk === "length") + return 2 ** 53 + 2; + return Reflect.get(t, pk, r); + } +}); +var result = SendableArray.prototype.slice.call(proxy, 9007199254740989); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + 'The value of result is expected to be ["9007199254740989", "9007199254740990"]'); +var result = SendableArray.prototype.slice.call(proxy, 9007199254740989, 9007199254740990); +assert.compareArray(result, ["9007199254740989"], + 'The value of result is expected to be ["9007199254740989"]'); +var result = SendableArray.prototype.slice.call(proxy, 9007199254740989, 9007199254740996); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + 'The value of result is expected to be ["9007199254740989", "9007199254740990"]'); +var result = SendableArray.prototype.slice.call(proxy, -2); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + 'The value of result is expected to be ["9007199254740989", "9007199254740990"]'); +var result = SendableArray.prototype.slice.call(proxy, -2, -1); +assert.compareArray(result, ["9007199254740989"], + 'The value of result is expected to be ["9007199254740989"]'); diff --git a/test/sendable/builtins/Array/prototype/slice/length-exceeding-integer-limit.js b/test/sendable/builtins/Array/prototype/slice/length-exceeding-integer-limit.js new file mode 100644 index 00000000000..a49fc971eb5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/length-exceeding-integer-limit.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + Length property is clamped to 2^53-1, test with indices near 2^53-1 and negative indices. +info: | + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let relativeStart be ? ToInteger(start). + 4. If relativeStart < 0, let k be max((len + relativeStart), 0); + else let k be min(relativeStart, len). + 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). + 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); + else let final be min(relativeEnd, len). +includes: [compareArray.js] +features: [exponentiation] +---*/ + +var arrayLike = { + "9007199254740988": "9007199254740988", + "9007199254740989": "9007199254740989", + "9007199254740990": "9007199254740990", + "9007199254740991": "9007199254740991", + length: 2 ** 53 + 2, +}; +var result = SendableArray.prototype.slice.call(arrayLike, 9007199254740989); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + 'The value of result is expected to be ["9007199254740989", "9007199254740990"]'); +var result = SendableArray.prototype.slice.call(arrayLike, 9007199254740989, 9007199254740990); +assert.compareArray(result, ["9007199254740989"], + 'The value of result is expected to be ["9007199254740989"]'); +var result = SendableArray.prototype.slice.call(arrayLike, 9007199254740989, 9007199254740996); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + 'The value of result is expected to be ["9007199254740989", "9007199254740990"]'); +var result = SendableArray.prototype.slice.call(arrayLike, -2); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + 'The value of result is expected to be ["9007199254740989", "9007199254740990"]'); +var result = SendableArray.prototype.slice.call(arrayLike, -2, -1); +assert.compareArray(result, ["9007199254740989"], + 'The value of result is expected to be ["9007199254740989"]'); diff --git a/test/sendable/builtins/Array/prototype/slice/length.js b/test/sendable/builtins/Array/prototype/slice/length.js new file mode 100644 index 00000000000..1abc72fc61b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/length.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + The "length" property of Array.prototype.slice +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.slice, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/slice/name.js b/test/sendable/builtins/Array/prototype/slice/name.js new file mode 100644 index 00000000000..35f233ce194 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + Array.prototype.slice.name is "slice". +info: | + Array.prototype.slice (start, end) + 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(SendableArray.prototype.slice, "name", { + value: "slice", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/slice/not-a-constructor.js b/test/sendable/builtins/Array/prototype/slice/not-a-constructor.js new file mode 100644 index 00000000000..13636497bfd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/not-a-constructor.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.slice 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(SendableArray.prototype.slice), + false, + 'isConstructor(SendableArray.prototype.slice) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.slice(); +}); + diff --git a/test/sendable/builtins/Array/prototype/slice/prop-desc.js b/test/sendable/builtins/Array/prototype/slice/prop-desc.js new file mode 100644 index 00000000000..137676a7e8b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + "slice" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.slice, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "slice", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/slice/resizable-buffer.js b/test/sendable/builtins/Array/prototype/slice/resizable-buffer.js new file mode 100644 index 00000000000..d96f5f57b97 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/resizable-buffer.js @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + Array.p.slice behaves correctly on TypedArrays backed by resizable buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, i); + } + const fixedLengthSlice = SendableArray.prototype.slice.call(fixedLength); + assert.compareArray(ToNumbers(fixedLengthSlice), [ + 0, + 1, + 2, + 3 + ]); + const fixedLengthWithOffsetSlice = SendableArray.prototype.slice.call(fixedLengthWithOffset); + assert.compareArray(ToNumbers(fixedLengthWithOffsetSlice), [ + 2, + 3 + ]); + const lengthTrackingSlice = SendableArray.prototype.slice.call(lengthTracking); + assert.compareArray(ToNumbers(lengthTrackingSlice), [ + 0, + 1, + 2, + 3 + ]); + const lengthTrackingWithOffsetSlice = SendableArray.prototype.slice.call(lengthTrackingWithOffset); + assert.compareArray(ToNumbers(lengthTrackingWithOffsetSlice), [ + 2, + 3 + ]); + + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(fixedLength)), []); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(fixedLengthWithOffset)), []); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTracking)), [ + 0, + 1, + 2 + ]); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTrackingWithOffset)), [2]); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(fixedLength)), []); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(fixedLengthWithOffset)), []); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTracking)), [0]); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTrackingWithOffset)), []); + // Shrink to zero. + rab.resize(0); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(fixedLength)), []); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(fixedLengthWithOffset)), []); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTracking)), []); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTrackingWithOffset)), []); + // Verify that the previously created slices aren't affected by the + // shrinking. + assert.compareArray(ToNumbers(fixedLengthSlice), [ + 0, + 1, + 2, + 3 + ]); + assert.compareArray(ToNumbers(fixedLengthWithOffsetSlice), [ + 2, + 3 + ]); + assert.compareArray(ToNumbers(lengthTrackingSlice), [ + 0, + 1, + 2, + 3 + ]); + assert.compareArray(ToNumbers(lengthTrackingWithOffsetSlice), [ + 2, + 3 + ]); + // Grow so that all TAs are back in-bounds. New memory is zeroed. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(fixedLength)), [ + 0, + 0, + 0, + 0 + ]); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(fixedLengthWithOffset)), [ + 0, + 0 + ]); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTracking)), [ + 0, + 0, + 0, + 0, + 0, + 0 + ]); + assert.compareArray(ToNumbers(SendableArray.prototype.slice.call(lengthTrackingWithOffset)), [ + 0, + 0, + 0, + 0 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/slice/target-array-non-extensible.js b/test/sendable/builtins/Array/prototype/slice/target-array-non-extensible.js new file mode 100644 index 00000000000..fb3fd737b55 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/target-array-non-extensible.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible) +features: [Symbol.species] +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.slice(0, 1); +}); diff --git a/test/sendable/builtins/Array/prototype/slice/target-array-with-non-configurable-property.js b/test/sendable/builtins/Array/prototype/slice/target-array-with-non-configurable-property.js new file mode 100644 index 00000000000..e02fb356c33 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/target-array-with-non-configurable-property.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable) +features: [Symbol.species] +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + set: function(_value) {}, + configurable: false, + }); +}; +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.slice(0, 1); +}); diff --git a/test/sendable/builtins/Array/prototype/slice/target-array-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/slice/target-array-with-non-writable-property.js new file mode 100644 index 00000000000..24416f3c0d4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/slice/target-array-with-non-writable-property.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.slice +description: > + Non-writable properties are overwritten by CreateDataPropertyOrThrow. +---*/ + +var a = [1]; +a.constructor = {}; +a.constructor[Symbol.species] = function(len) { + var q = new SendableArray(0); + Object.defineProperty(q, 0, { + value: 0, writable: false, configurable: true, enumerable: false, + }); + return q; +}; +var r = a.slice(0); +verifyProperty(r, 0, { + value: 1, writable: true, configurable: true, enumerable: true, +}); -- Gitee From 49663887ea00f45584e20c94a062ed3bf32ce8ea Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 3 Jan 2025 08:46:23 +0800 Subject: [PATCH 66/93] add array-some Signed-off-by: zhuzhihui7 --- .../Array/prototype/some/15.4.4.17-1-1.js | 22 +++++ .../Array/prototype/some/15.4.4.17-1-10.js | 25 +++++ .../Array/prototype/some/15.4.4.17-1-11.js | 27 ++++++ .../Array/prototype/some/15.4.4.17-1-12.js | 27 ++++++ .../Array/prototype/some/15.4.4.17-1-13.js | 25 +++++ .../Array/prototype/some/15.4.4.17-1-14.js | 26 +++++ .../Array/prototype/some/15.4.4.17-1-15.js | 26 +++++ .../Array/prototype/some/15.4.4.17-1-2.js | 22 +++++ .../Array/prototype/some/15.4.4.17-1-3.js | 25 +++++ .../Array/prototype/some/15.4.4.17-1-4.js | 27 ++++++ .../Array/prototype/some/15.4.4.17-1-5.js | 25 +++++ .../Array/prototype/some/15.4.4.17-1-6.js | 27 ++++++ .../Array/prototype/some/15.4.4.17-1-7.js | 23 +++++ .../Array/prototype/some/15.4.4.17-1-8.js | 24 +++++ .../Array/prototype/some/15.4.4.17-1-9.js | 28 ++++++ .../Array/prototype/some/15.4.4.17-2-1.js | 35 +++++++ .../Array/prototype/some/15.4.4.17-2-10.js | 42 ++++++++ .../Array/prototype/some/15.4.4.17-2-11.js | 36 +++++++ .../Array/prototype/some/15.4.4.17-2-12.js | 43 +++++++++ .../Array/prototype/some/15.4.4.17-2-13.js | 38 ++++++++ .../Array/prototype/some/15.4.4.17-2-14.js | 32 +++++++ .../Array/prototype/some/15.4.4.17-2-17.js | 33 +++++++ .../Array/prototype/some/15.4.4.17-2-18.js | 31 ++++++ .../Array/prototype/some/15.4.4.17-2-19.js | 35 +++++++ .../Array/prototype/some/15.4.4.17-2-2.js | 28 ++++++ .../Array/prototype/some/15.4.4.17-2-3.js | 39 ++++++++ .../Array/prototype/some/15.4.4.17-2-4.js | 33 +++++++ .../Array/prototype/some/15.4.4.17-2-5.js | 46 +++++++++ .../Array/prototype/some/15.4.4.17-2-6.js | 38 ++++++++ .../Array/prototype/some/15.4.4.17-2-7.js | 39 ++++++++ .../Array/prototype/some/15.4.4.17-2-8.js | 44 +++++++++ .../Array/prototype/some/15.4.4.17-2-9.js | 48 ++++++++++ .../Array/prototype/some/15.4.4.17-3-1.js | 30 ++++++ .../Array/prototype/some/15.4.4.17-3-10.js | 30 ++++++ .../Array/prototype/some/15.4.4.17-3-11.js | 35 +++++++ .../Array/prototype/some/15.4.4.17-3-12.js | 35 +++++++ .../Array/prototype/some/15.4.4.17-3-13.js | 35 +++++++ .../Array/prototype/some/15.4.4.17-3-14.js | 40 ++++++++ .../Array/prototype/some/15.4.4.17-3-15.js | 35 +++++++ .../Array/prototype/some/15.4.4.17-3-16.js | 33 +++++++ .../Array/prototype/some/15.4.4.17-3-17.js | 35 +++++++ .../Array/prototype/some/15.4.4.17-3-18.js | 33 +++++++ .../Array/prototype/some/15.4.4.17-3-19.js | 42 ++++++++ .../Array/prototype/some/15.4.4.17-3-2.js | 34 +++++++ .../Array/prototype/some/15.4.4.17-3-20.js | 42 ++++++++ .../Array/prototype/some/15.4.4.17-3-21.js | 49 ++++++++++ .../Array/prototype/some/15.4.4.17-3-22.js | 49 ++++++++++ .../Array/prototype/some/15.4.4.17-3-23.js | 52 ++++++++++ .../Array/prototype/some/15.4.4.17-3-24.js | 35 +++++++ .../Array/prototype/some/15.4.4.17-3-25.js | 33 +++++++ .../Array/prototype/some/15.4.4.17-3-28.js | 30 ++++++ .../Array/prototype/some/15.4.4.17-3-29.js | 34 +++++++ .../Array/prototype/some/15.4.4.17-3-3.js | 30 ++++++ .../Array/prototype/some/15.4.4.17-3-4.js | 30 ++++++ .../Array/prototype/some/15.4.4.17-3-5.js | 30 ++++++ .../Array/prototype/some/15.4.4.17-3-6.js | 35 +++++++ .../Array/prototype/some/15.4.4.17-3-7.js | 35 +++++++ .../Array/prototype/some/15.4.4.17-3-8.js | 32 +++++++ .../Array/prototype/some/15.4.4.17-3-9.js | 32 +++++++ .../Array/prototype/some/15.4.4.17-4-1.js | 23 +++++ .../Array/prototype/some/15.4.4.17-4-10.js | 34 +++++++ .../Array/prototype/some/15.4.4.17-4-11.js | 38 ++++++++ .../Array/prototype/some/15.4.4.17-4-12.js | 23 +++++ .../Array/prototype/some/15.4.4.17-4-15.js | 43 +++++++++ .../Array/prototype/some/15.4.4.17-4-2.js | 25 +++++ .../Array/prototype/some/15.4.4.17-4-3.js | 23 +++++ .../Array/prototype/some/15.4.4.17-4-4.js | 23 +++++ .../Array/prototype/some/15.4.4.17-4-5.js | 23 +++++ .../Array/prototype/some/15.4.4.17-4-6.js | 23 +++++ .../Array/prototype/some/15.4.4.17-4-7.js | 25 +++++ .../Array/prototype/some/15.4.4.17-4-8.js | 37 +++++++ .../Array/prototype/some/15.4.4.17-4-9.js | 41 ++++++++ .../Array/prototype/some/15.4.4.17-5-1.js | 29 ++++++ .../Array/prototype/some/15.4.4.17-5-10.js | 24 +++++ .../Array/prototype/some/15.4.4.17-5-11.js | 24 +++++ .../Array/prototype/some/15.4.4.17-5-12.js | 24 +++++ .../Array/prototype/some/15.4.4.17-5-13.js | 24 +++++ .../Array/prototype/some/15.4.4.17-5-14.js | 23 +++++ .../Array/prototype/some/15.4.4.17-5-15.js | 24 +++++ .../Array/prototype/some/15.4.4.17-5-16.js | 24 +++++ .../Array/prototype/some/15.4.4.17-5-17.js | 23 +++++ .../Array/prototype/some/15.4.4.17-5-18.js | 24 +++++ .../Array/prototype/some/15.4.4.17-5-19.js | 27 ++++++ .../Array/prototype/some/15.4.4.17-5-2.js | 28 ++++++ .../Array/prototype/some/15.4.4.17-5-21.js | 24 +++++ .../Array/prototype/some/15.4.4.17-5-22.js | 23 +++++ .../Array/prototype/some/15.4.4.17-5-23.js | 23 +++++ .../Array/prototype/some/15.4.4.17-5-24.js | 23 +++++ .../Array/prototype/some/15.4.4.17-5-25.js | 30 ++++++ .../Array/prototype/some/15.4.4.17-5-3.js | 28 ++++++ .../Array/prototype/some/15.4.4.17-5-4.js | 31 ++++++ .../Array/prototype/some/15.4.4.17-5-5.js | 29 ++++++ .../Array/prototype/some/15.4.4.17-5-6.js | 28 ++++++ .../Array/prototype/some/15.4.4.17-5-7.js | 23 +++++ .../Array/prototype/some/15.4.4.17-5-8.js | 28 ++++++ .../Array/prototype/some/15.4.4.17-5-9.js | 24 +++++ .../Array/prototype/some/15.4.4.17-7-1.js | 33 +++++++ .../Array/prototype/some/15.4.4.17-7-2.js | 31 ++++++ .../Array/prototype/some/15.4.4.17-7-3.js | 31 ++++++ .../Array/prototype/some/15.4.4.17-7-4.js | 31 ++++++ .../Array/prototype/some/15.4.4.17-7-5.js | 33 +++++++ .../Array/prototype/some/15.4.4.17-7-6.js | 34 +++++++ .../Array/prototype/some/15.4.4.17-7-8.js | 31 ++++++ .../Array/prototype/some/15.4.4.17-7-9.js | 40 ++++++++ .../Array/prototype/some/15.4.4.17-7-b-1.js | 31 ++++++ .../Array/prototype/some/15.4.4.17-7-b-10.js | 40 ++++++++ .../Array/prototype/some/15.4.4.17-7-b-11.js | 37 +++++++ .../Array/prototype/some/15.4.4.17-7-b-12.js | 44 +++++++++ .../Array/prototype/some/15.4.4.17-7-b-13.js | 38 ++++++++ .../Array/prototype/some/15.4.4.17-7-b-14.js | 36 +++++++ .../Array/prototype/some/15.4.4.17-7-b-15.js | 43 +++++++++ .../Array/prototype/some/15.4.4.17-7-b-16.js | 44 +++++++++ .../Array/prototype/some/15.4.4.17-7-b-2.js | 35 +++++++ .../Array/prototype/some/15.4.4.17-7-b-3.js | 39 ++++++++ .../Array/prototype/some/15.4.4.17-7-b-4.js | 44 +++++++++ .../Array/prototype/some/15.4.4.17-7-b-5.js | 42 ++++++++ .../Array/prototype/some/15.4.4.17-7-b-6.js | 44 +++++++++ .../Array/prototype/some/15.4.4.17-7-b-7.js | 42 ++++++++ .../Array/prototype/some/15.4.4.17-7-b-8.js | 44 +++++++++ .../Array/prototype/some/15.4.4.17-7-b-9.js | 42 ++++++++ .../Array/prototype/some/15.4.4.17-7-c-i-1.js | 33 +++++++ .../prototype/some/15.4.4.17-7-c-i-10.js | 36 +++++++ .../prototype/some/15.4.4.17-7-c-i-11.js | 43 +++++++++ .../prototype/some/15.4.4.17-7-c-i-12.js | 37 +++++++ .../prototype/some/15.4.4.17-7-c-i-13.js | 47 +++++++++ .../prototype/some/15.4.4.17-7-c-i-14.js | 42 ++++++++ .../prototype/some/15.4.4.17-7-c-i-15.js | 40 ++++++++ .../prototype/some/15.4.4.17-7-c-i-16.js | 35 +++++++ .../prototype/some/15.4.4.17-7-c-i-17.js | 35 +++++++ .../prototype/some/15.4.4.17-7-c-i-18.js | 33 +++++++ .../prototype/some/15.4.4.17-7-c-i-19.js | 37 +++++++ .../Array/prototype/some/15.4.4.17-7-c-i-2.js | 29 ++++++ .../prototype/some/15.4.4.17-7-c-i-20.js | 35 +++++++ .../prototype/some/15.4.4.17-7-c-i-21.js | 37 +++++++ .../prototype/some/15.4.4.17-7-c-i-22.js | 32 +++++++ .../prototype/some/15.4.4.17-7-c-i-25.js | 32 +++++++ .../prototype/some/15.4.4.17-7-c-i-26.js | 41 ++++++++ .../prototype/some/15.4.4.17-7-c-i-27.js | 46 +++++++++ .../prototype/some/15.4.4.17-7-c-i-28.js | 46 +++++++++ .../prototype/some/15.4.4.17-7-c-i-29.js | 48 ++++++++++ .../Array/prototype/some/15.4.4.17-7-c-i-3.js | 38 ++++++++ .../prototype/some/15.4.4.17-7-c-i-30.js | 41 ++++++++ .../prototype/some/15.4.4.17-7-c-i-31.js | 40 ++++++++ .../Array/prototype/some/15.4.4.17-7-c-i-4.js | 30 ++++++ .../Array/prototype/some/15.4.4.17-7-c-i-5.js | 45 +++++++++ .../Array/prototype/some/15.4.4.17-7-c-i-6.js | 35 +++++++ .../Array/prototype/some/15.4.4.17-7-c-i-7.js | 36 +++++++ .../Array/prototype/some/15.4.4.17-7-c-i-8.js | 30 ++++++ .../Array/prototype/some/15.4.4.17-7-c-i-9.js | 38 ++++++++ .../prototype/some/15.4.4.17-7-c-ii-1.js | 28 ++++++ .../prototype/some/15.4.4.17-7-c-ii-10.js | 23 +++++ .../prototype/some/15.4.4.17-7-c-ii-11.js | 23 +++++ .../prototype/some/15.4.4.17-7-c-ii-12.js | 23 +++++ .../prototype/some/15.4.4.17-7-c-ii-13.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-ii-16.js | 29 ++++++ .../prototype/some/15.4.4.17-7-c-ii-17.js | 29 ++++++ .../prototype/some/15.4.4.17-7-c-ii-18.js | 30 ++++++ .../prototype/some/15.4.4.17-7-c-ii-19.js | 32 +++++++ .../prototype/some/15.4.4.17-7-c-ii-2.js | 29 ++++++ .../prototype/some/15.4.4.17-7-c-ii-20.js | 32 +++++++ .../prototype/some/15.4.4.17-7-c-ii-21.js | 41 ++++++++ .../prototype/some/15.4.4.17-7-c-ii-22.js | 41 ++++++++ .../prototype/some/15.4.4.17-7-c-ii-23.js | 30 ++++++ .../prototype/some/15.4.4.17-7-c-ii-3.js | 33 +++++++ .../prototype/some/15.4.4.17-7-c-ii-4.js | 35 +++++++ .../prototype/some/15.4.4.17-7-c-ii-5.js | 37 +++++++ .../prototype/some/15.4.4.17-7-c-ii-6.js | 28 ++++++ .../prototype/some/15.4.4.17-7-c-ii-7.js | 41 ++++++++ .../prototype/some/15.4.4.17-7-c-ii-8.js | 33 +++++++ .../prototype/some/15.4.4.17-7-c-ii-9.js | 23 +++++ .../prototype/some/15.4.4.17-7-c-iii-1.js | 30 ++++++ .../prototype/some/15.4.4.17-7-c-iii-10.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-11.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-12.js | 27 ++++++ .../prototype/some/15.4.4.17-7-c-iii-13.js | 28 ++++++ .../prototype/some/15.4.4.17-7-c-iii-14.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-15.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-16.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-17.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-18.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-19.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-2.js | 30 ++++++ .../prototype/some/15.4.4.17-7-c-iii-20.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-21.js | 23 +++++ .../prototype/some/15.4.4.17-7-c-iii-22.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-23.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-24.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-25.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-26.js | 26 +++++ .../prototype/some/15.4.4.17-7-c-iii-28.js | 50 ++++++++++ .../prototype/some/15.4.4.17-7-c-iii-29.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-3.js | 32 +++++++ .../prototype/some/15.4.4.17-7-c-iii-4.js | 29 ++++++ .../prototype/some/15.4.4.17-7-c-iii-5.js | 28 ++++++ .../prototype/some/15.4.4.17-7-c-iii-6.js | 28 ++++++ .../prototype/some/15.4.4.17-7-c-iii-7.js | 28 ++++++ .../prototype/some/15.4.4.17-7-c-iii-8.js | 25 +++++ .../prototype/some/15.4.4.17-7-c-iii-9.js | 25 +++++ .../Array/prototype/some/15.4.4.17-8-1.js | 22 +++++ .../Array/prototype/some/15.4.4.17-8-10.js | 32 +++++++ .../Array/prototype/some/15.4.4.17-8-11.js | 30 ++++++ .../Array/prototype/some/15.4.4.17-8-12.js | 32 +++++++ .../Array/prototype/some/15.4.4.17-8-13.js | 30 ++++++ .../Array/prototype/some/15.4.4.17-8-2.js | 28 ++++++ .../Array/prototype/some/15.4.4.17-8-3.js | 28 ++++++ .../Array/prototype/some/15.4.4.17-8-4.js | 28 ++++++ .../Array/prototype/some/15.4.4.17-8-5.js | 28 ++++++ .../Array/prototype/some/15.4.4.17-8-6.js | 33 +++++++ .../Array/prototype/some/15.4.4.17-8-7.js | 38 ++++++++ .../Array/prototype/some/15.4.4.17-8-8.js | 41 ++++++++ .../Array/prototype/some/call-with-boolean.js | 29 ++++++ .../some/callbackfn-resize-arraybuffer.js | 76 +++++++++++++++ .../builtins/Array/prototype/some/length.js | 38 ++++++++ .../builtins/Array/prototype/some/name.js | 36 +++++++ .../Array/prototype/some/not-a-constructor.js | 34 +++++++ .../Array/prototype/some/prop-desc.js | 32 +++++++ .../resizable-buffer-grow-mid-iteration.js | 94 ++++++++++++++++++ .../resizable-buffer-shrink-mid-iteration.js | 84 ++++++++++++++++ .../Array/prototype/some/resizable-buffer.js | 96 +++++++++++++++++++ 219 files changed, 7276 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-1.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-10.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-11.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-12.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-13.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-14.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-15.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-2.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-3.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-4.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-5.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-6.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-7.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-8.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-1-9.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-1.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-10.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-11.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-12.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-13.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-14.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-17.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-18.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-19.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-2.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-3.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-4.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-5.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-6.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-7.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-8.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-2-9.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-1.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-10.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-11.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-12.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-13.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-14.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-15.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-16.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-17.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-18.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-19.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-2.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-20.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-21.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-22.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-23.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-24.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-25.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-28.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-29.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-3.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-4.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-5.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-6.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-7.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-8.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-3-9.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-4-1.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-4-10.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-4-11.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-4-12.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-4-15.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-4-2.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-4-3.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-4-4.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-4-5.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-4-6.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-4-7.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-4-8.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-4-9.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-1.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-10.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-11.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-12.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-13.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-14.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-15.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-16.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-17.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-18.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-19.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-2.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-21.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-22.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-23.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-24.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-25.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-3.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-4.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-5.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-6.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-7.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-8.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-5-9.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-1.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-2.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-3.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-4.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-5.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-6.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-8.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-9.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-1.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-10.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-11.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-12.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-13.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-14.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-15.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-16.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-2.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-3.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-4.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-5.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-6.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-7.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-8.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-9.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-1.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-10.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-11.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-12.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-13.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-14.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-15.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-16.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-17.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-18.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-19.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-2.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-20.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-21.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-22.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-25.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-26.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-27.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-28.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-29.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-3.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-30.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-31.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-4.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-5.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-6.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-7.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-8.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-9.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-1.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-10.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-11.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-12.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-13.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-16.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-17.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-18.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-19.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-2.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-20.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-21.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-22.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-23.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-3.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-4.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-5.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-6.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-7.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-8.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-9.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-1.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-10.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-11.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-12.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-13.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-14.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-15.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-16.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-17.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-18.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-19.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-2.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-20.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-21.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-22.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-23.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-24.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-25.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-26.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-28.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-29.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-3.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-4.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-5.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-6.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-7.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-8.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-9.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-8-1.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-8-10.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-8-11.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-8-12.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-8-13.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-8-2.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-8-3.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-8-4.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-8-5.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-8-6.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-8-7.js create mode 100644 test/sendable/builtins/Array/prototype/some/15.4.4.17-8-8.js create mode 100644 test/sendable/builtins/Array/prototype/some/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/some/callbackfn-resize-arraybuffer.js create mode 100644 test/sendable/builtins/Array/prototype/some/length.js create mode 100644 test/sendable/builtins/Array/prototype/some/name.js create mode 100644 test/sendable/builtins/Array/prototype/some/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/some/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/some/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/some/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/some/resizable-buffer.js diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-1.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-1.js new file mode 100644 index 00000000000..1a3946bf5e2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to undefined throws a TypeError +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.some.call(undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-10.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-10.js new file mode 100644 index 00000000000..e4d287e5be3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-10.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to the Math object +---*/ + +function callbackfn(val, idx, obj) { + return '[object Math]' === Object.prototype.toString.call(obj); +} +Math.length = 1; +Math[0] = 1; +assert(SendableArray.prototype.some.call(Math, callbackfn), 'SendableArray.prototype.some.call(Math, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-11.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-11.js new file mode 100644 index 00000000000..3e32aee7371 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-11.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to Date object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Date; +} +var obj = new Date(0); +obj.length = 2; +obj[0] = 11; +obj[1] = 9; +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-12.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-12.js new file mode 100644 index 00000000000..d05926ebc4a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-12.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to RegExp object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof RegExp; +} +var obj = new RegExp(); +obj.length = 2; +obj[0] = 11; +obj[1] = 9; +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-13.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-13.js new file mode 100644 index 00000000000..da560b1ea12 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-13.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to the JSON object +---*/ + +function callbackfn(val, idx, obj) { + return '[object JSON]' === Object.prototype.toString.call(obj); +} +JSON.length = 1; +JSON[0] = 1; +assert(SendableArray.prototype.some.call(JSON, callbackfn), 'SendableArray.prototype.some.call(JSON, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-14.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-14.js new file mode 100644 index 00000000000..1f723ab798c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-14.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to Error object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Error; +} +var obj = new Error(); +obj.length = 1; +obj[0] = 1; +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-15.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-15.js new file mode 100644 index 00000000000..72a21318f09 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-15.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to the Arguments object +---*/ + +function callbackfn(val, idx, obj) { + return '[object Arguments]' === Object.prototype.toString.call(obj); +} +var obj = (function() { + return arguments; +}("a", "b")); +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-2.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-2.js new file mode 100644 index 00000000000..9676e1599e3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-2.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to null throws a TypeError +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.some.call(null); +}); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-3.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-3.js new file mode 100644 index 00000000000..7b290d78bbb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-3.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to boolean primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Boolean; +} +Boolean.prototype[0] = 1; +Boolean.prototype.length = 1; +assert(SendableArray.prototype.some.call(false, callbackfn), 'SendableArray.prototype.some.call(false, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-4.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-4.js new file mode 100644 index 00000000000..f658e4383e6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-4.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to Boolean object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Boolean; +} +var obj = new Boolean(true); +obj.length = 2; +obj[0] = 11; +obj[1] = 9; +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-5.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-5.js new file mode 100644 index 00000000000..b3b372a0568 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-5.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to number primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Number; +} +Number.prototype[1] = true; +Number.prototype.length = 2; +assert(SendableArray.prototype.some.call(5, callbackfn), 'SendableArray.prototype.some.call(5, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-6.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-6.js new file mode 100644 index 00000000000..bc371d39723 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-6.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to Number object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Number; +} +var obj = new Number(-128); +obj.length = 2; +obj[0] = 11; +obj[1] = 9; +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-7.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-7.js new file mode 100644 index 00000000000..583d2d89afe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-7.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to applied to string primitive +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof String; +} +assert(SendableArray.prototype.some.call("hello\nw_orld\\!", callbackfn), 'SendableArray.prototype.some.call("hello\nw_orld\\!", callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-8.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-8.js new file mode 100644 index 00000000000..97e3f47ac92 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-8.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to String object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof String; +} +var obj = new String("hello\nw_orld\\!"); +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-9.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-9.js new file mode 100644 index 00000000000..6103fdf1b21 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-1-9.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to Function object +---*/ + +function callbackfn(val, idx, obj) { + return obj instanceof Function; +} +var obj = function(a, b) { + return a + b; +}; +obj[0] = 11; +obj[1] = 9; +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-1.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-1.js new file mode 100644 index 00000000000..1eb5376a45d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-1.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is own data property on an + Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: 2 +}; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-10.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-10.js new file mode 100644 index 00000000000..d2136402c00 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-10.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an inherited accessor property + on an Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 9; +child[1] = 11; +child[2] = 12; +assert(SendableArray.prototype.some.call(child, callbackfn1), 'SendableArray.prototype.some.call(child, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(child, callbackfn2), false, 'SendableArray.prototype.some.call(child, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-11.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-11.js new file mode 100644 index 00000000000..c5d0c913bfa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-11.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an own accessor property + without a get function on an Array-like object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-12.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-12.js new file mode 100644 index 00000000000..3cb6c3792a9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-12.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is own accessor property without a + get function that overrides an inherited accessor property on an + Array-like object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +Object.defineProperty(Object.prototype, "length", { + get: function() { + return 2; + }, + configurable: true +}); +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + set: function() {}, + configurable: true +}); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-13.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-13.js new file mode 100644 index 00000000000..90340b20640 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-13.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is inherited accessor property + without a get function on an Array-like object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var proto = {}; +Object.defineProperty(proto, "length", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 11; +child[1] = 12; +assert.sameValue(SendableArray.prototype.some.call(child, callbackfn), false, 'SendableArray.prototype.some.call(child, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-14.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-14.js new file mode 100644 index 00000000000..e5dfa3266c7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-14.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' property doesn't exist on an + Array-like object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + 1: 12 +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-17.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-17.js new file mode 100644 index 00000000000..bc760fa7796 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-17.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some applied to the Arguments object which + implements its own property get method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var func = function(a, b) { + arguments[2] = 12; + return SendableArray.prototype.some.call(arguments, callbackfn1) && + !SendableArray.prototype.some.call(arguments, callbackfn2); +}; +assert(func(9, 11), 'func(9, 11) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-18.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-18.js new file mode 100644 index 00000000000..01bc8979615 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-18.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some applied to String object which implements its + own property get method +---*/ + +function callbackfn1(val, idx, obj) { + return parseInt(val, 10) > 1; +} +function callbackfn2(val, idx, obj) { + return parseInt(val, 10) > 2; +} +var str = new String("12"); +String.prototype[2] = "3"; +assert(SendableArray.prototype.some.call(str, callbackfn1), 'SendableArray.prototype.some.call(str, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(str, callbackfn2), false, 'SendableArray.prototype.some.call(str, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-19.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-19.js new file mode 100644 index 00000000000..e6239947df4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-19.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some applied to Function object which implements + its own property get method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var fun = function(a, b) { + return a + b; +}; +fun[0] = 9; +fun[1] = 11; +fun[2] = 12; +assert(SendableArray.prototype.some.call(fun, callbackfn1), 'SendableArray.prototype.some.call(fun, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(fun, callbackfn2), false, 'SendableArray.prototype.some.call(fun, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-2.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-2.js new file mode 100644 index 00000000000..09705d53bb7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - 'length' is own data property on an Array +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +SendableArray.prototype[2] = 12; +assert([9, 11].some(callbackfn1), '[9, 11].some(callbackfn1) !== true'); +assert.sameValue([9, 11].some(callbackfn2), false, '[9, 11].some(callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-3.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-3.js new file mode 100644 index 00000000000..fe603934f3e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-3.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an own data property that + overrides an inherited data property on an Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var proto = { + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +child[0] = 9; +child[1] = 11; +child[2] = 12; +assert(SendableArray.prototype.some.call(child, callbackfn1), 'SendableArray.prototype.some.call(child, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(child, callbackfn2), false, 'SendableArray.prototype.some.call(child, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-4.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-4.js new file mode 100644 index 00000000000..ba1fa23d3e1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-4.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an own data property that + overrides an inherited data property on an array +---*/ + +var arrProtoLen = 0; +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +arrProtoLen = SendableArray.prototype.length; +SendableArray.prototype.length = 0; +SendableArray.prototype[2] = 12; +assert([9, 11].some(callbackfn1), '[9, 11].some(callbackfn1) !== true'); +assert.sameValue([9, 11].some(callbackfn2), false, '[9, 11].some(callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-5.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-5.js new file mode 100644 index 00000000000..fb7c1c00308 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-5.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an own data property that + overrides an inherited accessor property on an Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + value: 2, + configurable: true +}); +child[0] = 9; +child[1] = 11; +child[2] = 12; +assert(SendableArray.prototype.some.call(child, callbackfn1), 'SendableArray.prototype.some.call(child, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(child, callbackfn2), false, 'SendableArray.prototype.some.call(child, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-6.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-6.js new file mode 100644 index 00000000000..c3243d1245d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-6.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an inherited data property on + an Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var proto = { + length: 2 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[0] = 9; +child[1] = 11; +child[2] = 12; +assert(SendableArray.prototype.some.call(child, callbackfn1), 'SendableArray.prototype.some.call(child, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(child, callbackfn2), false, 'SendableArray.prototype.some.call(child, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-7.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-7.js new file mode 100644 index 00000000000..1e92791bfd9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-7.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an own accessor property on an + Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = {}; +Object.defineProperty(obj, "length", { + get: function() { + return 2; + }, + configurable: true +}); +obj[0] = 9; +obj[1] = 11; +obj[2] = 12; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-8.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-8.js new file mode 100644 index 00000000000..966b88dcf8c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-8.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an own accessor property that + overrides an inherited data property on an Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var proto = { + length: 3 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 9; +child[1] = 11; +child[2] = 12; +assert(SendableArray.prototype.some.call(child, callbackfn1), 'SendableArray.prototype.some.call(child, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(child, callbackfn2), false, 'SendableArray.prototype.some.call(child, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-9.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-9.js new file mode 100644 index 00000000000..22580c5b57d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-2-9.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an own accessor property that + overrides an inherited accessor property on an Array-like object +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var proto = {}; +Object.defineProperty(proto, "length", { + get: function() { + return 3; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +Object.defineProperty(child, "length", { + get: function() { + return 2; + }, + configurable: true +}); +child[0] = 9; +child[1] = 11; +child[2] = 12; +assert(SendableArray.prototype.some.call(child, callbackfn1), 'SendableArray.prototype.some.call(child, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(child, callbackfn2), false, 'SendableArray.prototype.some.call(child, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-1.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-1.js new file mode 100644 index 00000000000..24223f2fcfc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - value of 'length' is undefined +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + length: undefined +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-10.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-10.js new file mode 100644 index 00000000000..8b32fadb6be --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-10.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - value of 'length' is a number (value is NaN) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + length: NaN +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-11.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-11.js new file mode 100644 index 00000000000..5e75e9bdf3a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-11.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is a string containing a positive + number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: "2" +}; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-12.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-12.js new file mode 100644 index 00000000000..abbede395df --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-12.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is a string containing a negative + number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: "-4294967294" +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn1), false, 'SendableArray.prototype.some.call(obj, callbackfn1)'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-13.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-13.js new file mode 100644 index 00000000000..21b318649c6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-13.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is a string containing a decimal + number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: "2.5" +}; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-14.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-14.js new file mode 100644 index 00000000000..868901b3034 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-14.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - 'length' is a string containing +/-Infinity +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var objOne = { + 0: 11, + length: "Infinity" +}; +var objTwo = { + 0: 11, + length: "+Infinity" +}; +var objThree = { + 0: 11, + length: "-Infinity" +}; +assert(SendableArray.prototype.some.call(objOne, callbackfn), 'SendableArray.prototype.some.call(objOne, callbackfn) !== true'); +assert(SendableArray.prototype.some.call(objTwo, callbackfn), 'SendableArray.prototype.some.call(objTwo, callbackfn) !== true'); +assert.sameValue(SendableArray.prototype.some.call(objThree, callbackfn), false, 'SendableArray.prototype.some.call(objThree, callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-15.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-15.js new file mode 100644 index 00000000000..09b014d6ccb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-15.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is a string containing an + exponential number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: "2E0" +}; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-16.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-16.js new file mode 100644 index 00000000000..ad6089fb0ed --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-16.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - 'length' is a string containing a hex number +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: "0x0002" +}; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-17.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-17.js new file mode 100644 index 00000000000..29193721442 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-17.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is a string containing a number + with leading zeros +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: "0002.00" +}; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-18.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-18.js new file mode 100644 index 00000000000..49afa0dec7c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-18.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is a string that can't + convert to a number +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + 1: 21, + length: "two" +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-19.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-19.js new file mode 100644 index 00000000000..9c17fc9d972 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-19.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is an Object which has an + own toString method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var toStringAccessed = false; +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: { + toString: function() { + toStringAccessed = true; + return '2'; + } + } +}; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); +assert(toStringAccessed, 'toStringAccessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-2.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-2.js new file mode 100644 index 00000000000..b2c65704ac9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-2.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some on an Array-like object if 'length' is 1 + (length overridden to true(type conversion)) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 11, + 1: 12, + length: true +}; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-20.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-20.js new file mode 100644 index 00000000000..5e85fdc32a2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-20.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is an Object which has an + own valueOf method +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var valueOfAccessed = false; +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: { + valueOf: function() { + valueOfAccessed = true; + return 2; + } + } +}; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-21.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-21.js new file mode 100644 index 00000000000..26aaabc901c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-21.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'length' is an object that has an own + valueOf method that returns an object and toString method that + returns a string +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var toStringAccessed = false; +var valueOfAccessed = false; +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: { + valueOf: function() { + valueOfAccessed = true; + return {}; + }, + toString: function() { + toStringAccessed = true; + return '2'; + } + } +}; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert(toStringAccessed, 'toStringAccessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-22.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-22.js new file mode 100644 index 00000000000..b92ed8587ba --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-22.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some throws TypeError exception when 'length' is + an object with toString and valueOf methods that don�t return + primitive values +---*/ + +var callbackfnAccessed = false; +var toStringAccessed = false; +var valueOfAccessed = false; +function callbackfn(val, idx, obj) { + callbackfnAccessed = true; + return val > 10; +} +var obj = { + 0: 11, + 1: 12, + length: { + valueOf: function() { + valueOfAccessed = true; + return {}; + }, + toString: function() { + toStringAccessed = true; + return {}; + } + } +}; +assert.throws(TypeError, function() { + SendableArray.prototype.some.call(obj, callbackfn); +}); +assert(toStringAccessed, 'toStringAccessed !== true'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(callbackfnAccessed, false, 'callbackfnAccessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-23.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-23.js new file mode 100644 index 00000000000..6378a04c446 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-23.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some uses inherited valueOf method when 'length' + is an object with an own toString and inherited valueOf methods +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var valueOfAccessed = false; +var toStringAccessed = false; +var proto = { + valueOf: function() { + valueOfAccessed = true; + return 2; + } +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.toString = function() { + toStringAccessed = true; + return '1'; +}; +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: child +}; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); +assert(valueOfAccessed, 'valueOfAccessed !== true'); +assert.sameValue(toStringAccessed, false, 'toStringAccessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-24.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-24.js new file mode 100644 index 00000000000..fe62a6328f0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-24.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is a positive + non-integer, ensure truncation occurs in the proper direction +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 9, + 10: 11, + 11: 12, + length: 11.5 +}; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-25.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-25.js new file mode 100644 index 00000000000..623dcb4c88c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-25.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - value of 'length' is a negative non-integer +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: -4294967294.5 +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn1), false, 'SendableArray.prototype.some.call(obj, callbackfn1)'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-28.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-28.js new file mode 100644 index 00000000000..d4f3df6af27 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-28.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - value of 'length' is boundary value (2^32) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 12, + length: 4294967296 +}; +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-29.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-29.js new file mode 100644 index 00000000000..51eae07f240 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-29.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is boundary value (2^32 + + 1) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 11, + 1: 12, + length: 4294967297 +}; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert(SendableArray.prototype.some.call(obj, callbackfn2), 'SendableArray.prototype.some.call(obj, callbackfn2) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-3.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-3.js new file mode 100644 index 00000000000..15b236024c6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-3.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - value of 'length' is a number (value is 0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + length: 0 +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-4.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-4.js new file mode 100644 index 00000000000..8e6e3946b9a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - value of 'length' is a number (value is +0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + length: +0 +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-5.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-5.js new file mode 100644 index 00000000000..c7913be053d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-5.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - value of 'length' is a number (value is -0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + length: -0 +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-6.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-6.js new file mode 100644 index 00000000000..41d848b450d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is a number (value is + positive) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: 2 +}; +assert(SendableArray.prototype.some.call(obj, callbackfn1), 'SendableArray.prototype.some.call(obj, callbackfn1) !== true'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-7.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-7.js new file mode 100644 index 00000000000..9a585d1d76e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-7.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is a number (value is + negative) +---*/ + +function callbackfn1(val, idx, obj) { + return val > 10; +} +function callbackfn2(val, idx, obj) { + return val > 11; +} +var obj = { + 0: 9, + 1: 11, + 2: 12, + length: -4294967294 +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn1), false, 'SendableArray.prototype.some.call(obj, callbackfn1)'); +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn2), false, 'SendableArray.prototype.some.call(obj, callbackfn2)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-8.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-8.js new file mode 100644 index 00000000000..0ebe4c5883d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-8.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is a number (value is + Infinity) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + length: Infinity +}; +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-9.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-9.js new file mode 100644 index 00000000000..0f4dec26a6d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-3-9.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - value of 'length' is a number (value is + -Infinity) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + length: -Infinity +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-1.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-1.js new file mode 100644 index 00000000000..b7130ec1ea4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-1.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some throws TypeError if callbackfn is undefined +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.some(); +}); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-10.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-10.js new file mode 100644 index 00000000000..cccbd1a8ea3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-10.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - the exception is not thrown if exception + was thrown by step 2 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + throw new Test262Error(); + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.some.call(obj, undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-11.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-11.js new file mode 100644 index 00000000000..e8b936295b4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-11.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - the exception is not thrown if exception + was thrown by step 3 +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + throw new Test262Error(); + } + }; + }, + configurable: true +}); +assert.throws(Test262Error, function() { + SendableArray.prototype.some.call(obj, undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-12.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-12.js new file mode 100644 index 00000000000..85aa538e53d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-12.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - 'callbackfn' is a function +---*/ + +function callbackfn(val, idx, obj) { + return val > 10; +} +assert([9, 11].some(callbackfn), '[9, 11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-15.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-15.js new file mode 100644 index 00000000000..6eaff9c0cd8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-15.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - calling with no callbackfn is the same as + passing undefined for callbackfn +---*/ + +var obj = {}; +var lengthAccessed = false; +var loopAccessed = false; +Object.defineProperty(obj, "length", { + get: function() { + lengthAccessed = true; + return 20; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + loopAccessed = true; + return 10; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.some.call(obj); +}); +assert(lengthAccessed, 'lengthAccessed !== true'); +assert.sameValue(loopAccessed, false, 'loopAccessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-2.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-2.js new file mode 100644 index 00000000000..3f2193f567a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-2.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some throws ReferenceError if callbackfn is + unreferenced +---*/ + +var arr = new SendableArray(10); +assert.throws(ReferenceError, function() { + arr.some(foo); +}); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-3.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-3.js new file mode 100644 index 00000000000..d22b64e4175 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-3.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some throws TypeError if callbackfn is null +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.some(null); +}); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-4.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-4.js new file mode 100644 index 00000000000..637afe49e79 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-4.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some throws TypeError if callbackfn is boolean +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.some(true); +}); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-5.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-5.js new file mode 100644 index 00000000000..7458782c8c4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-5.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some throws TypeError if callbackfn is number +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.some(5); +}); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-6.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-6.js new file mode 100644 index 00000000000..057e9e4404a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-6.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some throws TypeError if callbackfn is string +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.some("abc"); +}); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-7.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-7.js new file mode 100644 index 00000000000..0d08cb61d3b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-7.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some throws TypeError if callbackfn is Object + without a Call internal method +---*/ + +var arr = new SendableArray(10); +assert.throws(TypeError, function() { + arr.some(new Object()); +}); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-8.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-8.js new file mode 100644 index 00000000000..7db27e3c4ba --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-8.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - side effects produced by step 2 are visible + when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + accessed = true; + return 2; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.some.call(obj, null); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-9.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-9.js new file mode 100644 index 00000000000..0ef1a45e406 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-4-9.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - side effects produced by step 3 are visible + when an exception occurs +---*/ + +var obj = { + 0: 11, + 1: 12 +}; +var accessed = false; +Object.defineProperty(obj, "length", { + get: function() { + return { + toString: function() { + accessed = true; + return "2"; + } + }; + }, + configurable: true +}); +assert.throws(TypeError, function() { + SendableArray.prototype.some.call(obj, null); +}); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-1.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-1.js new file mode 100644 index 00000000000..d570659ba04 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-1.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - thisArg is passed +flags: [noStrict] +---*/ + +(function() { + this._15_4_4_17_5_1 = false; + var _15_4_4_17_5_1 = true; + function callbackfn(val, idx, obj) { + return this._15_4_4_17_5_1; + } + var arr = [1]; + assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); +})(); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-10.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-10.js new file mode 100644 index 00000000000..374ff524755 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-10.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - Array Object can be used as thisArg +---*/ + +var objArray = []; +function callbackfn(val, idx, obj) { + return this === objArray; +} +assert([11].some(callbackfn, objArray), '[11].some(callbackfn, objArray) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-11.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-11.js new file mode 100644 index 00000000000..6fbed3b5748 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-11.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - String object can be used as thisArg +---*/ + +var objString = new String(); +function callbackfn(val, idx, obj) { + return this === objString; +} +assert([11].some(callbackfn, objString), '[11].some(callbackfn, objString) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-12.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-12.js new file mode 100644 index 00000000000..c8c697edd61 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-12.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - Boolean object can be used as thisArg +---*/ + +var objBoolean = new Boolean(); +function callbackfn(val, idx, obj) { + return this === objBoolean; +} +assert([11].some(callbackfn, objBoolean), '[11].some(callbackfn, objBoolean) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-13.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-13.js new file mode 100644 index 00000000000..7bd399df6b4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-13.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - Number object can be used as thisArg +---*/ + +var objNumber = new Number(); +function callbackfn(val, idx, obj) { + return this === objNumber; +} +assert([11].some(callbackfn, objNumber), '[11].some(callbackfn, objNumber) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-14.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-14.js new file mode 100644 index 00000000000..cf801802d3c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-14.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - the Math object can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this === Math; +} +assert([11].some(callbackfn, Math), '[11].some(callbackfn, Math) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-15.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-15.js new file mode 100644 index 00000000000..0885a14b95d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-15.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - Date object can be used as thisArg +---*/ + +var objDate = new Date(0); +function callbackfn(val, idx, obj) { + return this === objDate; +} +assert([11].some(callbackfn, objDate), '[11].some(callbackfn, objDate) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-16.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-16.js new file mode 100644 index 00000000000..484aa352637 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-16.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - RegExp object can be used as thisArg +---*/ + +var objRegExp = new RegExp(); +function callbackfn(val, idx, obj) { + return this === objRegExp; +} +assert([11].some(callbackfn, objRegExp), '[11].some(callbackfn, objRegExp) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-17.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-17.js new file mode 100644 index 00000000000..148ac9e205a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-17.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - the JSON object can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this === JSON; +} +assert([11].some(callbackfn, JSON), '[11].some(callbackfn, JSON) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-18.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-18.js new file mode 100644 index 00000000000..84cc0b1f11e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-18.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - Error object can be used as thisArg +---*/ + +var objError = new RangeError(); +function callbackfn(val, idx, obj) { + return this === objError; +} +assert([11].some(callbackfn, objError), '[11].some(callbackfn, objError) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-19.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-19.js new file mode 100644 index 00000000000..2ee7f7a3099 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-19.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - the Arguments object can be used as thisArg +---*/ + +var arg; +function callbackfn(val, idx, obj) { + return this === arg; +} +(function fun() { + arg = arguments; +}(1, 2, 3)); +assert([11].some(callbackfn, arg), '[11].some(callbackfn, arg) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-2.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-2.js new file mode 100644 index 00000000000..e895ef79554 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - thisArg is Object +---*/ + +var res = false; +var o = new Object(); +o.res = true; +function callbackfn(val, idx, obj) +{ + return this.res; +} +var arr = [1]; +assert.sameValue(arr.some(callbackfn, o), true, 'arr.some(callbackfn, o)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-21.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-21.js new file mode 100644 index 00000000000..71926d82347 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-21.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - the global object can be used as thisArg +---*/ + +var global = this; +function callbackfn(val, idx, obj) { + return this === global; +} +assert([11].some(callbackfn, this), '[11].some(callbackfn, global) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-22.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-22.js new file mode 100644 index 00000000000..da9128b3ccc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-22.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - boolean primitive can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === false; +} +assert([11].some(callbackfn, false), '[11].some(callbackfn, false) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-23.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-23.js new file mode 100644 index 00000000000..ef05380fa99 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-23.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - number primitive can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === 101; +} +assert([11].some(callbackfn, 101), '[11].some(callbackfn, 101) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-24.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-24.js new file mode 100644 index 00000000000..b2aac2c7a4e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-24.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - string primitive can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === "abc"; +} +assert([11].some(callbackfn, "abc"), '[11].some(callbackfn, "abc") !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-25.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-25.js new file mode 100644 index 00000000000..74fc7a0e3c1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-25.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - thisArg not passed +flags: [noStrict] +---*/ + +function innerObj() { + this._15_4_4_17_5_25 = true; + var _15_4_4_17_5_25 = false; + function callbackfn(val, idx, obj) { + return this._15_4_4_17_5_25; + } + var arr = [1]; + this.retVal = !arr.some(callbackfn); +} +assert(new innerObj().retVal, 'new innerObj().retVal !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-3.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-3.js new file mode 100644 index 00000000000..c7dedef4588 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-3.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - thisArg is Array +---*/ + +var res = false; +var a = new SendableArray(); +a.res = true; +function callbackfn(val, idx, obj) +{ + return this.res; +} +var arr = [1]; +assert.sameValue(arr.some(callbackfn, a), true, 'arr.some(callbackfn, a)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-4.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-4.js new file mode 100644 index 00000000000..ce5639febbb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-4.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - thisArg is object from object + template(prototype) +---*/ + +var res = false; +function callbackfn(val, idx, obj) +{ + return this.res; +} +function foo() {} +foo.prototype.res = true; +var f = new foo(); +var arr = [1]; +assert.sameValue(arr.some(callbackfn, f), true, 'arr.some(callbackfn,f)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-5.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-5.js new file mode 100644 index 00000000000..71b4d773db6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-5.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - thisArg is object from object template +---*/ + +var res = false; +function callbackfn(val, idx, obj) +{ + return this.res; +} +function foo() {} +var f = new foo(); +f.res = true; +var arr = [1]; +assert.sameValue(arr.some(callbackfn, f), true, 'arr.some(callbackfn,f)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-6.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-6.js new file mode 100644 index 00000000000..1c2e11a88d6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-6.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - thisArg is function +---*/ + +var res = false; +function callbackfn(val, idx, obj) +{ + return this.res; +} +function foo() {} +foo.res = true; +var arr = [1]; +assert.sameValue(arr.some(callbackfn, foo), true, 'arr.some(callbackfn,foo)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-7.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-7.js new file mode 100644 index 00000000000..d06295dbf46 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-7.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - built-in functions can be used as thisArg +---*/ + +function callbackfn(val, idx, obj) { + return this === eval; +} +assert([11].some(callbackfn, eval), '[11].some(callbackfn, eval) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-8.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-8.js new file mode 100644 index 00000000000..2fb83e67806 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-8.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - thisArg not passed to strict callbackfn +flags: [noStrict] +---*/ + +var innerThisCorrect = false; +function callbackfn(val, idx, obj) { + "use strict"; + innerThisCorrect = this === undefined; + return true; +} +[1].some(callbackfn); +assert(innerThisCorrect, 'innerThisCorrect !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-9.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-9.js new file mode 100644 index 00000000000..8ced7e61b7a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-5-9.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - Function Object can be used as thisArg +---*/ + +var objFunction = function() {}; +function callbackfn(val, idx, obj) { + return this === objFunction; +} +assert([11].some(callbackfn, objFunction), '[11].some(callbackfn, objFunction) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-1.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-1.js new file mode 100644 index 00000000000..3f25b7deb24 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-1.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some considers new elements added to array after + it is called +---*/ + +var calledForThree = false; +function callbackfn(val, idx, obj) +{ + arr[2] = 3; + if (val !== 3) + calledForThree = true; + + return false; +} +var arr = [1, 2, , 4, 5]; +var val = arr.some(callbackfn); +assert(calledForThree, 'calledForThree !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-2.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-2.js new file mode 100644 index 00000000000..8a701810d1a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-2.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some considers new value of elements in array + after it is called +---*/ + +function callbackfn(val, idx, obj) +{ + arr[4] = 6; + if (val < 6) + return false; + else + return true; +} +var arr = [1, 2, 3, 4, 5]; +assert.sameValue(arr.some(callbackfn), true, 'arr.some(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-3.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-3.js new file mode 100644 index 00000000000..7ce6349bdf9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-3.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some doesn't visit deleted elements in array after + it is called +---*/ + +function callbackfn(val, idx, obj) +{ + delete arr[2]; + if (val !== 3) + return false; + else + return true; +} +var arr = [1, 2, 3, 4, 5]; +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-4.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-4.js new file mode 100644 index 00000000000..730fbf5b925 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-4.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some doesn't visit deleted elements when + Array.length is decreased +---*/ + +function callbackfn(val, idx, obj) +{ + arr.length = 3; + if (val < 4) + return false; + else + return true; +} +var arr = [1, 2, 3, 4, 6]; +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-5.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-5.js new file mode 100644 index 00000000000..2232bde8a87 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-5.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some doesn't consider newly added elements in + sparse array +---*/ + +function callbackfn(val, idx, obj) +{ + arr[1000] = 5; + if (val < 5) + return false; + else + return true; +} +var arr = new SendableArray(10); +arr[1] = 1; +arr[2] = 2; +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-6.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-6.js new file mode 100644 index 00000000000..d5d5ec9723d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-6.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some visits deleted element in array after the + call when same index is also present in prototype +---*/ + +function callbackfn(val, idx, obj) +{ + delete arr[4]; + if (val < 5) + return false; + else + return true; +} +SendableArray.prototype[4] = 5; +var arr = [1, 2, 3, 4, 5]; +var res = arr.some(callbackfn); +delete SendableArray.prototype[4]; +assert.sameValue(res, true, 'res'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-8.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-8.js new file mode 100644 index 00000000000..de4f15abce0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-8.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - no observable effects occur if length is 0 +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return val > 10; +} +var obj = { + 0: 11, + 1: 12, + length: 0 +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-9.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-9.js new file mode 100644 index 00000000000..2700538cf47 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-9.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - modifications to length don't change number + of iterations +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + return val > 10; +} +var obj = { + 0: 9, + 2: 12, + length: 3 +}; +Object.defineProperty(obj, "1", { + get: function() { + obj.length = 2; + return 8; + }, + configurable: true +}); +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); +assert.sameValue(called, 3, 'called'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-1.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-1.js new file mode 100644 index 00000000000..a934afd2083 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - callbackfn not called for indexes never + been assigned values +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + callCnt++; + return false; +} +var arr = new SendableArray(10); +arr[1] = undefined; +arr.some(callbackfn); +assert.sameValue(callCnt, 1, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-10.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-10.js new file mode 100644 index 00000000000..8cd37486b98 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-10.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - deleting property of prototype causes + prototype index property not to be visited on an Array-like Object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return idx === 1; +} +var arr = { + 2: 2, + length: 20 +}; +Object.defineProperty(arr, "0", { + get: function() { + delete Object.prototype[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +assert.sameValue(SendableArray.prototype.some.call(arr, callbackfn), false, 'SendableArray.prototype.some.call(arr, callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-11.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-11.js new file mode 100644 index 00000000000..8a0c5536181 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-11.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - deleting property of prototype causes + prototype index property not to be visited on an Array +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return idx === 1; +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + delete SendableArray.prototype[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-12.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-12.js new file mode 100644 index 00000000000..c232adb1d48 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-12.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - deleting own property with prototype + property causes prototype index property to be visited on an + Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return true; + } else { + return false; + } +} +var arr = { + 0: 0, + 1: 111, + 2: 2, + length: 10 +}; +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +Object.prototype[1] = 1; +assert(SendableArray.prototype.some.call(arr, callbackfn), 'SendableArray.prototype.some.call(arr, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-13.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-13.js new file mode 100644 index 00000000000..68a1b8eeea4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-13.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - deleting own property with prototype + property causes prototype index property to be visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return true; + } else { + return false; + } +} +var arr = [0, 111, 2]; +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +SendableArray.prototype[1] = 1; +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-14.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-14.js new file mode 100644 index 00000000000..6923bd3ef7c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-14.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - decreasing length of array causes index + property not to be visited +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return idx === 3; +} +var arr = [0, 1, 2, "last"]; +Object.defineProperty(arr, "0", { + get: function() { + arr.length = 3; + return 0; + }, + configurable: true +}); +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-15.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-15.js new file mode 100644 index 00000000000..ef883fa7624 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-15.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - decreasing length of array with prototype + property causes prototype index property to be visited +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "prototype") { + return true; + } else { + return false; + } +} +var arr = [0, 1, 2]; +Object.defineProperty(SendableArray.prototype, "2", { + get: function() { + return "prototype"; + }, + configurable: true +}); +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-16.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-16.js new file mode 100644 index 00000000000..cc1219330ff --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-16.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - decreasing length of array does not delete + non-configurable properties +flags: [noStrict] +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "unconfigurable") { + return true; + } else { + return false; + } +} +var arr = [0, 1, 2]; +Object.defineProperty(arr, "2", { + get: function() { + return "unconfigurable"; + }, + configurable: false +}); +Object.defineProperty(arr, "1", { + get: function() { + arr.length = 2; + return 1; + }, + configurable: true +}); +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-2.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-2.js new file mode 100644 index 00000000000..1f3d5e2585c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-2.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - added properties in step 2 are visible here +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 2 && val === "length") { + return true; + } else { + return false; + } +} +var arr = {}; +Object.defineProperty(arr, "length", { + get: function() { + arr[2] = "length"; + return 3; + }, + configurable: true +}); +assert(SendableArray.prototype.some.call(arr, callbackfn), 'SendableArray.prototype.some.call(arr, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-3.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-3.js new file mode 100644 index 00000000000..c65da3ed46c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-3.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - deleted properties in step 2 are visible + here +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return idx === 2; +} +var arr = { + 2: 6.99, + 8: 19 +}; +Object.defineProperty(arr, "length", { + get: function() { + delete arr[2]; + return 10; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.some.call(arr, callbackfn), false, 'SendableArray.prototype.some.call(arr, callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-4.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-4.js new file mode 100644 index 00000000000..40d116f5414 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-4.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - properties added into own object after + current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return true; + } else { + return false; + } +} +var arr = { + length: 2 +}; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert(SendableArray.prototype.some.call(arr, callbackfn), 'SendableArray.prototype.some.call(arr, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-5.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-5.js new file mode 100644 index 00000000000..20ad59fb183 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-5.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - properties added into own object after + current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 1) { + return true; + } else { + return false; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(arr, "1", { + get: function() { + return 1; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-6.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-6.js new file mode 100644 index 00000000000..33fbf4cec39 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-6.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - properties can be added to prototype after + current position are visited on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + return true; + } else { + return false; + } +} +var arr = { + length: 2 +}; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(Object.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert(SendableArray.prototype.some.call(arr, callbackfn), 'SendableArray.prototype.some.call(arr, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-7.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-7.js new file mode 100644 index 00000000000..1e1a33e8d9d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-7.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - properties can be added to prototype after + current position are visited on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1 && val === 6.99) { + return true; + } else { + return false; + } +} +var arr = [0, , 2]; +Object.defineProperty(arr, "0", { + get: function() { + Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 6.99; + }, + configurable: true + }); + return 0; + }, + configurable: true +}); +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-8.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-8.js new file mode 100644 index 00000000000..c59c9b775ec --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-8.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - deleting own property causes index property + not to be visited on an Array-like object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return idx === 1; +} +var arr = { + length: 2 +}; +Object.defineProperty(arr, "1", { + get: function() { + return 6.99; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +assert.sameValue(SendableArray.prototype.some.call(arr, callbackfn), false, 'SendableArray.prototype.some.call(arr, callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-9.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-9.js new file mode 100644 index 00000000000..ae1ecd0d15c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-b-9.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - deleting own property causes index property + not to be visited on an Array +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return idx === 1; +} +var arr = [1, 2]; +Object.defineProperty(arr, "1", { + get: function() { + return "6.99"; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + delete arr[1]; + return 0; + }, + configurable: true +}); +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-1.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-1.js new file mode 100644 index 00000000000..b46d14fd2a7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-1.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own data + property on an Array-like object +---*/ + +var kValue = {}; +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val === kValue; + } + return false; +} +var obj = { + 5: kValue, + length: 100 +}; +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-10.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-10.js new file mode 100644 index 00000000000..c78ec9d5063 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-10.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property on an Array +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 10) { + return val === kValue; + } + return false; +} +var arr = []; +Object.defineProperty(arr, "10", { + get: function() { + return kValue; + }, + configurable: true +}); +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-11.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-11.js new file mode 100644 index 00000000000..00ebf0feb10 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-11.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property that overrides an inherited data property on an + Array-like object +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === kValue; + } + return false; +} +var proto = { + 1: 6 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 10; +Object.defineProperty(child, "1", { + get: function() { + return kValue; + }, + configurable: true +}); +assert(SendableArray.prototype.some.call(child, callbackfn), 'SendableArray.prototype.some.call(child, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-12.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-12.js new file mode 100644 index 00000000000..ab08be15a5b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-12.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property that overrides an inherited data property on an Array +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === kValue; + } + return false; +} +var arr = []; +SendableArray.prototype[1] = 100; +Object.defineProperty(arr, "1", { + get: function() { + return kValue; + }, + configurable: true +}); +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-13.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-13.js new file mode 100644 index 00000000000..36e5728ba77 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-13.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === kValue; + } + return false; +} +var proto = {}; +Object.defineProperty(proto, "1", { + get: function() { + return 5; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 10; +Object.defineProperty(child, "1", { + get: function() { + return kValue; + }, + configurable: true +}); +assert(SendableArray.prototype.some.call(child, callbackfn), 'SendableArray.prototype.some.call(child, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-14.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-14.js new file mode 100644 index 00000000000..878172d451b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-14.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property that overrides an inherited accessor property on an Array +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === kValue; + } + return false; +} +var arr = []; +Object.defineProperty(arr, "1", { + get: function() { + return kValue; + }, + configurable: true +}); +Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return 10; + }, + configurable: true +}); +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-15.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-15.js new file mode 100644 index 00000000000..3c0658d6a41 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-15.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is inherited + accessor property on an Array-like object +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === kValue; + } + return false; +} +var proto = {}; +Object.defineProperty(proto, "1", { + get: function() { + return kValue; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 20; +assert(SendableArray.prototype.some.call(child, callbackfn), 'SendableArray.prototype.some.call(child, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-16.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-16.js new file mode 100644 index 00000000000..471b856489f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-16.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is inherited + accessor property on an Array +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === kValue; + } + return false; +} +Object.defineProperty(SendableArray.prototype, "1", { + get: function() { + return kValue; + }, + configurable: true +}); +assert([, , ].some(callbackfn), '[, , ].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-17.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-17.js new file mode 100644 index 00000000000..2f326d1285c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-17.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property without a get function on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return typeof val === "undefined"; + } + return false; +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-18.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-18.js new file mode 100644 index 00000000000..2c3d5b3433f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-18.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property without a get function on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return typeof val === "undefined"; + } + return false; +} +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-19.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-19.js new file mode 100644 index 00000000000..06476493140 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-19.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return typeof val === "undefined"; + } + return false; +} +var obj = { + length: 2 +}; +Object.defineProperty(obj, "1", { + set: function() {}, + configurable: true +}); +Object.prototype[1] = 10; +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-2.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-2.js new file mode 100644 index 00000000000..8bc3342520a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-2.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own data + property on an Array +---*/ + +var kValue = {}; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return kValue === val; + } + return false; +} +assert([kValue].some(callbackfn), '[kValue].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-20.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-20.js new file mode 100644 index 00000000000..9f81032f973 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-20.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property without a get function that overrides an inherited + accessor property on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return typeof val === "undefined"; + } + return false; +} +var arr = []; +Object.defineProperty(arr, "0", { + set: function() {}, + configurable: true +}); +SendableArray.prototype[0] = 100; +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-21.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-21.js new file mode 100644 index 00000000000..5ed78f368cb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-21.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is inherited + accessor property without a get function on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return typeof val === "undefined"; + } + return false; +} +var proto = {}; +Object.defineProperty(proto, "1", { + set: function() {}, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +assert(SendableArray.prototype.some.call(child, callbackfn), 'SendableArray.prototype.some.call(child, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-22.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-22.js new file mode 100644 index 00000000000..1f52c39e0a0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-22.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is inherited + accessor property without a get function on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return typeof val === "undefined"; + } + return false; +} +Object.defineProperty(SendableArray.prototype, "0", { + set: function() {}, + configurable: true +}); +assert([, ].some(callbackfn), '[, ].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-25.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-25.js new file mode 100644 index 00000000000..c430f12010d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-25.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - This object is the Arguments object which + implements its own property get method (number of arguments is + less than number of parameters) +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === 11; + } + return false; +} +var func = function(a, b) { + return SendableArray.prototype.some.call(arguments, callbackfn); +}; +assert(func(11), 'func(11) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-26.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-26.js new file mode 100644 index 00000000000..4ac376f8ab6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-26.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - This object is the Arguments object which + implements its own property get method (number of arguments equals + number of parameters) +---*/ + +var firstResult = false; +var secondResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + firstResult = (val === 11); + return false; + } else if (idx === 1) { + secondResult = (val === 9); + return false; + } else { + return true; + } +} +var func = function(a, b) { + return SendableArray.prototype.some.call(arguments, callbackfn); +}; +assert.sameValue(func(11, 9), false, 'func(11, 9)'); +assert(firstResult, 'firstResult !== true'); +assert(secondResult, 'secondResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-27.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-27.js new file mode 100644 index 00000000000..973ab329d38 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-27.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - This object is the Arguments object which + implements its own property get method (number of arguments is + greater than number of parameters) +---*/ + +var firstResult = false; +var secondResult = false; +var thirdResult = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + firstResult = (val === 11); + return false; + } else if (idx === 1) { + secondResult = (val === 12); + return false; + } else if (idx === 2) { + thirdResult = (val === 9); + return false; + } else { + return true; + } +} +var func = function(a, b) { + return SendableArray.prototype.some.call(arguments, callbackfn); +}; +assert.sameValue(func(11, 12, 9), false, 'func(11, 12, 9)'); +assert(firstResult, 'firstResult !== true'); +assert(secondResult, 'secondResult !== true'); +assert(thirdResult, 'thirdResult !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-28.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-28.js new file mode 100644 index 00000000000..5ba4afb739c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-28.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element changed by getter on previous + iterations is observed on an Array +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === 12; + } + return false; +} +var arr = []; +var helpVerifyVar = 11; +Object.defineProperty(arr, "1", { + get: function() { + return helpVerifyVar; + }, + set: function(args) { + helpVerifyVar = args; + }, + configurable: true +}); +Object.defineProperty(arr, "0", { + get: function() { + arr[1] = 12; + return 9; + }, + configurable: true +}); +assert(arr.some(callbackfn), 'arr.some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-29.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-29.js new file mode 100644 index 00000000000..8908cdf8199 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-29.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element changed by getter on previous + iterations on an Array-like object +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 1) { + return val === 12; + } + return false; +} +var obj = { + length: 2 +}; +var helpVerifyVar = 11; +Object.defineProperty(obj, "1", { + get: function() { + return helpVerifyVar; + }, + set: function(args) { + helpVerifyVar = args; + }, + configurable: true +}); +Object.defineProperty(obj, "0", { + get: function() { + obj[1] = 12; + return 11; + }, + configurable: true +}); +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-3.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-3.js new file mode 100644 index 00000000000..ec33d6c0cac --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-3.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own data + property that overrides an inherited data property on an + Array-like object +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 5) { + return val === kValue; + } + return false; +} +var proto = { + 5: 100 +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child[5] = kValue; +child.length = 10; +assert(SendableArray.prototype.some.call(child, callbackfn), 'SendableArray.prototype.some.call(child, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-30.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-30.js new file mode 100644 index 00000000000..883529bd7cc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-30.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - unhandled exceptions happened in getter + terminate iteration on an Array-like object +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + if (idx > 1) { + accessed = true; + } + return true; +} +var obj = { + length: 20 +}; +Object.defineProperty(obj, "1", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + SendableArray.prototype.some.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-31.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-31.js new file mode 100644 index 00000000000..636f7a57a2b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-31.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - unhandled exceptions happened in getter + terminate iteration on an Array +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + if (idx > 0) { + accessed = true; + } + return true; +} +var arr = []; +arr[10] = 100; +Object.defineProperty(arr, "0", { + get: function() { + throw new RangeError("unhandle exception happened in getter"); + }, + configurable: true +}); +assert.throws(RangeError, function() { + arr.some(callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-4.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-4.js new file mode 100644 index 00000000000..35829566362 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-4.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own data + property that overrides an inherited data property on an Array +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} +SendableArray.prototype[0] = 11; +assert([kValue].some(callbackfn), '[kValue].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-5.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-5.js new file mode 100644 index 00000000000..f042e752764 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-5.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own data + property that overrides an inherited accessor property on an + Array-like object +---*/ + +var kValue = 1000; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} +var proto = {}; +Object.defineProperty(proto, "0", { + get: function() { + return 5; + }, + configurable: true +}); +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 2; +Object.defineProperty(child, "0", { + value: kValue, + configurable: true +}); +assert(SendableArray.prototype.some.call(child, callbackfn), 'SendableArray.prototype.some.call(child, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-6.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-6.js new file mode 100644 index 00000000000..32016d6cf81 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-6.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own data + property that overrides an inherited accessor property on an Array +---*/ + +var kValue = 1000; +function callbackfn(val, idx, obj) { + if (idx === 0) { + return val === kValue; + } + return false; +} +Object.defineProperty(SendableArray.prototype, "0", { + get: function() { + return 9; + }, + configurable: true +}); +assert([kValue].some(callbackfn), '[kValue].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-7.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-7.js new file mode 100644 index 00000000000..2a6560b9e8f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-7.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is inherited data + property on an Array-like object +---*/ + +var kValue = 'abc'; +function callbackfn(val, idx, obj) { + if (5 === idx) { + return kValue === val; + } + return false; +} +var proto = { + 5: kValue +}; +var Con = function() {}; +Con.prototype = proto; +var child = new Con(); +child.length = 10; +assert(SendableArray.prototype.some.call(child, callbackfn), 'SendableArray.prototype.some.call(child, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-8.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-8.js new file mode 100644 index 00000000000..7d8fa6dfe2b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-8.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is inherited data + property on an Array +---*/ + +var kValue = {}; +function callbackfn(val, idx, obj) { + if (0 === idx) { + return kValue === val; + } + return false; +} +SendableArray.prototype[0] = kValue; +assert([, ].some(callbackfn), '[, ].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-9.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-9.js new file mode 100644 index 00000000000..fe6c81abdcf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-i-9.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element to be retrieved is own accessor + property on an Array-like object +---*/ + +var kValue = "abc"; +function callbackfn(val, idx, obj) { + if (idx === 10) { + return val === kValue; + } + return false; +} +var obj = { + length: 20 +}; +Object.defineProperty(obj, "10", { + get: function() { + return kValue; + }, + configurable: true +}); +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-1.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-1.js new file mode 100644 index 00000000000..d5fa27a0a1d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-1.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - callbackfn called with correct parameters +---*/ + +function callbackfn(val, idx, obj) +{ + if (obj[idx] === val) + return false; + else + return true; +} +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-10.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-10.js new file mode 100644 index 00000000000..9a4a185a027 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-10.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - callbackfn is called with 1 formal parameter +---*/ + +function callbackfn(val) { + return val > 10; +} +assert([11, 12].some(callbackfn), '[11, 12].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-11.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-11.js new file mode 100644 index 00000000000..3a829fa0bd6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-11.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - callbackfn is called with 2 formal parameter +---*/ + +function callbackfn(val, idx) { + return val > 10 && arguments[2][idx] === val; +} +assert([9, 12].some(callbackfn), '[9, 12].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-12.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-12.js new file mode 100644 index 00000000000..ec48f3d71a0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-12.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - callbackfn is called with 3 formal parameter +---*/ + +function callbackfn(val, idx, obj) { + return val > 10 && obj[idx] === val; +} +assert([9, 12].some(callbackfn), '[9, 12].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-13.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-13.js new file mode 100644 index 00000000000..b7df3754c85 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-13.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - callbackfn that uses arguments object to + get parameter value +---*/ + +function callbackfn() { + return arguments[2][arguments[1]] === arguments[0]; +} +assert([9, 12].some(callbackfn), '[9, 12].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-16.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-16.js new file mode 100644 index 00000000000..2b02ab81feb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-16.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'this' of 'callback' is a Boolean object + when 'T' is not an object ('T' is a boolean primitive) +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === false; +} +var obj = { + 0: 11, + length: 1 +}; +assert(SendableArray.prototype.some.call(obj, callbackfn, false), 'SendableArray.prototype.some.call(obj, callbackfn, false) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-17.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-17.js new file mode 100644 index 00000000000..8fa523f8492 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-17.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'this' of 'callbackfn' is a Number object + when T is not an object (T is a number primitive) +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === 5; +} +var obj = { + 0: 11, + length: 1 +}; +assert(SendableArray.prototype.some.call(obj, callbackfn, 5), 'SendableArray.prototype.some.call(obj, callbackfn, 5) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-18.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-18.js new file mode 100644 index 00000000000..31c26402233 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-18.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - 'this' of 'callbackfn' is an String object + when T is not an object (T is a string primitive) +---*/ + +function callbackfn(val, idx, obj) { + return this.valueOf() === "hello!"; +} +var obj = { + 0: 11, + 1: 9, + length: 2 +}; +assert(SendableArray.prototype.some.call(obj, callbackfn, "hello!"), 'SendableArray.prototype.some.call(obj, callbackfn, "hello!") !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-19.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-19.js new file mode 100644 index 00000000000..13bce63b612 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-19.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - non-indexed properties are not called +---*/ + +var called = 0; +function callbackfn(val, idx, obj) { + called++; + return val === 11; +} +var obj = { + 0: 9, + 10: 8, + non_index_property: 11, + length: 20 +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert.sameValue(called, 2, 'called'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-2.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-2.js new file mode 100644 index 00000000000..e7f7f15abb8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-2.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - callbackfn takes 3 arguments +---*/ + +function callbackfn(val, idx, obj) +{ + if (arguments.length === 3) //verify if callbackfn was called with 3 parameters + return false; + else + return true; +} +var arr = [0, 1, true, null, new Object(), "five"]; +arr[999999] = -6.6; +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-20.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-20.js new file mode 100644 index 00000000000..2348a4de9bd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-20.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - callbackfn called with correct parameters + (thisArg is correct) +---*/ + +var thisArg = { + threshold: 10 +}; +function callbackfn(val, idx, obj) { + return this === thisArg; +} +var obj = { + 0: 11, + length: 2 +}; +assert(SendableArray.prototype.some.call(obj, callbackfn, thisArg), 'SendableArray.prototype.some.call(obj, callbackfn, thisArg) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-21.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-21.js new file mode 100644 index 00000000000..7f8d54e0b87 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-21.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - callbackfn called with correct parameters + (kValue is correct) +---*/ + +var firstIndex = false; +var secondIndex = false; +function callbackfn(val, idx, obj) { + if (idx === 0) { + firstIndex = (val === 11); + return false; + } + if (idx === 1) { + secondIndex = (val === 12); + return false; + } +} +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert(firstIndex, 'firstIndex !== true'); +assert(secondIndex, 'secondIndex !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-22.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-22.js new file mode 100644 index 00000000000..39a6c241ac9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-22.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - callbackfn called with correct parameters + (the index k is correct) +---*/ + +var firstIndex = false; +var secondIndex = false; +function callbackfn(val, idx, obj) { + if (val === 11) { + firstIndex = (idx === 0); + return false; + } + if (val === 12) { + secondIndex = (idx === 1); + return false; + } +} +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert(firstIndex, 'firstIndex !== true'); +assert(secondIndex, 'secondIndex !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-23.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-23.js new file mode 100644 index 00000000000..cc15354aa6b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-23.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - callbackfn called with correct parameters + (this object O is correct) +---*/ + +var obj = { + 0: 11, + 1: 12, + length: 2 +}; +function callbackfn(val, idx, o) { + return obj === o; +} +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-3.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-3.js new file mode 100644 index 00000000000..c6f4261eebf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-3.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some immediately returns true if callbackfn + returns true +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + callCnt++; + if (idx > 5) + return true; + else + return false; +} +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +assert.sameValue(arr.some(callbackfn), true, 'arr.some(callbackfn)'); +assert.sameValue(callCnt, 7, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-4.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-4.js new file mode 100644 index 00000000000..0e3c90a4088 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-4.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - k values are passed in ascending numeric + order +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +var lastIdx = 0; +var called = 0; +function callbackfn(val, idx, o) { + called++; + if (lastIdx !== idx) { + return true; + } else { + lastIdx++; + return false; + } +} +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); +assert.sameValue(arr.length, called, 'arr.length'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-5.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-5.js new file mode 100644 index 00000000000..e2b690b9490 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-5.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - k values are accessed during each iteration + and not prior to starting the loop +---*/ + +var kIndex = []; +//By below way, we could verify that k would be setted as 0, 1, ..., length - 1 in order, and each value will be setted one time. +function callbackfn(val, idx, obj) { + //Each position should be visited one time, which means k is accessed one time during iterations. + if (typeof kIndex[idx] === "undefined") { + //when current position is visited, its previous index should has been visited. + if (idx !== 0 && typeof kIndex[idx - 1] === "undefined") { + return true; + } + kIndex[idx] = 1; + return false; + } else { + return true; + } +} +assert.sameValue([11, 12, 13, 14].some(callbackfn, undefined), false, '[11, 12, 13, 14].some(callbackfn, undefined)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-6.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-6.js new file mode 100644 index 00000000000..24e8b6ab3a6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-6.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - arguments to callbackfn are self consistent +---*/ + +var obj = { + 0: 11, + length: 1 +}; +var thisArg = {}; +function callbackfn() { + return this === thisArg && arguments[0] === 11 && arguments[1] === 0 && arguments[2] === obj; +} +assert(SendableArray.prototype.some.call(obj, callbackfn, thisArg), 'SendableArray.prototype.some.call(obj, callbackfn, thisArg) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-7.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-7.js new file mode 100644 index 00000000000..ffc81669833 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-7.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - unhandled exceptions happened in callbackfn + terminate iteration +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + if (idx > 0) { + accessed = true; + } + if (idx === 0) { + throw new Error("Exception occurred in callbackfn"); + } + return false; +} +var obj = { + 0: 9, + 1: 100, + 10: 11, + length: 20 +}; +assert.throws(Error, function() { + SendableArray.prototype.some.call(obj, callbackfn); +}); +assert.sameValue(accessed, false, 'accessed'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-8.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-8.js new file mode 100644 index 00000000000..098601b9b7b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-8.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - element changed by callbackfn on previous + iterations is observed +---*/ + +function callbackfn(val, idx, obj) { + if (idx === 0) { + obj[idx + 1] = 11; + } + return val > 10; +} +var obj = { + 0: 9, + 1: 8, + length: 2 +}; +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-9.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-9.js new file mode 100644 index 00000000000..e53f600034b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-ii-9.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - callbackfn is called with 0 formal parameter +---*/ + +function callbackfn() { + return true; +} +assert([11, 12].some(callbackfn), '[11, 12].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-1.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-1.js new file mode 100644 index 00000000000..dfdeec74aaf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - return value of callbackfn is undefined +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return undefined; +} +var obj = { + 0: 11, + length: 2 +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-10.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-10.js new file mode 100644 index 00000000000..8774eec664b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-10.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is Infinity) +---*/ + +function callbackfn(val, idx, obj) { + return Infinity; +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-11.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-11.js new file mode 100644 index 00000000000..e3a57054b83 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-11.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is -Infinity) +---*/ + +function callbackfn(val, idx, obj) { + return -Infinity; +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-12.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-12.js new file mode 100644 index 00000000000..e78e843c8d6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-12.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is NaN) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return NaN; +} +assert.sameValue([11].some(callbackfn), false, '[11].some(callbackfn)'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-13.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-13.js new file mode 100644 index 00000000000..9b7212e1a97 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-13.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is an empty + string +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return ""; +} +assert.sameValue([11].some(callbackfn), false, '[11].some(callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-14.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-14.js new file mode 100644 index 00000000000..a8531a56cf7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-14.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a non-empty + string +---*/ + +function callbackfn(val, idx, obj) { + return "non-empty string"; +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-15.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-15.js new file mode 100644 index 00000000000..61dc5a8f445 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-15.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is Function + object +---*/ + +function callbackfn(val, idx, obj) { + return function() {}; +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-16.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-16.js new file mode 100644 index 00000000000..f3609811410 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-16.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is an Array + object +---*/ + +function callbackfn(val, idx, obj) { + return new SendableArray(10); +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-17.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-17.js new file mode 100644 index 00000000000..122dcf56800 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-17.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a String + object +---*/ + +function callbackfn(val, idx, obj) { + return new String(); +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-18.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-18.js new file mode 100644 index 00000000000..83fba8f9626 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-18.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a Boolean + object +---*/ + +function callbackfn(val, idx, obj) { + return new Boolean(); +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-19.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-19.js new file mode 100644 index 00000000000..4809a5493f6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-19.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a Number + object +---*/ + +function callbackfn(val, idx, obj) { + return new Number(); +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-2.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-2.js new file mode 100644 index 00000000000..a2decc8b731 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-2.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - return value of callbackfn is null +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return null; +} +var obj = { + 0: 11, + length: 2 +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-20.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-20.js new file mode 100644 index 00000000000..71eaf0e6bad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-20.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is the Math + object +---*/ + +function callbackfn(val, idx, obj) { + return Math; +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-21.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-21.js new file mode 100644 index 00000000000..d50e2094d63 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-21.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - return value of callbackfn is a Date object +---*/ + +function callbackfn(val, idx, obj) { + return new Date(0); +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-22.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-22.js new file mode 100644 index 00000000000..bec6e46fe68 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-22.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a RegExp + object +---*/ + +function callbackfn(val, idx, obj) { + return new RegExp(); +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-23.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-23.js new file mode 100644 index 00000000000..cbe9c9511c1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-23.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is the JSON + object +---*/ + +function callbackfn(val, idx, obj) { + return JSON; +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-24.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-24.js new file mode 100644 index 00000000000..6a1221c4399 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-24.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is an Error + object +---*/ + +function callbackfn(val, idx, obj) { + return new EvalError(); +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-25.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-25.js new file mode 100644 index 00000000000..0bbcb60240a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-25.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is the Arguments + object +---*/ + +function callbackfn(val, idx, obj) { + return arguments; +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-26.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-26.js new file mode 100644 index 00000000000..cc1ef24c2bf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-26.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is the global + object +---*/ + +var global = this; +function callbackfn(val, idx, obj) { + return global; +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-28.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-28.js new file mode 100644 index 00000000000..e9b5c8fbcf0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-28.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - true prevents further side effects +---*/ + +var result = false; +function callbackfn(val, idx, obj) { + if (idx > 1) { + result = true; + } + return val > 10; +} +var obj = { + length: 20 +}; +Object.defineProperty(obj, "0", { + get: function() { + return 8; + }, + configurable: true +}); +Object.defineProperty(obj, "1", { + get: function() { + return 11; + }, + configurable: true +}); +Object.defineProperty(obj, "2", { + get: function() { + result = true; + return 11; + }, + configurable: true +}); +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); +assert.sameValue(result, false, 'result'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-29.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-29.js new file mode 100644 index 00000000000..c5f77cc2a6a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-29.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value (new Boolean(false)) of + callbackfn is treated as true value +---*/ + +function callbackfn() { + return new Boolean(false); +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-3.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-3.js new file mode 100644 index 00000000000..c2006b8e870 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-3.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a boolean + (value is false) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return false; +} +var obj = { + 0: 11, + length: 2 +}; +assert.sameValue(SendableArray.prototype.some.call(obj, callbackfn), false, 'SendableArray.prototype.some.call(obj, callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-4.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-4.js new file mode 100644 index 00000000000..e9340f28341 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-4.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a boolean + (value is true) +---*/ + +function callbackfn(val, idx, obj) { + return true; +} +var obj = { + 0: 11, + length: 2 +}; +assert(SendableArray.prototype.some.call(obj, callbackfn), 'SendableArray.prototype.some.call(obj, callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-5.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-5.js new file mode 100644 index 00000000000..6b45b43bc9d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-5.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is 0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return 0; +} +assert.sameValue([11].some(callbackfn), false, '[11].some(callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-6.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-6.js new file mode 100644 index 00000000000..1f6ac137d8b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-6.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is +0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return +0; +} +assert.sameValue([11].some(callbackfn), false, '[11].some(callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-7.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-7.js new file mode 100644 index 00000000000..5661d3f4650 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-7.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is -0) +---*/ + +var accessed = false; +function callbackfn(val, idx, obj) { + accessed = true; + return -0; +} +assert.sameValue([11].some(callbackfn), false, '[11].some(callbackfn)'); +assert(accessed, 'accessed !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-8.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-8.js new file mode 100644 index 00000000000..cfa2bc51482 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-8.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is positive number) +---*/ + +function callbackfn(val, idx, obj) { + return 5; +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-9.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-9.js new file mode 100644 index 00000000000..c8ea7a652cd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-7-c-iii-9.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some - return value of callbackfn is a number + (value is negative number) +---*/ + +function callbackfn(val, idx, obj) { + return -5; +} +assert([11].some(callbackfn), '[11].some(callbackfn) !== true'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-1.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-1.js new file mode 100644 index 00000000000..e9a98f5b2fa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some returns false if 'length' is 0 (empty array) +---*/ + +function cb() {} +var i = [].some(cb); +assert.sameValue(i, false, 'i'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-10.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-10.js new file mode 100644 index 00000000000..0ac262901ba --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-10.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some - subclassed array when length is reduced +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = 2; +function cb(val) +{ + if (val > 2) + return true; + else + return false; +} +var i = f.some(cb); +assert.sameValue(i, false, 'i'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-11.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-11.js new file mode 100644 index 00000000000..83d9d1a2201 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-11.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false when all calls to callbackfn + return false +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + callCnt++; + return false; +} +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); +assert.sameValue(callCnt, 10, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-12.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-12.js new file mode 100644 index 00000000000..7f2271453af --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-12.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some doesn't mutate the array on which it is + called on +---*/ + +function callbackfn(val, idx, obj) +{ + return true; +} +var arr = [1, 2, 3, 4, 5]; +arr.some(callbackfn); +assert.sameValue(arr[0], 1, 'arr[0]'); +assert.sameValue(arr[1], 2, 'arr[1]'); +assert.sameValue(arr[2], 3, 'arr[2]'); +assert.sameValue(arr[3], 4, 'arr[3]'); +assert.sameValue(arr[4], 5, 'arr[4]'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-13.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-13.js new file mode 100644 index 00000000000..d0959a8e47d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-13.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some doesn't visit expandos +---*/ + +var callCnt = 0; +function callbackfn(val, idx, obj) +{ + callCnt++; + return false; +} +var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +arr["i"] = 10; +arr[true] = 11; +assert.sameValue(arr.some(callbackfn), false, 'arr.some(callbackfn)'); +assert.sameValue(callCnt, 10, 'callCnt'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-2.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-2.js new file mode 100644 index 00000000000..6dba23b9c8f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false if 'length' is 0 (subclassed + Array, length overridden to null (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = null; +function cb() {} +var i = f.some(cb); +assert.sameValue(i, false, 'i'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-3.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-3.js new file mode 100644 index 00000000000..6f785756ea0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-3.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false if 'length' is 0 (subclassed + Array, length overridden to false (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = false; +function cb() {} +var i = f.some(cb); +assert.sameValue(i, false, 'i'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-4.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-4.js new file mode 100644 index 00000000000..ced71ed42fe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false if 'length' is 0 (subclassed + Array, length overridden to 0 (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = 0; +function cb() {} +var i = f.some(cb); +assert.sameValue(i, false, 'i'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-5.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-5.js new file mode 100644 index 00000000000..032ed8df8c5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-5.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false if 'length' is 0 (subclassed + Array, length overridden to '0' (type conversion)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = '0'; +function cb() {} +var i = f.some(cb); +assert.sameValue(i, false, 'i'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-6.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-6.js new file mode 100644 index 00000000000..048177103c7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-6.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false if 'length' is 0 (subclassed + Array, length overridden with obj with valueOf) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + valueOf: function() { + return 0; + } +}; +f.length = o; +function cb() {} +var i = f.some(cb); +assert.sameValue(i, false, 'i'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-7.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-7.js new file mode 100644 index 00000000000..550f16d930f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-7.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false if 'length' is 0 (subclassed + Array, length overridden with obj w/o valueOf (toString)) +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +var o = { + toString: function() { + return '0'; + } +}; +f.length = o; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +function cb() {} +var i = f.some(cb); +assert.sameValue(i, false, 'i'); diff --git a/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-8.js b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-8.js new file mode 100644 index 00000000000..561650bf162 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/15.4.4.17-8-8.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some returns false if 'length' is 0 (subclassed + Array, length overridden with [] +---*/ + +foo.prototype = new SendableArray(1, 2, 3); +function foo() {} +var f = new foo(); +f.length = []; +// objects inherit the default valueOf method of the Object object; +// that simply returns the itself. Since the default valueOf() method +// does not return a primitive value, ES next tries to convert the object +// to a number by calling its toString() method and converting the +// resulting string to a number. +// +// The toString( ) method on Array converts the array elements to strings, +// then returns the result of concatenating these strings, with commas in +// between. An array with no elements converts to the empty string, which +// converts to the number 0. If an array has a single element that is a +// number n, the array converts to a string representation of n, which is +// then converted back to n itself. If an array contains more than one element, +// or if its one element is not a number, the array converts to NaN. +function cb() {} +var i = f.some(cb); +assert.sameValue(i, false, 'i'); diff --git a/test/sendable/builtins/Array/prototype/some/call-with-boolean.js b/test/sendable/builtins/Array/prototype/some/call-with-boolean.js new file mode 100644 index 00000000000..412cd9f100a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/call-with-boolean.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: Array.prototype.some applied to boolean primitive +---*/ + +assert.sameValue( + SendableArray.prototype.some.call(true, () => {}), + false, + 'SendableArray.prototype.some.call(true, () => {}) must return false' +); +assert.sameValue( + SendableArray.prototype.some.call(false, () => {}), + false, + 'SendableArray.prototype.some.call(false, () => {}) must return false' +); diff --git a/test/sendable/builtins/Array/prototype/some/callbackfn-resize-arraybuffer.js b/test/sendable/builtins/Array/prototype/some/callbackfn-resize-arraybuffer.js new file mode 100644 index 00000000000..b9b266369c6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/callbackfn-resize-arraybuffer.js @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: TypedArray instance buffer can be resized during iteration +includes: [testTypedArray.js, compareArray.js] +features: [TypedArray, resizable-arraybuffer] +---*/ + +// If the host chooses to throw as allowed by the specification, the observed +// behavior will be identical to the case where `ArrayBuffer.prototype.resize` +// has not been implemented. The following assertion prevents this test from +// passing in runtimes which have not implemented the method. +assert.sameValue(typeof ArrayBuffer.prototype.resize, 'function'); +testWithTypedArrayConstructors(function(TA) { + var BPE = TA.BYTES_PER_ELEMENT; + var buffer = new ArrayBuffer(BPE * 3, {maxByteLength: BPE * 4}); + var sample = new TA(buffer); + var expectedElements, expectedIndices, expectedArrays; + var elements, indices, arrays, result; + elements = []; + indices = []; + arrays = []; + result = SendableArray.prototype.some.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(2 * BPE); + expectedElements = [0, 0]; + expectedIndices = [0, 1]; + expectedArrays = [sample, sample]; + } catch (_) { + expectedElements = [0, 0, 0]; + expectedIndices = [0, 1, 2]; + expectedArrays = [sample, sample, sample]; + } + } + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + assert.compareArray(elements, expectedElements, 'elements (shrink)'); + assert.compareArray(indices, expectedIndices, 'indices (shrink)'); + assert.compareArray(arrays, expectedArrays, 'arrays (shrink)'); + assert.sameValue(result, false, 'result (shrink)'); + elements = []; + indices = []; + arrays = []; + result = SendableArray.prototype.some.call(sample, function(element, index, array) { + if (elements.length === 0) { + try { + buffer.resize(4 * BPE); + } catch (_) {} + } + elements.push(element); + indices.push(index); + arrays.push(array); + return false; + }); + assert.compareArray(elements, expectedElements, 'elements (grow)'); + assert.compareArray(indices, expectedIndices, 'indices (grow)'); + assert.compareArray(arrays, expectedArrays, 'arrays (grow)'); + assert.sameValue(result, false, 'result (grow)'); +}); diff --git a/test/sendable/builtins/Array/prototype/some/length.js b/test/sendable/builtins/Array/prototype/some/length.js new file mode 100644 index 00000000000..1cdcb4cd63a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/length.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + The "length" property of Array.prototype.some +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.some, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/some/name.js b/test/sendable/builtins/Array/prototype/some/name.js new file mode 100644 index 00000000000..436b1ca30a6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.prototype.some.name is "some". +info: | + Array.prototype.some ( callbackfn [ , thisArg ] ) + 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(SendableArray.prototype.some, "name", { + value: "some", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/some/not-a-constructor.js b/test/sendable/builtins/Array/prototype/some/not-a-constructor.js new file mode 100644 index 00000000000..17e4ef7b7c5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/not-a-constructor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.some 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(SendableArray.prototype.some), false, 'isConstructor(SendableArray.prototype.some) must return false'); +assert.throws(TypeError, () => { + new SendableArray.prototype.some(() => {}); +}); + diff --git a/test/sendable/builtins/Array/prototype/some/prop-desc.js b/test/sendable/builtins/Array/prototype/some/prop-desc.js new file mode 100644 index 00000000000..4ae0ba86108 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + "some" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.some, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "some", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/some/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/Array/prototype/some/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..13d53fb8e33 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.p.some behaves correctly on TypedArrays backed by resizable buffers that + are grown mid-iteration. +features: [resizable-arraybuffer] +includes: [compareArray.js, resizableArrayBufferUtils.js] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(!SendableArray.prototype.some.call(fixedLength, ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(!SendableArray.prototype.some.call(fixedLengthWithOffset, ResizeMidIteration)); + assert.compareArray(values, [ + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(!SendableArray.prototype.some.call(lengthTracking, ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2, + 4, + 6 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + rab = rab; + resizeAfter = 1; + resizeTo = 5 * ctor.BYTES_PER_ELEMENT; + assert(!SendableArray.prototype.some.call(lengthTrackingWithOffset, ResizeMidIteration)); + assert.compareArray(values, [ + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/some/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/Array/prototype/some/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..5e41f076460 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.p.some behaves correctly on TypedArrays backed by resizable buffers that + are shrunk mid-iteration. +features: [resizable-arraybuffer] +includes: [compareArray.js, resizableArrayBufferUtils.js] +---*/ + +let values; +let rab; +let resizeAfter; +let resizeTo; +// Collects the view of the resizable array buffer rab into values, with an +// iteration during which, after resizeAfter steps, rab is resized to length +// resizeTo. To be called by a method of the view being collected. +// Note that rab, values, resizeAfter, and resizeTo may need to be reset +// before calling this. +function ResizeMidIteration(n) { + CollectValuesAndResize(n, values, rab, resizeAfter, resizeTo); + return false; +} +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(!SendableArray.prototype.some.call(fixedLength, ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(!SendableArray.prototype.some.call(fixedLengthWithOffset, ResizeMidIteration)); + assert.compareArray(values, [4]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + values = []; + resizeAfter = 2; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(!SendableArray.prototype.some.call(lengthTracking, ResizeMidIteration)); + assert.compareArray(values, [ + 0, + 2, + 4 + ]); +} +for (let ctor of ctors) { + rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + values = []; + resizeAfter = 1; + resizeTo = 3 * ctor.BYTES_PER_ELEMENT; + assert(!SendableArray.prototype.some.call(lengthTrackingWithOffset, ResizeMidIteration)); + assert.compareArray(values, [4]); +} diff --git a/test/sendable/builtins/Array/prototype/some/resizable-buffer.js b/test/sendable/builtins/Array/prototype/some/resizable-buffer.js new file mode 100644 index 00000000000..f9b2354e18f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/some/resizable-buffer.js @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.some +description: > + Array.p.some behaves correctly on TypedArrays backed by resizable buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + function div3(n) { + return Number(n) % 3 == 0; + } + function over10(n) { + return Number(n) > 10; + } + assert(SendableArray.prototype.some.call(fixedLength, div3)); + assert(!SendableArray.prototype.some.call(fixedLength, over10)); + assert(SendableArray.prototype.some.call(fixedLengthWithOffset, div3)); + assert(!SendableArray.prototype.some.call(fixedLengthWithOffset, over10)); + assert(SendableArray.prototype.some.call(lengthTracking, div3)); + assert(!SendableArray.prototype.some.call(lengthTracking, over10)); + assert(SendableArray.prototype.some.call(lengthTrackingWithOffset, div3)); + assert(!SendableArray.prototype.some.call(lengthTrackingWithOffset, over10)); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + assert(!SendableArray.prototype.some.call(fixedLength, div3)); + assert(!SendableArray.prototype.some.call(fixedLengthWithOffset, div3)); + assert(SendableArray.prototype.some.call(lengthTracking, div3)); + assert(!SendableArray.prototype.some.call(lengthTracking, over10)); + assert(!SendableArray.prototype.some.call(lengthTrackingWithOffset, div3)); + assert(!SendableArray.prototype.some.call(lengthTrackingWithOffset, over10)); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert(!SendableArray.prototype.some.call(fixedLength, div3)); + assert(!SendableArray.prototype.some.call(fixedLengthWithOffset, div3)); + assert(!SendableArray.prototype.some.call(lengthTrackingWithOffset, div3)); + assert(SendableArray.prototype.some.call(lengthTracking, div3)); + assert(!SendableArray.prototype.some.call(lengthTracking, over10)); + // Shrink to zero. + rab.resize(0); + assert(!SendableArray.prototype.some.call(fixedLength, div3)); + assert(!SendableArray.prototype.some.call(fixedLengthWithOffset, div3)); + assert(!SendableArray.prototype.some.call(lengthTrackingWithOffset, div3)); + assert(!SendableArray.prototype.some.call(lengthTracking, div3)); + assert(!SendableArray.prototype.some.call(lengthTracking, over10)); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + assert(SendableArray.prototype.some.call(fixedLength, div3)); + assert(!SendableArray.prototype.some.call(fixedLength, over10)); + assert(SendableArray.prototype.some.call(fixedLengthWithOffset, div3)); + assert(!SendableArray.prototype.some.call(fixedLengthWithOffset, over10)); + assert(SendableArray.prototype.some.call(lengthTracking, div3)); + assert(!SendableArray.prototype.some.call(lengthTracking, over10)); + assert(SendableArray.prototype.some.call(lengthTrackingWithOffset, div3)); + assert(!SendableArray.prototype.some.call(lengthTrackingWithOffset, over10)); +} -- Gitee From be0f31d8ba1848418036feb194d04467ed79fe62 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 3 Jan 2025 09:44:37 +0800 Subject: [PATCH 67/93] add array-sort Signed-off-by: zhuzhihui7 --- .../prototype/sort/S15.4.4.11_A1.1_T1.js | 33 + .../prototype/sort/S15.4.4.11_A1.2_T1.js | 47 + .../prototype/sort/S15.4.4.11_A1.2_T2.js | 52 + .../prototype/sort/S15.4.4.11_A1.3_T1.js | 33 + .../prototype/sort/S15.4.4.11_A1.4_T1.js | 44 + .../prototype/sort/S15.4.4.11_A1.4_T2.js | 49 + .../prototype/sort/S15.4.4.11_A1.5_T1.js | 42 + .../prototype/sort/S15.4.4.11_A2.1_T1.js | 33 + .../prototype/sort/S15.4.4.11_A2.1_T2.js | 33 + .../prototype/sort/S15.4.4.11_A2.1_T3.js | 43 + .../prototype/sort/S15.4.4.11_A2.2_T1.js | 37 + .../prototype/sort/S15.4.4.11_A2.2_T2.js | 37 + .../prototype/sort/S15.4.4.11_A2.2_T3.js | 47 + .../Array/prototype/sort/S15.4.4.11_A3_T1.js | 59 + .../Array/prototype/sort/S15.4.4.11_A3_T2.js | 66 + .../Array/prototype/sort/S15.4.4.11_A4_T3.js | 41 + .../Array/prototype/sort/S15.4.4.11_A5_T1.js | 27 + .../Array/prototype/sort/S15.4.4.11_A6_T2.js | 61 + .../Array/prototype/sort/S15.4.4.11_A8.js | 33 + .../Array/prototype/sort/bug_596_1.js | 34 + .../Array/prototype/sort/bug_596_2.js | 57 + .../prototype/sort/call-with-primitive.js | 39 + .../Array/prototype/sort/comparefn-grow.js | 77 + .../sort/comparefn-nonfunction-call-throws.js | 85 + .../sort/comparefn-resizable-buffer.js | 191 ++ .../Array/prototype/sort/comparefn-shrink.js | 79 + .../builtins/Array/prototype/sort/length.js | 40 + .../builtins/Array/prototype/sort/name.js | 36 + .../Array/prototype/sort/not-a-constructor.js | 34 + .../sort/precise-comparefn-throws.js | 60 + .../sort/precise-getter-appends-elements.js | 56 + .../sort/precise-getter-decreases-length.js | 46 + .../precise-getter-deletes-predecessor.js | 50 + .../sort/precise-getter-deletes-successor.js | 51 + .../sort/precise-getter-increases-length.js | 56 + .../sort/precise-getter-pops-elements.js | 47 + .../sort/precise-getter-sets-predecessor.js | 48 + .../sort/precise-getter-sets-successor.js | 48 + .../sort/precise-prototype-accessors.js | 50 + .../sort/precise-prototype-element.js | 37 + .../sort/precise-setter-appends-elements.js | 50 + .../sort/precise-setter-decreases-length.js | 45 + .../precise-setter-deletes-predecessor.js | 48 + .../sort/precise-setter-deletes-successor.js | 47 + .../sort/precise-setter-increases-length.js | 51 + .../sort/precise-setter-pops-elements.js | 46 + .../sort/precise-setter-sets-predecessor.js | 47 + .../sort/precise-setter-sets-successor.js | 47 + .../Array/prototype/sort/prop-desc.js | 33 + .../resizable-buffer-default-comparator.js | 174 ++ .../prototype/sort/stability-11-elements.js | 45 + .../prototype/sort/stability-2048-elements.js | 2090 +++++++++++++++++ .../prototype/sort/stability-5-elements.js | 36 + .../prototype/sort/stability-513-elements.js | 555 +++++ 54 files changed, 5352 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.3_T1.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.4_T1.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.4_T2.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.5_T1.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.1_T2.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.1_T3.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.2_T3.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A3_T1.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A3_T2.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A4_T3.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A5_T1.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A6_T2.js create mode 100644 test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A8.js create mode 100644 test/sendable/builtins/Array/prototype/sort/bug_596_1.js create mode 100644 test/sendable/builtins/Array/prototype/sort/bug_596_2.js create mode 100644 test/sendable/builtins/Array/prototype/sort/call-with-primitive.js create mode 100644 test/sendable/builtins/Array/prototype/sort/comparefn-grow.js create mode 100644 test/sendable/builtins/Array/prototype/sort/comparefn-nonfunction-call-throws.js create mode 100644 test/sendable/builtins/Array/prototype/sort/comparefn-resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/sort/comparefn-shrink.js create mode 100644 test/sendable/builtins/Array/prototype/sort/length.js create mode 100644 test/sendable/builtins/Array/prototype/sort/name.js create mode 100644 test/sendable/builtins/Array/prototype/sort/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-comparefn-throws.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-getter-appends-elements.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-getter-decreases-length.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-getter-deletes-predecessor.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-getter-deletes-successor.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-getter-increases-length.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-getter-pops-elements.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-getter-sets-predecessor.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-getter-sets-successor.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-prototype-accessors.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-prototype-element.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-setter-appends-elements.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-setter-decreases-length.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-setter-deletes-predecessor.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-setter-deletes-successor.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-setter-increases-length.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-setter-pops-elements.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-setter-sets-predecessor.js create mode 100644 test/sendable/builtins/Array/prototype/sort/precise-setter-sets-successor.js create mode 100644 test/sendable/builtins/Array/prototype/sort/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/sort/resizable-buffer-default-comparator.js create mode 100644 test/sendable/builtins/Array/prototype/sort/stability-11-elements.js create mode 100644 test/sendable/builtins/Array/prototype/sort/stability-2048-elements.js create mode 100644 test/sendable/builtins/Array/prototype/sort/stability-5-elements.js create mode 100644 test/sendable/builtins/Array/prototype/sort/stability-513-elements.js diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.1_T1.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.1_T1.js new file mode 100644 index 00000000000..2d26baaaf96 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.1_T1.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If this object does not have a property named by ToString(j), + and this object does not have a property named by ToString(k), return +0 +esid: sec-array.prototype.sort +description: If comparefn is undefined, use SortCompare operator +---*/ + +var x = new SendableArray(2); +x.sort(); +if (x.length !== 2) { + throw new Test262Error('#1: var x = new SendableArray(2); x.sort(); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== undefined) { + throw new Test262Error('#2: var x = new SendableArray(2); x.sort(); x[0] === undefined. Actual: ' + (x[0])); +} +if (x[1] !== undefined) { + throw new Test262Error('#3: var x = new SendableArray(2); x.sort(); x[1] === undefined. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.2_T1.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.2_T1.js new file mode 100644 index 00000000000..f6e1d879650 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.2_T1.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If this object does not have a property named by + ToString(j), return 1. If this object does not have a property + named by ToString(k), return -1 +esid: sec-array.prototype.sort +description: If comparefn is undefined, use SortCompare operator +---*/ + +var x = new SendableArray(2); +x[1] = 1; +x.sort(); +if (x.length !== 2) { + throw new Test262Error('#1: var x = new SendableArray(2); x[1] = 1; x.sort(); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 1) { + throw new Test262Error('#2: var x = new SendableArray(2); x[1] = 1; x.sort(); x[0] === 1. Actual: ' + (x[0])); +} +if (x[1] !== undefined) { + throw new Test262Error('#3: var x = new SendableArray(2); x[1] = 1; x.sort(); x[1] === undefined. Actual: ' + (x[1])); +} +var x = new SendableArray(2); +x[0] = 1; +x.sort(); +if (x.length !== 2) { + throw new Test262Error('#4: var x = new SendableArray(2); x[0] = 1; x.sort(); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 1) { + throw new Test262Error('#5: var x = new SendableArray(2); x[0] = 1; x.sort(); x[0] === 1. Actual: ' + (x[0])); +} +if (x[1] !== undefined) { + throw new Test262Error('#6: var x = new SendableArray(2); x[0] = 1; x.sort(); x[1] === undefined. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.2_T2.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.2_T2.js new file mode 100644 index 00000000000..6e6ad6181fb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.2_T2.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If this object does not have a property named by + ToString(j), return 1. If this object does not have a property + named by ToString(k), return -1 +esid: sec-array.prototype.sort +description: If comparefn is not undefined +---*/ + +var myComparefn = function(x, y) { + if (x === undefined) return -1; + if (y === undefined) return 1; + return 0; +} +var x = new SendableArray(2); +x[1] = 1; +x.sort(myComparefn); +if (x.length !== 2) { + throw new Test262Error('#1: var x = new SendableArray(2); x[1] = 1; x.sort(myComparefn); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 1) { + throw new Test262Error('#2: var x = new SendableArray(2); x[1] = 1; x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0])); +} +if (x[1] !== undefined) { + throw new Test262Error('#3: var x = new SendableArray(2); x[1] = 1; x.sort(myComparefn); x[1] === undefined. Actual: ' + (x[1])); +} +var x = new SendableArray(2); +x[0] = 1; +x.sort(myComparefn); +if (x.length !== 2) { + throw new Test262Error('#4: var x = new SendableArray(2); x[0] = 1; x.sort(myComparefn); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 1) { + throw new Test262Error('#5: var x = new SendableArray(2); x[0] = 1; x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0])); +} +if (x[1] !== undefined) { + throw new Test262Error('#6: var x = new SendableArray(2); x[0] = 1; x.sort(myComparefn); x[1] === undefined. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.3_T1.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.3_T1.js new file mode 100644 index 00000000000..89efebda88e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.3_T1.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If [[Get]] ToString(j) and [[Get]] ToString(k) + are both undefined, return +0 +esid: sec-array.prototype.sort +description: If comparefn is undefined, use SortCompare operator +---*/ + +var x = new SendableArray(undefined, undefined); +x.sort(); +if (x.length !== 2) { + throw new Test262Error('#1: var x = new SendableArray(undefined, undefined); x.sort(); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== undefined) { + throw new Test262Error('#2: var x = new SendableArray(undefined, undefined); x.sort(); x[0] === undefined. Actual: ' + (x[0])); +} +if (x[1] !== undefined) { + throw new Test262Error('#3: var x = new SendableArray(undefined, undefined); x.sort(); x[1] === undefined. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.4_T1.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.4_T1.js new file mode 100644 index 00000000000..0f3f6fd881e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.4_T1.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If [[Get]] ToString(j) is undefined, return 1. + If [[]Get] ToString(k) is undefined, return -1 +esid: sec-array.prototype.sort +description: If comparefn is undefined, use SortCompare operator +---*/ + +var x = new SendableArray(undefined, 1); +x.sort(); +if (x.length !== 2) { + throw new Test262Error('#1: var x = new SendableArray(undefined, 1); x.sort(); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 1) { + throw new Test262Error('#2: var x = new SendableArray(undefined, 1); x.sort(); x[0] === 1. Actual: ' + (x[0])); +} +if (x[1] !== undefined) { + throw new Test262Error('#3: var x = new SendableArray(undefined, 1); x.sort(); x[1] === undefined. Actual: ' + (x[1])); +} +var x = new SendableArray(1, undefined); +x.sort(); +if (x.length !== 2) { + throw new Test262Error('#4: var x = new SendableArray(1, undefined); x.sort(); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 1) { + throw new Test262Error('#5: var x = new SendableArray(1, undefined); x.sort(); x[0] === 1. Actual: ' + (x[0])); +} +if (x[1] !== undefined) { + throw new Test262Error('#6: var x = new SendableArray(1, undefined); x.sort(); x[1] === undefined. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.4_T2.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.4_T2.js new file mode 100644 index 00000000000..76ce26e5ab6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.4_T2.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If [[Get]] ToString(j) is undefined, return 1. + If [[]Get] ToString(k) is undefined, return -1 +esid: sec-array.prototype.sort +description: If comparefn is not undefined +---*/ + +var myComparefn = function(x, y) { + if (x === undefined) return -1; + if (y === undefined) return 1; + return 0; +} +var x = new SendableArray(undefined, 1); +x.sort(myComparefn); +if (x.length !== 2) { + throw new Test262Error('#1: var x = new SendableArray(undefined, 1); x.sort(myComparefn); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 1) { + throw new Test262Error('#2: var x = new SendableArray(undefined, 1); x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0])); +} +if (x[1] !== undefined) { + throw new Test262Error('#3: var x = new SendableArray(undefined, 1); x.sort(myComparefn); x[1] === undefined. Actual: ' + (x[1])); +} +var x = new SendableArray(1, undefined); +x.sort(myComparefn); +if (x.length !== 2) { + throw new Test262Error('#4: var x = new SendableArray(1, undefined); x.sort(myComparefn); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 1) { + throw new Test262Error('#5: var x = new SendableArray(1, undefined); x.sort(myComparefn); x[0] === 1. Actual: ' + (x[0])); +} +if (x[1] !== undefined) { + throw new Test262Error('#6: var x = new SendableArray(1, undefined); x.sort(myComparefn); x[1] === undefined. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.5_T1.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.5_T1.js new file mode 100644 index 00000000000..32e947131d7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A1.5_T1.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: If comparefn is undefined, use SortCompare operator +esid: sec-array.prototype.sort +description: Checking sort() and sort(undefined) +---*/ + +var x = new SendableArray(1, 0); +x.sort(); +if (x.length !== 2) { + throw new Test262Error('#1: var x = new SendableArray(1,0); x.sort(); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#2: var x = new SendableArray(1,0); x.sort(); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#3: var x = new SendableArray(1,0); x.sort(); x[1] === 1. Actual: ' + (x[1])); +} +var x = new SendableArray(1, 0); +x.sort(undefined); +if (x.length !== 2) { + throw new Test262Error('#4: var x = new SendableArray(1,0); x.sort(undefined); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#5: var x = new SendableArray(1,0); x.sort(undefined); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#6: var x = new SendableArray(1,0); x.sort(undefined); x[1] === 1. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.1_T1.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.1_T1.js new file mode 100644 index 00000000000..e311ddccd0f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.1_T1.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If ToString([[Get]] ToString(j)) < ToString([[Get]] ToString(k)), return -1. + If ToString([[Get]] ToString(j)) > ToString([[Get]] ToString(k)), return 1; + return -1 +esid: sec-array.prototype.sort +description: Checking ENGLISH ALPHABET +---*/ + +var alphabetR = ["z", "y", "x", "w", "v", "u", "t", "s", "r", "q", "p", "o", "n", "M", "L", "K", "J", "I", "H", "G", "F", "E", "D", "C", "B", "A"]; +var alphabet = ["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"]; +alphabetR.sort(); +var result = true; +for (var i = 0; i < 26; i++) { + if (alphabetR[i] !== alphabet[i]) result = false; +} +if (result !== true) { + throw new Test262Error('#1: CHECK ENGLISH ALPHABET'); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.1_T2.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.1_T2.js new file mode 100644 index 00000000000..b177730a00f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.1_T2.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If ToString([[Get]] ToString(j)) < ToString([[Get]] ToString(k)), return -1. + If ToString([[Get]] ToString(j)) > ToString([[Get]] ToString(k)), return 1; + return -1 +esid: sec-array.prototype.sort +description: Checking RUSSIAN ALPHABET +---*/ + +var alphabetR = ["ё", "я", "ю", "э", "ь", "ы", "ъ", "щ", "ш", "ч", "ц", "х", "ф", "у", "т", "с", "р", "П", "О", "Н", "М", "Л", "К", "Й", "И", "З", "Ж", "Е", "Д", "Г", "В", "Б", "А"]; +var alphabet = ["А", "Б", "В", "Г", "Д", "Е", "Ж", "З", "И", "Й", "К", "Л", "М", "Н", "О", "П", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", "ь", "э", "ю", "я", "ё"]; +alphabetR.sort(); +var result = true; +for (var i = 0; i < 26; i++) { + if (alphabetR[i] !== alphabet[i]) result = false; +} +if (result !== true) { + throw new Test262Error('#1: CHECK RUSSIAN ALPHABET'); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.1_T3.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.1_T3.js new file mode 100644 index 00000000000..7b3376ac501 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.1_T3.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If ToString([[Get]] ToString(j)) < ToString([[Get]] ToString(k)), return -1. + If ToString([[Get]] ToString(j)) > ToString([[Get]] ToString(k)), return 1; + return -1 +esid: sec-array.prototype.sort +description: Checking ToString operator +---*/ + +var obj = { + valueOf: function() { + return 1 + }, + toString: function() { + return -2 + } +}; +var alphabetR = [undefined, 2, 1, "X", -1, "a", true, obj, NaN, Infinity]; +var alphabet = [-1, obj, 1, 2, Infinity, NaN, "X", "a", true, undefined]; +alphabetR.sort(); +var result = true; +for (var i = 0; i < 10; i++) { + if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) { + if (alphabetR[i] !== alphabet[i]) result = false; + } +} +if (result !== true) { + throw new Test262Error('#1: Check ToString operator'); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.2_T1.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.2_T1.js new file mode 100644 index 00000000000..d84218fd947 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.2_T1.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: My comparefn is inverse implementation comparefn +esid: sec-array.prototype.sort +description: Checking ENGLISH ALPHABET +---*/ + +var alphabetR = ["z", "y", "x", "w", "v", "u", "t", "s", "r", "q", "p", "o", "n", "M", "L", "K", "J", "I", "H", "G", "F", "E", "D", "C", "B", "A"]; +var alphabet = ["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"]; +var myComparefn = function(x, y) { + var xS = String(x); + var yS = String(y); + if (xS < yS) return 1 + if (xS > yS) return -1; + return 0; +} +alphabet.sort(myComparefn); +var result = true; +for (var i = 0; i < 26; i++) { + if (alphabetR[i] !== alphabet[i]) result = false; +} +if (result !== true) { + throw new Test262Error('#1: CHECK ENGLISH ALPHABET'); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.2_T2.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.2_T2.js new file mode 100644 index 00000000000..1c26122b3ed --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.2_T2.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: My comparefn is inverse implementation comparefn +esid: sec-array.prototype.sort +description: Checking RUSSIAN ALPHABET +---*/ + +var alphabetR = ["ё", "я", "ю", "э", "ь", "ы", "ъ", "щ", "ш", "ч", "ц", "х", "ф", "у", "т", "с", "р", "П", "О", "Н", "М", "Л", "К", "Й", "И", "З", "Ж", "Е", "Д", "Г", "В", "Б", "А"]; +var alphabet = ["А", "Б", "В", "Г", "Д", "Е", "Ж", "З", "И", "Й", "К", "Л", "М", "Н", "О", "П", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", "ь", "э", "ю", "я", "ё"]; +var myComparefn = function(x, y) { + var xS = String(x); + var yS = String(y); + if (xS < yS) return 1 + if (xS > yS) return -1; + return 0; +} +alphabet.sort(myComparefn); +var result = true; +for (var i = 0; i < 26; i++) { + if (alphabetR[i] !== alphabet[i]) result = false; +} +if (result !== true) { + throw new Test262Error('#1: CHECK RUSSIAN ALPHABET'); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.2_T3.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.2_T3.js new file mode 100644 index 00000000000..60aedeebe12 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A2.2_T3.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: My comparefn is inverse implementation comparefn +esid: sec-array.prototype.sort +description: Checking ToString operator +---*/ + +var obj = { + valueOf: function() { + return 1 + }, + toString: function() { + return -2 + } +}; +var alphabetR = [undefined, 2, 1, "X", -1, "a", true, obj, NaN, Infinity]; +var alphabet = [true, "a", "X", NaN, Infinity, 2, 1, obj, -1, undefined]; +var myComparefn = function(x, y) { + var xS = String(x); + var yS = String(y); + if (xS < yS) return 1 + if (xS > yS) return -1; + return 0; +} +alphabetR.sort(myComparefn); +var result = true; +for (var i = 0; i < 10; i++) { + if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) { + if (alphabetR[i] !== alphabet[i]) result = false; + } +} +if (result !== true) { + throw new Test262Error('#1: Check ToString operator'); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A3_T1.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A3_T1.js new file mode 100644 index 00000000000..0ef14ac3044 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A3_T1.js @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The sort function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.sort +description: If comparefn is undefined, use SortCompare operator +---*/ + +var obj = { + valueOf: function() { + return 1 + }, + toString: function() { + return -2 + } +}; +var alphabetR = { + 0: undefined, + 1: 2, + 2: 1, + 3: "X", + 4: -1, + 5: "a", + 6: true, + 7: obj, + 8: NaN, + 9: Infinity +}; +alphabetR.sort = SendableArray.prototype.sort; +alphabetR.length = 10; +var alphabet = [-1, obj, 1, 2, Infinity, NaN, "X", "a", true, undefined]; +alphabetR.sort(); +alphabetR.getClass = Object.prototype.toString; +if (alphabetR.getClass() !== "[object " + "Object" + "]") { + throw new Test262Error('#0: alphabetR.sort() is Object object, not SendableArray object'); +} +var result = true; +for (var i = 0; i < 10; i++) { + if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) { + if (alphabetR[i] !== alphabet[i]) result = false; + } +} +if (result !== true) { + throw new Test262Error('#1: Check ToString operator'); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A3_T2.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A3_T2.js new file mode 100644 index 00000000000..b940487d447 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A3_T2.js @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The sort function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.sort +description: If comparefn is not undefined +---*/ + +var obj = { + valueOf: function() { + return 1 + }, + toString: function() { + return -2 + } +}; +var alphabetR = { + 0: undefined, + 1: 2, + 2: 1, + 3: "X", + 4: -1, + 5: "a", + 6: true, + 7: obj, + 8: NaN, + 9: Infinity +}; +alphabetR.sort = SendableArray.prototype.sort; +alphabetR.length = 10; +var alphabet = [true, "a", "X", NaN, Infinity, 2, 1, obj, -1, undefined]; +var myComparefn = function(x, y) { + var xS = String(x); + var yS = String(y); + if (xS < yS) return 1 + if (xS > yS) return -1; + return 0; +} +alphabetR.sort(myComparefn); +alphabetR.getClass = Object.prototype.toString; +if (alphabetR.getClass() !== "[object " + "Object" + "]") { + throw new Test262Error('#0: alphabetR.sort() is Object object, not SendableArray object'); +} +var result = true; +for (var i = 0; i < 10; i++) { + if (!(isNaN(alphabetR[i]) && isNaN(alphabet[i]))) { + if (alphabetR[i] !== alphabet[i]) result = false; + } +} +if (result !== true) { + throw new Test262Error('#1: Check ToString operator'); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A4_T3.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A4_T3.js new file mode 100644 index 00000000000..64b9e389a95 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A4_T3.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.sort +description: length = -4294967294 +---*/ + +var obj = {}; +obj.sort = SendableArray.prototype.sort; +obj[0] = "z"; +obj[1] = "y"; +obj[2] = "x"; +obj.length = -4294967294; +if (obj.sort() !== obj) { + throw new Test262Error('#1: var obj = {}; obj.sort = SendableArray.prototype.sort; obj[0] = "z"; obj[1] = "y"; obj[2] = "x"; obj.length = -4294967294; obj.sort() === obj. Actual: ' + (obj.sort())); +} +if (obj.length !== -4294967294) { + throw new Test262Error('#2: var obj = {}; obj.sort = SendableArray.prototype.sort; obj[0] = "z"; obj[1] = "y"; obj[2] = "x"; obj.length = -4294967294; obj.sort(); obj.length === -4294967294. Actual: ' + (obj.length)); +} +if (obj[0] !== "z") { + throw new Test262Error('#3: var obj = {}; obj.sort = SendableArray.prototype.sort; obj[0] = "z"; obj[1] = "y"; obj[2] = "x"; obj.length = -4294967294; obj.sort(); obj[0] === "z". Actual: ' + (obj[0])); +} +if (obj[1] !== "y") { + throw new Test262Error('#4: var obj = {}; obj.sort = SendableArray.prototype.sort; obj[0] = "z"; obj[1] = "y"; obj[2] = "x"; obj.length = -4294967294; obj.sort(); obj[1] === "y". Actual: ' + (obj[1])); +} +if (obj[2] !== "x") { + throw new Test262Error('#5: var obj = {}; obj.sort = SendableArray.prototype.sort; obj[0] = "z"; obj[1] = "y"; obj[2] = "x"; obj.length = -4294967294; obj.sort(); obj[2] === "x". Actual: ' + (obj[2])); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A5_T1.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A5_T1.js new file mode 100644 index 00000000000..25a0cea0854 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A5_T1.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Array.sort should not eat exceptions +esid: sec-array.prototype.sort +description: comparefn function throw "error" +---*/ + +assert.throws(Test262Error, () => { + var myComparefn = function(x, y) { + throw new Test262Error(); + } + var x = [1, 0]; + x.sort(myComparefn); +}); diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A6_T2.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A6_T2.js new file mode 100644 index 00000000000..8560449e6cb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A6_T2.js @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.sort +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +SendableArray.prototype[1] = -1; +var x = [1, 0]; +x.length = 2; +x.sort(); +if (x[0] !== 0) { + throw new Test262Error('#1: SendableArray.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#2: SendableArray.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x[1] === 1. Actual: ' + (x[1])); +} +x.length = 0; +if (x[0] !== undefined) { + throw new Test262Error('#3: SendableArray.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x.length = 0; x[0] === undefined. Actual: ' + (x[0])); +} +if (x[1] !== -1) { + throw new Test262Error('#4: SendableArray.prototype[1] = -1; x = [1,0]; x.length = 2; x.sort(); x.length = 0; x[1] === -1. Actual: ' + (x[1])); +} +Object.prototype[1] = -1; +Object.prototype.length = 2; +Object.prototype.sort = SendableArray.prototype.sort; +x = { + 0: 1, + 1: 0 +}; +x.sort(); +if (x[0] !== 0) { + throw new Test262Error('#5: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = SendableArray.prototype.sort; x = {0:1,1:0}; x.sort(); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#6: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = SendableArray.prototype.sort; x = {0:1,1:0}; x.sort(); x[1] === 1. Actual: ' + (x[1])); +} +delete x[0]; +delete x[1]; +if (x[0] !== undefined) { + throw new Test262Error('#7: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = SendableArray.prototype.sort; x = {0:1,1:0}; x.sort(); delete x[0]; delete x[1]; x[0] === undefined. Actual: ' + (x[0])); +} +if (x[1] !== -1) { + throw new Test262Error('#8: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.sort = SendableArray.prototype.sort; x = {0:1,1:0}; x.sort(); delete x[0]; delete x[1]; x[1] === -1. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A8.js b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A8.js new file mode 100644 index 00000000000..65153e55af7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/S15.4.4.11_A8.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Call the comparefn passing undefined as the this value (step 13b) +esid: sec-array.prototype.sort +description: comparefn tests that its this value is undefined +flags: [noStrict] +---*/ + +var global = this; +[2, 3].sort(function(x, y) { + "use strict"; + if (this === global) { + throw new Test262Error('#1: Sort leaks global'); + } + if (this !== undefined) { + throw new Test262Error('#2: Sort comparefn should be called with this===undefined. ' + + 'Actual: ' + this); + } + return x - y; +}); diff --git a/test/sendable/builtins/Array/prototype/sort/bug_596_1.js b/test/sendable/builtins/Array/prototype/sort/bug_596_1.js new file mode 100644 index 00000000000..1bebbba7bac --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/bug_596_1.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + The SortCompare abstract operation calls ToString() for identical + elements (step 14/15) +author: Thomas Dahlstrom (tdahlstrom@gmail.com) +---*/ + +var counter = 0; +var object = { + toString: function() { + counter++; + return ""; + } +}; +[object, object].sort(); +if (counter < 2) { + // sort calls ToString() for each element at least once + throw new Test262Error('#1: [object, object].sort(); counter < 2. Actual: ' + (counter)); +} diff --git a/test/sendable/builtins/Array/prototype/sort/bug_596_2.js b/test/sendable/builtins/Array/prototype/sort/bug_596_2.js new file mode 100644 index 00000000000..d32cc7b4545 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/bug_596_2.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Array.prototype.sort does not change non-existent elements to + undefined elements, that means holes are preserved (cf. spec text + about [[Delete]] and sparse arrays) +author: Thomas Dahlstrom (tdahlstrom@gmail.com) +---*/ + +var array = ['a', , void 0]; +//CHECK#1 +if (array.length !== 3) { + throw new Test262Error('#1: array.length !== 3. Actual: ' + (array.length)) +} +//CHECK#2 +if (array.hasOwnProperty('0') !== true) { + throw new Test262Error("#2: array.hasOwnProperty('0'). Actual: " + array.hasOwnProperty('0')); +} +//CHECK#3 +if (array.hasOwnProperty('1') !== false) { + throw new Test262Error("#3: array.hasOwnProperty('1'). Actual: " + array.hasOwnProperty('1')); +} +//CHECK#4 +if (array.hasOwnProperty('2') !== true) { + throw new Test262Error("#4: array.hasOwnProperty('2'). Actual: " + array.hasOwnProperty('2')); +} +array.sort(); +//CHECK#5 +if (array.length !== 3) { + throw new Test262Error('#5: array.length !== 3. Actual: ' + (array.length)) +} +//CHECK#6 +if (array.hasOwnProperty('0') !== true) { + throw new Test262Error("#6: array.hasOwnProperty('0'). Actual: " + array.hasOwnProperty('0')); +} +//CHECK#7 +if (array.hasOwnProperty('1') !== true) { + throw new Test262Error("#7: array.hasOwnProperty('1'). Actual: " + array.hasOwnProperty('1')); +} +//CHECK#8 +if (array.hasOwnProperty('2') !== false) { + throw new Test262Error("#8: array.hasOwnProperty('2'). Actual: " + array.hasOwnProperty('2')); +} diff --git a/test/sendable/builtins/Array/prototype/sort/call-with-primitive.js b/test/sendable/builtins/Array/prototype/sort/call-with-primitive.js new file mode 100644 index 00000000000..29dc70337a6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/call-with-primitive.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + This value is coerced to an object. +info: | + Array.prototype.sort ( comparefn ) + [...] + 2. Let obj be ? ToObject(this value). + [...] + 12. Return obj. +features: [Symbol, BigInt] +---*/ + +assert.throws(TypeError, function() { + [].sort.call(undefined); +}, "undefined"); + +assert.throws(TypeError, function() { + [].sort.call(null); +}, "null"); +assert([].sort.call(false) instanceof Boolean, "boolean"); +assert([].sort.call(0) instanceof Number, "number"); +assert([].sort.call("") instanceof String, "string"); +assert([].sort.call(Symbol()) instanceof Symbol, "symbol"); +assert([].sort.call(0n) instanceof BigInt, "bigint"); diff --git a/test/sendable/builtins/Array/prototype/sort/comparefn-grow.js b/test/sendable/builtins/Array/prototype/sort/comparefn-grow.js new file mode 100644 index 00000000000..8c1d1923e7e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/comparefn-grow.js @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Array.p.sort behaves correctly on TypedArrays backed by resizable buffers which + are grown by the comparison callback. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function ResizeAndCompare(rab, resizeTo) { + return (a, b) => { + rab.resize(resizeTo); + if (a < b) { + return -1; + } + if (a > b) { + return 1; + } + return 0; + } +} +function WriteUnsortedData(taFull) { + for (let i = 0; i < taFull.length; ++i) { + taFull[i] = MayNeedBigInt(taFull, 10 - i); + } +} +// Fixed length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const resizeTo = 6 * ctor.BYTES_PER_ELEMENT; + const fixedLength = new ctor(rab, 0, 4); + const taFull = new ctor(rab, 0); + WriteUnsortedData(taFull); + SendableArray.prototype.sort.call(fixedLength, ResizeAndCompare(rab, resizeTo)); + // Growing doesn't affect the sorting. + assert.compareArray(ToNumbers(taFull), [ + 7, + 8, + 9, + 10, + 0, + 0 + ]); +} +// Length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const resizeTo = 6 * ctor.BYTES_PER_ELEMENT; + const lengthTracking = new ctor(rab, 0); + const taFull = new ctor(rab, 0); + WriteUnsortedData(taFull); + SendableArray.prototype.sort.call(lengthTracking, ResizeAndCompare(rab, resizeTo)); + // Growing doesn't affect the sorting. Only the elements that were part of + // the original TA are sorted. + assert.compareArray(ToNumbers(taFull), [ + 7, + 8, + 9, + 10, + 0, + 0 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/sort/comparefn-nonfunction-call-throws.js b/test/sendable/builtins/Array/prototype/sort/comparefn-nonfunction-call-throws.js new file mode 100644 index 00000000000..9b300e8070b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/comparefn-nonfunction-call-throws.js @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: throws on a non-undefined non-function +info: | + 22.1.3.25 Array.prototype.sort ( comparefn ) + Upon entry, the following steps are performed to initialize evaluation + of the sort function: + 1. If _comparefn_ is not *undefined* and IsCallable(_comparefn_) is *false*, throw a *TypeError* exception. +features: [Symbol] +---*/ + +var sample = [1]; +var poisoned = { + get length() { + throw new Test262Error("IsCallable(comparefn) should be observed before this.length"); + } +}; +assert.throws(TypeError, function() { + sample.sort(null); +}, "sample.sort(null);"); +assert.throws(TypeError, function() { + [].sort.call(poisoned, null); +}, "[].sort.call(poisoned, null);"); +assert.throws(TypeError, function() { + sample.sort(true); +}, "sample.sort(true);"); +assert.throws(TypeError, function() { + [].sort.call(poisoned, true); +}, "[].sort.call(poisoned, true);"); +assert.throws(TypeError, function() { + sample.sort(false); +}, "sample.sort(false);"); +assert.throws(TypeError, function() { + [].sort.call(poisoned, false); +}, "[].sort.call(poisoned, false);"); +assert.throws(TypeError, function() { + sample.sort(''); +}, "sample.sort('');"); +assert.throws(TypeError, function() { + [].sort.call(poisoned, ''); +}, "[].sort.call(poisoned, '');"); +assert.throws(TypeError, function() { + sample.sort(/a/g); +}, "sample.sort(/a/g);"); +assert.throws(TypeError, function() { + [].sort.call(poisoned, /a/g); +}, "[].sort.call(poisoned, /a/g);"); +assert.throws(TypeError, function() { + sample.sort(42); +}, "sample.sort(42);"); +assert.throws(TypeError, function() { + [].sort.call(poisoned, 42); +}, "[].sort.call(poisoned, 42);"); +assert.throws(TypeError, function() { + sample.sort([]); +}, "sample.sort([]);"); +assert.throws(TypeError, function() { + [].sort.call(poisoned, []); +}, "[].sort.call(poisoned, []);"); +assert.throws(TypeError, function() { + sample.sort({}); +}, "sample.sort({});"); +assert.throws(TypeError, function() { + [].sort.call(poisoned, {}); +}, "[].sort.call(poisoned, {});"); +assert.throws(TypeError, function() { + sample.sort(Symbol()); +}, "sample.sort(Symbol());"); +assert.throws(TypeError, function() { + [].sort.call(poisoned, Symbol()); +}, "[].sort.call(poisoned, Symbol());"); diff --git a/test/sendable/builtins/Array/prototype/sort/comparefn-resizable-buffer.js b/test/sendable/builtins/Array/prototype/sort/comparefn-resizable-buffer.js new file mode 100644 index 00000000000..8ffdc5d917a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/comparefn-resizable-buffer.js @@ -0,0 +1,191 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Array.p.sort behaves correctly on TypedArrays backed by resizable buffers and + is passed a user-provided comparison callback. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const taFull = new ctor(rab, 0); + function WriteUnsortedData() { + // Write some data into the array. + for (let i = 0; i < taFull.length; ++i) { + taFull[i] = MayNeedBigInt(taFull, 10 - i); + } + } + function OddBeforeEvenComparison(a, b) { + // Sort all odd numbers before even numbers. + a = Number(a); + b = Number(b); + if (a % 2 == 1 && b % 2 == 0) { + return -1; + } + if (a % 2 == 0 && b % 2 == 1) { + return 1; + } + if (a < b) { + return -1; + } + if (a > b) { + return 1; + } + return 0; + } + // Orig. array: [10, 9, 8, 7] + // [10, 9, 8, 7] << fixedLength + // [8, 7] << fixedLengthWithOffset + // [10, 9, 8, 7, ...] << lengthTracking + // [8, 7, ...] << lengthTrackingWithOffset + WriteUnsortedData(); + SendableArray.prototype.sort.call(fixedLength, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 7, + 9, + 8, + 10 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(fixedLengthWithOffset, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 10, + 9, + 7, + 8 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(lengthTracking, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 7, + 9, + 8, + 10 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(lengthTrackingWithOffset, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 10, + 9, + 7, + 8 + ]); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + // Orig. array: [10, 9, 8] + // [10, 9, 8, ...] << lengthTracking + // [8, ...] << lengthTrackingWithOffset + + WriteUnsortedData(); + SendableArray.prototype.sort.call(fixedLength, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 10, + 9, + 8 + ]); + SendableArray.prototype.sort.call(fixedLengthWithOffset, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 10, + 9, + 8 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(lengthTracking, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 9, + 8, + 10 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(lengthTrackingWithOffset, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 10, + 9, + 8 + ]); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + WriteUnsortedData(); + SendableArray.prototype.sort.call(fixedLength, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [10]); + SendableArray.prototype.sort.call(fixedLengthWithOffset, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [10]); + SendableArray.prototype.sort.call(lengthTrackingWithOffset, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [10]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(lengthTracking, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [10]); + // Shrink to zero. + rab.resize(0); + SendableArray.prototype.sort.call(fixedLength, OddBeforeEvenComparison); + SendableArray.prototype.sort.call(fixedLengthWithOffset, OddBeforeEvenComparison); + SendableArray.prototype.sort.call(lengthTrackingWithOffset, OddBeforeEvenComparison); + SendableArray.prototype.sort.call(lengthTracking, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), []); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + // Orig. array: [10, 9, 8, 7, 6, 5] + // [10, 9, 8, 7] << fixedLength + // [8, 7] << fixedLengthWithOffset + // [10, 9, 8, 7, 6, 5, ...] << lengthTracking + // [8, 7, 6, 5, ...] << lengthTrackingWithOffset + WriteUnsortedData(); + SendableArray.prototype.sort.call(fixedLength, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 7, + 9, + 8, + 10, + 6, + 5 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(fixedLengthWithOffset, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 10, + 9, + 7, + 8, + 6, + 5 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(lengthTracking, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 5, + 7, + 9, + 6, + 8, + 10 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(lengthTrackingWithOffset, OddBeforeEvenComparison); + assert.compareArray(ToNumbers(taFull), [ + 10, + 9, + 5, + 7, + 6, + 8 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/sort/comparefn-shrink.js b/test/sendable/builtins/Array/prototype/sort/comparefn-shrink.js new file mode 100644 index 00000000000..24368f82513 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/comparefn-shrink.js @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Array.p.sort behaves correctly on TypedArrays backed by resizable buffers and + is shrunk by the comparison callback. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer, Array.prototype.includes] +---*/ + +function ResizeAndCompare(rab, resizeTo) { + return (a, b) => { + rab.resize(resizeTo); + if (a < b) { + return -1; + } + if (a > b) { + return 1; + } + return 0; + } +} +function WriteUnsortedData(taFull) { + for (let i = 0; i < taFull.length; ++i) { + taFull[i] = MayNeedBigInt(taFull, 10 - i); + } +} +// Fixed length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const resizeTo = 2 * ctor.BYTES_PER_ELEMENT; + const fixedLength = new ctor(rab, 0, 4); + const taFull = new ctor(rab, 0); + WriteUnsortedData(taFull); + SendableArray.prototype.sort.call(fixedLength, ResizeAndCompare(rab, resizeTo)); + // The data is unchanged. + assert.compareArray(ToNumbers(taFull), [ + 10, + 9 + ]); +} +// Length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const resizeTo = 2 * ctor.BYTES_PER_ELEMENT; + const lengthTracking = new ctor(rab, 0); + const taFull = new ctor(rab, 0); + WriteUnsortedData(taFull); + SendableArray.prototype.sort.call(lengthTracking, ResizeAndCompare(rab, resizeTo)); + // The sort result is implementation defined, but it contains 2 elements out + // of the 4 original ones. + const newData = ToNumbers(taFull); + assert.sameValue(newData.length, 2); + assert([ + 10, + 9, + 8, + 7 + ].includes(newData[0])); + assert([ + 10, + 9, + 8, + 7 + ].includes(newData[1])); +} diff --git a/test/sendable/builtins/Array/prototype/sort/length.js b/test/sendable/builtins/Array/prototype/sort/length.js new file mode 100644 index 00000000000..ffd4dcd019a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/length.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + The "length" property of Array.prototype.sort +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.sort, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/sort/name.js b/test/sendable/builtins/Array/prototype/sort/name.js new file mode 100644 index 00000000000..4e2f3d7bdb8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Array.prototype.sort.name is "sort". +info: | + Array.prototype.sort (comparefn) + 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(SendableArray.prototype.sort, "name", { + value: "sort", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/sort/not-a-constructor.js b/test/sendable/builtins/Array/prototype/sort/not-a-constructor.js new file mode 100644 index 00000000000..60f52552937 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/not-a-constructor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.sort 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(SendableArray.prototype.sort), false, 'isConstructor(SendableArray.prototype.sort) must return false'); +assert.throws(TypeError, () => { + new SendableArray.prototype.sort(); +}); + diff --git a/test/sendable/builtins/Array/prototype/sort/precise-comparefn-throws.js b/test/sendable/builtins/Array/prototype/sort/precise-comparefn-throws.js new file mode 100644 index 00000000000..33f47a2df5d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-comparefn-throws.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const logs = []; +Object.defineProperty(Object.prototype, '2', { + get() { + logs.push('get'); + return 4; + }, + set(v) { + logs.push(`set with ${v}`); + } +}); +const array = [undefined, 3, /*hole*/, 2, undefined, /*hole*/, 1]; +let count = 0; +try { + array.sort((a, b) => { + if (++count === 3) { + throw new Error('lolwat'); + } + return b - a; + }); +} catch (exception) { + logs.push(exception.message); +} +assert.sameValue(logs[0], 'get'); +assert.sameValue(logs[1], 'lolwat'); +assert.sameValue(logs.length, 2); +assert.sameValue(array[0], undefined); +assert.sameValue(array[1], 3); +assert.sameValue('2' in array, true); +assert.sameValue(array.hasOwnProperty('2'), false); +assert.sameValue(array[3], 2); +assert.sameValue(array[4], undefined); +assert.sameValue('5' in array, false); +assert.sameValue(array.hasOwnProperty('5'), false); +assert.sameValue(array[6], 1); +assert.sameValue(array.length, 7); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-getter-appends-elements.js b/test/sendable/builtins/Array/prototype/sort/precise-getter-appends-elements.js new file mode 100644 index 00000000000..e5d935a0bd0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-getter-appends-elements.js @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + array.push('foo'); + array.push('bar'); + return this.foo; + }, + set(v) { + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue('2' in array, true); +assert.sameValue(array.hasOwnProperty('2'), true); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array[8], 'foo'); +assert.sameValue(array[9], 'bar'); +assert.sameValue(array.length, 10); +assert.sameValue(array.foo, 'c'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[10], 'foo'); +assert.sameValue(array[11], 'bar'); +assert.sameValue(array.length, 12); +assert.sameValue(array.foo, 'c'); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-getter-decreases-length.js b/test/sendable/builtins/Array/prototype/sort/precise-getter-decreases-length.js new file mode 100644 index 00000000000..5de39d66ae2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-getter-decreases-length.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + array.length = array.length - 2; + return this.foo; + }, + set(v) { + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'b'); +assert.sameValue(array[1], 'c'); +assert.sameValue(array[3], undefined); +assert.sameValue(array[4], undefined); +assert.sameValue('5' in array, false); +assert.sameValue(array.hasOwnProperty('5'), false); +assert.sameValue(array.length, 6); +assert.sameValue(array.foo, undefined); +assert.sameValue(array[2], undefined); +assert.sameValue(array.length, 4); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-getter-deletes-predecessor.js b/test/sendable/builtins/Array/prototype/sort/precise-getter-deletes-predecessor.js new file mode 100644 index 00000000000..4b7e476a569 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-getter-deletes-predecessor.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + delete array[1]; + return this.foo; + }, + set(v) { + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'c'); +assert.sameValue(array[2], 'c'); +assert.sameValue('1' in array, false); +assert.sameValue(array.hasOwnProperty(1), false); +assert.sameValue(array.length, 8); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-getter-deletes-successor.js b/test/sendable/builtins/Array/prototype/sort/precise-getter-deletes-successor.js new file mode 100644 index 00000000000..a81fd7534f6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-getter-deletes-successor.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + delete array[3]; + return this.foo; + }, + set(v) { + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'c'); +assert.sameValue(array[3], undefined); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue('6' in array, false); +assert.sameValue(array.hasOwnProperty('6'), false); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'd'); +assert.sameValue(array[2], 'd'); +assert.sameValue('3' in array, false); +assert.sameValue(array.hasOwnProperty(3), false); +assert.sameValue(array.length, 8); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-getter-increases-length.js b/test/sendable/builtins/Array/prototype/sort/precise-getter-increases-length.js new file mode 100644 index 00000000000..7b8242652f9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-getter-increases-length.js @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + array.length = array.length + 2; + return this.foo; + }, + set(v) { + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue('8' in array, false); +assert.sameValue(array.hasOwnProperty('8'), false); +assert.sameValue('9' in array, false); +assert.sameValue(array.hasOwnProperty('9'), false); +assert.sameValue(array.length, 10); +assert.sameValue(array.foo, 'c'); +assert.sameValue(array[2], 'c'); +assert.sameValue('10' in array, false); +assert.sameValue(array.hasOwnProperty('10'), false); +assert.sameValue('11' in array, false); +assert.sameValue(array.hasOwnProperty('11'), false); +assert.sameValue(array.length, 12); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-getter-pops-elements.js b/test/sendable/builtins/Array/prototype/sort/precise-getter-pops-elements.js new file mode 100644 index 00000000000..12dbe59d887 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-getter-pops-elements.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + array.pop(); + array.pop(); + return this.foo; + }, + set(v) { + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'b'); +assert.sameValue(array[1], 'c'); +assert.sameValue(array[3], undefined); +assert.sameValue(array[4], undefined); +assert.sameValue('5' in array, false); +assert.sameValue(array.hasOwnProperty('5'), false); +assert.sameValue(array.length, 6); +assert.sameValue(array.foo, undefined); +assert.sameValue(array[2], undefined); +assert.sameValue(array.length, 4); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-getter-sets-predecessor.js b/test/sendable/builtins/Array/prototype/sort/precise-getter-sets-predecessor.js new file mode 100644 index 00000000000..05324675410 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-getter-sets-predecessor.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + array[1] = 'foobar'; + return this.foo; + }, + set(v) { + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'c'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[1], 'foobar'); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-getter-sets-successor.js b/test/sendable/builtins/Array/prototype/sort/precise-getter-sets-successor.js new file mode 100644 index 00000000000..cd10de25063 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-getter-sets-successor.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + array[3] = 'foobar'; + return this.foo; + }, + set(v) { + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'c'); +assert.sameValue(array[3], 'foobar'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'd'); +assert.sameValue(array[2], 'd'); +assert.sameValue(array[3], 'foobar'); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-prototype-accessors.js b/test/sendable/builtins/Array/prototype/sort/precise-prototype-accessors.js new file mode 100644 index 00000000000..0ffcf6d93de --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-prototype-accessors.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const logs = []; +Object.defineProperty(Object.prototype, '2', { + get() { + logs.push('get'); + return 4; + }, + set(v) { + logs.push(`set with ${v}`); + } +}); +const array = [undefined, 3, /*hole*/, 2, undefined, /*hole*/, 1]; +array.sort(); +assert.sameValue(logs[0], 'get'); +assert.sameValue(logs[1], 'set with 3'); +assert.sameValue(logs.length, 2); +assert.sameValue(array[0], 1); +assert.sameValue(array[1], 2); +assert.sameValue('2' in array, true); +assert.sameValue(array.hasOwnProperty('2'), false); +assert.sameValue(array[3], 4); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue('6' in array, false); +assert.sameValue(array.hasOwnProperty('6'), false); +assert.sameValue(array.length, 7); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-prototype-element.js b/test/sendable/builtins/Array/prototype/sort/precise-prototype-element.js new file mode 100644 index 00000000000..7e1189131c5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-prototype-element.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +Object.prototype[2] = 4; +const array = [undefined, 3, /*hole*/, 2, undefined, /*hole*/, 1]; +array.sort(); +assert.sameValue(array[0], 1); +assert.sameValue(array[1], 2); +assert.sameValue(array[2], 3); +assert.sameValue(array[3], 4); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue('6' in array, false); +assert.sameValue(array.hasOwnProperty('6'), false); +assert.sameValue(array.length, 7); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-setter-appends-elements.js b/test/sendable/builtins/Array/prototype/sort/precise-setter-appends-elements.js new file mode 100644 index 00000000000..7736a9689b2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-setter-appends-elements.js @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + array.push('foo'); + array.push('bar'); + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array[8], 'foo'); +assert.sameValue(array[9], 'bar'); +assert.sameValue(array.length, 10); +assert.sameValue(array.foo, 'c'); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-setter-decreases-length.js b/test/sendable/builtins/Array/prototype/sort/precise-setter-decreases-length.js new file mode 100644 index 00000000000..2a3572e49d5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-setter-decreases-length.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + array.length = array.length - 2; + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue(array.length, 7); +assert.sameValue(array.foo, 'c'); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-setter-deletes-predecessor.js b/test/sendable/builtins/Array/prototype/sort/precise-setter-deletes-predecessor.js new file mode 100644 index 00000000000..5b30081948b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-setter-deletes-predecessor.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + delete array[1]; + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'a'); +assert.sameValue('1' in array, false); +assert.sameValue(array.hasOwnProperty(1), false); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'c'); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-setter-deletes-successor.js b/test/sendable/builtins/Array/prototype/sort/precise-setter-deletes-successor.js new file mode 100644 index 00000000000..699e19b7757 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-setter-deletes-successor.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + delete array[3]; + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'c'); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-setter-increases-length.js b/test/sendable/builtins/Array/prototype/sort/precise-setter-increases-length.js new file mode 100644 index 00000000000..e2b3afbce8b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-setter-increases-length.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + array.length = array.length + 2; + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue('8' in array, false); +assert.sameValue(array.hasOwnProperty('8'), false); +assert.sameValue('9' in array, false); +assert.sameValue(array.hasOwnProperty('9'), false); +assert.sameValue(array.length, 10); +assert.sameValue(array.foo, 'c'); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-setter-pops-elements.js b/test/sendable/builtins/Array/prototype/sort/precise-setter-pops-elements.js new file mode 100644 index 00000000000..8873acb44d6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-setter-pops-elements.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + array.pop(); + array.pop(); + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue(array.length, 7); +assert.sameValue(array.foo, 'c'); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-setter-sets-predecessor.js b/test/sendable/builtins/Array/prototype/sort/precise-setter-sets-predecessor.js new file mode 100644 index 00000000000..86b028eb8a6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-setter-sets-predecessor.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + array[1] = 'foobar'; + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'foobar'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'c'); diff --git a/test/sendable/builtins/Array/prototype/sort/precise-setter-sets-successor.js b/test/sendable/builtins/Array/prototype/sort/precise-setter-sets-successor.js new file mode 100644 index 00000000000..c92efc35463 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/precise-setter-sets-successor.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Previously implementation-defined aspects of Array.prototype.sort. +info: | + Historically, many aspects of Array.prototype.sort remained + implementation-defined. https://github.com/tc39/ecma262/pull/1585 + described some behaviors more precisely, reducing the amount of cases + that result in an implementation-defined sort order. +---*/ + +const array = [undefined, 'c', /*hole*/, 'b', undefined, /*hole*/, 'a', 'd']; +Object.defineProperty(array, '2', { + get() { + return this.foo; + }, + set(v) { + array[3] = 'foobar'; + this.foo = v; + } +}); +array.sort(); +assert.sameValue(array[0], 'a'); +assert.sameValue(array[1], 'b'); +assert.sameValue(array[2], 'c'); +assert.sameValue(array[3], 'd'); +assert.sameValue(array[4], undefined); +assert.sameValue(array[5], undefined); +assert.sameValue(array[6], undefined); +assert.sameValue('7' in array, false); +assert.sameValue(array.hasOwnProperty('7'), false); +assert.sameValue(array.length, 8); +assert.sameValue(array.foo, 'c'); diff --git a/test/sendable/builtins/Array/prototype/sort/prop-desc.js b/test/sendable/builtins/Array/prototype/sort/prop-desc.js new file mode 100644 index 00000000000..4679f1a4547 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/prop-desc.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + "sort" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.sort, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "sort", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/sort/resizable-buffer-default-comparator.js b/test/sendable/builtins/Array/prototype/sort/resizable-buffer-default-comparator.js new file mode 100644 index 00000000000..33a211c6b04 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/resizable-buffer-default-comparator.js @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Array.p.sort behaves correctly on TypedArrays backed by resizable buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +// The default comparison function for Array.prototype.sort is the string sort. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const taFull = new ctor(rab, 0); + function WriteUnsortedData() { + // Write some data into the array. + for (let i = 0; i < taFull.length; ++i) { + taFull[i] = MayNeedBigInt(taFull, 10 - 2 * i); + } + } + // Orig. array: [10, 8, 6, 4] + // [10, 8, 6, 4] << fixedLength + // [6, 4] << fixedLengthWithOffset + // [10, 8, 6, 4, ...] << lengthTracking + // [6, 4, ...] << lengthTrackingWithOffset + WriteUnsortedData(); + SendableArray.prototype.sort.call(fixedLength); + assert.compareArray(ToNumbers(taFull), [ + 10, + 4, + 6, + 8 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(fixedLengthWithOffset); + assert.compareArray(ToNumbers(taFull), [ + 10, + 8, + 4, + 6 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(lengthTracking); + assert.compareArray(ToNumbers(taFull), [ + 10, + 4, + 6, + 8 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(lengthTrackingWithOffset); + assert.compareArray(ToNumbers(taFull), [ + 10, + 8, + 4, + 6 + ]); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + // Orig. array: [10, 8, 6] + // [10, 8, 6, ...] << lengthTracking + // [6, ...] << lengthTrackingWithOffset + WriteUnsortedData(); + SendableArray.prototype.sort.call(fixedLength); // OOB -> NOOP + assert.compareArray(ToNumbers(taFull), [ + 10, + 8, + 6 + ]); + SendableArray.prototype.sort.call(fixedLengthWithOffset); // OOB -> NOOP + assert.compareArray(ToNumbers(taFull), [ + 10, + 8, + 6 + ]); + SendableArray.prototype.sort.call(lengthTracking); + assert.compareArray(ToNumbers(taFull), [ + 10, + 6, + 8 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(lengthTrackingWithOffset); + assert.compareArray(ToNumbers(taFull), [ + 10, + 8, + 6 + ]); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + WriteUnsortedData(); + SendableArray.prototype.sort.call(fixedLength); // OOB -> NOOP + assert.compareArray(ToNumbers(taFull), [10]); + SendableArray.prototype.sort.call(fixedLengthWithOffset); // OOB -> NOOP + assert.compareArray(ToNumbers(taFull), [10]); + SendableArray.prototype.sort.call(lengthTrackingWithOffset); // OOB -> NOOP + assert.compareArray(ToNumbers(taFull), [10]); + SendableArray.prototype.sort.call(lengthTracking); + assert.compareArray(ToNumbers(taFull), [10]); + + // Shrink to zero. + rab.resize(0); + SendableArray.prototype.sort.call(fixedLength); // OOB -> NOOP + assert.compareArray(ToNumbers(taFull), []); + SendableArray.prototype.sort.call(fixedLengthWithOffset); // OOB -> NOOP + assert.compareArray(ToNumbers(taFull), []); + SendableArray.prototype.sort.call(lengthTrackingWithOffset); // OOB -> NOOP + assert.compareArray(ToNumbers(taFull), []); + SendableArray.prototype.sort.call(lengthTracking); + assert.compareArray(ToNumbers(taFull), []); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + // Orig. array: [10, 8, 6, 4, 2, 0] + // [10, 8, 6, 4] << fixedLength + // [6, 4] << fixedLengthWithOffset + // [10, 8, 6, 4, 2, 0, ...] << lengthTracking + // [6, 4, 2, 0, ...] << lengthTrackingWithOffset + WriteUnsortedData(); + SendableArray.prototype.sort.call(fixedLength); + assert.compareArray(ToNumbers(taFull), [ + 10, + 4, + 6, + 8, + 2, + 0 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(fixedLengthWithOffset); + assert.compareArray(ToNumbers(taFull), [ + 10, + 8, + 4, + 6, + 2, + 0 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(lengthTracking); + assert.compareArray(ToNumbers(taFull), [ + 0, + 10, + 2, + 4, + 6, + 8 + ]); + WriteUnsortedData(); + SendableArray.prototype.sort.call(lengthTrackingWithOffset); + assert.compareArray(ToNumbers(taFull), [ + 10, + 8, + 0, + 2, + 4, + 6 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/sort/stability-11-elements.js b/test/sendable/builtins/Array/prototype/sort/stability-11-elements.js new file mode 100644 index 00000000000..1c7d8ac9f71 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/stability-11-elements.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Stability of Array.prototype.sort for an array with 11 elements. +info: | + The sort is required to be stable (that is, elements that compare equal + remain in their original order). + The array length of 11 was chosen because V8 used an unstable + QuickSort for arrays with more than 10 elements until v7.0 (September + 2018). https://v8.dev/blog/array-sort +---*/ + +const array = new SendableArray[ + { name: 'A', rating: 2 }, + { name: 'B', rating: 3 }, + { name: 'C', rating: 2 }, + { name: 'D', rating: 4 }, + { name: 'E', rating: 3 }, + { name: 'F', rating: 3 }, + { name: 'G', rating: 4 }, + { name: 'H', rating: 3 }, + { name: 'I', rating: 2 }, + { name: 'J', rating: 2 }, + { name: 'K', rating: 2 }, +]; +assert.sameValue(array.length, 11); +// Sort the elements by `rating` in descending order. +// (This updates `array` in place.) +array.sort((a, b) => b.rating - a.rating); +const reduced = array.reduce((acc, element) => acc + element.name, ''); +assert.sameValue(reduced, 'DGBEFHACIJK'); diff --git a/test/sendable/builtins/Array/prototype/sort/stability-2048-elements.js b/test/sendable/builtins/Array/prototype/sort/stability-2048-elements.js new file mode 100644 index 00000000000..851760ab283 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/stability-2048-elements.js @@ -0,0 +1,2090 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Stability of Array.prototype.sort for an array with 2048 elements. +info: | + The sort is required to be stable (that is, elements that compare equal + remain in their original order). + The array length of 2048 was chosen because as of late 2018, Chakra + uses merge sort for arrays with 2048 or more elements. It uses + insertion sort for smaller arrays. + https://github.com/Microsoft/ChakraCore/pull/5724/files#diff-85203ec16f5961eb4c18e4253bb42140R337 +---*/ + +const array = new SendableArray[ + { name: 'A000', rating: 2 }, + { name: 'A001', rating: 2 }, + { name: 'A002', rating: 2 }, + { name: 'A003', rating: 2 }, + { name: 'A004', rating: 2 }, + { name: 'A005', rating: 2 }, + { name: 'A006', rating: 2 }, + { name: 'A007', rating: 2 }, + { name: 'A008', rating: 2 }, + { name: 'A009', rating: 2 }, + { name: 'A010', rating: 2 }, + { name: 'A011', rating: 2 }, + { name: 'A012', rating: 2 }, + { name: 'A013', rating: 2 }, + { name: 'A014', rating: 2 }, + { name: 'A015', rating: 2 }, + { name: 'A016', rating: 2 }, + { name: 'A017', rating: 2 }, + { name: 'A018', rating: 2 }, + { name: 'A019', rating: 2 }, + { name: 'A020', rating: 2 }, + { name: 'A021', rating: 2 }, + { name: 'A022', rating: 2 }, + { name: 'A023', rating: 2 }, + { name: 'A024', rating: 2 }, + { name: 'A025', rating: 2 }, + { name: 'A026', rating: 2 }, + { name: 'A027', rating: 2 }, + { name: 'A028', rating: 2 }, + { name: 'A029', rating: 2 }, + { name: 'A030', rating: 2 }, + { name: 'A031', rating: 2 }, + { name: 'A032', rating: 2 }, + { name: 'A033', rating: 2 }, + { name: 'A034', rating: 2 }, + { name: 'A035', rating: 2 }, + { name: 'A036', rating: 2 }, + { name: 'A037', rating: 2 }, + { name: 'A038', rating: 2 }, + { name: 'A039', rating: 2 }, + { name: 'A040', rating: 2 }, + { name: 'A041', rating: 2 }, + { name: 'A042', rating: 2 }, + { name: 'A043', rating: 2 }, + { name: 'A044', rating: 2 }, + { name: 'A045', rating: 2 }, + { name: 'A046', rating: 2 }, + { name: 'A047', rating: 2 }, + { name: 'A048', rating: 2 }, + { name: 'A049', rating: 2 }, + { name: 'A050', rating: 2 }, + { name: 'A051', rating: 2 }, + { name: 'A052', rating: 2 }, + { name: 'A053', rating: 2 }, + { name: 'A054', rating: 2 }, + { name: 'A055', rating: 2 }, + { name: 'A056', rating: 2 }, + { name: 'A057', rating: 2 }, + { name: 'A058', rating: 2 }, + { name: 'A059', rating: 2 }, + { name: 'A060', rating: 2 }, + { name: 'A061', rating: 2 }, + { name: 'A062', rating: 2 }, + { name: 'A063', rating: 2 }, + { name: 'A064', rating: 2 }, + { name: 'A065', rating: 2 }, + { name: 'A066', rating: 2 }, + { name: 'A067', rating: 2 }, + { name: 'A068', rating: 2 }, + { name: 'A069', rating: 2 }, + { name: 'A070', rating: 2 }, + { name: 'A071', rating: 2 }, + { name: 'A072', rating: 2 }, + { name: 'A073', rating: 2 }, + { name: 'A074', rating: 2 }, + { name: 'A075', rating: 2 }, + { name: 'A076', rating: 2 }, + { name: 'A077', rating: 2 }, + { name: 'A078', rating: 2 }, + { name: 'A079', rating: 2 }, + { name: 'A080', rating: 2 }, + { name: 'A081', rating: 2 }, + { name: 'A082', rating: 2 }, + { name: 'A083', rating: 2 }, + { name: 'A084', rating: 2 }, + { name: 'A085', rating: 2 }, + { name: 'A086', rating: 2 }, + { name: 'A087', rating: 2 }, + { name: 'A088', rating: 2 }, + { name: 'A089', rating: 2 }, + { name: 'A090', rating: 2 }, + { name: 'A091', rating: 2 }, + { name: 'A092', rating: 2 }, + { name: 'A093', rating: 2 }, + { name: 'A094', rating: 2 }, + { name: 'A095', rating: 2 }, + { name: 'A096', rating: 2 }, + { name: 'A097', rating: 2 }, + { name: 'A098', rating: 2 }, + { name: 'A099', rating: 2 }, + { name: 'A100', rating: 2 }, + { name: 'A101', rating: 2 }, + { name: 'A102', rating: 2 }, + { name: 'A103', rating: 2 }, + { name: 'A104', rating: 2 }, + { name: 'A105', rating: 2 }, + { name: 'A106', rating: 2 }, + { name: 'A107', rating: 2 }, + { name: 'A108', rating: 2 }, + { name: 'A109', rating: 2 }, + { name: 'A110', rating: 2 }, + { name: 'A111', rating: 2 }, + { name: 'A112', rating: 2 }, + { name: 'A113', rating: 2 }, + { name: 'A114', rating: 2 }, + { name: 'A115', rating: 2 }, + { name: 'A116', rating: 2 }, + { name: 'A117', rating: 2 }, + { name: 'A118', rating: 2 }, + { name: 'A119', rating: 2 }, + { name: 'A120', rating: 2 }, + { name: 'A121', rating: 2 }, + { name: 'A122', rating: 2 }, + { name: 'A123', rating: 2 }, + { name: 'A124', rating: 2 }, + { name: 'A125', rating: 2 }, + { name: 'A126', rating: 2 }, + { name: 'A127', rating: 2 }, + { name: 'A128', rating: 2 }, + { name: 'A129', rating: 2 }, + { name: 'A130', rating: 2 }, + { name: 'A131', rating: 2 }, + { name: 'A132', rating: 2 }, + { name: 'A133', rating: 2 }, + { name: 'A134', rating: 2 }, + { name: 'A135', rating: 2 }, + { name: 'A136', rating: 2 }, + { name: 'A137', rating: 2 }, + { name: 'A138', rating: 2 }, + { name: 'A139', rating: 2 }, + { name: 'A140', rating: 2 }, + { name: 'A141', rating: 2 }, + { name: 'A142', rating: 2 }, + { name: 'A143', rating: 2 }, + { name: 'A144', rating: 2 }, + { name: 'A145', rating: 2 }, + { name: 'A146', rating: 2 }, + { name: 'A147', rating: 2 }, + { name: 'A148', rating: 2 }, + { name: 'A149', rating: 2 }, + { name: 'A150', rating: 2 }, + { name: 'A151', rating: 2 }, + { name: 'A152', rating: 2 }, + { name: 'A153', rating: 2 }, + { name: 'A154', rating: 2 }, + { name: 'A155', rating: 2 }, + { name: 'A156', rating: 2 }, + { name: 'A157', rating: 2 }, + { name: 'A158', rating: 2 }, + { name: 'A159', rating: 2 }, + { name: 'A160', rating: 2 }, + { name: 'A161', rating: 2 }, + { name: 'A162', rating: 2 }, + { name: 'A163', rating: 2 }, + { name: 'A164', rating: 2 }, + { name: 'A165', rating: 2 }, + { name: 'A166', rating: 2 }, + { name: 'A167', rating: 2 }, + { name: 'A168', rating: 2 }, + { name: 'A169', rating: 2 }, + { name: 'A170', rating: 2 }, + { name: 'A171', rating: 2 }, + { name: 'A172', rating: 2 }, + { name: 'A173', rating: 2 }, + { name: 'A174', rating: 2 }, + { name: 'A175', rating: 2 }, + { name: 'A176', rating: 2 }, + { name: 'A177', rating: 2 }, + { name: 'A178', rating: 2 }, + { name: 'A179', rating: 2 }, + { name: 'A180', rating: 2 }, + { name: 'A181', rating: 2 }, + { name: 'A182', rating: 2 }, + { name: 'A183', rating: 2 }, + { name: 'A184', rating: 2 }, + { name: 'A185', rating: 2 }, + { name: 'A186', rating: 2 }, + { name: 'B000', rating: 3 }, + { name: 'B001', rating: 3 }, + { name: 'B002', rating: 3 }, + { name: 'B003', rating: 3 }, + { name: 'B004', rating: 3 }, + { name: 'B005', rating: 3 }, + { name: 'B006', rating: 3 }, + { name: 'B007', rating: 3 }, + { name: 'B008', rating: 3 }, + { name: 'B009', rating: 3 }, + { name: 'B010', rating: 3 }, + { name: 'B011', rating: 3 }, + { name: 'B012', rating: 3 }, + { name: 'B013', rating: 3 }, + { name: 'B014', rating: 3 }, + { name: 'B015', rating: 3 }, + { name: 'B016', rating: 3 }, + { name: 'B017', rating: 3 }, + { name: 'B018', rating: 3 }, + { name: 'B019', rating: 3 }, + { name: 'B020', rating: 3 }, + { name: 'B021', rating: 3 }, + { name: 'B022', rating: 3 }, + { name: 'B023', rating: 3 }, + { name: 'B024', rating: 3 }, + { name: 'B025', rating: 3 }, + { name: 'B026', rating: 3 }, + { name: 'B027', rating: 3 }, + { name: 'B028', rating: 3 }, + { name: 'B029', rating: 3 }, + { name: 'B030', rating: 3 }, + { name: 'B031', rating: 3 }, + { name: 'B032', rating: 3 }, + { name: 'B033', rating: 3 }, + { name: 'B034', rating: 3 }, + { name: 'B035', rating: 3 }, + { name: 'B036', rating: 3 }, + { name: 'B037', rating: 3 }, + { name: 'B038', rating: 3 }, + { name: 'B039', rating: 3 }, + { name: 'B040', rating: 3 }, + { name: 'B041', rating: 3 }, + { name: 'B042', rating: 3 }, + { name: 'B043', rating: 3 }, + { name: 'B044', rating: 3 }, + { name: 'B045', rating: 3 }, + { name: 'B046', rating: 3 }, + { name: 'B047', rating: 3 }, + { name: 'B048', rating: 3 }, + { name: 'B049', rating: 3 }, + { name: 'B050', rating: 3 }, + { name: 'B051', rating: 3 }, + { name: 'B052', rating: 3 }, + { name: 'B053', rating: 3 }, + { name: 'B054', rating: 3 }, + { name: 'B055', rating: 3 }, + { name: 'B056', rating: 3 }, + { name: 'B057', rating: 3 }, + { name: 'B058', rating: 3 }, + { name: 'B059', rating: 3 }, + { name: 'B060', rating: 3 }, + { name: 'B061', rating: 3 }, + { name: 'B062', rating: 3 }, + { name: 'B063', rating: 3 }, + { name: 'B064', rating: 3 }, + { name: 'B065', rating: 3 }, + { name: 'B066', rating: 3 }, + { name: 'B067', rating: 3 }, + { name: 'B068', rating: 3 }, + { name: 'B069', rating: 3 }, + { name: 'B070', rating: 3 }, + { name: 'B071', rating: 3 }, + { name: 'B072', rating: 3 }, + { name: 'B073', rating: 3 }, + { name: 'B074', rating: 3 }, + { name: 'B075', rating: 3 }, + { name: 'B076', rating: 3 }, + { name: 'B077', rating: 3 }, + { name: 'B078', rating: 3 }, + { name: 'B079', rating: 3 }, + { name: 'B080', rating: 3 }, + { name: 'B081', rating: 3 }, + { name: 'B082', rating: 3 }, + { name: 'B083', rating: 3 }, + { name: 'B084', rating: 3 }, + { name: 'B085', rating: 3 }, + { name: 'B086', rating: 3 }, + { name: 'B087', rating: 3 }, + { name: 'B088', rating: 3 }, + { name: 'B089', rating: 3 }, + { name: 'B090', rating: 3 }, + { name: 'B091', rating: 3 }, + { name: 'B092', rating: 3 }, + { name: 'B093', rating: 3 }, + { name: 'B094', rating: 3 }, + { name: 'B095', rating: 3 }, + { name: 'B096', rating: 3 }, + { name: 'B097', rating: 3 }, + { name: 'B098', rating: 3 }, + { name: 'B099', rating: 3 }, + { name: 'B100', rating: 3 }, + { name: 'B101', rating: 3 }, + { name: 'B102', rating: 3 }, + { name: 'B103', rating: 3 }, + { name: 'B104', rating: 3 }, + { name: 'B105', rating: 3 }, + { name: 'B106', rating: 3 }, + { name: 'B107', rating: 3 }, + { name: 'B108', rating: 3 }, + { name: 'B109', rating: 3 }, + { name: 'B110', rating: 3 }, + { name: 'B111', rating: 3 }, + { name: 'B112', rating: 3 }, + { name: 'B113', rating: 3 }, + { name: 'B114', rating: 3 }, + { name: 'B115', rating: 3 }, + { name: 'B116', rating: 3 }, + { name: 'B117', rating: 3 }, + { name: 'B118', rating: 3 }, + { name: 'B119', rating: 3 }, + { name: 'B120', rating: 3 }, + { name: 'B121', rating: 3 }, + { name: 'B122', rating: 3 }, + { name: 'B123', rating: 3 }, + { name: 'B124', rating: 3 }, + { name: 'B125', rating: 3 }, + { name: 'B126', rating: 3 }, + { name: 'B127', rating: 3 }, + { name: 'B128', rating: 3 }, + { name: 'B129', rating: 3 }, + { name: 'B130', rating: 3 }, + { name: 'B131', rating: 3 }, + { name: 'B132', rating: 3 }, + { name: 'B133', rating: 3 }, + { name: 'B134', rating: 3 }, + { name: 'B135', rating: 3 }, + { name: 'B136', rating: 3 }, + { name: 'B137', rating: 3 }, + { name: 'B138', rating: 3 }, + { name: 'B139', rating: 3 }, + { name: 'B140', rating: 3 }, + { name: 'B141', rating: 3 }, + { name: 'B142', rating: 3 }, + { name: 'B143', rating: 3 }, + { name: 'B144', rating: 3 }, + { name: 'B145', rating: 3 }, + { name: 'B146', rating: 3 }, + { name: 'B147', rating: 3 }, + { name: 'B148', rating: 3 }, + { name: 'B149', rating: 3 }, + { name: 'B150', rating: 3 }, + { name: 'B151', rating: 3 }, + { name: 'B152', rating: 3 }, + { name: 'B153', rating: 3 }, + { name: 'B154', rating: 3 }, + { name: 'B155', rating: 3 }, + { name: 'B156', rating: 3 }, + { name: 'B157', rating: 3 }, + { name: 'B158', rating: 3 }, + { name: 'B159', rating: 3 }, + { name: 'B160', rating: 3 }, + { name: 'B161', rating: 3 }, + { name: 'B162', rating: 3 }, + { name: 'B163', rating: 3 }, + { name: 'B164', rating: 3 }, + { name: 'B165', rating: 3 }, + { name: 'B166', rating: 3 }, + { name: 'B167', rating: 3 }, + { name: 'B168', rating: 3 }, + { name: 'B169', rating: 3 }, + { name: 'B170', rating: 3 }, + { name: 'B171', rating: 3 }, + { name: 'B172', rating: 3 }, + { name: 'B173', rating: 3 }, + { name: 'B174', rating: 3 }, + { name: 'B175', rating: 3 }, + { name: 'B176', rating: 3 }, + { name: 'B177', rating: 3 }, + { name: 'B178', rating: 3 }, + { name: 'B179', rating: 3 }, + { name: 'B180', rating: 3 }, + { name: 'B181', rating: 3 }, + { name: 'B182', rating: 3 }, + { name: 'B183', rating: 3 }, + { name: 'B184', rating: 3 }, + { name: 'B185', rating: 3 }, + { name: 'B186', rating: 3 }, + { name: 'C000', rating: 2 }, + { name: 'C001', rating: 2 }, + { name: 'C002', rating: 2 }, + { name: 'C003', rating: 2 }, + { name: 'C004', rating: 2 }, + { name: 'C005', rating: 2 }, + { name: 'C006', rating: 2 }, + { name: 'C007', rating: 2 }, + { name: 'C008', rating: 2 }, + { name: 'C009', rating: 2 }, + { name: 'C010', rating: 2 }, + { name: 'C011', rating: 2 }, + { name: 'C012', rating: 2 }, + { name: 'C013', rating: 2 }, + { name: 'C014', rating: 2 }, + { name: 'C015', rating: 2 }, + { name: 'C016', rating: 2 }, + { name: 'C017', rating: 2 }, + { name: 'C018', rating: 2 }, + { name: 'C019', rating: 2 }, + { name: 'C020', rating: 2 }, + { name: 'C021', rating: 2 }, + { name: 'C022', rating: 2 }, + { name: 'C023', rating: 2 }, + { name: 'C024', rating: 2 }, + { name: 'C025', rating: 2 }, + { name: 'C026', rating: 2 }, + { name: 'C027', rating: 2 }, + { name: 'C028', rating: 2 }, + { name: 'C029', rating: 2 }, + { name: 'C030', rating: 2 }, + { name: 'C031', rating: 2 }, + { name: 'C032', rating: 2 }, + { name: 'C033', rating: 2 }, + { name: 'C034', rating: 2 }, + { name: 'C035', rating: 2 }, + { name: 'C036', rating: 2 }, + { name: 'C037', rating: 2 }, + { name: 'C038', rating: 2 }, + { name: 'C039', rating: 2 }, + { name: 'C040', rating: 2 }, + { name: 'C041', rating: 2 }, + { name: 'C042', rating: 2 }, + { name: 'C043', rating: 2 }, + { name: 'C044', rating: 2 }, + { name: 'C045', rating: 2 }, + { name: 'C046', rating: 2 }, + { name: 'C047', rating: 2 }, + { name: 'C048', rating: 2 }, + { name: 'C049', rating: 2 }, + { name: 'C050', rating: 2 }, + { name: 'C051', rating: 2 }, + { name: 'C052', rating: 2 }, + { name: 'C053', rating: 2 }, + { name: 'C054', rating: 2 }, + { name: 'C055', rating: 2 }, + { name: 'C056', rating: 2 }, + { name: 'C057', rating: 2 }, + { name: 'C058', rating: 2 }, + { name: 'C059', rating: 2 }, + { name: 'C060', rating: 2 }, + { name: 'C061', rating: 2 }, + { name: 'C062', rating: 2 }, + { name: 'C063', rating: 2 }, + { name: 'C064', rating: 2 }, + { name: 'C065', rating: 2 }, + { name: 'C066', rating: 2 }, + { name: 'C067', rating: 2 }, + { name: 'C068', rating: 2 }, + { name: 'C069', rating: 2 }, + { name: 'C070', rating: 2 }, + { name: 'C071', rating: 2 }, + { name: 'C072', rating: 2 }, + { name: 'C073', rating: 2 }, + { name: 'C074', rating: 2 }, + { name: 'C075', rating: 2 }, + { name: 'C076', rating: 2 }, + { name: 'C077', rating: 2 }, + { name: 'C078', rating: 2 }, + { name: 'C079', rating: 2 }, + { name: 'C080', rating: 2 }, + { name: 'C081', rating: 2 }, + { name: 'C082', rating: 2 }, + { name: 'C083', rating: 2 }, + { name: 'C084', rating: 2 }, + { name: 'C085', rating: 2 }, + { name: 'C086', rating: 2 }, + { name: 'C087', rating: 2 }, + { name: 'C088', rating: 2 }, + { name: 'C089', rating: 2 }, + { name: 'C090', rating: 2 }, + { name: 'C091', rating: 2 }, + { name: 'C092', rating: 2 }, + { name: 'C093', rating: 2 }, + { name: 'C094', rating: 2 }, + { name: 'C095', rating: 2 }, + { name: 'C096', rating: 2 }, + { name: 'C097', rating: 2 }, + { name: 'C098', rating: 2 }, + { name: 'C099', rating: 2 }, + { name: 'C100', rating: 2 }, + { name: 'C101', rating: 2 }, + { name: 'C102', rating: 2 }, + { name: 'C103', rating: 2 }, + { name: 'C104', rating: 2 }, + { name: 'C105', rating: 2 }, + { name: 'C106', rating: 2 }, + { name: 'C107', rating: 2 }, + { name: 'C108', rating: 2 }, + { name: 'C109', rating: 2 }, + { name: 'C110', rating: 2 }, + { name: 'C111', rating: 2 }, + { name: 'C112', rating: 2 }, + { name: 'C113', rating: 2 }, + { name: 'C114', rating: 2 }, + { name: 'C115', rating: 2 }, + { name: 'C116', rating: 2 }, + { name: 'C117', rating: 2 }, + { name: 'C118', rating: 2 }, + { name: 'C119', rating: 2 }, + { name: 'C120', rating: 2 }, + { name: 'C121', rating: 2 }, + { name: 'C122', rating: 2 }, + { name: 'C123', rating: 2 }, + { name: 'C124', rating: 2 }, + { name: 'C125', rating: 2 }, + { name: 'C126', rating: 2 }, + { name: 'C127', rating: 2 }, + { name: 'C128', rating: 2 }, + { name: 'C129', rating: 2 }, + { name: 'C130', rating: 2 }, + { name: 'C131', rating: 2 }, + { name: 'C132', rating: 2 }, + { name: 'C133', rating: 2 }, + { name: 'C134', rating: 2 }, + { name: 'C135', rating: 2 }, + { name: 'C136', rating: 2 }, + { name: 'C137', rating: 2 }, + { name: 'C138', rating: 2 }, + { name: 'C139', rating: 2 }, + { name: 'C140', rating: 2 }, + { name: 'C141', rating: 2 }, + { name: 'C142', rating: 2 }, + { name: 'C143', rating: 2 }, + { name: 'C144', rating: 2 }, + { name: 'C145', rating: 2 }, + { name: 'C146', rating: 2 }, + { name: 'C147', rating: 2 }, + { name: 'C148', rating: 2 }, + { name: 'C149', rating: 2 }, + { name: 'C150', rating: 2 }, + { name: 'C151', rating: 2 }, + { name: 'C152', rating: 2 }, + { name: 'C153', rating: 2 }, + { name: 'C154', rating: 2 }, + { name: 'C155', rating: 2 }, + { name: 'C156', rating: 2 }, + { name: 'C157', rating: 2 }, + { name: 'C158', rating: 2 }, + { name: 'C159', rating: 2 }, + { name: 'C160', rating: 2 }, + { name: 'C161', rating: 2 }, + { name: 'C162', rating: 2 }, + { name: 'C163', rating: 2 }, + { name: 'C164', rating: 2 }, + { name: 'C165', rating: 2 }, + { name: 'C166', rating: 2 }, + { name: 'C167', rating: 2 }, + { name: 'C168', rating: 2 }, + { name: 'C169', rating: 2 }, + { name: 'C170', rating: 2 }, + { name: 'C171', rating: 2 }, + { name: 'C172', rating: 2 }, + { name: 'C173', rating: 2 }, + { name: 'C174', rating: 2 }, + { name: 'C175', rating: 2 }, + { name: 'C176', rating: 2 }, + { name: 'C177', rating: 2 }, + { name: 'C178', rating: 2 }, + { name: 'C179', rating: 2 }, + { name: 'C180', rating: 2 }, + { name: 'C181', rating: 2 }, + { name: 'C182', rating: 2 }, + { name: 'C183', rating: 2 }, + { name: 'C184', rating: 2 }, + { name: 'C185', rating: 2 }, + { name: 'C186', rating: 2 }, + { name: 'D000', rating: 4 }, + { name: 'D001', rating: 4 }, + { name: 'D002', rating: 4 }, + { name: 'D003', rating: 4 }, + { name: 'D004', rating: 4 }, + { name: 'D005', rating: 4 }, + { name: 'D006', rating: 4 }, + { name: 'D007', rating: 4 }, + { name: 'D008', rating: 4 }, + { name: 'D009', rating: 4 }, + { name: 'D010', rating: 4 }, + { name: 'D011', rating: 4 }, + { name: 'D012', rating: 4 }, + { name: 'D013', rating: 4 }, + { name: 'D014', rating: 4 }, + { name: 'D015', rating: 4 }, + { name: 'D016', rating: 4 }, + { name: 'D017', rating: 4 }, + { name: 'D018', rating: 4 }, + { name: 'D019', rating: 4 }, + { name: 'D020', rating: 4 }, + { name: 'D021', rating: 4 }, + { name: 'D022', rating: 4 }, + { name: 'D023', rating: 4 }, + { name: 'D024', rating: 4 }, + { name: 'D025', rating: 4 }, + { name: 'D026', rating: 4 }, + { name: 'D027', rating: 4 }, + { name: 'D028', rating: 4 }, + { name: 'D029', rating: 4 }, + { name: 'D030', rating: 4 }, + { name: 'D031', rating: 4 }, + { name: 'D032', rating: 4 }, + { name: 'D033', rating: 4 }, + { name: 'D034', rating: 4 }, + { name: 'D035', rating: 4 }, + { name: 'D036', rating: 4 }, + { name: 'D037', rating: 4 }, + { name: 'D038', rating: 4 }, + { name: 'D039', rating: 4 }, + { name: 'D040', rating: 4 }, + { name: 'D041', rating: 4 }, + { name: 'D042', rating: 4 }, + { name: 'D043', rating: 4 }, + { name: 'D044', rating: 4 }, + { name: 'D045', rating: 4 }, + { name: 'D046', rating: 4 }, + { name: 'D047', rating: 4 }, + { name: 'D048', rating: 4 }, + { name: 'D049', rating: 4 }, + { name: 'D050', rating: 4 }, + { name: 'D051', rating: 4 }, + { name: 'D052', rating: 4 }, + { name: 'D053', rating: 4 }, + { name: 'D054', rating: 4 }, + { name: 'D055', rating: 4 }, + { name: 'D056', rating: 4 }, + { name: 'D057', rating: 4 }, + { name: 'D058', rating: 4 }, + { name: 'D059', rating: 4 }, + { name: 'D060', rating: 4 }, + { name: 'D061', rating: 4 }, + { name: 'D062', rating: 4 }, + { name: 'D063', rating: 4 }, + { name: 'D064', rating: 4 }, + { name: 'D065', rating: 4 }, + { name: 'D066', rating: 4 }, + { name: 'D067', rating: 4 }, + { name: 'D068', rating: 4 }, + { name: 'D069', rating: 4 }, + { name: 'D070', rating: 4 }, + { name: 'D071', rating: 4 }, + { name: 'D072', rating: 4 }, + { name: 'D073', rating: 4 }, + { name: 'D074', rating: 4 }, + { name: 'D075', rating: 4 }, + { name: 'D076', rating: 4 }, + { name: 'D077', rating: 4 }, + { name: 'D078', rating: 4 }, + { name: 'D079', rating: 4 }, + { name: 'D080', rating: 4 }, + { name: 'D081', rating: 4 }, + { name: 'D082', rating: 4 }, + { name: 'D083', rating: 4 }, + { name: 'D084', rating: 4 }, + { name: 'D085', rating: 4 }, + { name: 'D086', rating: 4 }, + { name: 'D087', rating: 4 }, + { name: 'D088', rating: 4 }, + { name: 'D089', rating: 4 }, + { name: 'D090', rating: 4 }, + { name: 'D091', rating: 4 }, + { name: 'D092', rating: 4 }, + { name: 'D093', rating: 4 }, + { name: 'D094', rating: 4 }, + { name: 'D095', rating: 4 }, + { name: 'D096', rating: 4 }, + { name: 'D097', rating: 4 }, + { name: 'D098', rating: 4 }, + { name: 'D099', rating: 4 }, + { name: 'D100', rating: 4 }, + { name: 'D101', rating: 4 }, + { name: 'D102', rating: 4 }, + { name: 'D103', rating: 4 }, + { name: 'D104', rating: 4 }, + { name: 'D105', rating: 4 }, + { name: 'D106', rating: 4 }, + { name: 'D107', rating: 4 }, + { name: 'D108', rating: 4 }, + { name: 'D109', rating: 4 }, + { name: 'D110', rating: 4 }, + { name: 'D111', rating: 4 }, + { name: 'D112', rating: 4 }, + { name: 'D113', rating: 4 }, + { name: 'D114', rating: 4 }, + { name: 'D115', rating: 4 }, + { name: 'D116', rating: 4 }, + { name: 'D117', rating: 4 }, + { name: 'D118', rating: 4 }, + { name: 'D119', rating: 4 }, + { name: 'D120', rating: 4 }, + { name: 'D121', rating: 4 }, + { name: 'D122', rating: 4 }, + { name: 'D123', rating: 4 }, + { name: 'D124', rating: 4 }, + { name: 'D125', rating: 4 }, + { name: 'D126', rating: 4 }, + { name: 'D127', rating: 4 }, + { name: 'D128', rating: 4 }, + { name: 'D129', rating: 4 }, + { name: 'D130', rating: 4 }, + { name: 'D131', rating: 4 }, + { name: 'D132', rating: 4 }, + { name: 'D133', rating: 4 }, + { name: 'D134', rating: 4 }, + { name: 'D135', rating: 4 }, + { name: 'D136', rating: 4 }, + { name: 'D137', rating: 4 }, + { name: 'D138', rating: 4 }, + { name: 'D139', rating: 4 }, + { name: 'D140', rating: 4 }, + { name: 'D141', rating: 4 }, + { name: 'D142', rating: 4 }, + { name: 'D143', rating: 4 }, + { name: 'D144', rating: 4 }, + { name: 'D145', rating: 4 }, + { name: 'D146', rating: 4 }, + { name: 'D147', rating: 4 }, + { name: 'D148', rating: 4 }, + { name: 'D149', rating: 4 }, + { name: 'D150', rating: 4 }, + { name: 'D151', rating: 4 }, + { name: 'D152', rating: 4 }, + { name: 'D153', rating: 4 }, + { name: 'D154', rating: 4 }, + { name: 'D155', rating: 4 }, + { name: 'D156', rating: 4 }, + { name: 'D157', rating: 4 }, + { name: 'D158', rating: 4 }, + { name: 'D159', rating: 4 }, + { name: 'D160', rating: 4 }, + { name: 'D161', rating: 4 }, + { name: 'D162', rating: 4 }, + { name: 'D163', rating: 4 }, + { name: 'D164', rating: 4 }, + { name: 'D165', rating: 4 }, + { name: 'D166', rating: 4 }, + { name: 'D167', rating: 4 }, + { name: 'D168', rating: 4 }, + { name: 'D169', rating: 4 }, + { name: 'D170', rating: 4 }, + { name: 'D171', rating: 4 }, + { name: 'D172', rating: 4 }, + { name: 'D173', rating: 4 }, + { name: 'D174', rating: 4 }, + { name: 'D175', rating: 4 }, + { name: 'D176', rating: 4 }, + { name: 'D177', rating: 4 }, + { name: 'D178', rating: 4 }, + { name: 'D179', rating: 4 }, + { name: 'D180', rating: 4 }, + { name: 'D181', rating: 4 }, + { name: 'D182', rating: 4 }, + { name: 'D183', rating: 4 }, + { name: 'D184', rating: 4 }, + { name: 'D185', rating: 4 }, + { name: 'D186', rating: 4 }, + { name: 'E000', rating: 3 }, + { name: 'E001', rating: 3 }, + { name: 'E002', rating: 3 }, + { name: 'E003', rating: 3 }, + { name: 'E004', rating: 3 }, + { name: 'E005', rating: 3 }, + { name: 'E006', rating: 3 }, + { name: 'E007', rating: 3 }, + { name: 'E008', rating: 3 }, + { name: 'E009', rating: 3 }, + { name: 'E010', rating: 3 }, + { name: 'E011', rating: 3 }, + { name: 'E012', rating: 3 }, + { name: 'E013', rating: 3 }, + { name: 'E014', rating: 3 }, + { name: 'E015', rating: 3 }, + { name: 'E016', rating: 3 }, + { name: 'E017', rating: 3 }, + { name: 'E018', rating: 3 }, + { name: 'E019', rating: 3 }, + { name: 'E020', rating: 3 }, + { name: 'E021', rating: 3 }, + { name: 'E022', rating: 3 }, + { name: 'E023', rating: 3 }, + { name: 'E024', rating: 3 }, + { name: 'E025', rating: 3 }, + { name: 'E026', rating: 3 }, + { name: 'E027', rating: 3 }, + { name: 'E028', rating: 3 }, + { name: 'E029', rating: 3 }, + { name: 'E030', rating: 3 }, + { name: 'E031', rating: 3 }, + { name: 'E032', rating: 3 }, + { name: 'E033', rating: 3 }, + { name: 'E034', rating: 3 }, + { name: 'E035', rating: 3 }, + { name: 'E036', rating: 3 }, + { name: 'E037', rating: 3 }, + { name: 'E038', rating: 3 }, + { name: 'E039', rating: 3 }, + { name: 'E040', rating: 3 }, + { name: 'E041', rating: 3 }, + { name: 'E042', rating: 3 }, + { name: 'E043', rating: 3 }, + { name: 'E044', rating: 3 }, + { name: 'E045', rating: 3 }, + { name: 'E046', rating: 3 }, + { name: 'E047', rating: 3 }, + { name: 'E048', rating: 3 }, + { name: 'E049', rating: 3 }, + { name: 'E050', rating: 3 }, + { name: 'E051', rating: 3 }, + { name: 'E052', rating: 3 }, + { name: 'E053', rating: 3 }, + { name: 'E054', rating: 3 }, + { name: 'E055', rating: 3 }, + { name: 'E056', rating: 3 }, + { name: 'E057', rating: 3 }, + { name: 'E058', rating: 3 }, + { name: 'E059', rating: 3 }, + { name: 'E060', rating: 3 }, + { name: 'E061', rating: 3 }, + { name: 'E062', rating: 3 }, + { name: 'E063', rating: 3 }, + { name: 'E064', rating: 3 }, + { name: 'E065', rating: 3 }, + { name: 'E066', rating: 3 }, + { name: 'E067', rating: 3 }, + { name: 'E068', rating: 3 }, + { name: 'E069', rating: 3 }, + { name: 'E070', rating: 3 }, + { name: 'E071', rating: 3 }, + { name: 'E072', rating: 3 }, + { name: 'E073', rating: 3 }, + { name: 'E074', rating: 3 }, + { name: 'E075', rating: 3 }, + { name: 'E076', rating: 3 }, + { name: 'E077', rating: 3 }, + { name: 'E078', rating: 3 }, + { name: 'E079', rating: 3 }, + { name: 'E080', rating: 3 }, + { name: 'E081', rating: 3 }, + { name: 'E082', rating: 3 }, + { name: 'E083', rating: 3 }, + { name: 'E084', rating: 3 }, + { name: 'E085', rating: 3 }, + { name: 'E086', rating: 3 }, + { name: 'E087', rating: 3 }, + { name: 'E088', rating: 3 }, + { name: 'E089', rating: 3 }, + { name: 'E090', rating: 3 }, + { name: 'E091', rating: 3 }, + { name: 'E092', rating: 3 }, + { name: 'E093', rating: 3 }, + { name: 'E094', rating: 3 }, + { name: 'E095', rating: 3 }, + { name: 'E096', rating: 3 }, + { name: 'E097', rating: 3 }, + { name: 'E098', rating: 3 }, + { name: 'E099', rating: 3 }, + { name: 'E100', rating: 3 }, + { name: 'E101', rating: 3 }, + { name: 'E102', rating: 3 }, + { name: 'E103', rating: 3 }, + { name: 'E104', rating: 3 }, + { name: 'E105', rating: 3 }, + { name: 'E106', rating: 3 }, + { name: 'E107', rating: 3 }, + { name: 'E108', rating: 3 }, + { name: 'E109', rating: 3 }, + { name: 'E110', rating: 3 }, + { name: 'E111', rating: 3 }, + { name: 'E112', rating: 3 }, + { name: 'E113', rating: 3 }, + { name: 'E114', rating: 3 }, + { name: 'E115', rating: 3 }, + { name: 'E116', rating: 3 }, + { name: 'E117', rating: 3 }, + { name: 'E118', rating: 3 }, + { name: 'E119', rating: 3 }, + { name: 'E120', rating: 3 }, + { name: 'E121', rating: 3 }, + { name: 'E122', rating: 3 }, + { name: 'E123', rating: 3 }, + { name: 'E124', rating: 3 }, + { name: 'E125', rating: 3 }, + { name: 'E126', rating: 3 }, + { name: 'E127', rating: 3 }, + { name: 'E128', rating: 3 }, + { name: 'E129', rating: 3 }, + { name: 'E130', rating: 3 }, + { name: 'E131', rating: 3 }, + { name: 'E132', rating: 3 }, + { name: 'E133', rating: 3 }, + { name: 'E134', rating: 3 }, + { name: 'E135', rating: 3 }, + { name: 'E136', rating: 3 }, + { name: 'E137', rating: 3 }, + { name: 'E138', rating: 3 }, + { name: 'E139', rating: 3 }, + { name: 'E140', rating: 3 }, + { name: 'E141', rating: 3 }, + { name: 'E142', rating: 3 }, + { name: 'E143', rating: 3 }, + { name: 'E144', rating: 3 }, + { name: 'E145', rating: 3 }, + { name: 'E146', rating: 3 }, + { name: 'E147', rating: 3 }, + { name: 'E148', rating: 3 }, + { name: 'E149', rating: 3 }, + { name: 'E150', rating: 3 }, + { name: 'E151', rating: 3 }, + { name: 'E152', rating: 3 }, + { name: 'E153', rating: 3 }, + { name: 'E154', rating: 3 }, + { name: 'E155', rating: 3 }, + { name: 'E156', rating: 3 }, + { name: 'E157', rating: 3 }, + { name: 'E158', rating: 3 }, + { name: 'E159', rating: 3 }, + { name: 'E160', rating: 3 }, + { name: 'E161', rating: 3 }, + { name: 'E162', rating: 3 }, + { name: 'E163', rating: 3 }, + { name: 'E164', rating: 3 }, + { name: 'E165', rating: 3 }, + { name: 'E166', rating: 3 }, + { name: 'E167', rating: 3 }, + { name: 'E168', rating: 3 }, + { name: 'E169', rating: 3 }, + { name: 'E170', rating: 3 }, + { name: 'E171', rating: 3 }, + { name: 'E172', rating: 3 }, + { name: 'E173', rating: 3 }, + { name: 'E174', rating: 3 }, + { name: 'E175', rating: 3 }, + { name: 'E176', rating: 3 }, + { name: 'E177', rating: 3 }, + { name: 'E178', rating: 3 }, + { name: 'E179', rating: 3 }, + { name: 'E180', rating: 3 }, + { name: 'E181', rating: 3 }, + { name: 'E182', rating: 3 }, + { name: 'E183', rating: 3 }, + { name: 'E184', rating: 3 }, + { name: 'E185', rating: 3 }, + { name: 'E186', rating: 3 }, + { name: 'F000', rating: 3 }, + { name: 'F001', rating: 3 }, + { name: 'F002', rating: 3 }, + { name: 'F003', rating: 3 }, + { name: 'F004', rating: 3 }, + { name: 'F005', rating: 3 }, + { name: 'F006', rating: 3 }, + { name: 'F007', rating: 3 }, + { name: 'F008', rating: 3 }, + { name: 'F009', rating: 3 }, + { name: 'F010', rating: 3 }, + { name: 'F011', rating: 3 }, + { name: 'F012', rating: 3 }, + { name: 'F013', rating: 3 }, + { name: 'F014', rating: 3 }, + { name: 'F015', rating: 3 }, + { name: 'F016', rating: 3 }, + { name: 'F017', rating: 3 }, + { name: 'F018', rating: 3 }, + { name: 'F019', rating: 3 }, + { name: 'F020', rating: 3 }, + { name: 'F021', rating: 3 }, + { name: 'F022', rating: 3 }, + { name: 'F023', rating: 3 }, + { name: 'F024', rating: 3 }, + { name: 'F025', rating: 3 }, + { name: 'F026', rating: 3 }, + { name: 'F027', rating: 3 }, + { name: 'F028', rating: 3 }, + { name: 'F029', rating: 3 }, + { name: 'F030', rating: 3 }, + { name: 'F031', rating: 3 }, + { name: 'F032', rating: 3 }, + { name: 'F033', rating: 3 }, + { name: 'F034', rating: 3 }, + { name: 'F035', rating: 3 }, + { name: 'F036', rating: 3 }, + { name: 'F037', rating: 3 }, + { name: 'F038', rating: 3 }, + { name: 'F039', rating: 3 }, + { name: 'F040', rating: 3 }, + { name: 'F041', rating: 3 }, + { name: 'F042', rating: 3 }, + { name: 'F043', rating: 3 }, + { name: 'F044', rating: 3 }, + { name: 'F045', rating: 3 }, + { name: 'F046', rating: 3 }, + { name: 'F047', rating: 3 }, + { name: 'F048', rating: 3 }, + { name: 'F049', rating: 3 }, + { name: 'F050', rating: 3 }, + { name: 'F051', rating: 3 }, + { name: 'F052', rating: 3 }, + { name: 'F053', rating: 3 }, + { name: 'F054', rating: 3 }, + { name: 'F055', rating: 3 }, + { name: 'F056', rating: 3 }, + { name: 'F057', rating: 3 }, + { name: 'F058', rating: 3 }, + { name: 'F059', rating: 3 }, + { name: 'F060', rating: 3 }, + { name: 'F061', rating: 3 }, + { name: 'F062', rating: 3 }, + { name: 'F063', rating: 3 }, + { name: 'F064', rating: 3 }, + { name: 'F065', rating: 3 }, + { name: 'F066', rating: 3 }, + { name: 'F067', rating: 3 }, + { name: 'F068', rating: 3 }, + { name: 'F069', rating: 3 }, + { name: 'F070', rating: 3 }, + { name: 'F071', rating: 3 }, + { name: 'F072', rating: 3 }, + { name: 'F073', rating: 3 }, + { name: 'F074', rating: 3 }, + { name: 'F075', rating: 3 }, + { name: 'F076', rating: 3 }, + { name: 'F077', rating: 3 }, + { name: 'F078', rating: 3 }, + { name: 'F079', rating: 3 }, + { name: 'F080', rating: 3 }, + { name: 'F081', rating: 3 }, + { name: 'F082', rating: 3 }, + { name: 'F083', rating: 3 }, + { name: 'F084', rating: 3 }, + { name: 'F085', rating: 3 }, + { name: 'F086', rating: 3 }, + { name: 'F087', rating: 3 }, + { name: 'F088', rating: 3 }, + { name: 'F089', rating: 3 }, + { name: 'F090', rating: 3 }, + { name: 'F091', rating: 3 }, + { name: 'F092', rating: 3 }, + { name: 'F093', rating: 3 }, + { name: 'F094', rating: 3 }, + { name: 'F095', rating: 3 }, + { name: 'F096', rating: 3 }, + { name: 'F097', rating: 3 }, + { name: 'F098', rating: 3 }, + { name: 'F099', rating: 3 }, + { name: 'F100', rating: 3 }, + { name: 'F101', rating: 3 }, + { name: 'F102', rating: 3 }, + { name: 'F103', rating: 3 }, + { name: 'F104', rating: 3 }, + { name: 'F105', rating: 3 }, + { name: 'F106', rating: 3 }, + { name: 'F107', rating: 3 }, + { name: 'F108', rating: 3 }, + { name: 'F109', rating: 3 }, + { name: 'F110', rating: 3 }, + { name: 'F111', rating: 3 }, + { name: 'F112', rating: 3 }, + { name: 'F113', rating: 3 }, + { name: 'F114', rating: 3 }, + { name: 'F115', rating: 3 }, + { name: 'F116', rating: 3 }, + { name: 'F117', rating: 3 }, + { name: 'F118', rating: 3 }, + { name: 'F119', rating: 3 }, + { name: 'F120', rating: 3 }, + { name: 'F121', rating: 3 }, + { name: 'F122', rating: 3 }, + { name: 'F123', rating: 3 }, + { name: 'F124', rating: 3 }, + { name: 'F125', rating: 3 }, + { name: 'F126', rating: 3 }, + { name: 'F127', rating: 3 }, + { name: 'F128', rating: 3 }, + { name: 'F129', rating: 3 }, + { name: 'F130', rating: 3 }, + { name: 'F131', rating: 3 }, + { name: 'F132', rating: 3 }, + { name: 'F133', rating: 3 }, + { name: 'F134', rating: 3 }, + { name: 'F135', rating: 3 }, + { name: 'F136', rating: 3 }, + { name: 'F137', rating: 3 }, + { name: 'F138', rating: 3 }, + { name: 'F139', rating: 3 }, + { name: 'F140', rating: 3 }, + { name: 'F141', rating: 3 }, + { name: 'F142', rating: 3 }, + { name: 'F143', rating: 3 }, + { name: 'F144', rating: 3 }, + { name: 'F145', rating: 3 }, + { name: 'F146', rating: 3 }, + { name: 'F147', rating: 3 }, + { name: 'F148', rating: 3 }, + { name: 'F149', rating: 3 }, + { name: 'F150', rating: 3 }, + { name: 'F151', rating: 3 }, + { name: 'F152', rating: 3 }, + { name: 'F153', rating: 3 }, + { name: 'F154', rating: 3 }, + { name: 'F155', rating: 3 }, + { name: 'F156', rating: 3 }, + { name: 'F157', rating: 3 }, + { name: 'F158', rating: 3 }, + { name: 'F159', rating: 3 }, + { name: 'F160', rating: 3 }, + { name: 'F161', rating: 3 }, + { name: 'F162', rating: 3 }, + { name: 'F163', rating: 3 }, + { name: 'F164', rating: 3 }, + { name: 'F165', rating: 3 }, + { name: 'F166', rating: 3 }, + { name: 'F167', rating: 3 }, + { name: 'F168', rating: 3 }, + { name: 'F169', rating: 3 }, + { name: 'F170', rating: 3 }, + { name: 'F171', rating: 3 }, + { name: 'F172', rating: 3 }, + { name: 'F173', rating: 3 }, + { name: 'F174', rating: 3 }, + { name: 'F175', rating: 3 }, + { name: 'F176', rating: 3 }, + { name: 'F177', rating: 3 }, + { name: 'F178', rating: 3 }, + { name: 'F179', rating: 3 }, + { name: 'F180', rating: 3 }, + { name: 'F181', rating: 3 }, + { name: 'F182', rating: 3 }, + { name: 'F183', rating: 3 }, + { name: 'F184', rating: 3 }, + { name: 'F185', rating: 3 }, + { name: 'F186', rating: 3 }, + { name: 'G000', rating: 4 }, + { name: 'G001', rating: 4 }, + { name: 'G002', rating: 4 }, + { name: 'G003', rating: 4 }, + { name: 'G004', rating: 4 }, + { name: 'G005', rating: 4 }, + { name: 'G006', rating: 4 }, + { name: 'G007', rating: 4 }, + { name: 'G008', rating: 4 }, + { name: 'G009', rating: 4 }, + { name: 'G010', rating: 4 }, + { name: 'G011', rating: 4 }, + { name: 'G012', rating: 4 }, + { name: 'G013', rating: 4 }, + { name: 'G014', rating: 4 }, + { name: 'G015', rating: 4 }, + { name: 'G016', rating: 4 }, + { name: 'G017', rating: 4 }, + { name: 'G018', rating: 4 }, + { name: 'G019', rating: 4 }, + { name: 'G020', rating: 4 }, + { name: 'G021', rating: 4 }, + { name: 'G022', rating: 4 }, + { name: 'G023', rating: 4 }, + { name: 'G024', rating: 4 }, + { name: 'G025', rating: 4 }, + { name: 'G026', rating: 4 }, + { name: 'G027', rating: 4 }, + { name: 'G028', rating: 4 }, + { name: 'G029', rating: 4 }, + { name: 'G030', rating: 4 }, + { name: 'G031', rating: 4 }, + { name: 'G032', rating: 4 }, + { name: 'G033', rating: 4 }, + { name: 'G034', rating: 4 }, + { name: 'G035', rating: 4 }, + { name: 'G036', rating: 4 }, + { name: 'G037', rating: 4 }, + { name: 'G038', rating: 4 }, + { name: 'G039', rating: 4 }, + { name: 'G040', rating: 4 }, + { name: 'G041', rating: 4 }, + { name: 'G042', rating: 4 }, + { name: 'G043', rating: 4 }, + { name: 'G044', rating: 4 }, + { name: 'G045', rating: 4 }, + { name: 'G046', rating: 4 }, + { name: 'G047', rating: 4 }, + { name: 'G048', rating: 4 }, + { name: 'G049', rating: 4 }, + { name: 'G050', rating: 4 }, + { name: 'G051', rating: 4 }, + { name: 'G052', rating: 4 }, + { name: 'G053', rating: 4 }, + { name: 'G054', rating: 4 }, + { name: 'G055', rating: 4 }, + { name: 'G056', rating: 4 }, + { name: 'G057', rating: 4 }, + { name: 'G058', rating: 4 }, + { name: 'G059', rating: 4 }, + { name: 'G060', rating: 4 }, + { name: 'G061', rating: 4 }, + { name: 'G062', rating: 4 }, + { name: 'G063', rating: 4 }, + { name: 'G064', rating: 4 }, + { name: 'G065', rating: 4 }, + { name: 'G066', rating: 4 }, + { name: 'G067', rating: 4 }, + { name: 'G068', rating: 4 }, + { name: 'G069', rating: 4 }, + { name: 'G070', rating: 4 }, + { name: 'G071', rating: 4 }, + { name: 'G072', rating: 4 }, + { name: 'G073', rating: 4 }, + { name: 'G074', rating: 4 }, + { name: 'G075', rating: 4 }, + { name: 'G076', rating: 4 }, + { name: 'G077', rating: 4 }, + { name: 'G078', rating: 4 }, + { name: 'G079', rating: 4 }, + { name: 'G080', rating: 4 }, + { name: 'G081', rating: 4 }, + { name: 'G082', rating: 4 }, + { name: 'G083', rating: 4 }, + { name: 'G084', rating: 4 }, + { name: 'G085', rating: 4 }, + { name: 'G086', rating: 4 }, + { name: 'G087', rating: 4 }, + { name: 'G088', rating: 4 }, + { name: 'G089', rating: 4 }, + { name: 'G090', rating: 4 }, + { name: 'G091', rating: 4 }, + { name: 'G092', rating: 4 }, + { name: 'G093', rating: 4 }, + { name: 'G094', rating: 4 }, + { name: 'G095', rating: 4 }, + { name: 'G096', rating: 4 }, + { name: 'G097', rating: 4 }, + { name: 'G098', rating: 4 }, + { name: 'G099', rating: 4 }, + { name: 'G100', rating: 4 }, + { name: 'G101', rating: 4 }, + { name: 'G102', rating: 4 }, + { name: 'G103', rating: 4 }, + { name: 'G104', rating: 4 }, + { name: 'G105', rating: 4 }, + { name: 'G106', rating: 4 }, + { name: 'G107', rating: 4 }, + { name: 'G108', rating: 4 }, + { name: 'G109', rating: 4 }, + { name: 'G110', rating: 4 }, + { name: 'G111', rating: 4 }, + { name: 'G112', rating: 4 }, + { name: 'G113', rating: 4 }, + { name: 'G114', rating: 4 }, + { name: 'G115', rating: 4 }, + { name: 'G116', rating: 4 }, + { name: 'G117', rating: 4 }, + { name: 'G118', rating: 4 }, + { name: 'G119', rating: 4 }, + { name: 'G120', rating: 4 }, + { name: 'G121', rating: 4 }, + { name: 'G122', rating: 4 }, + { name: 'G123', rating: 4 }, + { name: 'G124', rating: 4 }, + { name: 'G125', rating: 4 }, + { name: 'G126', rating: 4 }, + { name: 'G127', rating: 4 }, + { name: 'G128', rating: 4 }, + { name: 'G129', rating: 4 }, + { name: 'G130', rating: 4 }, + { name: 'G131', rating: 4 }, + { name: 'G132', rating: 4 }, + { name: 'G133', rating: 4 }, + { name: 'G134', rating: 4 }, + { name: 'G135', rating: 4 }, + { name: 'G136', rating: 4 }, + { name: 'G137', rating: 4 }, + { name: 'G138', rating: 4 }, + { name: 'G139', rating: 4 }, + { name: 'G140', rating: 4 }, + { name: 'G141', rating: 4 }, + { name: 'G142', rating: 4 }, + { name: 'G143', rating: 4 }, + { name: 'G144', rating: 4 }, + { name: 'G145', rating: 4 }, + { name: 'G146', rating: 4 }, + { name: 'G147', rating: 4 }, + { name: 'G148', rating: 4 }, + { name: 'G149', rating: 4 }, + { name: 'G150', rating: 4 }, + { name: 'G151', rating: 4 }, + { name: 'G152', rating: 4 }, + { name: 'G153', rating: 4 }, + { name: 'G154', rating: 4 }, + { name: 'G155', rating: 4 }, + { name: 'G156', rating: 4 }, + { name: 'G157', rating: 4 }, + { name: 'G158', rating: 4 }, + { name: 'G159', rating: 4 }, + { name: 'G160', rating: 4 }, + { name: 'G161', rating: 4 }, + { name: 'G162', rating: 4 }, + { name: 'G163', rating: 4 }, + { name: 'G164', rating: 4 }, + { name: 'G165', rating: 4 }, + { name: 'G166', rating: 4 }, + { name: 'G167', rating: 4 }, + { name: 'G168', rating: 4 }, + { name: 'G169', rating: 4 }, + { name: 'G170', rating: 4 }, + { name: 'G171', rating: 4 }, + { name: 'G172', rating: 4 }, + { name: 'G173', rating: 4 }, + { name: 'G174', rating: 4 }, + { name: 'G175', rating: 4 }, + { name: 'G176', rating: 4 }, + { name: 'G177', rating: 4 }, + { name: 'G178', rating: 4 }, + { name: 'G179', rating: 4 }, + { name: 'G180', rating: 4 }, + { name: 'G181', rating: 4 }, + { name: 'G182', rating: 4 }, + { name: 'G183', rating: 4 }, + { name: 'G184', rating: 4 }, + { name: 'G185', rating: 4 }, + { name: 'G186', rating: 4 }, + { name: 'H000', rating: 3 }, + { name: 'H001', rating: 3 }, + { name: 'H002', rating: 3 }, + { name: 'H003', rating: 3 }, + { name: 'H004', rating: 3 }, + { name: 'H005', rating: 3 }, + { name: 'H006', rating: 3 }, + { name: 'H007', rating: 3 }, + { name: 'H008', rating: 3 }, + { name: 'H009', rating: 3 }, + { name: 'H010', rating: 3 }, + { name: 'H011', rating: 3 }, + { name: 'H012', rating: 3 }, + { name: 'H013', rating: 3 }, + { name: 'H014', rating: 3 }, + { name: 'H015', rating: 3 }, + { name: 'H016', rating: 3 }, + { name: 'H017', rating: 3 }, + { name: 'H018', rating: 3 }, + { name: 'H019', rating: 3 }, + { name: 'H020', rating: 3 }, + { name: 'H021', rating: 3 }, + { name: 'H022', rating: 3 }, + { name: 'H023', rating: 3 }, + { name: 'H024', rating: 3 }, + { name: 'H025', rating: 3 }, + { name: 'H026', rating: 3 }, + { name: 'H027', rating: 3 }, + { name: 'H028', rating: 3 }, + { name: 'H029', rating: 3 }, + { name: 'H030', rating: 3 }, + { name: 'H031', rating: 3 }, + { name: 'H032', rating: 3 }, + { name: 'H033', rating: 3 }, + { name: 'H034', rating: 3 }, + { name: 'H035', rating: 3 }, + { name: 'H036', rating: 3 }, + { name: 'H037', rating: 3 }, + { name: 'H038', rating: 3 }, + { name: 'H039', rating: 3 }, + { name: 'H040', rating: 3 }, + { name: 'H041', rating: 3 }, + { name: 'H042', rating: 3 }, + { name: 'H043', rating: 3 }, + { name: 'H044', rating: 3 }, + { name: 'H045', rating: 3 }, + { name: 'H046', rating: 3 }, + { name: 'H047', rating: 3 }, + { name: 'H048', rating: 3 }, + { name: 'H049', rating: 3 }, + { name: 'H050', rating: 3 }, + { name: 'H051', rating: 3 }, + { name: 'H052', rating: 3 }, + { name: 'H053', rating: 3 }, + { name: 'H054', rating: 3 }, + { name: 'H055', rating: 3 }, + { name: 'H056', rating: 3 }, + { name: 'H057', rating: 3 }, + { name: 'H058', rating: 3 }, + { name: 'H059', rating: 3 }, + { name: 'H060', rating: 3 }, + { name: 'H061', rating: 3 }, + { name: 'H062', rating: 3 }, + { name: 'H063', rating: 3 }, + { name: 'H064', rating: 3 }, + { name: 'H065', rating: 3 }, + { name: 'H066', rating: 3 }, + { name: 'H067', rating: 3 }, + { name: 'H068', rating: 3 }, + { name: 'H069', rating: 3 }, + { name: 'H070', rating: 3 }, + { name: 'H071', rating: 3 }, + { name: 'H072', rating: 3 }, + { name: 'H073', rating: 3 }, + { name: 'H074', rating: 3 }, + { name: 'H075', rating: 3 }, + { name: 'H076', rating: 3 }, + { name: 'H077', rating: 3 }, + { name: 'H078', rating: 3 }, + { name: 'H079', rating: 3 }, + { name: 'H080', rating: 3 }, + { name: 'H081', rating: 3 }, + { name: 'H082', rating: 3 }, + { name: 'H083', rating: 3 }, + { name: 'H084', rating: 3 }, + { name: 'H085', rating: 3 }, + { name: 'H086', rating: 3 }, + { name: 'H087', rating: 3 }, + { name: 'H088', rating: 3 }, + { name: 'H089', rating: 3 }, + { name: 'H090', rating: 3 }, + { name: 'H091', rating: 3 }, + { name: 'H092', rating: 3 }, + { name: 'H093', rating: 3 }, + { name: 'H094', rating: 3 }, + { name: 'H095', rating: 3 }, + { name: 'H096', rating: 3 }, + { name: 'H097', rating: 3 }, + { name: 'H098', rating: 3 }, + { name: 'H099', rating: 3 }, + { name: 'H100', rating: 3 }, + { name: 'H101', rating: 3 }, + { name: 'H102', rating: 3 }, + { name: 'H103', rating: 3 }, + { name: 'H104', rating: 3 }, + { name: 'H105', rating: 3 }, + { name: 'H106', rating: 3 }, + { name: 'H107', rating: 3 }, + { name: 'H108', rating: 3 }, + { name: 'H109', rating: 3 }, + { name: 'H110', rating: 3 }, + { name: 'H111', rating: 3 }, + { name: 'H112', rating: 3 }, + { name: 'H113', rating: 3 }, + { name: 'H114', rating: 3 }, + { name: 'H115', rating: 3 }, + { name: 'H116', rating: 3 }, + { name: 'H117', rating: 3 }, + { name: 'H118', rating: 3 }, + { name: 'H119', rating: 3 }, + { name: 'H120', rating: 3 }, + { name: 'H121', rating: 3 }, + { name: 'H122', rating: 3 }, + { name: 'H123', rating: 3 }, + { name: 'H124', rating: 3 }, + { name: 'H125', rating: 3 }, + { name: 'H126', rating: 3 }, + { name: 'H127', rating: 3 }, + { name: 'H128', rating: 3 }, + { name: 'H129', rating: 3 }, + { name: 'H130', rating: 3 }, + { name: 'H131', rating: 3 }, + { name: 'H132', rating: 3 }, + { name: 'H133', rating: 3 }, + { name: 'H134', rating: 3 }, + { name: 'H135', rating: 3 }, + { name: 'H136', rating: 3 }, + { name: 'H137', rating: 3 }, + { name: 'H138', rating: 3 }, + { name: 'H139', rating: 3 }, + { name: 'H140', rating: 3 }, + { name: 'H141', rating: 3 }, + { name: 'H142', rating: 3 }, + { name: 'H143', rating: 3 }, + { name: 'H144', rating: 3 }, + { name: 'H145', rating: 3 }, + { name: 'H146', rating: 3 }, + { name: 'H147', rating: 3 }, + { name: 'H148', rating: 3 }, + { name: 'H149', rating: 3 }, + { name: 'H150', rating: 3 }, + { name: 'H151', rating: 3 }, + { name: 'H152', rating: 3 }, + { name: 'H153', rating: 3 }, + { name: 'H154', rating: 3 }, + { name: 'H155', rating: 3 }, + { name: 'H156', rating: 3 }, + { name: 'H157', rating: 3 }, + { name: 'H158', rating: 3 }, + { name: 'H159', rating: 3 }, + { name: 'H160', rating: 3 }, + { name: 'H161', rating: 3 }, + { name: 'H162', rating: 3 }, + { name: 'H163', rating: 3 }, + { name: 'H164', rating: 3 }, + { name: 'H165', rating: 3 }, + { name: 'H166', rating: 3 }, + { name: 'H167', rating: 3 }, + { name: 'H168', rating: 3 }, + { name: 'H169', rating: 3 }, + { name: 'H170', rating: 3 }, + { name: 'H171', rating: 3 }, + { name: 'H172', rating: 3 }, + { name: 'H173', rating: 3 }, + { name: 'H174', rating: 3 }, + { name: 'H175', rating: 3 }, + { name: 'H176', rating: 3 }, + { name: 'H177', rating: 3 }, + { name: 'H178', rating: 3 }, + { name: 'H179', rating: 3 }, + { name: 'H180', rating: 3 }, + { name: 'H181', rating: 3 }, + { name: 'H182', rating: 3 }, + { name: 'H183', rating: 3 }, + { name: 'H184', rating: 3 }, + { name: 'H185', rating: 3 }, + { name: 'H186', rating: 3 }, + { name: 'I000', rating: 2 }, + { name: 'I001', rating: 2 }, + { name: 'I002', rating: 2 }, + { name: 'I003', rating: 2 }, + { name: 'I004', rating: 2 }, + { name: 'I005', rating: 2 }, + { name: 'I006', rating: 2 }, + { name: 'I007', rating: 2 }, + { name: 'I008', rating: 2 }, + { name: 'I009', rating: 2 }, + { name: 'I010', rating: 2 }, + { name: 'I011', rating: 2 }, + { name: 'I012', rating: 2 }, + { name: 'I013', rating: 2 }, + { name: 'I014', rating: 2 }, + { name: 'I015', rating: 2 }, + { name: 'I016', rating: 2 }, + { name: 'I017', rating: 2 }, + { name: 'I018', rating: 2 }, + { name: 'I019', rating: 2 }, + { name: 'I020', rating: 2 }, + { name: 'I021', rating: 2 }, + { name: 'I022', rating: 2 }, + { name: 'I023', rating: 2 }, + { name: 'I024', rating: 2 }, + { name: 'I025', rating: 2 }, + { name: 'I026', rating: 2 }, + { name: 'I027', rating: 2 }, + { name: 'I028', rating: 2 }, + { name: 'I029', rating: 2 }, + { name: 'I030', rating: 2 }, + { name: 'I031', rating: 2 }, + { name: 'I032', rating: 2 }, + { name: 'I033', rating: 2 }, + { name: 'I034', rating: 2 }, + { name: 'I035', rating: 2 }, + { name: 'I036', rating: 2 }, + { name: 'I037', rating: 2 }, + { name: 'I038', rating: 2 }, + { name: 'I039', rating: 2 }, + { name: 'I040', rating: 2 }, + { name: 'I041', rating: 2 }, + { name: 'I042', rating: 2 }, + { name: 'I043', rating: 2 }, + { name: 'I044', rating: 2 }, + { name: 'I045', rating: 2 }, + { name: 'I046', rating: 2 }, + { name: 'I047', rating: 2 }, + { name: 'I048', rating: 2 }, + { name: 'I049', rating: 2 }, + { name: 'I050', rating: 2 }, + { name: 'I051', rating: 2 }, + { name: 'I052', rating: 2 }, + { name: 'I053', rating: 2 }, + { name: 'I054', rating: 2 }, + { name: 'I055', rating: 2 }, + { name: 'I056', rating: 2 }, + { name: 'I057', rating: 2 }, + { name: 'I058', rating: 2 }, + { name: 'I059', rating: 2 }, + { name: 'I060', rating: 2 }, + { name: 'I061', rating: 2 }, + { name: 'I062', rating: 2 }, + { name: 'I063', rating: 2 }, + { name: 'I064', rating: 2 }, + { name: 'I065', rating: 2 }, + { name: 'I066', rating: 2 }, + { name: 'I067', rating: 2 }, + { name: 'I068', rating: 2 }, + { name: 'I069', rating: 2 }, + { name: 'I070', rating: 2 }, + { name: 'I071', rating: 2 }, + { name: 'I072', rating: 2 }, + { name: 'I073', rating: 2 }, + { name: 'I074', rating: 2 }, + { name: 'I075', rating: 2 }, + { name: 'I076', rating: 2 }, + { name: 'I077', rating: 2 }, + { name: 'I078', rating: 2 }, + { name: 'I079', rating: 2 }, + { name: 'I080', rating: 2 }, + { name: 'I081', rating: 2 }, + { name: 'I082', rating: 2 }, + { name: 'I083', rating: 2 }, + { name: 'I084', rating: 2 }, + { name: 'I085', rating: 2 }, + { name: 'I086', rating: 2 }, + { name: 'I087', rating: 2 }, + { name: 'I088', rating: 2 }, + { name: 'I089', rating: 2 }, + { name: 'I090', rating: 2 }, + { name: 'I091', rating: 2 }, + { name: 'I092', rating: 2 }, + { name: 'I093', rating: 2 }, + { name: 'I094', rating: 2 }, + { name: 'I095', rating: 2 }, + { name: 'I096', rating: 2 }, + { name: 'I097', rating: 2 }, + { name: 'I098', rating: 2 }, + { name: 'I099', rating: 2 }, + { name: 'I100', rating: 2 }, + { name: 'I101', rating: 2 }, + { name: 'I102', rating: 2 }, + { name: 'I103', rating: 2 }, + { name: 'I104', rating: 2 }, + { name: 'I105', rating: 2 }, + { name: 'I106', rating: 2 }, + { name: 'I107', rating: 2 }, + { name: 'I108', rating: 2 }, + { name: 'I109', rating: 2 }, + { name: 'I110', rating: 2 }, + { name: 'I111', rating: 2 }, + { name: 'I112', rating: 2 }, + { name: 'I113', rating: 2 }, + { name: 'I114', rating: 2 }, + { name: 'I115', rating: 2 }, + { name: 'I116', rating: 2 }, + { name: 'I117', rating: 2 }, + { name: 'I118', rating: 2 }, + { name: 'I119', rating: 2 }, + { name: 'I120', rating: 2 }, + { name: 'I121', rating: 2 }, + { name: 'I122', rating: 2 }, + { name: 'I123', rating: 2 }, + { name: 'I124', rating: 2 }, + { name: 'I125', rating: 2 }, + { name: 'I126', rating: 2 }, + { name: 'I127', rating: 2 }, + { name: 'I128', rating: 2 }, + { name: 'I129', rating: 2 }, + { name: 'I130', rating: 2 }, + { name: 'I131', rating: 2 }, + { name: 'I132', rating: 2 }, + { name: 'I133', rating: 2 }, + { name: 'I134', rating: 2 }, + { name: 'I135', rating: 2 }, + { name: 'I136', rating: 2 }, + { name: 'I137', rating: 2 }, + { name: 'I138', rating: 2 }, + { name: 'I139', rating: 2 }, + { name: 'I140', rating: 2 }, + { name: 'I141', rating: 2 }, + { name: 'I142', rating: 2 }, + { name: 'I143', rating: 2 }, + { name: 'I144', rating: 2 }, + { name: 'I145', rating: 2 }, + { name: 'I146', rating: 2 }, + { name: 'I147', rating: 2 }, + { name: 'I148', rating: 2 }, + { name: 'I149', rating: 2 }, + { name: 'I150', rating: 2 }, + { name: 'I151', rating: 2 }, + { name: 'I152', rating: 2 }, + { name: 'I153', rating: 2 }, + { name: 'I154', rating: 2 }, + { name: 'I155', rating: 2 }, + { name: 'I156', rating: 2 }, + { name: 'I157', rating: 2 }, + { name: 'I158', rating: 2 }, + { name: 'I159', rating: 2 }, + { name: 'I160', rating: 2 }, + { name: 'I161', rating: 2 }, + { name: 'I162', rating: 2 }, + { name: 'I163', rating: 2 }, + { name: 'I164', rating: 2 }, + { name: 'I165', rating: 2 }, + { name: 'I166', rating: 2 }, + { name: 'I167', rating: 2 }, + { name: 'I168', rating: 2 }, + { name: 'I169', rating: 2 }, + { name: 'I170', rating: 2 }, + { name: 'I171', rating: 2 }, + { name: 'I172', rating: 2 }, + { name: 'I173', rating: 2 }, + { name: 'I174', rating: 2 }, + { name: 'I175', rating: 2 }, + { name: 'I176', rating: 2 }, + { name: 'I177', rating: 2 }, + { name: 'I178', rating: 2 }, + { name: 'I179', rating: 2 }, + { name: 'I180', rating: 2 }, + { name: 'I181', rating: 2 }, + { name: 'I182', rating: 2 }, + { name: 'I183', rating: 2 }, + { name: 'I184', rating: 2 }, + { name: 'I185', rating: 2 }, + { name: 'I186', rating: 2 }, + { name: 'J000', rating: 2 }, + { name: 'J001', rating: 2 }, + { name: 'J002', rating: 2 }, + { name: 'J003', rating: 2 }, + { name: 'J004', rating: 2 }, + { name: 'J005', rating: 2 }, + { name: 'J006', rating: 2 }, + { name: 'J007', rating: 2 }, + { name: 'J008', rating: 2 }, + { name: 'J009', rating: 2 }, + { name: 'J010', rating: 2 }, + { name: 'J011', rating: 2 }, + { name: 'J012', rating: 2 }, + { name: 'J013', rating: 2 }, + { name: 'J014', rating: 2 }, + { name: 'J015', rating: 2 }, + { name: 'J016', rating: 2 }, + { name: 'J017', rating: 2 }, + { name: 'J018', rating: 2 }, + { name: 'J019', rating: 2 }, + { name: 'J020', rating: 2 }, + { name: 'J021', rating: 2 }, + { name: 'J022', rating: 2 }, + { name: 'J023', rating: 2 }, + { name: 'J024', rating: 2 }, + { name: 'J025', rating: 2 }, + { name: 'J026', rating: 2 }, + { name: 'J027', rating: 2 }, + { name: 'J028', rating: 2 }, + { name: 'J029', rating: 2 }, + { name: 'J030', rating: 2 }, + { name: 'J031', rating: 2 }, + { name: 'J032', rating: 2 }, + { name: 'J033', rating: 2 }, + { name: 'J034', rating: 2 }, + { name: 'J035', rating: 2 }, + { name: 'J036', rating: 2 }, + { name: 'J037', rating: 2 }, + { name: 'J038', rating: 2 }, + { name: 'J039', rating: 2 }, + { name: 'J040', rating: 2 }, + { name: 'J041', rating: 2 }, + { name: 'J042', rating: 2 }, + { name: 'J043', rating: 2 }, + { name: 'J044', rating: 2 }, + { name: 'J045', rating: 2 }, + { name: 'J046', rating: 2 }, + { name: 'J047', rating: 2 }, + { name: 'J048', rating: 2 }, + { name: 'J049', rating: 2 }, + { name: 'J050', rating: 2 }, + { name: 'J051', rating: 2 }, + { name: 'J052', rating: 2 }, + { name: 'J053', rating: 2 }, + { name: 'J054', rating: 2 }, + { name: 'J055', rating: 2 }, + { name: 'J056', rating: 2 }, + { name: 'J057', rating: 2 }, + { name: 'J058', rating: 2 }, + { name: 'J059', rating: 2 }, + { name: 'J060', rating: 2 }, + { name: 'J061', rating: 2 }, + { name: 'J062', rating: 2 }, + { name: 'J063', rating: 2 }, + { name: 'J064', rating: 2 }, + { name: 'J065', rating: 2 }, + { name: 'J066', rating: 2 }, + { name: 'J067', rating: 2 }, + { name: 'J068', rating: 2 }, + { name: 'J069', rating: 2 }, + { name: 'J070', rating: 2 }, + { name: 'J071', rating: 2 }, + { name: 'J072', rating: 2 }, + { name: 'J073', rating: 2 }, + { name: 'J074', rating: 2 }, + { name: 'J075', rating: 2 }, + { name: 'J076', rating: 2 }, + { name: 'J077', rating: 2 }, + { name: 'J078', rating: 2 }, + { name: 'J079', rating: 2 }, + { name: 'J080', rating: 2 }, + { name: 'J081', rating: 2 }, + { name: 'J082', rating: 2 }, + { name: 'J083', rating: 2 }, + { name: 'J084', rating: 2 }, + { name: 'J085', rating: 2 }, + { name: 'J086', rating: 2 }, + { name: 'J087', rating: 2 }, + { name: 'J088', rating: 2 }, + { name: 'J089', rating: 2 }, + { name: 'J090', rating: 2 }, + { name: 'J091', rating: 2 }, + { name: 'J092', rating: 2 }, + { name: 'J093', rating: 2 }, + { name: 'J094', rating: 2 }, + { name: 'J095', rating: 2 }, + { name: 'J096', rating: 2 }, + { name: 'J097', rating: 2 }, + { name: 'J098', rating: 2 }, + { name: 'J099', rating: 2 }, + { name: 'J100', rating: 2 }, + { name: 'J101', rating: 2 }, + { name: 'J102', rating: 2 }, + { name: 'J103', rating: 2 }, + { name: 'J104', rating: 2 }, + { name: 'J105', rating: 2 }, + { name: 'J106', rating: 2 }, + { name: 'J107', rating: 2 }, + { name: 'J108', rating: 2 }, + { name: 'J109', rating: 2 }, + { name: 'J110', rating: 2 }, + { name: 'J111', rating: 2 }, + { name: 'J112', rating: 2 }, + { name: 'J113', rating: 2 }, + { name: 'J114', rating: 2 }, + { name: 'J115', rating: 2 }, + { name: 'J116', rating: 2 }, + { name: 'J117', rating: 2 }, + { name: 'J118', rating: 2 }, + { name: 'J119', rating: 2 }, + { name: 'J120', rating: 2 }, + { name: 'J121', rating: 2 }, + { name: 'J122', rating: 2 }, + { name: 'J123', rating: 2 }, + { name: 'J124', rating: 2 }, + { name: 'J125', rating: 2 }, + { name: 'J126', rating: 2 }, + { name: 'J127', rating: 2 }, + { name: 'J128', rating: 2 }, + { name: 'J129', rating: 2 }, + { name: 'J130', rating: 2 }, + { name: 'J131', rating: 2 }, + { name: 'J132', rating: 2 }, + { name: 'J133', rating: 2 }, + { name: 'J134', rating: 2 }, + { name: 'J135', rating: 2 }, + { name: 'J136', rating: 2 }, + { name: 'J137', rating: 2 }, + { name: 'J138', rating: 2 }, + { name: 'J139', rating: 2 }, + { name: 'J140', rating: 2 }, + { name: 'J141', rating: 2 }, + { name: 'J142', rating: 2 }, + { name: 'J143', rating: 2 }, + { name: 'J144', rating: 2 }, + { name: 'J145', rating: 2 }, + { name: 'J146', rating: 2 }, + { name: 'J147', rating: 2 }, + { name: 'J148', rating: 2 }, + { name: 'J149', rating: 2 }, + { name: 'J150', rating: 2 }, + { name: 'J151', rating: 2 }, + { name: 'J152', rating: 2 }, + { name: 'J153', rating: 2 }, + { name: 'J154', rating: 2 }, + { name: 'J155', rating: 2 }, + { name: 'J156', rating: 2 }, + { name: 'J157', rating: 2 }, + { name: 'J158', rating: 2 }, + { name: 'J159', rating: 2 }, + { name: 'J160', rating: 2 }, + { name: 'J161', rating: 2 }, + { name: 'J162', rating: 2 }, + { name: 'J163', rating: 2 }, + { name: 'J164', rating: 2 }, + { name: 'J165', rating: 2 }, + { name: 'J166', rating: 2 }, + { name: 'J167', rating: 2 }, + { name: 'J168', rating: 2 }, + { name: 'J169', rating: 2 }, + { name: 'J170', rating: 2 }, + { name: 'J171', rating: 2 }, + { name: 'J172', rating: 2 }, + { name: 'J173', rating: 2 }, + { name: 'J174', rating: 2 }, + { name: 'J175', rating: 2 }, + { name: 'J176', rating: 2 }, + { name: 'J177', rating: 2 }, + { name: 'J178', rating: 2 }, + { name: 'J179', rating: 2 }, + { name: 'J180', rating: 2 }, + { name: 'J181', rating: 2 }, + { name: 'J182', rating: 2 }, + { name: 'J183', rating: 2 }, + { name: 'J184', rating: 2 }, + { name: 'J185', rating: 2 }, + { name: 'J186', rating: 2 }, + { name: 'K000', rating: 2 }, + { name: 'K001', rating: 2 }, + { name: 'K002', rating: 2 }, + { name: 'K003', rating: 2 }, + { name: 'K004', rating: 2 }, + { name: 'K005', rating: 2 }, + { name: 'K006', rating: 2 }, + { name: 'K007', rating: 2 }, + { name: 'K008', rating: 2 }, + { name: 'K009', rating: 2 }, + { name: 'K010', rating: 2 }, + { name: 'K011', rating: 2 }, + { name: 'K012', rating: 2 }, + { name: 'K013', rating: 2 }, + { name: 'K014', rating: 2 }, + { name: 'K015', rating: 2 }, + { name: 'K016', rating: 2 }, + { name: 'K017', rating: 2 }, + { name: 'K018', rating: 2 }, + { name: 'K019', rating: 2 }, + { name: 'K020', rating: 2 }, + { name: 'K021', rating: 2 }, + { name: 'K022', rating: 2 }, + { name: 'K023', rating: 2 }, + { name: 'K024', rating: 2 }, + { name: 'K025', rating: 2 }, + { name: 'K026', rating: 2 }, + { name: 'K027', rating: 2 }, + { name: 'K028', rating: 2 }, + { name: 'K029', rating: 2 }, + { name: 'K030', rating: 2 }, + { name: 'K031', rating: 2 }, + { name: 'K032', rating: 2 }, + { name: 'K033', rating: 2 }, + { name: 'K034', rating: 2 }, + { name: 'K035', rating: 2 }, + { name: 'K036', rating: 2 }, + { name: 'K037', rating: 2 }, + { name: 'K038', rating: 2 }, + { name: 'K039', rating: 2 }, + { name: 'K040', rating: 2 }, + { name: 'K041', rating: 2 }, + { name: 'K042', rating: 2 }, + { name: 'K043', rating: 2 }, + { name: 'K044', rating: 2 }, + { name: 'K045', rating: 2 }, + { name: 'K046', rating: 2 }, + { name: 'K047', rating: 2 }, + { name: 'K048', rating: 2 }, + { name: 'K049', rating: 2 }, + { name: 'K050', rating: 2 }, + { name: 'K051', rating: 2 }, + { name: 'K052', rating: 2 }, + { name: 'K053', rating: 2 }, + { name: 'K054', rating: 2 }, + { name: 'K055', rating: 2 }, + { name: 'K056', rating: 2 }, + { name: 'K057', rating: 2 }, + { name: 'K058', rating: 2 }, + { name: 'K059', rating: 2 }, + { name: 'K060', rating: 2 }, + { name: 'K061', rating: 2 }, + { name: 'K062', rating: 2 }, + { name: 'K063', rating: 2 }, + { name: 'K064', rating: 2 }, + { name: 'K065', rating: 2 }, + { name: 'K066', rating: 2 }, + { name: 'K067', rating: 2 }, + { name: 'K068', rating: 2 }, + { name: 'K069', rating: 2 }, + { name: 'K070', rating: 2 }, + { name: 'K071', rating: 2 }, + { name: 'K072', rating: 2 }, + { name: 'K073', rating: 2 }, + { name: 'K074', rating: 2 }, + { name: 'K075', rating: 2 }, + { name: 'K076', rating: 2 }, + { name: 'K077', rating: 2 }, + { name: 'K078', rating: 2 }, + { name: 'K079', rating: 2 }, + { name: 'K080', rating: 2 }, + { name: 'K081', rating: 2 }, + { name: 'K082', rating: 2 }, + { name: 'K083', rating: 2 }, + { name: 'K084', rating: 2 }, + { name: 'K085', rating: 2 }, + { name: 'K086', rating: 2 }, + { name: 'K087', rating: 2 }, + { name: 'K088', rating: 2 }, + { name: 'K089', rating: 2 }, + { name: 'K090', rating: 2 }, + { name: 'K091', rating: 2 }, + { name: 'K092', rating: 2 }, + { name: 'K093', rating: 2 }, + { name: 'K094', rating: 2 }, + { name: 'K095', rating: 2 }, + { name: 'K096', rating: 2 }, + { name: 'K097', rating: 2 }, + { name: 'K098', rating: 2 }, + { name: 'K099', rating: 2 }, + { name: 'K100', rating: 2 }, + { name: 'K101', rating: 2 }, + { name: 'K102', rating: 2 }, + { name: 'K103', rating: 2 }, + { name: 'K104', rating: 2 }, + { name: 'K105', rating: 2 }, + { name: 'K106', rating: 2 }, + { name: 'K107', rating: 2 }, + { name: 'K108', rating: 2 }, + { name: 'K109', rating: 2 }, + { name: 'K110', rating: 2 }, + { name: 'K111', rating: 2 }, + { name: 'K112', rating: 2 }, + { name: 'K113', rating: 2 }, + { name: 'K114', rating: 2 }, + { name: 'K115', rating: 2 }, + { name: 'K116', rating: 2 }, + { name: 'K117', rating: 2 }, + { name: 'K118', rating: 2 }, + { name: 'K119', rating: 2 }, + { name: 'K120', rating: 2 }, + { name: 'K121', rating: 2 }, + { name: 'K122', rating: 2 }, + { name: 'K123', rating: 2 }, + { name: 'K124', rating: 2 }, + { name: 'K125', rating: 2 }, + { name: 'K126', rating: 2 }, + { name: 'K127', rating: 2 }, + { name: 'K128', rating: 2 }, + { name: 'K129', rating: 2 }, + { name: 'K130', rating: 2 }, + { name: 'K131', rating: 2 }, + { name: 'K132', rating: 2 }, + { name: 'K133', rating: 2 }, + { name: 'K134', rating: 2 }, + { name: 'K135', rating: 2 }, + { name: 'K136', rating: 2 }, + { name: 'K137', rating: 2 }, + { name: 'K138', rating: 2 }, + { name: 'K139', rating: 2 }, + { name: 'K140', rating: 2 }, + { name: 'K141', rating: 2 }, + { name: 'K142', rating: 2 }, + { name: 'K143', rating: 2 }, + { name: 'K144', rating: 2 }, + { name: 'K145', rating: 2 }, + { name: 'K146', rating: 2 }, + { name: 'K147', rating: 2 }, + { name: 'K148', rating: 2 }, + { name: 'K149', rating: 2 }, + { name: 'K150', rating: 2 }, + { name: 'K151', rating: 2 }, + { name: 'K152', rating: 2 }, + { name: 'K153', rating: 2 }, + { name: 'K154', rating: 2 }, + { name: 'K155', rating: 2 }, + { name: 'K156', rating: 2 }, + { name: 'K157', rating: 2 }, + { name: 'K158', rating: 2 }, + { name: 'K159', rating: 2 }, + { name: 'K160', rating: 2 }, + { name: 'K161', rating: 2 }, + { name: 'K162', rating: 2 }, + { name: 'K163', rating: 2 }, + { name: 'K164', rating: 2 }, + { name: 'K165', rating: 2 }, + { name: 'K166', rating: 2 }, + { name: 'K167', rating: 2 }, + { name: 'K168', rating: 2 }, + { name: 'K169', rating: 2 }, + { name: 'K170', rating: 2 }, + { name: 'K171', rating: 2 }, + { name: 'K172', rating: 2 }, + { name: 'K173', rating: 2 }, + { name: 'K174', rating: 2 }, + { name: 'K175', rating: 2 }, + { name: 'K176', rating: 2 }, + { name: 'K177', rating: 2 }, +]; +assert.sameValue(array.length, 2048); +// Sort the elements by `rating` in descending order. +// (This updates `array` in place.) +array.sort((a, b) => b.rating - a.rating); +const reduced = array.reduce((acc, element) => { + const letter = element.name.slice(0, 1); + const previousLetter = acc.slice(-1); + if (previousLetter === letter) { + return acc; + } + return acc + letter; +}, ''); +assert.sameValue(reduced, 'DGBEFHACIJK'); diff --git a/test/sendable/builtins/Array/prototype/sort/stability-5-elements.js b/test/sendable/builtins/Array/prototype/sort/stability-5-elements.js new file mode 100644 index 00000000000..d0da47dd572 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/stability-5-elements.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Stability of Array.prototype.sort for an array with 5 elements. +info: | + The sort is required to be stable (that is, elements that compare equal + remain in their original order). +---*/ + +const array = new SendableArray[ + { name: 'A', rating: 2 }, + { name: 'B', rating: 3 }, + { name: 'C', rating: 2 }, + { name: 'D', rating: 3 }, + { name: 'E', rating: 3 }, +]; +assert.sameValue(array.length, 5); +// Sort the elements by `rating` in descending order. +// (This updates `array` in place.) +array.sort((a, b) => b.rating - a.rating); +const reduced = array.reduce((acc, element) => acc + element.name, ''); +assert.sameValue(reduced, 'BDEAC'); diff --git a/test/sendable/builtins/Array/prototype/sort/stability-513-elements.js b/test/sendable/builtins/Array/prototype/sort/stability-513-elements.js new file mode 100644 index 00000000000..0d0f72abb19 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/sort/stability-513-elements.js @@ -0,0 +1,555 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.sort +description: > + Stability of Array.prototype.sort for an array with 513 elements. +info: | + The sort is required to be stable (that is, elements that compare equal + remain in their original order). + The array length of 513 was chosen because until late 2018, Chakra + used to apply an unstable QuickSort for arrays with more than 512 + elements, although it used a stable insertion sort for anything else. + https://github.com/Microsoft/ChakraCore/pull/5724 +---*/ + +const array = new SendableArray[ + { name: 'A00', rating: 2 }, + { name: 'A01', rating: 2 }, + { name: 'A02', rating: 2 }, + { name: 'A03', rating: 2 }, + { name: 'A04', rating: 2 }, + { name: 'A05', rating: 2 }, + { name: 'A06', rating: 2 }, + { name: 'A07', rating: 2 }, + { name: 'A08', rating: 2 }, + { name: 'A09', rating: 2 }, + { name: 'A10', rating: 2 }, + { name: 'A11', rating: 2 }, + { name: 'A12', rating: 2 }, + { name: 'A13', rating: 2 }, + { name: 'A14', rating: 2 }, + { name: 'A15', rating: 2 }, + { name: 'A16', rating: 2 }, + { name: 'A17', rating: 2 }, + { name: 'A18', rating: 2 }, + { name: 'A19', rating: 2 }, + { name: 'A20', rating: 2 }, + { name: 'A21', rating: 2 }, + { name: 'A22', rating: 2 }, + { name: 'A23', rating: 2 }, + { name: 'A24', rating: 2 }, + { name: 'A25', rating: 2 }, + { name: 'A26', rating: 2 }, + { name: 'A27', rating: 2 }, + { name: 'A28', rating: 2 }, + { name: 'A29', rating: 2 }, + { name: 'A30', rating: 2 }, + { name: 'A31', rating: 2 }, + { name: 'A32', rating: 2 }, + { name: 'A33', rating: 2 }, + { name: 'A34', rating: 2 }, + { name: 'A35', rating: 2 }, + { name: 'A36', rating: 2 }, + { name: 'A37', rating: 2 }, + { name: 'A38', rating: 2 }, + { name: 'A39', rating: 2 }, + { name: 'A40', rating: 2 }, + { name: 'A41', rating: 2 }, + { name: 'A42', rating: 2 }, + { name: 'A43', rating: 2 }, + { name: 'A44', rating: 2 }, + { name: 'A45', rating: 2 }, + { name: 'A46', rating: 2 }, + { name: 'B00', rating: 3 }, + { name: 'B01', rating: 3 }, + { name: 'B02', rating: 3 }, + { name: 'B03', rating: 3 }, + { name: 'B04', rating: 3 }, + { name: 'B05', rating: 3 }, + { name: 'B06', rating: 3 }, + { name: 'B07', rating: 3 }, + { name: 'B08', rating: 3 }, + { name: 'B09', rating: 3 }, + { name: 'B10', rating: 3 }, + { name: 'B11', rating: 3 }, + { name: 'B12', rating: 3 }, + { name: 'B13', rating: 3 }, + { name: 'B14', rating: 3 }, + { name: 'B15', rating: 3 }, + { name: 'B16', rating: 3 }, + { name: 'B17', rating: 3 }, + { name: 'B18', rating: 3 }, + { name: 'B19', rating: 3 }, + { name: 'B20', rating: 3 }, + { name: 'B21', rating: 3 }, + { name: 'B22', rating: 3 }, + { name: 'B23', rating: 3 }, + { name: 'B24', rating: 3 }, + { name: 'B25', rating: 3 }, + { name: 'B26', rating: 3 }, + { name: 'B27', rating: 3 }, + { name: 'B28', rating: 3 }, + { name: 'B29', rating: 3 }, + { name: 'B30', rating: 3 }, + { name: 'B31', rating: 3 }, + { name: 'B32', rating: 3 }, + { name: 'B33', rating: 3 }, + { name: 'B34', rating: 3 }, + { name: 'B35', rating: 3 }, + { name: 'B36', rating: 3 }, + { name: 'B37', rating: 3 }, + { name: 'B38', rating: 3 }, + { name: 'B39', rating: 3 }, + { name: 'B40', rating: 3 }, + { name: 'B41', rating: 3 }, + { name: 'B42', rating: 3 }, + { name: 'B43', rating: 3 }, + { name: 'B44', rating: 3 }, + { name: 'B45', rating: 3 }, + { name: 'B46', rating: 3 }, + { name: 'C00', rating: 2 }, + { name: 'C01', rating: 2 }, + { name: 'C02', rating: 2 }, + { name: 'C03', rating: 2 }, + { name: 'C04', rating: 2 }, + { name: 'C05', rating: 2 }, + { name: 'C06', rating: 2 }, + { name: 'C07', rating: 2 }, + { name: 'C08', rating: 2 }, + { name: 'C09', rating: 2 }, + { name: 'C10', rating: 2 }, + { name: 'C11', rating: 2 }, + { name: 'C12', rating: 2 }, + { name: 'C13', rating: 2 }, + { name: 'C14', rating: 2 }, + { name: 'C15', rating: 2 }, + { name: 'C16', rating: 2 }, + { name: 'C17', rating: 2 }, + { name: 'C18', rating: 2 }, + { name: 'C19', rating: 2 }, + { name: 'C20', rating: 2 }, + { name: 'C21', rating: 2 }, + { name: 'C22', rating: 2 }, + { name: 'C23', rating: 2 }, + { name: 'C24', rating: 2 }, + { name: 'C25', rating: 2 }, + { name: 'C26', rating: 2 }, + { name: 'C27', rating: 2 }, + { name: 'C28', rating: 2 }, + { name: 'C29', rating: 2 }, + { name: 'C30', rating: 2 }, + { name: 'C31', rating: 2 }, + { name: 'C32', rating: 2 }, + { name: 'C33', rating: 2 }, + { name: 'C34', rating: 2 }, + { name: 'C35', rating: 2 }, + { name: 'C36', rating: 2 }, + { name: 'C37', rating: 2 }, + { name: 'C38', rating: 2 }, + { name: 'C39', rating: 2 }, + { name: 'C40', rating: 2 }, + { name: 'C41', rating: 2 }, + { name: 'C42', rating: 2 }, + { name: 'C43', rating: 2 }, + { name: 'C44', rating: 2 }, + { name: 'C45', rating: 2 }, + { name: 'C46', rating: 2 }, + { name: 'D00', rating: 4 }, + { name: 'D01', rating: 4 }, + { name: 'D02', rating: 4 }, + { name: 'D03', rating: 4 }, + { name: 'D04', rating: 4 }, + { name: 'D05', rating: 4 }, + { name: 'D06', rating: 4 }, + { name: 'D07', rating: 4 }, + { name: 'D08', rating: 4 }, + { name: 'D09', rating: 4 }, + { name: 'D10', rating: 4 }, + { name: 'D11', rating: 4 }, + { name: 'D12', rating: 4 }, + { name: 'D13', rating: 4 }, + { name: 'D14', rating: 4 }, + { name: 'D15', rating: 4 }, + { name: 'D16', rating: 4 }, + { name: 'D17', rating: 4 }, + { name: 'D18', rating: 4 }, + { name: 'D19', rating: 4 }, + { name: 'D20', rating: 4 }, + { name: 'D21', rating: 4 }, + { name: 'D22', rating: 4 }, + { name: 'D23', rating: 4 }, + { name: 'D24', rating: 4 }, + { name: 'D25', rating: 4 }, + { name: 'D26', rating: 4 }, + { name: 'D27', rating: 4 }, + { name: 'D28', rating: 4 }, + { name: 'D29', rating: 4 }, + { name: 'D30', rating: 4 }, + { name: 'D31', rating: 4 }, + { name: 'D32', rating: 4 }, + { name: 'D33', rating: 4 }, + { name: 'D34', rating: 4 }, + { name: 'D35', rating: 4 }, + { name: 'D36', rating: 4 }, + { name: 'D37', rating: 4 }, + { name: 'D38', rating: 4 }, + { name: 'D39', rating: 4 }, + { name: 'D40', rating: 4 }, + { name: 'D41', rating: 4 }, + { name: 'D42', rating: 4 }, + { name: 'D43', rating: 4 }, + { name: 'D44', rating: 4 }, + { name: 'D45', rating: 4 }, + { name: 'D46', rating: 4 }, + { name: 'E00', rating: 3 }, + { name: 'E01', rating: 3 }, + { name: 'E02', rating: 3 }, + { name: 'E03', rating: 3 }, + { name: 'E04', rating: 3 }, + { name: 'E05', rating: 3 }, + { name: 'E06', rating: 3 }, + { name: 'E07', rating: 3 }, + { name: 'E08', rating: 3 }, + { name: 'E09', rating: 3 }, + { name: 'E10', rating: 3 }, + { name: 'E11', rating: 3 }, + { name: 'E12', rating: 3 }, + { name: 'E13', rating: 3 }, + { name: 'E14', rating: 3 }, + { name: 'E15', rating: 3 }, + { name: 'E16', rating: 3 }, + { name: 'E17', rating: 3 }, + { name: 'E18', rating: 3 }, + { name: 'E19', rating: 3 }, + { name: 'E20', rating: 3 }, + { name: 'E21', rating: 3 }, + { name: 'E22', rating: 3 }, + { name: 'E23', rating: 3 }, + { name: 'E24', rating: 3 }, + { name: 'E25', rating: 3 }, + { name: 'E26', rating: 3 }, + { name: 'E27', rating: 3 }, + { name: 'E28', rating: 3 }, + { name: 'E29', rating: 3 }, + { name: 'E30', rating: 3 }, + { name: 'E31', rating: 3 }, + { name: 'E32', rating: 3 }, + { name: 'E33', rating: 3 }, + { name: 'E34', rating: 3 }, + { name: 'E35', rating: 3 }, + { name: 'E36', rating: 3 }, + { name: 'E37', rating: 3 }, + { name: 'E38', rating: 3 }, + { name: 'E39', rating: 3 }, + { name: 'E40', rating: 3 }, + { name: 'E41', rating: 3 }, + { name: 'E42', rating: 3 }, + { name: 'E43', rating: 3 }, + { name: 'E44', rating: 3 }, + { name: 'E45', rating: 3 }, + { name: 'E46', rating: 3 }, + { name: 'F00', rating: 3 }, + { name: 'F01', rating: 3 }, + { name: 'F02', rating: 3 }, + { name: 'F03', rating: 3 }, + { name: 'F04', rating: 3 }, + { name: 'F05', rating: 3 }, + { name: 'F06', rating: 3 }, + { name: 'F07', rating: 3 }, + { name: 'F08', rating: 3 }, + { name: 'F09', rating: 3 }, + { name: 'F10', rating: 3 }, + { name: 'F11', rating: 3 }, + { name: 'F12', rating: 3 }, + { name: 'F13', rating: 3 }, + { name: 'F14', rating: 3 }, + { name: 'F15', rating: 3 }, + { name: 'F16', rating: 3 }, + { name: 'F17', rating: 3 }, + { name: 'F18', rating: 3 }, + { name: 'F19', rating: 3 }, + { name: 'F20', rating: 3 }, + { name: 'F21', rating: 3 }, + { name: 'F22', rating: 3 }, + { name: 'F23', rating: 3 }, + { name: 'F24', rating: 3 }, + { name: 'F25', rating: 3 }, + { name: 'F26', rating: 3 }, + { name: 'F27', rating: 3 }, + { name: 'F28', rating: 3 }, + { name: 'F29', rating: 3 }, + { name: 'F30', rating: 3 }, + { name: 'F31', rating: 3 }, + { name: 'F32', rating: 3 }, + { name: 'F33', rating: 3 }, + { name: 'F34', rating: 3 }, + { name: 'F35', rating: 3 }, + { name: 'F36', rating: 3 }, + { name: 'F37', rating: 3 }, + { name: 'F38', rating: 3 }, + { name: 'F39', rating: 3 }, + { name: 'F40', rating: 3 }, + { name: 'F41', rating: 3 }, + { name: 'F42', rating: 3 }, + { name: 'F43', rating: 3 }, + { name: 'F44', rating: 3 }, + { name: 'F45', rating: 3 }, + { name: 'F46', rating: 3 }, + { name: 'G00', rating: 4 }, + { name: 'G01', rating: 4 }, + { name: 'G02', rating: 4 }, + { name: 'G03', rating: 4 }, + { name: 'G04', rating: 4 }, + { name: 'G05', rating: 4 }, + { name: 'G06', rating: 4 }, + { name: 'G07', rating: 4 }, + { name: 'G08', rating: 4 }, + { name: 'G09', rating: 4 }, + { name: 'G10', rating: 4 }, + { name: 'G11', rating: 4 }, + { name: 'G12', rating: 4 }, + { name: 'G13', rating: 4 }, + { name: 'G14', rating: 4 }, + { name: 'G15', rating: 4 }, + { name: 'G16', rating: 4 }, + { name: 'G17', rating: 4 }, + { name: 'G18', rating: 4 }, + { name: 'G19', rating: 4 }, + { name: 'G20', rating: 4 }, + { name: 'G21', rating: 4 }, + { name: 'G22', rating: 4 }, + { name: 'G23', rating: 4 }, + { name: 'G24', rating: 4 }, + { name: 'G25', rating: 4 }, + { name: 'G26', rating: 4 }, + { name: 'G27', rating: 4 }, + { name: 'G28', rating: 4 }, + { name: 'G29', rating: 4 }, + { name: 'G30', rating: 4 }, + { name: 'G31', rating: 4 }, + { name: 'G32', rating: 4 }, + { name: 'G33', rating: 4 }, + { name: 'G34', rating: 4 }, + { name: 'G35', rating: 4 }, + { name: 'G36', rating: 4 }, + { name: 'G37', rating: 4 }, + { name: 'G38', rating: 4 }, + { name: 'G39', rating: 4 }, + { name: 'G40', rating: 4 }, + { name: 'G41', rating: 4 }, + { name: 'G42', rating: 4 }, + { name: 'G43', rating: 4 }, + { name: 'G44', rating: 4 }, + { name: 'G45', rating: 4 }, + { name: 'G46', rating: 4 }, + { name: 'H00', rating: 3 }, + { name: 'H01', rating: 3 }, + { name: 'H02', rating: 3 }, + { name: 'H03', rating: 3 }, + { name: 'H04', rating: 3 }, + { name: 'H05', rating: 3 }, + { name: 'H06', rating: 3 }, + { name: 'H07', rating: 3 }, + { name: 'H08', rating: 3 }, + { name: 'H09', rating: 3 }, + { name: 'H10', rating: 3 }, + { name: 'H11', rating: 3 }, + { name: 'H12', rating: 3 }, + { name: 'H13', rating: 3 }, + { name: 'H14', rating: 3 }, + { name: 'H15', rating: 3 }, + { name: 'H16', rating: 3 }, + { name: 'H17', rating: 3 }, + { name: 'H18', rating: 3 }, + { name: 'H19', rating: 3 }, + { name: 'H20', rating: 3 }, + { name: 'H21', rating: 3 }, + { name: 'H22', rating: 3 }, + { name: 'H23', rating: 3 }, + { name: 'H24', rating: 3 }, + { name: 'H25', rating: 3 }, + { name: 'H26', rating: 3 }, + { name: 'H27', rating: 3 }, + { name: 'H28', rating: 3 }, + { name: 'H29', rating: 3 }, + { name: 'H30', rating: 3 }, + { name: 'H31', rating: 3 }, + { name: 'H32', rating: 3 }, + { name: 'H33', rating: 3 }, + { name: 'H34', rating: 3 }, + { name: 'H35', rating: 3 }, + { name: 'H36', rating: 3 }, + { name: 'H37', rating: 3 }, + { name: 'H38', rating: 3 }, + { name: 'H39', rating: 3 }, + { name: 'H40', rating: 3 }, + { name: 'H41', rating: 3 }, + { name: 'H42', rating: 3 }, + { name: 'H43', rating: 3 }, + { name: 'H44', rating: 3 }, + { name: 'H45', rating: 3 }, + { name: 'H46', rating: 3 }, + { name: 'I00', rating: 2 }, + { name: 'I01', rating: 2 }, + { name: 'I02', rating: 2 }, + { name: 'I03', rating: 2 }, + { name: 'I04', rating: 2 }, + { name: 'I05', rating: 2 }, + { name: 'I06', rating: 2 }, + { name: 'I07', rating: 2 }, + { name: 'I08', rating: 2 }, + { name: 'I09', rating: 2 }, + { name: 'I10', rating: 2 }, + { name: 'I11', rating: 2 }, + { name: 'I12', rating: 2 }, + { name: 'I13', rating: 2 }, + { name: 'I14', rating: 2 }, + { name: 'I15', rating: 2 }, + { name: 'I16', rating: 2 }, + { name: 'I17', rating: 2 }, + { name: 'I18', rating: 2 }, + { name: 'I19', rating: 2 }, + { name: 'I20', rating: 2 }, + { name: 'I21', rating: 2 }, + { name: 'I22', rating: 2 }, + { name: 'I23', rating: 2 }, + { name: 'I24', rating: 2 }, + { name: 'I25', rating: 2 }, + { name: 'I26', rating: 2 }, + { name: 'I27', rating: 2 }, + { name: 'I28', rating: 2 }, + { name: 'I29', rating: 2 }, + { name: 'I30', rating: 2 }, + { name: 'I31', rating: 2 }, + { name: 'I32', rating: 2 }, + { name: 'I33', rating: 2 }, + { name: 'I34', rating: 2 }, + { name: 'I35', rating: 2 }, + { name: 'I36', rating: 2 }, + { name: 'I37', rating: 2 }, + { name: 'I38', rating: 2 }, + { name: 'I39', rating: 2 }, + { name: 'I40', rating: 2 }, + { name: 'I41', rating: 2 }, + { name: 'I42', rating: 2 }, + { name: 'I43', rating: 2 }, + { name: 'I44', rating: 2 }, + { name: 'I45', rating: 2 }, + { name: 'I46', rating: 2 }, + { name: 'J00', rating: 2 }, + { name: 'J01', rating: 2 }, + { name: 'J02', rating: 2 }, + { name: 'J03', rating: 2 }, + { name: 'J04', rating: 2 }, + { name: 'J05', rating: 2 }, + { name: 'J06', rating: 2 }, + { name: 'J07', rating: 2 }, + { name: 'J08', rating: 2 }, + { name: 'J09', rating: 2 }, + { name: 'J10', rating: 2 }, + { name: 'J11', rating: 2 }, + { name: 'J12', rating: 2 }, + { name: 'J13', rating: 2 }, + { name: 'J14', rating: 2 }, + { name: 'J15', rating: 2 }, + { name: 'J16', rating: 2 }, + { name: 'J17', rating: 2 }, + { name: 'J18', rating: 2 }, + { name: 'J19', rating: 2 }, + { name: 'J20', rating: 2 }, + { name: 'J21', rating: 2 }, + { name: 'J22', rating: 2 }, + { name: 'J23', rating: 2 }, + { name: 'J24', rating: 2 }, + { name: 'J25', rating: 2 }, + { name: 'J26', rating: 2 }, + { name: 'J27', rating: 2 }, + { name: 'J28', rating: 2 }, + { name: 'J29', rating: 2 }, + { name: 'J30', rating: 2 }, + { name: 'J31', rating: 2 }, + { name: 'J32', rating: 2 }, + { name: 'J33', rating: 2 }, + { name: 'J34', rating: 2 }, + { name: 'J35', rating: 2 }, + { name: 'J36', rating: 2 }, + { name: 'J37', rating: 2 }, + { name: 'J38', rating: 2 }, + { name: 'J39', rating: 2 }, + { name: 'J40', rating: 2 }, + { name: 'J41', rating: 2 }, + { name: 'J42', rating: 2 }, + { name: 'J43', rating: 2 }, + { name: 'J44', rating: 2 }, + { name: 'J45', rating: 2 }, + { name: 'J46', rating: 2 }, + { name: 'K00', rating: 2 }, + { name: 'K01', rating: 2 }, + { name: 'K02', rating: 2 }, + { name: 'K03', rating: 2 }, + { name: 'K04', rating: 2 }, + { name: 'K05', rating: 2 }, + { name: 'K06', rating: 2 }, + { name: 'K07', rating: 2 }, + { name: 'K08', rating: 2 }, + { name: 'K09', rating: 2 }, + { name: 'K10', rating: 2 }, + { name: 'K11', rating: 2 }, + { name: 'K12', rating: 2 }, + { name: 'K13', rating: 2 }, + { name: 'K14', rating: 2 }, + { name: 'K15', rating: 2 }, + { name: 'K16', rating: 2 }, + { name: 'K17', rating: 2 }, + { name: 'K18', rating: 2 }, + { name: 'K19', rating: 2 }, + { name: 'K20', rating: 2 }, + { name: 'K21', rating: 2 }, + { name: 'K22', rating: 2 }, + { name: 'K23', rating: 2 }, + { name: 'K24', rating: 2 }, + { name: 'K25', rating: 2 }, + { name: 'K26', rating: 2 }, + { name: 'K27', rating: 2 }, + { name: 'K28', rating: 2 }, + { name: 'K29', rating: 2 }, + { name: 'K30', rating: 2 }, + { name: 'K31', rating: 2 }, + { name: 'K32', rating: 2 }, + { name: 'K33', rating: 2 }, + { name: 'K34', rating: 2 }, + { name: 'K35', rating: 2 }, + { name: 'K36', rating: 2 }, + { name: 'K37', rating: 2 }, + { name: 'K38', rating: 2 }, + { name: 'K39', rating: 2 }, + { name: 'K40', rating: 2 }, + { name: 'K41', rating: 2 }, + { name: 'K42', rating: 2 }, +]; +assert.sameValue(array.length, 513); +// Sort the elements by `rating` in descending order. +// (This updates `array` in place.) +array.sort((a, b) => b.rating - a.rating); +const reduced = array.reduce((acc, element) => { + const letter = element.name.slice(0, 1); + const previousLetter = acc.slice(-1); + if (previousLetter === letter) { + return acc; + } + return acc + letter; +}, ''); +assert.sameValue(reduced, 'DGBEFHACIJK'); -- Gitee From f0ebaa418d3076b70caf4b8c0d29c5ab57333497 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 3 Jan 2025 09:51:02 +0800 Subject: [PATCH 68/93] modify case Signed-off-by: zhuzhihui7 --- .../builtins/Array/prototype/sort/stability-11-elements.js | 2 +- .../builtins/Array/prototype/sort/stability-2048-elements.js | 2 +- .../builtins/Array/prototype/sort/stability-5-elements.js | 2 +- .../builtins/Array/prototype/sort/stability-513-elements.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/sendable/builtins/Array/prototype/sort/stability-11-elements.js b/test/sendable/builtins/Array/prototype/sort/stability-11-elements.js index 1c7d8ac9f71..a4a0f027a26 100644 --- a/test/sendable/builtins/Array/prototype/sort/stability-11-elements.js +++ b/test/sendable/builtins/Array/prototype/sort/stability-11-elements.js @@ -24,7 +24,7 @@ info: | 2018). https://v8.dev/blog/array-sort ---*/ -const array = new SendableArray[ +const array = [ { name: 'A', rating: 2 }, { name: 'B', rating: 3 }, { name: 'C', rating: 2 }, diff --git a/test/sendable/builtins/Array/prototype/sort/stability-2048-elements.js b/test/sendable/builtins/Array/prototype/sort/stability-2048-elements.js index 851760ab283..03070e37b8d 100644 --- a/test/sendable/builtins/Array/prototype/sort/stability-2048-elements.js +++ b/test/sendable/builtins/Array/prototype/sort/stability-2048-elements.js @@ -25,7 +25,7 @@ info: | https://github.com/Microsoft/ChakraCore/pull/5724/files#diff-85203ec16f5961eb4c18e4253bb42140R337 ---*/ -const array = new SendableArray[ +const array = [ { name: 'A000', rating: 2 }, { name: 'A001', rating: 2 }, { name: 'A002', rating: 2 }, diff --git a/test/sendable/builtins/Array/prototype/sort/stability-5-elements.js b/test/sendable/builtins/Array/prototype/sort/stability-5-elements.js index d0da47dd572..4d4c1624095 100644 --- a/test/sendable/builtins/Array/prototype/sort/stability-5-elements.js +++ b/test/sendable/builtins/Array/prototype/sort/stability-5-elements.js @@ -21,7 +21,7 @@ info: | remain in their original order). ---*/ -const array = new SendableArray[ +const array = [ { name: 'A', rating: 2 }, { name: 'B', rating: 3 }, { name: 'C', rating: 2 }, diff --git a/test/sendable/builtins/Array/prototype/sort/stability-513-elements.js b/test/sendable/builtins/Array/prototype/sort/stability-513-elements.js index 0d0f72abb19..82267d1ac33 100644 --- a/test/sendable/builtins/Array/prototype/sort/stability-513-elements.js +++ b/test/sendable/builtins/Array/prototype/sort/stability-513-elements.js @@ -25,7 +25,7 @@ info: | https://github.com/Microsoft/ChakraCore/pull/5724 ---*/ -const array = new SendableArray[ +const array = [ { name: 'A00', rating: 2 }, { name: 'A01', rating: 2 }, { name: 'A02', rating: 2 }, -- Gitee From 3699acadbc153d5effaafe7abedac4f0f8e74674 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 3 Jan 2025 10:39:22 +0800 Subject: [PATCH 69/93] add array-splice Signed-off-by: zhuzhihui7 --- .../Array/prototype/splice/15.4.4.12-9-a-1.js | 25 +++++++ .../prototype/splice/15.4.4.12-9-c-ii-1.js | 44 ++++++++++++ .../prototype/splice/S15.4.4.12_A1.1_T1.js | 46 ++++++++++++ .../prototype/splice/S15.4.4.12_A1.1_T2.js | 52 ++++++++++++++ .../prototype/splice/S15.4.4.12_A1.1_T3.js | 46 ++++++++++++ .../prototype/splice/S15.4.4.12_A1.1_T4.js | 52 ++++++++++++++ .../prototype/splice/S15.4.4.12_A1.1_T5.js | 46 ++++++++++++ .../prototype/splice/S15.4.4.12_A1.1_T6.js | 52 ++++++++++++++ .../prototype/splice/S15.4.4.12_A1.2_T1.js | 40 +++++++++++ .../prototype/splice/S15.4.4.12_A1.2_T2.js | 40 +++++++++++ .../prototype/splice/S15.4.4.12_A1.2_T3.js | 46 ++++++++++++ .../prototype/splice/S15.4.4.12_A1.2_T4.js | 46 ++++++++++++ .../prototype/splice/S15.4.4.12_A1.2_T5.js | 46 ++++++++++++ .../prototype/splice/S15.4.4.12_A1.3_T1.js | 40 +++++++++++ .../prototype/splice/S15.4.4.12_A1.3_T2.js | 40 +++++++++++ .../prototype/splice/S15.4.4.12_A1.3_T3.js | 46 ++++++++++++ .../prototype/splice/S15.4.4.12_A1.3_T4.js | 46 ++++++++++++ .../prototype/splice/S15.4.4.12_A1.3_T5.js | 46 ++++++++++++ .../prototype/splice/S15.4.4.12_A1.4_T1.js | 46 ++++++++++++ .../prototype/splice/S15.4.4.12_A1.4_T2.js | 52 ++++++++++++++ .../prototype/splice/S15.4.4.12_A1.4_T3.js | 46 ++++++++++++ .../prototype/splice/S15.4.4.12_A1.4_T4.js | 52 ++++++++++++++ .../prototype/splice/S15.4.4.12_A1.4_T5.js | 46 ++++++++++++ .../prototype/splice/S15.4.4.12_A1.4_T6.js | 52 ++++++++++++++ .../prototype/splice/S15.4.4.12_A1.5_T1.js | 44 ++++++++++++ .../prototype/splice/S15.4.4.12_A1.5_T2.js | 44 ++++++++++++ .../prototype/splice/S15.4.4.12_A2.1_T1.js | 44 ++++++++++++ .../prototype/splice/S15.4.4.12_A2.1_T2.js | 44 ++++++++++++ .../prototype/splice/S15.4.4.12_A2.1_T3.js | 41 +++++++++++ .../prototype/splice/S15.4.4.12_A2.1_T4.js | 44 ++++++++++++ .../prototype/splice/S15.4.4.12_A2.1_T5.js | 51 ++++++++++++++ .../prototype/splice/S15.4.4.12_A2.2_T1.js | 44 ++++++++++++ .../prototype/splice/S15.4.4.12_A2.2_T2.js | 38 ++++++++++ .../prototype/splice/S15.4.4.12_A2.2_T3.js | 44 ++++++++++++ .../prototype/splice/S15.4.4.12_A2.2_T4.js | 38 ++++++++++ .../prototype/splice/S15.4.4.12_A2.2_T5.js | 51 ++++++++++++++ .../prototype/splice/S15.4.4.12_A2_T1.js | 64 +++++++++++++++++ .../prototype/splice/S15.4.4.12_A2_T2.js | 56 +++++++++++++++ .../prototype/splice/S15.4.4.12_A2_T3.js | 56 +++++++++++++++ .../prototype/splice/S15.4.4.12_A2_T4.js | 64 +++++++++++++++++ .../prototype/splice/S15.4.4.12_A3_T1.js | 41 +++++++++++ .../prototype/splice/S15.4.4.12_A3_T3.js | 37 ++++++++++ .../prototype/splice/S15.4.4.12_A4_T1.js | 69 ++++++++++++++++++ .../prototype/splice/S15.4.4.12_A4_T2.js | 70 +++++++++++++++++++ .../prototype/splice/S15.4.4.12_A4_T3.js | 63 +++++++++++++++++ .../prototype/splice/S15.4.4.12_A6.1_T1.js | 31 ++++++++ .../prototype/splice/S15.4.4.12_A6.1_T2.js | 27 +++++++ .../prototype/splice/S15.4.4.12_A6.1_T3.js | 34 +++++++++ .../prototype/splice/call-with-boolean.js | 22 ++++++ .../splice/called_with_one_argument.js | 31 ++++++++ .../splice/clamps-length-to-integer-limit.js | 34 +++++++++ .../splice/create-ctor-non-object.js | 40 +++++++++++ .../prototype/splice/create-ctor-poisoned.js | 28 ++++++++ .../splice/create-non-array-invalid-len.js | 37 ++++++++++ .../prototype/splice/create-non-array.js | 34 +++++++++ .../create-proto-from-ctor-realm-array.js | 34 +++++++++ .../create-proto-from-ctor-realm-non-array.js | 35 ++++++++++ .../Array/prototype/splice/create-proxy.js | 27 +++++++ .../prototype/splice/create-revoked-proxy.js | 31 ++++++++ .../prototype/splice/create-species-abrupt.js | 28 ++++++++ ...-species-length-exceeding-integer-limit.js | 69 ++++++++++++++++++ .../splice/create-species-neg-zero.js | 29 ++++++++ .../splice/create-species-non-ctor.js | 31 ++++++++ .../prototype/splice/create-species-null.js | 28 ++++++++ .../splice/create-species-poisoned.js | 30 ++++++++ .../create-species-undef-invalid-len.js | 45 ++++++++++++ .../prototype/splice/create-species-undef.js | 29 ++++++++ .../Array/prototype/splice/create-species.js | 38 ++++++++++ ...and-deleteCount-exceeding-integer-limit.js | 41 +++++++++++ ...th-exceeding-integer-limit-shrink-array.js | 47 +++++++++++++ .../length-near-integer-limit-grow-array.js | 48 +++++++++++++ .../builtins/Array/prototype/splice/length.js | 38 ++++++++++ .../builtins/Array/prototype/splice/name.js | 36 ++++++++++ .../prototype/splice/not-a-constructor.js | 38 ++++++++++ .../Array/prototype/splice/prop-desc.js | 32 +++++++++ .../property-traps-order-with-species.js | 43 ++++++++++++ .../prototype/splice/set_length_no_args.js | 42 +++++++++++ .../splice/target-array-non-extensible.js | 31 ++++++++ ...et-array-with-non-configurable-property.js | 33 +++++++++ ...target-array-with-non-writable-property.js | 33 +++++++++ .../throws-if-integer-limit-exceeded.js | 45 ++++++++++++ 81 files changed, 3419 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/splice/15.4.4.12-9-a-1.js create mode 100644 test/sendable/builtins/Array/prototype/splice/15.4.4.12-9-c-ii-1.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T2.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T3.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T4.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T5.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T6.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T3.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T4.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T5.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T1.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T2.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T3.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T4.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T5.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T1.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T2.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T3.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T4.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T5.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T6.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.5_T1.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.5_T2.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T2.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T3.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T4.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T5.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T3.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T4.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T5.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T3.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T4.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A3_T1.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A3_T3.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A4_T1.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A4_T2.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A4_T3.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A6.1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A6.1_T2.js create mode 100644 test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A6.1_T3.js create mode 100644 test/sendable/builtins/Array/prototype/splice/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/splice/called_with_one_argument.js create mode 100644 test/sendable/builtins/Array/prototype/splice/clamps-length-to-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-ctor-non-object.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-ctor-poisoned.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-non-array-invalid-len.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-non-array.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-proto-from-ctor-realm-array.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-proto-from-ctor-realm-non-array.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-proxy.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-revoked-proxy.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-species-abrupt.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-species-length-exceeding-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-species-neg-zero.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-species-non-ctor.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-species-null.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-species-poisoned.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-species-undef-invalid-len.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-species-undef.js create mode 100644 test/sendable/builtins/Array/prototype/splice/create-species.js create mode 100644 test/sendable/builtins/Array/prototype/splice/length-and-deleteCount-exceeding-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/splice/length-exceeding-integer-limit-shrink-array.js create mode 100644 test/sendable/builtins/Array/prototype/splice/length-near-integer-limit-grow-array.js create mode 100644 test/sendable/builtins/Array/prototype/splice/length.js create mode 100644 test/sendable/builtins/Array/prototype/splice/name.js create mode 100644 test/sendable/builtins/Array/prototype/splice/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/splice/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/splice/property-traps-order-with-species.js create mode 100644 test/sendable/builtins/Array/prototype/splice/set_length_no_args.js create mode 100644 test/sendable/builtins/Array/prototype/splice/target-array-non-extensible.js create mode 100644 test/sendable/builtins/Array/prototype/splice/target-array-with-non-configurable-property.js create mode 100644 test/sendable/builtins/Array/prototype/splice/target-array-with-non-writable-property.js create mode 100644 test/sendable/builtins/Array/prototype/splice/throws-if-integer-limit-exceeded.js diff --git a/test/sendable/builtins/Array/prototype/splice/15.4.4.12-9-a-1.js b/test/sendable/builtins/Array/prototype/splice/15.4.4.12-9-a-1.js new file mode 100644 index 00000000000..9b4d3faf62e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/15.4.4.12-9-a-1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + Array.prototype.splice - 'from' is the result of + ToString(actualStart+k) in an Array +---*/ + +var arrObj = [1, 2, 3]; +var newArrObj = arrObj.splice(-2, 1); +assert.sameValue(newArrObj.length, 1, 'newArrObj.length'); +assert.sameValue(newArrObj[0], 2, 'newArrObj[0]'); diff --git a/test/sendable/builtins/Array/prototype/splice/15.4.4.12-9-c-ii-1.js b/test/sendable/builtins/Array/prototype/splice/15.4.4.12-9-c-ii-1.js new file mode 100644 index 00000000000..d40f5353a5b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/15.4.4.12-9-c-ii-1.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + Array.prototype.splice will splice an array even when + Array.prototype has index '0' set to read-only and 'fromPresent' + less than 'actualDeleteCount (Step 9.c.ii) +---*/ + +var arr = ["a", "b", "c"]; +SendableArray.prototype[0] = "test"; +var newArr = arr.splice(2, 1, "d"); +var verifyValue = false; +verifyValue = arr.length === 3 && arr[0] === "a" && arr[1] === "b" && arr[2] === "d" && + newArr[0] === "c" && newArr.length === 1; +var verifyEnumerable = false; +for (var p in newArr) { + if (newArr.hasOwnProperty("0") && p === "0") { + verifyEnumerable = true; + } +} +var verifyWritable = false; +newArr[0] = 12; +verifyWritable = newArr[0] === 12; +var verifyConfigurable = false; +delete newArr[0]; +verifyConfigurable = newArr.hasOwnProperty("0"); +assert(verifyValue, 'verifyValue !== true'); +assert.sameValue(verifyConfigurable, false, 'verifyConfigurable'); +assert(verifyEnumerable, 'verifyEnumerable !== true'); +assert(verifyWritable, 'verifyWritable !== true'); diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T1.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T1.js new file mode 100644 index 00000000000..d8d02696a2a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T1.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length > deleteCount > start = 0, itemCount = 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(0, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(0,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(0,3); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(0,3); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(0,3); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(0,3); arr[2] === 2. Actual: ' + (arr[2])); +} +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(0,3); x.length === 1. Actual: ' + (x.length)); +} +if (x[0] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(0,3); x[0] === 3. Actual: ' + (x[0])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T2.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T2.js new file mode 100644 index 00000000000..d01fad6be71 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T2.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length > deleteCount > start = 0, itemCount > 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(0, 3, 4, 5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); arr[2] === 2. Actual: ' + (arr[2])); +} +if (x.length !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); x.length === 3. Actual: ' + (x.length)); +} +if (x[0] !== 4) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); x[0] === 4. Actual: ' + (x[0])); +} +if (x[1] !== 5) { + throw new Test262Error('#8: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); x[1] === 5. Actual: ' + (x[1])); +} +if (x[2] !== 3) { + throw new Test262Error('#9: var x = [0,1,2,3]; var arr = x.splice(0,3,4,5); x[2] === 3. Actual: ' + (x[2])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T3.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T3.js new file mode 100644 index 00000000000..7d4d45796d6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T3.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length = deleteCount > start = 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(0, 4); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(0,4); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 4) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(0,4); arr.length === 4. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(0,4); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(0,4); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(0,4); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(0,4); arr[3] === 3. Actual: ' + (arr[3])); +} +if (x.length !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(0,4); x.length === 0. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T4.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T4.js new file mode 100644 index 00000000000..f288423e97e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T4.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length > deleteCount > start > 0, itemCount > 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(1, 3, 4, 5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 1) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr[0] === 1. Actual: ' + (arr[0])); +} +if (arr[1] !== 2) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr[1] === 2. Actual: ' + (arr[1])); +} +if (arr[2] !== 3) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); arr[2] === 3. Actual: ' + (arr[2])); +} +if (x.length !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); x.length === 3. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 4) { + throw new Test262Error('#8: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); x[1] === 4. Actual: ' + (x[1])); +} +if (x[2] !== 5) { + throw new Test262Error('#9: var x = [0,1,2,3]; var arr = x.splice(1,3,4,5); x[2] === 5. Actual: ' + (x[2])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T5.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T5.js new file mode 100644 index 00000000000..f12d55e90e3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T5.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: deleteCount > length > start = 0, itemCount = 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(0, 5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(0,5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 4) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(0,5); arr.length === 4. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(0,5); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(0,5); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(0,5); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(0,5); arr[3] === 3. Actual: ' + (arr[3])); +} +if (x.length !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(0,5); x.length === 0. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T6.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T6.js new file mode 100644 index 00000000000..c428a619197 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.1_T6.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length = deleteCount > start > 0, itemCount > 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(1, 4, 4, 5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 1) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr[0] === 1. Actual: ' + (arr[0])); +} +if (arr[1] !== 2) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr[1] === 2. Actual: ' + (arr[1])); +} +if (arr[2] !== 3) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); arr[2] === 3. Actual: ' + (arr[2])); +} +if (x.length !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); x.length === 3. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 4) { + throw new Test262Error('#8: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); x[1] === 4. Actual: ' + (x[1])); +} +if (x[2] !== 5) { + throw new Test262Error('#9: var x = [0,1,2,3]; var arr = x.splice(1,4,4,5); x[2] === 5. Actual: ' + (x[2])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T1.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T1.js new file mode 100644 index 00000000000..a5f577c0b64 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T1.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length = start < deleteCount < 0, itemCount = 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(-2, -1); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(-2,-1); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(-2,-1); arr.length === 0. Actual: ' + (arr.length)); +} +if (x.length !== 2) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(-2,-1); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(-2,-1); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(-2,-1); x[1] === 1. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T2.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T2.js new file mode 100644 index 00000000000..b63c6e72dbe --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T2.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length < start = deleteCount < 0, itemCount = 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(-1, -1); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(-1,-1); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(-1,-1); arr.length === 0. Actual: ' + (arr.length)); +} +if (x.length !== 2) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(-1,-1); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(-1,-1); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(-1,-1); x[1] === 1. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T3.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T3.js new file mode 100644 index 00000000000..442a068d2d4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T3.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length = start < deleteCount < 0, itemCount > 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(-2, -1, 2, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(-2,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(-2,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} +if (x.length !== 4) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(-2,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} +if (x[0] !== 2) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(-2,-1,2,3); x[0] === 2. Actual: ' + (x[0])); +} +if (x[1] !== 3) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(-2,-1,2,3); x[1] === 3. Actual: ' + (x[1])); +} +if (x[2] !== 0) { + throw new Test262Error('#5: var x = [0,1]; var arr = x.splice(-2,-1,2,3); x[2] === 0. Actual: ' + (x[2])); +} +if (x[3] !== 1) { + throw new Test262Error('#6: var x = [0,1]; var arr = x.splice(-2,-1,2,3); x[3] === 1. Actual: ' + (x[3])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T4.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T4.js new file mode 100644 index 00000000000..11461eee381 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T4.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length < start = deleteCount < 0, itemCount > 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(-1, -1, 2, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(-1,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(-1,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} +if (x.length !== 4) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(-1,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(-1,-1,2,3); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 2) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(-1,-1,2,3); x[1] === 2. Actual: ' + (x[1])); +} +if (x[2] !== 3) { + throw new Test262Error('#5: var x = [0,1]; var arr = x.splice(-1,-1,2,3); x[2] === 3. Actual: ' + (x[2])); +} +if (x[3] !== 1) { + throw new Test262Error('#6: var x = [0,1]; var arr = x.splice(-1,-1,2,3); x[3] === 1. Actual: ' + (x[3])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T5.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T5.js new file mode 100644 index 00000000000..a68a5c119ff --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.2_T5.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: start < -length < deleteCount < 0, itemCount > 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(-3, -1, 2, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(-3,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(-3,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} +if (x.length !== 4) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(-3,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} +if (x[0] !== 2) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(-3,-1,2,3); x[0] === 2. Actual: ' + (x[0])); +} +if (x[1] !== 3) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(-3,-1,2,3); x[1] === 3. Actual: ' + (x[1])); +} +if (x[2] !== 0) { + throw new Test262Error('#5: var x = [0,1]; var arr = x.splice(-3,-1,2,3); x[2] === 0. Actual: ' + (x[2])); +} +if (x[3] !== 1) { + throw new Test262Error('#6: var x = [0,1]; var arr = x.splice(-3,-1,2,3); x[3] === 1. Actual: ' + (x[3])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T1.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T1.js new file mode 100644 index 00000000000..b56c626b73a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T1.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length < deleteCount < start = 0, itemCount = 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(0, -1); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(0,-1); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(0,-1); arr.length === 0. Actual: ' + (arr.length)); +} +if (x.length !== 2) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(0,-1); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(0,-1); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(0,-1); x[1] === 1. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T2.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T2.js new file mode 100644 index 00000000000..a27910b4437 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T2.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length = -start < deleteCount < 0, itemCount = 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(2, -1); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(2,-1); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(2,-1); arr.length === 0. Actual: ' + (arr.length)); +} +if (x.length !== 2) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(2,-1); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(2,-1); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(2,-1); x[1] === 1. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T3.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T3.js new file mode 100644 index 00000000000..96d4bb6b4bf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T3.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length < deleteCount < start = 0, itemCount > 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(0, -1, 2, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(0,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(0,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} +if (x.length !== 4) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(0,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} +if (x[0] !== 2) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(0,-1,2,3); x[0] === 2. Actual: ' + (x[0])); +} +if (x[1] !== 3) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(0,-1,2,3); x[1] === 3. Actual: ' + (x[1])); +} +if (x[2] !== 0) { + throw new Test262Error('#5: var x = [0,1]; var arr = x.splice(0,-1,2,3); x[2] === 0. Actual: ' + (x[2])); +} +if (x[3] !== 1) { + throw new Test262Error('#6: var x = [0,1]; var arr = x.splice(0,-1,2,3); x[3] === 1. Actual: ' + (x[3])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T4.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T4.js new file mode 100644 index 00000000000..a61cc2aa3a5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T4.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -length = -start < deleteCount < 0, itemCount > 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(2, -1, 2, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(2,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(2,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} +if (x.length !== 4) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(2,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(2,-1,2,3); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(2,-1,2,3); x[1] === 1. Actual: ' + (x[1])); +} +if (x[2] !== 2) { + throw new Test262Error('#5: var x = [0,1]; var arr = x.splice(2,-1,2,3); x[2] === 2. Actual: ' + (x[2])); +} +if (x[3] !== 3) { + throw new Test262Error('#6: var x = [0,1]; var arr = x.splice(2,-1,2,3); x[3] === 3. Actual: ' + (x[3])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T5.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T5.js new file mode 100644 index 00000000000..24e602547e7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.3_T5.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is positive, use min(start, length). + If deleteCount is negative, use 0 +esid: sec-array.prototype.splice +description: -start < -length < deleteCount < 0, itemCount > 0 +---*/ + +var x = [0, 1]; +var arr = x.splice(3, -1, 2, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(3,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(3,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} +if (x.length !== 4) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(3,-1,2,3); x.length === 4. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(3,-1,2,3); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(3,-1,2,3); x[1] === 1. Actual: ' + (x[1])); +} +if (x[2] !== 2) { + throw new Test262Error('#5: var x = [0,1]; var arr = x.splice(3,-1,2,3); x[2] === 2. Actual: ' + (x[2])); +} +if (x[3] !== 3) { + throw new Test262Error('#6: var x = [0,1]; var arr = x.splice(3,-1,2,3); x[3] === 3. Actual: ' + (x[3])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T1.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T1.js new file mode 100644 index 00000000000..9d30278c2e0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T1.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length = -start > deleteCount > 0, itemCount = 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(-4, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(-4,3); arr[2] === 2. Actual: ' + (arr[2])); +} +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(-4,3); x.length === 1. Actual: ' + (x.length)); +} +if (x[0] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(-4,3); x[0] === 3. Actual: ' + (x[0])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T2.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T2.js new file mode 100644 index 00000000000..882da8ef1f9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T2.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length = -start > deleteCount > 0, itemCount > 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(-4, 3, 4, 5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); arr[2] === 2. Actual: ' + (arr[2])); +} +if (x.length !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); x.length === 3. Actual: ' + (x.length)); +} +if (x[0] !== 4) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); x[0] === 4. Actual: ' + (x[0])); +} +if (x[1] !== 5) { + throw new Test262Error('#8: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); x[1] === 5. Actual: ' + (x[1])); +} +if (x[2] !== 3) { + throw new Test262Error('#9: var x = [0,1,2,3]; var arr = x.splice(-4,3,4,5); x[2] === 3. Actual: ' + (x[2])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T3.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T3.js new file mode 100644 index 00000000000..b73e229c93f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T3.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: -start > length = deleteCount > 0, itemCount = 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(-5, 4); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 4) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr.length === 4. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(-5,4); arr[3] === 3. Actual: ' + (arr[3])); +} +if (x.length !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(-5,4); x.length === 0. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T4.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T4.js new file mode 100644 index 00000000000..647c3798950 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T4.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length > -start = deleteCount > 0, itemCount > 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(-3, 3, 4, 5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 1) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr[0] === 1. Actual: ' + (arr[0])); +} +if (arr[1] !== 2) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr[1] === 2. Actual: ' + (arr[1])); +} +if (arr[2] !== 3) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); arr[2] === 3. Actual: ' + (arr[2])); +} +if (x.length !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); x.length === 3. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 4) { + throw new Test262Error('#8: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); x[1] === 4. Actual: ' + (x[1])); +} +if (x[2] !== 5) { + throw new Test262Error('#9: var x = [0,1,2,3]; var arr = x.splice(-3,3,4,5); x[2] === 5. Actual: ' + (x[2])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T5.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T5.js new file mode 100644 index 00000000000..38fa59c3100 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T5.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: -start > deleteCount > length > 0, itemCount = 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(-9, 5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 4) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr.length === 4. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(-9,5); arr[3] === 3. Actual: ' + (arr[3])); +} +if (x.length !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(-9,5); x.length === 0. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T6.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T6.js new file mode 100644 index 00000000000..75ffc42df3c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.4_T6.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If start is negative, use max(start + length, 0). + If deleteCount is positive, use min(deleteCount, length - start) +esid: sec-array.prototype.splice +description: length = deleteCount > -start > 0, itemCount > 0 +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(-3, 4, 4, 5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 1) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr[0] === 1. Actual: ' + (arr[0])); +} +if (arr[1] !== 2) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr[1] === 2. Actual: ' + (arr[1])); +} +if (arr[2] !== 3) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); arr[2] === 3. Actual: ' + (arr[2])); +} +if (x.length !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); x.length === 3. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 4) { + throw new Test262Error('#8: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); x[1] === 4. Actual: ' + (x[1])); +} +if (x[2] !== 5) { + throw new Test262Error('#9: var x = [0,1,2,3]; var arr = x.splice(-3,4,4,5); x[2] === 5. Actual: ' + (x[2])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.5_T1.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.5_T1.js new file mode 100644 index 00000000000..7f4778e6902 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.5_T1.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Splice with undefined arguments +esid: sec-array.prototype.splice +description: start === undefined, end === undefined +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(undefined, undefined); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); arr.length === 0. Actual: ' + (arr.length)); +} +if (x.length !== 4) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); x.length === 4. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); x[1] === 1. Actual: ' + (x[1])); +} +if (x[2] !== 2) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); x[2] === 2. Actual: ' + (x[2])); +} +if (x[3] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(undefined, undefined); x[3] === 3. Actual: ' + (x[3])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.5_T2.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.5_T2.js new file mode 100644 index 00000000000..9fe8fc521de --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A1.5_T2.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Splice with undefined arguments +esid: sec-array.prototype.splice +description: end === undefined +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(1, undefined); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(1,undefined); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(1,undefined); arr.length === 0. Actual: ' + (arr.length)); +} +if (x.length !== 4) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(1,undefined); x.length === 4. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(1,undefined); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(1,undefined); x[1] === 1. Actual: ' + (x[1])); +} +if (x[2] !== 2) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(1,undefined); x[2] === 2. Actual: ' + (x[2])); +} +if (x[3] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(1,undefined); x[3] === 3. Actual: ' + (x[3])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T1.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T1.js new file mode 100644 index 00000000000..d5bb2dc41ee --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T1.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.splice +description: start is not integer +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(1.5, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 1) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr[0] === 1. Actual: ' + (arr[0])); +} +if (arr[1] !== 2) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr[1] === 2. Actual: ' + (arr[1])); +} +if (arr[2] !== 3) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(1.5,3); arr[2] === 3. Actual: ' + (arr[2])); +} +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(1.5,3); x.length === 1. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(1.5,3); x[0] === 0. Actual: ' + (x[0])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T2.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T2.js new file mode 100644 index 00000000000..895463049f1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T2.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.splice +description: start = NaN +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(NaN, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(NaN,3); arr[2] === 2. Actual: ' + (arr[2])); +} +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(NaN,3); x.length === 1. Actual: ' + (x.length)); +} +if (x[0] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(NaN,3); x[0] === 3. Actual: ' + (x[0])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T3.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T3.js new file mode 100644 index 00000000000..f3176e81f0a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T3.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.splice +description: start = Infinity +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(Number.POSITIVE_INFINITY, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(Number.POSITIVE_INFINITY,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(Number.POSITIVE_INFINITY,3); arr.length === 0. Actual: ' + (arr.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var x = x.splice(Number.POSITIVE_INFINITY,3); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var x = x.splice(Number.POSITIVE_INFINITY,3); x[1] === 1. Actual: ' + (x[1])); +} +if (x[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var x = x.splice(Number.POSITIVE_INFINITY,3); x[2] === 2. Actual: ' + (x[2])); +} +if (x[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var x = x.splice(Number.POSITIVE_INFINITY,3); x[3] === 3. Actual: ' + (x[3])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T4.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T4.js new file mode 100644 index 00000000000..407bf7ed84f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T4.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.splice +description: start = -Infinity +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(Number.NEGATIVE_INFINITY, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); arr[2] === 2. Actual: ' + (arr[2])); +} +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); x.length === 1. Actual: ' + (x.length)); +} +if (x[0] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(Number.NEGATIVE_INFINITY,3); x[0] === 3. Actual: ' + (x[0])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T5.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T5.js new file mode 100644 index 00000000000..b8e5be100b5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.1_T5.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from start +esid: sec-array.prototype.splice +description: ToInteger use ToNumber +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice({ + valueOf: function() { + return 0 + }, + toString: function() { + return 3 + } +}, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice({valueOf: function() {return 0}, toString: function() {return 3}},3); arr[2] === 2. Actual: ' + (arr[2])); +} +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice({valueOf: function() {return 0}, toString: function() {return 3}},3); x.length === 1. Actual: ' + (x.length)); +} +if (x[0] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice({valueOf: function() {return 0}, toString: function() {return 3}},3); x[0] === 3. Actual: ' + (x[0])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T1.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T1.js new file mode 100644 index 00000000000..5749771bd24 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T1.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from deleteCount +esid: sec-array.prototype.splice +description: deleteCount is not integer +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(1, 3.5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 1) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr[0] === 1. Actual: ' + (arr[0])); +} +if (arr[1] !== 2) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr[1] === 2. Actual: ' + (arr[1])); +} +if (arr[2] !== 3) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(1,3.5); arr[2] === 3. Actual: ' + (arr[2])); +} +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(1,3.5); x.length === 1. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(1,3.5); x[0] === 0. Actual: ' + (x[0])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T2.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T2.js new file mode 100644 index 00000000000..1e2545523f0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T2.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from deleteCount +esid: sec-array.prototype.splice +description: deleteCount = NaN +---*/ + +var x = [0, 1]; +var arr = x.splice(0, NaN); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(0,NaN); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(0,NaN); arr.length === 0. Actual: ' + (arr.length)); +} +if (x.length !== 2) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(0,NaN); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(0,NaN); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(0,NaN); x[1] === 1. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T3.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T3.js new file mode 100644 index 00000000000..c72c12c12ed --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T3.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from deleteCount +esid: sec-array.prototype.splice +description: deleteCount = Infinity +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(0, Number.POSITIVE_INFINITY); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 4) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr.length === 4. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr[2] === 2. Actual: ' + (arr[2])); +} +if (arr[3] !== 3) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); arr[3] === 3. Actual: ' + (arr[3])); +} +if (x.length !== 0) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(0,Number.POSITIVE_INFINITY); x.length === 0. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T4.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T4.js new file mode 100644 index 00000000000..b0d9c0af2f9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T4.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from deleteCount +esid: sec-array.prototype.splice +description: deleteCount = -Infinity +---*/ + +var x = [0, 1]; +var arr = x.splice(0, Number.NEGATIVE_INFINITY); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#0: var x = [0,1]; var arr = x.splice(0,Number.NEGATIVE_INFINITY); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#1: var x = [0,1]; var arr = x.splice(0,Number.NEGATIVE_INFINITY); arr.length === 0. Actual: ' + (arr.length)); +} +if (x.length !== 2) { + throw new Test262Error('#2: var x = [0,1]; var arr = x.splice(0,Number.NEGATIVE_INFINITY); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#3: var x = [0,1]; var arr = x.splice(0,Number.NEGATIVE_INFINITY); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#4: var x = [0,1]; var arr = x.splice(0,Number.NEGATIVE_INFINITY); x[1] === 1. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T5.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T5.js new file mode 100644 index 00000000000..a535879090e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2.2_T5.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Operator use ToInteger from deleteCount +esid: sec-array.prototype.splice +description: ToInteger use ToNumber +---*/ + +var x = [0, 1, 2, 3]; +var arr = x.splice(0, { + valueOf: function() { + return 3 + }, + toString: function() { + return 0 + } +}); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "Array" + "]") { + throw new Test262Error('#1: var x = [0,1,2,3]; var arr = x.splice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var x = [0,1,2,3]; var arr = x.splice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var x = [0,1,2,3]; var arr = x.splice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var x = [0,1,2,3]; var arr = x.splice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var x = [0,1,2,3]; var arr = x.splice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); arr[2] === 2. Actual: ' + (arr[2])); +} +if (x.length !== 1) { + throw new Test262Error('#6: var x = [0,1,2,3]; var arr = x.splice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); x.length === 1. Actual: ' + (x.length)); +} +if (x[0] !== 3) { + throw new Test262Error('#7: var x = [0,1,2,3]; var arr = x.splice(0,{valueOf: function() {return 3}, toString: function() {return 0}}); x[0] === 3. Actual: ' + (x[0])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T1.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T1.js new file mode 100644 index 00000000000..c515fb81b5d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T1.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The splice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.splice +description: > + If start is positive, use min(start, length). If deleteCount is + positive, use min(deleteCount, length - start) +---*/ + +var obj = { + 0: 0, + 1: 1, + 2: 2, + 3: 3 +}; +obj.length = 4; +obj.splice = SendableArray.prototype.splice; +var arr = obj.splice(0, 3, 4, 5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "SendableArray" + "]") { + throw new Test262Error('#1: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,3,4,5); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,3,4,5); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,3,4,5); arr[2] === 2. Actual: ' + (arr[2])); +} +if (obj.length !== 3) { + throw new Test262Error('#6: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,3,4,5); obj.length === 3. Actual: ' + (obj.length)); +} +if (obj[0] !== 4) { + throw new Test262Error('#7: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,3,4,5); obj[0] === 4. Actual: ' + (obj[0])); +} +if (obj[1] !== 5) { + throw new Test262Error('#8: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,3,4,5); obj[1] === 5. Actual: ' + (obj[1])); +} +if (obj[2] !== 3) { + throw new Test262Error('#9: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,3,4,5); obj[2] === 3. Actual: ' + (obj[2])); +} +if (obj[3] !== undefined) { + throw new Test262Error('#10: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,3,4,5); obj[3] === undefined. Actual: ' + (obj[3])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T2.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T2.js new file mode 100644 index 00000000000..620bf3e7974 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T2.js @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The splice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.splice +description: > + If start is negative, use max(start + length, 0). If deleteCount + is negative, use 0 +---*/ + +var obj = { + 0: 0, + 1: 1 +}; +obj.length = 2; +obj.splice = SendableArray.prototype.splice; +var arr = obj.splice(-2, -1, 2, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "SendableArray" + "]") { + throw new Test262Error('#0: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-2,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#1: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-2,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} +if (obj.length !== 4) { + throw new Test262Error('#2: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-2,-1,2,3); obj.length === 4. Actual: ' + (obj.length)); +} +if (obj[0] !== 2) { + throw new Test262Error('#3: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-2,-1,2,3); obj[0] === 2. Actual: ' + (obj[0])); +} +if (obj[1] !== 3) { + throw new Test262Error('#4: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-2,-1,2,3); obj[1] === 3. Actual: ' + (obj[1])); +} +if (obj[2] !== 0) { + throw new Test262Error('#5: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-2,-1,2,3); obj[2] === 0. Actual: ' + (obj[2])); +} +if (obj[3] !== 1) { + throw new Test262Error('#6: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-2,-1,2,3); obj[3] === 1. Actual: ' + (obj[3])); +} +if (obj[4] !== undefined) { + throw new Test262Error('#7: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-2,-1,2,3); obj[4] === undefined. Actual: ' + (obj[4])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T3.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T3.js new file mode 100644 index 00000000000..f52b216ab21 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T3.js @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The splice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.splice +description: > + If start is positive, use min(start, length). If deleteCount is + negative, use 0 +---*/ + +var obj = { + 0: 0, + 1: 1 +}; +obj.length = 2; +obj.splice = SendableArray.prototype.splice; +var arr = obj.splice(0, -1, 2, 3); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "SendableArray" + "]") { + throw new Test262Error('#0: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,-1,2,3); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 0) { + throw new Test262Error('#1: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,-1,2,3); arr.length === 0. Actual: ' + (arr.length)); +} +if (obj.length !== 4) { + throw new Test262Error('#2: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,-1,2,3); obj.length === 4. Actual: ' + (obj.length)); +} +if (obj[0] !== 2) { + throw new Test262Error('#3: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,-1,2,3); obj[0] === 2. Actual: ' + (obj[0])); +} +if (obj[1] !== 3) { + throw new Test262Error('#4: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,-1,2,3); obj[1] === 3. Actual: ' + (obj[1])); +} +if (obj[2] !== 0) { + throw new Test262Error('#5: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,-1,2,3); obj[2] === 0. Actual: ' + (obj[2])); +} +if (obj[3] !== 1) { + throw new Test262Error('#6: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,-1,2,3); obj[3] === 1. Actual: ' + (obj[3])); +} +if (obj[4] !== undefined) { + throw new Test262Error('#7: var obj = {0:0,1:1}; obj.length = 2; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(0,-1,2,3); obj[4] === undefined. Actual: ' + (obj[4])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T4.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T4.js new file mode 100644 index 00000000000..53a688a314e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A2_T4.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The splice function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.splice +description: > + If start is negative, use max(start + length, 0). If deleteCount + is positive, use min(deleteCount, length - start) +---*/ + +var obj = { + 0: 0, + 1: 1, + 2: 2, + 3: 3 +}; +obj.length = 4; +obj.splice = SendableArray.prototype.splice; +var arr = obj.splice(-4, 3, 4, 5); +arr.getClass = Object.prototype.toString; +if (arr.getClass() !== "[object " + "SendableArray" + "]") { + throw new Test262Error('#1: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-4,3,4,5); arr is Array object. Actual: ' + (arr.getClass())); +} +if (arr.length !== 3) { + throw new Test262Error('#2: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-4,3,4,5); arr.length === 3. Actual: ' + (arr.length)); +} +if (arr[0] !== 0) { + throw new Test262Error('#3: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-4,3,4,5); arr[0] === 0. Actual: ' + (arr[0])); +} +if (arr[1] !== 1) { + throw new Test262Error('#4: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-4,3,4,5); arr[1] === 1. Actual: ' + (arr[1])); +} +if (arr[2] !== 2) { + throw new Test262Error('#5: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-4,3,4,5); arr[2] === 2. Actual: ' + (arr[2])); +} +if (obj.length !== 3) { + throw new Test262Error('#6: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-4,3,4,5); obj.length === 3. Actual: ' + (obj.length)); +} +if (obj[0] !== 4) { + throw new Test262Error('#7: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-4,3,4,5); obj[0] === 4. Actual: ' + (obj[0])); +} +if (obj[1] !== 5) { + throw new Test262Error('#8: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-4,3,4,5); obj[1] === 5. Actual: ' + (obj[1])); +} +if (obj[2] !== 3) { + throw new Test262Error('#9: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-4,3,4,5); obj[2] === 3. Actual: ' + (obj[2])); +} +if (obj[3] !== undefined) { + throw new Test262Error('#10: var obj = {0:0,1:1,2:2,3:3}; obj.length = 4; obj.splice = SendableArray.prototype.splice; var arr = obj.splice(-4,3,4,5); obj[3] === undefined. Actual: ' + (obj[3])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A3_T1.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A3_T1.js new file mode 100644 index 00000000000..18e9f4ae7a1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A3_T1.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.splice +description: length is arbitrarily +---*/ + +var obj = {}; +obj.splice = SendableArray.prototype.splice; +obj[0] = "x"; +obj[4294967295] = "y"; +obj.length = 4294967296; +var arr = obj.splice(4294967295, 1); +if (arr.length !== 1) { + throw new Test262Error('#1: var obj = {}; obj.splice = SendableArray.prototype.splice; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; var arr = obj.splice(4294967295,1); arr.length === 1. Actual: ' + (arr.length)); +} +if (obj.length !== 4294967295) { + throw new Test262Error('#2: var obj = {}; obj.splice = SendableArray.prototype.splice; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; var arr = obj.splice(4294967295,1); obj.length === 4294967295. Actual: ' + (obj.length)); +} +if (obj[0] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.splice = SendableArray.prototype.splice; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; var arr = obj.splice(4294967295,1); obj[0] === "x". Actual: ' + (obj[0])); +} +if (obj[4294967295] !== undefined) { + throw new Test262Error('#4: var obj = {}; obj.splice = SendableArray.prototype.splice; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; var arr = obj.splice(4294967295,1); obj[4294967295] === undefined. Actual: ' + (obj[4294967295])); +} +if (arr[0] !== "y") { + throw new Test262Error('#5: var obj = {}; obj.splice = SendableArray.prototype.splice; obj[0] = "x"; obj[4294967295] = "y"; obj.length = 4294967296; var arr = obj.splice(4294967295,1); arr[0] === "y". Actual: ' + (arr[0])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A3_T3.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A3_T3.js new file mode 100644 index 00000000000..77570cb40ae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A3_T3.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.splice +description: length is arbitrarily +---*/ + +var obj = {}; +obj.splice = SendableArray.prototype.splice; +obj[4294967294] = "x"; +obj.length = -1; +var arr = obj.splice(4294967294, 1); +if (arr.length !== 0) { + throw new Test262Error('#1: var obj = {}; obj.splice = SendableArray.prototype.splice; obj[4294967294] = "x"; obj.length = -1; var arr = obj.splice(4294967294,1); arr.length === 0. Actual: ' + (arr.length)); +} +if (arr[0] !== undefined) { + throw new Test262Error('#2: var obj = {}; obj.splice = SendableArray.prototype.splice; obj[4294967294] = "x"; obj.length = 1; var arr = obj.splice(4294967294,1); arr[0] === undefined. Actual: ' + (arr[0])); +} +if (obj.length !== 0) { + throw new Test262Error('#3: var obj = {}; obj.splice = SendableArray.prototype.splice; obj[4294967294] = "x"; obj.length = 1; var arr = obj.splice(4294967294,1); obj.length === 0. Actual: ' + (obj.length)); +} +if (obj[4294967294] !== "x") { + throw new Test262Error('#4: var obj = {}; obj.splice = SendableArray.prototype.splice; obj[4294967294] = "x"; obj.length = 1; var arr = obj.splice(4294967294,1); obj[4294967294] === "x". Actual: ' + (obj[4294967294])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A4_T1.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A4_T1.js new file mode 100644 index 00000000000..69dc7cee3b5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A4_T1.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]] from not an inherited property" +esid: sec-array.prototype.splice +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +SendableArray.prototype[1] = -1; +var x = [0, 1]; +var arr = x.splice(1, 1); +if (arr.length !== 1) { + throw new Test262Error('#1: SendableArray.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); arr.length === 1. Actual: ' + (arr.length)); +} +if (arr[0] !== 1) { + throw new Test262Error('#2: SendableArray.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); arr[0] === 1. Actual: ' + (arr[0])); +} +if (arr[1] !== -1) { + throw new Test262Error('#3: SendableArray.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); arr[1] === -1. Actual: ' + (arr[1])); +} +if (x.length !== 1) { + throw new Test262Error('#4: SendableArray.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); x.length === 1. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#5: SendableArray.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== -1) { + throw new Test262Error('#6: SendableArray.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1); x[1] === -1. Actual: ' + (x[1])); +} +Object.prototype[1] = -1; +Object.prototype.length = 2; +Object.prototype.splice = SendableArray.prototype.splice; +x = { + 0: 0, + 1: 1 +}; +var arr = x.splice(1, 1); +if (arr.length !== 1) { + throw new Test262Error('#7: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = SendableArray.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1); arr.length === 1. Actual: ' + (arr.length)); +} +if (arr[0] !== 1) { + throw new Test262Error('#8: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = SendableArray.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1); arr[0] === 1. Actual: ' + (arr[0])); +} +if (arr[1] !== -1) { + throw new Test262Error('#9: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = SendableArray.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1); arr[1] === -1. Actual: ' + (arr[1])); +} +if (x.length !== 1) { + throw new Test262Error('#10: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = SendableArray.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1); x.length === 1. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#11: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = SendableArray.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== -1) { + throw new Test262Error('#12: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = SendableArray.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1); x[1] === -1. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A4_T2.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A4_T2.js new file mode 100644 index 00000000000..a5ea77c22e0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A4_T2.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]] from not an inherited property" +esid: sec-array.prototype.splice +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +SendableArray.prototype[1] = -1; +var x = [0, 1]; +var arr = x.splice(1, 1, 2); +if (arr.length !== 1) { + throw new Test262Error('#1: SendableArray.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); arr.length === 1. Actual: ' + (arr.length)); +} +if (arr[0] !== 1) { + throw new Test262Error('#2: SendableArray.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); arr[0] === 1. Actual: ' + (arr[0])); +} +if (arr[1] !== -1) { + throw new Test262Error('#3: SendableArray.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); arr[1] === -1. Actual: ' + (arr[1])); +} +if (x.length !== 2) { + throw new Test262Error('#4: SendableArray.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#5: SendableArray.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); x[0] === 0. Actual: ' + (x[0])); +} + +if (x[1] !== 2) { + throw new Test262Error('#6: SendableArray.prototype[1] = -1; x = [0,1]; var arr = x.splice(1,1,2); x[1] === 2. Actual: ' + (x[1])); +} +Object.prototype[1] = -1; +Object.prototype.length = 2; +Object.prototype.splice = SendableArray.prototype.splice; +x = { + 0: 0, + 1: 1 +}; +var arr = x.splice(1, 1, 2); +if (arr.length !== 1) { + throw new Test262Error('#7: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = SendableArray.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1,2); arr.length === 1. Actual: ' + (arr.length)); +} +if (arr[0] !== 1) { + throw new Test262Error('#8: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = SendableArray.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1,2); arr[0] === 1. Actual: ' + (arr[0])); +} +if (arr[1] !== -1) { + throw new Test262Error('#9: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = SendableArray.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1,2); arr[1] === -1. Actual: ' + (arr[1])); +} +if (x.length !== 2) { + throw new Test262Error('#10: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = SendableArray.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1,2); x.length === 2. Actual: ' + (x.length)); +} +if (x[0] !== 0) { + throw new Test262Error('#11: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = SendableArray.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1,2); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 2) { + throw new Test262Error('#12: Object.prototype[1] = -1; Object.prototype.length = 2; Object.prototype.splice = SendableArray.prototype.splice; x = {0:0, 1:1}; var arr = x.splice(1,1,2); x[1] === 2. Actual: ' + (x[1])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A4_T3.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A4_T3.js new file mode 100644 index 00000000000..1e4cd9e7079 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A4_T3.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]] from not an inherited property" +esid: sec-array.prototype.splice +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +SendableArray.prototype[0] = -1; +var x = []; +x.length = 1; +var arr = x.splice(0, 1); +if (arr.length !== 1) { + throw new Test262Error('#1: SendableArray.prototype[0] = -1; x = []; x.length = 1; var arr = x.splice(0,1); arr.length === 1. Actual: ' + (arr.length)); +} +if (arr[0] !== -1) { + throw new Test262Error('#2: SendableArray.prototype[0] = -1; x = []; x.length = 1; var arr = x.splice(0,1); arr[0] === -1. Actual: ' + (arr[0])); +} +delete arr[0]; +if (arr[0] !== -1) { + throw new Test262Error('#3: SendableArray.prototype[0] = -1; x = []; x.length = 1; var arr = x.splice(0,1); delete arr[0]; arr[0] === -1. Actual: ' + (arr[0])); +} +if (x.length !== 0) { + throw new Test262Error('#4: SendableArray.prototype[0] = -1; x = []; x.length = 1; var arr = x.splice(0,1); x.length === 0. Actual: ' + (x.length)); +} +if (x[0] !== -1) { + throw new Test262Error('#5: SendableArray.prototype[0] = -1; x = []; x.length = 1; var arr = x.splice(0,1); x[0] === -1. Actual: ' + (x[0])); +} +Object.prototype[0] = -1; +Object.prototype.length = 1; +Object.prototype.splice = SendableArray.prototype.splice; +x = {}; +var arr = x.splice(0, 1); +if (arr.length !== 1) { + throw new Test262Error('#6: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.splice = SendableArray.prototype.splice; x = {}; var arr = x.splice(0,1); arr.length === 1. Actual: ' + (arr.length)); +} +if (arr[0] !== -1) { + throw new Test262Error('#7: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.splice = SendableArray.prototype.splice; x = {}; var arr = x.splice(0,1); arr[0] === -1. Actual: ' + (arr[0])); +} +delete arr[0]; +if (arr[0] !== -1) { + throw new Test262Error('#8: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.splice = SendableArray.prototype.splice; x = {}; var arr = x.splice(0,1); delete arr[0]; arr[0] === -1. Actual: ' + (arr[0])); +} +if (x.length !== 0) { + throw new Test262Error('#9: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.splice = SendableArray.prototype.splice; x = {}; var arr = x.splice(0,1); x.length === 0. Actual: ' + (x.length)); +} +if (x[0] !== -1) { + throw new Test262Error('#10: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.splice = SendableArray.prototype.splice; x = {}; var arr = x.splice(0,1); x[0] === -1. Actual: ' + (x[0])); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A6.1_T1.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A6.1_T1.js new file mode 100644 index 00000000000..dbc07ca5405 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A6.1_T1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Array.prototype.splice sets `length` on `this` +esid: sec-array.prototype.splice +description: Array.prototype.splice sets `length` on Array +---*/ + +var a = [0, 1, 2]; +a.splice(1, 2, 4); +if (a.length !== 2) { + throw new Test262Error("Expected a.length === 2, actually " + a.length); +} +if (a[0] !== 0) { + throw new Test262Error("Expected a[0] === 0, actually " + a[0]); +} +if (a[1] !== 4) { + throw new Test262Error("Expected a[1] === 4, actually " + a[1]); +} diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A6.1_T2.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A6.1_T2.js new file mode 100644 index 00000000000..7703083393b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A6.1_T2.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Array.prototype.splice sets `length` on `this` +esid: sec-array.prototype.splice +description: Array.prototype.splice throws if `length` is read-only +---*/ + +var a = [0, 1, 2]; +Object.defineProperty(a, 'length', { + writable: false +}); +assert.throws(TypeError, function() { + a.splice(1, 2, 4); +}); diff --git a/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A6.1_T3.js b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A6.1_T3.js new file mode 100644 index 00000000000..3ddbcde1bf9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/S15.4.4.12_A6.1_T3.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Array.prototype.splice sets `length` on `this` +esid: sec-array.prototype.splice +description: Array.prototype.splice throws if `length` is read-only +---*/ + +var a = { + get length() { + return 0; + }, + splice: SendableArray.prototype.splice +}; +try { + a.splice(1, 2, 4); + throw new Test262Error("Expected a TypeError"); +} catch (e) { + if (!(e instanceof TypeError)) { + throw e; + } +} diff --git a/test/sendable/builtins/Array/prototype/splice/call-with-boolean.js b/test/sendable/builtins/Array/prototype/splice/call-with-boolean.js new file mode 100644 index 00000000000..9b7e3bce321 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/call-with-boolean.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: Array.prototype.splice applied to boolean primitive +includes: [compareArray.js] +---*/ + +assert.compareArray(SendableArray.prototype.splice.call(true), [], 'SendableArray.prototype.splice.call(true) must return []'); +assert.compareArray(SendableArray.prototype.splice.call(false), [], 'SendableArray.prototype.splice.call(false) must return []'); diff --git a/test/sendable/builtins/Array/prototype/splice/called_with_one_argument.js b/test/sendable/builtins/Array/prototype/splice/called_with_one_argument.js new file mode 100644 index 00000000000..d1d41bcda19 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/called_with_one_argument.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Array.prototype.splice deletes length-start elements when called with one argument +info: | + 22.1.3.25 Array.prototype.splice (start, deleteCount , ...items ) + 9. Else if the number of actual arguments is 1, then + a. Let insertCount be 0. + b. Let actualDeleteCount be len – actualStart. +esid: sec-array.prototype.splice +---*/ + +var array = ["first", "second", "third"]; +var result = array.splice(1); +assert.sameValue(array.length, 1, "array length updated"); +assert.sameValue(array[0], "first", "array[0] unchanged"); +assert.sameValue(result.length, 2, "result array length correct"); +assert.sameValue(result[0], "second", "result[0] correct"); +assert.sameValue(result[1], "third", "result[1] correct"); diff --git a/test/sendable/builtins/Array/prototype/splice/clamps-length-to-integer-limit.js b/test/sendable/builtins/Array/prototype/splice/clamps-length-to-integer-limit.js new file mode 100644 index 00000000000..60db8f3fc9f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/clamps-length-to-integer-limit.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + Length values exceeding 2^53-1 are clamped to 2^53-1. +features: [exponentiation] +---*/ + +var arrayLike = {}; +arrayLike.length = 2 ** 53 - 1; +SendableArray.prototype.splice.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53 - 1"); +arrayLike.length = 2 ** 53; +SendableArray.prototype.splice.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53"); +arrayLike.length = 2 ** 53 + 2; +SendableArray.prototype.splice.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53 + 2"); +arrayLike.length = Infinity; +SendableArray.prototype.splice.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is Infinity"); diff --git a/test/sendable/builtins/Array/prototype/splice/create-ctor-non-object.js b/test/sendable/builtins/Array/prototype/splice/create-ctor-non-object.js new file mode 100644 index 00000000000..cdc8725bac0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-ctor-non-object.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + Behavior when `constructor` property is neither an Object nor undefined +---*/ + +var a = []; +a.constructor = null; +assert.throws(TypeError, function() { + a.splice(); +}, 'null value'); +a = []; +a.constructor = 1; +assert.throws(TypeError, function() { + a.splice(); +}, 'number value'); +a = []; +a.constructor = 'string'; +assert.throws(TypeError, function() { + a.splice(); +}, 'string value'); +a = []; +a.constructor = true; +assert.throws(TypeError, function() { + a.splice(); +}, 'boolean value'); diff --git a/test/sendable/builtins/Array/prototype/splice/create-ctor-poisoned.js b/test/sendable/builtins/Array/prototype/splice/create-ctor-poisoned.js new file mode 100644 index 00000000000..23f8fb0e133 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-ctor-poisoned.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: Abrupt completion from `constructor` property access +---*/ + +var a = []; +Object.defineProperty(a, 'constructor', { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + a.splice(); +}); diff --git a/test/sendable/builtins/Array/prototype/splice/create-non-array-invalid-len.js b/test/sendable/builtins/Array/prototype/splice/create-non-array-invalid-len.js new file mode 100644 index 00000000000..6c37e5058ad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-non-array-invalid-len.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: Abrupt completion from creating a new array +---*/ + +var callCount = 0; +var maxLength = Math.pow(2, 32); +var obj = Object.defineProperty({}, 'length', { + get: function() { + return maxLength; + }, + set: function() { + callCount += 1; + } +}); +assert.throws(RangeError, function() { + SendableArray.prototype.splice.call(obj, 0); +}); +assert.sameValue( + callCount, + 0, + 'RangeError thrown during array creation, not property modification' +); diff --git a/test/sendable/builtins/Array/prototype/splice/create-non-array.js b/test/sendable/builtins/Array/prototype/splice/create-non-array.js new file mode 100644 index 00000000000..69bde84ac5a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-non-array.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: Constructor is ignored for non-Array values +---*/ + +var obj = { + length: 0 +}; +var callCount = 0; +var result; +Object.defineProperty(obj, 'constructor', { + get: function() { + callCount += 1; + } +}); +result = SendableArray.prototype.splice.call(obj); +assert.sameValue(callCount, 0, '`constructor` property not accessed'); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert(SendableArray.isArray(result), 'result is an SendableArray exotic object'); +assert.sameValue(result.length, 0, 'SendableArray created with appropriate length'); diff --git a/test/sendable/builtins/Array/prototype/splice/create-proto-from-ctor-realm-array.js b/test/sendable/builtins/Array/prototype/splice/create-proto-from-ctor-realm-array.js new file mode 100644 index 00000000000..6e112903e3a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-proto-from-ctor-realm-array.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: Prefer Array constructor of current realm record +---*/ + +var array = []; +var callCount = 0; +var OArray = $262.createRealm().global.SendableArray; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OArray; +Object.defineProperty(SendableArray, Symbol.species, speciesDesc); +Object.defineProperty(OArray, Symbol.species, speciesDesc); +result = array.splice(); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert.sameValue(callCount, 0, 'Species constructor is not referenced'); diff --git a/test/sendable/builtins/Array/prototype/splice/create-proto-from-ctor-realm-non-array.js b/test/sendable/builtins/Array/prototype/splice/create-proto-from-ctor-realm-non-array.js new file mode 100644 index 00000000000..98b9db1ba38 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-proto-from-ctor-realm-non-array.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: Accept non-Array constructors from other realms +---*/ + +var array = []; +var callCount = 0; +var CustomCtor = function() {}; +var OObject = $262.createRealm().global.Object; +var speciesDesc = { + get: function() { + callCount += 1; + } +}; +var result; +array.constructor = OObject; +OObject[Symbol.species] = CustomCtor; +Object.defineProperty(SendableArray, Symbol.species, speciesDesc); +result = array.splice(); +assert.sameValue(Object.getPrototypeOf(result), CustomCtor.prototype); +assert.sameValue(callCount, 0, 'SendableArray species constructor is not referenced'); diff --git a/test/sendable/builtins/Array/prototype/splice/create-proxy.js b/test/sendable/builtins/Array/prototype/splice/create-proxy.js new file mode 100644 index 00000000000..239313a3fc9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-proxy.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: Species constructor of a Proxy object whose target is an array +---*/ + +var array = []; +var proxy = new Proxy(new Proxy(array, {}), {}); +var Ctor = function() {}; +var result; +array.constructor = function() {}; +array.constructor[Symbol.species] = Ctor; +result = SendableArray.prototype.splice.call(proxy); +assert.sameValue(Object.getPrototypeOf(result), Ctor.prototype); diff --git a/test/sendable/builtins/Array/prototype/splice/create-revoked-proxy.js b/test/sendable/builtins/Array/prototype/splice/create-revoked-proxy.js new file mode 100644 index 00000000000..cc87325ecaa --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-revoked-proxy.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: Abrupt completion from constructor that is a revoked Proxy object +---*/ + +var o = Proxy.revocable([], {}); +var callCount = 0; +Object.defineProperty(o.proxy, 'constructor', { + get: function() { + callCount += 1; + } +}); +o.revoke(); +assert.throws(TypeError, function() { + SendableArray.prototype.splice.call(o.proxy); +}); +assert.sameValue(callCount, 0, '`constructor` property not accessed'); diff --git a/test/sendable/builtins/Array/prototype/splice/create-species-abrupt.js b/test/sendable/builtins/Array/prototype/splice/create-species-abrupt.js new file mode 100644 index 00000000000..63388d2351d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-species-abrupt.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: Species constructor returns an abrupt completion +---*/ + +var Ctor = function() { + throw new Test262Error(); +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; +assert.throws(Test262Error, function() { + a.splice(); +}); diff --git a/test/sendable/builtins/Array/prototype/splice/create-species-length-exceeding-integer-limit.js b/test/sendable/builtins/Array/prototype/splice/create-species-length-exceeding-integer-limit.js new file mode 100644 index 00000000000..f7a854c3dc3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-species-length-exceeding-integer-limit.js @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + Create species constructor with length exceeding integer limit and ensure MOP + operations are called in correct order. +---*/ + +function StopSplice() {} +var traps = []; +var targetLength; +var array = ["no-hole", /* hole */ , "stop"]; +array.constructor = { + [Symbol.species]: function(n) { + targetLength = n; + return target; + } +}; +var source = new Proxy(array, allowProxyTraps({ + get(t, pk, r) { + traps.push(`source.[[Get]]:${String(pk)}`); + // length property exceeding 2^53-1. + if (pk === "length") + return 2 ** 53 + 2; + return Reflect.get(t, pk, r); + }, + has(t, pk, r) { + traps.push(`source.[[Has]]:${String(pk)}`); + return Reflect.get(t, pk, r); + }, +})); +var target = new Proxy([], allowProxyTraps({ + defineProperty(t, pk, desc) { + traps.push(`target.[[DefineProperty]]:${String(pk)}`); + if (pk === "0" || pk === "1") + return Reflect.defineProperty(t, pk, desc); + throw new StopSplice(); + } +})); +assert.throws(StopSplice, function() { + // deleteCount argument exceeding 2^53-1. + SendableArray.prototype.splice.call(source, 0, 2 ** 53 + 4); +}, '// deleteCount argument exceeding 2^53-1. SendableArray.prototype.splice.call(source, 0, 2 ** 53 + 4) throws a StopSplice exception'); +assert.sameValue(targetLength, 2 ** 53 - 1, + 'The value of targetLength is expected to be 2 ** 53 - 1'); +assert.compareArray(traps, [ + "source.[[Get]]:length", + "source.[[Get]]:constructor", + "source.[[Has]]:0", + "source.[[Get]]:0", + "target.[[DefineProperty]]:0", + "source.[[Has]]:1", + "source.[[Has]]:2", + "source.[[Get]]:2", + "target.[[DefineProperty]]:2", +], 'The value of traps is expected to be [\n "source.[[Get]]:length",\n\n "source.[[Get]]:constructor",\n\n "source.[[Has]]:0",\n "source.[[Get]]:0",\n "target.[[DefineProperty]]:0",\n\n "source.[[Has]]:1",\n\n "source.[[Has]]:2",\n "source.[[Get]]:2",\n "target.[[DefineProperty]]:2",\n]'); diff --git a/test/sendable/builtins/Array/prototype/splice/create-species-neg-zero.js b/test/sendable/builtins/Array/prototype/splice/create-species-neg-zero.js new file mode 100644 index 00000000000..fef347099cd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-species-neg-zero.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: The value `-0` is converted to `0` +---*/ + +var args; +var Ctor = function() { + args = arguments; +}; +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; +a.splice(0, -0); +assert.sameValue(args.length, 1); +assert.sameValue(args[0], 0); diff --git a/test/sendable/builtins/Array/prototype/splice/create-species-non-ctor.js b/test/sendable/builtins/Array/prototype/splice/create-species-non-ctor.js new file mode 100644 index 00000000000..7fe3a72edad --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-species-non-ctor.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + Behavior when the @@species attribute is a non-constructor object +---*/ + +assert.sameValue( + isConstructor(parseInt), + false, + 'precondition: isConstructor(parseInt) must return false' +); +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = parseInt; +assert.throws(TypeError, function() { + a.splice(); +}, 'a.splice() throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/splice/create-species-null.js b/test/sendable/builtins/Array/prototype/splice/create-species-null.js new file mode 100644 index 00000000000..8dc29d81ff2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-species-null.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + A null value for the @@species constructor is interpreted as `undefined` +features: [Symbol.species] +---*/ + +var a = []; +var result; +a.constructor = {}; +a.constructor[Symbol.species] = null; +result = a.splice(); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert(SendableArray.isArray(result), 'result is an SendableArray exotic object'); diff --git a/test/sendable/builtins/Array/prototype/splice/create-species-poisoned.js b/test/sendable/builtins/Array/prototype/splice/create-species-poisoned.js new file mode 100644 index 00000000000..1537394b5d0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-species-poisoned.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: Abrupt completion from `@@species` property access +features: [Symbol.species] +---*/ + +var a = []; +a.constructor = {}; +Object.defineProperty(a.constructor, Symbol.species, { + get: function() { + throw new Test262Error(); + } +}); +assert.throws(Test262Error, function() { + a.splice(); +}); diff --git a/test/sendable/builtins/Array/prototype/splice/create-species-undef-invalid-len.js b/test/sendable/builtins/Array/prototype/splice/create-species-undef-invalid-len.js new file mode 100644 index 00000000000..9a8202ddf95 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-species-undef-invalid-len.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + An undefined value for the @@species constructor triggers the creation of + an Array exotic object +features: [Proxy] +---*/ + +var array = []; +var maxLength = Math.pow(2, 32); +var callCount = 0; +var proxy = new Proxy(array, { + get: function(_, name) { + if (name === 'length') { + return maxLength; + } + return array[name]; + }, + set: function() { + callCount += 1; + return true; + } +}); +assert.throws(RangeError, function() { + SendableArray.prototype.splice.call(proxy, 0); +}); +assert.sameValue( + callCount, + 0, + 'RangeError thrown during SendableArray creation, not property modification' +); diff --git a/test/sendable/builtins/Array/prototype/splice/create-species-undef.js b/test/sendable/builtins/Array/prototype/splice/create-species-undef.js new file mode 100644 index 00000000000..7fe6d840b42 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-species-undef.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + An undefined value for the @@species constructor triggers the creation of + an Array exotic object +features: [Symbol.species] +---*/ + +var a = []; +var result; +a.constructor = {}; +a.constructor[Symbol.species] = undefined; +result = a.splice(); +assert.sameValue(Object.getPrototypeOf(result), SendableArray.prototype); +assert(SendableArray.isArray(result), 'result is an SendableArray exotic object'); diff --git a/test/sendable/builtins/Array/prototype/splice/create-species.js b/test/sendable/builtins/Array/prototype/splice/create-species.js new file mode 100644 index 00000000000..f822ce17abf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/create-species.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: Species constructor is used to create a new instance +features: [Symbol.species] +---*/ + +var thisValue, args, result; +var callCount = 0; +var instance = []; +var Ctor = function() { + callCount += 1; + thisValue = this; + args = arguments; + return instance; +}; +var a = [1, 2, 3, 4, 5]; +a.constructor = {}; +a.constructor[Symbol.species] = Ctor; +result = a.splice(2); +assert.sameValue(callCount, 1, 'Constructor invoked exactly once'); +assert.sameValue(Object.getPrototypeOf(thisValue), Ctor.prototype); +assert.sameValue(args.length, 1, 'Constructor invoked with a single argument'); +assert.sameValue(args[0], 3); +assert.sameValue(result, instance); diff --git a/test/sendable/builtins/Array/prototype/splice/length-and-deleteCount-exceeding-integer-limit.js b/test/sendable/builtins/Array/prototype/splice/length-and-deleteCount-exceeding-integer-limit.js new file mode 100644 index 00000000000..27097f96641 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/length-and-deleteCount-exceeding-integer-limit.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.splice +description: > + Length and deleteCount are both clamped to 2^53-1 when they exceed the integer limit. +---*/ + +var arrayLike = { + "9007199254740988": "9007199254740988", + "9007199254740989": "9007199254740989", + "9007199254740990": "9007199254740990", + "9007199254740991": "9007199254740991", + length: 2 ** 53 + 2, +}; +var result = SendableArray.prototype.splice.call(arrayLike, 9007199254740989, 2 ** 53 + 4); +assert.compareArray(result, ["9007199254740989", "9007199254740990"], + 'The value of result is expected to be ["9007199254740989", "9007199254740990"]'); +assert.sameValue(arrayLike.length, 2 ** 53 - 3, + 'The value of arrayLike.length is expected to be 2 ** 53 - 3'); +assert.sameValue(arrayLike["9007199254740988"], "9007199254740988", + 'The value of arrayLike["9007199254740988"] is expected to be "9007199254740988"'); +assert.sameValue("9007199254740989" in arrayLike, false, + 'The result of evaluating ("9007199254740989" in arrayLike) is expected to be false'); +assert.sameValue("9007199254740990" in arrayLike, false, + 'The result of evaluating ("9007199254740990" in arrayLike) is expected to be false'); +assert.sameValue(arrayLike["9007199254740991"], "9007199254740991", + 'The value of arrayLike["9007199254740991"] is expected to be "9007199254740991"'); diff --git a/test/sendable/builtins/Array/prototype/splice/length-exceeding-integer-limit-shrink-array.js b/test/sendable/builtins/Array/prototype/splice/length-exceeding-integer-limit-shrink-array.js new file mode 100644 index 00000000000..347c50f30cc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/length-exceeding-integer-limit-shrink-array.js @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.splice +description: > + An element is removed from an array-like object whose length exceeds the integer limit. +---*/ + +var arrayLike = { + "9007199254740986": "9007199254740986", + "9007199254740987": "9007199254740987", + "9007199254740988": "9007199254740988", + /* "9007199254740989": hole */ + "9007199254740990": "9007199254740990", + "9007199254740991": "9007199254740991", + length: 2 ** 53 + 2, +}; +var result = SendableArray.prototype.splice.call(arrayLike, 9007199254740987, 1); +assert.compareArray(result, ["9007199254740987"], + 'The value of result is expected to be ["9007199254740987"]'); +assert.sameValue(arrayLike.length, 2 ** 53 - 2, + 'The value of arrayLike.length is expected to be 2 ** 53 - 2'); +assert.sameValue(arrayLike["9007199254740986"], "9007199254740986", + 'The value of arrayLike["9007199254740986"] is expected to be "9007199254740986"'); +assert.sameValue(arrayLike["9007199254740987"], "9007199254740988", + 'The value of arrayLike["9007199254740987"] is expected to be "9007199254740988"'); +assert.sameValue("9007199254740988" in arrayLike, false, + 'The result of evaluating ("9007199254740988" in arrayLike) is expected to be false'); +assert.sameValue(arrayLike["9007199254740989"], "9007199254740990", + 'The value of arrayLike["9007199254740989"] is expected to be "9007199254740990"'); +assert.sameValue("9007199254740990" in arrayLike, false, + 'The result of evaluating ("9007199254740990" in arrayLike) is expected to be false'); +assert.sameValue(arrayLike["9007199254740991"], "9007199254740991", + 'The value of arrayLike["9007199254740991"] is expected to be "9007199254740991"'); diff --git a/test/sendable/builtins/Array/prototype/splice/length-near-integer-limit-grow-array.js b/test/sendable/builtins/Array/prototype/splice/length-near-integer-limit-grow-array.js new file mode 100644 index 00000000000..dee054789d3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/length-near-integer-limit-grow-array.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-array.prototype.splice +description: > + A value is inserted in an array-like object whose length property is near the integer limit. +---*/ + +var arrayLike = { + "9007199254740985": "9007199254740985", + "9007199254740986": "9007199254740986", + "9007199254740987": "9007199254740987", + /* "9007199254740988": hole */ + "9007199254740989": "9007199254740989", + /* "9007199254740990": empty */ + "9007199254740991": "9007199254740991", + length: 2 ** 53 - 2, +}; +var result = SendableArray.prototype.splice.call(arrayLike, 9007199254740986, 0, "new-value"); +assert.compareArray(result, [], 'The value of result is expected to be []'); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, 'The value of arrayLike.length is expected to be 2 ** 53 - 1'); +assert.sameValue(arrayLike["9007199254740985"], "9007199254740985", + 'The value of arrayLike["9007199254740985"] is expected to be "9007199254740985"'); +assert.sameValue(arrayLike["9007199254740986"], "new-value", + 'The value of arrayLike["9007199254740986"] is expected to be "new-value"'); +assert.sameValue(arrayLike["9007199254740987"], "9007199254740986", + 'The value of arrayLike["9007199254740987"] is expected to be "9007199254740986"'); +assert.sameValue(arrayLike["9007199254740988"], "9007199254740987", + 'The value of arrayLike["9007199254740988"] is expected to be "9007199254740987"'); +assert.sameValue("9007199254740989" in arrayLike, false, + 'The result of evaluating ("9007199254740989" in arrayLike) is expected to be false'); +assert.sameValue(arrayLike["9007199254740990"], "9007199254740989", + 'The value of arrayLike["9007199254740990"] is expected to be "9007199254740989"'); +assert.sameValue(arrayLike["9007199254740991"], "9007199254740991", + 'The value of arrayLike["9007199254740991"] is expected to be "9007199254740991"'); diff --git a/test/sendable/builtins/Array/prototype/splice/length.js b/test/sendable/builtins/Array/prototype/splice/length.js new file mode 100644 index 00000000000..064bcd4f163 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/length.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + The "length" property of Array.prototype.splice +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.splice, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/splice/name.js b/test/sendable/builtins/Array/prototype/splice/name.js new file mode 100644 index 00000000000..a34abc1a587 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + Array.prototype.splice.name is "splice". +info: | + Array.prototype.splice (start, deleteCount , ...items ) + 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(SendableArray.prototype.splice, "name", { + value: "splice", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/splice/not-a-constructor.js b/test/sendable/builtins/Array/prototype/splice/not-a-constructor.js new file mode 100644 index 00000000000..8fce445d3ca --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/not-a-constructor.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.splice 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(SendableArray.prototype.splice), + false, + 'isConstructor(SendableArray.prototype.splice) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.splice(); +}); + diff --git a/test/sendable/builtins/Array/prototype/splice/prop-desc.js b/test/sendable/builtins/Array/prototype/splice/prop-desc.js new file mode 100644 index 00000000000..781eb26cf77 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + "splice" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.splice, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "splice", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/splice/property-traps-order-with-species.js b/test/sendable/builtins/Array/prototype/splice/property-traps-order-with-species.js new file mode 100644 index 00000000000..9f0f5cadbba --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/property-traps-order-with-species.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + Ensure the correct property traps are called on the new array. +features: [Proxy, Symbol.species] +includes: [compareArray.js] +---*/ + +var log = []; +var a = [0, 1]; +a.constructor = {}; +a.constructor[Symbol.species] = function(len) { + return new Proxy(new SendableArray(len), new Proxy({}, { + get(t, pk, r) { + log.push(pk); + } + })); +}; +var r = a.splice(0); +assert.compareArray([ + // Step 11.c.ii: CreateDataPropertyOrThrow(A, ! ToString(k), fromValue). + "defineProperty", + // Step 11.c.ii: CreateDataPropertyOrThrow(A, ! ToString(k), fromValue). + "defineProperty", + // Step 12: Perform ? Set(A, "length", actualDeleteCount, true). + "set", + "getOwnPropertyDescriptor", + "defineProperty", +], log); diff --git a/test/sendable/builtins/Array/prototype/splice/set_length_no_args.js b/test/sendable/builtins/Array/prototype/splice/set_length_no_args.js new file mode 100644 index 00000000000..314c4d6c9ec --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/set_length_no_args.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Array.prototype.splice sets length when called with no arguments +info: | + 22.1.3.25 Array.prototype.splice (start, deleteCount , ...items ) + + ... + 24. Let setStatus be Set(O, "length", len – actualDeleteCount + itemCount, true). + 25. ReturnIfAbrupt(setStatus). +esid: sec-array.prototype.splice +---*/ + +var getCallCount = 0, + setCallCount = 0; +var lengthValue; +var obj = { + get length() { + getCallCount += 1; + return "0"; + }, + set length(v) { + setCallCount += 1; + lengthValue = v; + } +}; +SendableArray.prototype.splice.call(obj); +assert.sameValue(getCallCount, 1, "Get('length') called exactly once"); +assert.sameValue(setCallCount, 1, "Set('length') called exactly once"); +assert.sameValue(lengthValue, 0, "Set('length') called with ToLength('0')"); diff --git a/test/sendable/builtins/Array/prototype/splice/target-array-non-extensible.js b/test/sendable/builtins/Array/prototype/splice/target-array-non-extensible.js new file mode 100644 index 00000000000..9565e9b3014 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/target-array-non-extensible.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + TypeError is thrown if CreateDataProperty fails. + (result object is non-extensible) +---*/ + +var A = function(_length) { + this.length = 0; + Object.preventExtensions(this); +}; +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.splice(0); +}); diff --git a/test/sendable/builtins/Array/prototype/splice/target-array-with-non-configurable-property.js b/test/sendable/builtins/Array/prototype/splice/target-array-with-non-configurable-property.js new file mode 100644 index 00000000000..a883c5e88fc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/target-array-with-non-configurable-property.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + TypeError is thrown if CreateDataProperty fails. + (result object's "0" is non-configurable) +---*/ + +var A = function(_length) { + Object.defineProperty(this, "0", { + writable: true, + configurable: false, + }); +}; +var arr = [1]; +arr.constructor = {}; +arr.constructor[Symbol.species] = A; +assert.throws(TypeError, function() { + arr.splice(0); +}); diff --git a/test/sendable/builtins/Array/prototype/splice/target-array-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/splice/target-array-with-non-writable-property.js new file mode 100644 index 00000000000..21a52a5f793 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/target-array-with-non-writable-property.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + Non-writable properties are overwritten by CreateDataPropertyOrThrow. +---*/ + +var a = [1]; +a.constructor = {}; +a.constructor[Symbol.species] = function(len) { + var q = new SendableArray(0); + Object.defineProperty(q, 0, { + value: 0, writable: false, configurable: true, enumerable: false, + }); + return q; +}; +var r = a.splice(0); +verifyProperty(r, 0, { + value: 1, writable: true, configurable: true, enumerable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/splice/throws-if-integer-limit-exceeded.js b/test/sendable/builtins/Array/prototype/splice/throws-if-integer-limit-exceeded.js new file mode 100644 index 00000000000..514387ab8b1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/splice/throws-if-integer-limit-exceeded.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.splice +description: > + A TypeError is thrown if the new length exceeds 2^53-1. +info: | + 2. Let len be ? ToLength(? Get(O, "length")). + 7. Else, + a. Let insertCount be the number of actual arguments minus 2. + b. Let dc be ? ToInteger(deleteCount). + c. Let actualDeleteCount be min(max(dc, 0), len - actualStart). + 8. If len+insertCount-actualDeleteCount > 2^53-1, throw a TypeError exception. +features: [exponentiation] +---*/ + +var arrayLike = {}; +arrayLike.length = 2 ** 53 - 1; +assert.throws(TypeError, function() { + SendableArray.prototype.splice.call(arrayLike, 0, 0, null); +}, "Length is 2**53 - 1"); +arrayLike.length = 2 ** 53; +assert.throws(TypeError, function() { + SendableArray.prototype.splice.call(arrayLike, 0, 0, null); +}, "Length is 2**53"); +arrayLike.length = 2 ** 53 + 2; +assert.throws(TypeError, function() { + SendableArray.prototype.splice.call(arrayLike, 0, 0, null); +}, "Length is 2**53 + 2"); +arrayLike.length = Infinity; +assert.throws(TypeError, function() { + SendableArray.prototype.splice.call(arrayLike, 0, 0, null); +}, "Length is Infinity"); -- Gitee From 8602e2954ac5ae62895a37c4c981d732443dbc90 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 3 Jan 2025 14:06:05 +0800 Subject: [PATCH 70/93] add array- many Signed-off-by: zhuzhihui7 --- .../Array/prototype/Symbol.iterator.js | 32 ++++ .../Symbol.iterator/not-a-constructor.js | 38 ++++ .../array-find-from-last.js | 34 ++++ .../change-array-by-copy.js | 29 +++ .../prototype/Symbol.unscopables/prop-desc.js | 30 ++++ .../prototype/Symbol.unscopables/value.js | 82 +++++++++ .../builtins/Array/prototype/constructor.js | 34 ++++ .../builtins/Array/prototype/exotic-array.js | 32 ++++ .../builtins/Array/prototype/length.js | 33 ++++ .../prototype/methods-called-as-functions.js | 169 ++++++++++++++++++ .../builtins/Array/prototype/prop-desc.js | 31 ++++ .../builtins/Array/prototype/proto.js | 25 +++ .../toLocaleString/S15.4.4.3_A1_T1.js | 36 ++++ .../toLocaleString/S15.4.4.3_A3_T1.js | 34 ++++ .../invoke-element-tolocalestring.js | 57 ++++++ .../Array/prototype/toLocaleString/length.js | 38 ++++ .../Array/prototype/toLocaleString/name.js | 36 ++++ .../toLocaleString/not-a-constructor.js | 38 ++++ .../toLocaleString/primitive_this_value.js | 35 ++++ .../primitive_this_value_getter.js | 40 +++++ .../prototype/toLocaleString/prop-desc.js | 32 ++++ .../toLocaleString/resizable-buffer.js | 84 +++++++++ .../user-provided-tolocalestring-grow.js | 88 +++++++++ .../user-provided-tolocalestring-shrink.js | 89 +++++++++ .../prototype/toReversed/frozen-this-value.js | 28 +++ .../toReversed/get-descending-order.js | 42 +++++ .../toReversed/holes-not-preserved.js | 25 +++ .../prototype/toReversed/ignores-species.js | 31 ++++ .../Array/prototype/toReversed/immutable.js | 26 +++ .../toReversed/length-casted-to-zero.js | 28 +++ .../length-decreased-while-iterating.js | 29 +++ .../length-exceeding-array-length-limit.js | 38 ++++ .../length-increased-while-iterating.js | 28 +++ .../prototype/toReversed/length-tolength.js | 30 ++++ .../Array/prototype/toReversed/length.js | 39 ++++ .../Array/prototype/toReversed/name.js | 37 ++++ .../prototype/toReversed/not-a-constructor.js | 39 ++++ .../toReversed/property-descriptor.js | 35 ++++ .../toReversed/this-value-boolean.js | 39 ++++ .../toReversed/this-value-nullish.js | 26 +++ .../toReversed/zero-or-one-element.js | 30 ++++ .../comparefn-called-after-get-elements.js | 45 +++++ .../toSorted/comparefn-not-a-function.js | 40 +++++ .../toSorted/comparefn-stop-after-error.js | 48 +++++ .../prototype/toSorted/frozen-this-value.js | 28 +++ .../prototype/toSorted/holes-not-preserved.js | 32 ++++ .../prototype/toSorted/ignores-species.js | 35 ++++ .../Array/prototype/toSorted/immutable.js | 26 +++ .../toSorted/length-casted-to-zero.js | 28 +++ .../length-decreased-while-iterating.js | 35 ++++ .../length-exceeding-array-length-limit.js | 36 ++++ .../length-increased-while-iterating.js | 28 +++ .../prototype/toSorted/length-tolength.js | 30 ++++ .../Array/prototype/toSorted/length.js | 39 ++++ .../builtins/Array/prototype/toSorted/name.js | 37 ++++ .../prototype/toSorted/not-a-constructor.js | 38 ++++ .../prototype/toSorted/property-descriptor.js | 34 ++++ .../prototype/toSorted/this-value-boolean.js | 37 ++++ .../prototype/toSorted/this-value-nullish.js | 30 ++++ .../prototype/toSorted/zero-or-one-element.js | 30 ++++ ...lamped-between-zero-and-remaining-count.js | 42 +++++ .../toSpliced/deleteCount-missing.js | 27 +++ .../toSpliced/deleteCount-undefined.js | 34 ++++ .../toSpliced/discarded-element-not-read.js | 55 ++++++ .../toSpliced/elements-read-in-order.js | 60 +++++++ .../prototype/toSpliced/frozen-this-value.js | 27 +++ .../toSpliced/holes-not-preserved.js | 46 +++++ .../prototype/toSpliced/ignores-species.js | 35 ++++ .../Array/prototype/toSpliced/immutable.js | 27 +++ .../toSpliced/length-casted-to-zero.js | 29 +++ .../length-clamped-to-2pow53minus1.js | 31 ++++ .../length-decreased-while-iterating.js | 29 +++ .../length-exceeding-array-length-limit.js | 64 +++++++ .../length-increased-while-iterating.js | 36 ++++ .../prototype/toSpliced/length-tolength.js | 30 ++++ .../Array/prototype/toSpliced/length.js | 39 ++++ .../toSpliced/mutate-while-iterating.js | 39 ++++ .../Array/prototype/toSpliced/name.js | 37 ++++ .../prototype/toSpliced/not-a-constructor.js | 37 ++++ .../toSpliced/property-descriptor.js | 34 ++++ .../start-and-deleteCount-missing.js | 32 ++++ .../start-and-deleteCount-undefineds.js | 24 +++ .../toSpliced/start-bigger-than-length.js | 31 ++++ .../toSpliced/start-neg-infinity-is-zero.js | 30 ++++ ...tart-neg-less-than-minus-length-is-zero.js | 30 ++++ .../start-neg-subtracted-from-length.js | 30 ++++ ...start-undefined-and-deleteCount-missing.js | 31 ++++ .../prototype/toSpliced/this-value-boolean.js | 37 ++++ .../prototype/toSpliced/this-value-nullish.js | 30 ++++ .../Array/prototype/toSpliced/unmodified.js | 26 +++ .../prototype/toString/S15.4.4.2_A1_T1.js | 41 +++++ .../prototype/toString/S15.4.4.2_A1_T2.js | 62 +++++++ .../prototype/toString/S15.4.4.2_A1_T3.js | 87 +++++++++ .../prototype/toString/S15.4.4.2_A1_T4.js | 101 +++++++++++ .../prototype/toString/S15.4.4.2_A3_T1.js | 27 +++ .../prototype/toString/call-with-boolean.js | 29 +++ .../Array/prototype/toString/length.js | 39 ++++ .../builtins/Array/prototype/toString/name.js | 36 ++++ .../toString/non-callable-join-string-tag.js | 70 ++++++++ .../prototype/toString/not-a-constructor.js | 38 ++++ .../Array/prototype/toString/prop-desc.js | 32 ++++ .../prototype/unshift/S15.4.4.13_A1_T1.js | 51 ++++++ .../prototype/unshift/S15.4.4.13_A1_T2.js | 53 ++++++ .../prototype/unshift/S15.4.4.13_A2_T1.js | 63 +++++++ .../prototype/unshift/S15.4.4.13_A2_T2.js | 82 +++++++++ .../prototype/unshift/S15.4.4.13_A2_T3.js | 121 +++++++++++++ .../prototype/unshift/S15.4.4.13_A3_T2.js | 43 +++++ .../prototype/unshift/S15.4.4.13_A4_T1.js | 66 +++++++ .../prototype/unshift/S15.4.4.13_A4_T2.js | 64 +++++++ .../prototype/unshift/call-with-boolean.js | 21 +++ .../unshift/clamps-to-integer-limit.js | 40 +++++ .../unshift/length-near-integer-limit.js | 64 +++++++ .../Array/prototype/unshift/length.js | 40 +++++ .../builtins/Array/prototype/unshift/name.js | 36 ++++ .../prototype/unshift/not-a-constructor.js | 38 ++++ .../Array/prototype/unshift/prop-desc.js | 33 ++++ .../unshift/set-length-array-is-frozen.js | 34 ++++ ...set-length-array-length-is-non-writable.js | 34 ++++ .../set-length-zero-array-is-frozen.js | 27 +++ ...ength-zero-array-length-is-non-writable.js | 27 +++ .../throws-if-integer-limit-exceeded.js | 44 +++++ .../unshift/throws-with-string-receiver.js | 32 ++++ .../prototype/values/iteration-mutable.js | 46 +++++ .../Array/prototype/values/iteration.js | 40 +++++ .../builtins/Array/prototype/values/length.js | 35 ++++ .../builtins/Array/prototype/values/name.js | 35 ++++ .../prototype/values/not-a-constructor.js | 39 ++++ .../Array/prototype/values/prop-desc.js | 30 ++++ .../resizable-buffer-grow-mid-iteration.js | 70 ++++++++ .../resizable-buffer-shrink-mid-iteration.js | 63 +++++++ .../prototype/values/resizable-buffer.js | 154 ++++++++++++++++ .../values/returns-iterator-from-object.js | 35 ++++ .../prototype/values/returns-iterator.js | 36 ++++ .../values/this-val-non-obj-coercible.js | 29 +++ .../Array/prototype/with/frozen-this-value.js | 28 +++ .../prototype/with/holes-not-preserved.js | 37 ++++ .../Array/prototype/with/ignores-species.js | 31 ++++ .../Array/prototype/with/immutable.js | 27 +++ .../with/index-bigger-or-eq-than-length.js | 40 +++++ .../prototype/with/index-casted-to-number.js | 34 ++++ .../Array/prototype/with/index-negative.js | 33 ++++ .../with/index-smaller-than-minus-length.js | 41 +++++ .../with/length-decreased-while-iterating.js | 46 +++++ .../length-exceeding-array-length-limit.js | 36 ++++ .../with/length-increased-while-iterating.js | 28 +++ .../Array/prototype/with/length-tolength.js | 31 ++++ .../builtins/Array/prototype/with/length.js | 39 ++++ .../builtins/Array/prototype/with/name.js | 37 ++++ .../prototype/with/no-get-replaced-index.js | 38 ++++ .../Array/prototype/with/not-a-constructor.js | 38 ++++ .../prototype/with/property-descriptor.js | 34 ++++ .../prototype/with/this-value-boolean.js | 40 +++++ .../prototype/with/this-value-nullish.js | 26 +++ 153 files changed, 6292 insertions(+) create mode 100644 test/sendable/builtins/Array/prototype/Symbol.iterator.js create mode 100644 test/sendable/builtins/Array/prototype/Symbol.iterator/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/Symbol.unscopables/array-find-from-last.js create mode 100644 test/sendable/builtins/Array/prototype/Symbol.unscopables/change-array-by-copy.js create mode 100644 test/sendable/builtins/Array/prototype/Symbol.unscopables/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/Symbol.unscopables/value.js create mode 100644 test/sendable/builtins/Array/prototype/constructor.js create mode 100644 test/sendable/builtins/Array/prototype/exotic-array.js create mode 100644 test/sendable/builtins/Array/prototype/length.js create mode 100644 test/sendable/builtins/Array/prototype/methods-called-as-functions.js create mode 100644 test/sendable/builtins/Array/prototype/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/proto.js create mode 100644 test/sendable/builtins/Array/prototype/toLocaleString/S15.4.4.3_A1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/toLocaleString/S15.4.4.3_A3_T1.js create mode 100644 test/sendable/builtins/Array/prototype/toLocaleString/invoke-element-tolocalestring.js create mode 100644 test/sendable/builtins/Array/prototype/toLocaleString/length.js create mode 100644 test/sendable/builtins/Array/prototype/toLocaleString/name.js create mode 100644 test/sendable/builtins/Array/prototype/toLocaleString/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/toLocaleString/primitive_this_value.js create mode 100644 test/sendable/builtins/Array/prototype/toLocaleString/primitive_this_value_getter.js create mode 100644 test/sendable/builtins/Array/prototype/toLocaleString/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/toLocaleString/resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/toLocaleString/user-provided-tolocalestring-grow.js create mode 100644 test/sendable/builtins/Array/prototype/toLocaleString/user-provided-tolocalestring-shrink.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/frozen-this-value.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/get-descending-order.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/holes-not-preserved.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/ignores-species.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/immutable.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/length-casted-to-zero.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/length-decreased-while-iterating.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/length-exceeding-array-length-limit.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/length-increased-while-iterating.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/length-tolength.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/length.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/name.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/property-descriptor.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/this-value-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/this-value-nullish.js create mode 100644 test/sendable/builtins/Array/prototype/toReversed/zero-or-one-element.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/comparefn-called-after-get-elements.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/comparefn-not-a-function.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/comparefn-stop-after-error.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/frozen-this-value.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/holes-not-preserved.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/ignores-species.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/immutable.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/length-casted-to-zero.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/length-decreased-while-iterating.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/length-exceeding-array-length-limit.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/length-increased-while-iterating.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/length-tolength.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/length.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/name.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/property-descriptor.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/this-value-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/this-value-nullish.js create mode 100644 test/sendable/builtins/Array/prototype/toSorted/zero-or-one-element.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/deleteCount-missing.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/deleteCount-undefined.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/discarded-element-not-read.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/elements-read-in-order.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/frozen-this-value.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/holes-not-preserved.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/ignores-species.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/immutable.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/length-casted-to-zero.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/length-decreased-while-iterating.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/length-increased-while-iterating.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/length-tolength.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/length.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/mutate-while-iterating.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/name.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/property-descriptor.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/start-and-deleteCount-missing.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/start-bigger-than-length.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/this-value-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/this-value-nullish.js create mode 100644 test/sendable/builtins/Array/prototype/toSpliced/unmodified.js create mode 100644 test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T2.js create mode 100644 test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T3.js create mode 100644 test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T4.js create mode 100644 test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A3_T1.js create mode 100644 test/sendable/builtins/Array/prototype/toString/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/toString/length.js create mode 100644 test/sendable/builtins/Array/prototype/toString/name.js create mode 100644 test/sendable/builtins/Array/prototype/toString/non-callable-join-string-tag.js create mode 100644 test/sendable/builtins/Array/prototype/toString/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/toString/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A1_T1.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A1_T2.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A2_T1.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A2_T2.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A2_T3.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A3_T2.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A4_T1.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A4_T2.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/call-with-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/clamps-to-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/length-near-integer-limit.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/length.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/name.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/set-length-array-is-frozen.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/set-length-array-length-is-non-writable.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/set-length-zero-array-is-frozen.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/set-length-zero-array-length-is-non-writable.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/throws-if-integer-limit-exceeded.js create mode 100644 test/sendable/builtins/Array/prototype/unshift/throws-with-string-receiver.js create mode 100644 test/sendable/builtins/Array/prototype/values/iteration-mutable.js create mode 100644 test/sendable/builtins/Array/prototype/values/iteration.js create mode 100644 test/sendable/builtins/Array/prototype/values/length.js create mode 100644 test/sendable/builtins/Array/prototype/values/name.js create mode 100644 test/sendable/builtins/Array/prototype/values/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/values/prop-desc.js create mode 100644 test/sendable/builtins/Array/prototype/values/resizable-buffer-grow-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/values/resizable-buffer-shrink-mid-iteration.js create mode 100644 test/sendable/builtins/Array/prototype/values/resizable-buffer.js create mode 100644 test/sendable/builtins/Array/prototype/values/returns-iterator-from-object.js create mode 100644 test/sendable/builtins/Array/prototype/values/returns-iterator.js create mode 100644 test/sendable/builtins/Array/prototype/values/this-val-non-obj-coercible.js create mode 100644 test/sendable/builtins/Array/prototype/with/frozen-this-value.js create mode 100644 test/sendable/builtins/Array/prototype/with/holes-not-preserved.js create mode 100644 test/sendable/builtins/Array/prototype/with/ignores-species.js create mode 100644 test/sendable/builtins/Array/prototype/with/immutable.js create mode 100644 test/sendable/builtins/Array/prototype/with/index-bigger-or-eq-than-length.js create mode 100644 test/sendable/builtins/Array/prototype/with/index-casted-to-number.js create mode 100644 test/sendable/builtins/Array/prototype/with/index-negative.js create mode 100644 test/sendable/builtins/Array/prototype/with/index-smaller-than-minus-length.js create mode 100644 test/sendable/builtins/Array/prototype/with/length-decreased-while-iterating.js create mode 100644 test/sendable/builtins/Array/prototype/with/length-exceeding-array-length-limit.js create mode 100644 test/sendable/builtins/Array/prototype/with/length-increased-while-iterating.js create mode 100644 test/sendable/builtins/Array/prototype/with/length-tolength.js create mode 100644 test/sendable/builtins/Array/prototype/with/length.js create mode 100644 test/sendable/builtins/Array/prototype/with/name.js create mode 100644 test/sendable/builtins/Array/prototype/with/no-get-replaced-index.js create mode 100644 test/sendable/builtins/Array/prototype/with/not-a-constructor.js create mode 100644 test/sendable/builtins/Array/prototype/with/property-descriptor.js create mode 100644 test/sendable/builtins/Array/prototype/with/this-value-boolean.js create mode 100644 test/sendable/builtins/Array/prototype/with/this-value-nullish.js diff --git a/test/sendable/builtins/Array/prototype/Symbol.iterator.js b/test/sendable/builtins/Array/prototype/Symbol.iterator.js new file mode 100644 index 00000000000..e498e63a5db --- /dev/null +++ b/test/sendable/builtins/Array/prototype/Symbol.iterator.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: Initial state of the Symbol.iterator property +info: | + The initial value of the @@iterator property is the same function object as + the initial value of the Array.prototype.values property. + Per ES6 section 17, the method should exist on the Array prototype, and it + should be writable and configurable, but not enumerable. +includes: [propertyHelper.js] +features: [Symbol.iterator] +esid: sec-array.prototype-@@iterator +---*/ + +assert.sameValue(SendableArray.prototype[Symbol.iterator], SendableArray.prototype.values); +verifyProperty(SendableArray.prototype, Symbol.iterator, { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/Symbol.iterator/not-a-constructor.js b/test/sendable/builtins/Array/prototype/Symbol.iterator/not-a-constructor.js new file mode 100644 index 00000000000..095e8463674 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/Symbol.iterator/not-a-constructor.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype[Symbol.iterator] 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, Symbol, Symbol.iterator, arrow-function] +---*/ + +assert.sameValue( + isConstructor(SendableArray.prototype[Symbol.iterator]), + false, + 'isConstructor(SendableArray.prototype[Symbol.iterator]) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype[Symbol.iterator](); +}); + diff --git a/test/sendable/builtins/Array/prototype/Symbol.unscopables/array-find-from-last.js b/test/sendable/builtins/Array/prototype/Symbol.unscopables/array-find-from-last.js new file mode 100644 index 00000000000..1039266285e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/Symbol.unscopables/array-find-from-last.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype-@@unscopables +description: > + Initial value of `Symbol.unscopables` property +---*/ + +var unscopables = SendableArray.prototype[Symbol.unscopables]; +assert.sameValue(Object.getPrototypeOf(unscopables), null); +assert.sameValue(unscopables.findLast, true, '`findLast` property value'); +verifyProperty(unscopables, "findLast", { + writable: true, + enumerable: true, + configurable: true +}); +assert.sameValue(unscopables.findLastIndex, true, '`findLastIndex` property value'); +verifyProperty(unscopables, "findLastIndex", { + writable: true, + enumerable: true, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/Symbol.unscopables/change-array-by-copy.js b/test/sendable/builtins/Array/prototype/Symbol.unscopables/change-array-by-copy.js new file mode 100644 index 00000000000..0be62319c46 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/Symbol.unscopables/change-array-by-copy.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype-@@unscopables +description: > + Initial value of `Symbol.unscopables` property +---*/ + +var unscopables = SendableArray.prototype[Symbol.unscopables]; +for (const unscopable of ["toReversed", "toSorted", "toSpliced"]) { + verifyProperty(unscopables, unscopable, { + value: true, + writable: true, + configurable: true + }) +}; +assert(!Object.prototype.hasOwnProperty.call(unscopables, "with"), "does not have `with`"); diff --git a/test/sendable/builtins/Array/prototype/Symbol.unscopables/prop-desc.js b/test/sendable/builtins/Array/prototype/Symbol.unscopables/prop-desc.js new file mode 100644 index 00000000000..eecd840f95e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/Symbol.unscopables/prop-desc.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype-@@unscopables +description: > + Property descriptor for initial value of `Symbol.unscopables` property +info: | + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.unscopables] +---*/ + +verifyProperty(SendableArray.prototype, Symbol.unscopables, { + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/Symbol.unscopables/value.js b/test/sendable/builtins/Array/prototype/Symbol.unscopables/value.js new file mode 100644 index 00000000000..a983871b050 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/Symbol.unscopables/value.js @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype-@@unscopables +description: > + Initial value of `Symbol.unscopables` property +---*/ + +var unscopables = SendableArray.prototype[Symbol.unscopables]; +assert.sameValue(Object.getPrototypeOf(unscopables), null); +assert.sameValue(unscopables.copyWithin, true, '`copyWithin` property value'); +verifyProperty(unscopables, "copyWithin", { + writable: true, + enumerable: true, + configurable: true +}); +assert.sameValue(unscopables.entries, true, '`entries` property value'); +verifyProperty(unscopables, "entries", { + writable: true, + enumerable: true, + configurable: true +}); +assert.sameValue(unscopables.fill, true, '`fill` property value'); +verifyProperty(unscopables, "fill", { + writable: true, + enumerable: true, + configurable: true +}); +assert.sameValue(unscopables.find, true, '`find` property value'); +verifyProperty(unscopables, "find", { + writable: true, + enumerable: true, + configurable: true +}); +assert.sameValue(unscopables.findIndex, true, '`findIndex` property value'); +verifyProperty(unscopables, "findIndex", { + writable: true, + enumerable: true, + configurable: true +}); +assert.sameValue(unscopables.flat, true, '`flat` property value'); +verifyProperty(unscopables, "flat", { + writable: true, + enumerable: true, + configurable: true +}); +assert.sameValue(unscopables.flatMap, true, '`flatMap` property value'); +verifyProperty(unscopables, "flatMap", { + writable: true, + enumerable: true, + configurable: true +}); +assert.sameValue(unscopables.includes, true, '`includes` property value'); +verifyProperty(unscopables, "includes", { + writable: true, + enumerable: true, + configurable: true +}); +assert.sameValue(unscopables.keys, true, '`keys` property value'); +verifyProperty(unscopables, "keys", { + writable: true, + enumerable: true, + configurable: true +}); +assert.sameValue(unscopables.values, true, '`values` property value'); +verifyProperty(unscopables, "values", { + writable: true, + enumerable: true, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/constructor.js b/test/sendable/builtins/Array/prototype/constructor.js new file mode 100644 index 00000000000..6419736e75e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/constructor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.constructor +description: > + Array.prototype.constructor +info: | + 22.1.3.2 Array.prototype.constructor + The initial value of Array.prototype.constructor is the intrinsic object %Array%. + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(SendableArray.prototype.constructor, SendableArray); +verifyProperty(SendableArray.prototype, "constructor", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/exotic-array.js b/test/sendable/builtins/Array/prototype/exotic-array.js new file mode 100644 index 00000000000..aef0dae61e6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/exotic-array.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-properties-of-the-array-prototype-object +description: > + Array.prototype is an exoctic array object +info: | + 22.1.3 Properties of the Array Prototype Object + + (...) + The Array prototype object is an Array exotic object and has the internal + methods specified for such objects. +---*/ + +SendableArray.prototype[2] = 42; +assert.sameValue(SendableArray.prototype.length, 3); +assert.sameValue(SendableArray.prototype[0], undefined, 'SendableArray.prototype[0]'); +assert.sameValue(SendableArray.prototype[1], undefined, 'SendableArray.prototype[1]'); +assert.sameValue(SendableArray.prototype[2], 42, 'SendableArray.prototype[2]'); +assert.sameValue({}.toString.call(SendableArray.prototype), '[object SendableArray]'); diff --git a/test/sendable/builtins/Array/prototype/length.js b/test/sendable/builtins/Array/prototype/length.js new file mode 100644 index 00000000000..a0e8d3afae1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/length.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-properties-of-the-array-prototype-object +description: > + Array.prototype has a length property +info: | + 22.1.3 Properties of the Array Prototype Object + The Array prototype object is the intrinsic object %ArrayPrototype%. The Array + prototype object is an Array exotic object and has the internal methods specified + for such objects. It has a length property whose initial value is 0 and whose + attributes are { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: + false }. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(SendableArray.prototype.length, 0); +verifyNotEnumerable(SendableArray.prototype, 'length'); +// specify the value so it avoids a RangeError while setting the length +verifyWritable(SendableArray.prototype, 'length', false, 42); +verifyNotConfigurable(SendableArray.prototype, 'length'); diff --git a/test/sendable/builtins/Array/prototype/methods-called-as-functions.js b/test/sendable/builtins/Array/prototype/methods-called-as-functions.js new file mode 100644 index 00000000000..9ce4c0f95da --- /dev/null +++ b/test/sendable/builtins/Array/prototype/methods-called-as-functions.js @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-properties-of-the-array-prototype-object +description: > + Array.prototype methods resolve `this` value using strict mode semantics, + throwing TypeError if called as top-level function. +---*/ + +["constructor", "length", "0", Symbol.isConcatSpreadable, Symbol.species].forEach(function(key) { + Object.defineProperty(this, key, { + get: function() { + throw new Test262Error(String(key) + " lookup should not be performed"); + }, + }); +}, this); +function callback() { + throw new Test262Error("callback should not be called"); +} +var index = { + get valueOf() { + throw new Test262Error("index should not be coerced to number"); + }, +}; +var separator = { + get toString() { + throw new Test262Error("separator should not be coerced to string"); + }, +}; +var concat = SendableArray.prototype.concat; +assert.throws(TypeError, function() { + concat(); +}, "concat"); +var copyWithin = SendableArray.prototype.copyWithin; +assert.throws(TypeError, function() { + copyWithin(index, index); +}, "copyWithin"); +var entries = SendableArray.prototype.entries; +assert.throws(TypeError, function() { + entries(); +}, "entries"); +var every = SendableArray.prototype.every; +assert.throws(TypeError, function() { + every(callback); +}, "every"); +var fill = SendableArray.prototype.fill; +assert.throws(TypeError, function() { + fill(0); +}, "fill"); +var filter = SendableArray.prototype.filter; +assert.throws(TypeError, function() { + filter(callback); +}, "filter"); +var find = SendableArray.prototype.find; +assert.throws(TypeError, function() { + find(callback); +}, "find"); +var findIndex = SendableArray.prototype.findIndex; +assert.throws(TypeError, function() { + findIndex(callback); +}, "findIndex"); +var flat = SendableArray.prototype.flat; +assert.throws(TypeError, function() { + flat(index); +}, "flat"); +var flatMap = SendableArray.prototype.flatMap; +assert.throws(TypeError, function() { + flatMap(callback); +}, "flatMap"); +var forEach = SendableArray.prototype.forEach; +assert.throws(TypeError, function() { + forEach(callback); +}, "forEach"); +var includes = SendableArray.prototype.includes; +assert.throws(TypeError, function() { + includes(0, index); +}, "includes"); +var indexOf = SendableArray.prototype.indexOf; +assert.throws(TypeError, function() { + indexOf(0, index); +}, "indexOf"); +var join = SendableArray.prototype.join; +assert.throws(TypeError, function() { + join(separator); +}, "join"); +var keys = SendableArray.prototype.keys; +assert.throws(TypeError, function() { + keys(); +}, "keys"); +var lastIndexOf = SendableArray.prototype.lastIndexOf; +assert.throws(TypeError, function() { + lastIndexOf(0, index); +}, "lastIndexOf"); +var map = SendableArray.prototype.map; +assert.throws(TypeError, function() { + map(callback); +}, "map"); +var pop = SendableArray.prototype.pop; +assert.throws(TypeError, function() { + pop(); +}, "pop"); +var push = SendableArray.prototype.push; +assert.throws(TypeError, function() { + push(); +}, "push"); +var reduce = SendableArray.prototype.reduce; +assert.throws(TypeError, function() { + reduce(callback, 0); +}, "reduce"); +var reduceRight = SendableArray.prototype.reduceRight; +assert.throws(TypeError, function() { + reduceRight(callback, 0); +}, "reduceRight"); +var reverse = SendableArray.prototype.reverse; +assert.throws(TypeError, function() { + reverse(); +}, "reverse"); +var shift = SendableArray.prototype.shift; +assert.throws(TypeError, function() { + shift(); +}, "shift"); +var slice = SendableArray.prototype.slice; +assert.throws(TypeError, function() { + slice(index, index); +}, "slice"); +var some = SendableArray.prototype.some; +assert.throws(TypeError, function() { + some(callback); +}, "some"); +var sort = SendableArray.prototype.sort; +assert.throws(TypeError, function() { + sort(callback); +}, "sort"); +var splice = SendableArray.prototype.splice; +assert.throws(TypeError, function() { + splice(index, index); +}, "splice"); +var toLocaleString = SendableArray.prototype.toLocaleString; +assert.throws(TypeError, function() { + toLocaleString(); +}, "toLocaleString"); +var toString = SendableArray.prototype.toString; +assert.throws(TypeError, function() { + toString(); +}, "toString"); +var unshift = SendableArray.prototype.unshift; +assert.throws(TypeError, function() { + unshift(); +}, "unshift"); +var values = SendableArray.prototype.values; +assert.throws(TypeError, function() { + values(); +}, "values"); +var iterator = SendableArray.prototype[Symbol.iterator]; +assert.throws(TypeError, function() { + iterator(); +}, "Symbol.iterator"); diff --git a/test/sendable/builtins/Array/prototype/prop-desc.js b/test/sendable/builtins/Array/prototype/prop-desc.js new file mode 100644 index 00000000000..d9d3210804e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/prop-desc.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype +description: > + The property descriptor of Array.prototype +info: | + 22.1.2.4 Array.prototype + The value of Array.prototype is %ArrayPrototype%, the intrinsic Array prototype object. + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableArray, 'prototype', { + writable: false, + enumerable: false, + configurable: false, +}); diff --git a/test/sendable/builtins/Array/prototype/proto.js b/test/sendable/builtins/Array/prototype/proto.js new file mode 100644 index 00000000000..464e0c110bc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/proto.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-properties-of-the-array-prototype-object +description: > + The [[Prototype]] of Array.prototype is Object.Prototype. +info: | + 22.1.3 Properties of the Array Prototype Object + The value of the [[Prototype]] internal slot of the Array prototype object is + the intrinsic object %ObjectPrototype%. +---*/ + +assert.sameValue(Object.getPrototypeOf(SendableArray.prototype), Object.prototype); diff --git a/test/sendable/builtins/Array/prototype/toLocaleString/S15.4.4.3_A1_T1.js b/test/sendable/builtins/Array/prototype/toLocaleString/S15.4.4.3_A1_T1.js new file mode 100644 index 00000000000..75f0cab3774 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toLocaleString/S15.4.4.3_A1_T1.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tolocalestring +info: | + The elements of the array are converted to strings using their + toLocaleString methods, and these strings are then concatenated, separated + by occurrences of a separator string that has been derived in an + implementation-defined locale-specific way +es5id: 15.4.4.3_A1_T1 +description: it is the function that should be invoked +---*/ + +var n = 0; +var obj = { + toLocaleString: function() { + n++ + } +}; +var arr = [undefined, obj, null, obj, obj]; +arr.toLocaleString(); +if (n !== 3) { + throw new Test262Error('#1: var n = 0; var obj = {toLocaleString: function() {n++}}; var arr = [undefined, obj, null, obj, obj]; arr.toLocaleString(); n === 3. Actual: ' + (n)); +} diff --git a/test/sendable/builtins/Array/prototype/toLocaleString/S15.4.4.3_A3_T1.js b/test/sendable/builtins/Array/prototype/toLocaleString/S15.4.4.3_A3_T1.js new file mode 100644 index 00000000000..582dc4f1b6d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toLocaleString/S15.4.4.3_A3_T1.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tolocalestring +info: "[[Get]] from not an inherited property" +es5id: 15.4.4.3_A3_T1 +description: "[[Prototype]] of Array instance is Array.prototype" +---*/ + +var n = 0; +var obj = { + toLocaleString: function() { + n++ + } +}; +SendableArray.prototype[1] = obj; +var x = [obj]; +x.length = 2; +x.toLocaleString(); +if (n !== 2) { + throw new Test262Error('#1: var n = 0; var obj = {toLocaleString: function() {n++}}; Array.prototype[1] = obj; x = [obj]; x.length = 2; x.toLocaleString(); n === 2. Actual: ' + (n)); +} diff --git a/test/sendable/builtins/Array/prototype/toLocaleString/invoke-element-tolocalestring.js b/test/sendable/builtins/Array/prototype/toLocaleString/invoke-element-tolocalestring.js new file mode 100644 index 00000000000..cba4ce33d4f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toLocaleString/invoke-element-tolocalestring.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tolocalestring +description: > + The toLocaleString method of each non-undefined non-null element + must be called with no arguments. +includes: [compareArray.js] +---*/ + +const unique = { + toString() { + return ""; + } +}; +const testCases = [ + { label: "no arguments", args: [] }, + { label: "undefined locale", args: [undefined] }, + { label: "string locale", args: ["ar"] }, + { label: "object locale", args: [unique] }, + { label: "undefined locale and options", args: [undefined, unique] }, + { label: "string locale and options", args: ["zh", unique] }, + { label: "object locale and options", args: [unique, unique] }, + { label: "extra arguments", args: [unique, unique, unique] }, +]; +for (const { label, args } of testCases) { + assert.sameValue([undefined].toLocaleString(...args), "", + `must skip undefined elements when provided ${label}`); +} +for (const { label, args, expectedArgs } of testCases) { + assert.sameValue([null].toLocaleString(...args), "", + `must skip null elements when provided ${label}`); +} +if (typeof Intl !== "object") { + for (const { label, args } of testCases) { + const spy = { + toLocaleString(...receivedArgs) { + assert.compareArray(receivedArgs, [], + `must invoke element toLocaleString with no arguments when provided ${label}`); + return "ok"; + } + }; + assert.sameValue([spy].toLocaleString(...args), "ok"); + } +} diff --git a/test/sendable/builtins/Array/prototype/toLocaleString/length.js b/test/sendable/builtins/Array/prototype/toLocaleString/length.js new file mode 100644 index 00000000000..ce2ccc66ba2 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toLocaleString/length.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tolocalestring +description: > + The "length" property of Array.prototype.toLocaleString +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.toLocaleString, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/toLocaleString/name.js b/test/sendable/builtins/Array/prototype/toLocaleString/name.js new file mode 100644 index 00000000000..278b290f1b0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toLocaleString/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tolocalestring +description: > + Array.prototype.toLocaleString.name is "toLocaleString". +info: | + Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + 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(SendableArray.prototype.toLocaleString, "name", { + value: "toLocaleString", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/toLocaleString/not-a-constructor.js b/test/sendable/builtins/Array/prototype/toLocaleString/not-a-constructor.js new file mode 100644 index 00000000000..cd1a426f115 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toLocaleString/not-a-constructor.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.toLocaleString 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(SendableArray.prototype.toLocaleString), + false, + 'isConstructor(SendableArray.prototype.toLocaleString) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.toLocaleString(); +}); + diff --git a/test/sendable/builtins/Array/prototype/toLocaleString/primitive_this_value.js b/test/sendable/builtins/Array/prototype/toLocaleString/primitive_this_value.js new file mode 100644 index 00000000000..4bfadeb53fb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toLocaleString/primitive_this_value.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tolocalestring +description: Array.prototype.toLocaleString called with primitive element +info: | + 22.1.3.26 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + 10. Else + a. Let R be ToString(Invoke(firstElement, "toLocaleString")). + b. ReturnIfAbrupt(R). + 12. + e. Else + i. Let R be ToString(Invoke(nextElement, "toLocaleString")). + ii. ReturnIfAbrupt(R). +es6id: 22.1.3.26 +flags: [onlyStrict] +---*/ + +var listSeparator = ["", ""].toLocaleString(); +Boolean.prototype.toString = function() { + return typeof this; +}; +assert.sameValue([true, false].toLocaleString(), ("boolean" + listSeparator + "boolean")); diff --git a/test/sendable/builtins/Array/prototype/toLocaleString/primitive_this_value_getter.js b/test/sendable/builtins/Array/prototype/toLocaleString/primitive_this_value_getter.js new file mode 100644 index 00000000000..a25ff67ad53 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toLocaleString/primitive_this_value_getter.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tolocalestring +description: Array.prototype.toLocaleString called with primitive element in getter +info: | + 22.1.3.26 Array.prototype.toLocaleString ( [ reserved1 [ , reserved2 ] ] ) + 10. Else + a. Let R be ToString(Invoke(firstElement, "toLocaleString")). + b. ReturnIfAbrupt(R). + 12. + e. Else + i. Let R be ToString(Invoke(nextElement, "toLocaleString")). + ii. ReturnIfAbrupt(R). +es6id: 22.1.3.26 +flags: [onlyStrict] +---*/ + +var listSeparator = ["", ""].toLocaleString(); +Object.defineProperty(Boolean.prototype, "toString", { + get: function() { + var v = typeof this; + return function() { + return v; + }; + } +}); +assert.sameValue([true, false].toLocaleString(), ("boolean" + listSeparator + "boolean")); diff --git a/test/sendable/builtins/Array/prototype/toLocaleString/prop-desc.js b/test/sendable/builtins/Array/prototype/toLocaleString/prop-desc.js new file mode 100644 index 00000000000..3500037a813 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toLocaleString/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tolocalestring +description: > + "toLocaleString" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.toLocaleString, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "toLocaleString", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/toLocaleString/resizable-buffer.js b/test/sendable/builtins/Array/prototype/toLocaleString/resizable-buffer.js new file mode 100644 index 00000000000..7eff242a156 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toLocaleString/resizable-buffer.js @@ -0,0 +1,84 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tolocalestring +description: > + Array.p.toLocaleString behaves correctly on TypedArrays backed by resizable + buffers. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + const taWrite = new ctor(rab); + // toLocaleString separator is implementation dependent. + function listToString(list) { + const comma = ['',''].toLocaleString(); + return list.join(comma); + } + // Write some data into the array. + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + assert.sameValue(SendableArray.prototype.toLocaleString.call(fixedLength), listToString([0,2,4,6])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(fixedLengthWithOffset), listToString([4,6])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(lengthTracking), listToString([0,2,4,6])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(lengthTrackingWithOffset), listToString([4,6])); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + assert.sameValue(SendableArray.prototype.toLocaleString.call(fixedLength), listToString([])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(fixedLengthWithOffset), listToString([])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(lengthTracking), listToString([0,2,4])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(lengthTrackingWithOffset), listToString([4])); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + assert.sameValue(SendableArray.prototype.toLocaleString.call(fixedLength), listToString([])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(fixedLengthWithOffset), listToString([])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(lengthTrackingWithOffset), listToString([])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(lengthTracking), listToString([0])); + // Shrink to zero. + rab.resize(0); + assert.sameValue(SendableArray.prototype.toLocaleString.call(fixedLength), listToString([])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(fixedLengthWithOffset), listToString([])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(lengthTrackingWithOffset), listToString([])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(lengthTracking), listToString([])); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + assert.sameValue(SendableArray.prototype.toLocaleString.call(fixedLength), listToString([0,2,4,6])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(fixedLengthWithOffset), listToString([4,6])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(lengthTracking), listToString([0,2,4,6,8,10])); + assert.sameValue(SendableArray.prototype.toLocaleString.call(lengthTrackingWithOffset), listToString([4,6,8,10])); +} diff --git a/test/sendable/builtins/Array/prototype/toLocaleString/user-provided-tolocalestring-grow.js b/test/sendable/builtins/Array/prototype/toLocaleString/user-provided-tolocalestring-grow.js new file mode 100644 index 00000000000..98c17d3ddc1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toLocaleString/user-provided-tolocalestring-grow.js @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tolocalestring +description: > + Array.p.toLocaleString behaves correctly when {Number,BigInt}.prototype.toLocaleString + is replaced with a user-provided function that grows the array. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +const oldNumberPrototypeToLocaleString = Number.prototype.toLocaleString; +const oldBigIntPrototypeToLocaleString = BigInt.prototype.toLocaleString; +// toLocaleString separator is implementation dependent. +function listToString(list) { + const comma = ['',''].toLocaleString(); + const len = list.length; + let result = ''; + if (len > 1) { + for (let i=0; i < len - 1 ; i++) { + result += list[i] + comma; + } + } + if (len > 0) { + result += list[len-1]; + } + return result; +} +// Growing + fixed-length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let resizeAfter = 2; + Number.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + } + return oldNumberPrototypeToLocaleString.call(this); + }; + BigInt.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + } + return oldBigIntPrototypeToLocaleString.call(this); + }; + // We iterate 4 elements since it was the starting length. Resizing doesn't + // affect the TA. + assert.sameValue(SendableArray.prototype.toLocaleString.call(fixedLength), listToString([0,0,0,0])); +} +// Growing + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + let resizeAfter = 2; + Number.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + } + return oldNumberPrototypeToLocaleString.call(this); + }; + BigInt.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + } + return oldBigIntPrototypeToLocaleString.call(this); + }; + + // We iterate 4 elements since it was the starting length. + assert.sameValue(SendableArray.prototype.toLocaleString.call(lengthTracking), listToString([0,0,0,0])); +} +Number.prototype.toLocaleString = oldNumberPrototypeToLocaleString; +BigInt.prototype.toLocaleString = oldBigIntPrototypeToLocaleString; diff --git a/test/sendable/builtins/Array/prototype/toLocaleString/user-provided-tolocalestring-shrink.js b/test/sendable/builtins/Array/prototype/toLocaleString/user-provided-tolocalestring-shrink.js new file mode 100644 index 00000000000..356a4ab42a8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toLocaleString/user-provided-tolocalestring-shrink.js @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tolocalestring +description: > + Array.p.toLocaleString behaves correctly when {Number,BigInt}.prototype.toLocaleString + is replaced with a user-provided function that shrinks the array. +includes: [resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +const oldNumberPrototypeToLocaleString = Number.prototype.toLocaleString; +const oldBigIntPrototypeToLocaleString = BigInt.prototype.toLocaleString; +// toLocaleString separator is implementation dependent. +function listToString(list) { + const comma = ['',''].toLocaleString(); + const len = list.length; + let result = ''; + if (len > 1) { + for (let i=0; i < len - 1 ; i++) { + result += list[i] + comma; + } + } + if (len > 0) { + result += list[len-1]; + } + return result; +} +// Shrinking + fixed-length TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + let resizeAfter = 2; + Number.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + } + return oldNumberPrototypeToLocaleString.call(this); + }; + BigInt.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + } + return oldBigIntPrototypeToLocaleString.call(this); + }; + + // We iterate 4 elements, since it was the starting length. The TA goes + // OOB after 2 elements. + assert.sameValue(SendableArray.prototype.toLocaleString.call(fixedLength),listToString([0,0,'',''])); +} +// Shrinking + length-tracking TA. +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const lengthTracking = new ctor(rab); + let resizeAfter = 2; + Number.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + } + return oldNumberPrototypeToLocaleString.call(this); + }; + BigInt.prototype.toLocaleString = function () { + --resizeAfter; + if (resizeAfter == 0) { + rab.resize(2 * ctor.BYTES_PER_ELEMENT); + } + return oldBigIntPrototypeToLocaleString.call(this); + }; + // We iterate 4 elements, since it was the starting length. Elements beyond + // the new length are converted to the empty string. + assert.sameValue(SendableArray.prototype.toLocaleString.call(lengthTracking),listToString([0,0,'',''])); +} +Number.prototype.toLocaleString = oldNumberPrototypeToLocaleString; +BigInt.prototype.toLocaleString = oldBigIntPrototypeToLocaleString; diff --git a/test/sendable/builtins/Array/prototype/toReversed/frozen-this-value.js b/test/sendable/builtins/Array/prototype/toReversed/frozen-this-value.js new file mode 100644 index 00000000000..c4048bf6caf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/frozen-this-value.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed works on frozen objects +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = Object.freeze([0, 1, 2]); +var result = arr.toReversed(); +assert.compareArray(result, [2, 1, 0]); +var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); +result = SendableArray.prototype.toReversed.call(arrayLike); +assert.compareArray(result, [2, 1, 0]); diff --git a/test/sendable/builtins/Array/prototype/toReversed/get-descending-order.js b/test/sendable/builtins/Array/prototype/toReversed/get-descending-order.js new file mode 100644 index 00000000000..a9efcc8432b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/get-descending-order.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed gets the array elements from the last one to the first one. +---*/ + +var order = []; +var arrayLike = { + length: 3, + get 0() { + order.push(0); + }, + get 1() { + order.push(1); + }, + get 2() { + order.push(2); + }, +}; +SendableArray.prototype.toReversed.call(arrayLike); +assert.compareArray(order, [2, 1, 0]); +order = []; +var arr = [0, 1, 2]; +Object.defineProperty(arr, 0, { get: function() { order.push(0); } }); +Object.defineProperty(arr, 1, { get: function() { order.push(1); } }); +Object.defineProperty(arr, 2, { get: function() { order.push(2); } }); +SendableArray.prototype.toReversed.call(arr); +assert.compareArray(order, [2, 1, 0]); diff --git a/test/sendable/builtins/Array/prototype/toReversed/holes-not-preserved.js b/test/sendable/builtins/Array/prototype/toReversed/holes-not-preserved.js new file mode 100644 index 00000000000..ae38019afda --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/holes-not-preserved.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed does not preserve holes in the array +---*/ + +var arr = [0, /* hole */, 2, /* hole */, 4]; +SendableArray.prototype[3] = 3; +var reversed = arr.toReversed(); +assert.compareArray(reversed, [4, 3, 2, undefined, 0]); +assert(reversed.hasOwnProperty(3)); diff --git a/test/sendable/builtins/Array/prototype/toReversed/ignores-species.js b/test/sendable/builtins/Array/prototype/toReversed/ignores-species.js new file mode 100644 index 00000000000..78a35923385 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/ignores-species.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed ignores @@species +---*/ + +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = function () {} +assert.sameValue(Object.getPrototypeOf(a.toReversed()), SendableArray.prototype); +var b = []; +Object.defineProperty(b, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } +}); +b.toReversed(); diff --git a/test/sendable/builtins/Array/prototype/toReversed/immutable.js b/test/sendable/builtins/Array/prototype/toReversed/immutable.js new file mode 100644 index 00000000000..423ec07666a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/immutable.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed does not mutate its this value +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2]; +arr.toReversed(); +assert.compareArray(arr, [0, 1, 2]); +assert.notSameValue(arr.toReversed(), arr); diff --git a/test/sendable/builtins/Array/prototype/toReversed/length-casted-to-zero.js b/test/sendable/builtins/Array/prototype/toReversed/length-casted-to-zero.js new file mode 100644 index 00000000000..4749e17be4b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/length-casted-to-zero.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed creates an empty array if the this value .length is not a positive integer. +info: | + Array.prototype.toReversed ( ) + 2. Let len be ? LengthOfArrayLike(O). +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(SendableArray.prototype.toReversed.call({ length: -2 }), []); +assert.compareArray(SendableArray.prototype.toReversed.call({ length: "dog" }), []); +assert.compareArray(SendableArray.prototype.toReversed.call({ length: NaN }), []); diff --git a/test/sendable/builtins/Array/prototype/toReversed/length-decreased-while-iterating.js b/test/sendable/builtins/Array/prototype/toReversed/length-decreased-while-iterating.js new file mode 100644 index 00000000000..8bdfbb8e984 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/length-decreased-while-iterating.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed caches the length getting the array elements. +---*/ + +var arr = [0, 1, 2, 3, 4]; +SendableArray.prototype[1] = 5; +Object.defineProperty(arr, "3", { + get() { + arr.length = 1; + return 3; + } +}); +assert.compareArray(arr.toReversed(), [4, 3, undefined, 5, 0]); diff --git a/test/sendable/builtins/Array/prototype/toReversed/length-exceeding-array-length-limit.js b/test/sendable/builtins/Array/prototype/toReversed/length-exceeding-array-length-limit.js new file mode 100644 index 00000000000..54a2c4d71f0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/length-exceeding-array-length-limit.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed limits the length to 2 ** 32 - 1 +info: | + Array.prototype.toReversed ( ) +---*/ + +// Object with large "length" property +var arrayLike = { + get "0"() { + throw new Test262Error("Get 0"); + }, + get "4294967295" () { // 2 ** 32 - 1 + throw new Test262Error("Get 2147483648"); + }, + get "4294967296" () { // 2 ** 32 + throw new Test262Error("Get 2147483648"); + }, + length: 2 ** 32 +}; +assert.throws(RangeError, function() { + SendableArray.prototype.toReversed.call(arrayLike); +}); diff --git a/test/sendable/builtins/Array/prototype/toReversed/length-increased-while-iterating.js b/test/sendable/builtins/Array/prototype/toReversed/length-increased-while-iterating.js new file mode 100644 index 00000000000..299ff3ee671 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/length-increased-while-iterating.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed caches the length getting the array elements. +---*/ + +var arr = [0, 1, 2]; +Object.defineProperty(arr, "0", { + get() { + arr.push(4); + return 0; + } +}); +assert.compareArray(arr.toReversed(), [2, 1, 0]); diff --git a/test/sendable/builtins/Array/prototype/toReversed/length-tolength.js b/test/sendable/builtins/Array/prototype/toReversed/length-tolength.js new file mode 100644 index 00000000000..d8754fb1cd9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/length-tolength.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed converts the this value length to a number. +---*/ + +assert.compareArray(SendableArray.prototype.toReversed.call({ length: "2", 0: 1, 1: 2, 2: 3 }), [2, 1]); +var arrayLike = { + length: { + valueOf: () => 2 + }, + 0: 1, + 1: 2, + 2: 3, +}; +assert.compareArray(SendableArray.prototype.toReversed.call(arrayLike), [2, 1]); diff --git a/test/sendable/builtins/Array/prototype/toReversed/length.js b/test/sendable/builtins/Array/prototype/toReversed/length.js new file mode 100644 index 00000000000..8c847691b8c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/length.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + The "length" property of Array.prototype.toReversed +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +features: [change-array-by-copy] +---*/ + +verifyProperty(SendableArray.prototype.toReversed, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/toReversed/name.js b/test/sendable/builtins/Array/prototype/toReversed/name.js new file mode 100644 index 00000000000..b7804ad9e88 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/name.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed.name is "toReversed". +info: | + Array.prototype.toReversed ( ) + 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] +features: [change-array-by-copy] +---*/ + +verifyProperty(SendableArray.prototype.toReversed, "name", { + value: "toReversed", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/toReversed/not-a-constructor.js b/test/sendable/builtins/Array/prototype/toReversed/not-a-constructor.js new file mode 100644 index 00000000000..a04f729b54f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/not-a-constructor.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.toReversed 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: [change-array-by-copy, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(SendableArray.prototype.toReversed), + false, + 'isConstructor(SendableArray.prototype.toReversed) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.toReversed(); +}); + diff --git a/test/sendable/builtins/Array/prototype/toReversed/property-descriptor.js b/test/sendable/builtins/Array/prototype/toReversed/property-descriptor.js new file mode 100644 index 00000000000..e6e128a49f7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/property-descriptor.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + "toReversed" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + 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] +features: [change-array-by-copy] +---*/ + +assert.sameValue(typeof SendableArray.prototype.toReversed, "function", "typeof"); +verifyProperty(SendableArray.prototype, "toReversed", { + value: SendableArray.prototype.toReversed, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/toReversed/this-value-boolean.js b/test/sendable/builtins/Array/prototype/toReversed/this-value-boolean.js new file mode 100644 index 00000000000..68ec6c0787c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/this-value-boolean.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed converts booleans to objects +info: | + Array.prototype.toReversed ( ) + + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). + ... +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(SendableArray.prototype.toReversed.call(true), []); +assert.compareArray(SendableArray.prototype.toReversed.call(false), []); +/* Add length and indexed properties to `Boolean.prototype` */ +Boolean.prototype.length = 3; +assert.compareArray(SendableArray.prototype.toReversed.call(true), [undefined, undefined, undefined]); +assert.compareArray(SendableArray.prototype.toReversed.call(false), [undefined, undefined, undefined]); +delete Boolean.prototype.length; +Boolean.prototype[0] = "monkeys"; +Boolean.prototype[2] = "bogus"; +assert.compareArray(SendableArray.prototype.toReversed.call(true), []); +assert.compareArray(SendableArray.prototype.toReversed.call(false), []); diff --git a/test/sendable/builtins/Array/prototype/toReversed/this-value-nullish.js b/test/sendable/builtins/Array/prototype/toReversed/this-value-nullish.js new file mode 100644 index 00000000000..4bc4ab0a8c3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/this-value-nullish.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed throws if the receiver is null or undefined +---*/ + +assert.throws(TypeError, () => { + SendableArray.prototype.toReversed.call(null); +}); +assert.throws(TypeError, () => { + SendableArray.prototype.toReversed.call(undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/toReversed/zero-or-one-element.js b/test/sendable/builtins/Array/prototype/toReversed/zero-or-one-element.js new file mode 100644 index 00000000000..c4724a64796 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toReversed/zero-or-one-element.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toReversed +description: > + Array.prototype.toReversed returns a new array even if it has zero or one elements +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var zero = []; +var zeroReversed = zero.toReversed(); +assert.notSameValue(zero, zeroReversed); +assert.compareArray(zero, zeroReversed); +var one = [1]; +var oneReversed = one.toReversed(); +assert.notSameValue(one, oneReversed); +assert.compareArray(one, oneReversed); diff --git a/test/sendable/builtins/Array/prototype/toSorted/comparefn-called-after-get-elements.js b/test/sendable/builtins/Array/prototype/toSorted/comparefn-called-after-get-elements.js new file mode 100644 index 00000000000..dccd9abb54c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/comparefn-called-after-get-elements.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted reads all the array elements before calling compareFn +info: | + SortIndexedProperties ( obj, len, SortCompare, skipHoles ) + 3. Repeat, while k < len, + a. Let Pk be ! ToString(𝔽(k)). + i. Let kValue be ? Get(O, Pk). + 4. Sort items using an implementation-defined sequence of + calls to SortCompare. If any such call returns an abrupt + completion, stop before performing any further calls to + SortCompare or steps in this algorithm and return that + Completion Record. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var getCalls = []; +var arrayLike = { + length: 3, + get 0() { getCalls.push(0); return 2; }, + get 1() { getCalls.push(1); return 1; }, + get 2() { getCalls.push(2); return 3; }, +} +assert.throws(Test262Error, function() { + SendableArray.prototype.toSorted.call(arrayLike, () => { + throw new Test262Error(); + }); +}); +assert.compareArray(getCalls, [0, 1, 2]); diff --git a/test/sendable/builtins/Array/prototype/toSorted/comparefn-not-a-function.js b/test/sendable/builtins/Array/prototype/toSorted/comparefn-not-a-function.js new file mode 100644 index 00000000000..9e9afe22918 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/comparefn-not-a-function.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted verifies that the comparator is callable before reading the length. +info: | + Array.prototype.toSorted ( compareFn ) + 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. + 2. ... + 3. Let len be ? LengthOfArrayLike(O). +features: [change-array-by-copy] +---*/ + +var getLengthThrow = { + get length() { + throw new Test262Error("IsCallable(comparefn) should be observed before this.length"); + } +}; +var invalidComparators = [null, true, false, "", /a/g, 42, 42n, [], {}, Symbol()]; +for (var i = 0; i < invalidComparators.length; i++) { + assert.throws(TypeError, function() { + [1].toSorted(invalidComparators[i]); + }, String(invalidComparators[i]) + " on an array"); + assert.throws(TypeError, function() { + SendableArray.prototype.toSorted.call(getLengthThrow, invalidComparators[i]); + }, String(invalidComparators[i]) + " on an object whose 'length' throws"); +} diff --git a/test/sendable/builtins/Array/prototype/toSorted/comparefn-stop-after-error.js b/test/sendable/builtins/Array/prototype/toSorted/comparefn-stop-after-error.js new file mode 100644 index 00000000000..e098e308305 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/comparefn-stop-after-error.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted doesn't call compareFn if there is an error +info: | + Array.prototype.toSorted ( compareFn ) + 7. Sort items using an implementation-defined sequence of + calls to SortCompare. If any such call returns an abrupt + completion, stop before performing any further calls to + SortCompare or steps in this algorithm and return that completion. +features: [change-array-by-copy] +---*/ + +var arrayLike = { + length: 1, + get 0() { throw new Test262Error(); }, +}; +var called = false; +assert.throws(Test262Error, function() { + SendableArray.prototype.toSorted.call(arrayLike, () => { + called = true; + }); +}); +assert.sameValue(called, false); +called = 0; +assert.throws(Test262Error, function() { + [1, 2, 3].toSorted(() => { + ++called; + if (called === 1) { + throw new Test262Error(); + } + }); +}); +assert.sameValue(called, 1); diff --git a/test/sendable/builtins/Array/prototype/toSorted/frozen-this-value.js b/test/sendable/builtins/Array/prototype/toSorted/frozen-this-value.js new file mode 100644 index 00000000000..7ea93595afb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/frozen-this-value.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted works on frozen objects +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = Object.freeze([2, 0, 1]); +var result = arr.toSorted(); +assert.compareArray(result, [0, 1, 2]); +var arrayLike = Object.freeze({ length: 3, 0: 2, 1: 0, 2: 1 }); +result = SendableArray.prototype.toSorted.call(arrayLike); +assert.compareArray(result, [0, 1, 2]); diff --git a/test/sendable/builtins/Array/prototype/toSorted/holes-not-preserved.js b/test/sendable/builtins/Array/prototype/toSorted/holes-not-preserved.js new file mode 100644 index 00000000000..39362c712c9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/holes-not-preserved.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted does not preserve holes in the array +info: | + Array.prototype.toSorted ( compareFn ) + 8. Repeat, while j < len, + a. Perform ! CreateDataPropertyOrThrow(A, ! ToString(𝔽(j)), sortedList[j]). + b. Set j to j + 1. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [3, /* hole */, 4, /* hole */, 1]; +SendableArray.prototype[3] = 2; +var sorted = arr.toSorted(); +assert.compareArray(sorted, [1, 2, 3, 4, undefined]); +assert(sorted.hasOwnProperty(4)); diff --git a/test/sendable/builtins/Array/prototype/toSorted/ignores-species.js b/test/sendable/builtins/Array/prototype/toSorted/ignores-species.js new file mode 100644 index 00000000000..42d9147b009 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/ignores-species.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted ignores @@species +info: | + Array.prototype.toSorted ( compareFn ) + 8. Let A be ? ArrayCreate(𝔽(len)). +features: [change-array-by-copy] +---*/ + +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = function () {} +assert.sameValue(Object.getPrototypeOf(a.toSorted()), SendableArray.prototype); +var b = []; +Object.defineProperty(b, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } +}); +b.toSorted(); diff --git a/test/sendable/builtins/Array/prototype/toSorted/immutable.js b/test/sendable/builtins/Array/prototype/toSorted/immutable.js new file mode 100644 index 00000000000..19418ed536b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/immutable.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted does not mutate its this value +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [2, 0, 1]; +arr.toSorted(); +assert.compareArray(arr, [2, 0, 1]); +assert.notSameValue(arr.toSorted(), arr); diff --git a/test/sendable/builtins/Array/prototype/toSorted/length-casted-to-zero.js b/test/sendable/builtins/Array/prototype/toSorted/length-casted-to-zero.js new file mode 100644 index 00000000000..e2533f9492c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/length-casted-to-zero.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted creates an empty array if the this value .length is not a positive integer. +info: | + Array.prototype.toSorted ( compareFn ) + 3. Let len be ? LengthOfArrayLike(O). +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(SendableArray.prototype.toSorted.call({ length: -2 }), []); +assert.compareArray(SendableArray.prototype.toSorted.call({ length: "dog" }), []); +assert.compareArray(SendableArray.prototype.toSorted.call({ length: NaN }), []); diff --git a/test/sendable/builtins/Array/prototype/toSorted/length-decreased-while-iterating.js b/test/sendable/builtins/Array/prototype/toSorted/length-decreased-while-iterating.js new file mode 100644 index 00000000000..8b59dc68563 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/length-decreased-while-iterating.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted caches the length getting the array elements. +info: | + Array.prototype.toSorted ( compareFn ) + 3. Let len be ? LengthOfArrayLike(O). + 6. Let sortedList be ? SortIndexedProperties(obj, len, SortCompare, false). +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [5, 1, 4, 6, 3]; +SendableArray.prototype[3] = 2; +Object.defineProperty(arr, "2", { + get() { + arr.length = 1; + return 4; + } +}); +assert.compareArray(arr.toSorted(), [1, 2, 4, 5, undefined]); diff --git a/test/sendable/builtins/Array/prototype/toSorted/length-exceeding-array-length-limit.js b/test/sendable/builtins/Array/prototype/toSorted/length-exceeding-array-length-limit.js new file mode 100644 index 00000000000..48601b3b55f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/length-exceeding-array-length-limit.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted limits the length to 2 ** 32 - 1 +---*/ + +// Object with large "length" property +var arrayLike = { + get "0"() { + throw new Test262Error("Get 0"); + }, + get "4294967295" () { // 2 ** 32 - 1 + throw new Test262Error("Get 2147483648"); + }, + get "4294967296" () { // 2 ** 32 + throw new Test262Error("Get 2147483648"); + }, + length: 2 ** 32 +}; +assert.throws(RangeError, function() { + SendableArray.prototype.toSorted.call(arrayLike); +}); diff --git a/test/sendable/builtins/Array/prototype/toSorted/length-increased-while-iterating.js b/test/sendable/builtins/Array/prototype/toSorted/length-increased-while-iterating.js new file mode 100644 index 00000000000..cb2dc14db93 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/length-increased-while-iterating.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted caches the length getting the array elements. +---*/ + +var arr = [5, 0, 3]; +Object.defineProperty(arr, "0", { + get() { + arr.push(1); + return 5; + } +}); +assert.compareArray(arr.toSorted(), [0, 3, 5]); diff --git a/test/sendable/builtins/Array/prototype/toSorted/length-tolength.js b/test/sendable/builtins/Array/prototype/toSorted/length-tolength.js new file mode 100644 index 00000000000..70174996ff7 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/length-tolength.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted converts the this value length to a number. +---*/ + +assert.compareArray(SendableArray.prototype.toSorted.call({ length: "2", 0: 4, 1: 0, 2: 1 }), [0, 4]); +var arrayLike = { + length: { + valueOf: () => 2 + }, + 0: 4, + 1: 0, + 2: 1, +}; +assert.compareArray(SendableArray.prototype.toSorted.call(arrayLike), [0, 4]); diff --git a/test/sendable/builtins/Array/prototype/toSorted/length.js b/test/sendable/builtins/Array/prototype/toSorted/length.js new file mode 100644 index 00000000000..a426c65909e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/length.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + The "length" property of Array.prototype.toSorted +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +features: [change-array-by-copy] +---*/ + +verifyProperty(SendableArray.prototype.toSorted, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/toSorted/name.js b/test/sendable/builtins/Array/prototype/toSorted/name.js new file mode 100644 index 00000000000..ad602cd09cf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/name.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted.name is "toSorted". +info: | + Array.prototype.toSorted ( compareFn ) + 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] +features: [change-array-by-copy] +---*/ + +verifyProperty(SendableArray.prototype.toSorted, "name", { + value: "toSorted", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/toSorted/not-a-constructor.js b/test/sendable/builtins/Array/prototype/toSorted/not-a-constructor.js new file mode 100644 index 00000000000..57f7953afdf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/not-a-constructor.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.toSorted 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: [change-array-by-copy, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(SendableArray.prototype.toSorted), + false, + 'isConstructor(SendableArray.prototype.toSorted) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.toSorted(); +}); + diff --git a/test/sendable/builtins/Array/prototype/toSorted/property-descriptor.js b/test/sendable/builtins/Array/prototype/toSorted/property-descriptor.js new file mode 100644 index 00000000000..15b1523687e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/property-descriptor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + "toSorted" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +features: [change-array-by-copy] +---*/ + +assert.sameValue(typeof SendableArray.prototype.toSorted, "function", "typeof"); +verifyProperty(SendableArray.prototype, "toSorted", { + value: SendableArray.prototype.toSorted, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/toSorted/this-value-boolean.js b/test/sendable/builtins/Array/prototype/toSorted/this-value-boolean.js new file mode 100644 index 00000000000..6d0bb6d2c7b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/this-value-boolean.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted converts booleans to objects +info: | + Array.prototype.toSorted ( compareFn ) + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(SendableArray.prototype.toSorted.call(true), []); +assert.compareArray(SendableArray.prototype.toSorted.call(false), []); +/* Add length and indexed properties to `Boolean.prototype` */ +Boolean.prototype.length = 3; +assert.compareArray(SendableArray.prototype.toSorted.call(true), [undefined, undefined, undefined]); +assert.compareArray(SendableArray.prototype.toSorted.call(false), [undefined, undefined, undefined]); +delete Boolean.prototype.length; +Boolean.prototype[0] = "monkeys"; +Boolean.prototype[2] = "bogus"; +assert.compareArray(SendableArray.prototype.toSorted.call(true), []); +assert.compareArray(SendableArray.prototype.toSorted.call(false), []); diff --git a/test/sendable/builtins/Array/prototype/toSorted/this-value-nullish.js b/test/sendable/builtins/Array/prototype/toSorted/this-value-nullish.js new file mode 100644 index 00000000000..84c922c7cc6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/this-value-nullish.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted throws if the receiver is null or undefined +info: | + Array.prototype.toSorted ( compareFn ) + 1. Let O be ? ToObject(this value). +features: [change-array-by-copy] +---*/ + +assert.throws(TypeError, () => { + SendableArray.prototype.toSorted.call(null); +}); +assert.throws(TypeError, () => { + SendableArray.prototype.toSorted.call(undefined); +}); diff --git a/test/sendable/builtins/Array/prototype/toSorted/zero-or-one-element.js b/test/sendable/builtins/Array/prototype/toSorted/zero-or-one-element.js new file mode 100644 index 00000000000..9c3784d1789 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSorted/zero-or-one-element.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted returns a new array even if it has zero or one elements +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var zero = []; +var zeroReversed = zero.toSorted(); +assert.notSameValue(zero, zeroReversed); +assert.compareArray(zero, zeroReversed); +var one = [1]; +var oneReversed = one.toSorted(); +assert.notSameValue(one, oneReversed); +assert.compareArray(one, oneReversed); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js b/test/sendable/builtins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js new file mode 100644 index 00000000000..c106ed4ac02 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/deleteCount-clamped-between-zero-and-remaining-count.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: deleteCount is clamped between zero and len - actualStart +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + 10. Else, + a. Let dc be ? ToIntegerOrInfinity(deleteCount). + b. Let actualDeleteCount be the result of clamping dc between 0 and len - actualStart. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray( + [0, 1, 2, 3, 4, 5].toSpliced(2, -1), + [0, 1, 2, 3, 4, 5] +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].toSpliced(-4, -1), + [0, 1, 2, 3, 4, 5] +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].toSpliced(2, 6), + [0, 1] +); +assert.compareArray( + [0, 1, 2, 3, 4, 5].toSpliced(-4, 6), + [0, 1] +); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/deleteCount-missing.js b/test/sendable/builtins/Array/prototype/toSpliced/deleteCount-missing.js new file mode 100644 index 00000000000..b3d0a33b5e3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/deleteCount-missing.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced deletes the elements after start when called with one argument +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + 9. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var result = ["first", "second", "third"].toSpliced(1); +assert.compareArray(result, ["first"]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/deleteCount-undefined.js b/test/sendable/builtins/Array/prototype/toSpliced/deleteCount-undefined.js new file mode 100644 index 00000000000..449cf24c4a6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/deleteCount-undefined.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced(number, undefined) returns a copy of the original array +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 6. Else, let actualStart be min(relativeStart, len). + 8. If start is not present, then + a. Let actualDeleteCount be 0. + 9. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. + 10. Else, + a. Let dc be ? ToIntegerOrInfinity(deleteCount). + b. Let actualDeleteCount be the result of clamping dc between 0 and len - actualStart. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var result = ["first", "second", "third"].toSpliced(1, undefined); +assert.compareArray(result, ["first", "second", "third"]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/discarded-element-not-read.js b/test/sendable/builtins/Array/prototype/toSpliced/discarded-element-not-read.js new file mode 100644 index 00000000000..6963f706249 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/discarded-element-not-read.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced does not Get the discarded elements in the original array +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 6. Else, let actualStart be min(relativeStart, len). + 8. If start is not present, then + a. Let actualDeleteCount be 0. + 9. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. + 10. Else, + a. Let dc be ? ToIntegerOrInfinity(deleteCount). + b. Let actualDeleteCount be the result of clamping dc between 0 and len - actualStart. + 11. Let newLen be len + insertCount - actualDeleteCount. + 15. Let r be actualStart + actualDeleteCount. + 18. Repeat, while i < newLen, + a. Let Pi be ! ToString(𝔽(i)). + b. Let from be ! ToString(𝔽(r)). + c. Let fromValue be ? Get(O, from). + d. Perform ! CreateDataPropertyOrThrow(A, Pi, fromValue). + e. Set i to i + 1. + f. Set r to r + 1. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arrayLike = { + 0: "a", + 1: "b", + get 2() { throw new Test262Error(); }, + 3: "c", + length: 4, +}; +/* + * In this example, just before step 18, i == 2 and r == 3. + * So A[2] is set to arrayLike[3] and arrayLike[2] is never read + * (since i and r both increase monotonically). + */ +var result = SendableArray.prototype.toSpliced.call(arrayLike, 2, 1); +assert.compareArray(result, ["a", "b", "c"]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/elements-read-in-order.js b/test/sendable/builtins/Array/prototype/toSpliced/elements-read-in-order.js new file mode 100644 index 00000000000..46b5b210a06 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/elements-read-in-order.js @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced reads the items of the original array in order +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + 14. Let i be 0. + 15. Let r be actualStart + actualDeleteCount. + 16. Repeat, while i < actualStart, + a. Let Pi be ! ToString(𝔽(i)). + b. Let iValue be ? Get(O, Pi). + c. Perform ! CreateDataPropertyOrThrow(A, Pi, iValue). + d. Set i to i + 1. + 17. For each element E of items, do + a. Let Pi be ! ToString(𝔽(i)). + b. Perform ! CreateDataPropertyOrThrow(A, Pi, E). + c. Set i to i + 1. + 18. Repeat, while i < newLen, + a. Let Pi be ! ToString(𝔽(i)). + b. Let from be ! ToString(𝔽(r)). + c. Let fromValue be ? Get(O, from). + d. Perform ! CreateDataPropertyOrThrow(A, Pi, fromValue). + e. Set i to i + 1. + f. Set r to r + 1. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var order = []; +var arrayLike = { + get 0() { order.push(0); return "a" }, + get 1() { order.push(1); return "b" }, + 2: "none", + get 3() { order.push(3); return "c" }, + length: 4, +}; +var result = SendableArray.prototype.toSpliced.call(arrayLike, 2, 1); +assert.compareArray(result, ["a", "b", "c"]); +assert.compareArray(order, [0, 1, 3]); +order = []; +var arr = [0, 1, "none", 3]; +Object.defineProperty(arr, 0, { get: function() { order.push(0); return "a" } }); +Object.defineProperty(arr, 1, { get: function() { order.push(1); return "b" } }); +Object.defineProperty(arr, 3, { get: function() { order.push(3); return "c" } }); +result = SendableArray.prototype.toSpliced.call(arr, 2, 1); +assert.compareArray(result, ["a", "b", "c"]); +assert.compareArray(order, [0, 1, 3]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/frozen-this-value.js b/test/sendable/builtins/Array/prototype/toSpliced/frozen-this-value.js new file mode 100644 index 00000000000..88f40cc5516 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/frozen-this-value.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced works on frozen objects +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = Object.freeze([2, 0, 1]); +var result = arr.toSpliced(); +assert.compareArray(result, [2, 0, 1]); +var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); +assert.compareArray(SendableArray.prototype.toSpliced.call(arrayLike, 1, 1, 4, 5), [0, 4, 5, 2]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/holes-not-preserved.js b/test/sendable/builtins/Array/prototype/toSpliced/holes-not-preserved.js new file mode 100644 index 00000000000..6619767d006 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/holes-not-preserved.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced does not preserve holes in the array +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + 13. Let k be 0. + 14. Repeat, while k < actualStart, + a. Let Pk be ! ToString(𝔽(k)). + b. Let kValue be ? Get(O, Pk). + c. Perform ? CreateDataPropertyOrThrow(A, Pk, kValue). + d. Set k to k + 1. + 16. Repeat, while k < newLen, + a. Let Pk be ! ToString(𝔽(k)). + b. Let from be ! ToString(𝔽(k + actualDeleteCount - insertCount)). + c. Let fromValue be ? Get(O, from). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. +includes: [compareArray.js] +features: [change-array-by-copy] +---*/ + +var arr = [0, /* hole */, 2, /* hole */, 4]; +SendableArray.prototype[3] = 3; +var spliced = arr.toSpliced(0, 0); +assert.compareArray(spliced, [0, undefined, 2, 3, 4]); +assert(spliced.hasOwnProperty(1)); +assert(spliced.hasOwnProperty(3)); +spliced = arr.toSpliced(0, 0, -1); +assert.compareArray(spliced, [-1, 0, undefined, 2, 3, 4]); +assert(spliced.hasOwnProperty(1)); +assert(spliced.hasOwnProperty(3)); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/ignores-species.js b/test/sendable/builtins/Array/prototype/toSpliced/ignores-species.js new file mode 100644 index 00000000000..f4943e04405 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/ignores-species.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced ignores @@species +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + 12. Let A be ? ArrayCreate(𝔽(newLen)). +features: [change-array-by-copy] +---*/ + +var a = []; +a.constructor = {}; +a.constructor[Symbol.species] = function () {} +assert.sameValue(Object.getPrototypeOf(a.toSpliced(0, 0)), SendableArray.prototype); +var b = []; +Object.defineProperty(b, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } +}); +b.toSpliced(0, 0); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/immutable.js b/test/sendable/builtins/Array/prototype/toSpliced/immutable.js new file mode 100644 index 00000000000..0be967b4010 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/immutable.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced does not mutate its this value +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [2, 0, 1]; +arr.toSpliced(0, 0, -1); +assert.compareArray(arr, [2, 0, 1]); +assert.notSameValue(arr.toSpliced(0, 0, -1), arr); +assert.notSameValue(arr.toSpliced(0, 1, -1), arr); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/length-casted-to-zero.js b/test/sendable/builtins/Array/prototype/toSpliced/length-casted-to-zero.js new file mode 100644 index 00000000000..86a2140dee6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/length-casted-to-zero.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced treats its `this` value's `length` property as zero if the + property's value is not a positive integer. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + 2. Let len be ? LengthOfArrayLike(O). +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(SendableArray.prototype.toSpliced.call({ length: -2 }, 0, 0, 2, 3), [2, 3]); +assert.compareArray(SendableArray.prototype.toSpliced.call({ length: "dog" }, 0, 0, 2, 3), [2, 3]); +assert.compareArray(SendableArray.prototype.toSpliced.call({ length: NaN }, 0, 0, 2, 3), [2, 3]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js b/test/sendable/builtins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js new file mode 100644 index 00000000000..87a86bc8d4a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Length is clamped to 2^53-1 when they exceed the integer limit. +---*/ + +var arrayLike = { + "9007199254740989": 2 ** 53 - 3, + "9007199254740990": 2 ** 53 - 2, + "9007199254740991": 2 ** 53 - 1, + "9007199254740992": 2 ** 53, + "9007199254740994": 2 ** 53 + 2, // NOTE: 2 ** 53 + 1 is 2 ** 53 + length: 2 ** 53 + 20, +}; +var result = SendableArray.prototype.toSpliced.call(arrayLike, 0, 2 ** 53 - 3); +assert.sameValue(result.length, 2); +assert.compareArray(result, [2 ** 53 - 3, 2 ** 53 - 2]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/length-decreased-while-iterating.js b/test/sendable/builtins/Array/prototype/toSpliced/length-decreased-while-iterating.js new file mode 100644 index 00000000000..87aec8c88d6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/length-decreased-while-iterating.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced caches the length getting the array elements. +---*/ + +var arr = [0, 1, 2, 3, 4, 5]; +SendableArray.prototype[3] = 6; +Object.defineProperty(arr, "2", { + get() { + arr.length = 1; + return 2; + } +}); +assert.compareArray(arr.toSpliced(0, 0), [0, 1, 2, 6, undefined, undefined]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js b/test/sendable/builtins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js new file mode 100644 index 00000000000..5ba1f7af1d1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced limits the length to 2 ** 32 - 1 +---*/ + +// Object with large "length" property +var arrayLike = { + get "0"() { + throw new Test262Error("Get 0"); + }, + get "4294967295" () { // 2 ** 32 - 1 + throw new Test262Error("Get 4294967295"); + }, + get "4294967296" () { // 2 ** 32 + throw new Test262Error("Get 4294967296"); + }, + length: 2 ** 32 +}; +assert.throws(RangeError, function() { + SendableArray.prototype.toSpliced.call(arrayLike, 0, 0); +}); +arrayLike.length = 2 ** 32 - 1; +assert.throws(RangeError, function() { + SendableArray.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); +arrayLike.length = 2 ** 32; +assert.throws(RangeError, function() { + SendableArray.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); +arrayLike.length = 2 ** 32 + 1; +assert.throws(RangeError, function() { + SendableArray.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); +arrayLike.length = 2 ** 52 - 2; +assert.throws(RangeError, function() { + SendableArray.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); +arrayLike.length = 2 ** 53 - 1; +assert.throws(TypeError, function() { + SendableArray.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); +arrayLike.length = 2 ** 53; +assert.throws(TypeError, function() { + SendableArray.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); +arrayLike.length = 2 ** 53 + 1; +assert.throws(TypeError, function() { + SendableArray.prototype.toSpliced.call(arrayLike, 0, 0, 1); +}); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/length-increased-while-iterating.js b/test/sendable/builtins/Array/prototype/toSpliced/length-increased-while-iterating.js new file mode 100644 index 00000000000..4ea2fec2ffd --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/length-increased-while-iterating.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced caches the length getting the array elements. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) +---*/ + +var arr = [0, 1, 2]; +Object.defineProperty(arr, "0", { + get() { + arr.push(10); + return 0; + } +}); +Object.defineProperty(arr, "2", { + get() { + arr.push(11); + return 2; + } +}); +assert.compareArray(arr.toSpliced(1, 0, 0.5), [0, 0.5, 1, 2]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/length-tolength.js b/test/sendable/builtins/Array/prototype/toSpliced/length-tolength.js new file mode 100644 index 00000000000..94a39f4cdf3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/length-tolength.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced converts the this value length to a number. +---*/ + +assert.compareArray(SendableArray.prototype.toSpliced.call({ length: "2", 0: 0, 1: 1, 2: 2 }, 0, 0), [0, 1]); +var arrayLike = { + length: { + valueOf: () => 2 + }, + 0: 0, + 1: 1, + 2: 2, +}; +assert.compareArray(SendableArray.prototype.toSpliced.call(arrayLike, 0, 0), [0, 1]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/length.js b/test/sendable/builtins/Array/prototype/toSpliced/length.js new file mode 100644 index 00000000000..df82e6d2266 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/length.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + The "length" property of Array.prototype.toSpliced +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +features: [change-array-by-copy] +---*/ + +verifyProperty(SendableArray.prototype.toSpliced, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/mutate-while-iterating.js b/test/sendable/builtins/Array/prototype/toSpliced/mutate-while-iterating.js new file mode 100644 index 00000000000..01c9ee6723f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/mutate-while-iterating.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced gets array elements one at a time. +---*/ + +var arr = [0, 1, 2, 3]; +var zerothElementStorage = arr[0]; +Object.defineProperty(arr, "0", { + get() { + arr[1] = 42; + return zerothElementStorage; + }, + set(v) { + zerothElementStorage = v; + } +}); +Object.defineProperty(arr, "2", { + get() { + arr[0] = 17; + arr[3] = 37; + return 2; + } +}); +assert.compareArray(arr.toSpliced(1, 0, 0.5), [0, 0.5, 42, 2, 37]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/name.js b/test/sendable/builtins/Array/prototype/toSpliced/name.js new file mode 100644 index 00000000000..d6e37dc2694 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/name.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced.name is "toSpliced". +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + 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] +features: [change-array-by-copy] +---*/ + +verifyProperty(SendableArray.prototype.toSpliced, "name", { + value: "toSpliced", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/not-a-constructor.js b/test/sendable/builtins/Array/prototype/toSpliced/not-a-constructor.js new file mode 100644 index 00000000000..28b67085b0d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/not-a-constructor.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.toSpliced 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: [change-array-by-copy, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(SendableArray.prototype.toSpliced), + false, + 'isConstructor(SendableArray.prototype.toSpliced) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.toSpliced(); +}); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/property-descriptor.js b/test/sendable/builtins/Array/prototype/toSpliced/property-descriptor.js new file mode 100644 index 00000000000..0c922dca1e0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/property-descriptor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + "toSpliced" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +features: [change-array-by-copy] +---*/ + +assert.sameValue(typeof SendableArray.prototype.toSpliced, "function", "typeof"); +verifyProperty(SendableArray.prototype, "toSpliced", { + value: SendableArray.prototype.toSpliced, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/start-and-deleteCount-missing.js b/test/sendable/builtins/Array/prototype/toSpliced/start-and-deleteCount-missing.js new file mode 100644 index 00000000000..302670361c6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/start-and-deleteCount-missing.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced returns a copy of the array if called with zero arguments +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 6. Else, let actualStart be min(relativeStart, len). + 8. If start is not present, then + a. Let actualDeleteCount be 0. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +let arr = ["first", "second", "third"]; +let result = arr.toSpliced(); +assert.compareArray(result, arr); +assert.notSameValue(result, arr); + diff --git a/test/sendable/builtins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js b/test/sendable/builtins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js new file mode 100644 index 00000000000..9e7c2965f3b --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced(undefined, undefined) returns a copy of the original array +---*/ + +let arr = ["first", "second", "third"]; +let result = arr.toSpliced(undefined, undefined); +assert.compareArray(result, arr); +assert.notSameValue(result, arr); + diff --git a/test/sendable/builtins/Array/prototype/toSpliced/start-bigger-than-length.js b/test/sendable/builtins/Array/prototype/toSpliced/start-bigger-than-length.js new file mode 100644 index 00000000000..e99efb24210 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/start-bigger-than-length.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced clamps the start argument to the this value length. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 4. If relativeStart is -∞, let actualStart be 0. + 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). + 6. Else, let actualStart be min(relativeStart, len). +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var result = [0, 1, 2, 3, 4].toSpliced(10, 1, 5, 6); +assert.compareArray(result, [0, 1, 2, 3, 4, 5, 6]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js b/test/sendable/builtins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js new file mode 100644 index 00000000000..16a9c31e174 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/start-neg-infinity-is-zero.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced treats negative Infinity as zero for start. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 4. If relativeStart is -∞, let actualStart be 0. + 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var result = [0, 1, 2, 3, 4].toSpliced(-Infinity, 2); +assert.compareArray(result, [2, 3, 4]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js b/test/sendable/builtins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js new file mode 100644 index 00000000000..bde832bdd26 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/start-neg-less-than-minus-length-is-zero.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced treats a value smaller than -length as zero for start. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 4. If relativeStart is -∞, let actualStart be 0. + 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var result = [0, 1, 2, 3, 4].toSpliced(-20, 2); +assert.compareArray(result, [2, 3, 4]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js b/test/sendable/builtins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js new file mode 100644 index 00000000000..48a716f8941 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/start-neg-subtracted-from-length.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced treats a negative start as relative to the end. +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 4. If relativeStart is -∞, let actualStart be 0. + 5. Else if relativeStart < 0, let actualStart be max(len + relativeStart, 0). +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var result = [0, 1, 2, 3, 4].toSpliced(-3, 2); +assert.compareArray(result, [0, 1, 4]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js b/test/sendable/builtins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js new file mode 100644 index 00000000000..11a7bff6138 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/start-undefined-and-deleteCount-missing.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: Array.prototype.toSpliced(undefined) returns an empty array +info: | + 22.1.3.25 Array.prototype.toSpliced (start, deleteCount , ...items ) + 3. Let relativeStart be ? ToIntegerOrInfinity(start). + 6. Else, let actualStart be min(relativeStart, len). + 8. If start is not present, then + a. Let actualDeleteCount be 0. + 8. Else if deleteCount is not present, then + a. Let actualDeleteCount be len - actualStart. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var result = ["first", "second", "third"].toSpliced(undefined); +assert.compareArray(result, []); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/this-value-boolean.js b/test/sendable/builtins/Array/prototype/toSpliced/this-value-boolean.js new file mode 100644 index 00000000000..52033f2df42 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/this-value-boolean.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced converts booleans to objects +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + 1. Let O be ? ToObject(this value). + 2. Let len be ? LengthOfArrayLike(O). +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +assert.compareArray(SendableArray.prototype.toSpliced.call(true, 0, 0), []); +assert.compareArray(SendableArray.prototype.toSpliced.call(false, 0, 0), []); +/* Add length and indexed properties to `Boolean.prototype` */ +Boolean.prototype.length = 3; +assert.compareArray(SendableArray.prototype.toSpliced.call(true, 0, 0), [undefined, undefined, undefined]); +assert.compareArray(SendableArray.prototype.toSpliced.call(false, 0, 0), [undefined, undefined, undefined]); +delete Boolean.prototype.length; +Boolean.prototype[0] = "monkeys"; +Boolean.prototype[2] = "bogus"; +assert.compareArray(SendableArray.prototype.toSpliced.call(true, 0, 0), []); +assert.compareArray(SendableArray.prototype.toSpliced.call(false, 0, 0), []); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/this-value-nullish.js b/test/sendable/builtins/Array/prototype/toSpliced/this-value-nullish.js new file mode 100644 index 00000000000..60700f3396d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/this-value-nullish.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced throws if the receiver is null or undefined +info: | + Array.prototype.toSpliced ( start, deleteCount, ...items ) + 1. Let O be ? ToObject(this value). +features: [change-array-by-copy] +---*/ + +assert.throws(TypeError, () => { + SendableArray.prototype.toSpliced.call(null, 0, 0); +}, '`SendableArray.prototype.toSpliced.call(null)` throws TypeError'); +assert.throws(TypeError, () => { + SendableArray.prototype.toSpliced.call(undefined, 0, 0); +}, '`SendableArray.prototype.toSpliced.call(undefined)` throws TypeError'); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/unmodified.js b/test/sendable/builtins/Array/prototype/toSpliced/unmodified.js new file mode 100644 index 00000000000..7c8f9c5cc88 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toSpliced/unmodified.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toSpliced +description: > + Array.prototype.toSpliced returns a new array even if it the result is equal to the original array +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [1, 2, 3]; +var spliced = arr.toSpliced(1, 0); +assert.notSameValue(arr, spliced); +assert.compareArray(arr, spliced); diff --git a/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T1.js b/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T1.js new file mode 100644 index 00000000000..eaf0d968ba0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T1.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tostring +info: | + The result of calling this function is the same as if + the built-in join method were invoked for this object with no argument +es5id: 15.4.4.2_A1_T1 +description: If Result(2) is zero, return the empty string +---*/ + +var x = new SendableArray(); +if (x.toString() !== x.join()) { + throw new Test262Error('#1.1: x = new SendableArray(); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "") { + throw new Test262Error('#1.2: x = new SendableArray(); x.toString() === "". Actual: ' + (x.toString())); + } +} +x = []; +x[0] = 1; +x.length = 0; +if (x.toString() !== x.join()) { + throw new Test262Error('#2.1: x = []; x[0] = 1; x.length = 0; x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "") { + throw new Test262Error('#2.2: x = []; x[0] = 1; x.length = 0; x.toString() === "". Actual: ' + (x.toString())); + } +} diff --git a/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T2.js b/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T2.js new file mode 100644 index 00000000000..41efc2c2104 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T2.js @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tostring +info: | + The result of calling this function is the same as if + the built-in join method were invoked for this object with no argument +es5id: 15.4.4.2_A1_T2 +description: > + The elements of the array are converted to strings, and these + strings are then concatenated, separated by occurrences of the + separator. If no separator is provided, a single comma is used as + the separator +---*/ + +var x = new SendableArray(0, 1, 2, 3); +if (x.toString() !== x.join()) { + throw new Test262Error('#1.1: x = new SendableArray(0,1,2,3); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "0,1,2,3") { + throw new Test262Error('#1.2: x = new SendableArray(0,1,2,3); x.toString() === "0,1,2,3". Actual: ' + (x.toString())); + } +} +x = []; +x[0] = 0; +x[3] = 3; +if (x.toString() !== x.join()) { + throw new Test262Error('#2.1: x = []; x[0] = 0; x[3] = 3; x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "0,,,3") { + throw new Test262Error('#2.2: x = []; x[0] = 0; x[3] = 3; x.toString() === "0,,,3". Actual: ' + (x.toString())); + } +} +x = SendableArray(undefined, 1, null, 3); +if (x.toString() !== x.join()) { + throw new Test262Error('#3.1: x = SendableArray(undefined,1,null,3); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== ",1,,3") { + throw new Test262Error('#3.2: x = SendableArray(undefined,1,null,3); x.toString() === ",1,,3". Actual: ' + (x.toString())); + } +} +x = []; +x[0] = 0; +if (x.toString() !== x.join()) { + throw new Test262Error('#4.1: x = []; x[0] = 0; x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "0") { + throw new Test262Error('#4.2: x = []; x[0] = 0; x.toString() === "0". Actual: ' + (x.toString())); + } +} diff --git a/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T3.js b/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T3.js new file mode 100644 index 00000000000..03c50f0b3fc --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T3.js @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tostring +info: | + The result of calling this function is the same as if + the built-in join method were invoked for this object with no argument +es5id: 15.4.4.2_A1_T3 +description: Operator use ToString from array arguments +---*/ + +var x = new SendableArray("", "", ""); +if (x.toString() !== x.join()) { + throw new Test262Error('#0.1: var x = new SendableArray("","",""); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== ",,") { + throw new Test262Error('#0.2: var x = new SendableArray("","",""); x.toString() === ",,". Actual: ' + (x.toString())); + } +} +var x = new SendableArray("\\", "\\", "\\"); +if (x.toString() !== x.join()) { + throw new Test262Error('#1.1: var x = new SendableArray("\\","\\","\\"); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "\\,\\,\\") { + throw new Test262Error('#1.2: var x = new SendableArray("\\","\\","\\"); x.toString() === "\\,\\,\\". Actual: ' + (x.toString())); + } +} +var x = new SendableArray("&", "&", "&"); +if (x.toString() !== x.join()) { + throw new Test262Error('#2.1: var x = new SendableArray("&", "&", "&"); x.toString() === x.join(). Actual: ' + (x.toString())); +} else { + if (x.toString() !== "&,&,&") { + throw new Test262Error('#2.2: var x = new SendableArray("&", "&", "&"); x.toString() === "&,&,&". Actual: ' + (x.toString())); + } +} +var x = new SendableArray(true, true, true); +if (x.toString() !== x.join()) { + throw new Test262Error('#3.1: var x = new SendableArray(true,true,true); x.toString(true,true,true) === x.join(). Actual: ' + (x.toString(true, true, true))); +} else { + if (x.toString() !== "true,true,true") { + throw new Test262Error('#3.2: var x = new SendableArray(true,true,true); x.toString(true,true,true) === "true,true,true". Actual: ' + (x.toString(true, true, true))); + } +} +var x = new SendableArray(null, null, null); +if (x.toString() !== x.join()) { + throw new Test262Error('#4.1: var x = new SendableArray(null,null,null); x.toString(null,null,null) === x.join(). Actual: ' + (x.toString(null, null, null))); +} else { + if (x.toString() !== ",,") { + throw new Test262Error('#4.2: var x = new SendableArray(null,null,null); x.toString(null,null,null) === ",,". Actual: ' + (x.toString(null, null, null))); + } +} +var x = new SendableArray(undefined, undefined, undefined); +if (x.toString() !== x.join()) { + throw new Test262Error('#5.1: var x = new SendableArray(undefined,undefined,undefined); x.toString(undefined,undefined,undefined) === x.join(). Actual: ' + (x.toString(undefined, undefined, undefined))); +} else { + if (x.toString() !== ",,") { + throw new Test262Error('#5.2: var x = new SendableArray(undefined,undefined,undefined); x.toString(undefined,undefined,undefined) === ",,". Actual: ' + (x.toString(undefined, undefined, undefined))); + } +} +var x = new SendableArray(Infinity, Infinity, Infinity); +if (x.toString() !== x.join()) { + throw new Test262Error('#6.1: var x = new SendableArray(Infinity,Infinity,Infinity); x.toString(Infinity,Infinity,Infinity) === x.join(). Actual: ' + (x.toString(Infinity, Infinity, Infinity))); +} else { + if (x.toString() !== "Infinity,Infinity,Infinity") { + throw new Test262Error('#6.2: var x = new SendableArray(Infinity,Infinity,Infinity); x.toString(Infinity,Infinity,Infinity) === "Infinity,Infinity,Infinity". Actual: ' + (x.toString(Infinity, Infinity, Infinity))); + } +} +var x = new SendableArray(NaN, NaN, NaN); +if (x.toString() !== x.join()) { + throw new Test262Error('#7.1: var x = new SendableArray(NaN,NaN,NaN); x.toString(NaN,NaN,NaN) === x.join(). Actual: ' + (x.toString(NaN, NaN, NaN))); +} else { + if (x.toString() !== "NaN,NaN,NaN") { + throw new Test262Error('#7.2: var x = new SendableArray(NaN,NaN,NaN); x.toString(NaN,NaN,NaN) === "NaN,NaN,NaN". Actual: ' + (x.toString(NaN, NaN, NaN))); + } +} diff --git a/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T4.js b/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T4.js new file mode 100644 index 00000000000..c60e7e0e115 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T4.js @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tostring +info: | + The result of calling this function is the same as if + the built-in join method were invoked for this object with no argument +es5id: 15.4.4.2_A1_T4 +description: If Type(value) is Object, evaluate ToPrimitive(value, String) +---*/ + +var object = { + valueOf() { + return "+" + } +}; +var x = new SendableArray(object); +assert.sameValue(x.toString(), x.join(), 'x.toString() must return the same value returned by x.join()'); +var object = { + valueOf() { + return "+" + }, + toString() { + return "*" + } +}; +var x = new SendableArray(object); +assert.sameValue(x.toString(), x.join(), 'x.toString() must return the same value returned by x.join()'); +var object = { + valueOf() { + return "+" + }, + toString() { + return {} + } +}; +var x = new SendableArray(object); +assert.sameValue(x.toString(), x.join(), 'x.toString() must return the same value returned by x.join()'); +var object = { + valueOf() { + throw "error" + }, + toString() { + return "*" + } +}; +var x = new SendableArray(object); +assert.sameValue(x.toString(), x.join(), 'x.toString() must return the same value returned by x.join()'); +var object = { + toString() { + return "*" + } +}; +var x = new SendableArray(object); +assert.sameValue(x.toString(), x.join(), 'x.toString() must return the same value returned by x.join()'); +var object = { + valueOf() { + return {} + }, + toString() { + return "*" + } +} +var x = new SendableArray(object); +assert.sameValue(x.toString(), x.join(), 'x.toString() must return the same value returned by x.join()'); +assert.throws(Test262Error, () => { + var object = { + valueOf() { + return "+" + }, + toString() { + throw new Test262Error(); + } + }; + var x = new SendableArray(object); + x.toString(); +}); +assert.throws(TypeError, () => { + var object = { + valueOf() { + return {} + }, + toString() { + return {} + } + }; + var x = new SendableArray(object); + x.toString(); +}); diff --git a/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A3_T1.js b/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A3_T1.js new file mode 100644 index 00000000000..39235ffa72c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A3_T1.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tostring +info: "[[Get]] from not an inherited property" +es5id: 15.4.4.2_A3_T1 +description: "[[Prototype]] of Array instance is Array.prototype" +---*/ + +SendableArray.prototype[1] = 1; +var x = [0]; +x.length = 2; +if (x.toString() !== "0,1") { + throw new Test262Error('#1: SendableArray.prototype[1] = 1; x = [0]; x.length = 2; x.toString() === "0,1". Actual: ' + (x.toString())); +} diff --git a/test/sendable/builtins/Array/prototype/toString/call-with-boolean.js b/test/sendable/builtins/Array/prototype/toString/call-with-boolean.js new file mode 100644 index 00000000000..fe80670a8e8 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toString/call-with-boolean.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.toString +description: Array.prototype.toString applied to boolean primitive +---*/ + +assert.sameValue( + SendableArray.prototype.toString.call(true), + "[object Boolean]", + 'SendableArray.prototype.toString.call(true) must return "[object Boolean]"' +); +assert.sameValue( + SendableArray.prototype.toString.call(false), + "[object Boolean]", + 'SendableArray.prototype.toString.call(false) must return "[object Boolean]"' +); diff --git a/test/sendable/builtins/Array/prototype/toString/length.js b/test/sendable/builtins/Array/prototype/toString/length.js new file mode 100644 index 00000000000..26820784981 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toString/length.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tostring +description: > + Array.prototype.toString.length is 0. +info: | + Array.prototype.toString ( ) + 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(SendableArray.prototype.toString, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/toString/name.js b/test/sendable/builtins/Array/prototype/toString/name.js new file mode 100644 index 00000000000..806c369d313 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toString/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tostring +description: > + Array.prototype.toString.name is "toString". +info: | + Array.prototype.toString ( ) + 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(SendableArray.prototype.toString, "name", { + value: "toString", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/toString/non-callable-join-string-tag.js b/test/sendable/builtins/Array/prototype/toString/non-callable-join-string-tag.js new file mode 100644 index 00000000000..d272653d006 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toString/non-callable-join-string-tag.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tostring +description: > + If "join" value is non-callable, Object.prototype.toString intrinsic is called. +info: | + Array.prototype.toString ( ) + 2. Let func be ? Get(array, "join"). + 3. If IsCallable(func) is false, set func to the intrinsic function %Object.prototype.toString%. + 4. Return ? Call(func, array). +features: [Symbol.toStringTag, Proxy, Reflect, BigInt] +---*/ + +assert(delete Object.prototype.toString); +assert.sameValue(SendableArray.prototype.toString.call({ join: null }), "[object Object]"); +assert.sameValue(SendableArray.prototype.toString.call({ join: true }), "[object Object]"); +assert.sameValue(SendableArray.prototype.toString.call({ join: 0 }), "[object Object]"); +assert.sameValue(SendableArray.prototype.toString.call({ join: "join" }), "[object Object]"); +assert.sameValue(SendableArray.prototype.toString.call({ join: Symbol() }), "[object Object]"); +assert.sameValue(SendableArray.prototype.toString.call({ join: 0n }), "[object Object]"); +assert.sameValue(SendableArray.prototype.toString.call({ join: {} }), "[object Object]"); +let revokeOnGet = false; +const proxyTarget = []; +var proxyObj = Proxy.revocable(proxyTarget, { + get: (target, key, receiver) => { + if (revokeOnGet) + revoke(); + return Reflect.get(target, key, receiver); + }, +}); +var proxy = proxyObj.proxy; +var revoke = proxyObj.revoke; +proxyTarget.join = undefined; +assert.sameValue(SendableArray.prototype.toString.call(proxy), "[object SendableArray]"); +revokeOnGet = true; +assert.throws(TypeError, () => { SendableArray.prototype.toString.call(proxy); }); +assert.sameValue(SendableArray.prototype.toString.call((function() { return arguments; })()), "[object Arguments]"); +assert.sameValue(SendableArray.prototype.toString.call(new Error), "[object Error]"); +assert.sameValue(SendableArray.prototype.toString.call(new Boolean), "[object Boolean]"); +assert.sameValue(SendableArray.prototype.toString.call(new Number), "[object Number]"); +assert.sameValue(SendableArray.prototype.toString.call(new String), "[object String]"); +assert.sameValue(SendableArray.prototype.toString.call(new Date), "[object Date]"); +assert.sameValue(SendableArray.prototype.toString.call(new RegExp), "[object RegExp]"); +assert.sameValue(SendableArray.prototype.toString.call(new Proxy(() => {}, {})), "[object Function]"); +assert.sameValue(SendableArray.prototype.toString.call(new Proxy(new Date, {})), "[object Object]"); +assert.sameValue(SendableArray.prototype.toString.call({ [Symbol.toStringTag]: "Foo" }), "[object Foo]"); +assert.sameValue(SendableArray.prototype.toString.call(new Map), "[object Map]"); +RegExp.prototype[Symbol.toStringTag] = "Foo"; +assert.sameValue(SendableArray.prototype.toString.call(new RegExp), "[object Foo]"); +Number.prototype[Symbol.toStringTag] = Object("Foo"); // ignored +assert.sameValue(SendableArray.prototype.toString.call(new Number), "[object Number]"); +Object.defineProperty(JSON, Symbol.toStringTag, { value: "Foo" }); +assert.sameValue(SendableArray.prototype.toString.call(JSON), "[object Foo]"); +assert(delete Set.prototype[Symbol.toStringTag]); +assert.sameValue(SendableArray.prototype.toString.call(new Set), "[object Object]"); +Object.defineProperty(Object.prototype, Symbol.toStringTag, { get: () => { throw new Test262Error(); } }); +assert.throws(Test262Error, () => { SendableArray.prototype.toString.call({}); }); diff --git a/test/sendable/builtins/Array/prototype/toString/not-a-constructor.js b/test/sendable/builtins/Array/prototype/toString/not-a-constructor.js new file mode 100644 index 00000000000..4b0f3c74bb0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toString/not-a-constructor.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.toString 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(SendableArray.prototype.toString), + false, + 'isConstructor(SendableArray.prototype.toString) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.toString(); +}); + diff --git a/test/sendable/builtins/Array/prototype/toString/prop-desc.js b/test/sendable/builtins/Array/prototype/toString/prop-desc.js new file mode 100644 index 00000000000..d9e93323cae --- /dev/null +++ b/test/sendable/builtins/Array/prototype/toString/prop-desc.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.tostring +description: > + "toString" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.toString, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "toString", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A1_T1.js b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A1_T1.js new file mode 100644 index 00000000000..910b395b95e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A1_T1.js @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The arguments are prepended to the start of the array, such that + their order within the array is the same as the order in which they appear in + the argument list +esid: sec-array.prototype.unshift +description: Checking case when unsift is given no arguments or one argument +---*/ + +var x = new SendableArray(); +var unshift = x.unshift(1); +if (unshift !== 1) { + throw new Test262Error('#1: x = new SendableArray(); x.unshift(1) === 1. Actual: ' + (unshift)); +} +if (x[0] !== 1) { + throw new Test262Error('#2: x = new SendableArray(); x.unshift(1); x[0] === 1. Actual: ' + (x[0])); +} +var unshift = x.unshift(); +if (unshift !== 1) { + throw new Test262Error('#3: x = new SendableArray(); x.unshift(1); x.unshift() === 1. Actual: ' + (unshift)); +} +if (x[1] !== undefined) { + throw new Test262Error('#4: x = new SendableArray(); x.unshift(1); x.unshift(); x[1] === unedfined. Actual: ' + (x[1])); +} +var unshift = x.unshift(-1); +if (unshift !== 2) { + throw new Test262Error('#5: x = new SendableArray(); x.unshift(1); x.unshift(); x.unshift(-1) === 2. Actual: ' + (unshift)); +} +if (x[0] !== -1) { + throw new Test262Error('#6: x = new SendableArray(); x.unshift(1); x.unshift(-1); x[0] === -1. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#7: x = new SendableArray(); x.unshift(1); x.unshift(-1); x[1] === 1. Actual: ' + (x[1])); +} +if (x.length !== 2) { + throw new Test262Error('#8: x = new SendableArray(); x.unshift(1); x.unshift(); x.unshift(-1); x.length === 2. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A1_T2.js b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A1_T2.js new file mode 100644 index 00000000000..86c1ad5b171 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A1_T2.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The arguments are prepended to the start of the array, such that + their order within the array is the same as the order in which they appear in + the argument list +esid: sec-array.prototype.unshift +description: Checking case when unsift is given many arguments +---*/ + +var x = []; +if (x.length !== 0) { + throw new Test262Error('#1: x = []; x.length === 0. Actual: ' + (x.length)); +} +x[0] = 0; +var unshift = x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); +if (unshift !== 6) { + throw new Test262Error('#2: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1) === 6. Actual: ' + (unshift)); +} +if (x[5] !== 0) { + throw new Test262Error('#3: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[5] === 0. Actual: ' + (x[5])); +} +if (x[0] !== true) { + throw new Test262Error('#4: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[0] === true. Actual: ' + (x[0])); +} +if (x[1] !== Number.POSITIVE_INFINITY) { + throw new Test262Error('#5: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[1] === Number.POSITIVE_INFINITY. Actual: ' + (x[1])); +} +if (x[2] !== "NaN") { + throw new Test262Error('#6: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[2] === "NaN". Actual: ' + (x[2])); +} +if (x[3] !== "1") { + throw new Test262Error('#7: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[3] === "1". Actual: ' + (x[3])); +} +if (x[4] !== -1) { + throw new Test262Error('#8: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x[4] === -1. Actual: ' + (x[4])); +} +if (x.length !== 6) { + throw new Test262Error('#9: x = []; x[0] = 0; x.unshift(true, Number.POSITIVE_INFINITY, "NaN", "1", -1); x.length === 6. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A2_T1.js b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A2_T1.js new file mode 100644 index 00000000000..9d50717b343 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A2_T1.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The unshift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.unshift +description: > + The arguments are prepended to the start of the array, such that + their order within the array is the same as the order in which + they appear in the argument list +---*/ + +var obj = {}; +obj.unshift = SendableArray.prototype.unshift; +if (obj.length !== undefined) { + throw new Test262Error('#0: var obj = {}; obj.length === undefined. Actual: ' + (obj.length)); +} else { + var unshift = obj.unshift(-1); + if (unshift !== 1) { + throw new Test262Error('#1: var obj = {}; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-1) === 1. Actual: ' + (unshift)); + } + if (obj.length !== 1) { + throw new Test262Error('#2: var obj = {}; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-1); obj.length === 1. Actual: ' + (obj.length)); + } + if (obj["0"] !== -1) { + throw new Test262Error('#3: var obj = {}; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-1); obj["0"] === -1. Actual: ' + (obj["0"])); + } +} +obj.length = undefined; +var unshift = obj.unshift(-4); +if (unshift !== 1) { + throw new Test262Error('#4: var obj = {}; obj.length = undefined; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-4) === 1. Actual: ' + (unshift)); +} +if (obj.length !== 1) { + throw new Test262Error('#5: var obj = {}; obj.length = undefined; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-4); obj.length === 1. Actual: ' + (obj.length)); +} +if (obj["0"] !== -4) { + throw new Test262Error('#6: var obj = {}; obj.length = undefined; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-4); obj["0"] === -4. Actual: ' + (obj["0"])); +} +obj.length = null +var unshift = obj.unshift(-7); +if (unshift !== 1) { + throw new Test262Error('#7: var obj = {}; obj.length = null; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-7) === 1. Actual: ' + (unshift)); +} +if (obj.length !== 1) { + throw new Test262Error('#8: var obj = {}; obj.length = null; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-7); obj.length === 1. Actual: ' + (obj.length)); +} +if (obj["0"] !== -7) { + throw new Test262Error('#9: var obj = {}; obj.length = null; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-7); obj["0"] === -7. Actual: ' + (obj["0"])); +} diff --git a/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A2_T2.js b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A2_T2.js new file mode 100644 index 00000000000..1d1f4ec5577 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A2_T2.js @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The unshift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.unshift +description: > + The arguments are prepended to the start of the array, such that + their order within the array is the same as the order in which + they appear in the argument list +---*/ + +var obj = {}; +obj.unshift = SendableArray.prototype.unshift; +obj.length = NaN; +var unshift = obj.unshift(-1); +if (unshift !== 1) { + throw new Test262Error('#1: var obj = {}; obj.length = NaN; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-1) === 1. Actual: ' + (unshift)); +} +if (obj.length !== 1) { + throw new Test262Error('#2: var obj = {}; obj.length = NaN; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-1); obj.length === 1. Actual: ' + (obj.length)); +} +if (obj["0"] !== -1) { + throw new Test262Error('#3: var obj = {}; obj.length = NaN; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-1); obj["0"] === -1. Actual: ' + (obj["0"])); +} +obj.length = Number.NEGATIVE_INFINITY; +var unshift = obj.unshift(-7); +if (unshift !== 1) { + throw new Test262Error('#7: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-7) === 1. Actual: ' + (unshift)); +} +if (obj.length !== 1) { + throw new Test262Error('#8: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-7); obj.length === 1. Actual: ' + (obj.length)); +} +if (obj["0"] !== -7) { + throw new Test262Error('#9: var obj = {}; obj.length = Number.NEGATIVE_INFINITY; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-7); obj["0"] === -7. Actual: ' + (obj["0"])); +} +obj.length = 0.5; +var unshift = obj.unshift(-10); +if (unshift !== 1) { + throw new Test262Error('#10: var obj = {}; obj.length = 0.5; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-10) === 1. Actual: ' + (unshift)); +} +if (obj.length !== 1) { + throw new Test262Error('#11: var obj = {}; obj.length = 0.5; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-10); obj.length === 1. Actual: ' + (obj.length)); +} +if (obj["0"] !== -10) { + throw new Test262Error('#12: var obj = {}; obj.length = 0.5; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-10); obj["0"] === -10. Actual: ' + (obj["0"])); +} +obj.length = 1.5; +var unshift = obj.unshift(-13); +if (unshift !== 2) { + throw new Test262Error('#13: var obj = {}; obj.length = 1.5; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-13) === 2. Actual: ' + (unshift)); +} +if (obj.length !== 2) { + throw new Test262Error('#14: var obj = {}; obj.length = 1.5; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-13); obj.length === 2. Actual: ' + (obj.length)); +} +if (obj["0"] !== -13) { + throw new Test262Error('#15: var obj = {}; obj.length = 1.5; obj.unshift = SendableArray.prototype.unshift; obj.unshift(-13); obj["0"] === -13. Actual: ' + (obj["0"])); +} +obj.length = new Number(0); +var unshift = obj.unshift(-16); +if (unshift !== 1) { + throw new Test262Error('#16: var obj = {}; obj.length = new Number(0); obj.unshift = SendableArray.prototype.unshift; obj.unshift(-16) === 1. Actual: ' + (unshift)); +} +if (obj.length !== 1) { + throw new Test262Error('#17: var obj = {}; obj.length = new Number(0); obj.unshift = SendableArray.prototype.unshift; obj.unshift(-16); obj.length === 1. Actual: ' + (obj.length)); +} +if (obj["0"] !== -16) { + throw new Test262Error('#18: var obj = {}; obj.length = new Number(0); obj.unshift = SendableArray.prototype.unshift; obj.unshift(-16); obj["0"] === -16. Actual: ' + (obj["0"])); +} diff --git a/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A2_T3.js b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A2_T3.js new file mode 100644 index 00000000000..7f38988e8bf --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A2_T3.js @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The unshift function is intentionally generic. + It does not require that its this value be an Array object +esid: sec-array.prototype.unshift +description: > + Operator use ToNumber from length. If Type(value) is Object, + evaluate ToPrimitive(value, Number) +---*/ + +var obj = {}; +obj.unshift = SendableArray.prototype.unshift; +obj.length = { + valueOf() { + return 3 + } +}; +var unshift = obj.unshift(); +assert.sameValue(unshift, 3, 'The value of unshift is expected to be 3'); +obj.length = { + valueOf() { + return 3 + }, + toString() { + return 1 + } +}; +var unshift = obj.unshift(); +assert.sameValue(unshift, 3, 'The value of unshift is expected to be 3'); +obj.length = { + valueOf() { + return 3 + }, + toString() { + return {} + } +}; +var unshift = obj.unshift(); +assert.sameValue(unshift, 3, 'The value of unshift is expected to be 3'); +try { + obj.length = { + valueOf() { + return 3 + }, + toString() { + throw "error" + } + }; + var unshift = obj.unshift(); + assert.sameValue(unshift, 3, 'The value of unshift is expected to be 3'); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} +obj.length = { + toString() { + return 1 + } +}; +var unshift = obj.unshift(); +assert.sameValue(unshift, 1, 'The value of unshift is expected to be 1'); +obj.length = { + valueOf() { + return {} + }, + toString() { + return 1 + } +} +var unshift = obj.unshift(); +assert.sameValue(unshift, 1, 'The value of unshift is expected to be 1'); +try { + + obj.length = { + valueOf() { + throw "error" + }, + toString() { + return 1 + } + }; + var unshift = obj.unshift(); + throw new Test262Error('#7.1: obj.length = {valueOf() {throw "error"}, toString() {return 1}}; obj.unshift() throw "error". Actual: ' + (unshift)); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} +try { + + obj.length = { + valueOf() { + return {} + }, + toString() { + return {} + } + }; + var unshift = obj.unshift(); + throw new Test262Error('#8.1: obj.length = {valueOf() {return {}}, toString() {return {}}} obj.unshift() throw TypeError. Actual: ' + (unshift)); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A3_T2.js b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A3_T2.js new file mode 100644 index 00000000000..36886c5232f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A3_T2.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: Check ToLength(length) for non Array objects +esid: sec-array.prototype.unshift +description: length = -4294967295 +---*/ + +var obj = {}; +obj.unshift = SendableArray.prototype.unshift; +obj[0] = ""; +obj.length = -4294967295; +var unshift = obj.unshift("x", "y", "z"); +if (unshift !== 3) { + throw new Test262Error('#1: var obj = {}; obj.unshift = SendableArray.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z") === 3. Actual: ' + (unshift)); +} +if (obj.length !== 3) { + throw new Test262Error('#2: var obj = {}; obj.unshift = SendableArray.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z"); obj.length === 3. Actual: ' + (obj.length)); +} +if (obj[0] !== "x") { + throw new Test262Error('#3: var obj = {}; obj.unshift = SendableArray.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z"); obj[0] === "x". Actual: ' + (obj[0])); +} +if (obj[1] !== "y") { + throw new Test262Error('#4: var obj = {}; obj.unshift = SendableArray.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z"); obj[1] === "y". Actual: ' + (obj[1])); +} +if (obj[2] !== "z") { + throw new Test262Error('#5: var obj = {}; obj.unshift = SendableArray.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z"); obj[2] === "z". Actual: ' + (obj[2])); +} +if (obj[3] !== undefined) { + throw new Test262Error('#6: var obj = {}; obj.unshift = SendableArray.prototype.unshift; obj[0] = ""; obj.length = -4294967295; obj.unshift("x", "y", "z"); obj[3] === undefined. Actual: ' + (obj[3])); +} diff --git a/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A4_T1.js b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A4_T1.js new file mode 100644 index 00000000000..92ec2748bb4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A4_T1.js @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.unshift +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +SendableArray.prototype[0] = -1; +var x = [1]; +x.length = 1; +var unshift = x.unshift(0); +if (unshift !== 2) { + throw new Test262Error('#1: SendableArray.prototype[0] = -1; x = [1]; x.length = 1; x.unshift(0) === 2. Actual: ' + (unshift)); +} +if (x[0] !== 0) { + throw new Test262Error('#2: SendableArray.prototype[0] = -1; x = [1]; x.length = 1; x.unshift(0); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#3: SendableArray.prototype[0] = -1; x = [1]; x.length = 1; x.unshift(0); x[1] === 1. Actual: ' + (x[1])); +} +delete x[0]; +if (x[0] !== -1) { + throw new Test262Error('#4: SendableArray.prototype[0] = -1; x = [1]; x.length = 1; x.unshift(0); delete x[0]; x[0] === -1. Actual: ' + (x[0])); +} +Object.prototype[0] = -1; +Object.prototype.length = 1; +Object.prototype.unshift = SendableArray.prototype.unshift; +x = { + 0: 1 +}; +var unshift = x.unshift(0); +if (unshift !== 2) { + throw new Test262Error('#5: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.unshift = SendableArray.prototype.unshift; x = {0:0}; x.unshift(0) === 2. Actual: ' + (unshift)); +} +if (x[0] !== 0) { + throw new Test262Error('#6: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.unshift = SendableArray.prototype.unshift; x = {0:0}; x.unshift(0); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#7: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.unshift = SendableArray.prototype.unshift; x = {0:0}; x.unshift(0); x[1] === 1. Actual: ' + (x[1])); +} +delete x[0]; +if (x[0] !== -1) { + throw new Test262Error('#8: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.unshift = SendableArray.prototype.unshift; x = {0:0}; x.unshift(0); delete x[0]; x[0] === -1. Actual: ' + (x[0])); +} +if (x.length !== 2) { + throw new Test262Error('#9: Object.prototype[0] = -1; Object.prototype.length = 1; Object.prototype.unshift = SendableArray.prototype.unshift; x = {0:0}; x.unshift(0); x.length === 1. Actual: ' + (x.length)); +} +delete x.length; +if (x.length !== 1) { + throw new Test262Error('#10: Object.prototype[1] = -1; Object.prototype.length = 1; Object.prototype.unshift = SendableArray.prototype.unshift; x = {0:0}; x.unshift(0); delete x; x.length === 1. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A4_T2.js b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A4_T2.js new file mode 100644 index 00000000000..c09d900eb75 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/S15.4.4.13_A4_T2.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: "[[Get]], [[Delete]] from not an inherited property" +esid: sec-array.prototype.unshift +description: > + [[Prototype]] of Array instance is Array.prototype, [[Prototype] + of Array.prototype is Object.prototype +---*/ + +SendableArray.prototype[0] = 1; +var x = []; +x.length = 1; +var unshift = x.unshift(0); +if (unshift !== 2) { + throw new Test262Error('#1: SendableArray.prototype[0] = 1; x = []; x.length = 1; x.unshift(0) === 2. Actual: ' + (unshift)); +} +if (x[0] !== 0) { + throw new Test262Error('#2: SendableArray.prototype[0] = 1; x = []; x.length = 1; x.unshift(0); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#3: SendableArray.prototype[0] = 1; x = []; x.length = 1; x.unshift(0); x[1] === 1. Actual: ' + (x[1])); +} +delete x[0]; +if (x[0] !== 1) { + throw new Test262Error('#4: SendableArray.prototype[0] = 1; x = [1]; x.length = 1; x.unshift(0); delete x[0]; x[0] === 1. Actual: ' + (x[0])); +} +Object.prototype[0] = 1; +Object.prototype.length = 1; +Object.prototype.unshift = SendableArray.prototype.unshift; +x = {}; +var unshift = x.unshift(0); +if (unshift !== 2) { + throw new Test262Error('#5: Object.prototype[0] = 1; Object.prototype.length = 1; Object.prototype.unshift = SendableArray.prototype.unshift; x = {}; x.unshift(0) === 2. Actual: ' + (unshift)); +} +if (x[0] !== 0) { + throw new Test262Error('#6: Object.prototype[0] = 1; Object.prototype.length = 1; Object.prototype.unshift = SendableArray.prototype.unshift; x = {}; x.unshift(0); x[0] === 0. Actual: ' + (x[0])); +} +if (x[1] !== 1) { + throw new Test262Error('#7: Object.prototype[0] = 1; Object.prototype.length = 1; Object.prototype.unshift = SendableArray.prototype.unshift; x = {}; x.unshift(0); x[1] === 1. Actual: ' + (x[1])); +} +delete x[0]; +if (x[0] !== 1) { + throw new Test262Error('#8: Object.prototype[0] = 1; Object.prototype.length = 1; Object.prototype.unshift = SendableArray.prototype.unshift; x = {}; x.unshift(0); delete x[0]; x[0] === 1. Actual: ' + (x[0])); +} +if (x.length !== 2) { + throw new Test262Error('#9: Object.prototype[0] = 1; Object.prototype.length = 1; Object.prototype.unshift = SendableArray.prototype.unshift; x = {}; x.unshift(0); x.length === 1. Actual: ' + (x.length)); +} +delete x.length; +if (x.length !== 1) { + throw new Test262Error('#10: Object.prototype[1] = 1; Object.prototype.length = 1; Object.prototype.unshift = SendableArray.prototype.unshift; x = {}; x.unshift(0); delete x; x.length === 1. Actual: ' + (x.length)); +} diff --git a/test/sendable/builtins/Array/prototype/unshift/call-with-boolean.js b/test/sendable/builtins/Array/prototype/unshift/call-with-boolean.js new file mode 100644 index 00000000000..7e91802f517 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/call-with-boolean.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.unshift +description: Array.prototype.unshift applied to boolean primitive +---*/ + +assert.sameValue(SendableArray.prototype.unshift.call(true), 0, 'SendableArray.prototype.unshift.call(true) must return 0'); +assert.sameValue(SendableArray.prototype.unshift.call(false), 0, 'SendableArray.prototype.unshift.call(false) must return 0'); diff --git a/test/sendable/builtins/Array/prototype/unshift/clamps-to-integer-limit.js b/test/sendable/builtins/Array/prototype/unshift/clamps-to-integer-limit.js new file mode 100644 index 00000000000..c1952368451 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/clamps-to-integer-limit.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.unshift +description: > + Length values exceeding 2^53-1 are clamped to 2^53-1. +info: | + 1. ... + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let argCount be the number of actual arguments. + 4. If argCount > 0, then ... + 5. Perform ? Set(O, "length", len+argCount, true). +features: [exponentiation] +---*/ + +var arrayLike = {}; +arrayLike.length = 2 ** 53 - 1; +SendableArray.prototype.unshift.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53 - 1"); +arrayLike.length = 2 ** 53; +SendableArray.prototype.unshift.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53"); +arrayLike.length = 2 ** 53 + 2; +SendableArray.prototype.unshift.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is 2**53 + 2"); +arrayLike.length = Infinity; +SendableArray.prototype.unshift.call(arrayLike); +assert.sameValue(arrayLike.length, 2 ** 53 - 1, "Length is Infinity"); diff --git a/test/sendable/builtins/Array/prototype/unshift/length-near-integer-limit.js b/test/sendable/builtins/Array/prototype/unshift/length-near-integer-limit.js new file mode 100644 index 00000000000..469a2a20029 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/length-near-integer-limit.js @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.unshift +description: > + Test properties are correctly accessed when length property is near 2^53-1. +info: | + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let argCount be the number of actual arguments. + 4. If argCount > 0, then + ... + b. Let k be len. + c. Repeat, while k > 0, + i. Let from be ! ToString(k-1). + ii. Let to be ! ToString(k+argCount-1). + iii. Let fromPresent be ? HasProperty(O, from). + iv. If fromPresent is true, then + 1. Let fromValue be ? Get(O, from). + 2. Perform ? Set(O, to, fromValue, true). + v. Else fromPresent is false, + 1. Perform ? DeletePropertyOrThrow(O, to). + vi. Decrease k by 1. +features: [exponentiation] +---*/ + +function StopUnshift() {} +var arrayLike = { + get "9007199254740986" () { + throw new StopUnshift(); + }, + "9007199254740987": "9007199254740987", + /* "9007199254740988": hole */ + "9007199254740989": "9007199254740989", + /* "9007199254740990": empty */ + "9007199254740991": "9007199254740991", + length: 2 ** 53 - 2 +}; +assert.throws(StopUnshift, function() { + SendableArray.prototype.unshift.call(arrayLike, null); +}); +assert.sameValue(arrayLike.length, 2 ** 53 - 2, + "arrayLike.length is unchanged"); +assert.sameValue(arrayLike["9007199254740987"], "9007199254740987", + "arrayLike['9007199254740987'] is unchanged"); +assert.sameValue(arrayLike["9007199254740988"], "9007199254740987", + "arrayLike['9007199254740988'] is replaced with arrayLike['9007199254740987']"); +assert.sameValue("9007199254740989" in arrayLike, false, + "arrayLike['9007199254740989'] is removed"); +assert.sameValue(arrayLike["9007199254740990"], "9007199254740989", + "arrayLike['9007199254740990'] is replaced with arrayLike['9007199254740989']"); +assert.sameValue(arrayLike["9007199254740991"], "9007199254740991", + "arrayLike['9007199254740991'] is unchanged"); diff --git a/test/sendable/builtins/Array/prototype/unshift/length.js b/test/sendable/builtins/Array/prototype/unshift/length.js new file mode 100644 index 00000000000..a5468abe6b3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/length.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.unshift +description: > + The "length" property of Array.prototype.unshift +info: | + 22.1.3.29 Array.prototype.unshift ( ...items ) + The length property of the unshift method is 1. + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.unshift, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/unshift/name.js b/test/sendable/builtins/Array/prototype/unshift/name.js new file mode 100644 index 00000000000..e7615895cb9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/name.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.unshift +description: > + Array.prototype.unshift.name is "unshift". +info: | + Array.prototype.unshift ( ...items ) + 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(SendableArray.prototype.unshift, "name", { + value: "unshift", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/unshift/not-a-constructor.js b/test/sendable/builtins/Array/prototype/unshift/not-a-constructor.js new file mode 100644 index 00000000000..81515667ff9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/not-a-constructor.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.unshift 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(SendableArray.prototype.unshift), + false, + 'isConstructor(SendableArray.prototype.unshift) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.unshift(); +}); + diff --git a/test/sendable/builtins/Array/prototype/unshift/prop-desc.js b/test/sendable/builtins/Array/prototype/unshift/prop-desc.js new file mode 100644 index 00000000000..31afc9a3c7c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/prop-desc.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.unshift +description: > + "unshift" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + + 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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.unshift, 'function', 'typeof'); +verifyProperty(SendableArray.prototype, "unshift", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/unshift/set-length-array-is-frozen.js b/test/sendable/builtins/Array/prototype/unshift/set-length-array-is-frozen.js new file mode 100644 index 00000000000..a734cf73ca5 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/set-length-array-is-frozen.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.unshift +description: > + A TypeError is thrown when "length" is [[Set]] on a frozen array. +---*/ + +var array = []; +var arrayPrototypeSet0Calls = 0; +Object.defineProperty(SendableArray.prototype, "0", { + set(_val) { + Object.freeze(array); + arrayPrototypeSet0Calls++; + }, +}); +assert.throws(TypeError, function() { + array.unshift(1); +}); +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); +assert.sameValue(arrayPrototypeSet0Calls, 1); diff --git a/test/sendable/builtins/Array/prototype/unshift/set-length-array-length-is-non-writable.js b/test/sendable/builtins/Array/prototype/unshift/set-length-array-length-is-non-writable.js new file mode 100644 index 00000000000..ecdad69157f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/set-length-array-length-is-non-writable.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.unshift +description: > + A TypeError is thrown when "length" is [[Set]] on an array with non-writable "length". +---*/ + +var array = []; +var arrayPrototypeSet0Calls = 0; +Object.defineProperty(SendableArray.prototype, "0", { + set(_val) { + Object.defineProperty(array, "length", { writable: false }); + arrayPrototypeSet0Calls++; + }, +}); +assert.throws(TypeError, function() { + array.unshift(1); +}); +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); +assert.sameValue(arrayPrototypeSet0Calls, 1); diff --git a/test/sendable/builtins/Array/prototype/unshift/set-length-zero-array-is-frozen.js b/test/sendable/builtins/Array/prototype/unshift/set-length-zero-array-is-frozen.js new file mode 100644 index 00000000000..d82faf54411 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/set-length-zero-array-is-frozen.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.unshift +description: > + A TypeError is thrown when "length" is [[Set]] on an empty frozen array. +---*/ + +var array = []; +Object.freeze(array); +assert.throws(TypeError, function() { + array.unshift(); +}); +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); diff --git a/test/sendable/builtins/Array/prototype/unshift/set-length-zero-array-length-is-non-writable.js b/test/sendable/builtins/Array/prototype/unshift/set-length-zero-array-length-is-non-writable.js new file mode 100644 index 00000000000..992d0eedddb --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/set-length-zero-array-length-is-non-writable.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.unshift +description: > + A TypeError is thrown when "length" is [[Set]] on an empty array with non-writable "length". +---*/ + +var array = []; +Object.defineProperty(array, "length", { writable: false }); +assert.throws(TypeError, function() { + array.unshift(); +}); +assert(!array.hasOwnProperty(0)); +assert.sameValue(array.length, 0); diff --git a/test/sendable/builtins/Array/prototype/unshift/throws-if-integer-limit-exceeded.js b/test/sendable/builtins/Array/prototype/unshift/throws-if-integer-limit-exceeded.js new file mode 100644 index 00000000000..6228d92ae4a --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/throws-if-integer-limit-exceeded.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.unshift +description: > + A TypeError is thrown if the new length exceeds 2^53-1. +info: | + 2. Let len be ? ToLength(? Get(O, "length")). + 3. Let argCount be the number of actual arguments. + 4. If argCount > 0, then + a. If len+argCount > 2^53-1, throw a TypeError exception. + b. ... +features: [exponentiation] +---*/ + +var arrayLike = {}; +arrayLike.length = 2 ** 53 - 1; +assert.throws(TypeError, function() { + SendableArray.prototype.unshift.call(arrayLike, null); +}, "Length is 2**53 - 1"); +arrayLike.length = 2 ** 53; +assert.throws(TypeError, function() { + SendableArray.prototype.unshift.call(arrayLike, null); +}, "Length is 2**53"); +arrayLike.length = 2 ** 53 + 2; +assert.throws(TypeError, function() { + SendableArray.prototype.unshift.call(arrayLike, null); +}, "Length is 2**53 + 2"); +arrayLike.length = Infinity; +assert.throws(TypeError, function() { + SendableArray.prototype.unshift.call(arrayLike, null); +}, "Length is Infinity"); diff --git a/test/sendable/builtins/Array/prototype/unshift/throws-with-string-receiver.js b/test/sendable/builtins/Array/prototype/unshift/throws-with-string-receiver.js new file mode 100644 index 00000000000..547d1b737b1 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/unshift/throws-with-string-receiver.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.unshift +description: > + Array#unshift throws TypeError upon attempting to modify a string +---*/ + +assert.throws(TypeError, () => { + SendableArray.prototype.unshift.call(''); +}, "SendableArray.prototype.unshift.call('')"); +assert.throws(TypeError, () => { + SendableArray.prototype.unshift.call('', 1); +}, "SendableArray.prototype.unshift.call('', 1)"); +assert.throws(TypeError, () => { + SendableArray.prototype.unshift.call('abc'); +}, "SendableArray.prototype.unshift.call('abc')"); +assert.throws(TypeError, () => { + SendableArray.prototype.unshift.call('abc', 1); +}, "SendableArray.prototype.unshift.call('abc', 1)"); diff --git a/test/sendable/builtins/Array/prototype/values/iteration-mutable.js b/test/sendable/builtins/Array/prototype/values/iteration-mutable.js new file mode 100644 index 00000000000..ce1ceffea5f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/values/iteration-mutable.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.values +description: > + New items in the array are accessible via iteration until iterator is "done". +info: | + When an item is added to the array after the iterator is created but + before the iterator is "done" (as defined by 22.1.5.2.1), the new item's + value should be accessible via iteration. When an item is added to the + array after the iterator is "done", the new item should not be + accessible via iteration. +---*/ + +var array = []; +var iterator = array.values(); +var result; +array.push('a'); +result = iterator.next(); +assert.sameValue(result.done, false, 'First result `done` flag'); +assert.sameValue(result.value, 'a', 'First result `value`'); +result = iterator.next(); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +array.push('b'); +result = iterator.next(); +assert.sameValue( + result.done, true, + 'Exhausted result `done` flag (after push)' +); +assert.sameValue( + result.value, undefined, + 'Exhausted result `value` (after push)' +); diff --git a/test/sendable/builtins/Array/prototype/values/iteration.js b/test/sendable/builtins/Array/prototype/values/iteration.js new file mode 100644 index 00000000000..79fd21771a0 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/values/iteration.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.values +description: > + The return is a valid iterator with the array's numeric properties. +info: | + 22.1.3.29 Array.prototype.values ( ) + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "value"). +---*/ + +var array = ['a', 'b', 'c']; +var iterator = array.values(); +var result; +result = iterator.next(); +assert.sameValue(result.value, 'a', 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); +result = iterator.next(); +assert.sameValue(result.value, 'b', 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); +result = iterator.next(); +assert.sameValue(result.value, 'c', 'Third result `value`'); +assert.sameValue(result.done, false, 'Third result `done` flag'); +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); diff --git a/test/sendable/builtins/Array/prototype/values/length.js b/test/sendable/builtins/Array/prototype/values/length.js new file mode 100644 index 00000000000..8fa8f8d1423 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/values/length.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.values +description: Array.prototype.values `length` property +info: | + ES6 Section 17: + 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. + 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(SendableArray.prototype.values, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/values/name.js b/test/sendable/builtins/Array/prototype/values/name.js new file mode 100644 index 00000000000..7677a8285ea --- /dev/null +++ b/test/sendable/builtins/Array/prototype/values/name.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.values +description: Array.prototype.values `name` property +info: | + ES6 Section 17: + 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, this value is the name that is given to + the function in this specification. + 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(SendableArray.prototype.values, "name", { + value: "values", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/values/not-a-constructor.js b/test/sendable/builtins/Array/prototype/values/not-a-constructor.js new file mode 100644 index 00000000000..c93152300ba --- /dev/null +++ b/test/sendable/builtins/Array/prototype/values/not-a-constructor.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.values 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, Array.prototype.values, arrow-function] +---*/ + +assert.sameValue( + isConstructor(SendableArray.prototype.values), + false, + 'isConstructor(SendableArray.prototype.values) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.values(); +}); + diff --git a/test/sendable/builtins/Array/prototype/values/prop-desc.js b/test/sendable/builtins/Array/prototype/values/prop-desc.js new file mode 100644 index 00000000000..7cafe9fb506 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/values/prop-desc.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.values +description: Array.prototype.values property descriptor +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] +---*/ + +assert.sameValue(typeof SendableArray.prototype.values, 'function'); +verifyProperty(SendableArray.prototype, "values", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prototype/values/resizable-buffer-grow-mid-iteration.js b/test/sendable/builtins/Array/prototype/values/resizable-buffer-grow-mid-iteration.js new file mode 100644 index 00000000000..12c47983a63 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/values/resizable-buffer-grow-mid-iteration.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.values +description: > + Array.p.values behaves correctly on TypedArrays backed by resizable buffers and + resized mid-iteration. +features: [resizable-arraybuffer] +includes: [compareArray.js, resizableArrayBufferUtils.js] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + // The fixed length array is not affected by resizing. + TestIterationAndResize(SendableArray.prototype.values.call(fixedLength), [ + 0, + 2, + 4, + 6 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + // The fixed length array is not affected by resizing. + TestIterationAndResize(SendableArray.prototype.values.call(fixedLengthWithOffset), [ + 4, + 6 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + TestIterationAndResize(SendableArray.prototype.values.call(lengthTracking), [ + 0, + 2, + 4, + 6, + 0, + 0 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + TestIterationAndResize(SendableArray.prototype.values.call(lengthTrackingWithOffset), [ + 4, + 6, + 0, + 0 + ], rab, 2, 6 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/Array/prototype/values/resizable-buffer-shrink-mid-iteration.js b/test/sendable/builtins/Array/prototype/values/resizable-buffer-shrink-mid-iteration.js new file mode 100644 index 00000000000..8c54e2e66d3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/values/resizable-buffer-shrink-mid-iteration.js @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.values +description: > + Array.p.values behaves correctly on TypedArrays backed by resizable buffers + that are shrunk mid-iteration. +features: [resizable-arraybuffer] +includes: [compareArray.js, resizableArrayBufferUtils.js] +---*/ + +// Orig. array: [0, 2, 4, 6] +// [0, 2, 4, 6] << fixedLength +// [4, 6] << fixedLengthWithOffset +// [0, 2, 4, 6, ...] << lengthTracking +// [4, 6, ...] << lengthTrackingWithOffset +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLength = new ctor(rab, 0, 4); + + // The fixed length array goes out of bounds when the RAB is resized. + assert.throws(TypeError, () => { + TestIterationAndResize(SendableArray.prototype.values.call(fixedLength), null, rab, 2, 3 * ctor.BYTES_PER_ELEMENT); + }); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + assert.throws(TypeError, () => { + TestIterationAndResize(SendableArray.prototype.values.call(fixedLengthWithOffset), null, rab, 2, 3 * ctor.BYTES_PER_ELEMENT); + }); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTracking = new ctor(rab, 0); + TestIterationAndResize(SendableArray.prototype.values.call(lengthTracking), [ + 0, + 2, + 4 + ], rab, 2, 3 * ctor.BYTES_PER_ELEMENT); +} +for (let ctor of ctors) { + const rab = CreateRabForTest(ctor); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + + // The fixed length array goes out of bounds when the RAB is resized. + TestIterationAndResize(SendableArray.prototype.values.call(lengthTrackingWithOffset), [ + 4, + 6 + ], rab, 2, 3 * ctor.BYTES_PER_ELEMENT); +} diff --git a/test/sendable/builtins/Array/prototype/values/resizable-buffer.js b/test/sendable/builtins/Array/prototype/values/resizable-buffer.js new file mode 100644 index 00000000000..c602c9675f3 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/values/resizable-buffer.js @@ -0,0 +1,154 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.values +description: > + Array.p.values behaves correctly on TypedArrays backed by resizable buffers. +includes: [compareArray.js, resizableArrayBufferUtils.js] +features: [resizable-arraybuffer] +---*/ + +function IteratorToNumbers(iterator) { + const result = []; + for (let value of iterator) { + result.push(Number(value)); + } + return result; +} +for (let ctor of ctors) { + const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT); + const fixedLength = new ctor(rab, 0, 4); + const fixedLengthWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT, 2); + const lengthTracking = new ctor(rab, 0); + const lengthTrackingWithOffset = new ctor(rab, 2 * ctor.BYTES_PER_ELEMENT); + // Write some data into the array. + const taWrite = new ctor(rab); + for (let i = 0; i < 4; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, ...] << lengthTracking + // [4, 6, ...] << lengthTrackingWithOffset + assert.compareArray(IteratorToNumbers(SendableArray.prototype.values.call(fixedLength)), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(IteratorToNumbers(SendableArray.prototype.values.call(fixedLengthWithOffset)), [ + 4, + 6 + ]); + assert.compareArray(IteratorToNumbers(SendableArray.prototype.values.call(lengthTracking)), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(IteratorToNumbers(SendableArray.prototype.values.call(lengthTrackingWithOffset)), [ + 4, + 6 + ]); + // Shrink so that fixed length TAs go out of bounds. + rab.resize(3 * ctor.BYTES_PER_ELEMENT); + // Orig. array: [0, 2, 4] + // [0, 2, 4, ...] << lengthTracking + // [4, ...] << lengthTrackingWithOffset + + // TypedArray.prototype.{entries, keys, values} throw right away when + // called. Array.prototype.{entries, keys, values} don't throw, but when + // we try to iterate the returned ArrayIterator, that throws. + SendableArray.prototype.values.call(fixedLength); + SendableArray.prototype.values.call(fixedLengthWithOffset); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.values.call(fixedLength)); + }); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.values.call(fixedLengthWithOffset)); + }); + assert.compareArray(IteratorToNumbers(SendableArray.prototype.values.call(lengthTracking)), [ + 0, + 2, + 4 + ]); + assert.compareArray(IteratorToNumbers(SendableArray.prototype.values.call(lengthTrackingWithOffset)), [4]); + // Shrink so that the TAs with offset go out of bounds. + rab.resize(1 * ctor.BYTES_PER_ELEMENT); + SendableArray.prototype.values.call(fixedLength); + SendableArray.prototype.values.call(fixedLengthWithOffset); + SendableArray.prototype.values.call(lengthTrackingWithOffset); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.values.call(fixedLength)); + }); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.values.call(fixedLengthWithOffset)); + }); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.values.call(lengthTrackingWithOffset)); + }); + assert.compareArray(IteratorToNumbers(SendableArray.prototype.values.call(lengthTracking)), [0]); + // Shrink to zero. + rab.resize(0); + SendableArray.prototype.values.call(fixedLength); + SendableArray.prototype.values.call(fixedLengthWithOffset); + SendableArray.prototype.values.call(lengthTrackingWithOffset); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.values.call(fixedLength)); + }); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.values.call(fixedLengthWithOffset)); + }); + assert.throws(TypeError, () => { + SendableArray.from(SendableArray.prototype.values.call(lengthTrackingWithOffset)); + }); + assert.compareArray(IteratorToNumbers(SendableArray.prototype.values.call(lengthTracking)), []); + // Grow so that all TAs are back in-bounds. + rab.resize(6 * ctor.BYTES_PER_ELEMENT); + for (let i = 0; i < 6; ++i) { + taWrite[i] = MayNeedBigInt(taWrite, 2 * i); + } + // Orig. array: [0, 2, 4, 6, 8, 10] + // [0, 2, 4, 6] << fixedLength + // [4, 6] << fixedLengthWithOffset + // [0, 2, 4, 6, 8, 10, ...] << lengthTracking + // [4, 6, 8, 10, ...] << lengthTrackingWithOffset + + assert.compareArray(IteratorToNumbers(SendableArray.prototype.values.call(fixedLength)), [ + 0, + 2, + 4, + 6 + ]); + assert.compareArray(IteratorToNumbers(SendableArray.prototype.values.call(fixedLengthWithOffset)), [ + 4, + 6 + ]); + assert.compareArray(IteratorToNumbers(SendableArray.prototype.values.call(lengthTracking)), [ + 0, + 2, + 4, + 6, + 8, + 10 + ]); + assert.compareArray(IteratorToNumbers(SendableArray.prototype.values.call(lengthTrackingWithOffset)), [ + 4, + 6, + 8, + 10 + ]); +} diff --git a/test/sendable/builtins/Array/prototype/values/returns-iterator-from-object.js b/test/sendable/builtins/Array/prototype/values/returns-iterator-from-object.js new file mode 100644 index 00000000000..7316356a200 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/values/returns-iterator-from-object.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.values +description: > + Creates an iterator from a custom object. +info: | + 22.1.3.29 Array.prototype.values ( ) + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "value"). +features: [Symbol.iterator] +---*/ + +var obj = { + length: 2 +}; +var iter = SendableArray.prototype.values.call(obj); +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].values() is %ArrayIteratorPrototype%' +); diff --git a/test/sendable/builtins/Array/prototype/values/returns-iterator.js b/test/sendable/builtins/Array/prototype/values/returns-iterator.js new file mode 100644 index 00000000000..ab06ab6976d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/values/returns-iterator.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.values +description: > + The method should return an Iterator instance. +info: | + 22.1.3.29 Array.prototype.values ( ) + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). + 3. Return CreateArrayIterator(O, "value"). + 22.1.5.1 CreateArrayIterator Abstract Operation + 2. Let iterator be ObjectCreate(%ArrayIteratorPrototype%, «‍[[IteratedObject]], + [[ArrayIteratorNextIndex]], [[ArrayIterationKind]]»). + 6. Return iterator. +features: [Symbol.iterator] +---*/ + +var ArrayIteratorProto = Object.getPrototypeOf([][Symbol.iterator]()); +var iter = [].values(); +assert.sameValue( + Object.getPrototypeOf(iter), ArrayIteratorProto, + 'The prototype of [].values() is %ArrayIteratorPrototype%' +); diff --git a/test/sendable/builtins/Array/prototype/values/this-val-non-obj-coercible.js b/test/sendable/builtins/Array/prototype/values/this-val-non-obj-coercible.js new file mode 100644 index 00000000000..4ee963fb15f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/values/this-val-non-obj-coercible.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.values +description: > + `this` value not object coercible +info: | + 1. Let O be ToObject(this value). + 2. ReturnIfAbrupt(O). +---*/ + +assert.throws(TypeError, function() { + SendableArray.prototype.values.call(undefined); +}); +assert.throws(TypeError, function() { + SendableArray.prototype.values.call(null); +}); diff --git a/test/sendable/builtins/Array/prototype/with/frozen-this-value.js b/test/sendable/builtins/Array/prototype/with/frozen-this-value.js new file mode 100644 index 00000000000..7a2a79c8e9d --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/frozen-this-value.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with works on frozen objects +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = Object.freeze([0, 1, 2]); +var result = arr.with(1, 3); +assert.compareArray(result, [0, 3, 2]); +var arrayLike = Object.freeze({ length: 3, 0: 0, 1: 1, 2: 2 }); +var result2 = SendableArray.prototype.with.call(arrayLike, 1, 3); +assert.compareArray(result2, [0, 3, 2]); diff --git a/test/sendable/builtins/Array/prototype/with/holes-not-preserved.js b/test/sendable/builtins/Array/prototype/with/holes-not-preserved.js new file mode 100644 index 00000000000..7072eeb6481 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/holes-not-preserved.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with does not preserve holes in the array +info: | + Array.prototype.with ( ) + 2. Let len be ? LengthOfArrayLike(O). + 5. Repeat, while k < len + a. Let Pk be ! ToString(𝔽(k)). + b. If k is actualIndex, let fromValue be value. + c. Else, let fromValue be ? Get(O, Pk). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, /* hole */, 2, /* hole */, 4]; +SendableArray.prototype[3] = 3; +var result = arr.with(2, 6); +assert.compareArray(result, [0, undefined, 6, 3, 4]); +assert(result.hasOwnProperty(1)); +assert(result.hasOwnProperty(3)); diff --git a/test/sendable/builtins/Array/prototype/with/ignores-species.js b/test/sendable/builtins/Array/prototype/with/ignores-species.js new file mode 100644 index 00000000000..11ee50d95c4 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/ignores-species.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with ignores @@species +---*/ + +var a = [1, 2, 3]; +a.constructor = {}; +a.constructor[Symbol.species] = function () {} +assert.sameValue(Object.getPrototypeOf(a.with(0, 0)), SendableArray.prototype); +var b = [1, 2, 3]; +Object.defineProperty(b, "constructor", { + get() { + throw new Test262Error("Should not get .constructor"); + } +}); +b.with(0, 0); diff --git a/test/sendable/builtins/Array/prototype/with/immutable.js b/test/sendable/builtins/Array/prototype/with/immutable.js new file mode 100644 index 00000000000..3b69acb2e70 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/immutable.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with does not mutate its this value +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2]; +arr.with(1, 3); +assert.compareArray(arr, [0, 1, 2]); +assert.notSameValue(arr.with(1, 3), arr); +assert.notSameValue(arr.with(1, 1), arr); diff --git a/test/sendable/builtins/Array/prototype/with/index-bigger-or-eq-than-length.js b/test/sendable/builtins/Array/prototype/with/index-bigger-or-eq-than-length.js new file mode 100644 index 00000000000..6b6f5f9ec03 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/index-bigger-or-eq-than-length.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with throws if the index is bigger than or equal to the array length. +info: | + Array.prototype.with ( index, value ) + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + 6. If actualIndex >= len or actualIndex < 0, throw a *RangeError* exception. +features: [change-array-by-copy, exponentiation] +---*/ + +assert.throws(RangeError, function() { + [0, 1, 2].with(3, 7); +}); +assert.throws(RangeError, function() { + [0, 1, 2].with(10, 7); +}); +assert.throws(RangeError, function() { + [0, 1, 2].with(2 ** 53 + 2, 7); +}); +assert.throws(RangeError, function() { + [0, 1, 2].with(Infinity, 7); +}); diff --git a/test/sendable/builtins/Array/prototype/with/index-casted-to-number.js b/test/sendable/builtins/Array/prototype/with/index-casted-to-number.js new file mode 100644 index 00000000000..702f9e7ba7c --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/index-casted-to-number.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with casts the index to an integer. +info: | + Array.prototype.with ( index, value ) + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 4, 16]; +assert.compareArray(arr.with(1.2, 7), [0, 7, 16]); +assert.compareArray(arr.with("1", 3), [0, 3, 16]); +assert.compareArray(arr.with("-1", 5), [0, 4, 5]); +assert.compareArray(arr.with(NaN, 2), [2, 4, 16]); +assert.compareArray(arr.with("dog", "cat"), ["cat", 4, 16]); diff --git a/test/sendable/builtins/Array/prototype/with/index-negative.js b/test/sendable/builtins/Array/prototype/with/index-negative.js new file mode 100644 index 00000000000..aee5fe36e0f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/index-negative.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with adds length to index if it's negative. +info: | + Array.prototype.with ( index, value ) + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2]; +assert.compareArray(arr.with(-1, 4), [0, 1, 4]); +assert.compareArray(arr.with(-3, 4), [4, 1, 2]); +// -0 is not < 0 +assert.compareArray(arr.with(-0, 4), [4, 1, 2]); diff --git a/test/sendable/builtins/Array/prototype/with/index-smaller-than-minus-length.js b/test/sendable/builtins/Array/prototype/with/index-smaller-than-minus-length.js new file mode 100644 index 00000000000..03f875cf4c9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/index-smaller-than-minus-length.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with throws if the (negative) index is smaller than -length. +info: | + Array.prototype.with ( index, value ) + 2. Let len be ? LengthOfArrayLike(O). + 3. Let relativeIndex be ? ToIntegerOrInfinity(index). + 4. If index >= 0, let actualIndex be relativeIndex. + 5. Else, let actualIndex be len + relativeIndex. + 6. If actualIndex >= len or actualIndex < 0, throw a *RangeError* exception. +features: [change-array-by-copy, exponentiation] +---*/ + +[0, 1, 2].with(-3, 7); +assert.throws(RangeError, function() { + [0, 1, 2].with(-4, 7); +}); +assert.throws(RangeError, function() { + [0, 1, 2].with(-10, 7); +}); +assert.throws(RangeError, function() { + [0, 1, 2].with(-(2 ** 53) - 2, 7); +}); +assert.throws(RangeError, function() { + [0, 1, 2].with(-Infinity, 7); +}); diff --git a/test/sendable/builtins/Array/prototype/with/length-decreased-while-iterating.js b/test/sendable/builtins/Array/prototype/with/length-decreased-while-iterating.js new file mode 100644 index 00000000000..0d83a65da38 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/length-decreased-while-iterating.js @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with caches the length getting the array elements. +info: | + Array.prototype.with ( index, value ) + 2. Let len be ? LengthOfArrayLike(O). + 5. Repeat, while k < len + a. Let Pk be ! ToString(𝔽(k)). + b. If k is actualIndex, let fromValue be value. + c. Else, let fromValue be ? Get(O, Pk). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +SendableArray.prototype[4] = 5; +var arr = Object.defineProperty([0, 1, 2, 3, 4], "1", { + get() { + arr.length = 1; + return 1; + } +}); +assert.compareArray(arr.with(2, 7), [0, 1, 7, undefined, 5]); +arr = Object.defineProperty([0, 1, 2, 3, 4], "1", { + get() { + arr.length = 1; + return 1; + } +}); +assert.compareArray(arr.with(0, 7), [7, 1, undefined, undefined, 5]); diff --git a/test/sendable/builtins/Array/prototype/with/length-exceeding-array-length-limit.js b/test/sendable/builtins/Array/prototype/with/length-exceeding-array-length-limit.js new file mode 100644 index 00000000000..4e60f1dd07e --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/length-exceeding-array-length-limit.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with limits the length to 2 ** 32 - 1 +---*/ + +// Object with large "length" property +var arrayLike = { + get "0"() { + throw new Test262Error("Get 0"); + }, + get "4294967295" () { // 2 ** 32 - 1 + throw new Test262Error("Get 4294967295"); + }, + get "4294967296" () { // 2 ** 32 + throw new Test262Error("Get 4294967296"); + }, + length: 2 ** 32 +}; +assert.throws(RangeError, function() { + SendableArray.prototype.with.call(arrayLike, 0, 0); +}); diff --git a/test/sendable/builtins/Array/prototype/with/length-increased-while-iterating.js b/test/sendable/builtins/Array/prototype/with/length-increased-while-iterating.js new file mode 100644 index 00000000000..2b30e7981f9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/length-increased-while-iterating.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with caches the length getting the array elements. +---*/ + +var arr = [0, 1, 2]; +Object.defineProperty(arr, "0", { + get() { + arr.push(4); + return 0; + } +}); +assert.compareArray(arr.with(1, 4), [0, 4, 2]); diff --git a/test/sendable/builtins/Array/prototype/with/length-tolength.js b/test/sendable/builtins/Array/prototype/with/length-tolength.js new file mode 100644 index 00000000000..094a1e4887f --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/length-tolength.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with converts the this value length to a number. +---*/ + +var arrayLike = { length: "2", 0: 1, 1: 2, 2: 3 }; +assert.compareArray(SendableArray.prototype.with.call(arrayLike, 0, 4), [4, 2]); +var arrayLike = { + length: { + valueOf: () => 2 + }, + 0: 1, + 1: 2, + 2: 3, +}; +assert.compareArray(SendableArray.prototype.with.call(arrayLike, 0, 4), [4, 2]); diff --git a/test/sendable/builtins/Array/prototype/with/length.js b/test/sendable/builtins/Array/prototype/with/length.js new file mode 100644 index 00000000000..c17c99a33c9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/length.js @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + The "length" property of Array.prototype.with +info: | + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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] +features: [change-array-by-copy] +---*/ + +verifyProperty(SendableArray.prototype.with, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/with/name.js b/test/sendable/builtins/Array/prototype/with/name.js new file mode 100644 index 00000000000..36e0e57acb9 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/name.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with.name is "with". +info: | + Array.prototype.with ( index, value ) + 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] +features: [change-array-by-copy] +---*/ + +verifyProperty(SendableArray.prototype.with, "name", { + value: "with", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/with/no-get-replaced-index.js b/test/sendable/builtins/Array/prototype/with/no-get-replaced-index.js new file mode 100644 index 00000000000..7b195173896 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/no-get-replaced-index.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with does not [[Get]] the value in the replaced position +info: | + Array.prototype.with ( ) + 5. Repeat, while k < len + a. Let Pk be ! ToString(𝔽(k)). + b. If k is actualIndex, let fromValue be value. + c. Else, let fromValue be ? Get(O, Pk). + d. Perform ? CreateDataPropertyOrThrow(A, Pk, fromValue). + e. Set k to k + 1. +features: [change-array-by-copy] +includes: [compareArray.js] +---*/ + +var arr = [0, 1, 2, 3]; +Object.defineProperty(arr, "2", { + get() { + throw new Test262Error("Should not get '2'"); + } +}); +var result = arr.with(2, 6); +assert.compareArray(result, [0, 1, 6, 3]); diff --git a/test/sendable/builtins/Array/prototype/with/not-a-constructor.js b/test/sendable/builtins/Array/prototype/with/not-a-constructor.js new file mode 100644 index 00000000000..651e49ecba6 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/not-a-constructor.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array.prototype.with 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: [change-array-by-copy, Reflect.construct] +---*/ + +assert.sameValue( + isConstructor(SendableArray.prototype.with), + false, + 'isConstructor(SendableArray.prototype.with) must return false' +); +assert.throws(TypeError, () => { + new SendableArray.prototype.with(); +}); + diff --git a/test/sendable/builtins/Array/prototype/with/property-descriptor.js b/test/sendable/builtins/Array/prototype/with/property-descriptor.js new file mode 100644 index 00000000000..d72c585d123 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/property-descriptor.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + "with" property of Array.prototype +info: | + 17 ECMAScript Standard Built-in Objects + 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] +features: [change-array-by-copy] +---*/ + +assert.sameValue(typeof SendableArray.prototype.with, "function", "typeof"); +verifyProperty(SendableArray.prototype, "with", { + value: SendableArray.prototype.with, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/prototype/with/this-value-boolean.js b/test/sendable/builtins/Array/prototype/with/this-value-boolean.js new file mode 100644 index 00000000000..28fa8e1f207 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/this-value-boolean.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with casts primitive receivers to objects +---*/ + +Boolean.prototype.length = 2; +Boolean.prototype[0] = 0; +Boolean.prototype[1] = 1; +assert.compareArray(SendableArray.prototype.with.call(true, 0, 2), [2, 1]); +assert.compareArray(SendableArray.prototype.with.call(false, 0, 2), [2, 1]); +/* Add length and indexed properties to `Boolean.prototype` */ +Boolean.prototype.length = 3; +delete Boolean.prototype[0]; +delete Boolean.prototype[1]; +assert.compareArray(SendableArray.prototype.with.call(true, 0, 2), [2, undefined, undefined]); +assert.compareArray(SendableArray.prototype.with.call(false, 0, 2), [2, undefined, undefined]); +delete Boolean.prototype.length; +Boolean.prototype[0] = "monkeys"; +Boolean.prototype[2] = "bogus"; +assert.throws(RangeError, + () => compareArray(SendableArray.prototype.with.call(true, 0, 2)), + "SendableArray.prototype.with on object with undefined length"); +assert.throws(RangeError, + () => compareArray(SendableArray.prototype.with.call(false, 0, 2)), + "SendableArray.prototype.with on object with undefined length"); diff --git a/test/sendable/builtins/Array/prototype/with/this-value-nullish.js b/test/sendable/builtins/Array/prototype/with/this-value-nullish.js new file mode 100644 index 00000000000..307d2ac4e46 --- /dev/null +++ b/test/sendable/builtins/Array/prototype/with/this-value-nullish.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array.prototype.with +description: > + Array.prototype.with throws if the receiver is null or undefined +---*/ + +assert.throws(TypeError, () => { + SendableArray.prototype.with.call(null, 0, 0); +}); +assert.throws(TypeError, () => { + SendableArray.prototype.with.call(undefined, 0, 0); +}); -- Gitee From 629fdddc32591806ff4c59bb51249d48d70cf4cc Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 3 Jan 2025 14:52:13 +0800 Subject: [PATCH 71/93] modify error Signed-off-by: zhuzhihui7 --- .../builtins/Array/prototype/toString/S15.4.4.2_A1_T2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T2.js b/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T2.js index 41efc2c2104..ccf1dc69043 100644 --- a/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T2.js +++ b/test/sendable/builtins/Array/prototype/toString/S15.4.4.2_A1_T2.js @@ -43,7 +43,7 @@ if (x.toString() !== x.join()) { throw new Test262Error('#2.2: x = []; x[0] = 0; x[3] = 3; x.toString() === "0,,,3". Actual: ' + (x.toString())); } } -x = SendableArray(undefined, 1, null, 3); +x = new SendableArray(undefined, 1, null, 3); if (x.toString() !== x.join()) { throw new Test262Error('#3.1: x = SendableArray(undefined,1,null,3); x.toString() === x.join(). Actual: ' + (x.toString())); } else { -- Gitee From dc416d1ab707f899d75dd945d94e9e9d3ffa38bd Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 3 Jan 2025 16:17:49 +0800 Subject: [PATCH 72/93] add array others Signed-off-by: zhuzhihui7 --- test/sendable/builtins/Array/15.4.5-1.js | 22 ++++ test/sendable/builtins/Array/15.4.5.1-5-1.js | 24 ++++ test/sendable/builtins/Array/15.4.5.1-5-2.js | 24 ++++ .../builtins/Array/S15.4.1_A1.1_T1.js | 33 +++++ .../builtins/Array/S15.4.1_A1.1_T2.js | 29 +++++ .../builtins/Array/S15.4.1_A1.1_T3.js | 28 ++++ .../builtins/Array/S15.4.1_A1.2_T1.js | 26 ++++ .../builtins/Array/S15.4.1_A1.3_T1.js | 25 ++++ .../builtins/Array/S15.4.1_A2.1_T1.js | 28 ++++ .../builtins/Array/S15.4.1_A2.2_T1.js | 43 ++++++ .../builtins/Array/S15.4.1_A3.1_T1.js | 28 ++++ .../builtins/Array/S15.4.2.1_A1.1_T1.js | 29 +++++ .../builtins/Array/S15.4.2.1_A1.1_T2.js | 29 +++++ .../builtins/Array/S15.4.2.1_A1.1_T3.js | 27 ++++ .../builtins/Array/S15.4.2.1_A1.2_T1.js | 26 ++++ .../builtins/Array/S15.4.2.1_A1.3_T1.js | 25 ++++ .../builtins/Array/S15.4.2.1_A2.1_T1.js | 28 ++++ .../builtins/Array/S15.4.2.1_A2.2_T1.js | 44 +++++++ .../builtins/Array/S15.4.3_A1.1_T1.js | 27 ++++ .../builtins/Array/S15.4.3_A1.1_T2.js | 28 ++++ .../builtins/Array/S15.4.3_A1.1_T3.js | 26 ++++ .../builtins/Array/S15.4.5.1_A1.2_T2.js | 29 +++++ .../builtins/Array/S15.4.5.1_A2.1_T1.js | 34 +++++ .../builtins/Array/S15.4.5.1_A2.2_T1.js | 29 +++++ .../builtins/Array/S15.4.5.1_A2.3_T1.js | 27 ++++ .../builtins/Array/S15.4.5.2_A1_T1.js | 33 +++++ .../builtins/Array/S15.4.5.2_A1_T2.js | 30 +++++ .../builtins/Array/S15.4.5.2_A2_T1.js | 30 +++++ .../builtins/Array/S15.4.5.2_A3_T1.js | 31 +++++ .../builtins/Array/S15.4.5.2_A3_T2.js | 38 ++++++ .../builtins/Array/S15.4.5.2_A3_T3.js | 36 +++++ .../sendable/builtins/Array/S15.4_A1.1_T10.js | 33 +++++ test/sendable/builtins/Array/S15.4_A1.1_T4.js | 28 ++++ test/sendable/builtins/Array/S15.4_A1.1_T5.js | 30 +++++ test/sendable/builtins/Array/S15.4_A1.1_T6.js | 29 +++++ test/sendable/builtins/Array/S15.4_A1.1_T7.js | 31 +++++ test/sendable/builtins/Array/S15.4_A1.1_T8.js | 31 +++++ test/sendable/builtins/Array/S15.4_A1.1_T9.js | 123 ++++++++++++++++++ .../builtins/Array/Symbol.species/length.js | 41 ++++++ .../Array/Symbol.species/return-value.js | 25 ++++ .../Symbol.species/symbol-species-name.js | 32 +++++ .../Array/Symbol.species/symbol-species.js | 30 +++++ test/sendable/builtins/Array/constructor.js | 21 +++ .../builtins/Array/is-a-constructor.js | 33 +++++ test/sendable/builtins/Array/length.js | 33 +++++ test/sendable/builtins/Array/name.js | 37 ++++++ test/sendable/builtins/Array/prop-desc.js | 34 +++++ .../Array/property-cast-boolean-primitive.js | 29 +++++ .../Array/property-cast-nan-infinity.js | 34 +++++ .../builtins/Array/property-cast-number.js | 45 +++++++ .../Array/proto-from-ctor-realm-one.js | 53 ++++++++ .../Array/proto-from-ctor-realm-two.js | 40 ++++++ .../Array/proto-from-ctor-realm-zero.js | 40 ++++++ test/sendable/builtins/Array/proto.js | 29 +++++ 54 files changed, 1777 insertions(+) create mode 100644 test/sendable/builtins/Array/15.4.5-1.js create mode 100644 test/sendable/builtins/Array/15.4.5.1-5-1.js create mode 100644 test/sendable/builtins/Array/15.4.5.1-5-2.js create mode 100644 test/sendable/builtins/Array/S15.4.1_A1.1_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.1_A1.1_T2.js create mode 100644 test/sendable/builtins/Array/S15.4.1_A1.1_T3.js create mode 100644 test/sendable/builtins/Array/S15.4.1_A1.2_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.1_A1.3_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.1_A2.1_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.1_A2.2_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.1_A3.1_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.2.1_A1.1_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.2.1_A1.1_T2.js create mode 100644 test/sendable/builtins/Array/S15.4.2.1_A1.1_T3.js create mode 100644 test/sendable/builtins/Array/S15.4.2.1_A1.2_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.2.1_A1.3_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.2.1_A2.1_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.2.1_A2.2_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.3_A1.1_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.3_A1.1_T2.js create mode 100644 test/sendable/builtins/Array/S15.4.3_A1.1_T3.js create mode 100644 test/sendable/builtins/Array/S15.4.5.1_A1.2_T2.js create mode 100644 test/sendable/builtins/Array/S15.4.5.1_A2.1_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.5.1_A2.2_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.5.1_A2.3_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.5.2_A1_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.5.2_A1_T2.js create mode 100644 test/sendable/builtins/Array/S15.4.5.2_A2_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.5.2_A3_T1.js create mode 100644 test/sendable/builtins/Array/S15.4.5.2_A3_T2.js create mode 100644 test/sendable/builtins/Array/S15.4.5.2_A3_T3.js create mode 100644 test/sendable/builtins/Array/S15.4_A1.1_T10.js create mode 100644 test/sendable/builtins/Array/S15.4_A1.1_T4.js create mode 100644 test/sendable/builtins/Array/S15.4_A1.1_T5.js create mode 100644 test/sendable/builtins/Array/S15.4_A1.1_T6.js create mode 100644 test/sendable/builtins/Array/S15.4_A1.1_T7.js create mode 100644 test/sendable/builtins/Array/S15.4_A1.1_T8.js create mode 100644 test/sendable/builtins/Array/S15.4_A1.1_T9.js create mode 100644 test/sendable/builtins/Array/Symbol.species/length.js create mode 100644 test/sendable/builtins/Array/Symbol.species/return-value.js create mode 100644 test/sendable/builtins/Array/Symbol.species/symbol-species-name.js create mode 100644 test/sendable/builtins/Array/Symbol.species/symbol-species.js create mode 100644 test/sendable/builtins/Array/constructor.js create mode 100644 test/sendable/builtins/Array/is-a-constructor.js create mode 100644 test/sendable/builtins/Array/length.js create mode 100644 test/sendable/builtins/Array/name.js create mode 100644 test/sendable/builtins/Array/prop-desc.js create mode 100644 test/sendable/builtins/Array/property-cast-boolean-primitive.js create mode 100644 test/sendable/builtins/Array/property-cast-nan-infinity.js create mode 100644 test/sendable/builtins/Array/property-cast-number.js create mode 100644 test/sendable/builtins/Array/proto-from-ctor-realm-one.js create mode 100644 test/sendable/builtins/Array/proto-from-ctor-realm-two.js create mode 100644 test/sendable/builtins/Array/proto-from-ctor-realm-zero.js create mode 100644 test/sendable/builtins/Array/proto.js diff --git a/test/sendable/builtins/Array/15.4.5-1.js b/test/sendable/builtins/Array/15.4.5-1.js new file mode 100644 index 00000000000..e94ce1186e2 --- /dev/null +++ b/test/sendable/builtins/Array/15.4.5-1.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +es5id: 15.4.5-1 +description: Array instances have [[Class]] set to 'Array' +---*/ + +var a = []; +var s = Object.prototype.toString.call(a); +assert.sameValue(s, '[object SendableArray]', 'The value of s is expected to be "[object SendableArray]"'); diff --git a/test/sendable/builtins/Array/15.4.5.1-5-1.js b/test/sendable/builtins/Array/15.4.5.1-5-1.js new file mode 100644 index 00000000000..587cfcac961 --- /dev/null +++ b/test/sendable/builtins/Array/15.4.5.1-5-1.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +es5id: 15.4.5.1-5-1 +description: > + Defining a property named 4294967295 (2**32-1)(not an array + element) +---*/ + +var a = []; +a[4294967295] = "not an array element"; +assert.sameValue(a[4294967295], "not an array element", 'The value of a[4294967295] is expected to be "not an array element"'); diff --git a/test/sendable/builtins/Array/15.4.5.1-5-2.js b/test/sendable/builtins/Array/15.4.5.1-5-2.js new file mode 100644 index 00000000000..5c891e23bdd --- /dev/null +++ b/test/sendable/builtins/Array/15.4.5.1-5-2.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +es5id: 15.4.5.1-5-2 +description: > + Defining a property named 4294967295 (2**32-1) doesn't change + length of the array +---*/ + +var a = [0, 1, 2]; +a[4294967295] = "not an array element"; +assert.sameValue(a.length, 3, 'The value of a.length is expected to be 3'); diff --git a/test/sendable/builtins/Array/S15.4.1_A1.1_T1.js b/test/sendable/builtins/Array/S15.4.1_A1.1_T1.js new file mode 100644 index 00000000000..09d90b299ac --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.1_A1.1_T1.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.1_A1.1_T1 +description: > + Create new property of Array.prototype. When new Array object has + this property +---*/ + +SendableArray.prototype.myproperty = 42; +var x = SendableArray(); +assert.sameValue(x.myproperty, 42, 'The value of x.myproperty is expected to be 42'); +assert.sameValue( + Object.prototype.hasOwnProperty.call(x, 'myproperty'), + false, + 'Object.prototype.hasOwnProperty.call(SendableArray(), "myproperty") must return false' +); diff --git a/test/sendable/builtins/Array/S15.4.1_A1.1_T2.js b/test/sendable/builtins/Array/S15.4.1_A1.1_T2.js new file mode 100644 index 00000000000..51e04777f05 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.1_A1.1_T2.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.1_A1.1_T2 +description: Array.prototype.toString = Object.prototype.toString +---*/ + +SendableArray.prototype.toString = Object.prototype.toString; +var x = SendableArray(); +assert.sameValue(x.toString(), "[object SendableArray]", 'x.toString() must return "[object SendableArray]"'); +SendableArray.prototype.toString = Object.prototype.toString; +var x = SendableArray(0, 1, 2); +assert.sameValue(x.toString(), "[object SendableArray]", 'x.toString() must return "[object SendableArray]"'); diff --git a/test/sendable/builtins/Array/S15.4.1_A1.1_T3.js b/test/sendable/builtins/Array/S15.4.1_A1.1_T3.js new file mode 100644 index 00000000000..934d3569e14 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.1_A1.1_T3.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.1_A1.1_T3 +description: Checking use isPrototypeOf +---*/ + +assert.sameValue( + SendableArray.prototype.isPrototypeOf(SendableArray()), + true, + 'SendableArray.prototype.isPrototypeOf(SendableArray()) must return true' +); diff --git a/test/sendable/builtins/Array/S15.4.1_A1.2_T1.js b/test/sendable/builtins/Array/S15.4.1_A1.2_T1.js new file mode 100644 index 00000000000..56bbb9d689b --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.1_A1.2_T1.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: The [[Class]] property of the newly constructed object is set to "Array" +es5id: 15.4.1_A1.2_T1 +description: Checking use Object.prototype.toString +---*/ + +var x = SendableArray(); +x.getClass = Object.prototype.toString; +assert.sameValue(x.getClass(), "[object SendableArray]", 'x.getClass() must return "[object SendableArray]"'); +var x = SendableArray(0, 1, 2); +x.getClass = Object.prototype.toString; +assert.sameValue(x.getClass(), "[object SendableArray]", 'x.getClass() must return "[object SendableArray]"'); diff --git a/test/sendable/builtins/Array/S15.4.1_A1.3_T1.js b/test/sendable/builtins/Array/S15.4.1_A1.3_T1.js new file mode 100644 index 00000000000..49eaf28369f --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.1_A1.3_T1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + This description of Array constructor applies if and only if + the Array constructor is given no arguments or at least two arguments +es5id: 15.4.1_A1.3_T1 +description: Checking case when Array constructor is given one argument +---*/ + +var x = SendableArray(2); +assert.notSameValue(x.length, 1, 'The value of x.length is not 1'); +assert.notSameValue(x[0], 2, 'The value of x[0] is not 2'); diff --git a/test/sendable/builtins/Array/S15.4.1_A2.1_T1.js b/test/sendable/builtins/Array/S15.4.1_A2.1_T1.js new file mode 100644 index 00000000000..7a778123cce --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.1_A2.1_T1.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The length property of the newly constructed object; + is set to the number of arguments +es5id: 15.4.1_A2.1_T1 +description: Array constructor is given no arguments or at least two arguments +---*/ +assert.sameValue(SendableArray().length, 0, 'The value of SendableArray().length is expected to be 0'); +assert.sameValue(SendableArray(0, 1, 0, 1).length, 4, 'The value of SendableArray(0, 1, 0, 1).length is expected to be 4'); +assert.sameValue( + SendableArray(undefined, undefined).length, + 2, + 'The value of SendableArray(undefined, undefined).length is expected to be 2' +); diff --git a/test/sendable/builtins/Array/S15.4.1_A2.2_T1.js b/test/sendable/builtins/Array/S15.4.1_A2.2_T1.js new file mode 100644 index 00000000000..4847b889444 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.1_A2.2_T1.js @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The 0 property of the newly constructed object is set to item0 + (if supplied); the 1 property of the newly constructed object is set to item1 + (if supplied); and, in general, for as many arguments as there are, the k property + of the newly constructed object is set to argument k, where the first argument is + considered to be argument number 0 +es5id: 15.4.1_A2.2_T1 +description: Checking correct work this algorithm +---*/ +var x = SendableArray( + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 +); +for (var i = 0; i < 100; i++) { + var result = true; + if (x[i] !== i) { + result = false; + } +} +assert.sameValue(result, true, 'The value of result is expected to be true'); diff --git a/test/sendable/builtins/Array/S15.4.1_A3.1_T1.js b/test/sendable/builtins/Array/S15.4.1_A3.1_T1.js new file mode 100644 index 00000000000..b8c42478196 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.1_A3.1_T1.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + When Array is called as a function rather than as a constructor, + it creates and initialises a new Array object +es5id: 15.4.1_A3.1_T1 +description: Checking use typeof, instanceof +---*/ + +assert.sameValue(typeof SendableArray(), "object", 'The value of `typeof SendableArray()` is expected to be "object"'); +assert.sameValue( + SendableArray() instanceof SendableArray, + true, + 'The result of evaluating (SendableArray() instanceof SendableArray) is expected to be true' +); diff --git a/test/sendable/builtins/Array/S15.4.2.1_A1.1_T1.js b/test/sendable/builtins/Array/S15.4.2.1_A1.1_T1.js new file mode 100644 index 00000000000..71b3232dc51 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.2.1_A1.1_T1.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.2.1_A1.1_T1 +description: > + Create new property of Array.prototype. When new Array object has + this property +---*/ + +SendableArray.prototype.myproperty = 1; +var x = new SendableArray(); +assert.sameValue(x.myproperty, 1, 'The value of x.myproperty is expected to be 1'); +assert.sameValue(x.hasOwnProperty('myproperty'), false, 'x.hasOwnProperty("myproperty") must return false'); diff --git a/test/sendable/builtins/Array/S15.4.2.1_A1.1_T2.js b/test/sendable/builtins/Array/S15.4.2.1_A1.1_T2.js new file mode 100644 index 00000000000..b02e04ae2f8 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.2.1_A1.1_T2.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.2.1_A1.1_T2 +description: Array.prototype.toString = Object.prototype.toString +---*/ + +SendableArray.prototype.toString = Object.prototype.toString; +var x = new SendableArray(); +assert.sameValue(x.toString(), "[object SendableArray]", 'x.toString() must return "[object SendableArray]"'); +SendableArray.prototype.toString = Object.prototype.toString; +var x = new SendableArray(0, 1, 2); +assert.sameValue(x.toString(), "[object SendableArray]", 'x.toString() must return "[object SendableArray]"'); diff --git a/test/sendable/builtins/Array/S15.4.2.1_A1.1_T3.js b/test/sendable/builtins/Array/S15.4.2.1_A1.1_T3.js new file mode 100644 index 00000000000..9a1c62735b0 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.2.1_A1.1_T3.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The [[Prototype]] property of the newly constructed object + is set to the original Array prototype object, the one that + is the initial value of Array.prototype +es5id: 15.4.2.1_A1.1_T3 +description: Checking use isPrototypeOf +---*/ +assert.sameValue( + SendableArray.prototype.isPrototypeOf(new SendableArray()), + true, + 'SendableArray.prototype.isPrototypeOf(new SendableArray()) must return true' +); diff --git a/test/sendable/builtins/Array/S15.4.2.1_A1.2_T1.js b/test/sendable/builtins/Array/S15.4.2.1_A1.2_T1.js new file mode 100644 index 00000000000..76145021bf6 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.2.1_A1.2_T1.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: The [[Class]] property of the newly constructed object is set to "Array" +es5id: 15.4.2.1_A1.2_T1 +description: Checking use Object.prototype.toString +---*/ + +var x = new SendableArray(); +x.getClass = Object.prototype.toString; +assert.sameValue(x.getClass(), "[object SendableArray]", 'x.getClass() must return "[object SendableArray]"'); +var x = new SendableArray(0, 1, 2); +x.getClass = Object.prototype.toString; +assert.sameValue(x.getClass(), "[object SendableArray]", 'x.getClass() must return "[object SendableArray]"'); diff --git a/test/sendable/builtins/Array/S15.4.2.1_A1.3_T1.js b/test/sendable/builtins/Array/S15.4.2.1_A1.3_T1.js new file mode 100644 index 00000000000..4a5fa6300db --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.2.1_A1.3_T1.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + This description of Array constructor applies if and only if + the Array constructor is given no arguments or at least two arguments +es5id: 15.4.2.1_A1.3_T1 +description: Checking case when Array constructor is given one argument +---*/ + +var x = new SendableArray(2); +assert.notSameValue(x.length, 1, 'The value of x.length is not 1'); +assert.notSameValue(x[0], 2, 'The value of x[0] is not 2'); diff --git a/test/sendable/builtins/Array/S15.4.2.1_A2.1_T1.js b/test/sendable/builtins/Array/S15.4.2.1_A2.1_T1.js new file mode 100644 index 00000000000..6ea53b0c58d --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.2.1_A2.1_T1.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The length property of the newly constructed object; + is set to the number of arguments +es5id: 15.4.2.1_A2.1_T1 +description: Array constructor is given no arguments or at least two arguments +---*/ +assert.sameValue(new SendableArray().length, 0, 'The value of new SendableArray().length is expected to be 0'); +assert.sameValue(new SendableArray(0, 1, 0, 1).length, 4, 'The value of new SendableArray(0, 1, 0, 1).length is expected to be 4'); +assert.sameValue( + new SendableArray(undefined, undefined).length, + 2, + 'The value of new SendableArray(undefined, undefined).length is expected to be 2' +); diff --git a/test/sendable/builtins/Array/S15.4.2.1_A2.2_T1.js b/test/sendable/builtins/Array/S15.4.2.1_A2.2_T1.js new file mode 100644 index 00000000000..73fde085fe1 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.2.1_A2.2_T1.js @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The 0 property of the newly constructed object is set to item0 + (if supplied); the 1 property of the newly constructed object is set to item1 + (if supplied); and, in general, for as many arguments as there are, the k property + of the newly constructed object is set to argument k, where the first argument is + considered to be argument number 0 +es5id: 15.4.2.1_A2.2_T1 +description: Checking correct work this algorithm +---*/ + +var x = new SendableArray( + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, + 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, + 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, + 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 +); +for (var i = 0; i < 100; i++) { + var result = true; + if (x[i] !== i) { + result = false; + } +} +assert.sameValue(result, true, 'The value of result is expected to be true'); diff --git a/test/sendable/builtins/Array/S15.4.3_A1.1_T1.js b/test/sendable/builtins/Array/S15.4.3_A1.1_T1.js new file mode 100644 index 00000000000..24a3df9105d --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.3_A1.1_T1.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The value of the internal [[Prototype]] property of + the Array constructor is the Function prototype object +es5id: 15.4.3_A1.1_T1 +description: > + Create new property of Function.prototype. When Array constructor + has this property +---*/ + +Function.prototype.myproperty = 1; +assert.sameValue(SendableArray.myproperty, 1, 'The value of SendableArray.myproperty is expected to be 1'); +assert.sameValue(SendableArray.hasOwnProperty('myproperty'), false, 'SendableArray.hasOwnProperty("myproperty") must return false'); diff --git a/test/sendable/builtins/Array/S15.4.3_A1.1_T2.js b/test/sendable/builtins/Array/S15.4.3_A1.1_T2.js new file mode 100644 index 00000000000..5f42caeb9b9 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.3_A1.1_T2.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The value of the internal [[Prototype]] property of + the Array constructor is the Function prototype object +es5id: 15.4.3_A1.1_T2 +description: Function.prototype.toString = Object.prototype.toString +---*/ + +Function.prototype.toString = Object.prototype.toString; +assert.sameValue( + SendableArray.toString(), + "[object Function]", + 'SendableArray.toString() must return "[object Function]"' +); diff --git a/test/sendable/builtins/Array/S15.4.3_A1.1_T3.js b/test/sendable/builtins/Array/S15.4.3_A1.1_T3.js new file mode 100644 index 00000000000..fc22f086d4d --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.3_A1.1_T3.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + The value of the internal [[Prototype]] property of + the Array constructor is the Function prototype object +es5id: 15.4.3_A1.1_T3 +description: Checking use isPrototypeOf +---*/ +assert.sameValue( + Function.prototype.isPrototypeOf(SendableArray), + true, + 'Function.prototype.isPrototypeOf(SendableArray) must return true' +); diff --git a/test/sendable/builtins/Array/S15.4.5.1_A1.2_T2.js b/test/sendable/builtins/Array/S15.4.5.1_A1.2_T2.js new file mode 100644 index 00000000000..a6a3e0809fa --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.5.1_A1.2_T2.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + For every integer k that is less than the value of + the length property of A but not less than ToUint32(length), + if A itself has a property (not an inherited property) named ToString(k), + then delete that property +es5id: 15.4.5.1_A1.2_T2 +description: Checking an inherited property +---*/ + +SendableArray.prototype[2] = -1; +var x = [0, 1, 2]; +assert.sameValue(x[2], 2, 'The value of x[2] is expected to be 2'); +x.length = 2; +assert.sameValue(x[2], -1, 'The value of x[2] is expected to be -1'); diff --git a/test/sendable/builtins/Array/S15.4.5.1_A2.1_T1.js b/test/sendable/builtins/Array/S15.4.5.1_A2.1_T1.js new file mode 100644 index 00000000000..748289cd941 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.5.1_A2.1_T1.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If P is not an array index, return + (Create a property with name P, set its value to V and give it empty attributes) +es5id: 15.4.5.1_A2.1_T1 +description: P in [4294967295, -1, true] +---*/ + +var x = []; +x[4294967295] = 1; +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); +assert.sameValue(x[4294967295], 1, 'The value of x[4294967295] is expected to be 1'); +x = []; +x[-1] = 1; +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); +assert.sameValue(x[-1], 1, 'The value of x[-1] is expected to be 1'); +x = []; +x[true] = 1; +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); +assert.sameValue(x[true], 1, 'The value of x[true] is expected to be 1'); diff --git a/test/sendable/builtins/Array/S15.4.5.1_A2.2_T1.js b/test/sendable/builtins/Array/S15.4.5.1_A2.2_T1.js new file mode 100644 index 00000000000..d5db0c74276 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.5.1_A2.2_T1.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If ToUint32(P) is less than the value of + the length property of A, then return +es5id: 15.4.5.1_A2.2_T1 +description: length === 100, P in [0, 98, 99] +---*/ + +var x = SendableArray(100); +x[0] = 1; +assert.sameValue(x.length, 100, 'The value of x.length is expected to be 100'); +x[98] = 1; +assert.sameValue(x.length, 100, 'The value of x.length is expected to be 100'); +x[99] = 1; +assert.sameValue(x.length, 100, 'The value of x.length is expected to be 100'); diff --git a/test/sendable/builtins/Array/S15.4.5.1_A2.3_T1.js b/test/sendable/builtins/Array/S15.4.5.1_A2.3_T1.js new file mode 100644 index 00000000000..2348b975306 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.5.1_A2.3_T1.js @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If ToUint32(P) is less than the value of + the length property of A, change (or set) length to ToUint32(P)+1 +es5id: 15.4.5.1_A2.3_T1 +description: length = 100, P in [100, 199] +---*/ + +var x = SendableArray(100); +x[100] = 1; +assert.sameValue(x.length, 101, 'The value of x.length is expected to be 101'); +x[199] = 1; +assert.sameValue(x.length, 200, 'The value of x.length is expected to be 200'); diff --git a/test/sendable/builtins/Array/S15.4.5.2_A1_T1.js b/test/sendable/builtins/Array/S15.4.5.2_A1_T1.js new file mode 100644 index 00000000000..ab23a4ce073 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.5.2_A1_T1.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + Every Array object has a length property whose value is + always a nonnegative integer less than 2^32. The value of the length property is + numerically greater than the name of every property whose name is an array index +es5id: 15.4.5.2_A1_T1 +description: Checking boundary points +---*/ + +var x = []; +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); +x[0] = 1; +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +x[1] = 1; +assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); +x[2147483648] = 1; +assert.sameValue(x.length, 2147483649, 'The value of x.length is expected to be 2147483649'); +x[4294967294] = 1; +assert.sameValue(x.length, 4294967295, 'The value of x.length is expected to be 4294967295'); diff --git a/test/sendable/builtins/Array/S15.4.5.2_A1_T2.js b/test/sendable/builtins/Array/S15.4.5.2_A1_T2.js new file mode 100644 index 00000000000..8060baf982f --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.5.2_A1_T2.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + Every Array object has a length property whose value is + always a nonnegative integer less than 2^32. The value of the length property is + numerically greater than the name of every property whose name is an array index +es5id: 15.4.5.2_A1_T2 +description: P = "2^32 - 1" is not index array +---*/ + +var x = []; +x[4294967295] = 1; +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); +var y = []; +y[1] = 1; +y[4294967295] = 1; +assert.sameValue(y.length, 2, 'The value of y.length is expected to be 2'); diff --git a/test/sendable/builtins/Array/S15.4.5.2_A2_T1.js b/test/sendable/builtins/Array/S15.4.5.2_A2_T1.js new file mode 100644 index 00000000000..482e437b447 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.5.2_A2_T1.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If a property is added whose name is an array index, + the length property is changed +es5id: 15.4.5.2_A2_T1 +description: Checking length property +---*/ + +var x = []; +assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); +x[0] = 1; +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +x[1] = 1; +assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); +x[9] = 1; +assert.sameValue(x.length, 10, 'The value of x.length is expected to be 10'); diff --git a/test/sendable/builtins/Array/S15.4.5.2_A3_T1.js b/test/sendable/builtins/Array/S15.4.5.2_A3_T1.js new file mode 100644 index 00000000000..ad929c8f9d7 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.5.2_A3_T1.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If the length property is changed, every property whose name + is an array index whose value is not smaller than the new length is automatically deleted +es5id: 15.4.5.2_A3_T1 +description: > + If new length greater than the name of every property whose name + is an array index +---*/ + +var x = []; +x.length = 1; +assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); +x[5] = 1; +x.length = 10; +assert.sameValue(x.length, 10, 'The value of x.length is expected to be 10'); +assert.sameValue(x[5], 1, 'The value of x[5] is expected to be 1'); diff --git a/test/sendable/builtins/Array/S15.4.5.2_A3_T2.js b/test/sendable/builtins/Array/S15.4.5.2_A3_T2.js new file mode 100644 index 00000000000..9668838663e --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.5.2_A3_T2.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If the length property is changed, every property whose name + is an array index whose value is not smaller than the new length is automatically deleted +es5id: 15.4.5.2_A3_T2 +description: > + If new length greater than the name of every property whose name + is an array index +---*/ + +var x = []; +x[1] = 1; +x[3] = 3; +x[5] = 5; +x.length = 4; +assert.sameValue(x.length, 4, 'The value of x.length is expected to be 4'); +assert.sameValue(x[5], undefined, 'The value of x[5] is expected to equal undefined'); +assert.sameValue(x[3], 3, 'The value of x[3] is expected to be 3'); +x.length = new Number(6); +assert.sameValue(x[5], undefined, 'The value of x[5] is expected to equal undefined'); +x.length = 0; +assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined'); +x.length = 1; +assert.sameValue(x[1], undefined, 'The value of x[1] is expected to equal undefined'); diff --git a/test/sendable/builtins/Array/S15.4.5.2_A3_T3.js b/test/sendable/builtins/Array/S15.4.5.2_A3_T3.js new file mode 100644 index 00000000000..c73331bea8f --- /dev/null +++ b/test/sendable/builtins/Array/S15.4.5.2_A3_T3.js @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + If the length property is changed, every property whose name + is an array index whose value is not smaller than the new length is automatically deleted +es5id: 15.4.5.2_A3_T3 +description: "[[Put]] (length, 4294967296)" +---*/ + +var x = []; +x.length = 4294967295; +assert.sameValue(x.length, 4294967295, 'The value of x.length is expected to be 4294967295'); +try { + x = []; + x.length = 4294967296; + throw new Test262Error('#2.1: x = []; x.length = 4294967296 throw RangeError. Actual: x.length === ' + (x.length)); +} catch (e) { + assert.sameValue( + e instanceof RangeError, + true, + 'The result of evaluating (e instanceof RangeError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Array/S15.4_A1.1_T10.js b/test/sendable/builtins/Array/S15.4_A1.1_T10.js new file mode 100644 index 00000000000..35be576a29c --- /dev/null +++ b/test/sendable/builtins/Array/S15.4_A1.1_T10.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T10 +description: Array index is power of two +---*/ + +var x = []; +var k = 1; +for (var i = 0; i < 32; i++) { + k = k * 2; + x[k - 2] = k; +} +k = 1; +for (i = 0; i < 32; i++) { + k = k * 2; + assert.sameValue(x[k - 2], k, 'The value of x[k - 2] is expected to equal the value of k'); +} diff --git a/test/sendable/builtins/Array/S15.4_A1.1_T4.js b/test/sendable/builtins/Array/S15.4_A1.1_T4.js new file mode 100644 index 00000000000..2f96dd7f649 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4_A1.1_T4.js @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T4 +description: Checking for string primitive +---*/ + +var x = []; +x["0"] = 0; +assert.sameValue(x[0], 0, 'The value of x[0] is expected to be 0'); +var y = []; +y["1"] = 1; +assert.sameValue(y[1], 1, 'The value of y[1] is expected to be 1'); diff --git a/test/sendable/builtins/Array/S15.4_A1.1_T5.js b/test/sendable/builtins/Array/S15.4_A1.1_T5.js new file mode 100644 index 00000000000..13e9dbc4919 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4_A1.1_T5.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T5 +description: Checking for null and undefined +---*/ + +var x = []; +x[null] = 0; +assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined'); +assert.sameValue(x["null"], 0, 'The value of x["null"] is expected to be 0'); +var y = []; +y[undefined] = 0; +assert.sameValue(y[0], undefined, 'The value of y[0] is expected to equal undefined'); +assert.sameValue(y["undefined"], 0, 'The value of y["undefined"] is expected to be 0'); diff --git a/test/sendable/builtins/Array/S15.4_A1.1_T6.js b/test/sendable/builtins/Array/S15.4_A1.1_T6.js new file mode 100644 index 00000000000..45e5034706b --- /dev/null +++ b/test/sendable/builtins/Array/S15.4_A1.1_T6.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T6 +description: Checking for Boolean object +---*/ + +var x = []; +x[new Boolean(true)] = 1; +assert.sameValue(x[1], undefined, 'The value of x[1] is expected to equal undefined'); +assert.sameValue(x["true"], 1, 'The value of x["true"] is expected to be 1'); +x[new Boolean(false)] = 0; +assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined'); +assert.sameValue(x["false"], 0, 'The value of x["false"] is expected to be 0'); diff --git a/test/sendable/builtins/Array/S15.4_A1.1_T7.js b/test/sendable/builtins/Array/S15.4_A1.1_T7.js new file mode 100644 index 00000000000..9eb3a110786 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4_A1.1_T7.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T7 +description: Checking for Number object +---*/ + +var x = []; +x[new Number(0)] = 0; +assert.sameValue(x[0], 0, 'The value of x[0] is expected to be 0'); +var y = []; +y[new Number(1)] = 1; +assert.sameValue(y[1], 1, 'The value of y[1] is expected to be 1'); +var z = []; +z[new Number(1.1)] = 1; +assert.sameValue(z["1.1"], 1, 'The value of z["1.1"] is expected to be 1'); diff --git a/test/sendable/builtins/Array/S15.4_A1.1_T8.js b/test/sendable/builtins/Array/S15.4_A1.1_T8.js new file mode 100644 index 00000000000..3d5b7172b24 --- /dev/null +++ b/test/sendable/builtins/Array/S15.4_A1.1_T8.js @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T8 +description: Checking for Number object +---*/ + +var x = []; +x[new String("0")] = 0; +assert.sameValue(x[0], 0, 'The value of x[0] is expected to be 0'); +var y = []; +y[new String("1")] = 1; +assert.sameValue(y[1], 1, 'The value of y[1] is expected to be 1'); +var z = []; +z[new String("1.1")] = 1; +assert.sameValue(z["1.1"], 1, 'The value of z["1.1"] is expected to be 1'); diff --git a/test/sendable/builtins/Array/S15.4_A1.1_T9.js b/test/sendable/builtins/Array/S15.4_A1.1_T9.js new file mode 100644 index 00000000000..58d0ee61cee --- /dev/null +++ b/test/sendable/builtins/Array/S15.4_A1.1_T9.js @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T9 +description: If Type(value) is Object, evaluate ToPrimitive(value, String) +---*/ + +var x = []; +var object = { + valueOf: function() { + return 1 + } +}; +x[object] = 0; +assert.sameValue(x["[object Object]"], 0, 'The value of x["[object Object]"] is expected to be 0'); +x = []; +var object = { + valueOf: function() { + return 1 + }, + toString: function() { + return 0 + } +}; +x[object] = 0; +assert.sameValue(x[0], 0, 'The value of x[0] is expected to be 0'); +x = []; +var object = { + valueOf: function() { + return 1 + }, + toString: function() { + return {} + } +}; +x[object] = 0; +assert.sameValue(x[1], 0, 'The value of x[1] is expected to be 0'); +try { + x = []; + var object = { + valueOf: function() { + throw "error" + }, + toString: function() { + return 1 + } + }; + x[object] = 0; + assert.sameValue(x[1], 0, 'The value of x[1] is expected to be 0'); +} +catch (e) { + assert.notSameValue(e, "error", 'The value of e is not "error"'); +} +x = []; +var object = { + toString: function() { + return 1 + } +}; +x[object] = 0; +assert.sameValue(x[1], 0, 'The value of x[1] is expected to be 0'); +x = []; +var object = { + valueOf: function() { + return {} + }, + toString: function() { + return 1 + } +} +x[object] = 0; +assert.sameValue(x[1], 0, 'The value of x[1] is expected to be 0'); +try { + x = []; + var object = { + valueOf: function() { + return 1 + }, + toString: function() { + throw "error" + } + }; + x[object]; + throw new Test262Error('#7.1: x = []; var object = {valueOf: function() {return 1}, toString: function() {throw "error"}}; x[object] throw "error". Actual: ' + (x[object])); +} +catch (e) { + assert.sameValue(e, "error", 'The value of e is expected to be "error"'); +} +try { + x = []; + var object = { + valueOf: function() { + return {} + }, + toString: function() { + return {} + } + }; + x[object]; + throw new Test262Error('#8.1: x = []; var object = {valueOf: function() {return {}}, toString: function() {return {}}}; x[object] throw TypeError. Actual: ' + (x[object])); +} +catch (e) { + assert.sameValue( + e instanceof TypeError, + true, + 'The result of evaluating (e instanceof TypeError) is expected to be true' + ); +} diff --git a/test/sendable/builtins/Array/Symbol.species/length.js b/test/sendable/builtins/Array/Symbol.species/length.js new file mode 100644 index 00000000000..af2885c948d --- /dev/null +++ b/test/sendable/builtins/Array/Symbol.species/length.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +es6id: 22.1.2.5 +description: > + get Array [ @@species ].length is 0. +info: | + get Array [ @@species ] + 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] +features: [Symbol.species] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArray, Symbol.species); +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/Symbol.species/return-value.js b/test/sendable/builtins/Array/Symbol.species/return-value.js new file mode 100644 index 00000000000..18742ed7fd3 --- /dev/null +++ b/test/sendable/builtins/Array/Symbol.species/return-value.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-get-array-@@species +description: Return value of @@species accessor method +info: | + 1. Return the this value. +features: [Symbol.species] +---*/ + +var thisVal = {}; +var accessor = Object.getOwnPropertyDescriptor(SendableArray, Symbol.species).get; +assert.sameValue(accessor.call(thisVal), thisVal); diff --git a/test/sendable/builtins/Array/Symbol.species/symbol-species-name.js b/test/sendable/builtins/Array/Symbol.species/symbol-species-name.js new file mode 100644 index 00000000000..24bf9a9bc0b --- /dev/null +++ b/test/sendable/builtins/Array/Symbol.species/symbol-species-name.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +es6id: 22.1.2.5 +description: > + Array[Symbol.species] accessor property get name +info: | + 22.1.2.5 get Array [ @@species ] + The value of the name property of this function is "get [Symbol.species]". +features: [Symbol.species] +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(SendableArray, Symbol.species); +verifyProperty(descriptor.get, "name", { + value: "get [Symbol.species]", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/Symbol.species/symbol-species.js b/test/sendable/builtins/Array/Symbol.species/symbol-species.js new file mode 100644 index 00000000000..69061674383 --- /dev/null +++ b/test/sendable/builtins/Array/Symbol.species/symbol-species.js @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + Array has a property at `Symbol.species` +esid: sec-get-array-@@species +author: Sam Mikes +description: Array[Symbol.species] exists per spec +includes: [propertyHelper.js] +features: [Symbol.species] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableArray, Symbol.species); +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, 'function'); +verifyNotWritable(SendableArray, Symbol.species, Symbol.species); +verifyNotEnumerable(SendableArray, Symbol.species); +verifyConfigurable(SendableArray, Symbol.species); diff --git a/test/sendable/builtins/Array/constructor.js b/test/sendable/builtins/Array/constructor.js new file mode 100644 index 00000000000..87c405c346f --- /dev/null +++ b/test/sendable/builtins/Array/constructor.js @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-constructor-array +description: > + The Array constructor is a built-in function +---*/ + +assert.sameValue(typeof SendableArray, 'function', 'The value of `typeof SendableArray` is expected to be "function"'); diff --git a/test/sendable/builtins/Array/is-a-constructor.js b/test/sendable/builtins/Array/is-a-constructor.js new file mode 100644 index 00000000000..bc7083db37b --- /dev/null +++ b/test/sendable/builtins/Array/is-a-constructor.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Array implements [[Construct]] +info: | + IsConstructor ( argument ) + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ + +assert.sameValue(isConstructor(SendableArray), true, 'isConstructor(SendableArray) must return true'); +new SendableArray(); + diff --git a/test/sendable/builtins/Array/length.js b/test/sendable/builtins/Array/length.js new file mode 100644 index 00000000000..2d8886eba4b --- /dev/null +++ b/test/sendable/builtins/Array/length.js @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-constructor +description: > + Array has a "length" property whose value is 1. +info: | + 22.1.1 The Array Constructor + The length property of the Array constructor function is 1. + ES7 section 17: 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(SendableArray, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/name.js b/test/sendable/builtins/Array/name.js new file mode 100644 index 00000000000..299abc681bd --- /dev/null +++ b/test/sendable/builtins/Array/name.js @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-constructor +description: > + The "name" property of Array +info: | + 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, this value is the name that is given to + the function in this specification. + [...] + 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(SendableArray, "name", { + value: "SendableArray", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Array/prop-desc.js b/test/sendable/builtins/Array/prop-desc.js new file mode 100644 index 00000000000..d4ce336e34a --- /dev/null +++ b/test/sendable/builtins/Array/prop-desc.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-constructor +description: > + Property descriptor of Array +info: | + 22.1.1 The Array Constructor + * is the initial value of the Array property of the global object. + 17 ECMAScript Standard Built-in Objects + 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] +---*/ + +verifyProperty(this, 'SendableArray', { + value: SendableArray, + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Array/property-cast-boolean-primitive.js b/test/sendable/builtins/Array/property-cast-boolean-primitive.js new file mode 100644 index 00000000000..0b8be7b28c5 --- /dev/null +++ b/test/sendable/builtins/Array/property-cast-boolean-primitive.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T1 +description: Checking for boolean primitive +---*/ + +var x = []; +x[true] = 1; +assert.sameValue(x[1], undefined, 'The value of x[1] is expected to equal undefined'); +assert.sameValue(x["true"], 1, 'The value of x["true"] is expected to be 1'); +x[false] = 0; +assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined'); +assert.sameValue(x["false"], 0, 'The value of x["false"] is expected to be 0') diff --git a/test/sendable/builtins/Array/property-cast-nan-infinity.js b/test/sendable/builtins/Array/property-cast-nan-infinity.js new file mode 100644 index 00000000000..b094fedf42f --- /dev/null +++ b/test/sendable/builtins/Array/property-cast-nan-infinity.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T2 +description: Checking for number primitive +---*/ + +var x = []; +x[NaN] = 1; +assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined'); +assert.sameValue(x["NaN"], 1, 'The value of x["NaN"] is expected to be 1'); +var y = []; +y[Number.POSITIVE_INFINITY] = 1; +assert.sameValue(y[0], undefined, 'The value of y[0] is expected to equal undefined'); +assert.sameValue(y["Infinity"], 1, 'The value of y["Infinity"] is expected to be 1'); +var z = []; +z[Number.NEGATIVE_INFINITY] = 1; +assert.sameValue(z[0], undefined, 'The value of z[0] is expected to equal undefined'); +assert.sameValue(z["-Infinity"], 1, 'The value of z["-Infinity"] is expected to be 1'); diff --git a/test/sendable/builtins/Array/property-cast-number.js b/test/sendable/builtins/Array/property-cast-number.js new file mode 100644 index 00000000000..87e50b307d0 --- /dev/null +++ b/test/sendable/builtins/Array/property-cast-number.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +info: | + A property name P (in the form of a string value) is an array index + if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1 +es5id: 15.4_A1.1_T3 +description: Checking for number primitive +---*/ + +var x = []; +x[4294967296] = 1; +assert.sameValue(x[0], undefined, 'The value of x[0] is expected to equal undefined'); +assert.sameValue(x["4294967296"], 1, 'The value of x["4294967296"] is expected to be 1'); +var y = []; +y[4294967297] = 1; +if (y[1] !== undefined) { + throw new Test262Error('#3: y = []; y[4294967297] = 1; y[1] === undefined. Actual: ' + (y[1])); +} +//CHECK#4 +if (y["4294967297"] !== 1) { + throw new Test262Error('#4: y = []; y[4294967297] = 1; y["4294967297"] === 1. Actual: ' + (y["4294967297"])); +} +//CHECK#5 +var z = []; +z[1.1] = 1; +if (z[1] !== undefined) { + throw new Test262Error('#5: z = []; z[1.1] = 1; z[1] === undefined. Actual: ' + (z[1])); +} +//CHECK#6 +if (z["1.1"] !== 1) { + throw new Test262Error('#6: z = []; z[1.1] = 1; z["1.1"] === 1. Actual: ' + (z["1.1"])); +} diff --git a/test/sendable/builtins/Array/proto-from-ctor-realm-one.js b/test/sendable/builtins/Array/proto-from-ctor-realm-one.js new file mode 100644 index 00000000000..701d69f1d8b --- /dev/null +++ b/test/sendable/builtins/Array/proto-from-ctor-realm-one.js @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-len +description: Default [[Prototype]] value derived from realm of the NewTarget. +info: | + Array ( len ) + 3. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget. + 4. Let proto be ? GetPrototypeFromConstructor(newTarget, "%Array.prototype%"). + 5. Let array be ! ArrayCreate(0, proto). + 9. Return array. + GetPrototypeFromConstructor ( constructor, intrinsicDefaultProto ) + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Set proto to realm's intrinsic object named intrinsicDefaultProto. + 5. Return proto. +features: [cross-realm, Reflect, Symbol] +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var arr; +newTarget.prototype = undefined; +arr = Reflect.construct(SendableArray, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, [1], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = null; +arr = Reflect.construct(SendableArray, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, [1], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = true; +arr = Reflect.construct(SendableArray, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, [1], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = ''; +arr = Reflect.construct(SendableArray, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, [1], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = Symbol(); +arr = Reflect.construct(SendableArray, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, [1], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = 0; +arr = Reflect.construct(SendableArray, [1], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, [1], newTarget)) returns other.SendableArray.prototype'); diff --git a/test/sendable/builtins/Array/proto-from-ctor-realm-two.js b/test/sendable/builtins/Array/proto-from-ctor-realm-two.js new file mode 100644 index 00000000000..af504426102 --- /dev/null +++ b/test/sendable/builtins/Array/proto-from-ctor-realm-two.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-items +description: Default [[Prototype]] value derived from realm of the NewTarget. +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var arr; +newTarget.prototype = undefined; +arr = Reflect.construct(SendableArray, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, ["a", "b"], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = null; +arr = Reflect.construct(SendableArray, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, ["a", "b"], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = false; +arr = Reflect.construct(SendableArray, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, ["a", "b"], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = ''; +arr = Reflect.construct(SendableArray, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, ["a", "b"], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = Symbol(); +arr = Reflect.construct(SendableArray, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, ["a", "b"], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = -1; +arr = Reflect.construct(SendableArray, ['a', 'b'], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, ["a", "b"], newTarget)) returns other.SendableArray.prototype'); diff --git a/test/sendable/builtins/Array/proto-from-ctor-realm-zero.js b/test/sendable/builtins/Array/proto-from-ctor-realm-zero.js new file mode 100644 index 00000000000..3a5112fa5ba --- /dev/null +++ b/test/sendable/builtins/Array/proto-from-ctor-realm-zero.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-array-constructor-array +description: Default [[Prototype]] value derived from realm of the NewTarget. +---*/ + +var other = $262.createRealm().global; +var newTarget = new other.Function(); +var arr; +newTarget.prototype = undefined; +arr = Reflect.construct(SendableArray, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, [], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = null; +arr = Reflect.construct(SendableArray, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, [], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = true; +arr = Reflect.construct(SendableArray, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, [], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = 'str'; +arr = Reflect.construct(SendableArray, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, [], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = Symbol(); +arr = Reflect.construct(SendableArray, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, [], newTarget)) returns other.SendableArray.prototype'); +newTarget.prototype = 1; +arr = Reflect.construct(SendableArray, [], newTarget); +assert.sameValue(Object.getPrototypeOf(arr), other.SendableArray.prototype, 'Object.getPrototypeOf(Reflect.construct(SendableArray, [], newTarget)) returns other.SendableArray.prototype'); diff --git a/test/sendable/builtins/Array/proto.js b/test/sendable/builtins/Array/proto.js new file mode 100644 index 00000000000..d87b7f27268 --- /dev/null +++ b/test/sendable/builtins/Array/proto.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +esid: sec-properties-of-the-array-constructor +description: > + The prototype of the Array constructor is the intrinsic object %FunctionPrototype%. +info: | + 22.1.2 Properties of the Array Constructor + The value of the [[Prototype]] internal slot of the Array constructor is the + intrinsic object %FunctionPrototype%. +---*/ + +assert.sameValue( + Object.getPrototypeOf(SendableArray), + Function.prototype, + 'Object.getPrototypeOf(SendableArray) returns Function.prototype' +); -- Gitee From 7fd30a79cae57072fe7f94eb83b97b63dccbe867 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 3 Jan 2025 16:40:16 +0800 Subject: [PATCH 73/93] update Signed-off-by: zhuzhihui7 --- test/sendable/builtins/Array/15.4.5-1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sendable/builtins/Array/15.4.5-1.js b/test/sendable/builtins/Array/15.4.5-1.js index e94ce1186e2..6db446cd41d 100644 --- a/test/sendable/builtins/Array/15.4.5-1.js +++ b/test/sendable/builtins/Array/15.4.5-1.js @@ -19,4 +19,4 @@ description: Array instances have [[Class]] set to 'Array' var a = []; var s = Object.prototype.toString.call(a); -assert.sameValue(s, '[object SendableArray]', 'The value of s is expected to be "[object SendableArray]"'); +assert.sameValue(s, '[object Array]', 'The value of s is expected to be "[object Array]"'); -- Gitee From 45139fd88b5a328e249008081bb7e36278d32a7c Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 6 Jan 2025 09:14:56 +0800 Subject: [PATCH 74/93] map Signed-off-by: zhuzhihui7 --- .../builtins/Map/Symbol.species/length.js | 45 ++ .../Map/Symbol.species/return-value.js | 27 + .../Map/Symbol.species/symbol-species-name.js | 33 ++ .../Map/Symbol.species/symbol-species.js | 33 ++ .../builtins/Map/bigint-number-same-value.js | 57 ++ test/sendable/builtins/Map/constructor.js | 23 + ...does-not-throw-when-set-is-not-callable.js | 42 ++ .../builtins/Map/get-set-method-failure.js | 39 ++ .../builtins/Map/groupBy/callback-arg.js | 44 ++ .../builtins/Map/groupBy/callback-throws.js | 37 ++ .../builtins/Map/groupBy/emptyList.js | 39 ++ test/sendable/builtins/Map/groupBy/evenOdd.js | 34 ++ .../builtins/Map/groupBy/groupLength.js | 33 ++ .../builtins/Map/groupBy/invalid-callback.js | 41 ++ .../builtins/Map/groupBy/invalid-iterable.js | 46 ++ .../Map/groupBy/iterator-next-throws.js | 46 ++ test/sendable/builtins/Map/groupBy/length.js | 37 ++ .../builtins/Map/groupBy/map-instance.js | 38 ++ test/sendable/builtins/Map/groupBy/name.js | 37 ++ .../builtins/Map/groupBy/negativeZero.js | 42 ++ test/sendable/builtins/Map/groupBy/string.js | 34 ++ .../builtins/Map/groupBy/toPropertyKey.js | 41 ++ .../sendable/builtins/Map/is-a-constructor.js | 36 ++ .../builtins/Map/iterable-calls-set.js | 55 ++ .../Map/iterator-close-after-set-failure.js | 54 ++ ...terator-close-failure-after-set-failure.js | 40 ++ .../Map/iterator-is-undefined-throws.js | 32 ++ ...terator-item-first-entry-returns-abrupt.js | 60 +++ ...erator-item-second-entry-returns-abrupt.js | 60 +++ ...tor-items-are-not-object-close-iterator.js | 88 ++++ .../Map/iterator-items-are-not-object.js | 64 +++ .../builtins/Map/iterator-next-failure.js | 41 ++ .../builtins/Map/iterator-value-failure.js | 47 ++ test/sendable/builtins/Map/length.js | 31 ++ .../map-iterable-empty-does-not-call-set.js | 44 ++ ...terable-throws-when-set-is-not-callable.js | 43 ++ test/sendable/builtins/Map/map-iterable.js | 39 ++ .../Map/map-no-iterable-does-not-call-set.js | 48 ++ test/sendable/builtins/Map/map-no-iterable.js | 45 ++ test/sendable/builtins/Map/map.js | 32 ++ test/sendable/builtins/Map/name.js | 32 ++ test/sendable/builtins/Map/newtarget.js | 50 ++ .../Map/properties-of-map-instances.js | 27 + .../properties-of-the-map-prototype-object.js | 31 ++ .../builtins/Map/proto-from-ctor-realm.js | 42 ++ .../sendable/builtins/Map/prototype-of-map.js | 29 + .../builtins/Map/prototype/Symbol.iterator.js | 34 ++ .../Symbol.iterator/not-a-constructor.js | 45 ++ .../Map/prototype/Symbol.toStringTag.js | 36 ++ .../builtins/Map/prototype/clear/clear-map.js | 49 ++ .../builtins/Map/prototype/clear/clear.js | 36 ++ .../clear/context-is-not-map-object.js | 36 ++ .../prototype/clear/context-is-not-object.js | 51 ++ .../clear/context-is-set-object-throws.js | 33 ++ .../clear/context-is-weakmap-object-throws.js | 33 ++ .../builtins/Map/prototype/clear/length.js | 33 ++ .../clear/map-data-list-is-preserved.js | 48 ++ .../builtins/Map/prototype/clear/name.js | 33 ++ .../Map/prototype/clear/not-a-constructor.js | 41 ++ .../Map/prototype/clear/returns-undefined.js | 38 ++ .../builtins/Map/prototype/constructor.js | 31 ++ .../delete/context-is-not-map-object.js | 36 ++ .../prototype/delete/context-is-not-object.js | 51 ++ .../delete/context-is-set-object-throws.js | 33 ++ .../context-is-weakmap-object-throws.js | 33 ++ .../builtins/Map/prototype/delete/delete.js | 36 ++ .../delete/does-not-break-iterators.js | 49 ++ .../builtins/Map/prototype/delete/length.js | 33 ++ .../builtins/Map/prototype/delete/name.js | 33 ++ .../Map/prototype/delete/not-a-constructor.js | 41 ++ .../Map/prototype/delete/returns-false.js | 39 ++ .../delete/returns-true-for-deleted-entry.js | 40 ++ .../builtins/Map/prototype/descriptor.js | 29 + ...does-not-have-mapdata-internal-slot-set.js | 42 ++ ...-not-have-mapdata-internal-slot-weakmap.js | 42 ++ .../does-not-have-mapdata-internal-slot.js | 51 ++ .../builtins/Map/prototype/entries/entries.js | 37 ++ .../builtins/Map/prototype/entries/length.js | 33 ++ .../builtins/Map/prototype/entries/name.js | 33 ++ .../prototype/entries/not-a-constructor.js | 45 ++ .../entries/returns-iterator-empty.js | 40 ++ .../Map/prototype/entries/returns-iterator.js | 68 +++ .../entries/this-not-object-throw.js | 60 +++ .../prototype/forEach/callback-parameters.js | 57 ++ .../forEach/callback-result-is-abrupt.js | 40 ++ .../forEach/callback-this-non-strict.js | 48 ++ .../prototype/forEach/callback-this-strict.js | 48 ++ .../forEach/deleted-values-during-foreach.js | 54 ++ ...does-not-have-mapdata-internal-slot-set.js | 37 ++ ...-not-have-mapdata-internal-slot-weakmap.js | 37 ++ .../does-not-have-mapdata-internal-slot.js | 45 ++ .../forEach/first-argument-is-not-callable.js | 56 ++ .../builtins/Map/prototype/forEach/forEach.js | 37 ++ .../iterates-in-key-insertion-order.js | 64 +++ ...rates-values-added-after-foreach-begins.js | 62 +++ .../iterates-values-deleted-then-readded.js | 63 +++ .../builtins/Map/prototype/forEach/length.js | 33 ++ .../builtins/Map/prototype/forEach/name.js | 33 ++ .../prototype/forEach/not-a-constructor.js | 45 ++ .../Map/prototype/forEach/return-undefined.js | 40 ++ .../second-parameter-as-callback-context.js | 50 ++ .../forEach/this-not-object-throw.js | 56 ++ ...does-not-have-mapdata-internal-slot-set.js | 37 ++ ...-not-have-mapdata-internal-slot-weakmap.js | 37 ++ .../does-not-have-mapdata-internal-slot.js | 45 ++ .../builtins/Map/prototype/get/get.js | 37 ++ .../builtins/Map/prototype/get/length.js | 33 ++ .../builtins/Map/prototype/get/name.js | 33 ++ .../Map/prototype/get/not-a-constructor.js | 41 ++ .../Map/prototype/get/returns-undefined.js | 54 ++ .../get/returns-value-different-key-types.js | 61 +++ .../get/returns-value-normalized-zero-key.js | 38 ++ .../prototype/get/this-not-object-throw.js | 56 ++ ...does-not-have-mapdata-internal-slot-set.js | 37 ++ ...-not-have-mapdata-internal-slot-weakmap.js | 37 ++ .../does-not-have-mapdata-internal-slot.js | 45 ++ .../builtins/Map/prototype/has/has.js | 37 ++ .../builtins/Map/prototype/has/length.js | 33 ++ .../builtins/Map/prototype/has/name.js | 33 ++ .../Map/prototype/has/normalizes-zero-key.js | 43 ++ .../Map/prototype/has/not-a-constructor.js | 41 ++ .../has/return-false-different-key-types.js | 42 ++ .../has/return-true-different-key-types.js | 57 ++ .../prototype/has/this-not-object-throw.js | 56 ++ ...does-not-have-mapdata-internal-slot-set.js | 42 ++ ...-not-have-mapdata-internal-slot-weakmap.js | 42 ++ .../does-not-have-mapdata-internal-slot.js | 51 ++ .../builtins/Map/prototype/keys/keys.js | 37 ++ .../builtins/Map/prototype/keys/length.js | 33 ++ .../builtins/Map/prototype/keys/name.js | 33 ++ .../Map/prototype/keys/not-a-constructor.js | 41 ++ .../prototype/keys/returns-iterator-empty.js | 40 ++ .../Map/prototype/keys/returns-iterator.js | 63 +++ .../prototype/keys/this-not-object-throw.js | 60 +++ .../append-new-values-normalizes-zero-key.js | 38 ++ .../set/append-new-values-return-map.js | 43 ++ .../Map/prototype/set/append-new-values.js | 60 +++ ...does-not-have-mapdata-internal-slot-set.js | 37 ++ ...-not-have-mapdata-internal-slot-weakmap.js | 37 ++ .../does-not-have-mapdata-internal-slot.js | 45 ++ .../builtins/Map/prototype/set/length.js | 33 ++ .../builtins/Map/prototype/set/name.js | 33 ++ .../Map/prototype/set/not-a-constructor.js | 41 ++ .../replaces-a-value-normalizes-zero-key.js | 39 ++ .../set/replaces-a-value-returns-map.js | 43 ++ .../Map/prototype/set/replaces-a-value.js | 36 ++ .../builtins/Map/prototype/set/set.js | 37 ++ .../prototype/set/this-not-object-throw.js | 56 ++ ...does-not-have-mapdata-internal-slot-set.js | 37 ++ ...-not-have-mapdata-internal-slot-weakmap.js | 40 ++ .../does-not-have-mapdata-internal-slot.js | 39 ++ .../builtins/Map/prototype/size/length.js | 34 ++ .../builtins/Map/prototype/size/name.js | 38 ++ ...f-present-values-before-after-set-clear.js | 43 ++ ...-present-values-before-after-set-delete.js | 42 ++ ...ns-count-of-present-values-by-insertion.js | 39 ++ ...rns-count-of-present-values-by-iterable.js | 39 ++ .../builtins/Map/prototype/size/size.js | 42 ++ .../prototype/size/this-not-object-throw.js | 60 +++ ...does-not-have-mapdata-internal-slot-set.js | 42 ++ ...-not-have-mapdata-internal-slot-weakmap.js | 42 ++ .../does-not-have-mapdata-internal-slot.js | 51 ++ .../builtins/Map/prototype/values/length.js | 33 ++ .../builtins/Map/prototype/values/name.js | 33 ++ .../Map/prototype/values/not-a-constructor.js | 41 ++ .../values/returns-iterator-empty.js | 40 ++ .../Map/prototype/values/returns-iterator.js | 63 +++ .../prototype/values/this-not-object-throw.js | 60 +++ .../builtins/Map/prototype/values/values.js | 37 ++ .../builtins/Map/undefined-newtarget.js | 37 ++ test/sendable/builtins/Map/valid-keys.js | 496 ++++++++++++++++++ 171 files changed, 7685 insertions(+) create mode 100644 test/sendable/builtins/Map/Symbol.species/length.js create mode 100644 test/sendable/builtins/Map/Symbol.species/return-value.js create mode 100644 test/sendable/builtins/Map/Symbol.species/symbol-species-name.js create mode 100644 test/sendable/builtins/Map/Symbol.species/symbol-species.js create mode 100644 test/sendable/builtins/Map/bigint-number-same-value.js create mode 100644 test/sendable/builtins/Map/constructor.js create mode 100644 test/sendable/builtins/Map/does-not-throw-when-set-is-not-callable.js create mode 100644 test/sendable/builtins/Map/get-set-method-failure.js create mode 100644 test/sendable/builtins/Map/groupBy/callback-arg.js create mode 100644 test/sendable/builtins/Map/groupBy/callback-throws.js create mode 100644 test/sendable/builtins/Map/groupBy/emptyList.js create mode 100644 test/sendable/builtins/Map/groupBy/evenOdd.js create mode 100644 test/sendable/builtins/Map/groupBy/groupLength.js create mode 100644 test/sendable/builtins/Map/groupBy/invalid-callback.js create mode 100644 test/sendable/builtins/Map/groupBy/invalid-iterable.js create mode 100644 test/sendable/builtins/Map/groupBy/iterator-next-throws.js create mode 100644 test/sendable/builtins/Map/groupBy/length.js create mode 100644 test/sendable/builtins/Map/groupBy/map-instance.js create mode 100644 test/sendable/builtins/Map/groupBy/name.js create mode 100644 test/sendable/builtins/Map/groupBy/negativeZero.js create mode 100644 test/sendable/builtins/Map/groupBy/string.js create mode 100644 test/sendable/builtins/Map/groupBy/toPropertyKey.js create mode 100644 test/sendable/builtins/Map/is-a-constructor.js create mode 100644 test/sendable/builtins/Map/iterable-calls-set.js create mode 100644 test/sendable/builtins/Map/iterator-close-after-set-failure.js create mode 100644 test/sendable/builtins/Map/iterator-close-failure-after-set-failure.js create mode 100644 test/sendable/builtins/Map/iterator-is-undefined-throws.js create mode 100644 test/sendable/builtins/Map/iterator-item-first-entry-returns-abrupt.js create mode 100644 test/sendable/builtins/Map/iterator-item-second-entry-returns-abrupt.js create mode 100644 test/sendable/builtins/Map/iterator-items-are-not-object-close-iterator.js create mode 100644 test/sendable/builtins/Map/iterator-items-are-not-object.js create mode 100644 test/sendable/builtins/Map/iterator-next-failure.js create mode 100644 test/sendable/builtins/Map/iterator-value-failure.js create mode 100644 test/sendable/builtins/Map/length.js create mode 100644 test/sendable/builtins/Map/map-iterable-empty-does-not-call-set.js create mode 100644 test/sendable/builtins/Map/map-iterable-throws-when-set-is-not-callable.js create mode 100644 test/sendable/builtins/Map/map-iterable.js create mode 100644 test/sendable/builtins/Map/map-no-iterable-does-not-call-set.js create mode 100644 test/sendable/builtins/Map/map-no-iterable.js create mode 100644 test/sendable/builtins/Map/map.js create mode 100644 test/sendable/builtins/Map/name.js create mode 100644 test/sendable/builtins/Map/newtarget.js create mode 100644 test/sendable/builtins/Map/properties-of-map-instances.js create mode 100644 test/sendable/builtins/Map/properties-of-the-map-prototype-object.js create mode 100644 test/sendable/builtins/Map/proto-from-ctor-realm.js create mode 100644 test/sendable/builtins/Map/prototype-of-map.js create mode 100644 test/sendable/builtins/Map/prototype/Symbol.iterator.js create mode 100644 test/sendable/builtins/Map/prototype/Symbol.iterator/not-a-constructor.js create mode 100644 test/sendable/builtins/Map/prototype/Symbol.toStringTag.js create mode 100644 test/sendable/builtins/Map/prototype/clear/clear-map.js create mode 100644 test/sendable/builtins/Map/prototype/clear/clear.js create mode 100644 test/sendable/builtins/Map/prototype/clear/context-is-not-map-object.js create mode 100644 test/sendable/builtins/Map/prototype/clear/context-is-not-object.js create mode 100644 test/sendable/builtins/Map/prototype/clear/context-is-set-object-throws.js create mode 100644 test/sendable/builtins/Map/prototype/clear/context-is-weakmap-object-throws.js create mode 100644 test/sendable/builtins/Map/prototype/clear/length.js create mode 100644 test/sendable/builtins/Map/prototype/clear/map-data-list-is-preserved.js create mode 100644 test/sendable/builtins/Map/prototype/clear/name.js create mode 100644 test/sendable/builtins/Map/prototype/clear/not-a-constructor.js create mode 100644 test/sendable/builtins/Map/prototype/clear/returns-undefined.js create mode 100644 test/sendable/builtins/Map/prototype/constructor.js create mode 100644 test/sendable/builtins/Map/prototype/delete/context-is-not-map-object.js create mode 100644 test/sendable/builtins/Map/prototype/delete/context-is-not-object.js create mode 100644 test/sendable/builtins/Map/prototype/delete/context-is-set-object-throws.js create mode 100644 test/sendable/builtins/Map/prototype/delete/context-is-weakmap-object-throws.js create mode 100644 test/sendable/builtins/Map/prototype/delete/delete.js create mode 100644 test/sendable/builtins/Map/prototype/delete/does-not-break-iterators.js create mode 100644 test/sendable/builtins/Map/prototype/delete/length.js create mode 100644 test/sendable/builtins/Map/prototype/delete/name.js create mode 100644 test/sendable/builtins/Map/prototype/delete/not-a-constructor.js create mode 100644 test/sendable/builtins/Map/prototype/delete/returns-false.js create mode 100644 test/sendable/builtins/Map/prototype/delete/returns-true-for-deleted-entry.js create mode 100644 test/sendable/builtins/Map/prototype/descriptor.js create mode 100644 test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot-set.js create mode 100644 test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot-weakmap.js create mode 100644 test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot.js create mode 100644 test/sendable/builtins/Map/prototype/entries/entries.js create mode 100644 test/sendable/builtins/Map/prototype/entries/length.js create mode 100644 test/sendable/builtins/Map/prototype/entries/name.js create mode 100644 test/sendable/builtins/Map/prototype/entries/not-a-constructor.js create mode 100644 test/sendable/builtins/Map/prototype/entries/returns-iterator-empty.js create mode 100644 test/sendable/builtins/Map/prototype/entries/returns-iterator.js create mode 100644 test/sendable/builtins/Map/prototype/entries/this-not-object-throw.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/callback-parameters.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/callback-result-is-abrupt.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/callback-this-non-strict.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/callback-this-strict.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/deleted-values-during-foreach.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-set.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-weakmap.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/first-argument-is-not-callable.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/forEach.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/iterates-in-key-insertion-order.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/iterates-values-added-after-foreach-begins.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/iterates-values-deleted-then-readded.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/length.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/name.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/not-a-constructor.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/return-undefined.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/second-parameter-as-callback-context.js create mode 100644 test/sendable/builtins/Map/prototype/forEach/this-not-object-throw.js create mode 100644 test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot-set.js create mode 100644 test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot-weakmap.js create mode 100644 test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot.js create mode 100644 test/sendable/builtins/Map/prototype/get/get.js create mode 100644 test/sendable/builtins/Map/prototype/get/length.js create mode 100644 test/sendable/builtins/Map/prototype/get/name.js create mode 100644 test/sendable/builtins/Map/prototype/get/not-a-constructor.js create mode 100644 test/sendable/builtins/Map/prototype/get/returns-undefined.js create mode 100644 test/sendable/builtins/Map/prototype/get/returns-value-different-key-types.js create mode 100644 test/sendable/builtins/Map/prototype/get/returns-value-normalized-zero-key.js create mode 100644 test/sendable/builtins/Map/prototype/get/this-not-object-throw.js create mode 100644 test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot-set.js create mode 100644 test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot-weakmap.js create mode 100644 test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot.js create mode 100644 test/sendable/builtins/Map/prototype/has/has.js create mode 100644 test/sendable/builtins/Map/prototype/has/length.js create mode 100644 test/sendable/builtins/Map/prototype/has/name.js create mode 100644 test/sendable/builtins/Map/prototype/has/normalizes-zero-key.js create mode 100644 test/sendable/builtins/Map/prototype/has/not-a-constructor.js create mode 100644 test/sendable/builtins/Map/prototype/has/return-false-different-key-types.js create mode 100644 test/sendable/builtins/Map/prototype/has/return-true-different-key-types.js create mode 100644 test/sendable/builtins/Map/prototype/has/this-not-object-throw.js create mode 100644 test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot-set.js create mode 100644 test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot-weakmap.js create mode 100644 test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot.js create mode 100644 test/sendable/builtins/Map/prototype/keys/keys.js create mode 100644 test/sendable/builtins/Map/prototype/keys/length.js create mode 100644 test/sendable/builtins/Map/prototype/keys/name.js create mode 100644 test/sendable/builtins/Map/prototype/keys/not-a-constructor.js create mode 100644 test/sendable/builtins/Map/prototype/keys/returns-iterator-empty.js create mode 100644 test/sendable/builtins/Map/prototype/keys/returns-iterator.js create mode 100644 test/sendable/builtins/Map/prototype/keys/this-not-object-throw.js create mode 100644 test/sendable/builtins/Map/prototype/set/append-new-values-normalizes-zero-key.js create mode 100644 test/sendable/builtins/Map/prototype/set/append-new-values-return-map.js create mode 100644 test/sendable/builtins/Map/prototype/set/append-new-values.js create mode 100644 test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot-set.js create mode 100644 test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot-weakmap.js create mode 100644 test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot.js create mode 100644 test/sendable/builtins/Map/prototype/set/length.js create mode 100644 test/sendable/builtins/Map/prototype/set/name.js create mode 100644 test/sendable/builtins/Map/prototype/set/not-a-constructor.js create mode 100644 test/sendable/builtins/Map/prototype/set/replaces-a-value-normalizes-zero-key.js create mode 100644 test/sendable/builtins/Map/prototype/set/replaces-a-value-returns-map.js create mode 100644 test/sendable/builtins/Map/prototype/set/replaces-a-value.js create mode 100644 test/sendable/builtins/Map/prototype/set/set.js create mode 100644 test/sendable/builtins/Map/prototype/set/this-not-object-throw.js create mode 100644 test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot-set.js create mode 100644 test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot-weakmap.js create mode 100644 test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot.js create mode 100644 test/sendable/builtins/Map/prototype/size/length.js create mode 100644 test/sendable/builtins/Map/prototype/size/name.js create mode 100644 test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-before-after-set-clear.js create mode 100644 test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-before-after-set-delete.js create mode 100644 test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-by-insertion.js create mode 100644 test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-by-iterable.js create mode 100644 test/sendable/builtins/Map/prototype/size/size.js create mode 100644 test/sendable/builtins/Map/prototype/size/this-not-object-throw.js create mode 100644 test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot-set.js create mode 100644 test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot-weakmap.js create mode 100644 test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot.js create mode 100644 test/sendable/builtins/Map/prototype/values/length.js create mode 100644 test/sendable/builtins/Map/prototype/values/name.js create mode 100644 test/sendable/builtins/Map/prototype/values/not-a-constructor.js create mode 100644 test/sendable/builtins/Map/prototype/values/returns-iterator-empty.js create mode 100644 test/sendable/builtins/Map/prototype/values/returns-iterator.js create mode 100644 test/sendable/builtins/Map/prototype/values/this-not-object-throw.js create mode 100644 test/sendable/builtins/Map/prototype/values/values.js create mode 100644 test/sendable/builtins/Map/undefined-newtarget.js create mode 100644 test/sendable/builtins/Map/valid-keys.js diff --git a/test/sendable/builtins/Map/Symbol.species/length.js b/test/sendable/builtins/Map/Symbol.species/length.js new file mode 100644 index 00000000000..68dc626bcc4 --- /dev/null +++ b/test/sendable/builtins/Map/Symbol.species/length.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 23.1.2.2 +description: > + get SendableMap [ @@species ].length is 0. +info: | + get SendableMap [ @@species ] + + 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] +features: [Symbol.species] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableMap, Symbol.species); + +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/Symbol.species/return-value.js b/test/sendable/builtins/Map/Symbol.species/return-value.js new file mode 100644 index 00000000000..49808024813 --- /dev/null +++ b/test/sendable/builtins/Map/Symbol.species/return-value.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-map-@@species +description: Return value of @@species accessor method +info: | + 1. Return the this value. +features: [Symbol.species] +---*/ + +var thisVal = {}; +var accessor = Object.getOwnPropertyDescriptor(SendableMap, Symbol.species).get; + +assert.sameValue(accessor.call(thisVal), thisVal); diff --git a/test/sendable/builtins/Map/Symbol.species/symbol-species-name.js b/test/sendable/builtins/Map/Symbol.species/symbol-species-name.js new file mode 100644 index 00000000000..2e89fb38c02 --- /dev/null +++ b/test/sendable/builtins/Map/Symbol.species/symbol-species-name.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 23.1.2.2 +description: > + SendableMap[Symbol.species] accessor property get name +info: | + 23.1.2.2 get SendableMap [ @@species ] + + ... + The value of the name property of this function is "get [Symbol.species]". +features: [Symbol.species] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(SendableMap, Symbol.species); + +assert.sameValue( + descriptor.get.name, + 'get [Symbol.species]' +); diff --git a/test/sendable/builtins/Map/Symbol.species/symbol-species.js b/test/sendable/builtins/Map/Symbol.species/symbol-species.js new file mode 100644 index 00000000000..5ad1e3ede61 --- /dev/null +++ b/test/sendable/builtins/Map/Symbol.species/symbol-species.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +info: | + SendableMap has a property at `Symbol.species` +esid: sec-get-map-@@species +author: Sam Mikes +description: SendableMap[Symbol.species] exists per spec +includes: [propertyHelper.js] +features: [Symbol.species] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableMap, Symbol.species); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, 'function'); + +verifyNotWritable(SendableMap, Symbol.species, Symbol.species); +verifyNotEnumerable(SendableMap, Symbol.species); +verifyConfigurable(SendableMap, Symbol.species); diff --git a/test/sendable/builtins/Map/bigint-number-same-value.js b/test/sendable/builtins/Map/bigint-number-same-value.js new file mode 100644 index 00000000000..c41941f488a --- /dev/null +++ b/test/sendable/builtins/Map/bigint-number-same-value.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: > + Observing the expected behavior of keys when a BigInt and Number have + the same value. +info: | + SendableMap.prototype.set ( key , value ) + + ... + Let p be the Record {[[key]]: key, [[value]]: value}. + Append p as the last element of entries. + ... + +features: [BigInt] +---*/ + +const number = 9007199254740991; +const bigint = 9007199254740991n; + +const m = new SendableMap([ + [number, number], + [bigint, bigint], +]); + +assert.sameValue(m.size, 2); +assert.sameValue(m.has(number), true); +assert.sameValue(m.has(bigint), true); + +assert.sameValue(m.get(number), number); +assert.sameValue(m.get(bigint), bigint); + +m.delete(number); +assert.sameValue(m.size, 1); +assert.sameValue(m.has(number), false); +m.delete(bigint); +assert.sameValue(m.size, 0); +assert.sameValue(m.has(bigint), false); + +m.set(number, number); +assert.sameValue(m.size, 1); +m.set(bigint, bigint); +assert.sameValue(m.size, 2); diff --git a/test/sendable/builtins/Map/constructor.js b/test/sendable/builtins/Map/constructor.js new file mode 100644 index 00000000000..1dc794f3cbe --- /dev/null +++ b/test/sendable/builtins/Map/constructor.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-constructor +description: > + The SendableMap constructor is the %SendableMap% intrinsic object and the initial value of the + SendableMap property of the global object. +---*/ + +assert.sameValue(typeof SendableMap, 'function', 'typeof SendableMap is "function"'); diff --git a/test/sendable/builtins/Map/does-not-throw-when-set-is-not-callable.js b/test/sendable/builtins/Map/does-not-throw-when-set-is-not-callable.js new file mode 100644 index 00000000000..9108a75f9fe --- /dev/null +++ b/test/sendable/builtins/Map/does-not-throw-when-set-is-not-callable.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + Creating a new SendableMap object without arguments doesn't throw if `set` is not + callable +info: | + SendableMap ( [ iterable ] ) + + When the Set function is called with optional argument iterable the following steps are taken: + + ... + 5. If iterable is not present, let iterable be undefined. + 6. If iterable is either undefined or null, let iter be undefined. + 7. Else, + a. Let adder be Get(map, "set"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + ... + 8. If iter is undefined, return map. + ... +---*/ + +SendableMap.prototype.set = null; + +var m = new SendableMap(); + +assert.sameValue(m.size, 0, 'The value of `m.size` is `0`'); diff --git a/test/sendable/builtins/Map/get-set-method-failure.js b/test/sendable/builtins/Map/get-set-method-failure.js new file mode 100644 index 00000000000..e1ff5194035 --- /dev/null +++ b/test/sendable/builtins/Map/get-set-method-failure.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + new SendableMap returns abrupt from getting SendableMap.prototype.set. +info: | + SendableMap ( [ iterable ] ) + + ... + 7. Else, + a. Let adder be Get(map, "add"). + b. ReturnIfAbrupt(adder). +---*/ + +Object.defineProperty(SendableMap.prototype, 'set', { + get: function() { + throw new Test262Error(); + } +}); + +new SendableMap(); + +assert.throws(Test262Error, function() { + new SendableMap([]); +}); diff --git a/test/sendable/builtins/Map/groupBy/callback-arg.js b/test/sendable/builtins/Map/groupBy/callback-arg.js new file mode 100644 index 00000000000..b9a6e278fdd --- /dev/null +++ b/test/sendable/builtins/Map/groupBy/callback-arg.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.groupby +description: SendableMap.groupBy calls function with correct arguments +info: | + SendableMap.groupBy ( items, callbackfn ) + + ... + GroupBy ( items, callbackfn, coercion ) + + 6. Repeat, + + e. Let key be Completion(Call(callbackfn, undefined, « value, 𝔽(k) »)). + ... +features: [array-grouping, SendableMap] +---*/ + + +const arr = [-0, 0, 1, 2, 3]; + +let calls = 0; + +SendableMap.groupBy(arr, function (n, i) { + calls++; + assert.sameValue(n, arr[i], "selected element aligns with index"); + assert.sameValue(arguments.length, 2, "only two arguments are passed"); + return null; +}); + +assert.sameValue(calls, 5, 'called for all 5 elements'); diff --git a/test/sendable/builtins/Map/groupBy/callback-throws.js b/test/sendable/builtins/Map/groupBy/callback-throws.js new file mode 100644 index 00000000000..35ce70f9bd7 --- /dev/null +++ b/test/sendable/builtins/Map/groupBy/callback-throws.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.groupby +description: SendableMap.groupBy throws when callback throws +info: | + SendableMap.groupBy ( items, callbackfn ) + + ... + GroupBy ( items, callbackfn, coercion ) + + 6. Repeat, + e. Let key be Completion(Call(callbackfn, undefined, « value, 𝔽(k) »)). + f. IfAbruptCloseIterator(key, iteratorRecord). + ... +features: [array-grouping, SendableMap] +---*/ + +assert.throws(Test262Error, function() { + const array = [1]; + SendableMap.groupBy(array, function() { + throw new Test262Error('throw in callback'); + }) +}); diff --git a/test/sendable/builtins/Map/groupBy/emptyList.js b/test/sendable/builtins/Map/groupBy/emptyList.js new file mode 100644 index 00000000000..68467968479 --- /dev/null +++ b/test/sendable/builtins/Map/groupBy/emptyList.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.groupby +description: Callback is not called and object is not populated if the iterable is empty +info: | + SendableMap.groupBy ( items, callbackfn ) + + ... + GroupBy ( items, callbackfn, coercion ) + + 6. Repeat, + c. If next is false, then + i. Return groups. + ... +features: [array-grouping, SendableMap] +---*/ + +const original = []; + +const map = SendableMap.groupBy(original, function () { + throw new Test262Error('callback function should not be called') +}); + +assert.notSameValue(original, map, 'SendableMap.groupBy returns a map'); +assert.sameValue(map.size, 0); diff --git a/test/sendable/builtins/Map/groupBy/evenOdd.js b/test/sendable/builtins/Map/groupBy/evenOdd.js new file mode 100644 index 00000000000..fc401da71f6 --- /dev/null +++ b/test/sendable/builtins/Map/groupBy/evenOdd.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.groupby +description: SendableMap.groupBy populates SendableMap with correct keys and values +info: | + SendableMap.groupBy ( items, callbackfn ) + ... +includes: [compareArray.js] +features: [array-grouping, SendableMap] +---*/ + +const array = [1, 2, 3]; + +const map = SendableMap.groupBy(array, function (i) { + return i % 2 === 0 ? 'even' : 'odd'; +}); + +assert.compareArray(Array.from(map.keys()), ['odd', 'even']); +assert.compareArray(map.get('even'), [2]); +assert.compareArray(map.get('odd'), [1, 3]); diff --git a/test/sendable/builtins/Map/groupBy/groupLength.js b/test/sendable/builtins/Map/groupBy/groupLength.js new file mode 100644 index 00000000000..bddd6bdb36f --- /dev/null +++ b/test/sendable/builtins/Map/groupBy/groupLength.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.groupby +description: SendableMap.groupBy populates SendableMap with correct keys and values +info: | + SendableMap.groupBy ( items, callbackfn ) + + ... +includes: [compareArray.js] +features: [array-grouping, SendableMap, Symbol.iterator] +---*/ + +const arr = ['hello', 'test', 'world']; + +const map = SendableMap.groupBy(arr, function (i) { return i.length; }); + +assert.compareArray(Array.from(map.keys()), [5, 4]); +assert.compareArray(map.get(5), ['hello', 'world']); +assert.compareArray(map.get(4), ['test']); diff --git a/test/sendable/builtins/Map/groupBy/invalid-callback.js b/test/sendable/builtins/Map/groupBy/invalid-callback.js new file mode 100644 index 00000000000..9692451b82a --- /dev/null +++ b/test/sendable/builtins/Map/groupBy/invalid-callback.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.groupby +description: SendableMap.groupBy called with non-callable throws TypeError +info: | + SendableMap.groupBy ( items, callbackfn ) + + ... + GroupBy ( items, callbackfn, coercion ) + + 2. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... +features: [array-grouping, SendableMap] +---*/ + + +assert.throws(TypeError, function() { + SendableMap.groupBy([], null) +}, "null callback throws TypeError"); + +assert.throws(TypeError, function() { + SendableMap.groupBy([], undefined) +}, "undefined callback throws TypeError"); + +assert.throws(TypeError, function() { + SendableMap.groupBy([], {}) +}, "object callback throws TypeError"); diff --git a/test/sendable/builtins/Map/groupBy/invalid-iterable.js b/test/sendable/builtins/Map/groupBy/invalid-iterable.js new file mode 100644 index 00000000000..372210311eb --- /dev/null +++ b/test/sendable/builtins/Map/groupBy/invalid-iterable.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.groupby +description: SendableMap.groupBy with a nullish Symbol.iterator throws +info: | + SendableMap.groupBy ( items, callbackfn ) + + ... + GroupBy ( items, callbackfn, coercion ) + + 4. Let iteratorRecord be ? GetIterator(items). + + ... +features: [array-grouping, SendableMap] +---*/ + +const throws = function () { + throw new Test262Error('callback function should not be called') +}; + +function makeIterable(obj, iteratorFn) { + obj[Symbol.iterator] = iteratorFn; + return obj; +} + +assert.throws(TypeError, function () { + SendableMap.groupBy(makeIterable({}, undefined), throws); +}, 'undefined Symbol.iterator'); + +assert.throws(TypeError, function () { + SendableMap.groupBy(makeIterable({}, null), throws); +}, 'null Symbol.iterator'); diff --git a/test/sendable/builtins/Map/groupBy/iterator-next-throws.js b/test/sendable/builtins/Map/groupBy/iterator-next-throws.js new file mode 100644 index 00000000000..b7db3353c46 --- /dev/null +++ b/test/sendable/builtins/Map/groupBy/iterator-next-throws.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.groupby +description: SendableMap.groupBy throws when iterator next throws +info: | + SendableMap.groupBy ( items, callbackfn ) + + ... + + GroupBy ( items, callbackfn, coercion ) + + 6. Repeat, + b. Let next be ? IteratorStep(iteratorRecord). + + ... +features: [array-grouping, SendableMap, Symbol.iterator] +---*/ + +const throwingIterator = { + [Symbol.iterator]: function () { + return this; + }, + next: function next() { + throw new Test262Error('next() method was called'); + } +}; + +assert.throws(Test262Error, function () { + SendableMap.groupBy(throwingIterator, function () { + return 'key'; + }); +}); diff --git a/test/sendable/builtins/Map/groupBy/length.js b/test/sendable/builtins/Map/groupBy/length.js new file mode 100644 index 00000000000..7e05824187a --- /dev/null +++ b/test/sendable/builtins/Map/groupBy/length.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.groupby +description: SendableMap.groupBy property length descriptor +info: | + SendableMap.groupBy ( items, callbackfn ) + + ... + + 17 ECMAScript Standard Built-in Objects + + ... + +includes: [propertyHelper.js] +features: [array-grouping, SendableMap] +---*/ + +verifyProperty(SendableMap.groupBy, "length", { + value: 2, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/groupBy/map-instance.js b/test/sendable/builtins/Map/groupBy/map-instance.js new file mode 100644 index 00000000000..55f11f0ab4b --- /dev/null +++ b/test/sendable/builtins/Map/groupBy/map-instance.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.groupby +description: SendableMap.groupBy returns a SendableMap instance +info: | + SendableMap.groupBy ( items, callbackfn ) + + ... + + 2. Let map be ! Construct(%SendableMap%). + ... + 4. Return map. + + ... +features: [array-grouping, SendableMap] +---*/ + +const array = [1, 2, 3]; + +const map = SendableMap.groupBy(array, function (i) { + return i % 2 === 0 ? 'even' : 'odd'; +}); + +assert.sameValue(map instanceof SendableMap, true); diff --git a/test/sendable/builtins/Map/groupBy/name.js b/test/sendable/builtins/Map/groupBy/name.js new file mode 100644 index 00000000000..bea007056ff --- /dev/null +++ b/test/sendable/builtins/Map/groupBy/name.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.groupby +description: SendableMap.groupBy property name descriptor +info: | + SendableMap.groupBy ( items, callbackfn ) + + ... + + 17 ECMAScript Standard Built-in Objects + + ... + +includes: [propertyHelper.js] +features: [array-grouping, SendableMap] +---*/ + +verifyProperty(SendableMap.groupBy, "name", { + value: "groupBy", + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/groupBy/negativeZero.js b/test/sendable/builtins/Map/groupBy/negativeZero.js new file mode 100644 index 00000000000..1a4ae2550b8 --- /dev/null +++ b/test/sendable/builtins/Map/groupBy/negativeZero.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.groupby +description: SendableMap.groupBy normalizes 0 for SendableMap key +info: | + SendableMap.groupBy ( items, callbackfn ) + + ... + + GroupBy ( items, callbackfn, coercion ) + + 6. Repeat, + h. Else, + i. Assert: coercion is zero. + ii. If key is -0𝔽, set key to +0𝔽. + + ... +includes: [compareArray.js] +features: [array-grouping, SendableMap] +---*/ + + +const arr = [-0, +0]; + +const map = SendableMap.groupBy(arr, function (i) { return i; }); + +assert.sameValue(map.size, 1); +assert.compareArray(map.get(0), [-0, 0]); diff --git a/test/sendable/builtins/Map/groupBy/string.js b/test/sendable/builtins/Map/groupBy/string.js new file mode 100644 index 00000000000..c2f47a723fa --- /dev/null +++ b/test/sendable/builtins/Map/groupBy/string.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.groupby +description: SendableMap.groupBy works for string items +info: | + SendableMap.groupBy ( items, callbackfn ) + ... +includes: [compareArray.js] +features: [array-grouping, SendableMap] +---*/ + +const string = '🥰💩🙏😈'; + +const map = SendableMap.groupBy(string, function (char) { + return char < '🙏' ? 'before' : 'after'; +}); + +assert.compareArray(Array.from(map.keys()), ['after', 'before']); +assert.compareArray(map.get('before'), ['💩', '😈']); +assert.compareArray(map.get('after'), ['🥰', '🙏']); diff --git a/test/sendable/builtins/Map/groupBy/toPropertyKey.js b/test/sendable/builtins/Map/groupBy/toPropertyKey.js new file mode 100644 index 00000000000..02a71bbd666 --- /dev/null +++ b/test/sendable/builtins/Map/groupBy/toPropertyKey.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.groupby +description: SendableMap.groupBy does not coerce return value with ToPropertyKey +info: | + SendableMap.groupBy ( items, callbackfn ) + + ... +includes: [compareArray.js] +features: [array-grouping, SendableMap] +---*/ + +let calls = 0; +const stringable = { + toString: function toString() { + return 1; + } +}; + +const array = [1, '1', stringable]; + +const map = SendableMap.groupBy(array, function (v) { return v; }); + +assert.compareArray(Array.from(map.keys()), [1, '1', stringable]); +assert.compareArray(map.get('1'), ['1']); +assert.compareArray(map.get(1), [1]); +assert.compareArray(map.get(stringable), [stringable]); diff --git a/test/sendable/builtins/Map/is-a-constructor.js b/test/sendable/builtins/Map/is-a-constructor.js new file mode 100644 index 00000000000..afdcf9cb382 --- /dev/null +++ b/test/sendable/builtins/Map/is-a-constructor.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + The SendableMap constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct, SendableMap] +---*/ + +assert.sameValue(isConstructor(SendableMap), true, 'isConstructor(SendableMap) must return true'); +new SendableMap(); + diff --git a/test/sendable/builtins/Map/iterable-calls-set.js b/test/sendable/builtins/Map/iterable-calls-set.js new file mode 100644 index 00000000000..10b1b49b954 --- /dev/null +++ b/test/sendable/builtins/Map/iterable-calls-set.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + new SendableMap calls `set` for each item on the iterable argument in order. +info: | + SendableMap ( [ iterable ] ) + + ... + 9. Repeat + ... + k. Let status be Call(adder, map, «k.[[value]], v.[[value]]»). + ... +includes: [compareArray.js] +---*/ + +var mapSet = SendableMap.prototype.set; +var counter = 0; + +var iterable = [ + ["foo", 1], + ["bar", 2] +]; +var results = []; +var _this = []; + +SendableMap.prototype.set = function(k, v) { + counter++; + results.push([k, v]); + _this.push(this); + mapSet.call(this, k, v); +}; + +var map = new SendableMap(iterable); + +assert.sameValue(counter, 2, "`SendableMap.prototype.set` called twice."); + +assert.compareArray(results[0], iterable[0]); +assert.compareArray(results[1], iterable[1]); +assert.sameValue(_this[0], map); +assert.sameValue(_this[1], map); diff --git a/test/sendable/builtins/Map/iterator-close-after-set-failure.js b/test/sendable/builtins/Map/iterator-close-after-set-failure.js new file mode 100644 index 00000000000..155e2eeaf2b --- /dev/null +++ b/test/sendable/builtins/Map/iterator-close-after-set-failure.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + The iterator is closed when `SendableMap.prototype.set` throws an error. +info: | + SendableMap ( [ iterable ] ) + + ... + 9. Repeat + ... + k. Let status be Call(adder, map, «k.[[value]], v.[[value]]»). + l. If status is an abrupt completion, return IteratorClose(iter, status). +features: [Symbol.iterator] +---*/ + +var count = 0; +var iterable = {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + return { + value: [], + done: false + }; + }, + return: function() { + count += 1; + } + }; +}; +SendableMap.prototype.set = function() { + throw new Test262Error(); +} + +assert.throws(Test262Error, function() { + new SendableMap(iterable); +}); + +assert.sameValue(count, 1); diff --git a/test/sendable/builtins/Map/iterator-close-failure-after-set-failure.js b/test/sendable/builtins/Map/iterator-close-failure-after-set-failure.js new file mode 100644 index 00000000000..4609a1e6ce8 --- /dev/null +++ b/test/sendable/builtins/Map/iterator-close-failure-after-set-failure.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + The correct error is thrown `SendableMap.prototype.set` throws an error and + the IteratorClose throws an error. +features: [Symbol.iterator] +---*/ + +var count = 0; +var iterable = {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + return { value: [], done: false }; + }, + return: function() { + throw new TypeError('ignore'); + } + }; +}; +SendableMap.prototype.set = function() { throw new Test262Error(); } + +assert.throws(Test262Error, function() { + new SendableMap(iterable); +}); diff --git a/test/sendable/builtins/Map/iterator-is-undefined-throws.js b/test/sendable/builtins/Map/iterator-is-undefined-throws.js new file mode 100644 index 00000000000..cb84ef17a7e --- /dev/null +++ b/test/sendable/builtins/Map/iterator-is-undefined-throws.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-objects +description: > + Throws a TypeError if the iterator of the iterable is undefined. +info: | + SendableMap ( [ iterable ] ) + ... + 9. Let iteratorRecord be ? GetIterator(iterable). +features: [Symbol.iterator] +---*/ + +var iterable = { [Symbol.iterator]: undefined }; + +assert.throws(TypeError, + function () { + new SendableMap(iterable); +}); diff --git a/test/sendable/builtins/Map/iterator-item-first-entry-returns-abrupt.js b/test/sendable/builtins/Map/iterator-item-first-entry-returns-abrupt.js new file mode 100644 index 00000000000..9ad73c9e361 --- /dev/null +++ b/test/sendable/builtins/Map/iterator-item-first-entry-returns-abrupt.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + Closes iterator if item first entry completes abruptly. +info: | + SendableMap ( [ iterable ] ) + + ... + 9. Repeat + ... + d. Let nextItem be IteratorValue(next). + ... + g. Let k be Get(nextItem, "0"). + h. If k is an abrupt completion, return IteratorClose(iter, k). + ... +features: [Symbol.iterator] +---*/ + +var count = 0; +var item = ['foo', 'bar']; +Object.defineProperty(item, 0, { + get: function() { + throw new Test262Error(); + } +}); +var iterable = {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + return { + value: item, + done: false + }; + }, + return: function() { + count++; + } + }; +}; + +assert.throws(Test262Error, function() { + new SendableMap(iterable); +}); + +assert.sameValue(count, 1, 'The get error closed the iterator'); diff --git a/test/sendable/builtins/Map/iterator-item-second-entry-returns-abrupt.js b/test/sendable/builtins/Map/iterator-item-second-entry-returns-abrupt.js new file mode 100644 index 00000000000..a9404d0f83f --- /dev/null +++ b/test/sendable/builtins/Map/iterator-item-second-entry-returns-abrupt.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + Closes iterator if item second entry completes abruptly. +info: | + SendableMap ( [ iterable ] ) + + ... + 9. Repeat + ... + d. Let nextItem be IteratorValue(next). + ... + i. Let v be Get(nextItem, "1"). + j. If v is an abrupt completion, return IteratorClose(iter, v). + ... +features: [Symbol.iterator] +---*/ + +var count = 0; +var item = ['foo', 'bar']; +Object.defineProperty(item, 1, { + get: function() { + throw new Test262Error(); + } +}); +var iterable = {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + return { + value: item, + done: false + }; + }, + return: function() { + count++; + } + }; +}; + +assert.throws(Test262Error, function() { + new SendableMap(iterable); +}); + +assert.sameValue(count, 1, 'The get error closed the iterator'); diff --git a/test/sendable/builtins/Map/iterator-items-are-not-object-close-iterator.js b/test/sendable/builtins/Map/iterator-items-are-not-object-close-iterator.js new file mode 100644 index 00000000000..bf38c77c3ab --- /dev/null +++ b/test/sendable/builtins/Map/iterator-items-are-not-object-close-iterator.js @@ -0,0 +1,88 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + Closes the iterator after `not Object` error. +info: | + SendableMap ( [ iterable ] ) + + ... + 9. Repeat + ... + d. Let nextItem be IteratorValue(next). + e. ReturnIfAbrupt(nextItem). + f. If Type(nextItem) is not Object, + i. Let error be Completion{[[type]]: throw, [[value]]: a newly created + TypeError object, [[target]]:empty}. + ii. Return IteratorClose(iter, error). +features: + - Symbol + - Symbol.iterator +---*/ + +var count = 0; +var nextItem; +var iterable = {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + return { + value: nextItem, + done: false + }; + }, + return: function() { + count += 1; + } + }; +}; + +nextItem = 1; +assert.throws(TypeError, function() { + new SendableMap(iterable); +}); +assert.sameValue(count, 1); + +nextItem = true; +assert.throws(TypeError, function() { + new SendableMap(iterable); +}); +assert.sameValue(count, 2); + +nextItem = ''; +assert.throws(TypeError, function() { + new SendableMap(iterable); +}); +assert.sameValue(count, 3); + +nextItem = null; +assert.throws(TypeError, function() { + new SendableMap(iterable); +}); +assert.sameValue(count, 4); + +nextItem = undefined; +assert.throws(TypeError, function() { + new SendableMap(iterable); +}); +assert.sameValue(count, 5); + +nextItem = Symbol('a'); +assert.throws(TypeError, function() { + new SendableMap(iterable); +}); +assert.sameValue(count, 6); diff --git a/test/sendable/builtins/Map/iterator-items-are-not-object.js b/test/sendable/builtins/Map/iterator-items-are-not-object.js new file mode 100644 index 00000000000..78ca4246575 --- /dev/null +++ b/test/sendable/builtins/Map/iterator-items-are-not-object.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + Throws a TypeError if iterable items are not Objects. +info: | + SendableMap ( [ iterable ] ) + + ... + 9. Repeat + ... + d. Let nextItem be IteratorValue(next). + e. ReturnIfAbrupt(nextItem). + f. If Type(nextItem) is not Object, + i. Let error be Completion{[[type]]: throw, [[value]]: a newly created + TypeError object, [[target]]:empty}. + ii. Return IteratorClose(iter, error). +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + new SendableMap([1]); +}); + +assert.throws(TypeError, function() { + new SendableMap(['']); +}); + +assert.throws(TypeError, function() { + new SendableMap([true]); +}); + +assert.throws(TypeError, function() { + new SendableMap([null]); +}); + +assert.throws(TypeError, function() { + new SendableMap([Symbol('a')]); +}); + +assert.throws(TypeError, function() { + new SendableMap([undefined]); +}); + +assert.throws(TypeError, function() { + new SendableMap([ + ['a', 1], + 2 + ]); +}); diff --git a/test/sendable/builtins/Map/iterator-next-failure.js b/test/sendable/builtins/Map/iterator-next-failure.js new file mode 100644 index 00000000000..6fc7e6cdecd --- /dev/null +++ b/test/sendable/builtins/Map/iterator-next-failure.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + The iterator is closed when iterable `next` throws an error. +info: | + SendableMap ( [ iterable ] ) + + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). +features: [Symbol.iterator] +---*/ + +var iterable = {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + throw new Test262Error(); + } + }; +}; + +assert.throws(Test262Error, function() { + new SendableMap(iterable); +}); diff --git a/test/sendable/builtins/Map/iterator-value-failure.js b/test/sendable/builtins/Map/iterator-value-failure.js new file mode 100644 index 00000000000..09a7e3be00b --- /dev/null +++ b/test/sendable/builtins/Map/iterator-value-failure.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + The iterator is closed when iterable `next` value throws an error. +info: | + SendableMap ( [ iterable ] ) + + ... + 9. Repeat + ... + d. Let nextItem be IteratorValue(next). + e. ReturnIfAbrupt(nextItem). +features: [Symbol.iterator] +---*/ + +var iterable = {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + return { + get value() { + throw new Test262Error(); + }, + done: false + }; + } + }; +}; + +assert.throws(Test262Error, function() { + new SendableMap(iterable); +}); diff --git a/test/sendable/builtins/Map/length.js b/test/sendable/builtins/Map/length.js new file mode 100644 index 00000000000..f9810f7e06e --- /dev/null +++ b/test/sendable/builtins/Map/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 23.1.2 +description: SendableMap.length is 0. +info: | + Properties of the SendableMap Constructor + + Besides the length property (whose value is 0) +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/map-iterable-empty-does-not-call-set.js b/test/sendable/builtins/Map/map-iterable-empty-does-not-call-set.js new file mode 100644 index 00000000000..df47c932f3c --- /dev/null +++ b/test/sendable/builtins/Map/map-iterable-empty-does-not-call-set.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + A SendableMap constructed with an empty iterable argument does not call set. +info: | + SendableMap ( [ iterable ] ) + + When the SendableMap function is called with optional argument the following steps are + taken: + + ... + 8. If iter is undefined, return map. + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return map. +---*/ + +var set = SendableMap.prototype.set; +var counter = 0; + +SendableMap.prototype.set = function(value) { + counter++; + set.call(this, value); +}; + +new SendableMap([]); + +assert.sameValue(counter, 0, '`SendableMap.prototype.set` was not called.'); diff --git a/test/sendable/builtins/Map/map-iterable-throws-when-set-is-not-callable.js b/test/sendable/builtins/Map/map-iterable-throws-when-set-is-not-callable.js new file mode 100644 index 00000000000..70da0de1b95 --- /dev/null +++ b/test/sendable/builtins/Map/map-iterable-throws-when-set-is-not-callable.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + Throws a TypeError if `set` is not callable on SendableMap constructor with a + iterable argument. +info: | + SendableMap ( [ iterable ] ) + + When the SendableMap function is called with optional argument the following steps are + taken: + + ... + 5. If iterable is not present, let iterable be undefined. + 6. If iterable is either undefined or null, let iter be undefined. + 7. Else, + a. Let adder be Get(map, "set"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. +---*/ + +SendableMap.prototype.set = null; + +assert.throws(TypeError, function() { + new SendableMap([ + [1, 1], + [2, 2] + ]); +}); diff --git a/test/sendable/builtins/Map/map-iterable.js b/test/sendable/builtins/Map/map-iterable.js new file mode 100644 index 00000000000..da19e175763 --- /dev/null +++ b/test/sendable/builtins/Map/map-iterable.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + Contructor returns a map object set with the elements from the iterable + argument. +info: | + SendableMap ( [ iterable ] ) + + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return map. + ... +---*/ + +var m = new SendableMap([ + ["attr", 1], + ["foo", 2] +]); + +assert.sameValue(m.size, 2, 'The value of `m.size` is `2`'); +assert.sameValue(m.get("attr"), 1); +assert.sameValue(m.get("foo"), 2); diff --git a/test/sendable/builtins/Map/map-no-iterable-does-not-call-set.js b/test/sendable/builtins/Map/map-no-iterable-does-not-call-set.js new file mode 100644 index 00000000000..c8ad230600f --- /dev/null +++ b/test/sendable/builtins/Map/map-no-iterable-does-not-call-set.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + A SendableMap constructed without a iterable argument does not call set. +info: | + SendableMap ( [ iterable ] ) + + When the SendableMap function is called with optional argument the following steps are + taken: + + ... + 5. If iterable is not present, let iterable be undefined. + 6. If iterable is either undefined or null, let iter be undefined. + 7. Else, + a. Let adder be Get(map, "set"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + 8. If iter is undefined, return map. +---*/ + +var set = SendableMap.prototype.set; +var counter = 0; + +SendableMap.prototype.set = function(value) { + counter++; + set.call(this, value); +}; + +new SendableMap(); + +assert.sameValue(counter, 0, '`SendableMap.prototype.set` was not called.'); diff --git a/test/sendable/builtins/Map/map-no-iterable.js b/test/sendable/builtins/Map/map-no-iterable.js new file mode 100644 index 00000000000..d861d65f8d3 --- /dev/null +++ b/test/sendable/builtins/Map/map-no-iterable.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + Returns the new SendableMap object with the new empty list if the iterable argument is + undefined. +info: | + SendableMap ( [ iterable ] ) + + ... + 2. Let map be OrdinaryCreateFromConstructor(NewTarget, "%SendableMapPrototype%", + «‍[[SendableMapData]]» ). + ... + 4. SendableMap map’s [[SendableMapData]] internal slot to a new empty List. + 5. If iterable is not present, let iterable be undefined. + 6. If iterable is either undefined or null, let iter be undefined. + ... + 8. If iter is undefined, return map. +---*/ + +var m1 = new SendableMap(); +var m2 = new SendableMap(undefined); +var m3 = new SendableMap(null); + +assert.sameValue(m1.size, 0, 'The value of `new SendableMap().size` is `0`'); +assert.sameValue(m2.size, 0, 'The value of `new SendableMap(undefined).size` is `0`'); +assert.sameValue(m3.size, 0, 'The value of `new SendableMap(null).size` is `0`'); + +assert(m1 instanceof SendableMap); +assert(m2 instanceof SendableMap); +assert(m3 instanceof SendableMap); diff --git a/test/sendable/builtins/Map/map.js b/test/sendable/builtins/Map/map.js new file mode 100644 index 00000000000..027c6df618b --- /dev/null +++ b/test/sendable/builtins/Map/map.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + SendableMap descriptor as a standard built-in object. +info: | + SendableMap ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(this, 'SendableMap', { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/name.js b/test/sendable/builtins/Map/name.js new file mode 100644 index 00000000000..528bab3d0ec --- /dev/null +++ b/test/sendable/builtins/Map/name.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: SendableMap.name value and descriptor. +info: | + SendableMap ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap, "name", { + value: "SendableMap", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/newtarget.js b/test/sendable/builtins/Map/newtarget.js new file mode 100644 index 00000000000..6f5f1880c26 --- /dev/null +++ b/test/sendable/builtins/Map/newtarget.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + The new SendableMap object's prototype is SendableMap.prototype +info: | + SendableMap ( [ iterable ] ) + + When the SendableMap function is called with optional argument the following steps + are taken: + + ... + 2. Let map be OrdinaryCreateFromConstructor(NewTarget, "%SendableMapPrototype%", + «‍[[SendableMapData]]» ). + ... + +---*/ + +var m1 = new SendableMap(); + +assert.sameValue( + Object.getPrototypeOf(m1), + SendableMap.prototype, + "`Object.getPrototypeOf(m1)` returns `SendableMap.prototype`" +); + +var m2 = new SendableMap([ + [1, 1], + [2, 2] +]); + +assert.sameValue( + Object.getPrototypeOf(m2), + SendableMap.prototype, + "`Object.getPrototypeOf(m2)` returns `SendableMap.prototype`" +); diff --git a/test/sendable/builtins/Map/properties-of-map-instances.js b/test/sendable/builtins/Map/properties-of-map-instances.js new file mode 100644 index 00000000000..e3e6a3cbfb3 --- /dev/null +++ b/test/sendable/builtins/Map/properties-of-map-instances.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 23.1.4 +description: > + SendableMap instances are ordinary objects that inherit properties from the SendableMap + prototype. +---*/ + +assert.sameValue( + Object.getPrototypeOf(new SendableMap()), + SendableMap.prototype, + '`Object.getPrototypeOf(new SendableMap())` returns `SendableMap.prototype`' +); diff --git a/test/sendable/builtins/Map/properties-of-the-map-prototype-object.js b/test/sendable/builtins/Map/properties-of-the-map-prototype-object.js new file mode 100644 index 00000000000..10011203805 --- /dev/null +++ b/test/sendable/builtins/Map/properties-of-the-map-prototype-object.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 23.1.3 +description: > + The prototype of SendableMap.prototype is Object.prototype. +info: | + The SendableMap prototype object is the intrinsic object %SendableMapPrototype%. The value + of the [[Prototype]] internal slot of the SendableMap prototype object is the + intrinsic object %ObjectPrototype% (19.1.3). The SendableMap prototype object is an + ordinary object. It does not have a [[SendableMapData]] internal slot. +---*/ + +assert.sameValue( + Object.getPrototypeOf(SendableMap.prototype), + Object.prototype, + 'Object.getPrototypeOf(SendableMap.prototype) returns Object.prototype' +); diff --git a/test/sendable/builtins/Map/proto-from-ctor-realm.js b/test/sendable/builtins/Map/proto-from-ctor-realm.js new file mode 100644 index 00000000000..ab8cd5a0cb0 --- /dev/null +++ b/test/sendable/builtins/Map/proto-from-ctor-realm.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 3. Let map be ? OrdinaryCreateFromConstructor(NewTarget, "%SendableMapPrototype%", + « [[SendableMapData]] »). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var o = Reflect.construct(SendableMap, [], C); + +assert.sameValue(Object.getPrototypeOf(o), other.SendableMap.prototype); diff --git a/test/sendable/builtins/Map/prototype-of-map.js b/test/sendable/builtins/Map/prototype-of-map.js new file mode 100644 index 00000000000..9f041cdb04c --- /dev/null +++ b/test/sendable/builtins/Map/prototype-of-map.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +es6id: 23.1.2 +description: > + The prototype of SendableMap is the intrinsic FunctionPrototype. +info: | + The value of the [[Prototype]] internal slot of the SendableMap constructor is the + intrinsic object %FunctionPrototype% (19.2.3). +---*/ + +assert.sameValue( + Object.getPrototypeOf(SendableMap), + Function.prototype, + '`Object.getPrototypeOf(SendableMap)` returns `Function.prototype`' +); diff --git a/test/sendable/builtins/Map/prototype/Symbol.iterator.js b/test/sendable/builtins/Map/prototype/Symbol.iterator.js new file mode 100644 index 00000000000..38079bc69d0 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/Symbol.iterator.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype-@@iterator +description: Initial state of the Symbol.iterator property +info: | + The initial value of the @@iterator property is the same function object as + the initial value of the entries property. + + Per ES6 section 17, the method should exist on the Array prototype, and it + should be writable and configurable, but not enumerable. +includes: [propertyHelper.js] +features: [Symbol.iterator] +---*/ + +assert.sameValue(SendableMap.prototype[Symbol.iterator], SendableMap.prototype.entries); +verifyProperty(SendableMap.prototype, Symbol.iterator, { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Map/prototype/Symbol.iterator/not-a-constructor.js b/test/sendable/builtins/Map/prototype/Symbol.iterator/not-a-constructor.js new file mode 100644 index 00000000000..a73038b6cd6 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/Symbol.iterator/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableMap.prototype[Symbol.iterator] 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, Symbol, Symbol.iterator, SendableMap, arrow-function] +---*/ + +assert.sameValue( + isConstructor(SendableMap.prototype[Symbol.iterator]), + false, + 'isConstructor(SendableMap.prototype[Symbol.iterator]) must return false' +); + +assert.throws(TypeError, () => { + let m = new SendableMap(); new m[Symbol.iterator](); +}); + diff --git a/test/sendable/builtins/Map/prototype/Symbol.toStringTag.js b/test/sendable/builtins/Map/prototype/Symbol.toStringTag.js new file mode 100644 index 00000000000..49918f0119b --- /dev/null +++ b/test/sendable/builtins/Map/prototype/Symbol.toStringTag.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype-@@tostringtag +description: > + `Symbol.toStringTag` property descriptor +info: | + The initial value of the @@toStringTag property is the String value + "SendableMap". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.toStringTag] +---*/ + +assert.sameValue(SendableMap.prototype[Symbol.toStringTag], 'SendableMap'); + +verifyProperty(SendableMap.prototype, Symbol.toStringTag, { + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Map/prototype/clear/clear-map.js b/test/sendable/builtins/Map/prototype/clear/clear-map.js new file mode 100644 index 00000000000..8efa79a811a --- /dev/null +++ b/test/sendable/builtins/Map/prototype/clear/clear-map.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.clear +description: > + Clears a SendableMap. +info: | + SendableMap.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + a. Set p.[[key]] to empty. + b. Set p.[[value]] to empty. + 6. Return undefined. +features: [Symbol] +---*/ + +var m1 = new SendableMap([ + ['foo', 'bar'], + [1, 1] +]); +var m2 = new SendableMap(); +var m3 = new SendableMap(); +m2.set('foo', 'bar'); +m2.set(1, 1); +m2.set(Symbol('a'), Symbol('a')); + +m1.clear(); +m2.clear(); +m3.clear(); + +assert.sameValue(m1.size, 0); +assert.sameValue(m2.size, 0); +assert.sameValue(m3.size, 0); diff --git a/test/sendable/builtins/Map/prototype/clear/clear.js b/test/sendable/builtins/Map/prototype/clear/clear.js new file mode 100644 index 00000000000..82a94c2a437 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/clear/clear.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.clear +description: > + SendableMap.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableMap.prototype.clear, + 'function', + 'typeof SendableMap.prototype.clear is "function"' +); + +verifyProperty(SendableMap.prototype, 'clear', { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Map/prototype/clear/context-is-not-map-object.js b/test/sendable/builtins/Map/prototype/clear/context-is-not-map-object.js new file mode 100644 index 00000000000..16664dc3804 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/clear/context-is-not-map-object.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.clear +description: > + Throws a TypeError if `this` does not have a [[SendableMapData]] internal slot. +info: | + SendableMap.prototype.clear ( ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.clear.call({}); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.clear.call([]); +}); diff --git a/test/sendable/builtins/Map/prototype/clear/context-is-not-object.js b/test/sendable/builtins/Map/prototype/clear/context-is-not-object.js new file mode 100644 index 00000000000..441c4610e8a --- /dev/null +++ b/test/sendable/builtins/Map/prototype/clear/context-is-not-object.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.clear +description: > + Throws a TypeError if `this` is not an Object. +info: | + SendableMap.prototype.clear ( ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.clear.call(1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.clear.call(true); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.clear.call(''); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.clear.call(null); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.clear.call(undefined); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.clear.call(Symbol()); +}); diff --git a/test/sendable/builtins/Map/prototype/clear/context-is-set-object-throws.js b/test/sendable/builtins/Map/prototype/clear/context-is-set-object-throws.js new file mode 100644 index 00000000000..c44e1f2fef2 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/clear/context-is-set-object-throws.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.clear +description: > + Throws a TypeError if `this` is a Set object. +info: | + SendableMap.prototype.clear ( ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.clear.call(new Set()); +}); diff --git a/test/sendable/builtins/Map/prototype/clear/context-is-weakmap-object-throws.js b/test/sendable/builtins/Map/prototype/clear/context-is-weakmap-object-throws.js new file mode 100644 index 00000000000..8158de8bb5e --- /dev/null +++ b/test/sendable/builtins/Map/prototype/clear/context-is-weakmap-object-throws.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.clear +description: > + Throws a TypeError if `this` is a WeakSendableMap object. +info: | + SendableMap.prototype.clear ( ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [WeakSendableMap] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.clear.call(new WeakSendableMap()); +}); diff --git a/test/sendable/builtins/Map/prototype/clear/length.js b/test/sendable/builtins/Map/prototype/clear/length.js new file mode 100644 index 00000000000..fb10fc07302 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/clear/length.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.clear +description: > + SendableMap.prototype.clear.length value and descriptor. +info: | + SendableMap.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.clear, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/clear/map-data-list-is-preserved.js b/test/sendable/builtins/Map/prototype/clear/map-data-list-is-preserved.js new file mode 100644 index 00000000000..2ba52ff3505 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/clear/map-data-list-is-preserved.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.clear +description: > + The existing [[SendableMapData]] List is preserved. +info: | + The existing [[SendableMapData]] List is preserved because there may be existing + SendableMapIterator objects that are suspended midway through iterating over that + List. + + SendableMap.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + a. Set p.[[key]] to empty. + b. Set p.[[value]] to empty. + 6. Return undefined. +---*/ + +var m = new SendableMap([ + [1, 1], + [2, 2], + [3, 3] +]); +var e = m.entries(); + +e.next(); +m.clear(); + +var n = e.next(); +assert.sameValue(n.value, undefined); +assert.sameValue(n.done, true); diff --git a/test/sendable/builtins/Map/prototype/clear/name.js b/test/sendable/builtins/Map/prototype/clear/name.js new file mode 100644 index 00000000000..73c655714a7 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/clear/name.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.clear +description: > + SendableMap.prototype.entries.name value and descriptor. +info: | + SendableMap.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.clear, "name", { + value: "clear", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/clear/not-a-constructor.js b/test/sendable/builtins/Map/prototype/clear/not-a-constructor.js new file mode 100644 index 00000000000..8828dcf71ac --- /dev/null +++ b/test/sendable/builtins/Map/prototype/clear/not-a-constructor.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableMap.prototype.clear 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, SendableMap, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableMap.prototype.clear), false, 'isConstructor(SendableMap.prototype.clear) must return false'); + +assert.throws(TypeError, () => { + let m = new SendableMap(); new m.clear(); +}); + diff --git a/test/sendable/builtins/Map/prototype/clear/returns-undefined.js b/test/sendable/builtins/Map/prototype/clear/returns-undefined.js new file mode 100644 index 00000000000..bda29a4b123 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/clear/returns-undefined.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.clear +description: > + Returns undefined. +info: | + SendableMap.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + a. Set p.[[key]] to empty. + b. Set p.[[value]] to empty. + 6. Return undefined. +---*/ + +var m1 = new SendableMap([ + ['foo', 'bar'], + [1, 1] +]); + +assert.sameValue(m1.clear(), undefined, 'clears a map and returns undefined'); +assert.sameValue(m1.clear(), undefined, 'returns undefined on an empty map'); diff --git a/test/sendable/builtins/Map/prototype/constructor.js b/test/sendable/builtins/Map/prototype/constructor.js new file mode 100644 index 00000000000..b186ac1170f --- /dev/null +++ b/test/sendable/builtins/Map/prototype/constructor.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-constructor +description: SendableMap.prototype.constructor value and descriptor +info: | + The initial value of SendableMap.prototype.constructor is the intrinsic object %SendableMap%. +includes: [propertyHelper.js] +---*/ + +assert.sameValue(SendableMap.prototype.constructor, SendableMap); +assert.sameValue((new SendableMap()).constructor, SendableMap); + +verifyProperty(SendableMap.prototype, 'constructor', { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Map/prototype/delete/context-is-not-map-object.js b/test/sendable/builtins/Map/prototype/delete/context-is-not-map-object.js new file mode 100644 index 00000000000..344ed7857dd --- /dev/null +++ b/test/sendable/builtins/Map/prototype/delete/context-is-not-map-object.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.delete +description: > + Throws a TypeError if `this` does not have a [[SendableMapData]] internal slot. +info: | + SendableMap.prototype.delete ( key ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.delete.call({}, 'attr'); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.delete.call([], 'attr'); +}); diff --git a/test/sendable/builtins/Map/prototype/delete/context-is-not-object.js b/test/sendable/builtins/Map/prototype/delete/context-is-not-object.js new file mode 100644 index 00000000000..8d95e5ae361 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/delete/context-is-not-object.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.delete +description: > + Throws a TypeError if `this` is not an Object. +info: | + SendableMap.prototype.delete ( key ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.delete.call(1, 'attr'); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.delete.call(true, 'attr'); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.delete.call('', 'attr'); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.delete.call(null, 'attr'); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.delete.call(undefined, 'attr'); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.delete.call(Symbol(), 'attr'); +}); diff --git a/test/sendable/builtins/Map/prototype/delete/context-is-set-object-throws.js b/test/sendable/builtins/Map/prototype/delete/context-is-set-object-throws.js new file mode 100644 index 00000000000..d2f3b158391 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/delete/context-is-set-object-throws.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.delete +description: > + Throws a TypeError if `this` is a Set object. +info: | + SendableMap.prototype.delete ( key ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.delete.call(new Set(), 'attr'); +}); diff --git a/test/sendable/builtins/Map/prototype/delete/context-is-weakmap-object-throws.js b/test/sendable/builtins/Map/prototype/delete/context-is-weakmap-object-throws.js new file mode 100644 index 00000000000..209cbdeedc5 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/delete/context-is-weakmap-object-throws.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.delete +description: > + Throws a TypeError if `this` is a WeakSendableMap object. +info: | + SendableMap.prototype.delete ( key ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [WeakSendableMap] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.delete.call(new WeakSendableMap(), 'attr'); +}); diff --git a/test/sendable/builtins/Map/prototype/delete/delete.js b/test/sendable/builtins/Map/prototype/delete/delete.js new file mode 100644 index 00000000000..7b9ae109096 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/delete/delete.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.delete +description: > + SendableMap.prototype.delete ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableMap.prototype.delete, + 'function', + 'typeof SendableMap.prototype.delete is "function"' +); + +verifyProperty(SendableMap.prototype, 'delete', { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Map/prototype/delete/does-not-break-iterators.js b/test/sendable/builtins/Map/prototype/delete/does-not-break-iterators.js new file mode 100644 index 00000000000..97e73c5583b --- /dev/null +++ b/test/sendable/builtins/Map/prototype/delete/does-not-break-iterators.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.delete +description: > + Deleting an entry does not break a [[SendableMapData]] List. +info: | + SendableMap.prototype.delete ( key ) + + 4. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of entries, + a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, then + i. Set p.[[key]] to empty. + ii. Set p.[[value]] to empty. + iii. Return true. + ... +---*/ + +var m = new SendableMap([ + ['a', 1], + ['b', 2], + ['c', 3] +]); +var e = m.entries(); + +e.next(); +m.delete('b'); + +var n = e.next(); + +assert.sameValue(n.value[0], 'c'); +assert.sameValue(n.value[1], 3); + +n = e.next(); +assert.sameValue(n.value, undefined); +assert.sameValue(n.done, true); diff --git a/test/sendable/builtins/Map/prototype/delete/length.js b/test/sendable/builtins/Map/prototype/delete/length.js new file mode 100644 index 00000000000..4bb01e3fb54 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/delete/length.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.delete +description: > + SendableMap.prototype.delete.length value and descriptor. +info: | + SendableMap.prototype.delete ( key ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.delete, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/delete/name.js b/test/sendable/builtins/Map/prototype/delete/name.js new file mode 100644 index 00000000000..962466fdc3b --- /dev/null +++ b/test/sendable/builtins/Map/prototype/delete/name.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.delete +description: > + SendableMap.prototype.delete.name value and descriptor. +info: | + SendableMap.prototype.delete ( key ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.delete, "name", { + value: "delete", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/delete/not-a-constructor.js b/test/sendable/builtins/Map/prototype/delete/not-a-constructor.js new file mode 100644 index 00000000000..db15edc42e6 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/delete/not-a-constructor.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableMap.prototype.delete 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, SendableMap, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableMap.prototype.delete), false, 'isConstructor(SendableMap.prototype.delete) must return false'); + +assert.throws(TypeError, () => { + let m = new SendableMap(); new m.delete(); +}); + diff --git a/test/sendable/builtins/Map/prototype/delete/returns-false.js b/test/sendable/builtins/Map/prototype/delete/returns-false.js new file mode 100644 index 00000000000..582ff66321b --- /dev/null +++ b/test/sendable/builtins/Map/prototype/delete/returns-false.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.delete +description: > + Returns false when it does not delete an entry. +info: | + SendableMap.prototype.delete ( key ) + + 4. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of entries, + a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, then + ... + iii. Return true. + 6. Return false. +---*/ + +var m = new SendableMap([ + ['a', 1], + ['b', 2] +]); + +assert.sameValue(m.delete('not-in-the-map'), false); + +m.delete('a'); +assert.sameValue(m.delete('a'), false); diff --git a/test/sendable/builtins/Map/prototype/delete/returns-true-for-deleted-entry.js b/test/sendable/builtins/Map/prototype/delete/returns-true-for-deleted-entry.js new file mode 100644 index 00000000000..3210881033d --- /dev/null +++ b/test/sendable/builtins/Map/prototype/delete/returns-true-for-deleted-entry.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.delete +description: > + Returns true when deletes an entry. +info: | + SendableMap.prototype.delete ( key ) + + 4. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of entries, + a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, then + i. Set p.[[key]] to empty. + ii. Set p.[[value]] to empty. + iii. Return true. + ... +---*/ + +var m = new SendableMap([ + ['a', 1], + ['b', 2] +]); + +var result = m.delete('a'); + +assert(result); +assert.sameValue(m.size, 1); diff --git a/test/sendable/builtins/Map/prototype/descriptor.js b/test/sendable/builtins/Map/prototype/descriptor.js new file mode 100644 index 00000000000..94949b366f8 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/descriptor.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype +description: SendableMap.prototype property attributes. +info: | + This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, + [[Configurable]]: false }. +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap, 'prototype', { + writable: false, + enumerable: false, + configurable: false, +}); diff --git a/test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot-set.js b/test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot-set.js new file mode 100644 index 00000000000..73dd846ced6 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot-set.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.entries +description: > + Throws a TypeError if `this` is a Set object. +info: | + SendableMap.prototype.entries ( ) + + 1. Let M be the this value. + 2. Return CreateSendableMapIterator(M, "key+value"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 2. If map does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.entries.call(new Set()); +}); + +assert.throws(TypeError, function() { + var m = new SendableMap(); + m.entries.call(new Set()); +}); diff --git a/test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot-weakmap.js new file mode 100644 index 00000000000..69de96ea867 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot-weakmap.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.entries +description: > + Throws a TypeError if `this` is a WeakSendableMap object. +info: | + SendableMap.prototype.entries ( ) + + 1. Let M be the this value. + 2. Return CreateSendableMapIterator(M, "key+value"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 2. If map does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [WeakSendableMap] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.entries.call(new WeakSendableMap()); +}); + +assert.throws(TypeError, function() { + var m = new SendableMap(); + m.entries.call(new WeakSendableMap()); +}); diff --git a/test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot.js b/test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot.js new file mode 100644 index 00000000000..20458ca36c0 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.entries +description: > + Throws a TypeError if `this` object does not have a [[SendableMapData]] internal slot. +info: | + SendableMap.prototype.entries ( ) + + 1. Let M be the this value. + 2. Return CreateSendableMapIterator(M, "key+value"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 2. If map does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... + +---*/ + +var m = new SendableMap(); + +assert.throws(TypeError, function() { + SendableMap.prototype.entries.call([]); +}); + +assert.throws(TypeError, function() { + m.entries.call([]); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.entries.call({}); +}); + +assert.throws(TypeError, function() { + m.entries.call({}); +}); diff --git a/test/sendable/builtins/Map/prototype/entries/entries.js b/test/sendable/builtins/Map/prototype/entries/entries.js new file mode 100644 index 00000000000..c3f98862aa2 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/entries/entries.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.entries +description: > + Property type and descriptor. +info: | + SendableMap.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableMap.prototype.entries, + 'function', + '`typeof SendableMap.prototype.entries` is `function`' +); + +verifyProperty(SendableMap.prototype, 'entries', { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Map/prototype/entries/length.js b/test/sendable/builtins/Map/prototype/entries/length.js new file mode 100644 index 00000000000..a738bc8a0a4 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/entries/length.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.entries +description: > + SendableMap.prototype.entries.length value and descriptor. +info: | + SendableMap.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.entries, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/entries/name.js b/test/sendable/builtins/Map/prototype/entries/name.js new file mode 100644 index 00000000000..d7de8b94cfd --- /dev/null +++ b/test/sendable/builtins/Map/prototype/entries/name.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.entries +description: > + SendableMap.prototype.entries.name value and descriptor. +info: | + SendableMap.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.entries, "name", { + value: "entries", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/entries/not-a-constructor.js b/test/sendable/builtins/Map/prototype/entries/not-a-constructor.js new file mode 100644 index 00000000000..8c8cf9b9456 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/entries/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableMap.prototype.entries 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, SendableMap, arrow-function] +---*/ + +assert.sameValue( + isConstructor(SendableMap.prototype.entries), + false, + 'isConstructor(SendableMap.prototype.entries) must return false' +); + +assert.throws(TypeError, () => { + let m = new SendableMap(); new m.entries(); +}); + diff --git a/test/sendable/builtins/Map/prototype/entries/returns-iterator-empty.js b/test/sendable/builtins/Map/prototype/entries/returns-iterator-empty.js new file mode 100644 index 00000000000..650c0decbc2 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/entries/returns-iterator-empty.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.entries +description: > + Returns an iterator on an empty SendableMap object. +info: | + SendableMap.prototype.entries ( ) + + ... + 2. Return CreateSendableMapIterator(M, "key+value"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 7. Return iterator. +---*/ + +var map = new SendableMap(); +var iterator = map.entries(); +var result = iterator.next(); + +assert.sameValue( + result.value, undefined, + 'The value of `result.value` is `undefined`' +); +assert.sameValue(result.done, true, 'The value of `result.done` is `true`'); diff --git a/test/sendable/builtins/Map/prototype/entries/returns-iterator.js b/test/sendable/builtins/Map/prototype/entries/returns-iterator.js new file mode 100644 index 00000000000..43a6908737e --- /dev/null +++ b/test/sendable/builtins/Map/prototype/entries/returns-iterator.js @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.entries +description: > + Returns an iterator. +info: | + SendableMap.prototype.entries ( ) + + ... + 2. Return CreateSendableMapIterator(M, "key+value"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 7. Return iterator. +---*/ + +var map = new SendableMap(); +map.set('a',1); +map.set('b',2); +map.set('c',3); + +var iterator = map.entries(); +var result; + +result = iterator.next(); +assert.sameValue(result.value[0], 'a', 'First result `value` ("key")'); +assert.sameValue(result.value[1], 1, 'First result `value` ("value")'); +assert.sameValue(result.value.length, 2, 'First result `value` (length)'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value[0], 'b', 'Second result `value` ("key")'); +assert.sameValue(result.value[1], 2, 'Second result `value` ("value")'); +assert.sameValue(result.value.length, 2, 'Second result `value` (length)'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value[0], 'c', 'Third result `value` ("key")'); +assert.sameValue(result.value[1], 3, 'Third result `value` ("value")'); +assert.sameValue(result.value.length, 2, 'Third result `value` (length)'); +assert.sameValue(result.done, false, 'Third result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); + +result = iterator.next(); +assert.sameValue( + result.value, undefined, 'Exhausted result `value` (repeated request)' +); +assert.sameValue( + result.done, true, 'Exhausted result `done` flag (repeated request)' +); diff --git a/test/sendable/builtins/Map/prototype/entries/this-not-object-throw.js b/test/sendable/builtins/Map/prototype/entries/this-not-object-throw.js new file mode 100644 index 00000000000..d83fecfa269 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/entries/this-not-object-throw.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.entries +description: > + Throws a TypeError if `this` is not an Object. +info: | + SendableMap.prototype.entries ( ) + + ... + 2. Return CreateSetIterator(M, "key+value"). + + 23.1.5.1 CreateSetIterator Abstract Operation + + 1. If Type(map) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.entries.call(false); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.entries.call(1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.entries.call(''); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.entries.call(undefined); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.entries.call(null); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.entries.call(Symbol()); +}); + +assert.throws(TypeError, function() { + var map = new SendableMap(); + map.entries.call(false); +}); diff --git a/test/sendable/builtins/Map/prototype/forEach/callback-parameters.js b/test/sendable/builtins/Map/prototype/forEach/callback-parameters.js new file mode 100644 index 00000000000..d9f3569f4b0 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/callback-parameters.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + Verify the parameters order on the given callback. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + 6. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 7. Repeat for each Record {[[key]], [[value]]} e that is an element of + entries, in original key insertion order + a. If e.[[key]] is not empty, then + i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»). + ... +---*/ + +var map = new SendableMap(); +map.set('foo', 42); +map.set('bar', 'baz'); + +var results = []; + +var callback = function(value, key, thisArg) { + results.push({ + value: value, + key: key, + thisArg: thisArg + }); +}; + +map.forEach(callback); + +assert.sameValue(results[0].value, 42); +assert.sameValue(results[0].key, 'foo'); +assert.sameValue(results[0].thisArg, map); + +assert.sameValue(results[1].value, 'baz'); +assert.sameValue(results[1].key, 'bar'); +assert.sameValue(results[1].thisArg, map); + +assert.sameValue(results.length, 2); diff --git a/test/sendable/builtins/Map/prototype/forEach/callback-result-is-abrupt.js b/test/sendable/builtins/Map/prototype/forEach/callback-result-is-abrupt.js new file mode 100644 index 00000000000..9d639454dd3 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/callback-result-is-abrupt.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + Returns error from callback result is abrupt. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + 6. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 7. Repeat for each Record {[[key]], [[value]]} e that is an element of + entries, in original key insertion order + a. If e.[[key]] is not empty, then + i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»). + ii. ReturnIfAbrupt(funcResult). + ... +---*/ + +var map = new SendableMap([[0, 0]]); + +assert.throws(Test262Error, function() { + map.forEach(function() { + throw new Test262Error(); + }); +}); diff --git a/test/sendable/builtins/Map/prototype/forEach/callback-this-non-strict.js b/test/sendable/builtins/Map/prototype/forEach/callback-this-non-strict.js new file mode 100644 index 00000000000..8ce87579bbf --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/callback-this-non-strict.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + If a thisArg is not provided, undefined will be used as the this value for + each invocation of callbackfn. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + 6. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 7. Repeat for each Record {[[key]], [[value]]} e that is an element of + entries, in original key insertion order + a. If e.[[key]] is not empty, then + i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»). + ... +flags: [noStrict] +---*/ + +var _this = []; +var map = new SendableMap(); + +map.set(0, 0); +map.set(1, 1); +map.set(2, 2); + +map.forEach(function() { + _this.push(this); +}); + +assert.sameValue(_this[0], this); +assert.sameValue(_this[1], this); +assert.sameValue(_this[2], this); diff --git a/test/sendable/builtins/Map/prototype/forEach/callback-this-strict.js b/test/sendable/builtins/Map/prototype/forEach/callback-this-strict.js new file mode 100644 index 00000000000..037108b6508 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/callback-this-strict.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + If a thisArg is not provided, undefined will be used as the this value for + each invocation of callbackfn. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + 6. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 7. Repeat for each Record {[[key]], [[value]]} e that is an element of + entries, in original key insertion order + a. If e.[[key]] is not empty, then + i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»). + ... +flags: [onlyStrict] +---*/ + +var _this = []; +var map = new SendableMap(); + +map.set(0, 0); +map.set(1, 1); +map.set(2, 2); + +map.forEach(function() { + _this.push(this); +}); + +assert.sameValue(_this[0], undefined); +assert.sameValue(_this[1], undefined); +assert.sameValue(_this[2], undefined); diff --git a/test/sendable/builtins/Map/prototype/forEach/deleted-values-during-foreach.js b/test/sendable/builtins/Map/prototype/forEach/deleted-values-during-foreach.js new file mode 100644 index 00000000000..ebbc30adddb --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/deleted-values-during-foreach.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + SendableMap state with deleted values during forEach. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + 6. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 7. Repeat for each Record {[[key]], [[value]]} e that is an element of + entries, in original key insertion order + a. If e.[[key]] is not empty, then + i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»). + ii. ReturnIfAbrupt(funcResult). + ... +---*/ + +var map = new SendableMap(); +map.set('foo', 0); +map.set('bar', 1); + +var count = 0; +var results = []; + +map.forEach(function(value, key) { + if (count === 0) { + map.delete('bar'); + } + results.push({ + value: value, + key: key + }); + count++; +}); + +assert.sameValue(results.length, 1); +assert.sameValue(results[0].key, 'foo'); +assert.sameValue(results[0].value, 0); diff --git a/test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-set.js b/test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-set.js new file mode 100644 index 00000000000..5860757a169 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-set.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + Throws a TypeError if `this` is a Set object. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.forEach.call(new Set(), function() {}); +}); + +assert.throws(TypeError, function() { + var m = new SendableMap(); + m.forEach.call(new Set(), function() {}); +}); diff --git a/test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-weakmap.js new file mode 100644 index 00000000000..0d336523a15 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-weakmap.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + Throws a TypeError if `this` is a WeakSendableMap object. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [WeakSendableMap] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.forEach.call(new WeakSendableMap(), function() {}); +}); + +assert.throws(TypeError, function() { + var m = new SendableMap(); + m.forEach.call(new WeakSendableMap(), function() {}); +}); diff --git a/test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot.js b/test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot.js new file mode 100644 index 00000000000..512307fd099 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + Throws a TypeError if `this` object does not have a [[SendableMapData]] internal slot. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +---*/ + +var m = new SendableMap(); + +assert.throws(TypeError, function() { + SendableMap.prototype.forEach.call([], function() {}); +}); + +assert.throws(TypeError, function() { + m.forEach.call([], function() {}); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.forEach.call({}, function() {}); +}); + +assert.throws(TypeError, function() { + m.forEach.call({}, function() {}); +}); diff --git a/test/sendable/builtins/Map/prototype/forEach/first-argument-is-not-callable.js b/test/sendable/builtins/Map/prototype/forEach/first-argument-is-not-callable.js new file mode 100644 index 00000000000..3c2a3d07b38 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/first-argument-is-not-callable.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + Throws a TypeError if first argument is not callable. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +var map = new SendableMap(); + +assert.throws(TypeError, function() { + map.forEach({}); +}); + +assert.throws(TypeError, function() { + map.forEach([]); +}); + +assert.throws(TypeError, function() { + map.forEach(1); +}); + +assert.throws(TypeError, function() { + map.forEach(''); +}); + +assert.throws(TypeError, function() { + map.forEach(null); +}); + +assert.throws(TypeError, function() { + map.forEach(undefined); +}); + +assert.throws(TypeError, function() { + map.forEach(Symbol()); +}); diff --git a/test/sendable/builtins/Map/prototype/forEach/forEach.js b/test/sendable/builtins/Map/prototype/forEach/forEach.js new file mode 100644 index 00000000000..c7490340294 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/forEach.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + Property type and descriptor. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableMap.prototype.forEach, + 'function', + '`typeof SendableMap.prototype.forEach` is `function`' +); + +verifyProperty(SendableMap.prototype, 'forEach', { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Map/prototype/forEach/iterates-in-key-insertion-order.js b/test/sendable/builtins/Map/prototype/forEach/iterates-in-key-insertion-order.js new file mode 100644 index 00000000000..e8b089677f0 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/iterates-in-key-insertion-order.js @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + Repeats for each non-empty record, in original key insertion order. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + 6. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 7. Repeat for each Record {[[key]], [[value]]} e that is an element of + entries, in original key insertion order + a. If e.[[key]] is not empty, then + i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»). + ... +---*/ + +var map = new SendableMap([ + ['foo', 'valid foo'], + ['bar', false], + ['baz', 'valid baz'] +]); +map.set(0, false); +map.set(1, false); +map.set(2, 'valid 2'); +map.delete(1); +map.delete('bar'); + +// Not setting a new key, just changing the value +map.set(0, 'valid 0'); + +var results = []; +var callback = function(value) { + results.push(value); +}; + +map.forEach(callback); + +assert.sameValue(results[0], 'valid foo'); +assert.sameValue(results[1], 'valid baz'); +assert.sameValue(results[2], 'valid 0'); +assert.sameValue(results[3], 'valid 2'); +assert.sameValue(results.length, 4); + +map.clear(); +results = []; + +map.forEach(callback); +assert.sameValue(results.length, 0); diff --git a/test/sendable/builtins/Map/prototype/forEach/iterates-values-added-after-foreach-begins.js b/test/sendable/builtins/Map/prototype/forEach/iterates-values-added-after-foreach-begins.js new file mode 100644 index 00000000000..34d52a8c671 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/iterates-values-added-after-foreach-begins.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + New keys are visited if created during forEach execution. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + 6. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 7. Repeat for each Record {[[key]], [[value]]} e that is an element of + entries, in original key insertion order + a. If e.[[key]] is not empty, then + i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»). + ii. ReturnIfAbrupt(funcResult). + ... +---*/ + +var map = new SendableMap(); +map.set('foo', 0); +map.set('bar', 1); + +var count = 0; +var results = []; + +map.forEach(function(value, key) { + if (count === 0) { + map.set('baz', 2); + } + results.push({ + value: value, + key: key + }); + count++; +}); + +assert.sameValue(count, 3); +assert.sameValue(map.size, 3); + +assert.sameValue(results[0].key, 'foo'); +assert.sameValue(results[0].value, 0); + +assert.sameValue(results[1].key, 'bar'); +assert.sameValue(results[1].value, 1); + +assert.sameValue(results[2].key, 'baz'); +assert.sameValue(results[2].value, 2); diff --git a/test/sendable/builtins/Map/prototype/forEach/iterates-values-deleted-then-readded.js b/test/sendable/builtins/Map/prototype/forEach/iterates-values-deleted-then-readded.js new file mode 100644 index 00000000000..0575317c865 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/iterates-values-deleted-then-readded.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + New keys are visited if created during forEach execution. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + 6. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 7. Repeat for each Record {[[key]], [[value]]} e that is an element of + entries, in original key insertion order + a. If e.[[key]] is not empty, then + i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»). + ii. ReturnIfAbrupt(funcResult). + ... +---*/ + +var map = new SendableMap(); +map.set('foo', 0); +map.set('bar', 1); + +var count = 0; +var results = []; + +map.forEach(function(value, key) { + if (count === 0) { + map.delete('foo'); + map.set('foo', 'baz'); + } + results.push({ + value: value, + key: key + }); + count++; +}); + +assert.sameValue(count, 3); +assert.sameValue(map.size, 2); + +assert.sameValue(results[0].key, 'foo'); +assert.sameValue(results[0].value, 0); + +assert.sameValue(results[1].key, 'bar'); +assert.sameValue(results[1].value, 1); + +assert.sameValue(results[2].key, 'foo'); +assert.sameValue(results[2].value, 'baz'); diff --git a/test/sendable/builtins/Map/prototype/forEach/length.js b/test/sendable/builtins/Map/prototype/forEach/length.js new file mode 100644 index 00000000000..9b419dafbf8 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/length.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + SendableMap.prototype.forEach.length value and descriptor. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.forEach, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/forEach/name.js b/test/sendable/builtins/Map/prototype/forEach/name.js new file mode 100644 index 00000000000..a2872e5a409 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/name.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + SendableMap.prototype.forEach.name value and descriptor. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.forEach, "name", { + value: "forEach", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/forEach/not-a-constructor.js b/test/sendable/builtins/Map/prototype/forEach/not-a-constructor.js new file mode 100644 index 00000000000..cc4437c10e3 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableMap.prototype.forEach 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, SendableMap, arrow-function] +---*/ + +assert.sameValue( + isConstructor(SendableMap.prototype.forEach), + false, + 'isConstructor(SendableMap.prototype.forEach) must return false' +); + +assert.throws(TypeError, () => { + let m = new SendableMap(); new m.forEach(); +}); + diff --git a/test/sendable/builtins/Map/prototype/forEach/return-undefined.js b/test/sendable/builtins/Map/prototype/forEach/return-undefined.js new file mode 100644 index 00000000000..64d78d5fa9e --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/return-undefined.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + Returns undefined. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 8. Return undefined. +---*/ + +var map = new SendableMap(); + +var result = map.forEach(function() { + return true; +}); + +assert.sameValue(result, undefined, 'Empty map#forEach returns undefined'); + +map.set(1, 1); +result = map.forEach(function() { + return true; +}); + +assert.sameValue(result, undefined, 'map#forEach returns undefined'); diff --git a/test/sendable/builtins/Map/prototype/forEach/second-parameter-as-callback-context.js b/test/sendable/builtins/Map/prototype/forEach/second-parameter-as-callback-context.js new file mode 100644 index 00000000000..fa28fa548ee --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/second-parameter-as-callback-context.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + If a thisArg parameter is provided, it will be used as the this value for each + invocation of callbackfn. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + 6. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 7. Repeat for each Record {[[key]], [[value]]} e that is an element of + entries, in original key insertion order + a. If e.[[key]] is not empty, then + i. Let funcResult be Call(callbackfn, T, «e.[[value]], e.[[key]], M»). + ... +---*/ + +var expectedThis = {}; +var _this = []; + +var map = new SendableMap(); +map.set(0, 0); +map.set(1, 1); +map.set(2, 2); + +var callback = function() { + _this.push(this); +}; + +map.forEach(callback, expectedThis); + +assert.sameValue(_this[0], expectedThis); +assert.sameValue(_this[1], expectedThis); +assert.sameValue(_this[2], expectedThis); diff --git a/test/sendable/builtins/Map/prototype/forEach/this-not-object-throw.js b/test/sendable/builtins/Map/prototype/forEach/this-not-object-throw.js new file mode 100644 index 00000000000..e4b8c26bfcc --- /dev/null +++ b/test/sendable/builtins/Map/prototype/forEach/this-not-object-throw.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.forEach +description: > + Throws a TypeError if `this` is not an Object. +info: | + SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.forEach.call(false, function() {}); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.forEach.call(1, function() {}); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.forEach.call('', function() {}); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.forEach.call(undefined, function() {}); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.forEach.call(null, function() {}); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.forEach.call(Symbol(), function() {}); +}); + +assert.throws(TypeError, function() { + var map = new SendableMap(); + map.forEach.call(false, function() {}); +}); diff --git a/test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot-set.js b/test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot-set.js new file mode 100644 index 00000000000..0e99f0048ac --- /dev/null +++ b/test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot-set.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.get +description: > + Throws a TypeError if `this` is a Set object. +info: | + SendableMap.prototype.get ( key ) + + ... + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.get.call(new Set(), 1); +}); + +assert.throws(TypeError, function() { + var m = new SendableMap(); + m.get.call(new Set(), 1); +}); diff --git a/test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot-weakmap.js new file mode 100644 index 00000000000..22a7744bb57 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot-weakmap.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.get +description: > + Throws a TypeError if `this` is a WeakSendableMap object. +info: | + SendableMap.prototype.get ( key ) + + ... + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [WeakSendableMap] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.get.call(new WeakSendableMap(), 1); +}); + +assert.throws(TypeError, function() { + var m = new SendableMap(); + m.get.call(new WeakSendableMap(), 1); +}); diff --git a/test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot.js b/test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot.js new file mode 100644 index 00000000000..2c6198e7667 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.get +description: > + Throws a TypeError if `this` object does not have a [[SendableMapData]] internal slot. +info: | + SendableMap.prototype.get ( key ) + + ... + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +---*/ + +var m = new SendableMap(); + +assert.throws(TypeError, function() { + SendableMap.prototype.get.call([], 1); +}); + +assert.throws(TypeError, function() { + m.get.call([], 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.get.call({}, 1); +}); + +assert.throws(TypeError, function() { + m.get.call({}, 1); +}); diff --git a/test/sendable/builtins/Map/prototype/get/get.js b/test/sendable/builtins/Map/prototype/get/get.js new file mode 100644 index 00000000000..f561273f63e --- /dev/null +++ b/test/sendable/builtins/Map/prototype/get/get.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.get +description: > + Property type and descriptor. +info: | + SendableMap.prototype.get ( key ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableMap.prototype.get, + 'function', + '`typeof SendableMap.prototype.get` is `function`' +); + +verifyProperty(SendableMap.prototype, 'get', { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Map/prototype/get/length.js b/test/sendable/builtins/Map/prototype/get/length.js new file mode 100644 index 00000000000..7ce377d5d07 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/get/length.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.get +description: > + SendableMap.prototype.get.length value and descriptor. +info: | + SendableMap.prototype.get ( key ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.get, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/get/name.js b/test/sendable/builtins/Map/prototype/get/name.js new file mode 100644 index 00000000000..0d4739d6eda --- /dev/null +++ b/test/sendable/builtins/Map/prototype/get/name.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.get +description: > + SendableMap.prototype.get.name value and descriptor. +info: | + SendableMap.prototype.get ( key ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.get, "name", { + value: "get", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/get/not-a-constructor.js b/test/sendable/builtins/Map/prototype/get/not-a-constructor.js new file mode 100644 index 00000000000..3d91289b031 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/get/not-a-constructor.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableMap.prototype.get 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, SendableMap, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableMap.prototype.get), false, 'isConstructor(SendableMap.prototype.get) must return false'); + +assert.throws(TypeError, () => { + let m = new SendableMap(); new m.get(); +}); + diff --git a/test/sendable/builtins/Map/prototype/get/returns-undefined.js b/test/sendable/builtins/Map/prototype/get/returns-undefined.js new file mode 100644 index 00000000000..9b0532e484a --- /dev/null +++ b/test/sendable/builtins/Map/prototype/get/returns-undefined.js @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.get +description: > + Returns undefined when key is not on the map. +info: | + SendableMap.prototype.get ( key ) + + 4. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, + return p.[[value]]. + 6. Return undefined. + ... +---*/ + +var map = new SendableMap(); + +assert.sameValue( + map.get('item'), undefined, + 'returns undefined if key is not on the map' +); + +map.set('item', 1); +map.set('another_item', 2); +map.delete('item'); + +assert.sameValue( + map.get('item'), undefined, + 'returns undefined if key was deleted' +); + +map.set('item', 1); +map.clear(); + +assert.sameValue( + map.get('item'), undefined, + 'returns undefined after map is cleared' +); diff --git a/test/sendable/builtins/Map/prototype/get/returns-value-different-key-types.js b/test/sendable/builtins/Map/prototype/get/returns-value-different-key-types.js new file mode 100644 index 00000000000..fb3dc179701 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/get/returns-value-different-key-types.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.get +description: > + Returns the value from the specified key on different types. +info: | + SendableMap.prototype.get ( key ) + + 4. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, + return p.[[value]]. + ... +features: [Symbol] +---*/ + +var map = new SendableMap(); + +map.set('bar', 0); +assert.sameValue(map.get('bar'), 0); + +map.set(1, 42); +assert.sameValue(map.get(1), 42); + +map.set(NaN, 1); +assert.sameValue(map.get(NaN), 1); + +var item = {}; +map.set(item, 2); +assert.sameValue(map.get(item), 2); + +item = []; +map.set(item, 3); +assert.sameValue(map.get(item), 3); + +item = Symbol('item'); +map.set(item, 4); +assert.sameValue(map.get(item), 4); + +item = null; +map.set(item, 5); +assert.sameValue(map.get(item), 5); + +item = undefined; +map.set(item, 6); +assert.sameValue(map.get(item), 6); diff --git a/test/sendable/builtins/Map/prototype/get/returns-value-normalized-zero-key.js b/test/sendable/builtins/Map/prototype/get/returns-value-normalized-zero-key.js new file mode 100644 index 00000000000..7b040b05603 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/get/returns-value-normalized-zero-key.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.get +description: > + -0 and +0 are normalized to +0; +info: | + SendableMap.prototype.get ( key ) + + 4. Let entries be the List that is the value of M’s [[SendableMapData]] internal slot. + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, + return p.[[value]]. + ... +---*/ + +var map = new SendableMap(); + +map.set(+0, 42); +assert.sameValue(map.get(-0), 42); + +map = new SendableMap(); +map.set(-0, 43); +assert.sameValue(map.get(+0), 43); diff --git a/test/sendable/builtins/Map/prototype/get/this-not-object-throw.js b/test/sendable/builtins/Map/prototype/get/this-not-object-throw.js new file mode 100644 index 00000000000..6a36c5f4794 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/get/this-not-object-throw.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.get +description: > + Throws a TypeError if `this` is not an Object. +info: | + SendableMap.prototype.get ( key ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.get.call(false, 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.get.call(1, 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.get.call('', 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.get.call(undefined, 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.get.call(null, 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.get.call(Symbol(), 1); +}); + +assert.throws(TypeError, function() { + var map = new SendableMap(); + map.get.call(false, 1); +}); diff --git a/test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot-set.js b/test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot-set.js new file mode 100644 index 00000000000..39f682dcc2d --- /dev/null +++ b/test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot-set.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.has +description: > + Throws a TypeError if `this` is a Set object. +info: | + SendableMap.prototype.has ( key ) + + ... + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.has.call(new Set(), 1); +}); + +assert.throws(TypeError, function() { + var m = new SendableMap(); + m.has.call(new Set(), 1); +}); diff --git a/test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot-weakmap.js new file mode 100644 index 00000000000..100d823a03d --- /dev/null +++ b/test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot-weakmap.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.has +description: > + Throws a TypeError if `this` is a WeakSendableMap object. +info: | + SendableMap.prototype.has ( key ) + + ... + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [WeakSendableMap] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.has.call(new WeakSendableMap(), 1); +}); + +assert.throws(TypeError, function() { + var m = new SendableMap(); + m.has.call(new WeakSendableMap(), 1); +}); diff --git a/test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot.js b/test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot.js new file mode 100644 index 00000000000..eae79bad1fc --- /dev/null +++ b/test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.has +description: > + Throws a TypeError if `this` object does not have a [[SendableMapData]] internal slot. +info: | + SendableMap.prototype.has ( key ) + + ... + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +---*/ + +var m = new SendableMap(); + +assert.throws(TypeError, function() { + SendableMap.prototype.has.call([], 1); +}); + +assert.throws(TypeError, function() { + m.has.call([], 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.has.call({}, 1); +}); + +assert.throws(TypeError, function() { + m.has.call({}, 1); +}); diff --git a/test/sendable/builtins/Map/prototype/has/has.js b/test/sendable/builtins/Map/prototype/has/has.js new file mode 100644 index 00000000000..3fe6f98c711 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/has/has.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.has +description: > + Property type and descriptor. +info: | + SendableMap.prototype.has ( key ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableMap.prototype.has, + 'function', + '`typeof SendableMap.prototype.has` is `function`' +); + +verifyProperty(SendableMap.prototype, 'has', { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Map/prototype/has/length.js b/test/sendable/builtins/Map/prototype/has/length.js new file mode 100644 index 00000000000..e73df7cf0b7 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/has/length.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.has +description: > + SendableMap.prototype.has.length value and descriptor. +info: | + SendableMap.prototype.has ( key ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.has, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/has/name.js b/test/sendable/builtins/Map/prototype/has/name.js new file mode 100644 index 00000000000..42a50a24716 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/has/name.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.has +description: > + SendableMap.prototype.has.name value and descriptor. +info: | + SendableMap.prototype.has ( key ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.has, "name", { + value: "has", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/has/normalizes-zero-key.js b/test/sendable/builtins/Map/prototype/has/normalizes-zero-key.js new file mode 100644 index 00000000000..27049df0c69 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/has/normalizes-zero-key.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.has +description: > + -0 and +0 are normalized to +0; +info: | + SendableMap.prototype.has ( key ) + + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, + return true. + ... +---*/ + +var map = new SendableMap(); + +assert.sameValue(map.has(-0), false); +assert.sameValue(map.has(+0), false); + +map.set(-0, 42); +assert.sameValue(map.has(-0), true); +assert.sameValue(map.has(+0), true); + +map.clear(); + +map.set(+0, 42); +assert.sameValue(map.has(-0), true); +assert.sameValue(map.has(+0), true); diff --git a/test/sendable/builtins/Map/prototype/has/not-a-constructor.js b/test/sendable/builtins/Map/prototype/has/not-a-constructor.js new file mode 100644 index 00000000000..fda1bdb95fd --- /dev/null +++ b/test/sendable/builtins/Map/prototype/has/not-a-constructor.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableMap.prototype.has 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, SendableMap, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableMap.prototype.has), false, 'isConstructor(SendableMap.prototype.has) must return false'); + +assert.throws(TypeError, () => { + let m = new SendableMap(); new m.has(); +}); + diff --git a/test/sendable/builtins/Map/prototype/has/return-false-different-key-types.js b/test/sendable/builtins/Map/prototype/has/return-false-different-key-types.js new file mode 100644 index 00000000000..ab18d649a4a --- /dev/null +++ b/test/sendable/builtins/Map/prototype/has/return-false-different-key-types.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.has +description: > + Returns true for existing keys, using different key types. +info: | + SendableMap.prototype.has ( key ) + + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + i. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, + return true. + ... +features: [Symbol] +---*/ + +var map = new SendableMap(); + +assert.sameValue(map.has('str'), false); +assert.sameValue(map.has(1), false); +assert.sameValue(map.has(NaN), false); +assert.sameValue(map.has(true), false); +assert.sameValue(map.has(false), false); +assert.sameValue(map.has({}), false); +assert.sameValue(map.has([]), false); +assert.sameValue(map.has(Symbol()), false); +assert.sameValue(map.has(null), false); +assert.sameValue(map.has(undefined), false); diff --git a/test/sendable/builtins/Map/prototype/has/return-true-different-key-types.js b/test/sendable/builtins/Map/prototype/has/return-true-different-key-types.js new file mode 100644 index 00000000000..3ac9e7c6550 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/has/return-true-different-key-types.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.has +description: > + Returns true for existing keys, using different key types. +info: | + SendableMap.prototype.has ( key ) + + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + i. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, + return true. + ... +features: [Symbol] +---*/ + +var map = new SendableMap(); + +var obj = {}; +var arr = []; +var symb = Symbol(); + +map.set('str', undefined); +map.set(1, undefined); +map.set(NaN, undefined); +map.set(true, undefined); +map.set(false, undefined); +map.set(obj, undefined); +map.set(arr, undefined); +map.set(symb, undefined); +map.set(null, undefined); +map.set(undefined, undefined); + +assert.sameValue(map.has('str'), true); +assert.sameValue(map.has(1), true); +assert.sameValue(map.has(NaN), true); +assert.sameValue(map.has(true), true); +assert.sameValue(map.has(false), true); +assert.sameValue(map.has(obj), true); +assert.sameValue(map.has(arr), true); +assert.sameValue(map.has(symb), true); +assert.sameValue(map.has(null), true); +assert.sameValue(map.has(undefined), true); diff --git a/test/sendable/builtins/Map/prototype/has/this-not-object-throw.js b/test/sendable/builtins/Map/prototype/has/this-not-object-throw.js new file mode 100644 index 00000000000..8c1898b75f0 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/has/this-not-object-throw.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.has +description: > + Throws a TypeError if `this` is not an Object. +info: | + SendableMap.prototype.has ( key ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.has.call(false, 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.has.call(1, 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.has.call('', 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.has.call(undefined, 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.has.call(null, 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.has.call(Symbol(), 1); +}); + +assert.throws(TypeError, function() { + var map = new SendableMap(); + map.has.call(false, 1); +}); diff --git a/test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot-set.js b/test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot-set.js new file mode 100644 index 00000000000..783e0016ae0 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot-set.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.keys +description: > + Throws a TypeError if `this` is a Set object. +info: | + SendableMap.prototype.keys () + + 1. Let M be the this value. + 2. Return CreateSendableMapIterator(M, "key"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 2. If map does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.keys.call(new Set()); +}); + +assert.throws(TypeError, function() { + var m = new SendableMap(); + m.keys.call(new Set()); +}); diff --git a/test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot-weakmap.js new file mode 100644 index 00000000000..2ebc60fc8ab --- /dev/null +++ b/test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot-weakmap.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.keys +description: > + Throws a TypeError if `this` is a WeakSendableMap object. +info: | + SendableMap.prototype.keys () + + 1. Let M be the this value. + 2. Return CreateSendableMapIterator(M, "key"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 2. If map does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [WeakSendableMap] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.keys.call(new WeakSendableMap()); +}); + +assert.throws(TypeError, function() { + var m = new SendableMap(); + m.keys.call(new WeakSendableMap()); +}); diff --git a/test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot.js b/test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot.js new file mode 100644 index 00000000000..dbb50010471 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.keys +description: > + Throws a TypeError if `this` object does not have a [[SendableMapData]] internal slot. +info: | + SendableMap.prototype.keys () + + 1. Let M be the this value. + 2. Return CreateSendableMapIterator(M, "key"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 2. If map does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... + +---*/ + +var m = new SendableMap(); + +assert.throws(TypeError, function() { + SendableMap.prototype.keys.call([]); +}); + +assert.throws(TypeError, function() { + m.keys.call([]); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.keys.call({}); +}); + +assert.throws(TypeError, function() { + m.keys.call({}); +}); diff --git a/test/sendable/builtins/Map/prototype/keys/keys.js b/test/sendable/builtins/Map/prototype/keys/keys.js new file mode 100644 index 00000000000..c9bdc36447c --- /dev/null +++ b/test/sendable/builtins/Map/prototype/keys/keys.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.keys +description: > + Property type and descriptor. +info: | + SendableMap.prototype.keys () + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableMap.prototype.keys, + 'function', + '`typeof SendableMap.prototype.keys` is `function`' +); + +verifyProperty(SendableMap.prototype, 'keys', { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Map/prototype/keys/length.js b/test/sendable/builtins/Map/prototype/keys/length.js new file mode 100644 index 00000000000..24749029c9f --- /dev/null +++ b/test/sendable/builtins/Map/prototype/keys/length.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.keys +description: > + SendableMap.prototype.keys.length value and descriptor. +info: | + SendableMap.prototype.keys () + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.keys, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/keys/name.js b/test/sendable/builtins/Map/prototype/keys/name.js new file mode 100644 index 00000000000..26a1bb61894 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/keys/name.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.keys +description: > + SendableMap.prototype.keys.name value and descriptor. +info: | + SendableMap.prototype.keys () + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.keys, "name", { + value: "keys", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/keys/not-a-constructor.js b/test/sendable/builtins/Map/prototype/keys/not-a-constructor.js new file mode 100644 index 00000000000..bd97eb98248 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/keys/not-a-constructor.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableMap.prototype.keys 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, SendableMap, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableMap.prototype.keys), false, 'isConstructor(SendableMap.prototype.keys) must return false'); + +assert.throws(TypeError, () => { + let m = new SendableMap(); new m.keys(); +}); + diff --git a/test/sendable/builtins/Map/prototype/keys/returns-iterator-empty.js b/test/sendable/builtins/Map/prototype/keys/returns-iterator-empty.js new file mode 100644 index 00000000000..2d60bdfe656 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/keys/returns-iterator-empty.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.keys +description: > + Returns an iterator on an empty SendableMap object. +info: | + SendableMap.prototype.keys () + + ... + 2. Return CreateSendableMapIterator(M, "key"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 7. Return iterator. +---*/ + +var map = new SendableMap(); +var iterator = map.keys(); +var result = iterator.next(); + +assert.sameValue( + result.value, undefined, + 'The value of `result.value` is `undefined`' +); +assert.sameValue(result.done, true, 'The value of `result.done` is `true`'); diff --git a/test/sendable/builtins/Map/prototype/keys/returns-iterator.js b/test/sendable/builtins/Map/prototype/keys/returns-iterator.js new file mode 100644 index 00000000000..d8b3b9fde61 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/keys/returns-iterator.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.keys +description: > + Returns an iterator. +info: | + SendableMap.prototype.keys ( ) + + ... + 2. Return CreateSendableMapIterator(M, "key"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 7. Return iterator. +---*/ + +var obj = {}; +var map = new SendableMap(); +map.set('foo', 1); +map.set(obj, 2); +map.set(map, 3); + +var iterator = map.keys(); +var result; + +result = iterator.next(); +assert.sameValue(result.value, 'foo', 'First result `value` ("key")'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, obj, 'Second result `value` ("key")'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, map, 'Third result `value` ("key")'); +assert.sameValue(result.done, false, 'Third result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); + +result = iterator.next(); +assert.sameValue( + result.value, undefined, 'Exhausted result `value` (repeated request)' +); +assert.sameValue( + result.done, true, 'Exhausted result `done` flag (repeated request)' +); diff --git a/test/sendable/builtins/Map/prototype/keys/this-not-object-throw.js b/test/sendable/builtins/Map/prototype/keys/this-not-object-throw.js new file mode 100644 index 00000000000..62668bd895b --- /dev/null +++ b/test/sendable/builtins/Map/prototype/keys/this-not-object-throw.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.keys +description: > + Throws a TypeError if `this` is not an Object. +info: | + SendableMap.prototype.keys () + + ... + 2. Return CreateSendableMapIterator(M, "key"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + 1. If Type(map) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.keys.call(false); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.keys.call(1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.keys.call(''); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.keys.call(undefined); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.keys.call(null); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.keys.call(Symbol()); +}); + +assert.throws(TypeError, function() { + var map = new SendableMap(); + map.keys.call(false); +}); diff --git a/test/sendable/builtins/Map/prototype/set/append-new-values-normalizes-zero-key.js b/test/sendable/builtins/Map/prototype/set/append-new-values-normalizes-zero-key.js new file mode 100644 index 00000000000..6c3729b3787 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/set/append-new-values-normalizes-zero-key.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: > + Appends new value in the map normalizing +0 and -0. +info: | + SendableMap.prototype.set ( key , value ) + + ... + 6. If key is −0, let key be +0. + 7. Let p be the Record {[[key]]: key, [[value]]: value}. + 8. Append p as the last element of entries. + 9. Return M. + ... +---*/ + +var map = new SendableMap(); +map.set(-0, 42); + +assert.sameValue(map.get(0), 42); + +map = new SendableMap(); +map.set(+0, 43); +assert.sameValue(map.get(0), 43); diff --git a/test/sendable/builtins/Map/prototype/set/append-new-values-return-map.js b/test/sendable/builtins/Map/prototype/set/append-new-values-return-map.js new file mode 100644 index 00000000000..205147862e8 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/set/append-new-values-return-map.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: > + SendableMap.prototype.set returns the given `this` object. +info: | + SendableMap.prototype.set ( key , value ) + + ... + 6. If key is −0, let key be +0. + 7. Let p be the Record {[[key]]: key, [[value]]: value}. + 8. Append p as the last element of entries. + 9. Return M. + ... +---*/ + +var map = new SendableMap(); +var result = map.set(1, 1); + +assert.sameValue(result, map); + +result = map.set(1,1).set(2,2).set(3,3); + +assert.sameValue(result, map, 'SendableMap.prototype.set is chainable'); + +var map2 = new SendableMap(); +result = map2.set.call(map, 4, 4); + +assert.sameValue(result, map); diff --git a/test/sendable/builtins/Map/prototype/set/append-new-values.js b/test/sendable/builtins/Map/prototype/set/append-new-values.js new file mode 100644 index 00000000000..36b6531163a --- /dev/null +++ b/test/sendable/builtins/Map/prototype/set/append-new-values.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: > + Append a new value as the last element of entries. +info: | + SendableMap.prototype.set ( key , value ) + + ... + 6. If key is −0, let key be +0. + 7. Let p be the Record {[[key]]: key, [[value]]: value}. + 8. Append p as the last element of entries. + 9. Return M. + ... +features: [Symbol] +---*/ + +var s = Symbol(2); +var map = new SendableMap([[4, 4], ['foo3', 3], [s, 2]]); + +map.set(null, 42); +map.set(1, 'valid'); + +assert.sameValue(map.size, 5); +assert.sameValue(map.get(1), 'valid'); + +var results = []; + +map.forEach(function(value, key) { + results.push({ + value: value, + key: key + }); +}); + +var result = results.pop(); +assert.sameValue(result.value, 'valid'); +assert.sameValue(result.key, 1); + +result = results.pop(); +assert.sameValue(result.value, 42); +assert.sameValue(result.key, null); + +result = results.pop(); +assert.sameValue(result.value, 2); +assert.sameValue(result.key, s); diff --git a/test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot-set.js b/test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot-set.js new file mode 100644 index 00000000000..0d552e5d79c --- /dev/null +++ b/test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot-set.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: > + Throws a TypeError if `this` is a Set object. +info: | + SendableMap.prototype.set ( key , value ) + + ... + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.set.call(new Set(), 1, 1); +}); + +assert.throws(TypeError, function() { + var m = new SendableMap(); + m.set.call(new Set(), 1, 1); +}); diff --git a/test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot-weakmap.js new file mode 100644 index 00000000000..202f17b535c --- /dev/null +++ b/test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot-weakmap.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: > + Throws a TypeError if `this` is a WeakSendableMap object. +info: | + SendableMap.prototype.set ( key , value ) + + ... + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [WeakSendableMap] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.set.call(new WeakSendableMap(), 1, 1); +}); + +assert.throws(TypeError, function() { + var m = new SendableMap(); + m.set.call(new WeakSendableMap(), 1, 1); +}); diff --git a/test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot.js b/test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot.js new file mode 100644 index 00000000000..1f459791cf1 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: > + Throws a TypeError if `this` object does not have a [[SendableMapData]] internal slot. +info: | + SendableMap.prototype.set ( key , value ) + + ... + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +---*/ + +var m = new SendableMap(); + +assert.throws(TypeError, function() { + SendableMap.prototype.set.call([], 1, 1); +}); + +assert.throws(TypeError, function() { + m.set.call([], 1, 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.set.call({}, 1, 1); +}); + +assert.throws(TypeError, function() { + m.set.call({}, 1, 1); +}); diff --git a/test/sendable/builtins/Map/prototype/set/length.js b/test/sendable/builtins/Map/prototype/set/length.js new file mode 100644 index 00000000000..26c85d5c9d9 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/set/length.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: > + SendableMap.prototype.set.length value and descriptor. +info: | + SendableMap.prototype.set ( key , value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.set, "length", { + value: 2, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/set/name.js b/test/sendable/builtins/Map/prototype/set/name.js new file mode 100644 index 00000000000..15f44965f1c --- /dev/null +++ b/test/sendable/builtins/Map/prototype/set/name.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: > + SendableMap.prototype.set.name value and descriptor. +info: | + SendableMap.prototype.set ( key , value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.set, "name", { + value: "set", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/set/not-a-constructor.js b/test/sendable/builtins/Map/prototype/set/not-a-constructor.js new file mode 100644 index 00000000000..bbf5c4b383e --- /dev/null +++ b/test/sendable/builtins/Map/prototype/set/not-a-constructor.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableMap.prototype.set 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, SendableMap, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableMap.prototype.set), false, 'isConstructor(SendableMap.prototype.set) must return false'); + +assert.throws(TypeError, () => { + let m = new SendableMap(); new m.set(); +}); + diff --git a/test/sendable/builtins/Map/prototype/set/replaces-a-value-normalizes-zero-key.js b/test/sendable/builtins/Map/prototype/set/replaces-a-value-normalizes-zero-key.js new file mode 100644 index 00000000000..4ebf32d5ef8 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/set/replaces-a-value-normalizes-zero-key.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: > + Replaces a value in the map normalizing +0 and -0. +info: | + SendableMap.prototype.set ( key , value ) + + ... + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, then + i. Set p.[[value]] to value. + ii. Return M. + ... +---*/ + +var map = new SendableMap([[+0, 1]]); + +map.set(-0, 42); +assert.sameValue(map.get(+0), 42, 'zero key is normalized in SameValueZero'); + +map = new SendableMap([[-0, 1]]); +map.set(+0, 42); +assert.sameValue(map.get(-0), 42, 'zero key is normalized in SameValueZero'); diff --git a/test/sendable/builtins/Map/prototype/set/replaces-a-value-returns-map.js b/test/sendable/builtins/Map/prototype/set/replaces-a-value-returns-map.js new file mode 100644 index 00000000000..4f478bbefa8 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/set/replaces-a-value-returns-map.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: > + SendableMap.prototype.set returns the given `this` map object. +info: | + SendableMap.prototype.set ( key , value ) + + 1. Let M be the this value. + ... + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, then + i. Set p.[[value]] to value. + ii. Return M. + ... +---*/ + +var map = new SendableMap([['item', 0]]); +var map2 = new SendableMap(); + +var x = map.set('item', 42); +assert.sameValue(x, map); + +x = SendableMap.prototype.set.call(map, 'item', 0); +assert.sameValue(x, map); + +x = map2.set.call(map, 'item', 0); +assert.sameValue(x, map, 'SendableMap#set returns the map `this` value'); diff --git a/test/sendable/builtins/Map/prototype/set/replaces-a-value.js b/test/sendable/builtins/Map/prototype/set/replaces-a-value.js new file mode 100644 index 00000000000..e4bde7fc472 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/set/replaces-a-value.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: > + Replaces a value in the map. +info: | + SendableMap.prototype.set ( key , value ) + + ... + 5. Repeat for each Record {[[key]], [[value]]} p that is an element of + entries, + a. If p.[[key]] is not empty and SameValueZero(p.[[key]], key) is true, then + i. Set p.[[value]] to value. + ii. Return M. + ... +---*/ + +var m = new SendableMap([['item', 1]]); + +m.set('item', 42); +assert.sameValue(m.get('item'), 42); +assert.sameValue(m.size, 1); diff --git a/test/sendable/builtins/Map/prototype/set/set.js b/test/sendable/builtins/Map/prototype/set/set.js new file mode 100644 index 00000000000..b709714aa46 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/set/set.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: > + Property type and descriptor. +info: | + SendableMap.prototype.set ( key , value ) + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableMap.prototype.set, + 'function', + '`typeof SendableMap.prototype.set` is `function`' +); + +verifyProperty(SendableMap.prototype, 'set', { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Map/prototype/set/this-not-object-throw.js b/test/sendable/builtins/Map/prototype/set/this-not-object-throw.js new file mode 100644 index 00000000000..7f7d698b846 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/set/this-not-object-throw.js @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: > + Throws a TypeError if `this` is not an Object. +info: | + SendableMap.prototype.set ( key , value ) + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.set.call(false, 1, 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.set.call(1, 1, 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.set.call('', 1, 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.set.call(undefined, 1, 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.set.call(null, 1, 1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.set.call(Symbol(), 1, 1); +}); + +assert.throws(TypeError, function() { + var map = new SendableMap(); + map.set.call(false, 1, 1); +}); diff --git a/test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot-set.js b/test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot-set.js new file mode 100644 index 00000000000..67867be1c8a --- /dev/null +++ b/test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot-set.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-map.prototype.size +description: > + Throws a TypeError if `this` is a Set object. +info: | + ... + If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(SendableMap.prototype, 'size'); + +var map = new SendableMap(); + +// Does not throw +descriptor.get.call(map); + +assert.throws(TypeError, function() { + descriptor.get.call(new Set()); +}); diff --git a/test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot-weakmap.js new file mode 100644 index 00000000000..21caf773df1 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot-weakmap.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-map.prototype.size +description: > + Throws a TypeError if `this` is a WeakSendableMap object. +info: | + get SendableMap.prototype.size + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [WeakSendableMap] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(SendableMap.prototype, 'size'); + +var map = new SendableMap(); + +// Does not throw +descriptor.get.call(map); + +assert.throws(TypeError, function() { + descriptor.get.call(new WeakSendableMap()); +}); diff --git a/test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot.js b/test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot.js new file mode 100644 index 00000000000..33bf4729799 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-map.prototype.size +description: > + Throws a TypeError if `this` object does not have a [[SendableMapData]] internal slot. +info: | + get SendableMap.prototype.size + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(SendableMap.prototype, 'size'); + +var map = new SendableMap(); + +// Does not throw +descriptor.get.call(map); + +assert.throws(TypeError, function() { + descriptor.get.call([]); +}); diff --git a/test/sendable/builtins/Map/prototype/size/length.js b/test/sendable/builtins/Map/prototype/size/length.js new file mode 100644 index 00000000000..2eb39918dea --- /dev/null +++ b/test/sendable/builtins/Map/prototype/size/length.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-map.prototype.size +description: > + SendableMap.prototype.size.length value and descriptor. +info: | + get SendableMap.prototype.size + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(SendableMap.prototype, 'size'); + +verifyProperty(descriptor.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/size/name.js b/test/sendable/builtins/Map/prototype/size/name.js new file mode 100644 index 00000000000..997beab4b48 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/size/name.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-map.prototype.size +description: > + SendableMap.prototype.size.name value and descriptor. +info: | + get SendableMap.prototype.size + + 17 ECMAScript Standard Built-in Objects + + Functions that are specified as get or set accessor functions of built-in + properties have "get " or "set " prepended to the property name string. + +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(SendableMap.prototype, 'size'); + +verifyProperty(descriptor.get, "name", { + value: "get size", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-before-after-set-clear.js b/test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-before-after-set-clear.js new file mode 100644 index 00000000000..bdeecc09abe --- /dev/null +++ b/test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-before-after-set-clear.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-map.prototype.size +description: > + Returns count of present values before and after using `set` and `clear`. +info: | + get SendableMap.prototype.size + + 5. Let count be 0. + 6. For each Record {[[key]], [[value]]} p that is an element of entries + a. If p.[[key]] is not empty, set count to count+1. +---*/ + +var map = new SendableMap(); + +assert.sameValue(map.size, 0, 'The value of `map.size` is `0`'); + +map.set(1, 1); +map.set(2, 2); +assert.sameValue( + map.size, 2, + 'The value of `map.size` is `2`' +); + +map.clear(); +assert.sameValue( + map.size, 0, + 'The value of `map.size` is `0`, after executing `map.clear()`' +); diff --git a/test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-before-after-set-delete.js b/test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-before-after-set-delete.js new file mode 100644 index 00000000000..48146f9be30 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-before-after-set-delete.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-map.prototype.size +description: > + Returns count of present values before and after using `set` and `delete`. +info: | + get SendableMap.prototype.size + + 5. Let count be 0. + 6. For each Record {[[key]], [[value]]} p that is an element of entries + a. If p.[[key]] is not empty, set count to count+1. +---*/ + +var map = new SendableMap(); + +assert.sameValue(map.size, 0, 'The value of `map.size` is `0`'); + +map.set(1, 1); +assert.sameValue( + map.size, 1, + 'The value of `map.size` is `1`, after executing `map.set(1, 1)`' +); + +map.delete(1); +assert.sameValue( + map.size, 0, + 'The value of `map.size` is `0`, after executing `map.delete(1)`' +); diff --git a/test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-by-insertion.js b/test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-by-insertion.js new file mode 100644 index 00000000000..10de04d7718 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-by-insertion.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-map.prototype.size +description: > + Returns count of present values inserted with set. +info: | + get SendableMap.prototype.size + + 5. Let count be 0. + 6. For each Record {[[key]], [[value]]} p that is an element of entries + a. If p.[[key]] is not empty, set count to count+1. +features: [Symbol] +---*/ + +var map = new SendableMap(); + +map.set(0, undefined); +map.set(undefined, undefined); +map.set(false, undefined); +map.set(NaN, undefined); +map.set(null, undefined); +map.set('', undefined); +map.set(Symbol(), undefined); + +assert.sameValue(map.size, 7, 'The value of `map.size` is `7`'); diff --git a/test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-by-iterable.js b/test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-by-iterable.js new file mode 100644 index 00000000000..2babd5c5c8d --- /dev/null +++ b/test/sendable/builtins/Map/prototype/size/returns-count-of-present-values-by-iterable.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-map.prototype.size +description: > + Returns count of present values inserted via iterable argument. +info: | + get SendableMap.prototype.size + + 5. Let count be 0. + 6. For each Record {[[key]], [[value]]} p that is an element of entries + a. If p.[[key]] is not empty, set count to count+1. +features: [Symbol] +---*/ + +var map = new SendableMap([ + [0, undefined], + [undefined, undefined], + [false, undefined], + [NaN, undefined], + [null, undefined], + ['', undefined], + [Symbol(), undefined], +]); + +assert.sameValue(map.size, 7, 'The value of `map.size` is `7`'); diff --git a/test/sendable/builtins/Map/prototype/size/size.js b/test/sendable/builtins/Map/prototype/size/size.js new file mode 100644 index 00000000000..87364b92895 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/size/size.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-map.prototype.size +description: > + Property type and descriptor. +info: | + get SendableMap.prototype.size + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(SendableMap.prototype, 'size'); + +assert.sameValue( + typeof descriptor.get, + 'function', + 'typeof descriptor.get is function' +); +assert.sameValue( + typeof descriptor.set, + 'undefined', + 'typeof descriptor.set is undefined' +); + +verifyNotEnumerable(SendableMap.prototype, 'size'); +verifyConfigurable(SendableMap.prototype, 'size'); diff --git a/test/sendable/builtins/Map/prototype/size/this-not-object-throw.js b/test/sendable/builtins/Map/prototype/size/this-not-object-throw.js new file mode 100644 index 00000000000..4328211821a --- /dev/null +++ b/test/sendable/builtins/Map/prototype/size/this-not-object-throw.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-map.prototype.size +description: > + Throws a TypeError if `this` is not an Object. +info: | + get SendableMap.prototype.size + + 1. Let M be the this value. + 2. If Type(M) is not Object, throw a TypeError exception. + 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... + +features: [Symbol] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(SendableMap.prototype, 'size'); + +assert.throws(TypeError, function() { + descriptor.get.call(1); +}); + +assert.throws(TypeError, function() { + descriptor.get.call(false); +}); + +assert.throws(TypeError, function() { + descriptor.get.call(1); +}); + +assert.throws(TypeError, function() { + descriptor.get.call(''); +}); + +assert.throws(TypeError, function() { + descriptor.get.call(undefined); +}); + +assert.throws(TypeError, function() { + descriptor.get.call(null); +}); + +assert.throws(TypeError, function() { + descriptor.get.call(Symbol()); +}); diff --git a/test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot-set.js b/test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot-set.js new file mode 100644 index 00000000000..a9011bd191d --- /dev/null +++ b/test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot-set.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.values +description: > + Throws a TypeError if `this` is a Set object. +info: | + SendableMap.prototype.values () + + 1. Let M be the this value. + 2. Return CreateSendableMapIterator(M, "value"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 2. If map does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [Set] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.values.call(new Set()); +}); + +assert.throws(TypeError, function() { + var m = new SendableMap(); + m.values.call(new Set()); +}); diff --git a/test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot-weakmap.js new file mode 100644 index 00000000000..7f9b93b8dc4 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot-weakmap.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.values +description: > + Throws a TypeError if `this` is a WeakSendableMap object. +info: | + SendableMap.prototype.values () + + 1. Let M be the this value. + 2. Return CreateSendableMapIterator(M, "value"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 2. If map does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... +features: [WeakSendableMap] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.values.call(new WeakSendableMap()); +}); + +assert.throws(TypeError, function() { + var m = new SendableMap(); + m.values.call(new WeakSendableMap()); +}); diff --git a/test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot.js b/test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot.js new file mode 100644 index 00000000000..5c313fc3a12 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.values +description: > + Throws a TypeError if `this` object does not have a [[SendableMapData]] internal slot. +info: | + SendableMap.prototype.values () + + 1. Let M be the this value. + 2. Return CreateSendableMapIterator(M, "value"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 2. If map does not have a [[SendableMapData]] internal slot, throw a TypeError + exception. + ... + +---*/ + +var m = new SendableMap(); + +assert.throws(TypeError, function() { + SendableMap.prototype.values.call([]); +}); + +assert.throws(TypeError, function() { + m.values.call([]); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.values.call({}); +}); + +assert.throws(TypeError, function() { + m.values.call({}); +}); diff --git a/test/sendable/builtins/Map/prototype/values/length.js b/test/sendable/builtins/Map/prototype/values/length.js new file mode 100644 index 00000000000..751ddcbfb13 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/values/length.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.values +description: > + SendableMap.prototype.values.length value and descriptor. +info: | + SendableMap.prototype.values () + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.values, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/values/name.js b/test/sendable/builtins/Map/prototype/values/name.js new file mode 100644 index 00000000000..a5b90a5f9b1 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/values/name.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.values +description: > + SendableMap.prototype.values.name value and descriptor. +info: | + SendableMap.prototype.values () + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableMap.prototype.values, "name", { + value: "values", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Map/prototype/values/not-a-constructor.js b/test/sendable/builtins/Map/prototype/values/not-a-constructor.js new file mode 100644 index 00000000000..9a07dcacfec --- /dev/null +++ b/test/sendable/builtins/Map/prototype/values/not-a-constructor.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableMap.prototype.values 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, SendableMap, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableMap.prototype.values), false, 'isConstructor(SendableMap.prototype.values) must return false'); + +assert.throws(TypeError, () => { + let m = new SendableMap(); new m.values(); +}); + diff --git a/test/sendable/builtins/Map/prototype/values/returns-iterator-empty.js b/test/sendable/builtins/Map/prototype/values/returns-iterator-empty.js new file mode 100644 index 00000000000..4c5fc2efa81 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/values/returns-iterator-empty.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.values +description: > + Returns an iterator on an empty SendableMap object. +info: | + SendableMap.prototype.values () + + ... + 2. Return CreateSendableMapIterator(M, "value"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 7. Return iterator. +---*/ + +var map = new SendableMap(); +var iterator = map.values(); +var result = iterator.next(); + +assert.sameValue( + result.value, undefined, + 'The value of `result.value` is `undefined`' +); +assert.sameValue(result.done, true, 'The value of `result.done` is `true`'); diff --git a/test/sendable/builtins/Map/prototype/values/returns-iterator.js b/test/sendable/builtins/Map/prototype/values/returns-iterator.js new file mode 100644 index 00000000000..f6797acc54d --- /dev/null +++ b/test/sendable/builtins/Map/prototype/values/returns-iterator.js @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.values +description: > + Returns an iterator. +info: | + SendableMap.prototype.values ( ) + + ... + 2. Return CreateSendableMapIterator(M, "value"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + ... + 7. Return iterator. +---*/ + +var obj = {}; +var map = new SendableMap(); +map.set(1, 'foo'); +map.set(2, obj); +map.set(3, map); + +var iterator = map.values(); +var result; + +result = iterator.next(); +assert.sameValue(result.value, 'foo', 'First result `value` ("value")'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, obj, 'Second result `value` ("value")'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, map, 'Third result `value` ("value")'); +assert.sameValue(result.done, false, 'Third result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); + +result = iterator.next(); +assert.sameValue( + result.value, undefined, 'Exhausted result `value` (repeated request)' +); +assert.sameValue( + result.done, true, 'Exhausted result `done` flag (repeated request)' +); diff --git a/test/sendable/builtins/Map/prototype/values/this-not-object-throw.js b/test/sendable/builtins/Map/prototype/values/this-not-object-throw.js new file mode 100644 index 00000000000..114688ec056 --- /dev/null +++ b/test/sendable/builtins/Map/prototype/values/this-not-object-throw.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.values +description: > + Throws a TypeError if `this` is not an Object. +info: | + SendableMap.prototype.values () + + ... + 2. Return CreateSendableMapIterator(M, "values"). + + 23.1.5.1 CreateSendableMapIterator Abstract Operation + + 1. If Type(map) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableMap.prototype.values.call(false); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.values.call(1); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.values.call(''); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.values.call(undefined); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.values.call(null); +}); + +assert.throws(TypeError, function() { + SendableMap.prototype.values.call(Symbol()); +}); + +assert.throws(TypeError, function() { + var map = new SendableMap(); + map.values.call(false); +}); diff --git a/test/sendable/builtins/Map/prototype/values/values.js b/test/sendable/builtins/Map/prototype/values/values.js new file mode 100644 index 00000000000..722459650eb --- /dev/null +++ b/test/sendable/builtins/Map/prototype/values/values.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.values +description: > + Property type and descriptor. +info: | + SendableMap.prototype.values () + + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableMap.prototype.values, + 'function', + '`typeof SendableMap.prototype.values` is `function`' +); + +verifyProperty(SendableMap.prototype, 'values', { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Map/undefined-newtarget.js b/test/sendable/builtins/Map/undefined-newtarget.js new file mode 100644 index 00000000000..581cba4cc41 --- /dev/null +++ b/test/sendable/builtins/Map/undefined-newtarget.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map-iterable +description: > + Throws a TypeError if SendableMap is called without a newTarget. +info: | + SendableMap ( [ iterable ] ) + + When the SendableMap function is called with optional argument the following steps + are taken: + + 1. If NewTarget is undefined, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableMap(); +}); + +assert.throws(TypeError, function() { + SendableMap([]); +}); diff --git a/test/sendable/builtins/Map/valid-keys.js b/test/sendable/builtins/Map/valid-keys.js new file mode 100644 index 00000000000..7e018757907 --- /dev/null +++ b/test/sendable/builtins/Map/valid-keys.js @@ -0,0 +1,496 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-map.prototype.set +description: Observing the expected behavior of valid keys +info: | + SendableMap.prototype.set ( key , value ) + + ... + Let p be the Record {[[key]]: key, [[value]]: value}. + Append p as the last element of entries. + ... + +features: [BigInt, Symbol, TypedArray, WeakRef, exponentiation] +---*/ + + +const negativeZero = -0; +const positiveZero = +0; +const zero = 0; +const one = 1; +const twoRaisedToFiftyThreeMinusOne = 2 ** 53 - 1; +const int32Array = new Int32Array([zero, one]); +const uint32Array = new Uint32Array([zero, one]); +const n = 100000000000000000000000000000000000000000000000000000000000000000000000000000000001n; +const bigInt = BigInt('100000000000000000000000000000000000000000000000000000000000000000000000000000000001'); +const n1 = 1n; +const n53 = 9007199254740991n; +const fiftyThree = BigInt('9007199254740991'); +const bigInt64Array = new BigInt64Array([n1, n53]); +const bigUint64Array = new BigUint64Array([n1, n53]); +const symbol = Symbol(''); +const object = {}; +const array = []; +const string = ''; +const booleanTrue = true; +const booleanFalse = true; +const functionExprValue = function() {}; +const arrowFunctionValue = () => {}; +const classValue = class {}; +const map = new SendableMap(); +const set = new Set(); +const weakSendableMap = new WeakSendableMap(); +const weakRef = new WeakRef({}); +const weakSet = new WeakSet(); +const nullValue = null; +const undefinedValue = undefined; +let unassigned; + +{ + const m = new SendableMap([[negativeZero, negativeZero]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(negativeZero), true); + assert.sameValue(m.get(negativeZero), negativeZero); + m.delete(negativeZero); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(negativeZero), false); + m.set(negativeZero, negativeZero); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(negativeZero), true); + assert.sameValue(m.get(negativeZero), negativeZero); +}; + +{ + const m = new SendableMap([[positiveZero, positiveZero]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(positiveZero), true); + assert.sameValue(m.get(positiveZero), positiveZero); + m.delete(positiveZero); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(positiveZero), false); + m.set(positiveZero, positiveZero); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(positiveZero), true); + assert.sameValue(m.get(positiveZero), positiveZero); +}; + +{ + const m = new SendableMap([[zero, zero]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(zero), true); + assert.sameValue(m.get(zero), zero); + m.delete(zero); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(zero), false); + m.set(zero, zero); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(zero), true); + assert.sameValue(m.get(zero), zero); +}; + +{ + const m = new SendableMap([[one, one]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(one), true); + assert.sameValue(m.get(one), one); + m.delete(one); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(one), false); + m.set(one, one); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(one), true); + assert.sameValue(m.get(one), one); +}; + +{ + const m = new SendableMap([[twoRaisedToFiftyThreeMinusOne, twoRaisedToFiftyThreeMinusOne]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(twoRaisedToFiftyThreeMinusOne), true); + assert.sameValue(m.get(twoRaisedToFiftyThreeMinusOne), twoRaisedToFiftyThreeMinusOne); + m.delete(twoRaisedToFiftyThreeMinusOne); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(twoRaisedToFiftyThreeMinusOne), false); + m.set(twoRaisedToFiftyThreeMinusOne, twoRaisedToFiftyThreeMinusOne); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(twoRaisedToFiftyThreeMinusOne), true); + assert.sameValue(m.get(twoRaisedToFiftyThreeMinusOne), twoRaisedToFiftyThreeMinusOne); +}; + +{ + const m = new SendableMap([[int32Array, int32Array]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(int32Array), true); + assert.sameValue(m.get(int32Array), int32Array); + m.delete(int32Array); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(int32Array), false); + m.set(int32Array, int32Array); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(int32Array), true); + assert.sameValue(m.get(int32Array), int32Array); +}; + +{ + const m = new SendableMap([[uint32Array, uint32Array]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(uint32Array), true); + assert.sameValue(m.get(uint32Array), uint32Array); + m.delete(uint32Array); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(uint32Array), false); + m.set(uint32Array, uint32Array); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(uint32Array), true); + assert.sameValue(m.get(uint32Array), uint32Array); +}; + +{ + const m = new SendableMap([[n, n]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(n), true); + assert.sameValue(m.get(n), n); + m.delete(n); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(n), false); + m.set(n, n); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(n), true); + assert.sameValue(m.get(n), n); +}; + +{ + const m = new SendableMap([[bigInt, bigInt]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(bigInt), true); + assert.sameValue(m.get(bigInt), bigInt); + m.delete(bigInt); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(bigInt), false); + m.set(bigInt, bigInt); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(bigInt), true); + assert.sameValue(m.get(bigInt), bigInt); +}; + +{ + const m = new SendableMap([[n1, n1]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(n1), true); + assert.sameValue(m.get(n1), n1); + m.delete(n1); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(n1), false); + m.set(n1, n1); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(n1), true); + assert.sameValue(m.get(n1), n1); +}; + +{ + const m = new SendableMap([[n53, n53]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(n53), true); + assert.sameValue(m.get(n53), n53); + m.delete(n53); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(n53), false); + m.set(n53, n53); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(n53), true); + assert.sameValue(m.get(n53), n53); +}; + +{ + const m = new SendableMap([[fiftyThree, fiftyThree]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(fiftyThree), true); + assert.sameValue(m.get(fiftyThree), fiftyThree); + m.delete(fiftyThree); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(fiftyThree), false); + m.set(fiftyThree, fiftyThree); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(fiftyThree), true); + assert.sameValue(m.get(fiftyThree), fiftyThree); +}; + +{ + const m = new SendableMap([[bigInt64Array, bigInt64Array]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(bigInt64Array), true); + assert.sameValue(m.get(bigInt64Array), bigInt64Array); + m.delete(bigInt64Array); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(bigInt64Array), false); + m.set(bigInt64Array, bigInt64Array); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(bigInt64Array), true); + assert.sameValue(m.get(bigInt64Array), bigInt64Array); +}; + +{ + const m = new SendableMap([[bigUint64Array, bigUint64Array]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(bigUint64Array), true); + assert.sameValue(m.get(bigUint64Array), bigUint64Array); + m.delete(bigUint64Array); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(bigUint64Array), false); + m.set(bigUint64Array, bigUint64Array); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(bigUint64Array), true); + assert.sameValue(m.get(bigUint64Array), bigUint64Array); +}; + +{ + const m = new SendableMap([[symbol, symbol]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(symbol), true); + assert.sameValue(m.get(symbol), symbol); + m.delete(symbol); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(symbol), false); + m.set(symbol, symbol); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(symbol), true); + assert.sameValue(m.get(symbol), symbol); +}; + +{ + const m = new SendableMap([[object, object]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(object), true); + assert.sameValue(m.get(object), object); + m.delete(object); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(object), false); + m.set(object, object); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(object), true); + assert.sameValue(m.get(object), object); +}; + +{ + const m = new SendableMap([[array, array]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(array), true); + assert.sameValue(m.get(array), array); + m.delete(array); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(array), false); + m.set(array, array); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(array), true); + assert.sameValue(m.get(array), array); +}; + +{ + const m = new SendableMap([[string, string]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(string), true); + assert.sameValue(m.get(string), string); + m.delete(string); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(string), false); + m.set(string, string); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(string), true); + assert.sameValue(m.get(string), string); +}; + +{ + const m = new SendableMap([[booleanTrue, booleanTrue]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(booleanTrue), true); + assert.sameValue(m.get(booleanTrue), booleanTrue); + m.delete(booleanTrue); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(booleanTrue), false); + m.set(booleanTrue, booleanTrue); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(booleanTrue), true); + assert.sameValue(m.get(booleanTrue), booleanTrue); +}; + +{ + const m = new SendableMap([[booleanFalse, booleanFalse]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(booleanFalse), true); + assert.sameValue(m.get(booleanFalse), booleanFalse); + m.delete(booleanFalse); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(booleanFalse), false); + m.set(booleanFalse, booleanFalse); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(booleanFalse), true); + assert.sameValue(m.get(booleanFalse), booleanFalse); +}; + +{ + const m = new SendableMap([[functionExprValue, functionExprValue]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(functionExprValue), true); + assert.sameValue(m.get(functionExprValue), functionExprValue); + m.delete(functionExprValue); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(functionExprValue), false); + m.set(functionExprValue, functionExprValue); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(functionExprValue), true); + assert.sameValue(m.get(functionExprValue), functionExprValue); +}; + +{ + const m = new SendableMap([[arrowFunctionValue, arrowFunctionValue]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(arrowFunctionValue), true); + assert.sameValue(m.get(arrowFunctionValue), arrowFunctionValue); + m.delete(arrowFunctionValue); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(arrowFunctionValue), false); + m.set(arrowFunctionValue, arrowFunctionValue); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(arrowFunctionValue), true); + assert.sameValue(m.get(arrowFunctionValue), arrowFunctionValue); +}; + +{ + const m = new SendableMap([[classValue, classValue]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(classValue), true); + assert.sameValue(m.get(classValue), classValue); + m.delete(classValue); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(classValue), false); + m.set(classValue, classValue); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(classValue), true); + assert.sameValue(m.get(classValue), classValue); +}; + +{ + const m = new SendableMap([[map, map]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(map), true); + assert.sameValue(m.get(map), map); + m.delete(map); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(map), false); + m.set(map, map); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(map), true); + assert.sameValue(m.get(map), map); +}; + +{ + const m = new SendableMap([[set, set]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(set), true); + assert.sameValue(m.get(set), set); + m.delete(set); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(set), false); + m.set(set, set); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(set), true); + assert.sameValue(m.get(set), set); +}; + +{ + const m = new SendableMap([[weakSendableMap, weakSendableMap]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(weakSendableMap), true); + assert.sameValue(m.get(weakSendableMap), weakSendableMap); + m.delete(weakSendableMap); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(weakSendableMap), false); + m.set(weakSendableMap, weakSendableMap); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(weakSendableMap), true); + assert.sameValue(m.get(weakSendableMap), weakSendableMap); +}; + +{ + const m = new SendableMap([[weakRef, weakRef]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(weakRef), true); + assert.sameValue(m.get(weakRef), weakRef); + m.delete(weakRef); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(weakRef), false); + m.set(weakRef, weakRef); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(weakRef), true); + assert.sameValue(m.get(weakRef), weakRef); +}; + +{ + const m = new SendableMap([[weakSet, weakSet]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(weakSet), true); + assert.sameValue(m.get(weakSet), weakSet); + m.delete(weakSet); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(weakSet), false); + m.set(weakSet, weakSet); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(weakSet), true); + assert.sameValue(m.get(weakSet), weakSet); +}; + +{ + const m = new SendableMap([[nullValue, nullValue]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(nullValue), true); + assert.sameValue(m.get(nullValue), nullValue); + m.delete(nullValue); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(nullValue), false); + m.set(nullValue, nullValue); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(nullValue), true); + assert.sameValue(m.get(nullValue), nullValue); +}; + +{ + const m = new SendableMap([[undefinedValue, undefinedValue]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(undefinedValue), true); + assert.sameValue(m.get(undefinedValue), undefinedValue); + m.delete(undefinedValue); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(undefinedValue), false); + m.set(undefinedValue, undefinedValue); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(undefinedValue), true); + assert.sameValue(m.get(undefinedValue), undefinedValue); +}; + +{ + const m = new SendableMap([[unassigned, unassigned]]); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(unassigned), true); + assert.sameValue(m.get(unassigned), unassigned); + m.delete(unassigned); + assert.sameValue(m.size, 0); + assert.sameValue(m.has(unassigned), false); + m.set(unassigned, unassigned); + assert.sameValue(m.size, 1); + assert.sameValue(m.has(unassigned), true); + assert.sameValue(m.get(unassigned), unassigned); +}; + -- Gitee From ad40c3d31dcb1268a3c9d1ef73f4f54de495c7e0 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Mon, 6 Jan 2025 09:43:35 +0800 Subject: [PATCH 75/93] set Signed-off-by: zhuzhihui7 --- .../clear/context-is-weakmap-object-throws.js | 6 +- .../context-is-weakmap-object-throws.js | 6 +- ...-not-have-mapdata-internal-slot-weakmap.js | 8 +- ...-not-have-mapdata-internal-slot-weakmap.js | 8 +- ...-not-have-mapdata-internal-slot-weakmap.js | 8 +- ...-not-have-mapdata-internal-slot-weakmap.js | 8 +- ...-not-have-mapdata-internal-slot-weakmap.js | 8 +- ...-not-have-mapdata-internal-slot-weakmap.js | 8 +- ...-not-have-mapdata-internal-slot-weakmap.js | 6 +- ...-not-have-mapdata-internal-slot-weakmap.js | 8 +- test/sendable/builtins/Map/valid-keys.js | 18 +- .../builtins/Set/Symbol.species/length.js | 45 ++ .../Set/Symbol.species/return-value.js | 27 ++ .../Set/Symbol.species/symbol-species-name.js | 33 ++ .../Set/Symbol.species/symbol-species.js | 33 ++ .../builtins/Set/bigint-number-same-value.js | 57 +++ test/sendable/builtins/Set/constructor.js | 23 + .../sendable/builtins/Set/is-a-constructor.js | 36 ++ test/sendable/builtins/Set/length.js | 31 ++ test/sendable/builtins/Set/name.js | 31 ++ .../properties-of-the-set-prototype-object.js | 30 ++ .../builtins/Set/proto-from-ctor-realm.js | 42 ++ .../sendable/builtins/Set/prototype-of-set.js | 27 ++ .../builtins/Set/prototype/Symbol.iterator.js | 34 ++ .../Symbol.iterator/not-a-constructor.js | 45 ++ .../Set/prototype/Symbol.toStringTag.js | 36 ++ .../Symbol.toStringTag/property-descriptor.js | 37 ++ .../builtins/Set/prototype/add/add.js | 36 ++ ...es-not-have-setdata-internal-slot-array.js | 34 ++ ...does-not-have-setdata-internal-slot-map.js | 34 ++ ...s-not-have-setdata-internal-slot-object.js | 34 ++ ...ave-setdata-internal-slot-set-prototype.js | 34 ++ ...-not-have-setdata-internal-slot-weakset.js | 34 ++ .../builtins/Set/prototype/add/length.js | 31 ++ .../builtins/Set/prototype/add/name.js | 31 ++ .../Set/prototype/add/not-a-constructor.js | 41 ++ .../add/preserves-insertion-order.js | 35 ++ .../returns-this-when-ignoring-duplicate.js | 32 ++ .../Set/prototype/add/returns-this.js | 29 ++ .../add/this-not-object-throw-boolean.js | 33 ++ .../add/this-not-object-throw-null.js | 33 ++ .../add/this-not-object-throw-number.js | 33 ++ .../add/this-not-object-throw-string.js | 33 ++ .../add/this-not-object-throw-symbol.js | 34 ++ .../add/this-not-object-throw-undefined.js | 33 ++ ...ot-add-duplicate-entry-initial-iterable.js | 38 ++ ...not-add-duplicate-entry-normalizes-zero.js | 42 ++ .../add/will-not-add-duplicate-entry.js | 39 ++ .../builtins/Set/prototype/clear/clear.js | 36 ++ .../clears-all-contents-from-iterable.js | 39 ++ .../prototype/clear/clears-all-contents.js | 41 ++ .../prototype/clear/clears-an-empty-set.js | 34 ++ ...es-not-have-setdata-internal-slot-array.js | 34 ++ ...does-not-have-setdata-internal-slot-map.js | 34 ++ ...s-not-have-setdata-internal-slot-object.js | 34 ++ ...ave-setdata-internal-slot-set.prototype.js | 34 ++ ...-not-have-setdata-internal-slot-weakset.js | 34 ++ .../builtins/Set/prototype/clear/length.js | 31 ++ .../builtins/Set/prototype/clear/name.js | 31 ++ .../Set/prototype/clear/not-a-constructor.js | 41 ++ .../Set/prototype/clear/returns-undefined.js | 28 ++ .../clear/this-not-object-throw-boolean.js | 33 ++ .../clear/this-not-object-throw-null.js | 33 ++ .../clear/this-not-object-throw-number.js | 33 ++ .../clear/this-not-object-throw-string.js | 33 ++ .../clear/this-not-object-throw-symbol.js | 34 ++ .../clear/this-not-object-throw-undefined.js | 33 ++ .../set-prototype-constructor-intrinsic.js | 29 ++ .../constructor/set-prototype-constructor.js | 30 ++ .../delete/delete-entry-initial-iterable.js | 39 ++ .../delete/delete-entry-normalizes-zero.js | 38 ++ .../Set/prototype/delete/delete-entry.js | 43 ++ .../builtins/Set/prototype/delete/delete.js | 36 ++ ...es-not-have-setdata-internal-slot-array.js | 34 ++ ...does-not-have-setdata-internal-slot-map.js | 34 ++ ...s-not-have-setdata-internal-slot-object.js | 34 ++ ...ave-setdata-internal-slot-set-prototype.js | 34 ++ ...-not-have-setdata-internal-slot-weakset.js | 34 ++ .../builtins/Set/prototype/delete/length.js | 31 ++ .../builtins/Set/prototype/delete/name.js | 31 ++ .../Set/prototype/delete/not-a-constructor.js | 41 ++ .../returns-false-when-delete-is-noop.js | 28 ++ ...turns-true-when-delete-operation-occurs.js | 35 ++ .../delete/this-not-object-throw-boolean.js | 33 ++ .../delete/this-not-object-throw-null.js | 33 ++ .../delete/this-not-object-throw-number.js | 33 ++ .../delete/this-not-object-throw-string.js | 33 ++ .../delete/this-not-object-throw-symbol.js | 34 ++ .../delete/this-not-object-throw-undefined.js | 33 ++ .../prototype/difference/add-not-called.js | 40 ++ .../difference/allows-set-like-class.js | 48 +++ .../difference/allows-set-like-object.js | 46 ++ .../Set/prototype/difference/array-throws.js | 30 ++ .../Set/prototype/difference/builtins.js | 38 ++ .../difference/called-with-object.js | 79 ++++ .../Set/prototype/difference/combines-Map.js | 32 ++ .../difference/combines-empty-sets.js | 45 ++ .../prototype/difference/combines-itself.js | 29 ++ .../difference/combines-same-sets.js | 31 ++ .../Set/prototype/difference/combines-sets.js | 29 ++ .../difference/converts-negative-zero.js | 41 ++ .../Set/prototype/difference/difference.js | 33 ++ .../prototype/difference/has-is-callable.js | 49 +++ .../prototype/difference/keys-is-callable.js | 46 ++ .../Set/prototype/difference/length.js | 31 ++ .../builtins/Set/prototype/difference/name.js | 31 ++ .../prototype/difference/not-a-constructor.js | 33 ++ .../prototype/difference/receiver-not-set.js | 57 +++ .../difference/require-internal-slot.js | 40 ++ .../Set/prototype/difference/result-order.js | 50 +++ .../prototype/difference/set-like-array.js | 39 ++ .../difference/set-like-class-mutation.js | 62 +++ .../difference/set-like-class-order.js | 153 +++++++ .../prototype/difference/size-is-a-number.js | 85 ++++ .../difference/subclass-receiver-methods.js | 58 +++ .../difference/subclass-symbol-species.js | 42 ++ .../Set/prototype/difference/subclass.js | 36 ++ ...es-not-have-setdata-internal-slot-array.js | 40 ++ ...does-not-have-setdata-internal-slot-map.js | 39 ++ ...s-not-have-setdata-internal-slot-object.js | 39 ++ ...ave-setdata-internal-slot-set-prototype.js | 39 ++ ...-not-have-setdata-internal-slot-weakset.js | 40 ++ .../builtins/Set/prototype/entries/entries.js | 36 ++ .../builtins/Set/prototype/entries/length.js | 31 ++ .../builtins/Set/prototype/entries/name.js | 31 ++ .../prototype/entries/not-a-constructor.js | 45 ++ .../entries/returns-iterator-empty.js | 38 ++ .../Set/prototype/entries/returns-iterator.js | 69 +++ .../entries/this-not-object-throw-boolean.js | 39 ++ .../entries/this-not-object-throw-null.js | 38 ++ .../entries/this-not-object-throw-number.js | 38 ++ .../entries/this-not-object-throw-string.js | 38 ++ .../entries/this-not-object-throw-symbol.js | 39 ++ .../this-not-object-throw-undefined.js | 38 ++ .../forEach/callback-not-callable-boolean.js | 33 ++ .../forEach/callback-not-callable-null.js | 33 ++ .../forEach/callback-not-callable-number.js | 33 ++ .../forEach/callback-not-callable-string.js | 33 ++ .../forEach/callback-not-callable-symbol.js | 34 ++ .../callback-not-callable-undefined.js | 33 ++ ...es-not-have-setdata-internal-slot-array.js | 34 ++ ...does-not-have-setdata-internal-slot-map.js | 34 ++ ...s-not-have-setdata-internal-slot-object.js | 34 ++ ...ave-setdata-internal-slot-set-prototype.js | 34 ++ ...-not-have-setdata-internal-slot-weakset.js | 34 ++ .../builtins/Set/prototype/forEach/forEach.js | 36 ++ .../forEach/iterates-in-insertion-order.js | 42 ++ .../iterates-in-iterable-entry-order.js | 40 ++ ...rates-values-added-after-foreach-begins.js | 55 +++ .../iterates-values-deleted-then-readded.js | 58 +++ .../forEach/iterates-values-not-deleted.js | 47 ++ ...tes-values-revisits-after-delete-re-add.js | 58 +++ .../builtins/Set/prototype/forEach/length.js | 31 ++ .../builtins/Set/prototype/forEach/name.js | 31 ++ .../prototype/forEach/not-a-constructor.js | 45 ++ .../prototype/forEach/returns-undefined.js | 32 ++ ...icit-cannot-override-lexical-this-arrow.js | 39 ++ .../prototype/forEach/this-arg-explicit.js | 35 ++ .../Set/prototype/forEach/this-non-strict.js | 37 ++ .../forEach/this-not-object-throw-boolean.js | 33 ++ .../forEach/this-not-object-throw-null.js | 33 ++ .../forEach/this-not-object-throw-number.js | 33 ++ .../forEach/this-not-object-throw-string.js | 33 ++ .../forEach/this-not-object-throw-symbol.js | 34 ++ .../this-not-object-throw-undefined.js | 33 ++ .../Set/prototype/forEach/this-strict.js | 36 ++ .../forEach/throws-when-callback-throws.js | 39 ++ ...es-not-have-setdata-internal-slot-array.js | 34 ++ ...does-not-have-setdata-internal-slot-map.js | 34 ++ ...s-not-have-setdata-internal-slot-object.js | 34 ++ ...ave-setdata-internal-slot-set-prototype.js | 34 ++ ...-not-have-setdata-internal-slot-weakset.js | 34 ++ .../builtins/Set/prototype/has/has.js | 36 ++ .../builtins/Set/prototype/has/length.js | 31 ++ .../builtins/Set/prototype/has/name.js | 31 ++ .../Set/prototype/has/not-a-constructor.js | 41 ++ ...ned-added-deleted-not-present-undefined.js | 34 ++ ...ns-false-when-value-not-present-boolean.js | 28 ++ ...eturns-false-when-value-not-present-nan.js | 28 ++ ...turns-false-when-value-not-present-null.js | 28 ++ ...rns-false-when-value-not-present-number.js | 28 ++ ...rns-false-when-value-not-present-string.js | 28 ++ ...rns-false-when-value-not-present-symbol.js | 29 ++ ...-false-when-value-not-present-undefined.js | 28 ++ ...returns-true-when-value-present-boolean.js | 32 ++ .../returns-true-when-value-present-nan.js | 32 ++ .../returns-true-when-value-present-null.js | 32 ++ .../returns-true-when-value-present-number.js | 32 ++ .../returns-true-when-value-present-string.js | 32 ++ .../returns-true-when-value-present-symbol.js | 34 ++ ...turns-true-when-value-present-undefined.js | 32 ++ .../has/this-not-object-throw-boolean.js | 33 ++ .../has/this-not-object-throw-null.js | 33 ++ .../has/this-not-object-throw-number.js | 33 ++ .../has/this-not-object-throw-string.js | 33 ++ .../has/this-not-object-throw-symbol.js | 34 ++ .../has/this-not-object-throw-undefined.js | 33 ++ .../prototype/intersection/add-not-called.js | 40 ++ .../intersection/allows-set-like-class.js | 48 +++ .../intersection/allows-set-like-object.js | 46 ++ .../prototype/intersection/array-throws.js | 30 ++ .../Set/prototype/intersection/builtins.js | 38 ++ .../intersection/called-with-object.js | 79 ++++ .../prototype/intersection/combines-Map.js | 32 ++ .../intersection/combines-empty-sets.js | 45 ++ .../prototype/intersection/combines-itself.js | 29 ++ .../intersection/combines-same-sets.js | 31 ++ .../prototype/intersection/combines-sets.js | 29 ++ .../intersection/converts-negative-zero.js | 41 ++ .../prototype/intersection/has-is-callable.js | 49 +++ .../prototype/intersection/intersection.js | 33 ++ .../intersection/keys-is-callable.js | 46 ++ .../Set/prototype/intersection/length.js | 31 ++ .../Set/prototype/intersection/name.js | 31 ++ .../intersection/not-a-constructor.js | 33 ++ .../intersection/receiver-not-set.js | 57 +++ .../intersection/require-internal-slot.js | 40 ++ .../prototype/intersection/result-order.js | 66 +++ .../prototype/intersection/set-like-array.js | 39 ++ .../intersection/set-like-class-mutation.js | 62 +++ .../intersection/set-like-class-order.js | 153 +++++++ .../intersection/size-is-a-number.js | 85 ++++ .../intersection/subclass-receiver-methods.js | 58 +++ .../intersection/subclass-symbol-species.js | 42 ++ .../Set/prototype/intersection/subclass.js | 36 ++ .../isDisjointFrom/allows-set-like-class.js | 43 ++ .../isDisjointFrom/allows-set-like-object.js | 41 ++ .../prototype/isDisjointFrom/array-throws.js | 30 ++ .../Set/prototype/isDisjointFrom/builtins.js | 38 ++ .../isDisjointFrom/called-with-object.js | 79 ++++ .../prototype/isDisjointFrom/compares-Map.js | 28 ++ .../isDisjointFrom/compares-empty-sets.js | 35 ++ .../isDisjointFrom/compares-itself.js | 24 ++ .../isDisjointFrom/compares-same-sets.js | 25 ++ .../prototype/isDisjointFrom/compares-sets.js | 29 ++ .../isDisjointFrom/converts-negative-zero.js | 35 ++ .../isDisjointFrom/has-is-callable.js | 49 +++ .../isDisjointFrom/isDisjointFrom.js | 33 ++ .../isDisjointFrom/keys-is-callable.js | 46 ++ .../Set/prototype/isDisjointFrom/length.js | 31 ++ .../Set/prototype/isDisjointFrom/name.js | 31 ++ .../isDisjointFrom/not-a-constructor.js | 33 ++ .../isDisjointFrom/receiver-not-set.js | 57 +++ .../isDisjointFrom/require-internal-slot.js | 40 ++ .../isDisjointFrom/set-like-array.js | 33 ++ .../isDisjointFrom/set-like-class-mutation.js | 51 +++ .../isDisjointFrom/set-like-class-order.js | 204 +++++++++ .../isDisjointFrom/size-is-a-number.js | 85 ++++ .../subclass-receiver-methods.js | 50 +++ .../isSubsetOf/allows-set-like-class.js | 44 ++ .../isSubsetOf/allows-set-like-object.js | 42 ++ .../Set/prototype/isSubsetOf/array-throws.js | 30 ++ .../Set/prototype/isSubsetOf/builtins.js | 38 ++ .../isSubsetOf/called-with-object.js | 79 ++++ .../Set/prototype/isSubsetOf/compares-Map.js | 28 ++ .../isSubsetOf/compares-empty-sets.js | 35 ++ .../prototype/isSubsetOf/compares-itself.js | 24 ++ .../isSubsetOf/compares-same-sets.js | 25 ++ .../Set/prototype/isSubsetOf/compares-sets.js | 29 ++ .../prototype/isSubsetOf/has-is-callable.js | 49 +++ .../Set/prototype/isSubsetOf/isSubsetOf.js | 33 ++ .../prototype/isSubsetOf/keys-is-callable.js | 46 ++ .../Set/prototype/isSubsetOf/length.js | 31 ++ .../builtins/Set/prototype/isSubsetOf/name.js | 31 ++ .../prototype/isSubsetOf/not-a-constructor.js | 33 ++ .../prototype/isSubsetOf/receiver-not-set.js | 57 +++ .../isSubsetOf/require-internal-slot.js | 40 ++ .../prototype/isSubsetOf/set-like-array.js | 34 ++ .../isSubsetOf/set-like-class-mutation.js | 42 ++ .../isSubsetOf/set-like-class-order.js | 134 ++++++ .../prototype/isSubsetOf/size-is-a-number.js | 85 ++++ .../isSubsetOf/subclass-receiver-methods.js | 50 +++ .../isSupersetOf/allows-set-like-class.js | 42 ++ .../isSupersetOf/allows-set-like-object.js | 40 ++ .../prototype/isSupersetOf/array-throws.js | 30 ++ .../Set/prototype/isSupersetOf/builtins.js | 38 ++ .../isSupersetOf/called-with-object.js | 79 ++++ .../prototype/isSupersetOf/compares-Map.js | 28 ++ .../isSupersetOf/compares-empty-sets.js | 35 ++ .../prototype/isSupersetOf/compares-itself.js | 24 ++ .../isSupersetOf/compares-same-sets.js | 25 ++ .../prototype/isSupersetOf/compares-sets.js | 29 ++ .../isSupersetOf/converts-negative-zero.js | 35 ++ .../prototype/isSupersetOf/has-is-callable.js | 49 +++ .../prototype/isSupersetOf/isSupersetOf.js | 33 ++ .../isSupersetOf/keys-is-callable.js | 46 ++ .../Set/prototype/isSupersetOf/length.js | 31 ++ .../Set/prototype/isSupersetOf/name.js | 31 ++ .../isSupersetOf/not-a-constructor.js | 33 ++ .../isSupersetOf/receiver-not-set.js | 57 +++ .../isSupersetOf/require-internal-slot.js | 40 ++ .../prototype/isSupersetOf/set-like-array.js | 34 ++ .../isSupersetOf/set-like-class-mutation.js | 43 ++ .../isSupersetOf/set-like-class-order.js | 192 +++++++++ .../isSupersetOf/size-is-a-number.js | 85 ++++ .../isSupersetOf/subclass-receiver-methods.js | 50 +++ .../builtins/Set/prototype/keys/keys.js | 27 ++ .../builtins/Set/prototype/size/length.js | 34 ++ .../builtins/Set/prototype/size/name.js | 37 ++ ...-present-values-before-after-add-delete.js | 38 ++ ...ns-count-of-present-values-by-insertion.js | 38 ++ ...rns-count-of-present-values-by-iterable.js | 30 ++ .../builtins/Set/prototype/size/size.js | 40 ++ .../symmetricDifference/add-not-called.js | 40 ++ .../allows-set-like-class.js | 47 ++ .../allows-set-like-object.js | 45 ++ .../symmetricDifference/array-throws.js | 30 ++ .../prototype/symmetricDifference/builtins.js | 38 ++ .../symmetricDifference/called-with-object.js | 79 ++++ .../symmetricDifference/combines-Map.js | 32 ++ .../combines-empty-sets.js | 45 ++ .../symmetricDifference/combines-itself.js | 29 ++ .../symmetricDifference/combines-same-sets.js | 31 ++ .../symmetricDifference/combines-sets.js | 29 ++ .../converts-negative-zero.js | 41 ++ .../symmetricDifference/has-is-callable.js | 49 +++ .../symmetricDifference/keys-is-callable.js | 46 ++ .../prototype/symmetricDifference/length.js | 31 ++ .../Set/prototype/symmetricDifference/name.js | 31 ++ .../symmetricDifference/not-a-constructor.js | 33 ++ .../symmetricDifference/receiver-not-set.js | 57 +++ .../require-internal-slot.js | 40 ++ .../symmetricDifference/result-order.js | 36 ++ .../symmetricDifference/set-like-array.js | 37 ++ .../set-like-class-mutation.js | 62 +++ .../set-like-class-order.js | 179 ++++++++ .../symmetricDifference/size-is-a-number.js | 85 ++++ .../subclass-receiver-methods.js | 58 +++ .../subclass-symbol-species.js | 42 ++ .../prototype/symmetricDifference/subclass.js | 36 ++ .../symmetricDifference.js | 33 ++ .../Set/prototype/union/add-not-called.js | 40 ++ .../prototype/union/allows-set-like-class.js | 47 ++ .../prototype/union/allows-set-like-object.js | 45 ++ .../Set/prototype/union/appends-new-values.js | 43 ++ .../Set/prototype/union/array-throws.js | 30 ++ .../builtins/Set/prototype/union/builtins.js | 38 ++ .../Set/prototype/union/called-with-object.js | 79 ++++ .../Set/prototype/union/combines-Map.js | 32 ++ .../prototype/union/combines-empty-sets.js | 45 ++ .../Set/prototype/union/combines-itself.js | 29 ++ .../Set/prototype/union/combines-same-sets.js | 31 ++ .../Set/prototype/union/combines-sets.js | 29 ++ .../prototype/union/converts-negative-zero.js | 48 +++ .../Set/prototype/union/has-is-callable.js | 49 +++ .../Set/prototype/union/keys-is-callable.js | 46 ++ .../builtins/Set/prototype/union/length.js | 31 ++ .../builtins/Set/prototype/union/name.js | 31 ++ .../Set/prototype/union/not-a-constructor.js | 33 ++ .../Set/prototype/union/receiver-not-set.js | 57 +++ .../prototype/union/require-internal-slot.js | 40 ++ .../Set/prototype/union/result-order.js | 49 +++ .../Set/prototype/union/set-like-array.js | 37 ++ .../union/set-like-class-mutation.js | 60 +++ .../prototype/union/set-like-class-order.js | 131 ++++++ .../Set/prototype/union/size-is-a-number.js | 85 ++++ .../union/subclass-receiver-methods.js | 58 +++ .../union/subclass-symbol-species.js | 42 ++ .../builtins/Set/prototype/union/subclass.js | 36 ++ .../builtins/Set/prototype/union/union.js | 33 ++ ...es-not-have-setdata-internal-slot-array.js | 40 ++ ...does-not-have-setdata-internal-slot-map.js | 39 ++ ...s-not-have-setdata-internal-slot-object.js | 39 ++ ...ave-setdata-internal-slot-set-prototype.js | 39 ++ ...-not-have-setdata-internal-slot-weakset.js | 40 ++ .../builtins/Set/prototype/values/length.js | 31 ++ .../builtins/Set/prototype/values/name.js | 31 ++ .../Set/prototype/values/not-a-constructor.js | 41 ++ .../values/returns-iterator-empty.js | 26 ++ .../Set/prototype/values/returns-iterator.js | 53 +++ .../values/this-not-object-throw-boolean.js | 39 ++ .../values/this-not-object-throw-null.js | 38 ++ .../values/this-not-object-throw-number.js | 38 ++ .../values/this-not-object-throw-string.js | 38 ++ .../values/this-not-object-throw-symbol.js | 39 ++ .../values/this-not-object-throw-undefined.js | 38 ++ .../values/values-iteration-mutable.js | 58 +++ .../builtins/Set/prototype/values/values.js | 36 ++ ...does-not-throw-when-add-is-not-callable.js | 46 ++ .../Set/set-get-add-method-failure.js | 41 ++ .../builtins/Set/set-iterable-calls-add.js | 52 +++ .../set-iterable-empty-does-not-call-add.js | 52 +++ ...terable-throws-when-add-is-not-callable.js | 47 ++ test/sendable/builtins/Set/set-iterable.js | 44 ++ .../set-iterator-close-after-add-failure.js | 61 +++ .../builtins/Set/set-iterator-next-failure.js | 43 ++ .../Set/set-iterator-value-failure.js | 50 +++ test/sendable/builtins/Set/set-newtarget.js | 43 ++ test/sendable/builtins/Set/set-no-iterable.js | 34 ++ .../builtins/Set/set-undefined-newtarget.js | 34 ++ test/sendable/builtins/Set/set.js | 30 ++ test/sendable/builtins/Set/valid-values.js | 400 ++++++++++++++++++ 392 files changed, 16226 insertions(+), 46 deletions(-) create mode 100644 test/sendable/builtins/Set/Symbol.species/length.js create mode 100644 test/sendable/builtins/Set/Symbol.species/return-value.js create mode 100644 test/sendable/builtins/Set/Symbol.species/symbol-species-name.js create mode 100644 test/sendable/builtins/Set/Symbol.species/symbol-species.js create mode 100644 test/sendable/builtins/Set/bigint-number-same-value.js create mode 100644 test/sendable/builtins/Set/constructor.js create mode 100644 test/sendable/builtins/Set/is-a-constructor.js create mode 100644 test/sendable/builtins/Set/length.js create mode 100644 test/sendable/builtins/Set/name.js create mode 100644 test/sendable/builtins/Set/properties-of-the-set-prototype-object.js create mode 100644 test/sendable/builtins/Set/proto-from-ctor-realm.js create mode 100644 test/sendable/builtins/Set/prototype-of-set.js create mode 100644 test/sendable/builtins/Set/prototype/Symbol.iterator.js create mode 100644 test/sendable/builtins/Set/prototype/Symbol.iterator/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/Symbol.toStringTag.js create mode 100644 test/sendable/builtins/Set/prototype/Symbol.toStringTag/property-descriptor.js create mode 100644 test/sendable/builtins/Set/prototype/add/add.js create mode 100644 test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-array.js create mode 100644 test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-map.js create mode 100644 test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-object.js create mode 100644 test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-set-prototype.js create mode 100644 test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-weakset.js create mode 100644 test/sendable/builtins/Set/prototype/add/length.js create mode 100644 test/sendable/builtins/Set/prototype/add/name.js create mode 100644 test/sendable/builtins/Set/prototype/add/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/add/preserves-insertion-order.js create mode 100644 test/sendable/builtins/Set/prototype/add/returns-this-when-ignoring-duplicate.js create mode 100644 test/sendable/builtins/Set/prototype/add/returns-this.js create mode 100644 test/sendable/builtins/Set/prototype/add/this-not-object-throw-boolean.js create mode 100644 test/sendable/builtins/Set/prototype/add/this-not-object-throw-null.js create mode 100644 test/sendable/builtins/Set/prototype/add/this-not-object-throw-number.js create mode 100644 test/sendable/builtins/Set/prototype/add/this-not-object-throw-string.js create mode 100644 test/sendable/builtins/Set/prototype/add/this-not-object-throw-symbol.js create mode 100644 test/sendable/builtins/Set/prototype/add/this-not-object-throw-undefined.js create mode 100644 test/sendable/builtins/Set/prototype/add/will-not-add-duplicate-entry-initial-iterable.js create mode 100644 test/sendable/builtins/Set/prototype/add/will-not-add-duplicate-entry-normalizes-zero.js create mode 100644 test/sendable/builtins/Set/prototype/add/will-not-add-duplicate-entry.js create mode 100644 test/sendable/builtins/Set/prototype/clear/clear.js create mode 100644 test/sendable/builtins/Set/prototype/clear/clears-all-contents-from-iterable.js create mode 100644 test/sendable/builtins/Set/prototype/clear/clears-all-contents.js create mode 100644 test/sendable/builtins/Set/prototype/clear/clears-an-empty-set.js create mode 100644 test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js create mode 100644 test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js create mode 100644 test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js create mode 100644 test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js create mode 100644 test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js create mode 100644 test/sendable/builtins/Set/prototype/clear/length.js create mode 100644 test/sendable/builtins/Set/prototype/clear/name.js create mode 100644 test/sendable/builtins/Set/prototype/clear/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/clear/returns-undefined.js create mode 100644 test/sendable/builtins/Set/prototype/clear/this-not-object-throw-boolean.js create mode 100644 test/sendable/builtins/Set/prototype/clear/this-not-object-throw-null.js create mode 100644 test/sendable/builtins/Set/prototype/clear/this-not-object-throw-number.js create mode 100644 test/sendable/builtins/Set/prototype/clear/this-not-object-throw-string.js create mode 100644 test/sendable/builtins/Set/prototype/clear/this-not-object-throw-symbol.js create mode 100644 test/sendable/builtins/Set/prototype/clear/this-not-object-throw-undefined.js create mode 100644 test/sendable/builtins/Set/prototype/constructor/set-prototype-constructor-intrinsic.js create mode 100644 test/sendable/builtins/Set/prototype/constructor/set-prototype-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/delete/delete-entry-initial-iterable.js create mode 100644 test/sendable/builtins/Set/prototype/delete/delete-entry-normalizes-zero.js create mode 100644 test/sendable/builtins/Set/prototype/delete/delete-entry.js create mode 100644 test/sendable/builtins/Set/prototype/delete/delete.js create mode 100644 test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-array.js create mode 100644 test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-map.js create mode 100644 test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-object.js create mode 100644 test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-set-prototype.js create mode 100644 test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-weakset.js create mode 100644 test/sendable/builtins/Set/prototype/delete/length.js create mode 100644 test/sendable/builtins/Set/prototype/delete/name.js create mode 100644 test/sendable/builtins/Set/prototype/delete/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/delete/returns-false-when-delete-is-noop.js create mode 100644 test/sendable/builtins/Set/prototype/delete/returns-true-when-delete-operation-occurs.js create mode 100644 test/sendable/builtins/Set/prototype/delete/this-not-object-throw-boolean.js create mode 100644 test/sendable/builtins/Set/prototype/delete/this-not-object-throw-null.js create mode 100644 test/sendable/builtins/Set/prototype/delete/this-not-object-throw-number.js create mode 100644 test/sendable/builtins/Set/prototype/delete/this-not-object-throw-string.js create mode 100644 test/sendable/builtins/Set/prototype/delete/this-not-object-throw-symbol.js create mode 100644 test/sendable/builtins/Set/prototype/delete/this-not-object-throw-undefined.js create mode 100644 test/sendable/builtins/Set/prototype/difference/add-not-called.js create mode 100644 test/sendable/builtins/Set/prototype/difference/allows-set-like-class.js create mode 100644 test/sendable/builtins/Set/prototype/difference/allows-set-like-object.js create mode 100644 test/sendable/builtins/Set/prototype/difference/array-throws.js create mode 100644 test/sendable/builtins/Set/prototype/difference/builtins.js create mode 100644 test/sendable/builtins/Set/prototype/difference/called-with-object.js create mode 100644 test/sendable/builtins/Set/prototype/difference/combines-Map.js create mode 100644 test/sendable/builtins/Set/prototype/difference/combines-empty-sets.js create mode 100644 test/sendable/builtins/Set/prototype/difference/combines-itself.js create mode 100644 test/sendable/builtins/Set/prototype/difference/combines-same-sets.js create mode 100644 test/sendable/builtins/Set/prototype/difference/combines-sets.js create mode 100644 test/sendable/builtins/Set/prototype/difference/converts-negative-zero.js create mode 100644 test/sendable/builtins/Set/prototype/difference/difference.js create mode 100644 test/sendable/builtins/Set/prototype/difference/has-is-callable.js create mode 100644 test/sendable/builtins/Set/prototype/difference/keys-is-callable.js create mode 100644 test/sendable/builtins/Set/prototype/difference/length.js create mode 100644 test/sendable/builtins/Set/prototype/difference/name.js create mode 100644 test/sendable/builtins/Set/prototype/difference/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/difference/receiver-not-set.js create mode 100644 test/sendable/builtins/Set/prototype/difference/require-internal-slot.js create mode 100644 test/sendable/builtins/Set/prototype/difference/result-order.js create mode 100644 test/sendable/builtins/Set/prototype/difference/set-like-array.js create mode 100644 test/sendable/builtins/Set/prototype/difference/set-like-class-mutation.js create mode 100644 test/sendable/builtins/Set/prototype/difference/set-like-class-order.js create mode 100644 test/sendable/builtins/Set/prototype/difference/size-is-a-number.js create mode 100644 test/sendable/builtins/Set/prototype/difference/subclass-receiver-methods.js create mode 100644 test/sendable/builtins/Set/prototype/difference/subclass-symbol-species.js create mode 100644 test/sendable/builtins/Set/prototype/difference/subclass.js create mode 100644 test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-array.js create mode 100644 test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-map.js create mode 100644 test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-object.js create mode 100644 test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-set-prototype.js create mode 100644 test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-weakset.js create mode 100644 test/sendable/builtins/Set/prototype/entries/entries.js create mode 100644 test/sendable/builtins/Set/prototype/entries/length.js create mode 100644 test/sendable/builtins/Set/prototype/entries/name.js create mode 100644 test/sendable/builtins/Set/prototype/entries/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/entries/returns-iterator-empty.js create mode 100644 test/sendable/builtins/Set/prototype/entries/returns-iterator.js create mode 100644 test/sendable/builtins/Set/prototype/entries/this-not-object-throw-boolean.js create mode 100644 test/sendable/builtins/Set/prototype/entries/this-not-object-throw-null.js create mode 100644 test/sendable/builtins/Set/prototype/entries/this-not-object-throw-number.js create mode 100644 test/sendable/builtins/Set/prototype/entries/this-not-object-throw-string.js create mode 100644 test/sendable/builtins/Set/prototype/entries/this-not-object-throw-symbol.js create mode 100644 test/sendable/builtins/Set/prototype/entries/this-not-object-throw-undefined.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/callback-not-callable-boolean.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/callback-not-callable-null.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/callback-not-callable-number.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/callback-not-callable-string.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/callback-not-callable-symbol.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/callback-not-callable-undefined.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-array.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-map.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-object.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-set-prototype.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-weakset.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/forEach.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/iterates-in-insertion-order.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/iterates-in-iterable-entry-order.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/iterates-values-deleted-then-readded.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/iterates-values-not-deleted.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/iterates-values-revisits-after-delete-re-add.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/length.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/name.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/returns-undefined.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/this-arg-explicit-cannot-override-lexical-this-arrow.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/this-arg-explicit.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/this-non-strict.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-boolean.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-null.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-number.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-string.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-symbol.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-undefined.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/this-strict.js create mode 100644 test/sendable/builtins/Set/prototype/forEach/throws-when-callback-throws.js create mode 100644 test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-array.js create mode 100644 test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-map.js create mode 100644 test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-object.js create mode 100644 test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-set-prototype.js create mode 100644 test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-weakset.js create mode 100644 test/sendable/builtins/Set/prototype/has/has.js create mode 100644 test/sendable/builtins/Set/prototype/has/length.js create mode 100644 test/sendable/builtins/Set/prototype/has/name.js create mode 100644 test/sendable/builtins/Set/prototype/has/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-false-when-undefined-added-deleted-not-present-undefined.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-boolean.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-nan.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-null.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-number.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-string.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-symbol.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-undefined.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-boolean.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-nan.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-null.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-number.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-string.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-symbol.js create mode 100644 test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-undefined.js create mode 100644 test/sendable/builtins/Set/prototype/has/this-not-object-throw-boolean.js create mode 100644 test/sendable/builtins/Set/prototype/has/this-not-object-throw-null.js create mode 100644 test/sendable/builtins/Set/prototype/has/this-not-object-throw-number.js create mode 100644 test/sendable/builtins/Set/prototype/has/this-not-object-throw-string.js create mode 100644 test/sendable/builtins/Set/prototype/has/this-not-object-throw-symbol.js create mode 100644 test/sendable/builtins/Set/prototype/has/this-not-object-throw-undefined.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/add-not-called.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/allows-set-like-class.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/allows-set-like-object.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/array-throws.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/builtins.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/called-with-object.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/combines-Map.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/combines-empty-sets.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/combines-itself.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/combines-same-sets.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/combines-sets.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/converts-negative-zero.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/has-is-callable.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/intersection.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/keys-is-callable.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/length.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/name.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/receiver-not-set.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/require-internal-slot.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/result-order.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/set-like-array.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/set-like-class-mutation.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/set-like-class-order.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/size-is-a-number.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/subclass-receiver-methods.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/subclass-symbol-species.js create mode 100644 test/sendable/builtins/Set/prototype/intersection/subclass.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/allows-set-like-class.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/allows-set-like-object.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/array-throws.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/builtins.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/called-with-object.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/compares-Map.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/compares-empty-sets.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/compares-itself.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/compares-same-sets.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/compares-sets.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/converts-negative-zero.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/has-is-callable.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/isDisjointFrom.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/keys-is-callable.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/length.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/name.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/receiver-not-set.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/require-internal-slot.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/set-like-array.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/set-like-class-mutation.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/set-like-class-order.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/size-is-a-number.js create mode 100644 test/sendable/builtins/Set/prototype/isDisjointFrom/subclass-receiver-methods.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/allows-set-like-class.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/allows-set-like-object.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/array-throws.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/builtins.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/called-with-object.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/compares-Map.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/compares-empty-sets.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/compares-itself.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/compares-same-sets.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/compares-sets.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/has-is-callable.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/isSubsetOf.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/keys-is-callable.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/length.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/name.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/receiver-not-set.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/require-internal-slot.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/set-like-array.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/set-like-class-mutation.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/set-like-class-order.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/size-is-a-number.js create mode 100644 test/sendable/builtins/Set/prototype/isSubsetOf/subclass-receiver-methods.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/allows-set-like-class.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/allows-set-like-object.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/array-throws.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/builtins.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/called-with-object.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/compares-Map.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/compares-empty-sets.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/compares-itself.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/compares-same-sets.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/compares-sets.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/converts-negative-zero.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/has-is-callable.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/isSupersetOf.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/keys-is-callable.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/length.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/name.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/receiver-not-set.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/require-internal-slot.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/set-like-array.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/set-like-class-mutation.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/set-like-class-order.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/size-is-a-number.js create mode 100644 test/sendable/builtins/Set/prototype/isSupersetOf/subclass-receiver-methods.js create mode 100644 test/sendable/builtins/Set/prototype/keys/keys.js create mode 100644 test/sendable/builtins/Set/prototype/size/length.js create mode 100644 test/sendable/builtins/Set/prototype/size/name.js create mode 100644 test/sendable/builtins/Set/prototype/size/returns-count-of-present-values-before-after-add-delete.js create mode 100644 test/sendable/builtins/Set/prototype/size/returns-count-of-present-values-by-insertion.js create mode 100644 test/sendable/builtins/Set/prototype/size/returns-count-of-present-values-by-iterable.js create mode 100644 test/sendable/builtins/Set/prototype/size/size.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/add-not-called.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/allows-set-like-class.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/allows-set-like-object.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/array-throws.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/builtins.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/called-with-object.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/combines-Map.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/combines-empty-sets.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/combines-itself.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/combines-same-sets.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/combines-sets.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/converts-negative-zero.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/has-is-callable.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/keys-is-callable.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/length.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/name.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/receiver-not-set.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/require-internal-slot.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/result-order.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/set-like-array.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/set-like-class-mutation.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/set-like-class-order.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/size-is-a-number.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/subclass-receiver-methods.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/subclass-symbol-species.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/subclass.js create mode 100644 test/sendable/builtins/Set/prototype/symmetricDifference/symmetricDifference.js create mode 100644 test/sendable/builtins/Set/prototype/union/add-not-called.js create mode 100644 test/sendable/builtins/Set/prototype/union/allows-set-like-class.js create mode 100644 test/sendable/builtins/Set/prototype/union/allows-set-like-object.js create mode 100644 test/sendable/builtins/Set/prototype/union/appends-new-values.js create mode 100644 test/sendable/builtins/Set/prototype/union/array-throws.js create mode 100644 test/sendable/builtins/Set/prototype/union/builtins.js create mode 100644 test/sendable/builtins/Set/prototype/union/called-with-object.js create mode 100644 test/sendable/builtins/Set/prototype/union/combines-Map.js create mode 100644 test/sendable/builtins/Set/prototype/union/combines-empty-sets.js create mode 100644 test/sendable/builtins/Set/prototype/union/combines-itself.js create mode 100644 test/sendable/builtins/Set/prototype/union/combines-same-sets.js create mode 100644 test/sendable/builtins/Set/prototype/union/combines-sets.js create mode 100644 test/sendable/builtins/Set/prototype/union/converts-negative-zero.js create mode 100644 test/sendable/builtins/Set/prototype/union/has-is-callable.js create mode 100644 test/sendable/builtins/Set/prototype/union/keys-is-callable.js create mode 100644 test/sendable/builtins/Set/prototype/union/length.js create mode 100644 test/sendable/builtins/Set/prototype/union/name.js create mode 100644 test/sendable/builtins/Set/prototype/union/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/union/receiver-not-set.js create mode 100644 test/sendable/builtins/Set/prototype/union/require-internal-slot.js create mode 100644 test/sendable/builtins/Set/prototype/union/result-order.js create mode 100644 test/sendable/builtins/Set/prototype/union/set-like-array.js create mode 100644 test/sendable/builtins/Set/prototype/union/set-like-class-mutation.js create mode 100644 test/sendable/builtins/Set/prototype/union/set-like-class-order.js create mode 100644 test/sendable/builtins/Set/prototype/union/size-is-a-number.js create mode 100644 test/sendable/builtins/Set/prototype/union/subclass-receiver-methods.js create mode 100644 test/sendable/builtins/Set/prototype/union/subclass-symbol-species.js create mode 100644 test/sendable/builtins/Set/prototype/union/subclass.js create mode 100644 test/sendable/builtins/Set/prototype/union/union.js create mode 100644 test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-array.js create mode 100644 test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-map.js create mode 100644 test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-object.js create mode 100644 test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-set-prototype.js create mode 100644 test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-weakset.js create mode 100644 test/sendable/builtins/Set/prototype/values/length.js create mode 100644 test/sendable/builtins/Set/prototype/values/name.js create mode 100644 test/sendable/builtins/Set/prototype/values/not-a-constructor.js create mode 100644 test/sendable/builtins/Set/prototype/values/returns-iterator-empty.js create mode 100644 test/sendable/builtins/Set/prototype/values/returns-iterator.js create mode 100644 test/sendable/builtins/Set/prototype/values/this-not-object-throw-boolean.js create mode 100644 test/sendable/builtins/Set/prototype/values/this-not-object-throw-null.js create mode 100644 test/sendable/builtins/Set/prototype/values/this-not-object-throw-number.js create mode 100644 test/sendable/builtins/Set/prototype/values/this-not-object-throw-string.js create mode 100644 test/sendable/builtins/Set/prototype/values/this-not-object-throw-symbol.js create mode 100644 test/sendable/builtins/Set/prototype/values/this-not-object-throw-undefined.js create mode 100644 test/sendable/builtins/Set/prototype/values/values-iteration-mutable.js create mode 100644 test/sendable/builtins/Set/prototype/values/values.js create mode 100644 test/sendable/builtins/Set/set-does-not-throw-when-add-is-not-callable.js create mode 100644 test/sendable/builtins/Set/set-get-add-method-failure.js create mode 100644 test/sendable/builtins/Set/set-iterable-calls-add.js create mode 100644 test/sendable/builtins/Set/set-iterable-empty-does-not-call-add.js create mode 100644 test/sendable/builtins/Set/set-iterable-throws-when-add-is-not-callable.js create mode 100644 test/sendable/builtins/Set/set-iterable.js create mode 100644 test/sendable/builtins/Set/set-iterator-close-after-add-failure.js create mode 100644 test/sendable/builtins/Set/set-iterator-next-failure.js create mode 100644 test/sendable/builtins/Set/set-iterator-value-failure.js create mode 100644 test/sendable/builtins/Set/set-newtarget.js create mode 100644 test/sendable/builtins/Set/set-no-iterable.js create mode 100644 test/sendable/builtins/Set/set-undefined-newtarget.js create mode 100644 test/sendable/builtins/Set/set.js create mode 100644 test/sendable/builtins/Set/valid-values.js diff --git a/test/sendable/builtins/Map/prototype/clear/context-is-weakmap-object-throws.js b/test/sendable/builtins/Map/prototype/clear/context-is-weakmap-object-throws.js index 8158de8bb5e..dfee81fe5e3 100644 --- a/test/sendable/builtins/Map/prototype/clear/context-is-weakmap-object-throws.js +++ b/test/sendable/builtins/Map/prototype/clear/context-is-weakmap-object-throws.js @@ -16,7 +16,7 @@ /*--- esid: sec-map.prototype.clear description: > - Throws a TypeError if `this` is a WeakSendableMap object. + Throws a TypeError if `this` is a WeakMap object. info: | SendableMap.prototype.clear ( ) @@ -25,9 +25,9 @@ info: | 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError exception. ... -features: [WeakSendableMap] +features: [WeakMap] ---*/ assert.throws(TypeError, function() { - SendableMap.prototype.clear.call(new WeakSendableMap()); + SendableMap.prototype.clear.call(new WeakMap()); }); diff --git a/test/sendable/builtins/Map/prototype/delete/context-is-weakmap-object-throws.js b/test/sendable/builtins/Map/prototype/delete/context-is-weakmap-object-throws.js index 209cbdeedc5..7b2288f12ec 100644 --- a/test/sendable/builtins/Map/prototype/delete/context-is-weakmap-object-throws.js +++ b/test/sendable/builtins/Map/prototype/delete/context-is-weakmap-object-throws.js @@ -16,7 +16,7 @@ /*--- esid: sec-map.prototype.delete description: > - Throws a TypeError if `this` is a WeakSendableMap object. + Throws a TypeError if `this` is a WeakMap object. info: | SendableMap.prototype.delete ( key ) @@ -25,9 +25,9 @@ info: | 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError exception. ... -features: [WeakSendableMap] +features: [WeakMap] ---*/ assert.throws(TypeError, function() { - SendableMap.prototype.delete.call(new WeakSendableMap(), 'attr'); + SendableMap.prototype.delete.call(new WeakMap(), 'attr'); }); diff --git a/test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot-weakmap.js index 69de96ea867..b570e517223 100644 --- a/test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot-weakmap.js +++ b/test/sendable/builtins/Map/prototype/entries/does-not-have-mapdata-internal-slot-weakmap.js @@ -16,7 +16,7 @@ /*--- esid: sec-map.prototype.entries description: > - Throws a TypeError if `this` is a WeakSendableMap object. + Throws a TypeError if `this` is a WeakMap object. info: | SendableMap.prototype.entries ( ) @@ -29,14 +29,14 @@ info: | 2. If map does not have a [[SendableMapData]] internal slot, throw a TypeError exception. ... -features: [WeakSendableMap] +features: [WeakMap] ---*/ assert.throws(TypeError, function() { - SendableMap.prototype.entries.call(new WeakSendableMap()); + SendableMap.prototype.entries.call(new WeakMap()); }); assert.throws(TypeError, function() { var m = new SendableMap(); - m.entries.call(new WeakSendableMap()); + m.entries.call(new WeakMap()); }); diff --git a/test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-weakmap.js index 0d336523a15..bd29975dec7 100644 --- a/test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-weakmap.js +++ b/test/sendable/builtins/Map/prototype/forEach/does-not-have-mapdata-internal-slot-weakmap.js @@ -16,7 +16,7 @@ /*--- esid: sec-map.prototype.forEach description: > - Throws a TypeError if `this` is a WeakSendableMap object. + Throws a TypeError if `this` is a WeakMap object. info: | SendableMap.prototype.forEach ( callbackfn [ , thisArg ] ) @@ -24,14 +24,14 @@ info: | 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError exception. ... -features: [WeakSendableMap] +features: [WeakMap] ---*/ assert.throws(TypeError, function() { - SendableMap.prototype.forEach.call(new WeakSendableMap(), function() {}); + SendableMap.prototype.forEach.call(new WeakMap(), function() {}); }); assert.throws(TypeError, function() { var m = new SendableMap(); - m.forEach.call(new WeakSendableMap(), function() {}); + m.forEach.call(new WeakMap(), function() {}); }); diff --git a/test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot-weakmap.js index 22a7744bb57..deb286c182f 100644 --- a/test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot-weakmap.js +++ b/test/sendable/builtins/Map/prototype/get/does-not-have-mapdata-internal-slot-weakmap.js @@ -16,7 +16,7 @@ /*--- esid: sec-map.prototype.get description: > - Throws a TypeError if `this` is a WeakSendableMap object. + Throws a TypeError if `this` is a WeakMap object. info: | SendableMap.prototype.get ( key ) @@ -24,14 +24,14 @@ info: | 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError exception. ... -features: [WeakSendableMap] +features: [WeakMap] ---*/ assert.throws(TypeError, function() { - SendableMap.prototype.get.call(new WeakSendableMap(), 1); + SendableMap.prototype.get.call(new WeakMap(), 1); }); assert.throws(TypeError, function() { var m = new SendableMap(); - m.get.call(new WeakSendableMap(), 1); + m.get.call(new WeakMap(), 1); }); diff --git a/test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot-weakmap.js index 100d823a03d..0f44a465cdd 100644 --- a/test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot-weakmap.js +++ b/test/sendable/builtins/Map/prototype/has/does-not-have-mapdata-internal-slot-weakmap.js @@ -16,7 +16,7 @@ /*--- esid: sec-map.prototype.has description: > - Throws a TypeError if `this` is a WeakSendableMap object. + Throws a TypeError if `this` is a WeakMap object. info: | SendableMap.prototype.has ( key ) @@ -24,14 +24,14 @@ info: | 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError exception. ... -features: [WeakSendableMap] +features: [WeakMap] ---*/ assert.throws(TypeError, function() { - SendableMap.prototype.has.call(new WeakSendableMap(), 1); + SendableMap.prototype.has.call(new WeakMap(), 1); }); assert.throws(TypeError, function() { var m = new SendableMap(); - m.has.call(new WeakSendableMap(), 1); + m.has.call(new WeakMap(), 1); }); diff --git a/test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot-weakmap.js index 2ebc60fc8ab..fbde6bf7d78 100644 --- a/test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot-weakmap.js +++ b/test/sendable/builtins/Map/prototype/keys/does-not-have-mapdata-internal-slot-weakmap.js @@ -16,7 +16,7 @@ /*--- esid: sec-map.prototype.keys description: > - Throws a TypeError if `this` is a WeakSendableMap object. + Throws a TypeError if `this` is a WeakMap object. info: | SendableMap.prototype.keys () @@ -29,14 +29,14 @@ info: | 2. If map does not have a [[SendableMapData]] internal slot, throw a TypeError exception. ... -features: [WeakSendableMap] +features: [WeakMap] ---*/ assert.throws(TypeError, function() { - SendableMap.prototype.keys.call(new WeakSendableMap()); + SendableMap.prototype.keys.call(new WeakMap()); }); assert.throws(TypeError, function() { var m = new SendableMap(); - m.keys.call(new WeakSendableMap()); + m.keys.call(new WeakMap()); }); diff --git a/test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot-weakmap.js index 202f17b535c..0850f6ef7f3 100644 --- a/test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot-weakmap.js +++ b/test/sendable/builtins/Map/prototype/set/does-not-have-mapdata-internal-slot-weakmap.js @@ -16,7 +16,7 @@ /*--- esid: sec-map.prototype.set description: > - Throws a TypeError if `this` is a WeakSendableMap object. + Throws a TypeError if `this` is a WeakMap object. info: | SendableMap.prototype.set ( key , value ) @@ -24,14 +24,14 @@ info: | 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError exception. ... -features: [WeakSendableMap] +features: [WeakMap] ---*/ assert.throws(TypeError, function() { - SendableMap.prototype.set.call(new WeakSendableMap(), 1, 1); + SendableMap.prototype.set.call(new WeakMap(), 1, 1); }); assert.throws(TypeError, function() { var m = new SendableMap(); - m.set.call(new WeakSendableMap(), 1, 1); + m.set.call(new WeakMap(), 1, 1); }); diff --git a/test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot-weakmap.js index 21caf773df1..dcb4f2be24e 100644 --- a/test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot-weakmap.js +++ b/test/sendable/builtins/Map/prototype/size/does-not-have-mapdata-internal-slot-weakmap.js @@ -16,7 +16,7 @@ /*--- esid: sec-get-map.prototype.size description: > - Throws a TypeError if `this` is a WeakSendableMap object. + Throws a TypeError if `this` is a WeakMap object. info: | get SendableMap.prototype.size @@ -25,7 +25,7 @@ info: | 3. If M does not have a [[SendableMapData]] internal slot, throw a TypeError exception. ... -features: [WeakSendableMap] +features: [WeakMap] ---*/ var descriptor = Object.getOwnPropertyDescriptor(SendableMap.prototype, 'size'); @@ -36,5 +36,5 @@ var map = new SendableMap(); descriptor.get.call(map); assert.throws(TypeError, function() { - descriptor.get.call(new WeakSendableMap()); + descriptor.get.call(new WeakMap()); }); diff --git a/test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot-weakmap.js b/test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot-weakmap.js index 7f9b93b8dc4..58f030e9375 100644 --- a/test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot-weakmap.js +++ b/test/sendable/builtins/Map/prototype/values/does-not-have-mapdata-internal-slot-weakmap.js @@ -16,7 +16,7 @@ /*--- esid: sec-map.prototype.values description: > - Throws a TypeError if `this` is a WeakSendableMap object. + Throws a TypeError if `this` is a WeakMap object. info: | SendableMap.prototype.values () @@ -29,14 +29,14 @@ info: | 2. If map does not have a [[SendableMapData]] internal slot, throw a TypeError exception. ... -features: [WeakSendableMap] +features: [WeakMap] ---*/ assert.throws(TypeError, function() { - SendableMap.prototype.values.call(new WeakSendableMap()); + SendableMap.prototype.values.call(new WeakMap()); }); assert.throws(TypeError, function() { var m = new SendableMap(); - m.values.call(new WeakSendableMap()); + m.values.call(new WeakMap()); }); diff --git a/test/sendable/builtins/Map/valid-keys.js b/test/sendable/builtins/Map/valid-keys.js index 7e018757907..db513bc7726 100644 --- a/test/sendable/builtins/Map/valid-keys.js +++ b/test/sendable/builtins/Map/valid-keys.js @@ -53,7 +53,7 @@ const arrowFunctionValue = () => {}; const classValue = class {}; const map = new SendableMap(); const set = new Set(); -const weakSendableMap = new WeakSendableMap(); +const weakMap = new WeakMap(); const weakRef = new WeakRef({}); const weakSet = new WeakSet(); const nullValue = null; @@ -411,17 +411,17 @@ let unassigned; }; { - const m = new SendableMap([[weakSendableMap, weakSendableMap]]); + const m = new SendableMap([[weakMap, weakMap]]); assert.sameValue(m.size, 1); - assert.sameValue(m.has(weakSendableMap), true); - assert.sameValue(m.get(weakSendableMap), weakSendableMap); - m.delete(weakSendableMap); + assert.sameValue(m.has(weakMap), true); + assert.sameValue(m.get(weakMap), weakMap); + m.delete(weakMap); assert.sameValue(m.size, 0); - assert.sameValue(m.has(weakSendableMap), false); - m.set(weakSendableMap, weakSendableMap); + assert.sameValue(m.has(weakMap), false); + m.set(weakMap, weakMap); assert.sameValue(m.size, 1); - assert.sameValue(m.has(weakSendableMap), true); - assert.sameValue(m.get(weakSendableMap), weakSendableMap); + assert.sameValue(m.has(weakMap), true); + assert.sameValue(m.get(weakMap), weakMap); }; { diff --git a/test/sendable/builtins/Set/Symbol.species/length.js b/test/sendable/builtins/Set/Symbol.species/length.js new file mode 100644 index 00000000000..f08cd5e3fe7 --- /dev/null +++ b/test/sendable/builtins/Set/Symbol.species/length.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-set-@@species +description: > + get SendableSet [ @@species ].length is 0. +info: | + get SendableSet [ @@species ] + + 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] +features: [Symbol.species] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableSet, Symbol.species); + +verifyProperty(desc.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/Symbol.species/return-value.js b/test/sendable/builtins/Set/Symbol.species/return-value.js new file mode 100644 index 00000000000..71778bb8e80 --- /dev/null +++ b/test/sendable/builtins/Set/Symbol.species/return-value.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-set-@@species +description: Return value of @@species accessor method +info: | + 1. Return the this value. +features: [Symbol.species] +---*/ + +var thisVal = {}; +var accessor = Object.getOwnPropertyDescriptor(SendableSet, Symbol.species).get; + +assert.sameValue(accessor.call(thisVal), thisVal); diff --git a/test/sendable/builtins/Set/Symbol.species/symbol-species-name.js b/test/sendable/builtins/Set/Symbol.species/symbol-species-name.js new file mode 100644 index 00000000000..daae0593b48 --- /dev/null +++ b/test/sendable/builtins/Set/Symbol.species/symbol-species-name.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-set-@@species +description: > + SendableSet[Symbol.species] accessor property get name +info: | + 23.2.2.2 get SendableSet [ @@species ] + + ... + The value of the name property of this function is "get [Symbol.species]". +features: [Symbol.species] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(SendableSet, Symbol.species); + +assert.sameValue( + descriptor.get.name, + 'get [Symbol.species]' +); diff --git a/test/sendable/builtins/Set/Symbol.species/symbol-species.js b/test/sendable/builtins/Set/Symbol.species/symbol-species.js new file mode 100644 index 00000000000..efa092c9d31 --- /dev/null +++ b/test/sendable/builtins/Set/Symbol.species/symbol-species.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-set-@@species +description: SendableSet[Symbol.species] exists per spec +info: | + SendableSet has a property at `Symbol.species` +author: Sam Mikes +includes: [propertyHelper.js] +features: [Symbol.species] +---*/ + +var desc = Object.getOwnPropertyDescriptor(SendableSet, Symbol.species); + +assert.sameValue(desc.set, undefined); +assert.sameValue(typeof desc.get, 'function'); + +verifyNotWritable(SendableSet, Symbol.species, Symbol.species); +verifyNotEnumerable(SendableSet, Symbol.species); +verifyConfigurable(SendableSet, Symbol.species); diff --git a/test/sendable/builtins/Set/bigint-number-same-value.js b/test/sendable/builtins/Set/bigint-number-same-value.js new file mode 100644 index 00000000000..bffbb9e403f --- /dev/null +++ b/test/sendable/builtins/Set/bigint-number-same-value.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + Observing the expected behavior of keys when a BigInt and Number have + the same value. +info: | + SendableSet.prototype.add ( value ) + + ... + For each element e of entries, do + If e is not empty and SameValueZero(e, value) is true, then + Return S. + If value is -0, set value to +0. + Append value as the last element of entries. + ... + +features: [BigInt] +---*/ + +const number = 9007199254740991; +const bigint = 9007199254740991n; + +const s = new SendableSet([ + number, + bigint, +]); + +assert.sameValue(s.size, 2); +assert.sameValue(s.has(number), true); +assert.sameValue(s.has(bigint), true); + +s.delete(number); +assert.sameValue(s.size, 1); +assert.sameValue(s.has(number), false); +s.delete(bigint); +assert.sameValue(s.size, 0); +assert.sameValue(s.has(bigint), false); + +s.add(number); +assert.sameValue(s.size, 1); +s.add(bigint); +assert.sameValue(s.size, 2); diff --git a/test/sendable/builtins/Set/constructor.js b/test/sendable/builtins/Set/constructor.js new file mode 100644 index 00000000000..f13db4ac767 --- /dev/null +++ b/test/sendable/builtins/Set/constructor.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + The SendableSet constructor is the %SendableSet% intrinsic object and the + initial value of the SendableSet property of the global object. +---*/ + +assert.sameValue(typeof SendableSet, "function", "`typeof SendableSet` is `'function'`"); diff --git a/test/sendable/builtins/Set/is-a-constructor.js b/test/sendable/builtins/Set/is-a-constructor.js new file mode 100644 index 00000000000..fd89d617350 --- /dev/null +++ b/test/sendable/builtins/Set/is-a-constructor.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + The SendableSet constructor implements [[Construct]] +info: | + IsConstructor ( argument ) + + The abstract operation IsConstructor takes argument argument (an ECMAScript language value). + It determines if argument is a function object with a [[Construct]] internal method. + It performs the following steps when called: + + If Type(argument) is not Object, return false. + If argument has a [[Construct]] internal method, return true. + Return false. +includes: [isConstructor.js] +features: [Reflect.construct, SendableSet] +---*/ + +assert.sameValue(isConstructor(SendableSet), true, 'isConstructor(SendableSet) must return true'); +new SendableSet(); + diff --git a/test/sendable/builtins/Set/length.js b/test/sendable/builtins/Set/length.js new file mode 100644 index 00000000000..bc82180910c --- /dev/null +++ b/test/sendable/builtins/Set/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + Properties of the SendableSet Constructor + + Besides the length property (whose value is 0) + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/name.js b/test/sendable/builtins/Set/name.js new file mode 100644 index 00000000000..b3f9f9e0209 --- /dev/null +++ b/test/sendable/builtins/Set/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + SendableSet ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet, "name", { + value: "SendableSet", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/properties-of-the-set-prototype-object.js b/test/sendable/builtins/Set/properties-of-the-set-prototype-object.js new file mode 100644 index 00000000000..355c8f2e14e --- /dev/null +++ b/test/sendable/builtins/Set/properties-of-the-set-prototype-object.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-properties-of-the-set-prototype-object +description: > + The SendableSet prototype object is the intrinsic object %SendableSetPrototype%. + The value of the [[Prototype]] internal slot of the SendableSet prototype + object is the intrinsic object %ObjectPrototype% (19.1.3). The SendableSet + prototype object is an ordinary object. It does not have a + [[SendableSetData]] internal slot. +---*/ + +assert.sameValue( + Object.getPrototypeOf(SendableSet.prototype), + Object.prototype, + "`Object.getPrototypeOf(SendableSet.prototype)` returns `Object.prototype`" +); diff --git a/test/sendable/builtins/Set/proto-from-ctor-realm.js b/test/sendable/builtins/Set/proto-from-ctor-realm.js new file mode 100644 index 00000000000..3039823332e --- /dev/null +++ b/test/sendable/builtins/Set/proto-from-ctor-realm.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-iterable +description: Default [[Prototype]] value derived from realm of the newTarget +info: | + [...] + 2. Let set be ? OrdinaryCreateFromConstructor(NewTarget, "%SendableSetPrototype%", + « [[SendableSetData]] »). + [...] + + 9.1.14 GetPrototypeFromConstructor + + [...] + 3. Let proto be ? Get(constructor, "prototype"). + 4. If Type(proto) is not Object, then + a. Let realm be ? GetFunctionRealm(constructor). + b. Let proto be realm's intrinsic object named intrinsicDefaultProto. + [...] +features: [cross-realm, Reflect] +---*/ + +var other = $262.createRealm().global; +var C = new other.Function(); +C.prototype = null; + +var o = Reflect.construct(SendableSet, [], C); + +assert.sameValue(Object.getPrototypeOf(o), other.SendableSet.prototype); diff --git a/test/sendable/builtins/Set/prototype-of-set.js b/test/sendable/builtins/Set/prototype-of-set.js new file mode 100644 index 00000000000..5b44a0d2d73 --- /dev/null +++ b/test/sendable/builtins/Set/prototype-of-set.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-properties-of-the-set-constructor +description: > + The value of the [[Prototype]] internal slot of the SendableSet constructor + is the intrinsic object %FunctionPrototype% (19.2.3). +---*/ + +assert.sameValue( + Object.getPrototypeOf(SendableSet), + Function.prototype, + "`Object.getPrototypeOf(SendableSet)` returns `Function.prototype`" +); diff --git a/test/sendable/builtins/Set/prototype/Symbol.iterator.js b/test/sendable/builtins/Set/prototype/Symbol.iterator.js new file mode 100644 index 00000000000..4495d2b6d39 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/Symbol.iterator.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype-@@iterator +description: Initial state of the Symbol.iterator property +info: | + The initial value of the @@iterator property is the same function object as + the initial value of the values property. + + Per ES6 section 17, the method should exist on the SendableSet prototype, and it + should be writable and configurable, but not enumerable. +includes: [propertyHelper.js] +features: [Symbol.iterator] +---*/ + +assert.sameValue(SendableSet.prototype[Symbol.iterator], SendableSet.prototype.values); +verifyProperty(SendableSet.prototype, Symbol.iterator, { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/Symbol.iterator/not-a-constructor.js b/test/sendable/builtins/Set/prototype/Symbol.iterator/not-a-constructor.js new file mode 100644 index 00000000000..86941c16a31 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/Symbol.iterator/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableSet.prototype[Symbol.iterator] 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, Symbol, Symbol.iterator, SendableSet, arrow-function] +---*/ + +assert.sameValue( + isConstructor(SendableSet.prototype[Symbol.iterator]), + false, + 'isConstructor(SendableSet.prototype[Symbol.iterator]) must return false' +); + +assert.throws(TypeError, () => { + let s = new SendableSet([]); new s[Symbol.iterator](); +}); + diff --git a/test/sendable/builtins/Set/prototype/Symbol.toStringTag.js b/test/sendable/builtins/Set/prototype/Symbol.toStringTag.js new file mode 100644 index 00000000000..c806d932475 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/Symbol.toStringTag.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype-@@tostringtag +description: > + `Symbol.toStringTag` property descriptor +info: | + The initial value of the @@toStringTag property is the String value + "SendableSet". + + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Symbol.toStringTag] +---*/ + +assert.sameValue(SendableSet.prototype[Symbol.toStringTag], 'SendableSet'); + +verifyProperty(SendableSet.prototype, Symbol.toStringTag, { + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/Symbol.toStringTag/property-descriptor.js b/test/sendable/builtins/Set/prototype/Symbol.toStringTag/property-descriptor.js new file mode 100644 index 00000000000..9e067128d06 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/Symbol.toStringTag/property-descriptor.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype-@@tostringtag +description: > + `Object.prototype.getOwnPropertyDescriptor` should reflect the value and + writability of the @@toStringTag attribute. +includes: [propertyHelper.js] +features: [Symbol.toStringTag] +---*/ + +var SendableSetProto = Object.getPrototypeOf(new SendableSet()); + +assert.sameValue( + SendableSetProto[Symbol.toStringTag], + 'SendableSet', + "The value of `SendableSetProto[Symbol.toStringTag]` is `'SendableSet'`" +); + +verifyProperty(SendableSetProto, Symbol.toStringTag, { + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/add/add.js b/test/sendable/builtins/Set/prototype/add/add.js new file mode 100644 index 00000000000..1c76772546a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/add.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableSet.prototype.add, + "function", + "`typeof SendableSet.prototype.add` is `'function'`" +); + +verifyProperty(SendableSet.prototype, "add", { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-array.js b/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 00000000000..2e1a313119a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.add.call([], 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.add.call([], 1); +}); diff --git a/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-map.js b/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 00000000000..2bee729625b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.add.call(new Map(), 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.add.call(new Map(), 1); +}); diff --git a/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-object.js b/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 00000000000..50a95db2be4 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.add.call({}, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.add.call({}, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-set-prototype.js b/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 00000000000..96ba1e15536 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-set-prototype.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.add.call(SendableSet.prototype, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.add.call(SendableSet.prototype, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-weakset.js b/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 00000000000..8b5dbfe514f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.add.call(new WeakSet(), 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.add.call(new WeakSet(), 1); +}); diff --git a/test/sendable/builtins/Set/prototype/add/length.js b/test/sendable/builtins/Set/prototype/add/length.js new file mode 100644 index 00000000000..1814ffd6d4c --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype.add, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/add/name.js b/test/sendable/builtins/Set/prototype/add/name.js new file mode 100644 index 00000000000..d87d840e283 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype.add, "name", { + value: "add", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/add/not-a-constructor.js b/test/sendable/builtins/Set/prototype/add/not-a-constructor.js new file mode 100644 index 00000000000..3c836157ff5 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/not-a-constructor.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableSet.prototype.add 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, SendableSet, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableSet.prototype.add), false, 'isConstructor(SendableSet.prototype.add) must return false'); + +assert.throws(TypeError, () => { + let s = new SendableSet([]); new s.add(); +}); + diff --git a/test/sendable/builtins/Set/prototype/add/preserves-insertion-order.js b/test/sendable/builtins/Set/prototype/add/preserves-insertion-order.js new file mode 100644 index 00000000000..540854783fc --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/preserves-insertion-order.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + ... + 7. Append value as the last element of entries. + ... +---*/ + +var s = new SendableSet(); +var expects = [1, 2, 3]; + +s.add(1).add(2).add(3); + +s.forEach(function(value) { + assert.sameValue(value, expects.shift()); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); diff --git a/test/sendable/builtins/Set/prototype/add/returns-this-when-ignoring-duplicate.js b/test/sendable/builtins/Set/prototype/add/returns-this-when-ignoring-duplicate.js new file mode 100644 index 00000000000..f010fe2b0aa --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/returns-this-when-ignoring-duplicate.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + 1. Let S be this value. + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + ... + +---*/ + +var s = new SendableSet([1]); + +assert.sameValue(s.add(1), s, "`s.add(1)` returns `s`"); diff --git a/test/sendable/builtins/Set/prototype/add/returns-this.js b/test/sendable/builtins/Set/prototype/add/returns-this.js new file mode 100644 index 00000000000..7ea874e2d9d --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/returns-this.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + 1. Let S be this value. + ... + 8. Return S. + +---*/ + +var s = new SendableSet(); + +assert.sameValue(s.add(1), s, "`s.add(1)` returns `s`"); diff --git a/test/sendable/builtins/Set/prototype/add/this-not-object-throw-boolean.js b/test/sendable/builtins/Set/prototype/add/this-not-object-throw-boolean.js new file mode 100644 index 00000000000..a0079089117 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/this-not-object-throw-boolean.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.add.call(false, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.add.call(false, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/add/this-not-object-throw-null.js b/test/sendable/builtins/Set/prototype/add/this-not-object-throw-null.js new file mode 100644 index 00000000000..e11aa8e4e94 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/this-not-object-throw-null.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.add.call(null, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.add.call(null, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/add/this-not-object-throw-number.js b/test/sendable/builtins/Set/prototype/add/this-not-object-throw-number.js new file mode 100644 index 00000000000..dc0e270e21b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/this-not-object-throw-number.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.add.call(0, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.add.call(0, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/add/this-not-object-throw-string.js b/test/sendable/builtins/Set/prototype/add/this-not-object-throw-string.js new file mode 100644 index 00000000000..08c535cbf8f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/this-not-object-throw-string.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.add.call("", 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.add.call("", 1); +}); diff --git a/test/sendable/builtins/Set/prototype/add/this-not-object-throw-symbol.js b/test/sendable/builtins/Set/prototype/add/this-not-object-throw-symbol.js new file mode 100644 index 00000000000..2719d227ab7 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/this-not-object-throw-symbol.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.add.call(Symbol(), 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.add.call(Symbol(), 1); +}); diff --git a/test/sendable/builtins/Set/prototype/add/this-not-object-throw-undefined.js b/test/sendable/builtins/Set/prototype/add/this-not-object-throw-undefined.js new file mode 100644 index 00000000000..7c5e1de48bb --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/this-not-object-throw-undefined.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.add.call(undefined, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.add.call(undefined, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/add/will-not-add-duplicate-entry-initial-iterable.js b/test/sendable/builtins/Set/prototype/add/will-not-add-duplicate-entry-initial-iterable.js new file mode 100644 index 00000000000..5d5e4ceb7f0 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/will-not-add-duplicate-entry-initial-iterable.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SendableSetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + 6. If value is −0, let value be +0. + 7. Append value as the last element of entries. + ... + +---*/ + +var s = new SendableSet([1]); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); + +s.add(1); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); diff --git a/test/sendable/builtins/Set/prototype/add/will-not-add-duplicate-entry-normalizes-zero.js b/test/sendable/builtins/Set/prototype/add/will-not-add-duplicate-entry-normalizes-zero.js new file mode 100644 index 00000000000..fd07635924f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/will-not-add-duplicate-entry-normalizes-zero.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SendableSetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + 6. If value is −0, let value be +0. + 7. Append value as the last element of entries. + ... + +---*/ + +var s = new SendableSet([-0]); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); + +s.add(-0); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(-0)`"); + +s.add(0); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(0)`"); diff --git a/test/sendable/builtins/Set/prototype/add/will-not-add-duplicate-entry.js b/test/sendable/builtins/Set/prototype/add/will-not-add-duplicate-entry.js new file mode 100644 index 00000000000..0d794adbaef --- /dev/null +++ b/test/sendable/builtins/Set/prototype/add/will-not-add-duplicate-entry.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: > + SendableSet.prototype.add ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SendableSetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + 6. If value is −0, let value be +0. + 7. Append value as the last element of entries. + ... + +---*/ + +var s = new SendableSet(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); + +s.add(1); +s.add(1); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(1); s.add(1);`"); diff --git a/test/sendable/builtins/Set/prototype/clear/clear.js b/test/sendable/builtins/Set/prototype/clear/clear.js new file mode 100644 index 00000000000..57eff4d063c --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/clear.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableSet.prototype.clear, + "function", + "`typeof SendableSet.prototype.clear` is `'function'`" +); + +verifyProperty(SendableSet.prototype, "clear", { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/clear/clears-all-contents-from-iterable.js b/test/sendable/builtins/Set/prototype/clear/clears-all-contents-from-iterable.js new file mode 100644 index 00000000000..5f64a910796 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/clears-all-contents-from-iterable.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of S’s [[SendableSetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. Replace the element of entries whose value is e with an element whose value is empty. + ... + +---*/ + +var s = new SendableSet([1, 2, 3]); + +assert.sameValue(s.size, 3, "The value of `s.size` is `3`"); + +var result = s.clear(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.clear()`"); +assert.sameValue(s.has(1), false, "`s.has(1)` returns `false`"); +assert.sameValue(s.has(2), false, "`s.has(2)` returns `false`"); +assert.sameValue(s.has(3), false, "`s.has(3)` returns `false`"); +assert.sameValue(result, undefined, "The result of `s.clear()` is `undefined`"); diff --git a/test/sendable/builtins/Set/prototype/clear/clears-all-contents.js b/test/sendable/builtins/Set/prototype/clear/clears-all-contents.js new file mode 100644 index 00000000000..aeaa384a4fc --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/clears-all-contents.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of S’s [[SendableSetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. Replace the element of entries whose value is e with an element whose value is empty. + ... + +---*/ + +var s = new SendableSet(); + +s.add(1).add(2).add(3); + +assert.sameValue(s.size, 3, "The value of `s.size` is `3`"); + +var result = s.clear(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.clear()`"); +assert.sameValue(s.has(1), false, "`s.has(1)` returns `false`"); +assert.sameValue(s.has(2), false, "`s.has(2)` returns `false`"); +assert.sameValue(s.has(3), false, "`s.has(3)` returns `false`"); +assert.sameValue(result, undefined, "The result of `s.clear()` is `undefined`"); diff --git a/test/sendable/builtins/Set/prototype/clear/clears-an-empty-set.js b/test/sendable/builtins/Set/prototype/clear/clears-an-empty-set.js new file mode 100644 index 00000000000..dd10b7dd4c3 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/clears-an-empty-set.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + ... + 4. Let entries be the List that is the value of S’s [[SendableSetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. Replace the element of entries whose value is e with an element whose value is empty. + ... + +---*/ + +var s = new SendableSet(); + +var result = s.clear(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); +assert.sameValue(result, undefined, "The result of `s.clear()` is `undefined`"); diff --git a/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js b/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 00000000000..b6a87f4046c --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.clear.call([]); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.clear.call([]); +}); diff --git a/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js b/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 00000000000..3d2218e04de --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.clear.call(new Map()); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.clear.call(new Map()); +}); diff --git a/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js b/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 00000000000..a9e16f9740b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.clear.call({}); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.clear.call({}); +}); diff --git a/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js b/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js new file mode 100644 index 00000000000..45d1886cd56 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-set.prototype.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.clear.call(SendableSet.prototype); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.clear.call(SendableSet.prototype); +}); diff --git a/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js b/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 00000000000..1a78dd40f5e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.clear.call(new WeakSet()); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.clear.call(new WeakSet()); +}); diff --git a/test/sendable/builtins/Set/prototype/clear/length.js b/test/sendable/builtins/Set/prototype/clear/length.js new file mode 100644 index 00000000000..08586731ae6 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype.clear, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/clear/name.js b/test/sendable/builtins/Set/prototype/clear/name.js new file mode 100644 index 00000000000..05bb398f858 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype.clear, "name", { + value: "clear", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/clear/not-a-constructor.js b/test/sendable/builtins/Set/prototype/clear/not-a-constructor.js new file mode 100644 index 00000000000..87e3ec626b8 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/not-a-constructor.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableSet.prototype.clear 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, SendableSet, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableSet.prototype.clear), false, 'isConstructor(SendableSet.prototype.clear) must return false'); + +assert.throws(TypeError, () => { + let s = new SendableSet([]); new s.clear(); +}); + diff --git a/test/sendable/builtins/Set/prototype/clear/returns-undefined.js b/test/sendable/builtins/Set/prototype/clear/returns-undefined.js new file mode 100644 index 00000000000..ee4082cca44 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/returns-undefined.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + ... + 6. Return undefined. + +---*/ + +var s = new SendableSet(); + +assert.sameValue(s.clear(), undefined, "`s.clear()` returns `undefined`"); diff --git a/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-boolean.js b/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-boolean.js new file mode 100644 index 00000000000..c4f8cf85cc9 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-boolean.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.clear.call(false); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.clear.call(false); +}); diff --git a/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-null.js b/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-null.js new file mode 100644 index 00000000000..384d65228f5 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-null.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.clear.call(null); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.clear.call(null); +}); diff --git a/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-number.js b/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-number.js new file mode 100644 index 00000000000..913c69dca02 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-number.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.clear.call(0); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.clear.call(0); +}); diff --git a/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-string.js b/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-string.js new file mode 100644 index 00000000000..4cc4310037e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-string.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.clear.call(""); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.clear.call(""); +}); diff --git a/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-symbol.js b/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-symbol.js new file mode 100644 index 00000000000..4de0afcabcc --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-symbol.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.clear.call(Symbol()); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.clear.call(Symbol()); +}); diff --git a/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-undefined.js b/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-undefined.js new file mode 100644 index 00000000000..8501eb01165 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/clear/this-not-object-throw-undefined.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.clear +description: > + SendableSet.prototype.clear ( ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.clear.call(undefined); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.clear.call(undefined); +}); diff --git a/test/sendable/builtins/Set/prototype/constructor/set-prototype-constructor-intrinsic.js b/test/sendable/builtins/Set/prototype/constructor/set-prototype-constructor-intrinsic.js new file mode 100644 index 00000000000..c6193dc0b98 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/constructor/set-prototype-constructor-intrinsic.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableSet.prototype.constructor + + The initial value of SendableSet.prototype.constructor is the intrinsic object %SendableSet%. + +---*/ + +assert.sameValue( + SendableSet.prototype.constructor, + SendableSet, + "The value of `SendableSet.prototype.constructor` is `SendableSet`" +); diff --git a/test/sendable/builtins/Set/prototype/constructor/set-prototype-constructor.js b/test/sendable/builtins/Set/prototype/constructor/set-prototype-constructor.js new file mode 100644 index 00000000000..672e8815d31 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/constructor/set-prototype-constructor.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableSet ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype, "constructor", { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/delete/delete-entry-initial-iterable.js b/test/sendable/builtins/Set/prototype/delete/delete-entry-initial-iterable.js new file mode 100644 index 00000000000..97fdcebb3d8 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/delete-entry-initial-iterable.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SendableSetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + b. Replace the element of entries whose value is e with an element whose value is empty. + c. Return true. + ... + + +---*/ + +var s = new SendableSet([1]); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); + +var result = s.delete(1); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(1)`"); +assert.sameValue(result, true, "The result of `s.delete(1)` is `true`"); diff --git a/test/sendable/builtins/Set/prototype/delete/delete-entry-normalizes-zero.js b/test/sendable/builtins/Set/prototype/delete/delete-entry-normalizes-zero.js new file mode 100644 index 00000000000..727efb276b1 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/delete-entry-normalizes-zero.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SendableSetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + b. Replace the element of entries whose value is e with an element whose value is empty. + c. Return true. + ... + +---*/ + +var s = new SendableSet([-0]); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`"); + +var result = s.delete(+0); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(-0)`"); +assert.sameValue(result, true, "The result of `s.delete(+0)` is `true`"); diff --git a/test/sendable/builtins/Set/prototype/delete/delete-entry.js b/test/sendable/builtins/Set/prototype/delete/delete-entry.js new file mode 100644 index 00000000000..895e8cf32c6 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/delete-entry.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SendableSetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + i. Return S. + 6. If value is −0, let value be +0. + 7. Append value as the last element of entries. + ... + +---*/ + +var s = new SendableSet(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); + +s.add(1); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(1)`"); + +var result = s.delete(1); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(1)`"); +assert.sameValue(result, true, "The result of `s.delete(1)` is `true`"); diff --git a/test/sendable/builtins/Set/prototype/delete/delete.js b/test/sendable/builtins/Set/prototype/delete/delete.js new file mode 100644 index 00000000000..bc8602ae55a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/delete.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableSet.prototype.delete, + "function", + "`typeof SendableSet.prototype.delete` is `'function'`" +); + +verifyProperty(SendableSet.prototype, "delete", { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-array.js b/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 00000000000..a200e687da8 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.delete.call([], 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.delete.call([], 1); +}); diff --git a/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-map.js b/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 00000000000..e429e6c7ac3 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.delete.call(new Map(), 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.delete.call(new Map(), 1); +}); diff --git a/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-object.js b/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 00000000000..aa5f7032bb4 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.delete.call({}, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.delete.call({}, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-set-prototype.js b/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 00000000000..85819bf5b0b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-set-prototype.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.delete.call(SendableSet.prototype, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.delete.call(SendableSet.prototype, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-weakset.js b/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 00000000000..0b0992731a9 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.delete.call(new WeakSet(), 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.delete.call(new WeakSet(), 1); +}); diff --git a/test/sendable/builtins/Set/prototype/delete/length.js b/test/sendable/builtins/Set/prototype/delete/length.js new file mode 100644 index 00000000000..4bdf2f50794 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype.delete, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/delete/name.js b/test/sendable/builtins/Set/prototype/delete/name.js new file mode 100644 index 00000000000..851b4bf71d9 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype.delete, "name", { + value: "delete", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/delete/not-a-constructor.js b/test/sendable/builtins/Set/prototype/delete/not-a-constructor.js new file mode 100644 index 00000000000..2cc09403734 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/not-a-constructor.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableSet.prototype.delete 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, SendableSet, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableSet.prototype.delete), false, 'isConstructor(SendableSet.prototype.delete) must return false'); + +assert.throws(TypeError, () => { + let s = new SendableSet([]); new s.delete(); +}); + diff --git a/test/sendable/builtins/Set/prototype/delete/returns-false-when-delete-is-noop.js b/test/sendable/builtins/Set/prototype/delete/returns-false-when-delete-is-noop.js new file mode 100644 index 00000000000..411530e0945 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/returns-false-when-delete-is-noop.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + ... + 6. Return false. + +---*/ + +var s = new SendableSet(); + +assert.sameValue(s.delete(1), false, "`s.delete(1)` returns `false`"); diff --git a/test/sendable/builtins/Set/prototype/delete/returns-true-when-delete-operation-occurs.js b/test/sendable/builtins/Set/prototype/delete/returns-true-when-delete-operation-occurs.js new file mode 100644 index 00000000000..650346293ec --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/returns-true-when-delete-operation-occurs.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + ... + 4. Let entries be the List that is the value of S’s [[SendableSetData]] internal slot. + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, then + b. Replace the element of entries whose value is e with an element whose value is empty. + c. Return true. + ... + +---*/ + +var s = new SendableSet(); + +s.add(1); + +assert.sameValue(s.delete(1), true, "`s.delete(1)` returns `true`"); diff --git a/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-boolean.js b/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-boolean.js new file mode 100644 index 00000000000..acd462a2e6f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-boolean.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.delete.call(false, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.delete.call(false, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-null.js b/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-null.js new file mode 100644 index 00000000000..179b36110b8 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-null.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.delete.call(null, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.delete.call(null, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-number.js b/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-number.js new file mode 100644 index 00000000000..fd00dedd788 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-number.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.delete.call(0, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.delete.call(0, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-string.js b/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-string.js new file mode 100644 index 00000000000..cba49f02a30 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-string.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.delete.call("", 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.delete.call("", 1); +}); diff --git a/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-symbol.js b/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-symbol.js new file mode 100644 index 00000000000..94cbd19e650 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-symbol.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.delete.call(Symbol(), 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.delete.call(Symbol(), 1); +}); diff --git a/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-undefined.js b/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-undefined.js new file mode 100644 index 00000000000..5cd6365e807 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/delete/this-not-object-throw-undefined.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.delete +description: > + SendableSet.prototype.delete ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.delete.call(undefined, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.delete.call(undefined, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/difference/add-not-called.js b/test/sendable/builtins/Set/prototype/difference/add-not-called.js new file mode 100644 index 00000000000..6a4c27636c3 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/add-not-called.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference should not call SendableSet.prototype.add +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1]; + +const originalAdd = SendableSet.prototype.add; +let count = 0; +SendableSet.prototype.add = function (...rest) { + count++; + return originalAdd.apply(this, rest); +}; + +const combined = s1.difference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue(count, 0, "Add is never called"); + +SendableSet.prototype.add = originalAdd; diff --git a/test/sendable/builtins/Set/prototype/difference/allows-set-like-class.js b/test/sendable/builtins/Set/prototype/difference/allows-set-like-class.js new file mode 100644 index 00000000000..24518f454db --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/allows-set-like-class.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: GetSendableSetRecord allows instances of SendableSet-like classes +info: | + 1. If obj is not an Object, throw a TypeError exception. + 2. Let rawSize be ? Get(obj, "size"). + ... + 7. Let has be ? Get(obj, "has"). + ... + 9. Let keys be ? Get(obj, "keys"). +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new class { + get size() { + return 2; + } + has(v) { + if (v === 1) return false; + if (v === 2) return true; + throw new Test262Error("SendableSet.prototype.difference should only call its argument's has method with contents of this"); + } + * keys() { + throw new Test262Error("SendableSet.prototype.difference should not call its argument's keys iterator when this.size ≤ arg.size"); + } +}; +const expected = [1]; +const combined = s1.difference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/difference/allows-set-like-object.js b/test/sendable/builtins/Set/prototype/difference/allows-set-like-object.js new file mode 100644 index 00000000000..5ffc8000941 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/allows-set-like-object.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: GetSendableSetRecord allows SendableSet-like objects +info: | + 1. If obj is not an Object, throw a TypeError exception. + 2. Let rawSize be ? Get(obj, "size"). + ... + 7. Let has be ? Get(obj, "has"). + ... + 9. Let keys be ? Get(obj, "keys"). +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: (v) => { + if (v === 1) return false; + if (v === 2) return true; + throw new Test262Error("SendableSet.prototype.difference should only call its argument's has method with contents of this"); + }, + keys: function* keys() { + throw new Test262Error("SendableSet.prototype.difference should not call its argument's keys iterator when this.size ≤ arg.size"); + }, +}; +const expected = [1]; +const combined = s1.difference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/difference/array-throws.js b/test/sendable/builtins/Set/prototype/difference/array-throws.js new file mode 100644 index 00000000000..396fa8526e1 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/array-throws.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference doesn't work with arrays +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = [3]; +assert.throws( + TypeError, + function () { + s1.difference(s2); + }, + "Throws an error when an array is used" +); diff --git a/test/sendable/builtins/Set/prototype/difference/builtins.js b/test/sendable/builtins/Set/prototype/difference/builtins.js new file mode 100644 index 00000000000..fdae2112d71 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/builtins.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: Tests that SendableSet.prototype.difference meets the requirements for built-in objects +features: [set-methods] +---*/ + +assert.sameValue( + Object.isExtensible(SendableSet.prototype.difference), + true, + "Built-in objects must be extensible." +); + +assert.sameValue( + Object.prototype.toString.call(SendableSet.prototype.difference), + "[object Function]", + "Object.prototype.toString" +); + +assert.sameValue( + Object.getPrototypeOf(SendableSet.prototype.difference), + Function.prototype, + "prototype" +); diff --git a/test/sendable/builtins/Set/prototype/difference/called-with-object.js b/test/sendable/builtins/Set/prototype/difference/called-with-object.js new file mode 100644 index 00000000000..9cacb497ada --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/called-with-object.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws if obj is not an object +info: | + 1. If obj is not an Object, throw a TypeError exception. +features: [set-methods] +---*/ + +let s1 = new SendableSet([1]); +assert.throws( + TypeError, + function () { + s1.difference(1); + }, + "number" +); + +assert.throws( + TypeError, + function () { + s1.difference(""); + }, + "string" +); + +assert.throws( + TypeError, + function () { + s1.difference(1n); + }, + "bigint" +); + +assert.throws( + TypeError, + function () { + s1.difference(false); + }, + "boolean" +); + +assert.throws( + TypeError, + function () { + s1.difference(undefined); + }, + "undefined" +); + +assert.throws( + TypeError, + function () { + s1.difference(null); + }, + "null" +); + +assert.throws( + TypeError, + function () { + s1.difference(Symbol("test")); + }, + "symbol" +); diff --git a/test/sendable/builtins/Set/prototype/difference/combines-Map.js b/test/sendable/builtins/Set/prototype/difference/combines-Map.js new file mode 100644 index 00000000000..3efdb8ecd63 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/combines-Map.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference combines with Map +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const m1 = new Map([ + [2, "two"], + [3, "three"], +]); +const expected = [1]; +const combined = s1.difference(m1); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/difference/combines-empty-sets.js b/test/sendable/builtins/Set/prototype/difference/combines-empty-sets.js new file mode 100644 index 00000000000..a996ced8dd0 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/combines-empty-sets.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference can combine empty SendableSets +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([]); +const s2 = new SendableSet([1, 2]); +let expected = []; +let combined = s1.difference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); + +const s3 = new SendableSet([1, 2]); +const s4 = new SendableSet([]); +expected = [1, 2]; +combined = s3.difference(s4); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); + +const s5 = new SendableSet([]); +const s6 = new SendableSet([]); +expected = []; +combined = s5.difference(s6); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/difference/combines-itself.js b/test/sendable/builtins/Set/prototype/difference/combines-itself.js new file mode 100644 index 00000000000..f301a6a7b01 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/combines-itself.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference is successful when called on itself +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const expected = []; +const combined = s1.difference(s1); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue(combined === s1, false, "The returned object is a new object"); diff --git a/test/sendable/builtins/Set/prototype/difference/combines-same-sets.js b/test/sendable/builtins/Set/prototype/difference/combines-same-sets.js new file mode 100644 index 00000000000..1821fe36134 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/combines-same-sets.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference can combine SendableSets that have the same content +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([1, 2]); +const expected = []; +const combined = s1.difference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue(combined === s1, false, "The returned object is a new object"); +assert.sameValue(combined === s2, false, "The returned object is a new object"); diff --git a/test/sendable/builtins/Set/prototype/difference/combines-sets.js b/test/sendable/builtins/Set/prototype/difference/combines-sets.js new file mode 100644 index 00000000000..6c2d6941823 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/combines-sets.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference combines SendableSets +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1]; +const combined = s1.difference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/difference/converts-negative-zero.js b/test/sendable/builtins/Set/prototype/difference/converts-negative-zero.js new file mode 100644 index 00000000000..247bb6f81ac --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/converts-negative-zero.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference converts -0𝔽 to +0𝔽 +info: | + 7.b.ii If nextValue is -0𝔽, set nextValue to +0𝔽. +features: [set-methods] +includes: [compareArray.js] +---*/ + +const setlikeWithMinusZero = { + size: 1, + has: function () { + throw new Test262Error("SendableSet.prototype.difference should not call its argument's has method when this.size > arg.size"); + }, + keys: function () { + // we use an array here because the SendableSet constructor would normalize away -0 + return [-0].values(); + }, +}; + +const s1 = new SendableSet([+0, 1]); +let expected = [1]; +let combined = s1.difference(setlikeWithMinusZero); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/difference/difference.js b/test/sendable/builtins/Set/prototype/difference/difference.js new file mode 100644 index 00000000000..017602a9a49 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/difference.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference properties +includes: [propertyHelper.js] +features: [set-methods] +---*/ + +assert.sameValue( + typeof SendableSet.prototype.difference, + "function", + "`typeof SendableSet.prototype.difference` is `'function'`" +); + +verifyProperty(SendableSet.prototype, "difference", { + enumerable: false, + writable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/difference/has-is-callable.js b/test/sendable/builtins/Set/prototype/difference/has-is-callable.js new file mode 100644 index 00000000000..43e12d53010 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/has-is-callable.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object's 'has' property is not callable +info: | + 7. Let has be ? Get(obj, "has"). + 8. If IsCallable(has) is false, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: undefined, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + function () { + s1.difference(s2); + }, + "GetSendableSetRecord throws an error when has is undefined" +); + +s2.has = {}; +assert.throws( + TypeError, + function () { + s1.difference(s2); + }, + "GetSendableSetRecord throws an error when has is not callable" +); diff --git a/test/sendable/builtins/Set/prototype/difference/keys-is-callable.js b/test/sendable/builtins/Set/prototype/difference/keys-is-callable.js new file mode 100644 index 00000000000..ab27cc75899 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/keys-is-callable.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object's 'keys' property is not callable +info: | + 9. Let keys be ? Get(obj, "keys"). + 10. If IsCallable(keys) is false, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: () => {}, + keys: undefined, +}; +assert.throws( + TypeError, + function () { + s1.difference(s2); + }, + "GetSendableSetRecord throws an error when keys is undefined" +); + +s2.keys = {}; +assert.throws( + TypeError, + function () { + s1.difference(s2); + }, + "GetSendableSetRecord throws an error when keys is not callable" +); diff --git a/test/sendable/builtins/Set/prototype/difference/length.js b/test/sendable/builtins/Set/prototype/difference/length.js new file mode 100644 index 00000000000..f6e078301f2 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference length property +info: | + SendableSet.prototype.difference ( other ) +includes: [propertyHelper.js] +features: [set-methods] +---*/ +assert.sameValue(typeof SendableSet.prototype.difference, "function"); + +verifyProperty(SendableSet.prototype.difference, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 1, +}); diff --git a/test/sendable/builtins/Set/prototype/difference/name.js b/test/sendable/builtins/Set/prototype/difference/name.js new file mode 100644 index 00000000000..459eb5bec64 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference name property +info: | + SendableSet.prototype.difference ( other ) +includes: [propertyHelper.js] +features: [set-methods] +---*/ +assert.sameValue(typeof SendableSet.prototype.difference, "function"); + +verifyProperty(SendableSet.prototype.difference, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "difference", +}); diff --git a/test/sendable/builtins/Set/prototype/difference/not-a-constructor.js b/test/sendable/builtins/Set/prototype/difference/not-a-constructor.js new file mode 100644 index 00000000000..4b229908785 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/not-a-constructor.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference does not implement [[Construct]], is not new-able +includes: [isConstructor.js] +features: [Reflect.construct, set-methods] +---*/ + +assert.sameValue( + isConstructor(SendableSet.prototype.difference), + false, + "isConstructor(SendableSet.prototype.difference) must return false" +); + +assert.throws( + TypeError, + () => { + new SendableSet.prototype.difference(); + }); diff --git a/test/sendable/builtins/Set/prototype/difference/receiver-not-set.js b/test/sendable/builtins/Set/prototype/difference/receiver-not-set.js new file mode 100644 index 00000000000..293c8311c47 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/receiver-not-set.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference throws when receiver is not a SendableSet +features: [set-methods] +---*/ + +class MySendableSetLike { + constructor() { + this.size = 2; + this.has = () => {}; + this.keys = function* keys() { + yield 2; + yield 3; + }; + } +} + +const s1 = new MySendableSetLike(); +const s2 = new SendableSet(); +assert.throws( + TypeError, + () => { + SendableSet.prototype.difference.call(s1, s2); + }, + "SendableSet-like class" +); + +const s3 = { + size: 2, + has: () => {}, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + () => { + SendableSet.prototype.difference.call(s3, s2); + }, + "SendableSet-like object" +); diff --git a/test/sendable/builtins/Set/prototype/difference/require-internal-slot.js b/test/sendable/builtins/Set/prototype/difference/require-internal-slot.js new file mode 100644 index 00000000000..9ee5fbc1f27 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/require-internal-slot.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference RequireInternalSlot +info: | + 2. Perform ? RequireInternalSlot(O, [[SendableSetData]]) +features: [set-methods] +---*/ + +const difference = SendableSet.prototype.difference; + +assert.sameValue(typeof difference, "function"); + +const realSendableSet = new SendableSet([]); + +assert.throws(TypeError, () => difference.call(undefined, realSendableSet), "undefined"); +assert.throws(TypeError, () => difference.call(null, realSendableSet), "null"); +assert.throws(TypeError, () => difference.call(true, realSendableSet), "true"); +assert.throws(TypeError, () => difference.call("", realSendableSet), "empty string"); +assert.throws(TypeError, () => difference.call(Symbol(), realSendableSet), "symbol"); +assert.throws(TypeError, () => difference.call(1, realSendableSet), "1"); +assert.throws(TypeError, () => difference.call(1n, realSendableSet), "1n"); +assert.throws(TypeError, () => difference.call({}, realSendableSet), "plain object"); +assert.throws(TypeError, () => difference.call([], realSendableSet), "array"); +assert.throws(TypeError, () => difference.call(new Map(), realSendableSet), "map"); +assert.throws(TypeError, () => difference.call(SendableSet.prototype, realSendableSet), "SendableSet.prototype"); diff --git a/test/sendable/builtins/Set/prototype/difference/result-order.js b/test/sendable/builtins/Set/prototype/difference/result-order.js new file mode 100644 index 00000000000..789a1ddf8e7 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/result-order.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference orders results as in this, regardless of sizes +features: [set-methods] +includes: [compareArray.js] +---*/ + +{ + const s1 = new SendableSet([1, 2, 3, 4]); + const s2 = new SendableSet([6, 5, 3, 2]); + + assert.compareArray([...s1.difference(s2)], [1, 4]); +} + +{ + const s1 = new SendableSet([6, 5, 3, 2]); + const s2 = new SendableSet([1, 2, 3, 4]); + + assert.compareArray([...s1.difference(s2)], [6, 5]); +} + +{ + const s1 = new SendableSet([1, 2, 3, 4]); + const s2 = new SendableSet([7, 6, 5, 3, 2]); + + assert.compareArray([...s1.difference(s2)], [1, 4]); +} + +{ + const s1 = new SendableSet([7, 6, 5, 3, 2]); + const s2 = new SendableSet([1, 2, 3, 4]); + + assert.compareArray([...s1.difference(s2)], [7, 6, 5]); +} + diff --git a/test/sendable/builtins/Set/prototype/difference/set-like-array.js b/test/sendable/builtins/Set/prototype/difference/set-like-array.js new file mode 100644 index 00000000000..9da2fd7448a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/set-like-array.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference consumes a set-like array as a set-like, not an array +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = [5, 6]; +s2.size = 3; +s2.has = function (v) { + if (v === 1) return false; + if (v === 2) return true; + throw new Test262Error("SendableSet.prototype.difference should only call its argument's has method with contents of this"); +}; +s2.keys = function () { + throw new Test262Error("SendableSet.prototype.difference should not call its argument's keys iterator when this.size ≤ arg.size"); +}; + +const expected = [1]; +const combined = s1.difference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/difference/set-like-class-mutation.js b/test/sendable/builtins/Set/prototype/difference/set-like-class-mutation.js new file mode 100644 index 00000000000..fb839765ffa --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/set-like-class-mutation.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference maintains values even when a custom SendableSet-like class mutates the receiver +features: [set-methods] +includes: [compareArray.js] +---*/ + +const baseSendableSet = new SendableSet(["a", "b", "c", "d", "e"]); + +function mutatingIterator() { + let index = 0; + let values = ["x", "b", "b"]; + return { + next() { + if (index === 0) { + baseSendableSet.delete("b"); + baseSendableSet.delete("c"); + baseSendableSet.add("b"); + baseSendableSet.add("d"); + } + return { + done: index >= values.length, + value: values[index++], + }; + }, + }; +} + +const evilSendableSetLike = { + size: 3, + get has() { + baseSendableSet.add("q"); + return function () { + throw new Test262Error("SendableSet.prototype.difference should not invoke .has on its argument when this.size > other.size"); + }; + }, + keys() { + return mutatingIterator(); + }, +}; + +const combined = baseSendableSet.difference(evilSendableSetLike); +const expectedCombined = ["a", "c", "d", "e", "q"]; +assert.compareArray([...combined], expectedCombined); + +const expectedNewBase = ["a", "d", "e", "q", "b"]; +assert.compareArray([...baseSendableSet], expectedNewBase); diff --git a/test/sendable/builtins/Set/prototype/difference/set-like-class-order.js b/test/sendable/builtins/Set/prototype/difference/set-like-class-order.js new file mode 100644 index 00000000000..2f627ff61ab --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/set-like-class-order.js @@ -0,0 +1,153 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference calls a SendableSet-like class's methods in order +features: [set-methods] +includes: [compareArray.js] +---*/ + +let observedOrder = []; + +function observableIterator() { + let values = ["a", "b", "c"]; + let index = 0; + return { + get next() { + observedOrder.push("getting next"); + return function () { + observedOrder.push("calling next"); + return { + get done() { + observedOrder.push("getting done"); + return index >= values.length; + }, + get value() { + observedOrder.push("getting value"); + return values[index++]; + }, + }; + }; + }, + }; +} + +class MySendableSetLike { + get size() { + observedOrder.push("getting size"); + return { + valueOf: function () { + observedOrder.push("ToNumber(size)"); + return 3; + }, + }; + } + get has() { + observedOrder.push("getting has"); + return function (v) { + observedOrder.push("calling has"); + return ["a", "b", "c"].indexOf(v) !== -1; + }; + } + get keys() { + observedOrder.push("getting keys"); + return function () { + observedOrder.push("calling keys"); + return observableIterator(); + }; + } +} + +// this is smaller than argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "d"]); + const s2 = new MySendableSetLike(); + const combined = s1.difference(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + // two calls to has + "calling has", + "calling has", + ]; + + assert.compareArray([...combined], ["d"]); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is same size as argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "b", "d"]); + const s2 = new MySendableSetLike(); + const combined = s1.difference(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + // three calls to has + "calling has", + "calling has", + "calling has", + ]; + + assert.compareArray([...combined], ["d"]); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is larger than argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "b", "c", "d"]); + const s2 = new MySendableSetLike(); + const combined = s1.difference(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + "calling keys", + "getting next", + // first iteration, has value + "calling next", + "getting done", + "getting value", + // second iteration, has value + "calling next", + "getting done", + "getting value", + // third iteration, has value + "calling next", + "getting done", + "getting value", + // fourth iteration, no value; ends + "calling next", + "getting done", + ]; + + assert.compareArray([...combined], ["d"]); + assert.compareArray(observedOrder, expectedOrder); +} diff --git a/test/sendable/builtins/Set/prototype/difference/size-is-a-number.js b/test/sendable/builtins/Set/prototype/difference/size-is-a-number.js new file mode 100644 index 00000000000..df5704bbec9 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/size-is-a-number.js @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object has a size that is coerced to NaN +info: | + 2. Let rawSize be ? Get(obj, "size"). + 3. Let numSize be ? ToNumber(rawSize). + 4. NOTE: If rawSize is undefined, then numSize will be NaN. + 5. If numSize is NaN, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: undefined, + has: () => {}, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + function () { + s1.difference(s2); + }, + "GetSendableSetRecord throws an error when size is undefined" +); + +s2.size = NaN; +assert.throws( + TypeError, + function () { + s1.difference(s2); + }, + "GetSendableSetRecord throws an error when size is NaN" +); + +let coercionCalls = 0; +s2.size = { + valueOf: function() { + ++coercionCalls; + return NaN; + }, +}; +assert.throws( + TypeError, + function () { + s1.difference(s2); + }, + "GetSendableSetRecord throws an error when size coerces to NaN" +); +assert.sameValue(coercionCalls, 1, "GetSendableSetRecord coerces size"); + +s2.size = 0n; +assert.throws( + TypeError, + function () { + s1.difference(s2); + }, + "GetSendableSetRecord throws an error when size is a BigInt" +); + +s2.size = "string"; +assert.throws( + TypeError, + function () { + s1.difference(s2); + }, + "GetSendableSetRecord throws an error when size is a non-numeric string" +); diff --git a/test/sendable/builtins/Set/prototype/difference/subclass-receiver-methods.js b/test/sendable/builtins/Set/prototype/difference/subclass-receiver-methods.js new file mode 100644 index 00000000000..6278f67a96f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/subclass-receiver-methods.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference works on subclasses of SendableSet, but never calls the receiver's size/has/keys methods +features: [set-methods] +includes: [compareArray.js] +---*/ + +let sizeCount = 0; +let hasCount = 0; +let keysCount = 0; + +class MySendableSet extends SendableSet { + size(...rest) { + sizeCount++; + return super.size(...rest); + } + + has(...rest) { + hasCount++; + return super.has(...rest); + } + + keys(...rest) { + keysCount++; + return super.keys(...rest); + } +} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1]; +const combined = s1.difference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue( + combined instanceof MySendableSet, + false, + "The returned object is a SendableSet, not a subclass" +); +assert.sameValue(sizeCount, 0, "size should not be called on the receiver"); +assert.sameValue(hasCount, 0, "has should not be called on the receiver"); +assert.sameValue(keysCount, 0, "keys should not be called on the receiver"); diff --git a/test/sendable/builtins/Set/prototype/difference/subclass-symbol-species.js b/test/sendable/builtins/Set/prototype/difference/subclass-symbol-species.js new file mode 100644 index 00000000000..bb37e12b712 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/subclass-symbol-species.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference works on subclasses of SendableSet, but returns an instance of SendableSet even when Symbol.species is overridden. +features: [set-methods] +includes: [compareArray.js] +---*/ +var count = 0; +class MySendableSet extends SendableSet { + static get [Symbol.species]() { + count++; + return SendableSet; + } +} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1]; +const combined = s1.difference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(count, 0, "Symbol.species is never called"); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue( + combined instanceof MySendableSet, + false, + "The returned object is a SendableSet, not a subclass" +); diff --git a/test/sendable/builtins/Set/prototype/difference/subclass.js b/test/sendable/builtins/Set/prototype/difference/subclass.js new file mode 100644 index 00000000000..dc5668b91b3 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/difference/subclass.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.difference +description: SendableSet.prototype.difference works on subclasses of SendableSet, but returns an instance of SendableSet +features: [set-methods] +includes: [compareArray.js] +---*/ + +class MySendableSet extends SendableSet {} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1]; +const combined = s1.difference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue( + combined instanceof MySendableSet, + false, + "The returned object is a SendableSet, not a subclass" +); diff --git a/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-array.js b/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 00000000000..531bfa35fd6 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + ... + 2. Return CreateSendableSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + ... + 2. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.entries.call([]); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.entries.call([]); +}); diff --git a/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-map.js b/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 00000000000..6bae5c7e99d --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + ... + 2. Return CreateSendableSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + ... + 2. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.entries.call(new Map()); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.entries.call(new Map()); +}); diff --git a/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-object.js b/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 00000000000..2129bf806a3 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + ... + 2. Return CreateSendableSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + ... + 2. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.entries.call({}); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.entries.call({}); +}); diff --git a/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-set-prototype.js b/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 00000000000..0d7815b25b5 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-set-prototype.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + ... + 2. Return CreateSendableSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + ... + 2. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.entries.call(SendableSet.prototype); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.entries.call(SendableSet.prototype); +}); diff --git a/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-weakset.js b/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 00000000000..f7503407f44 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + ... + 2. Return CreateSendableSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + ... + 2. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.entries.call(new WeakSet()); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.entries.call(new WeakSet()); +}); diff --git a/test/sendable/builtins/Set/prototype/entries/entries.js b/test/sendable/builtins/Set/prototype/entries/entries.js new file mode 100644 index 00000000000..708e89de539 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/entries.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableSet.prototype.entries, + "function", + "`typeof SendableSet.prototype.entries` is `'function'`" +); + +verifyProperty(SendableSet.prototype, "entries", { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/entries/length.js b/test/sendable/builtins/Set/prototype/entries/length.js new file mode 100644 index 00000000000..6632bb6805e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype.entries, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/entries/name.js b/test/sendable/builtins/Set/prototype/entries/name.js new file mode 100644 index 00000000000..4578beae6c1 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype.entries, "name", { + value: "entries", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/entries/not-a-constructor.js b/test/sendable/builtins/Set/prototype/entries/not-a-constructor.js new file mode 100644 index 00000000000..3c5fd807125 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableSet.prototype.entries 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, SendableSet, arrow-function] +---*/ + +assert.sameValue( + isConstructor(SendableSet.prototype.entries), + false, + 'isConstructor(SendableSet.prototype.entries) must return false' +); + +assert.throws(TypeError, () => { + let s = new SendableSet([]); new s.entries(); +}); + diff --git a/test/sendable/builtins/Set/prototype/entries/returns-iterator-empty.js b/test/sendable/builtins/Set/prototype/entries/returns-iterator-empty.js new file mode 100644 index 00000000000..57c0c891479 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/returns-iterator-empty.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + ... + 2. Return CreateSendableSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + ... + 7. Return iterator. + + +---*/ + +var set = new SendableSet(); +var iterator = set.entries(); +var result = iterator.next(); + +assert.sameValue(result.value, undefined, "The value of `result.value` is `undefined`"); +assert.sameValue(result.done, true, "The value of `result.done` is `true`"); diff --git a/test/sendable/builtins/Set/prototype/entries/returns-iterator.js b/test/sendable/builtins/Set/prototype/entries/returns-iterator.js new file mode 100644 index 00000000000..2e7724b7e05 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/returns-iterator.js @@ -0,0 +1,69 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + ... + 2. Return CreateSendableSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + ... + 7. Return iterator. + + +---*/ + +var set = new SendableSet(); +set.add(1); +set.add(2); +set.add(3); + +var iterator = set.entries(); +var result; + +result = iterator.next(); +assert.sameValue(result.value[0], 1, 'First result `value` ("key")'); +assert.sameValue(result.value[1], 1, 'First result `value` ("value")'); +assert.sameValue(result.value.length, 2, 'First result `value` (length)'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value[0], 2, 'Second result `value` ("key")'); +assert.sameValue(result.value[1], 2, 'Second result `value` ("value")'); +assert.sameValue(result.value.length, 2, 'Second result `value` (length)'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value[0], 3, 'Third result `value` ("key")'); +assert.sameValue(result.value[1], 3, 'Third result `value` ("value")'); +assert.sameValue(result.value.length, 2, 'Third result `value` (length)'); +assert.sameValue(result.done, false, 'Third result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); + +result = iterator.next(); +assert.sameValue( + result.value, undefined, 'Exhausted result `value` (repeated request)' +); +assert.sameValue( + result.done, true, 'Exhausted result `done` flag (repeated request)' +); diff --git a/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-boolean.js b/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-boolean.js new file mode 100644 index 00000000000..54a92290cda --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-boolean.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + ... + 2. Return CreateSendableSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.entries.call(false); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.entries.call(false); +}); diff --git a/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-null.js b/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-null.js new file mode 100644 index 00000000000..07bb3542cb0 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-null.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + ... + 2. Return CreateSendableSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.entries.call(null); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.entries.call(null); +}); diff --git a/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-number.js b/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-number.js new file mode 100644 index 00000000000..1534f1bb98f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-number.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + ... + 2. Return CreateSendableSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.entries.call(0); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.entries.call(0); +}); diff --git a/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-string.js b/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-string.js new file mode 100644 index 00000000000..19b90304285 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-string.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + ... + 2. Return CreateSendableSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.entries.call(""); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.entries.call(""); +}); diff --git a/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-symbol.js b/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-symbol.js new file mode 100644 index 00000000000..2c0989f1f57 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-symbol.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + ... + 2. Return CreateSendableSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.entries.call(Symbol()); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.entries.call(Symbol()); +}); diff --git a/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-undefined.js b/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-undefined.js new file mode 100644 index 00000000000..f6f06c62b7d --- /dev/null +++ b/test/sendable/builtins/Set/prototype/entries/this-not-object-throw-undefined.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.entries +description: > + SendableSet.prototype.entries ( ) + + ... + 2. Return CreateSendableSetIterator(S, "key+value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.entries.call(undefined); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.entries.call(undefined); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-boolean.js b/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-boolean.js new file mode 100644 index 00000000000..2cc150d8880 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-boolean.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `false` as callback + +---*/ + +var s = new SendableSet([1]); + +assert.throws(TypeError, function() { + s.forEach(false); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-null.js b/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-null.js new file mode 100644 index 00000000000..06bcfa4a59a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-null.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `null` as callback + +---*/ + +var s = new SendableSet([1]); + +assert.throws(TypeError, function() { + s.forEach(null); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-number.js b/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-number.js new file mode 100644 index 00000000000..869213fc0c8 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-number.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `number` as callback + +---*/ + +var s = new SendableSet([1]); + +assert.throws(TypeError, function() { + s.forEach(0); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-string.js b/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-string.js new file mode 100644 index 00000000000..d2cbfc17147 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-string.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `string` as callback + +---*/ + +var s = new SendableSet([1]); + +assert.throws(TypeError, function() { + s.forEach(""); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-symbol.js b/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-symbol.js new file mode 100644 index 00000000000..32f51e5a38e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-symbol.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `symbol` as callback + +features: [Symbol] +---*/ + +var s = new SendableSet([1]); + +assert.throws(TypeError, function() { + s.forEach(Symbol()); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-undefined.js b/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-undefined.js new file mode 100644 index 00000000000..1ff798bf033 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/callback-not-callable-undefined.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 4. If IsCallable(callbackfn) is false, throw a TypeError exception. + ... + + Passing `undefined` as callback + +---*/ + +var s = new SendableSet([1]); + +assert.throws(TypeError, function() { + s.forEach(undefined); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-array.js b/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 00000000000..3c6c1d8fddc --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.forEach.call([], function() {}); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.forEach.call([], function() {}); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-map.js b/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 00000000000..69c5ac5ecaa --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.forEach.call(new Map(), function() {}); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.forEach.call(new Map(), function() {}); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-object.js b/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 00000000000..621904c043d --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.forEach.call({}, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.forEach.call({}, function() {}); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-set-prototype.js b/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 00000000000..ce4ed46ecb1 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-set-prototype.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.forEach.call(SendableSet.prototype, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.forEach.call(SendableSet.prototype, function() {}); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-weakset.js b/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 00000000000..e974585e9d4 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.forEach.call(new WeakSet(), function() {}); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.forEach.call(new WeakSet(), function() {}); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/forEach.js b/test/sendable/builtins/Set/prototype/forEach/forEach.js new file mode 100644 index 00000000000..ae24cc2d67b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/forEach.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableSet.prototype.forEach, + "function", + "`typeof SendableSet.prototype.forEach` is `'function'`" +); + +verifyProperty(SendableSet.prototype, "forEach", { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/iterates-in-insertion-order.js b/test/sendable/builtins/Set/prototype/forEach/iterates-in-insertion-order.js new file mode 100644 index 00000000000..1c5e39d3424 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/iterates-in-insertion-order.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... +---*/ + +var s = new SendableSet(); +var expects = [1, 2, 3]; + +s.add(1).add(2).add(3); + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); diff --git a/test/sendable/builtins/Set/prototype/forEach/iterates-in-iterable-entry-order.js b/test/sendable/builtins/Set/prototype/forEach/iterates-in-iterable-entry-order.js new file mode 100644 index 00000000000..0fa445eed17 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/iterates-in-iterable-entry-order.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... +---*/ + +var expects = [1, 2, 3]; +var s = new SendableSet(expects); + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); diff --git a/test/sendable/builtins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js b/test/sendable/builtins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js new file mode 100644 index 00000000000..fa7b446dbc9 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/iterates-values-added-after-foreach-begins.js @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... + + NOTE: + + ... + New values added after the call to forEach begins are visited. + +---*/ + + +var s = new SendableSet([1]); +var expects = [1, 2, 3]; + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + if (value === 1) { + set.add(2); + } + + if (value === 2) { + set.add(3); + } + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); diff --git a/test/sendable/builtins/Set/prototype/forEach/iterates-values-deleted-then-readded.js b/test/sendable/builtins/Set/prototype/forEach/iterates-values-deleted-then-readded.js new file mode 100644 index 00000000000..4ccca0f109b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/iterates-values-deleted-then-readded.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... + + NOTE: + + ... + Values that are deleted after the call to forEach begins and before being visited are not visited unless the value is added again before the forEach call completes. + ... + +---*/ + + +var s = new SendableSet([1, 2, 3]); +var expects = [1, 3, 2]; + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + // Delete `2` before being visited + if (value === 1) { + set.delete(2); + } + + // Re-add `2` before forEach call completes + if (value === 3) { + set.add(2); + } + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); diff --git a/test/sendable/builtins/Set/prototype/forEach/iterates-values-not-deleted.js b/test/sendable/builtins/Set/prototype/forEach/iterates-values-not-deleted.js new file mode 100644 index 00000000000..2767432cfcd --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/iterates-values-not-deleted.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... + + NOTE: + + callbackfn should be a function that accepts three arguments. forEach calls callbackfn once for each value present in the set object, in value insertion order. callbackfn is called only for values of the SendableSet which actually exist; it is not called for keys that have been deleted from the set. + +---*/ + +var expects = [1, 3]; +var s = new SendableSet([1, 2, 3]); + +s.delete(2); + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "`forEach` is not a no-op"); diff --git a/test/sendable/builtins/Set/prototype/forEach/iterates-values-revisits-after-delete-re-add.js b/test/sendable/builtins/Set/prototype/forEach/iterates-values-revisits-after-delete-re-add.js new file mode 100644 index 00000000000..daa7c929a95 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/iterates-values-revisits-after-delete-re-add.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... + + NOTE: + + ... + a value will be revisited if it is deleted after it has been visited and then re-added before the forEach call completes. + ... + +---*/ + + +var s = new SendableSet([1, 2, 3]); +var expects = [1, 2, 3, 1]; + +s.forEach(function(value, entry, set) { + var expect = expects.shift(); + + // Delete `1` after visit + if (value === 2) { + set.delete(1); + } + + // Re-add `1` + if (value === 3) { + set.add(1); + } + + assert.sameValue(value, expect); + assert.sameValue(entry, expect); + assert.sameValue(set, s); +}); + +assert.sameValue(expects.length, 0, "The value of `expects.length` is `0`"); diff --git a/test/sendable/builtins/Set/prototype/forEach/length.js b/test/sendable/builtins/Set/prototype/forEach/length.js new file mode 100644 index 00000000000..f7b8588716c --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + The length property of the forEach method is 1. + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype.forEach, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/name.js b/test/sendable/builtins/Set/prototype/forEach/name.js new file mode 100644 index 00000000000..03403b14023 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype.forEach, "name", { + value: "forEach", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/not-a-constructor.js b/test/sendable/builtins/Set/prototype/forEach/not-a-constructor.js new file mode 100644 index 00000000000..6f8fc4228db --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/not-a-constructor.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableSet.prototype.forEach 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, SendableSet, arrow-function] +---*/ + +assert.sameValue( + isConstructor(SendableSet.prototype.forEach), + false, + 'isConstructor(SendableSet.prototype.forEach) must return false' +); + +assert.throws(TypeError, () => { + let s = new SendableSet([]); new s.forEach(() => {}); +}); + diff --git a/test/sendable/builtins/Set/prototype/forEach/returns-undefined.js b/test/sendable/builtins/Set/prototype/forEach/returns-undefined.js new file mode 100644 index 00000000000..5a1576f4c7b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/returns-undefined.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 8. Return undefined. + +---*/ + +var s = new SendableSet([1]); + +assert.sameValue( + s.forEach(function() {}), + undefined, + "`s.forEach(function() {})` returns `undefined`" +); diff --git a/test/sendable/builtins/Set/prototype/forEach/this-arg-explicit-cannot-override-lexical-this-arrow.js b/test/sendable/builtins/Set/prototype/forEach/this-arg-explicit-cannot-override-lexical-this-arrow.js new file mode 100644 index 00000000000..08282ffb96e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/this-arg-explicit-cannot-override-lexical-this-arrow.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + + An arrow function will ignore an explicit thisArg + +features: [arrow-function] +---*/ + +var s = new SendableSet([1]); +var usurper = {}; +var counter = 0; + +s.forEach(_ => { + assert.notSameValue(this, usurper, "`this` is not `usurper`"); + counter++; +}, usurper); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); diff --git a/test/sendable/builtins/Set/prototype/forEach/this-arg-explicit.js b/test/sendable/builtins/Set/prototype/forEach/this-arg-explicit.js new file mode 100644 index 00000000000..43ce1da84f4 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/this-arg-explicit.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... +---*/ + +var s = new SendableSet([1]); +var thisArg = {}; +var counter = 0; + +s.forEach(function() { + assert.sameValue(this, thisArg, "`this` is `thisArg`"); + counter++; +}, thisArg); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); diff --git a/test/sendable/builtins/Set/prototype/forEach/this-non-strict.js b/test/sendable/builtins/Set/prototype/forEach/this-non-strict.js new file mode 100644 index 00000000000..dde323167eb --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/this-non-strict.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + +flags: [noStrict] +---*/ + +var s = new SendableSet([1]); +var counter = 0; +var globalObject = this; + +s.forEach(function() { + assert.sameValue(this, globalObject, "`this` is the global object in non-strict mode code"); + counter++; +}); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); diff --git a/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-boolean.js b/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-boolean.js new file mode 100644 index 00000000000..940b55d236a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-boolean.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.forEach.call(false, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.forEach.call(false, function() {}); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-null.js b/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-null.js new file mode 100644 index 00000000000..a950acb119a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-null.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.forEach.call(null, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.forEach.call(null, function() {}); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-number.js b/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-number.js new file mode 100644 index 00000000000..e01b1678e0d --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-number.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.forEach.call(0, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.forEach.call(0, function() {}); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-string.js b/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-string.js new file mode 100644 index 00000000000..ae9fcaf44ea --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-string.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.forEach.call("", function() {}); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.forEach.call("", function() {}); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-symbol.js b/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-symbol.js new file mode 100644 index 00000000000..5753fcfbfec --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-symbol.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.forEach.call(Symbol(), function() {}); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.forEach.call(Symbol(), function() {}); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-undefined.js b/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-undefined.js new file mode 100644 index 00000000000..fe6984b13ce --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/this-not-object-throw-undefined.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.forEach.call(undefined, function() {}); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.forEach.call(undefined, function() {}); +}); diff --git a/test/sendable/builtins/Set/prototype/forEach/this-strict.js b/test/sendable/builtins/Set/prototype/forEach/this-strict.js new file mode 100644 index 00000000000..9d582c84281 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/this-strict.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 5. If thisArg was supplied, let T be thisArg; else let T be undefined. + ... + +flags: [onlyStrict] +---*/ + +var s = new SendableSet([1]); +var counter = 0; + +s.forEach(function() { + assert.sameValue(this, undefined, "`this` is `undefined` in strict mode code"); + counter++; +}); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); diff --git a/test/sendable/builtins/Set/prototype/forEach/throws-when-callback-throws.js b/test/sendable/builtins/Set/prototype/forEach/throws-when-callback-throws.js new file mode 100644 index 00000000000..86154b336ab --- /dev/null +++ b/test/sendable/builtins/Set/prototype/forEach/throws-when-callback-throws.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.forEach +description: > + SendableSet.prototype.forEach ( callbackfn [ , thisArg ] ) + + ... + 7. Repeat for each e that is an element of entries, in original insertion order + a. If e is not empty, then + i. Let funcResult be Call(callbackfn, T, «e, e, S»). + ii. ReturnIfAbrupt(funcResult). + ... +---*/ + +var s = new SendableSet([1]); +var counter = 0; + +assert.throws(Error, function() { + s.forEach(function() { + counter++; + throw new Error(); + }); +}); + +assert.sameValue(counter, 1, "`forEach` is not a no-op"); diff --git a/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-array.js b/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 00000000000..87c7d0efbf6 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.has.call([], 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.has.call([], 1); +}); diff --git a/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-map.js b/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 00000000000..c1073821814 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.has.call(new Map(), 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.has.call(new Map(), 1); +}); diff --git a/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-object.js b/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 00000000000..5fba9aa1c7f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.has.call({}, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.has.call({}, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-set-prototype.js b/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 00000000000..d8f2c393de1 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-set-prototype.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.has.call(SendableSet.prototype, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.has.call(SendableSet.prototype, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-weakset.js b/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 00000000000..6bc5aa4f9d2 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 3. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.has.call(new WeakSet(), 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.has.call(new WeakSet(), 1); +}); diff --git a/test/sendable/builtins/Set/prototype/has/has.js b/test/sendable/builtins/Set/prototype/has/has.js new file mode 100644 index 00000000000..46f8bec3e07 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/has.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableSet.prototype.has, + "function", + "`typeof SendableSet.prototype.has` is `'function'`" +); + +verifyProperty(SendableSet.prototype, "has", { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/has/length.js b/test/sendable/builtins/Set/prototype/has/length.js new file mode 100644 index 00000000000..9e09aa7437b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype.has, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/has/name.js b/test/sendable/builtins/Set/prototype/has/name.js new file mode 100644 index 00000000000..9e74f521fc8 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype.has, "name", { + value: "has", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/has/not-a-constructor.js b/test/sendable/builtins/Set/prototype/has/not-a-constructor.js new file mode 100644 index 00000000000..2f31c55be18 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/not-a-constructor.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableSet.prototype.has 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, SendableSet, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableSet.prototype.has), false, 'isConstructor(SendableSet.prototype.has) must return false'); + +assert.throws(TypeError, () => { + let s = new SendableSet([]); new s.has(); +}); + diff --git a/test/sendable/builtins/Set/prototype/has/returns-false-when-undefined-added-deleted-not-present-undefined.js b/test/sendable/builtins/Set/prototype/has/returns-false-when-undefined-added-deleted-not-present-undefined.js new file mode 100644 index 00000000000..5a0820b39b8 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-false-when-undefined-added-deleted-not-present-undefined.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new SendableSet(); + +s.add(undefined); +assert.sameValue(s.has(undefined), true, "`s.has(undefined)` returns `true`"); + +var result = s.delete(undefined); + +assert.sameValue(s.has(undefined), false, "`s.has(undefined)` returns `false`"); +assert.sameValue(result, true, "The result of `s.delete(undefined)` is `true`"); diff --git a/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-boolean.js b/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-boolean.js new file mode 100644 index 00000000000..98f86b93646 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-boolean.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new SendableSet(); + +assert.sameValue(s.has(false), false, "`s.has(false)` returns `false`"); diff --git a/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-nan.js b/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-nan.js new file mode 100644 index 00000000000..1470a16acd9 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-nan.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new SendableSet(); + +assert.sameValue(s.has(NaN), false, "`s.has(NaN)` returns `false`"); diff --git a/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-null.js b/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-null.js new file mode 100644 index 00000000000..d02f5613013 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-null.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new SendableSet(); + +assert.sameValue(s.has(null), false, "`s.has(null)` returns `false`"); diff --git a/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-number.js b/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-number.js new file mode 100644 index 00000000000..d66e1209ddf --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-number.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new SendableSet(); + +assert.sameValue(s.has(0), false, "`s.has(0)` returns `false`"); diff --git a/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-string.js b/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-string.js new file mode 100644 index 00000000000..9f58e14d8c2 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-string.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new SendableSet(); + +assert.sameValue(s.has(""), false, "`s.has('')` returns `false`"); diff --git a/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-symbol.js b/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-symbol.js new file mode 100644 index 00000000000..787a0c9f991 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-symbol.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 6. Return false. + +features: [Symbol] +---*/ + +var s = new SendableSet(); + +assert.sameValue(s.has(Symbol()), false, "`s.has(Symbol())` returns `false`"); diff --git a/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-undefined.js b/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-undefined.js new file mode 100644 index 00000000000..f1478c7e105 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-false-when-value-not-present-undefined.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 6. Return false. + +---*/ + +var s = new SendableSet(); + +assert.sameValue(s.has(undefined), false, "`s.has(undefined)` returns `false`"); diff --git a/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-boolean.js b/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-boolean.js new file mode 100644 index 00000000000..50ad841e00b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-boolean.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new SendableSet(); + +s.add(false) + +assert.sameValue(s.has(false), true, "`s.has(false)` returns `true`"); diff --git a/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-nan.js b/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-nan.js new file mode 100644 index 00000000000..a9c3fe13fd4 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-nan.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new SendableSet(); + +s.add(NaN) + +assert.sameValue(s.has(NaN), true, "`s.has(NaN)` returns `true`"); diff --git a/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-null.js b/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-null.js new file mode 100644 index 00000000000..78b5b18b9e0 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-null.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new SendableSet(); + +s.add(null) + +assert.sameValue(s.has(null), true, "`s.has(null)` returns `true`"); diff --git a/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-number.js b/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-number.js new file mode 100644 index 00000000000..8f8538d0d1e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-number.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new SendableSet(); + +s.add(0) + +assert.sameValue(s.has(0), true, "`s.has(0)` returns `true`"); diff --git a/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-string.js b/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-string.js new file mode 100644 index 00000000000..84a5aa32c62 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-string.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new SendableSet(); + +s.add("") + +assert.sameValue(s.has(""), true, "`s.has('')` returns `true`"); diff --git a/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-symbol.js b/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-symbol.js new file mode 100644 index 00000000000..9cdae26056c --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-symbol.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +features: [Symbol] +---*/ + +var s = new SendableSet(); +var a = Symbol(); + +s.add(a) + +assert.sameValue(s.has(a), true, "`s.has(a)` returns `true`"); diff --git a/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-undefined.js b/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-undefined.js new file mode 100644 index 00000000000..8b2c4212f50 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/returns-true-when-value-present-undefined.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + ... + 5. Repeat for each e that is an element of entries, + a. If e is not empty and SameValueZero(e, value) is true, return true. + ... + +---*/ + +var s = new SendableSet(); + +s.add(undefined) + +assert.sameValue(s.has(undefined), true, "`s.has(undefined)` returns `true`"); diff --git a/test/sendable/builtins/Set/prototype/has/this-not-object-throw-boolean.js b/test/sendable/builtins/Set/prototype/has/this-not-object-throw-boolean.js new file mode 100644 index 00000000000..d608b2adf61 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/this-not-object-throw-boolean.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.has.call(false, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.has.call(false, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/has/this-not-object-throw-null.js b/test/sendable/builtins/Set/prototype/has/this-not-object-throw-null.js new file mode 100644 index 00000000000..5fb249b0c49 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/this-not-object-throw-null.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.has.call(null, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.has.call(null, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/has/this-not-object-throw-number.js b/test/sendable/builtins/Set/prototype/has/this-not-object-throw-number.js new file mode 100644 index 00000000000..75415ba482c --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/this-not-object-throw-number.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.has.call(0, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.has.call(0, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/has/this-not-object-throw-string.js b/test/sendable/builtins/Set/prototype/has/this-not-object-throw-string.js new file mode 100644 index 00000000000..0f1f25e7603 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/this-not-object-throw-string.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.has.call("", 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.has.call("", 1); +}); diff --git a/test/sendable/builtins/Set/prototype/has/this-not-object-throw-symbol.js b/test/sendable/builtins/Set/prototype/has/this-not-object-throw-symbol.js new file mode 100644 index 00000000000..6917d6a2c70 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/this-not-object-throw-symbol.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.has.call(Symbol(), 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.has.call(Symbol(), 1); +}); diff --git a/test/sendable/builtins/Set/prototype/has/this-not-object-throw-undefined.js b/test/sendable/builtins/Set/prototype/has/this-not-object-throw-undefined.js new file mode 100644 index 00000000000..0fef31de421 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/has/this-not-object-throw-undefined.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.has +description: > + SendableSet.prototype.has ( value ) + + 1. Let S be the this value. + 2. If Type(S) is not Object, throw a TypeError exception. + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.has.call(undefined, 1); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.has.call(undefined, 1); +}); diff --git a/test/sendable/builtins/Set/prototype/intersection/add-not-called.js b/test/sendable/builtins/Set/prototype/intersection/add-not-called.js new file mode 100644 index 00000000000..386b0bb2f70 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/add-not-called.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection should not call SendableSet.prototype.add +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [2]; + +const originalAdd = SendableSet.prototype.add; +let count = 0; +SendableSet.prototype.add = function (...rest) { + count++; + return originalAdd.apply(this, rest); +}; + +const combined = s1.intersection(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue(count, 0, "Add is never called"); + +SendableSet.prototype.add = originalAdd; diff --git a/test/sendable/builtins/Set/prototype/intersection/allows-set-like-class.js b/test/sendable/builtins/Set/prototype/intersection/allows-set-like-class.js new file mode 100644 index 00000000000..b82cf713e20 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/allows-set-like-class.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: GetSendableSetRecord allows instances of SendableSet-like classes +info: | + 1. If obj is not an Object, throw a TypeError exception. + 2. Let rawSize be ? Get(obj, "size"). + ... + 7. Let has be ? Get(obj, "has"). + ... + 9. Let keys be ? Get(obj, "keys"). +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new class { + get size() { + return 2; + } + has(v) { + if (v === 1) return false; + if (v === 2) return true; + throw new Test262Error("SendableSet.prototype.intersection should only call its argument's has method with contents of this"); + } + * keys() { + throw new Test262Error("SendableSet.prototype.intersection should not call its argument's keys iterator when this.size ≤ arg.size"); + } +}; +const expected = [2]; +const combined = s1.intersection(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/intersection/allows-set-like-object.js b/test/sendable/builtins/Set/prototype/intersection/allows-set-like-object.js new file mode 100644 index 00000000000..0fd6e9161b3 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/allows-set-like-object.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: GetSendableSetRecord allows SendableSet-like objects +info: | + 1. If obj is not an Object, throw a TypeError exception. + 2. Let rawSize be ? Get(obj, "size"). + ... + 7. Let has be ? Get(obj, "has"). + ... + 9. Let keys be ? Get(obj, "keys"). +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: (v) => { + if (v === 1) return false; + if (v === 2) return true; + throw new Test262Error("SendableSet.prototype.intersection should only call its argument's has method with contents of this"); + }, + keys: function* keys() { + throw new Test262Error("SendableSet.prototype.intersection should not call its argument's keys iterator when this.size ≤ arg.size"); + }, +}; +const expected = [2]; +const combined = s1.intersection(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/intersection/array-throws.js b/test/sendable/builtins/Set/prototype/intersection/array-throws.js new file mode 100644 index 00000000000..5230342676f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/array-throws.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection doesn't work with arrays +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = [3]; +assert.throws( + TypeError, + function () { + s1.intersection(s2); + }, + "Throws an error when an array is used" +); diff --git a/test/sendable/builtins/Set/prototype/intersection/builtins.js b/test/sendable/builtins/Set/prototype/intersection/builtins.js new file mode 100644 index 00000000000..6bc43c900d9 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/builtins.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: Tests that SendableSet.prototype.intersection meets the requirements for built-in objects +features: [set-methods] +---*/ + +assert.sameValue( + Object.isExtensible(SendableSet.prototype.intersection), + true, + "Built-in objects must be extensible." +); + +assert.sameValue( + Object.prototype.toString.call(SendableSet.prototype.intersection), + "[object Function]", + "Object.prototype.toString" +); + +assert.sameValue( + Object.getPrototypeOf(SendableSet.prototype.intersection), + Function.prototype, + "prototype" +); diff --git a/test/sendable/builtins/Set/prototype/intersection/called-with-object.js b/test/sendable/builtins/Set/prototype/intersection/called-with-object.js new file mode 100644 index 00000000000..ee028f9b999 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/called-with-object.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws if obj is not an object +info: | + 1. If obj is not an Object, throw a TypeError exception. +features: [set-methods] +---*/ + +let s1 = new SendableSet([1]); +assert.throws( + TypeError, + function () { + s1.intersection(1); + }, + "number" +); + +assert.throws( + TypeError, + function () { + s1.intersection(""); + }, + "string" +); + +assert.throws( + TypeError, + function () { + s1.intersection(1n); + }, + "bigint" +); + +assert.throws( + TypeError, + function () { + s1.intersection(false); + }, + "boolean" +); + +assert.throws( + TypeError, + function () { + s1.intersection(undefined); + }, + "undefined" +); + +assert.throws( + TypeError, + function () { + s1.intersection(null); + }, + "null" +); + +assert.throws( + TypeError, + function () { + s1.intersection(Symbol("test")); + }, + "symbol" +); diff --git a/test/sendable/builtins/Set/prototype/intersection/combines-Map.js b/test/sendable/builtins/Set/prototype/intersection/combines-Map.js new file mode 100644 index 00000000000..4342019e76d --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/combines-Map.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection combines with Map +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const m1 = new Map([ + [2, "two"], + [3, "three"], +]); +const expected = [2]; +const combined = s1.intersection(m1); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/intersection/combines-empty-sets.js b/test/sendable/builtins/Set/prototype/intersection/combines-empty-sets.js new file mode 100644 index 00000000000..1ce0361fbc3 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/combines-empty-sets.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection can combine empty SendableSets +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([]); +const s2 = new SendableSet([1, 2]); +let expected = []; +let combined = s1.intersection(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); + +const s3 = new SendableSet([1, 2]); +const s4 = new SendableSet([]); +expected = []; +combined = s3.intersection(s4); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); + +const s5 = new SendableSet([]); +const s6 = new SendableSet([]); +expected = []; +combined = s5.intersection(s6); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/intersection/combines-itself.js b/test/sendable/builtins/Set/prototype/intersection/combines-itself.js new file mode 100644 index 00000000000..7a8bdec212f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/combines-itself.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection is successful when called on itself +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const expected = [1, 2]; +const combined = s1.intersection(s1); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue(combined === s1, false, "The returned object is a new object"); diff --git a/test/sendable/builtins/Set/prototype/intersection/combines-same-sets.js b/test/sendable/builtins/Set/prototype/intersection/combines-same-sets.js new file mode 100644 index 00000000000..f0f4f5abed6 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/combines-same-sets.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection can combine SendableSets that have the same content +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([1, 2]); +const expected = [1, 2]; +const combined = s1.intersection(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue(combined === s1, false, "The returned object is a new object"); +assert.sameValue(combined === s2, false, "The returned object is a new object"); diff --git a/test/sendable/builtins/Set/prototype/intersection/combines-sets.js b/test/sendable/builtins/Set/prototype/intersection/combines-sets.js new file mode 100644 index 00000000000..e4812f82d1d --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/combines-sets.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection combines SendableSets +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [2]; +const combined = s1.intersection(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/intersection/converts-negative-zero.js b/test/sendable/builtins/Set/prototype/intersection/converts-negative-zero.js new file mode 100644 index 00000000000..b26d07f881d --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/converts-negative-zero.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection converts -0𝔽 to +0𝔽 +info: | + 7.c.ii.2 If nextValue is -0𝔽, set nextValue to +0𝔽. +features: [set-methods] +includes: [compareArray.js] +---*/ + +const setlikeWithMinusZero = { + size: 1, + has: function () { + throw new Test262Error("SendableSet.prototype.intersection should not invoke .has on its argument when this.size > arg.size"); + }, + keys: function () { + // we use an array here because the SendableSet constructor would normalize away -0 + return [-0].values(); + }, +}; + +const s1 = new SendableSet([0, 1, 2]); +let expected = [+0]; +let combined = s1.intersection(setlikeWithMinusZero); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/intersection/has-is-callable.js b/test/sendable/builtins/Set/prototype/intersection/has-is-callable.js new file mode 100644 index 00000000000..85fa2085efc --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/has-is-callable.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object's 'has' property is not callable +info: | + 7. Let has be ? Get(obj, "has"). + 8. If IsCallable(has) is false, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: undefined, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + function () { + s1.intersection(s2); + }, + "GetSendableSetRecord throws an error when has is undefined" +); + +s2.has = {}; +assert.throws( + TypeError, + function () { + s1.intersection(s2); + }, + "GetSendableSetRecord throws an error when has is not callable" +); diff --git a/test/sendable/builtins/Set/prototype/intersection/intersection.js b/test/sendable/builtins/Set/prototype/intersection/intersection.js new file mode 100644 index 00000000000..d9016d3b6d1 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/intersection.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection properties +includes: [propertyHelper.js] +features: [set-methods] +---*/ + +assert.sameValue( + typeof SendableSet.prototype.intersection, + "function", + "`typeof SendableSet.prototype.intersection` is `'function'`" +); + +verifyProperty(SendableSet.prototype, "intersection", { + enumerable: false, + writable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/intersection/keys-is-callable.js b/test/sendable/builtins/Set/prototype/intersection/keys-is-callable.js new file mode 100644 index 00000000000..09dcf0cfc52 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/keys-is-callable.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object's 'keys' property is not callable +info: | + 9. Let keys be ? Get(obj, "keys"). + 10. If IsCallable(keys) is false, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: () => {}, + keys: undefined, +}; +assert.throws( + TypeError, + function () { + s1.intersection(s2); + }, + "GetSendableSetRecord throws an error when keys is undefined" +); + +s2.keys = {}; +assert.throws( + TypeError, + function () { + s1.intersection(s2); + }, + "GetSendableSetRecord throws an error when keys is not callable" +); diff --git a/test/sendable/builtins/Set/prototype/intersection/length.js b/test/sendable/builtins/Set/prototype/intersection/length.js new file mode 100644 index 00000000000..987980e623f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection length property +info: | + SendableSet.prototype.intersection ( other ) +includes: [propertyHelper.js] +features: [set-methods] +---*/ +assert.sameValue(typeof SendableSet.prototype.intersection, "function"); + +verifyProperty(SendableSet.prototype.intersection, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 1, +}); diff --git a/test/sendable/builtins/Set/prototype/intersection/name.js b/test/sendable/builtins/Set/prototype/intersection/name.js new file mode 100644 index 00000000000..fafb674c2ee --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection name property +info: | + SendableSet.prototype.intersection ( other ) +includes: [propertyHelper.js] +features: [set-methods] +---*/ +assert.sameValue(typeof SendableSet.prototype.intersection, "function"); + +verifyProperty(SendableSet.prototype.intersection, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "intersection", +}); diff --git a/test/sendable/builtins/Set/prototype/intersection/not-a-constructor.js b/test/sendable/builtins/Set/prototype/intersection/not-a-constructor.js new file mode 100644 index 00000000000..71b0351bbe0 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/not-a-constructor.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection does not implement [[Construct]], is not new-able +includes: [isConstructor.js] +features: [Reflect.construct, set-methods] +---*/ + +assert.sameValue( + isConstructor(SendableSet.prototype.intersection), + false, + "isConstructor(SendableSet.prototype.intersection) must return false" +); + +assert.throws( + TypeError, + () => { + new SendableSet.prototype.intersection(); + }); diff --git a/test/sendable/builtins/Set/prototype/intersection/receiver-not-set.js b/test/sendable/builtins/Set/prototype/intersection/receiver-not-set.js new file mode 100644 index 00000000000..fbd7d8116c5 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/receiver-not-set.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection throws when receiver is not a SendableSet +features: [set-methods] +---*/ + +class MySendableSetLike { + constructor() { + this.size = 2; + this.has = () => {}; + this.keys = function* keys() { + yield 2; + yield 3; + }; + } +} + +const s1 = new MySendableSetLike(); +const s2 = new SendableSet(); +assert.throws( + TypeError, + () => { + SendableSet.prototype.intersection.call(s1, s2); + }, + "SendableSet-like class" +); + +const s3 = { + size: 2, + has: () => {}, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + () => { + SendableSet.prototype.intersection.call(s3, s2); + }, + "SendableSet-like object" +); diff --git a/test/sendable/builtins/Set/prototype/intersection/require-internal-slot.js b/test/sendable/builtins/Set/prototype/intersection/require-internal-slot.js new file mode 100644 index 00000000000..1567f753e30 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/require-internal-slot.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection RequireInternalSlot +info: | + 2. Perform ? RequireInternalSlot(O, [[SendableSetData]]) +features: [set-methods] +---*/ + +const intersection = SendableSet.prototype.intersection; + +assert.sameValue(typeof intersection, "function"); + +const realSendableSet = new SendableSet([]); + +assert.throws(TypeError, () => intersection.call(undefined, realSendableSet), "undefined"); +assert.throws(TypeError, () => intersection.call(null, realSendableSet), "null"); +assert.throws(TypeError, () => intersection.call(true, realSendableSet), "true"); +assert.throws(TypeError, () => intersection.call("", realSendableSet), "empty string"); +assert.throws(TypeError, () => intersection.call(Symbol(), realSendableSet), "symbol"); +assert.throws(TypeError, () => intersection.call(1, realSendableSet), "1"); +assert.throws(TypeError, () => intersection.call(1n, realSendableSet), "1n"); +assert.throws(TypeError, () => intersection.call({}, realSendableSet), "plain object"); +assert.throws(TypeError, () => intersection.call([], realSendableSet), "array"); +assert.throws(TypeError, () => intersection.call(new Map(), realSendableSet), "map"); +assert.throws(TypeError, () => intersection.call(SendableSet.prototype, realSendableSet), "SendableSet.prototype"); diff --git a/test/sendable/builtins/Set/prototype/intersection/result-order.js b/test/sendable/builtins/Set/prototype/intersection/result-order.js new file mode 100644 index 00000000000..49af585cab4 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/result-order.js @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection result ordering +features: [set-methods] +includes: [compareArray.js] +---*/ + +// when this.size ≤ other.size, results are ordered as in this +{ + const s1 = new SendableSet([1, 3, 5]); + const s2 = new SendableSet([3, 2, 1]); + + assert.compareArray([...s1.intersection(s2)], [1, 3]); +} + +{ + const s1 = new SendableSet([3, 2, 1]); + const s2 = new SendableSet([1, 3, 5]); + + assert.compareArray([...s1.intersection(s2)], [3, 1]); +} + +{ + const s1 = new SendableSet([1, 3, 5]); + const s2 = new SendableSet([3, 2, 1, 0]); + + assert.compareArray([...s1.intersection(s2)], [1, 3]); +} + +{ + const s1 = new SendableSet([3, 2, 1]); + const s2 = new SendableSet([1, 3, 5, 7]); + + assert.compareArray([...s1.intersection(s2)], [3, 1]); +} + + +// when this.size > other.size, results are ordered as in other +{ + const s1 = new SendableSet([3, 2, 1, 0]); + const s2 = new SendableSet([1, 3, 5]); + + assert.compareArray([...s1.intersection(s2)], [1, 3]); +} + +{ + const s1 = new SendableSet([1, 3, 5, 7]); + const s2 = new SendableSet([3, 2, 1]); + + assert.compareArray([...s1.intersection(s2)], [3, 1]); +} diff --git a/test/sendable/builtins/Set/prototype/intersection/set-like-array.js b/test/sendable/builtins/Set/prototype/intersection/set-like-array.js new file mode 100644 index 00000000000..656e161295a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/set-like-array.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection consumes a set-like array as a set-like, not an array +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = [5, 6]; +s2.size = 3; +s2.has = function (v) { + if (v === 1) return false; + if (v === 2) return true; + throw new Test262Error("SendableSet.prototype.intersection should only call its argument's has method with contents of this"); +}; +s2.keys = function () { + throw new Test262Error("SendableSet.prototype.intersection should not call its argument's keys iterator when this.size ≤ arg.size"); +}; + +const expected = [2]; +const combined = s1.intersection(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/intersection/set-like-class-mutation.js b/test/sendable/builtins/Set/prototype/intersection/set-like-class-mutation.js new file mode 100644 index 00000000000..491405f6f03 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/set-like-class-mutation.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection maintains values even when a custom SendableSet-like class mutates the receiver +features: [set-methods] +includes: [compareArray.js] +---*/ + +const baseSendableSet = new SendableSet(["a", "b", "c", "d", "e"]); + +function mutatingIterator() { + let index = 0; + let values = ["x", "b", "b"]; + return { + next() { + if (index === 0) { + baseSendableSet.delete("b"); + baseSendableSet.delete("c"); + baseSendableSet.add("b"); + baseSendableSet.add("d"); + } + return { + done: index >= values.length, + value: values[index++], + }; + }, + }; +} + +const evilSendableSetLike = { + size: 3, + get has() { + baseSendableSet.add("q"); + return function () { + throw new Test262Error("SendableSet.prototype.intersection should not invoke .has on its argument when this.size > other.size"); + }; + }, + keys() { + return mutatingIterator(); + }, +}; + +const combined = baseSendableSet.intersection(evilSendableSetLike); +const expectedCombined = ["b"]; +assert.compareArray([...combined], expectedCombined); + +const expectedNewBase = ["a", "d", "e", "q", "b"]; +assert.compareArray([...baseSendableSet], expectedNewBase); diff --git a/test/sendable/builtins/Set/prototype/intersection/set-like-class-order.js b/test/sendable/builtins/Set/prototype/intersection/set-like-class-order.js new file mode 100644 index 00000000000..b2237ee3bb6 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/set-like-class-order.js @@ -0,0 +1,153 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection calls a SendableSet-like class's methods in order +features: [set-methods] +includes: [compareArray.js] +---*/ + +let observedOrder = []; + +function observableIterator() { + let values = ["a", "b", "c"]; + let index = 0; + return { + get next() { + observedOrder.push("getting next"); + return function () { + observedOrder.push("calling next"); + return { + get done() { + observedOrder.push("getting done"); + return index >= values.length; + }, + get value() { + observedOrder.push("getting value"); + return values[index++]; + }, + }; + }; + }, + }; +} + +class MySendableSetLike { + get size() { + observedOrder.push("getting size"); + return { + valueOf: function () { + observedOrder.push("ToNumber(size)"); + return 3; + }, + }; + } + get has() { + observedOrder.push("getting has"); + return function (v) { + observedOrder.push("calling has"); + return ["a", "b", "c"].indexOf(v) !== -1; + }; + } + get keys() { + observedOrder.push("getting keys"); + return function () { + observedOrder.push("calling keys"); + return observableIterator(); + }; + } +} + +// this is smaller than argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "d"]); + const s2 = new MySendableSetLike(); + const combined = s1.intersection(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + // two calls to has + "calling has", + "calling has", + ]; + + assert.compareArray([...combined], ["a"]); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is same size as argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "b", "d"]); + const s2 = new MySendableSetLike(); + const combined = s1.intersection(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + // three calls to has + "calling has", + "calling has", + "calling has", + ]; + + assert.compareArray([...combined], ["a", "b"]); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is larger than argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "b", "c", "d"]); + const s2 = new MySendableSetLike(); + const combined = s1.intersection(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + "calling keys", + "getting next", + // first iteration, has value + "calling next", + "getting done", + "getting value", + // second iteration, has value + "calling next", + "getting done", + "getting value", + // third iteration, has value + "calling next", + "getting done", + "getting value", + // fourth iteration, no value; ends + "calling next", + "getting done", + ]; + + assert.compareArray([...combined], ["a", "b", "c"]); + assert.compareArray(observedOrder, expectedOrder); +} diff --git a/test/sendable/builtins/Set/prototype/intersection/size-is-a-number.js b/test/sendable/builtins/Set/prototype/intersection/size-is-a-number.js new file mode 100644 index 00000000000..950d3a32bb3 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/size-is-a-number.js @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object has a size that is coerced to NaN +info: | + 2. Let rawSize be ? Get(obj, "size"). + 3. Let numSize be ? ToNumber(rawSize). + 4. NOTE: If rawSize is undefined, then numSize will be NaN. + 5. If numSize is NaN, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: undefined, + has: () => {}, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + function () { + s1.intersection(s2); + }, + "GetSendableSetRecord throws an error when size is undefined" +); + +s2.size = NaN; +assert.throws( + TypeError, + function () { + s1.intersection(s2); + }, + "GetSendableSetRecord throws an error when size is NaN" +); + +let coercionCalls = 0; +s2.size = { + valueOf: function() { + ++coercionCalls; + return NaN; + }, +}; +assert.throws( + TypeError, + function () { + s1.intersection(s2); + }, + "GetSendableSetRecord throws an error when size coerces to NaN" +); +assert.sameValue(coercionCalls, 1, "GetSendableSetRecord coerces size"); + +s2.size = 0n; +assert.throws( + TypeError, + function () { + s1.intersection(s2); + }, + "GetSendableSetRecord throws an error when size is a BigInt" +); + +s2.size = "string"; +assert.throws( + TypeError, + function () { + s1.intersection(s2); + }, + "GetSendableSetRecord throws an error when size is a non-numeric string" +); diff --git a/test/sendable/builtins/Set/prototype/intersection/subclass-receiver-methods.js b/test/sendable/builtins/Set/prototype/intersection/subclass-receiver-methods.js new file mode 100644 index 00000000000..d1075476a5f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/subclass-receiver-methods.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection works on subclasses of SendableSet, but never calls the receiver's size/has/keys methods +features: [set-methods] +includes: [compareArray.js] +---*/ + +let sizeCount = 0; +let hasCount = 0; +let keysCount = 0; + +class MySendableSet extends SendableSet { + size(...rest) { + sizeCount++; + return super.size(...rest); + } + + has(...rest) { + hasCount++; + return super.has(...rest); + } + + keys(...rest) { + keysCount++; + return super.keys(...rest); + } +} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [2]; +const combined = s1.intersection(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue( + combined instanceof MySendableSet, + false, + "The returned object is a SendableSet, not a subclass" +); +assert.sameValue(sizeCount, 0, "size should not be called on the receiver"); +assert.sameValue(hasCount, 0, "has should not be called on the receiver"); +assert.sameValue(keysCount, 0, "keys should not be called on the receiver"); diff --git a/test/sendable/builtins/Set/prototype/intersection/subclass-symbol-species.js b/test/sendable/builtins/Set/prototype/intersection/subclass-symbol-species.js new file mode 100644 index 00000000000..03d69853298 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/subclass-symbol-species.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection works on subclasses of SendableSet, but returns an instance of SendableSet even when Symbol.species is overridden. +features: [set-methods] +includes: [compareArray.js] +---*/ +var count = 0; +class MySendableSet extends SendableSet { + static get [Symbol.species]() { + count++; + return SendableSet; + } +} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [2]; +const combined = s1.intersection(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(count, 0, "Symbol.species is never called"); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue( + combined instanceof MySendableSet, + false, + "The returned object is a SendableSet, not a subclass" +); diff --git a/test/sendable/builtins/Set/prototype/intersection/subclass.js b/test/sendable/builtins/Set/prototype/intersection/subclass.js new file mode 100644 index 00000000000..e21c936458e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/intersection/subclass.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.intersection +description: SendableSet.prototype.intersection works on subclasses of SendableSet, but returns an instance of SendableSet +features: [set-methods] +includes: [compareArray.js] +---*/ + +class MySendableSet extends SendableSet {} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [2]; +const combined = s1.intersection(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue( + combined instanceof MySendableSet, + false, + "The returned object is a SendableSet, not a subclass" +); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/allows-set-like-class.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/allows-set-like-class.js new file mode 100644 index 00000000000..000b817a4ac --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/allows-set-like-class.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: GetSendableSetRecord allows instances of SendableSet-like classes +info: | + 1. If obj is not an Object, throw a TypeError exception. + 2. Let rawSize be ? Get(obj, "size"). + ... + 7. Let has be ? Get(obj, "has"). + ... + 9. Let keys be ? Get(obj, "keys"). +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new class { + get size() { + return 2; + } + has(v) { + if (v === 1 || v === 2) return false; + throw new Test262Error("SendableSet.prototype.isDisjointFrom should only call its argument's has method with contents of this"); + } + * keys() { + throw new Test262Error("SendableSet.prototype.isDisjointFrom should not call its argument's keys iterator when this.size ≤ arg.size"); + } +}; + +assert.sameValue(s1.isDisjointFrom(s2), true); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/allows-set-like-object.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/allows-set-like-object.js new file mode 100644 index 00000000000..04e96a602fd --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/allows-set-like-object.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: GetSendableSetRecord allows SendableSet-like objects +info: | + 1. If obj is not an Object, throw a TypeError exception. + 2. Let rawSize be ? Get(obj, "size"). + ... + 7. Let has be ? Get(obj, "has"). + ... + 9. Let keys be ? Get(obj, "keys"). +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: (v) => { + if (v === 1 || v === 2) return false; + throw new Test262Error("SendableSet.prototype.isDisjointFrom should only call its argument's has method with contents of this"); + }, + keys: function* keys() { + throw new Test262Error("SendableSet.prototype.isDisjointFrom should not call its argument's keys iterator when this.size ≤ arg.size"); + }, +}; + +assert.sameValue(s1.isDisjointFrom(s2), true); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/array-throws.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/array-throws.js new file mode 100644 index 00000000000..ce6007e486b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/array-throws.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom doesn't work with arrays +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = [3]; +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(s2); + }, + "Throws an error when an array is used" +); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/builtins.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/builtins.js new file mode 100644 index 00000000000..c272fb6cb26 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/builtins.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: Tests that SendableSet.prototype.isDisjointFrom meets the requirements for built-in objects +features: [set-methods] +---*/ + +assert.sameValue( + Object.isExtensible(SendableSet.prototype.isDisjointFrom), + true, + "Built-in objects must be extensible." +); + +assert.sameValue( + Object.prototype.toString.call(SendableSet.prototype.isDisjointFrom), + "[object Function]", + "Object.prototype.toString" +); + +assert.sameValue( + Object.getPrototypeOf(SendableSet.prototype.isDisjointFrom), + Function.prototype, + "prototype" +); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/called-with-object.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/called-with-object.js new file mode 100644 index 00000000000..f817779c098 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/called-with-object.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws if obj is not an object +info: | + 1. If obj is not an Object, throw a TypeError exception. +features: [set-methods] +---*/ + +let s1 = new SendableSet([1]); +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(1); + }, + "number" +); + +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(""); + }, + "string" +); + +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(1n); + }, + "bigint" +); + +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(false); + }, + "boolean" +); + +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(undefined); + }, + "undefined" +); + +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(null); + }, + "null" +); + +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(Symbol("test")); + }, + "symbol" +); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-Map.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-Map.js new file mode 100644 index 00000000000..7e3d339cc22 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-Map.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom compares with Map +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const m1 = new Map([ + [2, "two"], + [3, "three"], +]); + +assert.sameValue(s1.isDisjointFrom(m1), false); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-empty-sets.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-empty-sets.js new file mode 100644 index 00000000000..817c07b5f4b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-empty-sets.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom can compare empty SendableSets +features: [set-methods] +---*/ + +const s1 = new SendableSet([]); +const s2 = new SendableSet([1, 2]); + +assert.sameValue(s1.isDisjointFrom(s2), true); + +const s3 = new SendableSet([1, 2]); +const s4 = new SendableSet([]); + +assert.sameValue(s3.isDisjointFrom(s4), true); + +const s5 = new SendableSet([]); +const s6 = new SendableSet([]); + +assert.sameValue(s5.isDisjointFrom(s6), true); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-itself.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-itself.js new file mode 100644 index 00000000000..2d1f8945635 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-itself.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom is successful when called on itself +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); + +assert.sameValue(s1.isDisjointFrom(s1), false); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-same-sets.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-same-sets.js new file mode 100644 index 00000000000..d3b66578526 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-same-sets.js @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom can compare SendableSets that have the same content +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([1, 2]); + +assert.sameValue(s1.isDisjointFrom(s2), false); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-sets.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-sets.js new file mode 100644 index 00000000000..f03fb689d73 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/compares-sets.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom compares SendableSets +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); + +assert.sameValue(s1.isDisjointFrom(s2), false); + +const s3 = new SendableSet([3]); + +assert.sameValue(s1.isDisjointFrom(s3), true); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/converts-negative-zero.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/converts-negative-zero.js new file mode 100644 index 00000000000..8c65df4615d --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/converts-negative-zero.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom converts -0𝔽 to +0𝔽 +features: [set-methods] +---*/ + +const setlikeWithMinusZero = { + size: 1, + has: function () { + throw new Test262Error("SendableSet.prototype.isDisjointFrom should not call its argument's has method when this.size > arg.size"); + }, + keys: function () { + // we use an array here because the SendableSet constructor would normalize away -0 + return [-0].values(); + }, +}; + +const s1 = new SendableSet([+0, 1]); + +assert.sameValue(s1.isDisjointFrom(setlikeWithMinusZero), false); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/has-is-callable.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/has-is-callable.js new file mode 100644 index 00000000000..53409059e75 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/has-is-callable.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object's 'has' property is not callable +info: | + 7. Let has be ? Get(obj, "has"). + 8. If IsCallable(has) is false, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: undefined, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(s2); + }, + "GetSendableSetRecord throws an error when has is undefined" +); + +s2.has = {}; +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(s2); + }, + "GetSendableSetRecord throws an error when has is not callable" +); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/isDisjointFrom.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/isDisjointFrom.js new file mode 100644 index 00000000000..4e0b549d1ed --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/isDisjointFrom.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom properties +includes: [propertyHelper.js] +features: [set-methods] +---*/ + +assert.sameValue( + typeof SendableSet.prototype.isDisjointFrom, + "function", + "`typeof SendableSet.prototype.isDisjointFrom` is `'function'`" +); + +verifyProperty(SendableSet.prototype, "isDisjointFrom", { + enumerable: false, + writable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/keys-is-callable.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/keys-is-callable.js new file mode 100644 index 00000000000..b12490826d0 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/keys-is-callable.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object's 'keys' property is not callable +info: | + 9. Let keys be ? Get(obj, "keys"). + 10. If IsCallable(keys) is false, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: () => {}, + keys: undefined, +}; +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(s2); + }, + "GetSendableSetRecord throws an error when keys is undefined" +); + +s2.keys = {}; +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(s2); + }, + "GetSendableSetRecord throws an error when keys is not callable" +); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/length.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/length.js new file mode 100644 index 00000000000..76988dbb412 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom length property +info: | + SendableSet.prototype.isDisjointFrom ( other ) +includes: [propertyHelper.js] +features: [set-methods] +---*/ +assert.sameValue(typeof SendableSet.prototype.isDisjointFrom, "function"); + +verifyProperty(SendableSet.prototype.isDisjointFrom, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 1, +}); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/name.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/name.js new file mode 100644 index 00000000000..ed0b3fc9dc0 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom name property +info: | + SendableSet.prototype.isDisjointFrom ( other ) +includes: [propertyHelper.js] +features: [set-methods] +---*/ +assert.sameValue(typeof SendableSet.prototype.isDisjointFrom, "function"); + +verifyProperty(SendableSet.prototype.isDisjointFrom, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "isDisjointFrom", +}); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/not-a-constructor.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/not-a-constructor.js new file mode 100644 index 00000000000..74938ee8003 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/not-a-constructor.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom does not implement [[Construct]], is not new-able +includes: [isConstructor.js] +features: [Reflect.construct, set-methods] +---*/ + +assert.sameValue( + isConstructor(SendableSet.prototype.isDisjointFrom), + false, + "isConstructor(SendableSet.prototype.isDisjointFrom) must return false" +); + +assert.throws( + TypeError, + () => { + new SendableSet.prototype.isDisjointFrom(); + }); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/receiver-not-set.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/receiver-not-set.js new file mode 100644 index 00000000000..7671303e527 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/receiver-not-set.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom throws when receiver is not a SendableSet +features: [set-methods] +---*/ + +class MySendableSetLike { + constructor() { + this.size = 2; + this.has = () => {}; + this.keys = function* keys() { + yield 2; + yield 3; + }; + } +} + +const s1 = new MySendableSetLike(); +const s2 = new SendableSet(); +assert.throws( + TypeError, + () => { + SendableSet.prototype.isDisjointFrom.call(s1, s2); + }, + "SendableSet-like class" +); + +const s3 = { + size: 2, + has: () => {}, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + () => { + SendableSet.prototype.isDisjointFrom.call(s3, s2); + }, + "SendableSet-like object" +); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/require-internal-slot.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/require-internal-slot.js new file mode 100644 index 00000000000..574bd92a120 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/require-internal-slot.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom RequireInternalSlot +info: | + 2. Perform ? RequireInternalSlot(O, [[SendableSetData]]) +features: [set-methods] +---*/ + +const isDisjointFrom = SendableSet.prototype.isDisjointFrom; + +assert.sameValue(typeof isDisjointFrom, "function"); + +const realSendableSet = new SendableSet([]); + +assert.throws(TypeError, () => isDisjointFrom.call(undefined, realSendableSet), "undefined"); +assert.throws(TypeError, () => isDisjointFrom.call(null, realSendableSet), "null"); +assert.throws(TypeError, () => isDisjointFrom.call(true, realSendableSet), "true"); +assert.throws(TypeError, () => isDisjointFrom.call("", realSendableSet), "empty string"); +assert.throws(TypeError, () => isDisjointFrom.call(Symbol(), realSendableSet), "symbol"); +assert.throws(TypeError, () => isDisjointFrom.call(1, realSendableSet), "1"); +assert.throws(TypeError, () => isDisjointFrom.call(1n, realSendableSet), "1n"); +assert.throws(TypeError, () => isDisjointFrom.call({}, realSendableSet), "plain object"); +assert.throws(TypeError, () => isDisjointFrom.call([], realSendableSet), "array"); +assert.throws(TypeError, () => isDisjointFrom.call(new Map(), realSendableSet), "map"); +assert.throws(TypeError, () => isDisjointFrom.call(SendableSet.prototype, realSendableSet), "SendableSet.prototype"); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/set-like-array.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/set-like-array.js new file mode 100644 index 00000000000..4356dd5ed9f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/set-like-array.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom consumes a set-like array as a set-like, not an array +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = [5, 6]; +s2.size = 3; +s2.has = function (v) { + if (v === 1 || v === 2) return true; + throw new Test262Error("SendableSet.prototype.isDisjointFrom should only call its argument's has method with contents of this"); +}; +s2.keys = function () { + throw new Test262Error("SendableSet.prototype.isDisjointFrom should not call its argument's keys iterator when this.size ≤ arg.size"); +}; + +assert.sameValue(s1.isDisjointFrom(s2), false); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/set-like-class-mutation.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/set-like-class-mutation.js new file mode 100644 index 00000000000..7b13bc5442a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/set-like-class-mutation.js @@ -0,0 +1,51 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom behavior when a custom SendableSet-like class mutates the receiver +features: [set-methods] +includes: [compareArray.js] +---*/ + +const baseSendableSet = new SendableSet(["a", "b", "c"]); + +const evilSendableSetLike = { + size: 3, + has(v) { + if (v === "a") { + baseSendableSet.delete("b"); + baseSendableSet.delete("c"); + baseSendableSet.add("b"); + return false; + } + if (v === "b") { + return false; + } + if (v === "c") { + throw new Test262Error("SendableSet.prototype.isDisjointFrom should not call its argument's has method with values from this which have been deleted before visiting"); + } + throw new Test262Error("SendableSet.prototype.isDisjointFrom should only call its argument's has method with contents of this"); + }, + * keys() { + throw new Test262Error("SendableSet.prototype.isDisjointFrom should not call its argument's keys iterator when this.size ≤ arg.size"); + }, +}; + +const result = baseSendableSet.isDisjointFrom(evilSendableSetLike); +assert.sameValue(result, true); + +const expectedNewBase = ["a", "b"]; +assert.compareArray([...baseSendableSet], expectedNewBase); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/set-like-class-order.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/set-like-class-order.js new file mode 100644 index 00000000000..c72eea0f643 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/set-like-class-order.js @@ -0,0 +1,204 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom calls a SendableSet-like class's methods in order +features: [set-methods] +includes: [compareArray.js] +---*/ + +let observedOrder = []; + +function observableIterator() { + let values = ["a", "b", "c"]; + let index = 0; + return { + get next() { + observedOrder.push("getting next"); + return function () { + observedOrder.push("calling next"); + return { + get done() { + observedOrder.push("getting done"); + return index >= values.length; + }, + get value() { + observedOrder.push("getting value"); + return values[index++]; + }, + }; + }; + }, + }; +} + +class MySendableSetLike { + get size() { + observedOrder.push("getting size"); + return { + valueOf: function () { + observedOrder.push("ToNumber(size)"); + return 3; + }, + }; + } + get has() { + observedOrder.push("getting has"); + return function (v) { + observedOrder.push("calling has"); + return ["a", "b", "c"].indexOf(v) !== -1; + }; + } + get keys() { + observedOrder.push("getting keys"); + return function () { + observedOrder.push("calling keys"); + return observableIterator(); + }; + } +} + +// this is smaller than argument +{ + observedOrder = []; + + const s1 = new SendableSet(["x", "b"]); + const s2 = new MySendableSetLike(); + const result = s1.isDisjointFrom(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + // two calls to has + "calling has", + "calling has", + ]; + + assert.sameValue(result, false); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is same size as argument - stops eagerly +{ + observedOrder = []; + + const s1 = new SendableSet(["x", "b", "y"]); + const s2 = new MySendableSetLike(); + const result = s1.isDisjointFrom(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + // two calls to has + "calling has", + "calling has", + ]; + + assert.sameValue(result, false); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is same size as argument - full run +{ + observedOrder = []; + + const s1 = new SendableSet(["x", "y", "z"]); + const s2 = new MySendableSetLike(); + const result = s1.isDisjointFrom(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + // three calls to has + "calling has", + "calling has", + "calling has", + ]; + + assert.sameValue(result, true); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is larger than argument - stops eagerly +{ + observedOrder = []; + + const s1 = new SendableSet(["x", "b", "y", "z"]); + const s2 = new MySendableSetLike(); + const result = s1.isDisjointFrom(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + "calling keys", + "getting next", + // first iteration, has value + "calling next", + "getting done", + "getting value", + // second iteration, has value + "calling next", + "getting done", + "getting value", + ]; + + assert.sameValue(result, false); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is larger than argument - full run +{ + observedOrder = []; + + const s1 = new SendableSet(["x", "y", "z", "w"]); + const s2 = new MySendableSetLike(); + const result = s1.isDisjointFrom(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + "calling keys", + "getting next", + // first iteration, has value + "calling next", + "getting done", + "getting value", + // second iteration, has value + "calling next", + "getting done", + "getting value", + // third iteration, has value + "calling next", + "getting done", + "getting value", + // fourth iteration, done + "calling next", + "getting done", + ]; + + assert.sameValue(result, true); + assert.compareArray(observedOrder, expectedOrder); +} diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/size-is-a-number.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/size-is-a-number.js new file mode 100644 index 00000000000..1de5b114137 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/size-is-a-number.js @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object has a size that is coerced to NaN +info: | + 2. Let rawSize be ? Get(obj, "size"). + 3. Let numSize be ? ToNumber(rawSize). + 4. NOTE: If rawSize is undefined, then numSize will be NaN. + 5. If numSize is NaN, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: undefined, + has: () => {}, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(s2); + }, + "GetSendableSetRecord throws an error when size is undefined" +); + +s2.size = NaN; +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(s2); + }, + "GetSendableSetRecord throws an error when size is NaN" +); + +let coercionCalls = 0; +s2.size = { + valueOf: function() { + ++coercionCalls; + return NaN; + }, +}; +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(s2); + }, + "GetSendableSetRecord throws an error when size coerces to NaN" +); +assert.sameValue(coercionCalls, 1, "GetSendableSetRecord coerces size"); + +s2.size = 0n; +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(s2); + }, + "GetSendableSetRecord throws an error when size is a BigInt" +); + +s2.size = "string"; +assert.throws( + TypeError, + function () { + s1.isDisjointFrom(s2); + }, + "GetSendableSetRecord throws an error when size is a non-numeric string" +); diff --git a/test/sendable/builtins/Set/prototype/isDisjointFrom/subclass-receiver-methods.js b/test/sendable/builtins/Set/prototype/isDisjointFrom/subclass-receiver-methods.js new file mode 100644 index 00000000000..aa5160181a7 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isDisjointFrom/subclass-receiver-methods.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.isdisjointfrom +description: SendableSet.prototype.isDisjointFrom works on subclasses of SendableSet, but never calls the receiver's size/has/keys methods +features: [set-methods] +---*/ + +let sizeCount = 0; +let hasCount = 0; +let keysCount = 0; + +class MySendableSet extends SendableSet { + size(...rest) { + sizeCount++; + return super.size(...rest); + } + + has(...rest) { + hasCount++; + return super.has(...rest); + } + + keys(...rest) { + keysCount++; + return super.keys(...rest); + } +} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const result = s1.isDisjointFrom(s2); +assert.sameValue(result, false); + +assert.sameValue(sizeCount, 0, "size should not be called on the receiver"); +assert.sameValue(hasCount, 0, "has should not be called on the receiver"); +assert.sameValue(keysCount, 0, "keys should not be called on the receiver"); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/allows-set-like-class.js b/test/sendable/builtins/Set/prototype/isSubsetOf/allows-set-like-class.js new file mode 100644 index 00000000000..e458f9f0ca1 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/allows-set-like-class.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: GetSendableSetRecord allows instances of SendableSet-like classes +info: | + 1. If obj is not an Object, throw a TypeError exception. + 2. Let rawSize be ? Get(obj, "size"). + ... + 7. Let has be ? Get(obj, "has"). + ... + 9. Let keys be ? Get(obj, "keys"). +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new class { + get size() { + return 3; + } + has(v) { + if (v === 1) return false; + if (v === 2) return true; + throw new Test262Error("SendableSet.prototype.isSubsetOf should only call its argument's has method with contents of this"); + } + * keys() { + throw new Test262Error("SendableSet.prototype.isSubsetOf should not call its argument's keys iterator"); + } +}; + +assert.sameValue(s1.isSubsetOf(s2), false); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/allows-set-like-object.js b/test/sendable/builtins/Set/prototype/isSubsetOf/allows-set-like-object.js new file mode 100644 index 00000000000..4fe659afcac --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/allows-set-like-object.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: GetSendableSetRecord allows SendableSet-like objects +info: | + 1. If obj is not an Object, throw a TypeError exception. + 2. Let rawSize be ? Get(obj, "size"). + ... + 7. Let has be ? Get(obj, "has"). + ... + 9. Let keys be ? Get(obj, "keys"). +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: (v) => { + if (v === 1) return false; + if (v === 2) return true; + throw new Test262Error("SendableSet.prototype.isSubsetOf should only call its argument's has method with contents of this"); + }, + keys: function* keys() { + throw new Test262Error("SendableSet.prototype.isSubsetOf should not call its argument's keys iterator"); + }, +}; + +assert.sameValue(s1.isSubsetOf(s2), false); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/array-throws.js b/test/sendable/builtins/Set/prototype/isSubsetOf/array-throws.js new file mode 100644 index 00000000000..85fdeee8f1e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/array-throws.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf doesn't work with arrays +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = [3]; +assert.throws( + TypeError, + function () { + s1.isSubsetOf(s2); + }, + "Throws an error when an array is used" +); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/builtins.js b/test/sendable/builtins/Set/prototype/isSubsetOf/builtins.js new file mode 100644 index 00000000000..51a27424e63 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/builtins.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: Tests that SendableSet.prototype.isSubsetOf meets the requirements for built-in objects +features: [set-methods] +---*/ + +assert.sameValue( + Object.isExtensible(SendableSet.prototype.isSubsetOf), + true, + "Built-in objects must be extensible." +); + +assert.sameValue( + Object.prototype.toString.call(SendableSet.prototype.isSubsetOf), + "[object Function]", + "Object.prototype.toString" +); + +assert.sameValue( + Object.getPrototypeOf(SendableSet.prototype.isSubsetOf), + Function.prototype, + "prototype" +); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/called-with-object.js b/test/sendable/builtins/Set/prototype/isSubsetOf/called-with-object.js new file mode 100644 index 00000000000..74cff4ca1c8 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/called-with-object.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws if obj is not an object +info: | + 1. If obj is not an Object, throw a TypeError exception. +features: [set-methods] +---*/ + +let s1 = new SendableSet([1]); +assert.throws( + TypeError, + function () { + s1.isSubsetOf(1); + }, + "number" +); + +assert.throws( + TypeError, + function () { + s1.isSubsetOf(""); + }, + "string" +); + +assert.throws( + TypeError, + function () { + s1.isSubsetOf(1n); + }, + "bigint" +); + +assert.throws( + TypeError, + function () { + s1.isSubsetOf(false); + }, + "boolean" +); + +assert.throws( + TypeError, + function () { + s1.isSubsetOf(undefined); + }, + "undefined" +); + +assert.throws( + TypeError, + function () { + s1.isSubsetOf(null); + }, + "null" +); + +assert.throws( + TypeError, + function () { + s1.isSubsetOf(Symbol("test")); + }, + "symbol" +); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/compares-Map.js b/test/sendable/builtins/Set/prototype/isSubsetOf/compares-Map.js new file mode 100644 index 00000000000..5a6a2189556 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/compares-Map.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf compares with Map +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const m1 = new Map([ + [2, "two"], + [3, "three"], +]); + +assert.sameValue(s1.isSubsetOf(m1), false); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/compares-empty-sets.js b/test/sendable/builtins/Set/prototype/isSubsetOf/compares-empty-sets.js new file mode 100644 index 00000000000..dea8c5772e6 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/compares-empty-sets.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf can compare empty SendableSets +features: [set-methods] +---*/ + +const s1 = new SendableSet([]); +const s2 = new SendableSet([1, 2]); + +assert.sameValue(s1.isSubsetOf(s2), true); + +const s3 = new SendableSet([1, 2]); +const s4 = new SendableSet([]); + +assert.sameValue(s3.isSubsetOf(s4), false); + +const s5 = new SendableSet([]); +const s6 = new SendableSet([]); + +assert.sameValue(s5.isSubsetOf(s6), true); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/compares-itself.js b/test/sendable/builtins/Set/prototype/isSubsetOf/compares-itself.js new file mode 100644 index 00000000000..e0d7d8be936 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/compares-itself.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf is successful when called on itself +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); + +assert.sameValue(s1.isSubsetOf(s1), true); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/compares-same-sets.js b/test/sendable/builtins/Set/prototype/isSubsetOf/compares-same-sets.js new file mode 100644 index 00000000000..b4c33d59f9e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/compares-same-sets.js @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf can compare SendableSets that have the same content +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([1, 2]); + +assert.sameValue(s1.isSubsetOf(s2), true); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/compares-sets.js b/test/sendable/builtins/Set/prototype/isSubsetOf/compares-sets.js new file mode 100644 index 00000000000..d30799efb22 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/compares-sets.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf compares SendableSets +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); + +assert.sameValue(s1.isSubsetOf(s2), false); + +const s3 = new SendableSet([1, 2, 3]); + +assert.sameValue(s1.isSubsetOf(s3), true); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/has-is-callable.js b/test/sendable/builtins/Set/prototype/isSubsetOf/has-is-callable.js new file mode 100644 index 00000000000..2a46129717f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/has-is-callable.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object's 'has' property is not callable +info: | + 7. Let has be ? Get(obj, "has"). + 8. If IsCallable(has) is false, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: undefined, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + function () { + s1.isSubsetOf(s2); + }, + "GetSendableSetRecord throws an error when has is undefined" +); + +s2.has = {}; +assert.throws( + TypeError, + function () { + s1.isSubsetOf(s2); + }, + "GetSendableSetRecord throws an error when has is not callable" +); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/isSubsetOf.js b/test/sendable/builtins/Set/prototype/isSubsetOf/isSubsetOf.js new file mode 100644 index 00000000000..fd7c6eca970 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/isSubsetOf.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf properties +includes: [propertyHelper.js] +features: [set-methods] +---*/ + +assert.sameValue( + typeof SendableSet.prototype.isSubsetOf, + "function", + "`typeof SendableSet.prototype.isSubsetOf` is `'function'`" +); + +verifyProperty(SendableSet.prototype, "isSubsetOf", { + enumerable: false, + writable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/keys-is-callable.js b/test/sendable/builtins/Set/prototype/isSubsetOf/keys-is-callable.js new file mode 100644 index 00000000000..969408af3cf --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/keys-is-callable.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object's 'keys' property is not callable +info: | + 9. Let keys be ? Get(obj, "keys"). + 10. If IsCallable(keys) is false, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: () => {}, + keys: undefined, +}; +assert.throws( + TypeError, + function () { + s1.isSubsetOf(s2); + }, + "GetSendableSetRecord throws an error when keys is undefined" +); + +s2.keys = {}; +assert.throws( + TypeError, + function () { + s1.isSubsetOf(s2); + }, + "GetSendableSetRecord throws an error when keys is not callable" +); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/length.js b/test/sendable/builtins/Set/prototype/isSubsetOf/length.js new file mode 100644 index 00000000000..24bde29e7e2 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf length property +info: | + SendableSet.prototype.isSubsetOf ( other ) +includes: [propertyHelper.js] +features: [set-methods] +---*/ +assert.sameValue(typeof SendableSet.prototype.isSubsetOf, "function"); + +verifyProperty(SendableSet.prototype.isSubsetOf, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 1, +}); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/name.js b/test/sendable/builtins/Set/prototype/isSubsetOf/name.js new file mode 100644 index 00000000000..f376efd900a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf name property +info: | + SendableSet.prototype.isSubsetOf ( other ) +includes: [propertyHelper.js] +features: [set-methods] +---*/ +assert.sameValue(typeof SendableSet.prototype.isSubsetOf, "function"); + +verifyProperty(SendableSet.prototype.isSubsetOf, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "isSubsetOf", +}); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/not-a-constructor.js b/test/sendable/builtins/Set/prototype/isSubsetOf/not-a-constructor.js new file mode 100644 index 00000000000..d73d1aa1ba4 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/not-a-constructor.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf does not implement [[Construct]], is not new-able +includes: [isConstructor.js] +features: [Reflect.construct, set-methods] +---*/ + +assert.sameValue( + isConstructor(SendableSet.prototype.isSubsetOf), + false, + "isConstructor(SendableSet.prototype.isSubsetOf) must return false" +); + +assert.throws( + TypeError, + () => { + new SendableSet.prototype.isSubsetOf(); + }); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/receiver-not-set.js b/test/sendable/builtins/Set/prototype/isSubsetOf/receiver-not-set.js new file mode 100644 index 00000000000..d81f171330d --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/receiver-not-set.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf throws when receiver is not a SendableSet +features: [set-methods] +---*/ + +class MySendableSetLike { + constructor() { + this.size = 2; + this.has = () => {}; + this.keys = function* keys() { + yield 2; + yield 3; + }; + } +} + +const s1 = new MySendableSetLike(); +const s2 = new SendableSet(); +assert.throws( + TypeError, + () => { + SendableSet.prototype.isSubsetOf.call(s1, s2); + }, + "SendableSet-like class" +); + +const s3 = { + size: 2, + has: () => {}, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + () => { + SendableSet.prototype.isSubsetOf.call(s3, s2); + }, + "SendableSet-like object" +); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/require-internal-slot.js b/test/sendable/builtins/Set/prototype/isSubsetOf/require-internal-slot.js new file mode 100644 index 00000000000..4c108e51076 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/require-internal-slot.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf RequireInternalSlot +info: | + 2. Perform ? RequireInternalSlot(O, [[SendableSetData]]) +features: [set-methods] +---*/ + +const isSubsetOf = SendableSet.prototype.isSubsetOf; + +assert.sameValue(typeof isSubsetOf, "function"); + +const realSendableSet = new SendableSet([]); + +assert.throws(TypeError, () => isSubsetOf.call(undefined, realSendableSet), "undefined"); +assert.throws(TypeError, () => isSubsetOf.call(null, realSendableSet), "null"); +assert.throws(TypeError, () => isSubsetOf.call(true, realSendableSet), "true"); +assert.throws(TypeError, () => isSubsetOf.call("", realSendableSet), "empty string"); +assert.throws(TypeError, () => isSubsetOf.call(Symbol(), realSendableSet), "symbol"); +assert.throws(TypeError, () => isSubsetOf.call(1, realSendableSet), "1"); +assert.throws(TypeError, () => isSubsetOf.call(1n, realSendableSet), "1n"); +assert.throws(TypeError, () => isSubsetOf.call({}, realSendableSet), "plain object"); +assert.throws(TypeError, () => isSubsetOf.call([], realSendableSet), "array"); +assert.throws(TypeError, () => isSubsetOf.call(new Map(), realSendableSet), "map"); +assert.throws(TypeError, () => isSubsetOf.call(SendableSet.prototype, realSendableSet), "SendableSet.prototype"); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/set-like-array.js b/test/sendable/builtins/Set/prototype/isSubsetOf/set-like-array.js new file mode 100644 index 00000000000..cec1e8f6ed1 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/set-like-array.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf consumes a set-like array as a set-like, not an array +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = [5, 6]; +s2.size = 3; +s2.has = function (v) { + if (v === 1) return true; + if (v === 2) return true; + throw new Test262Error("SendableSet.prototype.isSubsetOf should only call its argument's has method with contents of this"); +}; +s2.keys = function () { + throw new Test262Error("SendableSet.prototype.isSubsetOf should not call its argument's keys iterator when this.size ≤ arg.size"); +}; + +assert.sameValue(s1.isSubsetOf(s2), true); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/set-like-class-mutation.js b/test/sendable/builtins/Set/prototype/isSubsetOf/set-like-class-mutation.js new file mode 100644 index 00000000000..62b003bb446 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/set-like-class-mutation.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf behavior when a custom SendableSet-like class mutates the receiver +features: [set-methods] +includes: [compareArray.js] +---*/ + +const baseSendableSet = new SendableSet(["a", "b", "c"]); + +const evilSendableSetLike = { + size: 3, + has(v) { + if (v === "a") { + baseSendableSet.delete("c"); + } + return ["x", "a", "b"].includes(v); + }, + * keys() { + throw new Test262Error("SendableSet.prototype.isSubsetOf should not call its argument's keys iterator"); + }, +}; + +const result = baseSendableSet.isSubsetOf(evilSendableSetLike); +assert.sameValue(result, true); + +const expectedNewBase = ["a", "b"]; +assert.compareArray([...baseSendableSet], expectedNewBase); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/set-like-class-order.js b/test/sendable/builtins/Set/prototype/isSubsetOf/set-like-class-order.js new file mode 100644 index 00000000000..8dfcfbf4605 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/set-like-class-order.js @@ -0,0 +1,134 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf calls a SendableSet-like class's methods in order +features: [set-methods] +includes: [compareArray.js] +---*/ + +let observedOrder = []; + +class MySendableSetLike { + get size() { + observedOrder.push("getting size"); + return { + valueOf: function () { + observedOrder.push("ToNumber(size)"); + return 3; + }, + }; + } + get has() { + observedOrder.push("getting has"); + return function (v) { + observedOrder.push("calling has"); + return ["a", "b", "c"].indexOf(v) !== -1; + }; + } + get keys() { + observedOrder.push("getting keys"); + return function () { + throw new Test262Error("SendableSet.prototype.isSubsetOf should not call its argument's keys iterator"); + }; + } +} + +// this is smaller than argument - stops eagerly +{ + observedOrder = []; + + const s1 = new SendableSet(["d", "a"]); + const s2 = new MySendableSetLike(); + const result = s1.isSubsetOf(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + // one call to has + "calling has", + ]; + + assert.sameValue(result, false); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is smaller than argument - full run +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "b"]); + const s2 = new MySendableSetLike(); + const result = s1.isSubsetOf(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + // two calls to has + "calling has", + "calling has", + ]; + + assert.sameValue(result, true); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is same size as argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "b", "c"]); + const s2 = new MySendableSetLike(); + const result = s1.isSubsetOf(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + // three calls to has + "calling has", + "calling has", + "calling has", + ]; + + assert.sameValue(result, true); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is larger than argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "b", "c", "d"]); + const s2 = new MySendableSetLike(); + const result = s1.isSubsetOf(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + // no calls to has + ]; + + assert.sameValue(result, false); + assert.compareArray(observedOrder, expectedOrder); +} diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/size-is-a-number.js b/test/sendable/builtins/Set/prototype/isSubsetOf/size-is-a-number.js new file mode 100644 index 00000000000..5394b699918 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/size-is-a-number.js @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object has a size that is coerced to NaN +info: | + 2. Let rawSize be ? Get(obj, "size"). + 3. Let numSize be ? ToNumber(rawSize). + 4. NOTE: If rawSize is undefined, then numSize will be NaN. + 5. If numSize is NaN, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: undefined, + has: () => {}, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + function () { + s1.isSubsetOf(s2); + }, + "GetSendableSetRecord throws an error when size is undefined" +); + +s2.size = NaN; +assert.throws( + TypeError, + function () { + s1.isSubsetOf(s2); + }, + "GetSendableSetRecord throws an error when size is NaN" +); + +let coercionCalls = 0; +s2.size = { + valueOf: function() { + ++coercionCalls; + return NaN; + }, +}; +assert.throws( + TypeError, + function () { + s1.isSubsetOf(s2); + }, + "GetSendableSetRecord throws an error when size coerces to NaN" +); +assert.sameValue(coercionCalls, 1, "GetSendableSetRecord coerces size"); + +s2.size = 0n; +assert.throws( + TypeError, + function () { + s1.isSubsetOf(s2); + }, + "GetSendableSetRecord throws an error when size is a BigInt" +); + +s2.size = "string"; +assert.throws( + TypeError, + function () { + s1.isSubsetOf(s2); + }, + "GetSendableSetRecord throws an error when size is a non-numeric string" +); diff --git a/test/sendable/builtins/Set/prototype/isSubsetOf/subclass-receiver-methods.js b/test/sendable/builtins/Set/prototype/isSubsetOf/subclass-receiver-methods.js new file mode 100644 index 00000000000..42af3fdb337 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSubsetOf/subclass-receiver-methods.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issubsetof +description: SendableSet.prototype.isSubsetOf works on subclasses of SendableSet, but never calls the receiver's size/has/keys methods +features: [set-methods] +---*/ + +let sizeCount = 0; +let hasCount = 0; +let keysCount = 0; + +class MySendableSet extends SendableSet { + size(...rest) { + sizeCount++; + return super.size(...rest); + } + + has(...rest) { + hasCount++; + return super.has(...rest); + } + + keys(...rest) { + keysCount++; + return super.keys(...rest); + } +} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const result = s1.isSubsetOf(s2); +assert.sameValue(result, false); + +assert.sameValue(sizeCount, 0, "size should not be called on the receiver"); +assert.sameValue(hasCount, 0, "has should not be called on the receiver"); +assert.sameValue(keysCount, 0, "keys should not be called on the receiver"); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/allows-set-like-class.js b/test/sendable/builtins/Set/prototype/isSupersetOf/allows-set-like-class.js new file mode 100644 index 00000000000..542ffd00339 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/allows-set-like-class.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: GetSendableSetRecord allows instances of SendableSet-like classes +info: | + 1. If obj is not an Object, throw a TypeError exception. + 2. Let rawSize be ? Get(obj, "size"). + ... + 7. Let has be ? Get(obj, "has"). + ... + 9. Let keys be ? Get(obj, "keys"). +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new class { + get size() { + return 1; + } + has(v) { + throw new Test262Error("SendableSet.prototype.isSupersetOf should not call its argument's has method"); + } + * keys() { + yield 1; + } +}; + +assert.sameValue(s1.isSupersetOf(s2), true); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/allows-set-like-object.js b/test/sendable/builtins/Set/prototype/isSupersetOf/allows-set-like-object.js new file mode 100644 index 00000000000..fbbf225a820 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/allows-set-like-object.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: GetSendableSetRecord allows SendableSet-like objects +info: | + 1. If obj is not an Object, throw a TypeError exception. + 2. Let rawSize be ? Get(obj, "size"). + ... + 7. Let has be ? Get(obj, "has"). + ... + 9. Let keys be ? Get(obj, "keys"). +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 1, + has: (v) => { + throw new Test262Error("SendableSet.prototype.isSupersetOf should not call its argument's has method"); + }, + keys: function* keys() { + yield 1; + }, +}; + +assert.sameValue(s1.isSupersetOf(s2), true); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/array-throws.js b/test/sendable/builtins/Set/prototype/isSupersetOf/array-throws.js new file mode 100644 index 00000000000..bee793c5944 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/array-throws.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf doesn't work with arrays +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = [3]; +assert.throws( + TypeError, + function () { + s1.isSupersetOf(s2); + }, + "Throws an error when an array is used" +); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/builtins.js b/test/sendable/builtins/Set/prototype/isSupersetOf/builtins.js new file mode 100644 index 00000000000..13e7229f83c --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/builtins.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: Tests that SendableSet.prototype.isSupersetOf meets the requirements for built-in objects +features: [set-methods] +---*/ + +assert.sameValue( + Object.isExtensible(SendableSet.prototype.isSupersetOf), + true, + "Built-in objects must be extensible." +); + +assert.sameValue( + Object.prototype.toString.call(SendableSet.prototype.isSupersetOf), + "[object Function]", + "Object.prototype.toString" +); + +assert.sameValue( + Object.getPrototypeOf(SendableSet.prototype.isSupersetOf), + Function.prototype, + "prototype" +); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/called-with-object.js b/test/sendable/builtins/Set/prototype/isSupersetOf/called-with-object.js new file mode 100644 index 00000000000..157aaf8db34 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/called-with-object.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws if obj is not an object +info: | + 1. If obj is not an Object, throw a TypeError exception. +features: [set-methods] +---*/ + +let s1 = new SendableSet([1]); +assert.throws( + TypeError, + function () { + s1.isSupersetOf(1); + }, + "number" +); + +assert.throws( + TypeError, + function () { + s1.isSupersetOf(""); + }, + "string" +); + +assert.throws( + TypeError, + function () { + s1.isSupersetOf(1n); + }, + "bigint" +); + +assert.throws( + TypeError, + function () { + s1.isSupersetOf(false); + }, + "boolean" +); + +assert.throws( + TypeError, + function () { + s1.isSupersetOf(undefined); + }, + "undefined" +); + +assert.throws( + TypeError, + function () { + s1.isSupersetOf(null); + }, + "null" +); + +assert.throws( + TypeError, + function () { + s1.isSupersetOf(Symbol("test")); + }, + "symbol" +); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/compares-Map.js b/test/sendable/builtins/Set/prototype/isSupersetOf/compares-Map.js new file mode 100644 index 00000000000..834b7fe079a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/compares-Map.js @@ -0,0 +1,28 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf compares with Map +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const m1 = new Map([ + [2, "two"], + [3, "three"], +]); + +assert.sameValue(s1.isSupersetOf(m1), false); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/compares-empty-sets.js b/test/sendable/builtins/Set/prototype/isSupersetOf/compares-empty-sets.js new file mode 100644 index 00000000000..98bf65f4c29 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/compares-empty-sets.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf can compare empty SendableSets +features: [set-methods] +---*/ + +const s1 = new SendableSet([]); +const s2 = new SendableSet([1, 2]); + +assert.sameValue(s1.isSupersetOf(s2), false); + +const s3 = new SendableSet([1, 2]); +const s4 = new SendableSet([]); + +assert.sameValue(s3.isSupersetOf(s4), true); + +const s5 = new SendableSet([]); +const s6 = new SendableSet([]); + +assert.sameValue(s5.isSupersetOf(s6), true); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/compares-itself.js b/test/sendable/builtins/Set/prototype/isSupersetOf/compares-itself.js new file mode 100644 index 00000000000..80e5104fb6f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/compares-itself.js @@ -0,0 +1,24 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf is successful when called on itself +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); + +assert.sameValue(s1.isSupersetOf(s1), true); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/compares-same-sets.js b/test/sendable/builtins/Set/prototype/isSupersetOf/compares-same-sets.js new file mode 100644 index 00000000000..4ad98819ab4 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/compares-same-sets.js @@ -0,0 +1,25 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf can compare SendableSets that have the same content +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([1, 2]); + +assert.sameValue(s1.isSupersetOf(s2), true); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/compares-sets.js b/test/sendable/builtins/Set/prototype/isSupersetOf/compares-sets.js new file mode 100644 index 00000000000..ffeeae1a393 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/compares-sets.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf compares SendableSets +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); + +assert.sameValue(s1.isSupersetOf(s2), false); + +const s3 = new SendableSet([1]); + +assert.sameValue(s1.isSupersetOf(s3), true); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/converts-negative-zero.js b/test/sendable/builtins/Set/prototype/isSupersetOf/converts-negative-zero.js new file mode 100644 index 00000000000..a5a17656590 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/converts-negative-zero.js @@ -0,0 +1,35 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf converts -0𝔽 to +0𝔽 +features: [set-methods] +---*/ + +const setlikeWithMinusZero = { + size: 1, + has: function () { + throw new Test262Error("SendableSet.prototype.isSupersetOf should not call its argument's has method"); + }, + keys: function () { + // we use an array here because the SendableSet constructor would normalize away -0 + return [-0].values(); + }, +}; + +const s1 = new SendableSet([+0, 1]); + +assert.sameValue(s1.isSupersetOf(setlikeWithMinusZero), true); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/has-is-callable.js b/test/sendable/builtins/Set/prototype/isSupersetOf/has-is-callable.js new file mode 100644 index 00000000000..442b8bacae0 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/has-is-callable.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object's 'has' property is not callable +info: | + 7. Let has be ? Get(obj, "has"). + 8. If IsCallable(has) is false, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: undefined, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + function () { + s1.isSupersetOf(s2); + }, + "GetSendableSetRecord throws an error when has is undefined" +); + +s2.has = {}; +assert.throws( + TypeError, + function () { + s1.isSupersetOf(s2); + }, + "GetSendableSetRecord throws an error when has is not callable" +); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/isSupersetOf.js b/test/sendable/builtins/Set/prototype/isSupersetOf/isSupersetOf.js new file mode 100644 index 00000000000..2a2b8dff984 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/isSupersetOf.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf properties +includes: [propertyHelper.js] +features: [set-methods] +---*/ + +assert.sameValue( + typeof SendableSet.prototype.isSupersetOf, + "function", + "`typeof SendableSet.prototype.isSupersetOf` is `'function'`" +); + +verifyProperty(SendableSet.prototype, "isSupersetOf", { + enumerable: false, + writable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/keys-is-callable.js b/test/sendable/builtins/Set/prototype/isSupersetOf/keys-is-callable.js new file mode 100644 index 00000000000..547f3174439 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/keys-is-callable.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object's 'keys' property is not callable +info: | + 9. Let keys be ? Get(obj, "keys"). + 10. If IsCallable(keys) is false, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: () => {}, + keys: undefined, +}; +assert.throws( + TypeError, + function () { + s1.isSupersetOf(s2); + }, + "GetSendableSetRecord throws an error when keys is undefined" +); + +s2.keys = {}; +assert.throws( + TypeError, + function () { + s1.isSupersetOf(s2); + }, + "GetSendableSetRecord throws an error when keys is not callable" +); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/length.js b/test/sendable/builtins/Set/prototype/isSupersetOf/length.js new file mode 100644 index 00000000000..d815fbde54f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf length property +info: | + SendableSet.prototype.isSupersetOf ( other ) +includes: [propertyHelper.js] +features: [set-methods] +---*/ +assert.sameValue(typeof SendableSet.prototype.isSupersetOf, "function"); + +verifyProperty(SendableSet.prototype.isSupersetOf, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 1, +}); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/name.js b/test/sendable/builtins/Set/prototype/isSupersetOf/name.js new file mode 100644 index 00000000000..d63fa32f3df --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf name property +info: | + SendableSet.prototype.isSupersetOf ( other ) +includes: [propertyHelper.js] +features: [set-methods] +---*/ +assert.sameValue(typeof SendableSet.prototype.isSupersetOf, "function"); + +verifyProperty(SendableSet.prototype.isSupersetOf, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "isSupersetOf", +}); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/not-a-constructor.js b/test/sendable/builtins/Set/prototype/isSupersetOf/not-a-constructor.js new file mode 100644 index 00000000000..64352fdaf36 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/not-a-constructor.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf does not implement [[Construct]], is not new-able +includes: [isConstructor.js] +features: [Reflect.construct, set-methods] +---*/ + +assert.sameValue( + isConstructor(SendableSet.prototype.isSupersetOf), + false, + "isConstructor(SendableSet.prototype.isSupersetOf) must return false" +); + +assert.throws( + TypeError, + () => { + new SendableSet.prototype.isSupersetOf(); + }); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/receiver-not-set.js b/test/sendable/builtins/Set/prototype/isSupersetOf/receiver-not-set.js new file mode 100644 index 00000000000..af3ff6dd524 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/receiver-not-set.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf throws when receiver is not a SendableSet +features: [set-methods] +---*/ + +class MySendableSetLike { + constructor() { + this.size = 2; + this.has = () => {}; + this.keys = function* keys() { + yield 2; + yield 3; + }; + } +} + +const s1 = new MySendableSetLike(); +const s2 = new SendableSet(); +assert.throws( + TypeError, + () => { + SendableSet.prototype.isSupersetOf.call(s1, s2); + }, + "SendableSet-like class" +); + +const s3 = { + size: 2, + has: () => {}, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + () => { + SendableSet.prototype.isSupersetOf.call(s3, s2); + }, + "SendableSet-like object" +); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/require-internal-slot.js b/test/sendable/builtins/Set/prototype/isSupersetOf/require-internal-slot.js new file mode 100644 index 00000000000..f36bae9d221 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/require-internal-slot.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf RequireInternalSlot +info: | + 2. Perform ? RequireInternalSlot(O, [[SendableSetData]]) +features: [set-methods] +---*/ + +const isSupersetOf = SendableSet.prototype.isSupersetOf; + +assert.sameValue(typeof isSupersetOf, "function"); + +const realSendableSet = new SendableSet([]); + +assert.throws(TypeError, () => isSupersetOf.call(undefined, realSendableSet), "undefined"); +assert.throws(TypeError, () => isSupersetOf.call(null, realSendableSet), "null"); +assert.throws(TypeError, () => isSupersetOf.call(true, realSendableSet), "true"); +assert.throws(TypeError, () => isSupersetOf.call("", realSendableSet), "empty string"); +assert.throws(TypeError, () => isSupersetOf.call(Symbol(), realSendableSet), "symbol"); +assert.throws(TypeError, () => isSupersetOf.call(1, realSendableSet), "1"); +assert.throws(TypeError, () => isSupersetOf.call(1n, realSendableSet), "1n"); +assert.throws(TypeError, () => isSupersetOf.call({}, realSendableSet), "plain object"); +assert.throws(TypeError, () => isSupersetOf.call([], realSendableSet), "array"); +assert.throws(TypeError, () => isSupersetOf.call(new Map(), realSendableSet), "map"); +assert.throws(TypeError, () => isSupersetOf.call(SendableSet.prototype, realSendableSet), "SendableSet.prototype"); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/set-like-array.js b/test/sendable/builtins/Set/prototype/isSupersetOf/set-like-array.js new file mode 100644 index 00000000000..fa420513057 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/set-like-array.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf consumes a set-like array as a set-like, not an array +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = [1]; +s2.size = 3; +s2.has = function (v) { + if (v === 1) return true; + if (v === 2) return true; + throw new Test262Error("SendableSet.prototype.isSupersetOf should only call its argument's has method with contents of this"); +}; +s2.keys = function () { + throw new Test262Error("SendableSet.prototype.isSupersetOf should not call its argument's keys iterator when this.size ≤ arg.size"); +}; + +assert.sameValue(s1.isSupersetOf(s2), false); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/set-like-class-mutation.js b/test/sendable/builtins/Set/prototype/isSupersetOf/set-like-class-mutation.js new file mode 100644 index 00000000000..960e91f2235 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/set-like-class-mutation.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf behavior when a custom SendableSet-like class mutates the receiver +features: [set-methods] +includes: [compareArray.js] +---*/ + +const baseSendableSet = new SendableSet(["a", "b", "c"]); + +const evilSendableSetLike = { + size: 3, + has(v) { + throw new Test262Error("SendableSet.prototype.isSupersetOf should not call its argument's has method"); + }, + * keys() { + yield "a"; + baseSendableSet.delete("b"); + baseSendableSet.delete("c"); + baseSendableSet.add("b"); + yield "b"; + }, +}; + +const result = baseSendableSet.isSupersetOf(evilSendableSetLike); +assert.sameValue(result, true); + +const expectedNewBase = ["a", "b"]; +assert.compareArray([...baseSendableSet], expectedNewBase); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/set-like-class-order.js b/test/sendable/builtins/Set/prototype/isSupersetOf/set-like-class-order.js new file mode 100644 index 00000000000..0b39e4fcbf1 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/set-like-class-order.js @@ -0,0 +1,192 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf calls a SendableSet-like class's methods in order +features: [set-methods] +includes: [compareArray.js] +---*/ + +let observedOrder = []; + +function observableIterator() { + let values = ["a", "b", "c"]; + let index = 0; + return { + get next() { + observedOrder.push("getting next"); + return function () { + observedOrder.push("calling next"); + return { + get done() { + observedOrder.push("getting done"); + return index >= values.length; + }, + get value() { + observedOrder.push("getting value"); + return values[index++]; + }, + }; + }; + }, + }; +} + +class MySendableSetLike { + get size() { + observedOrder.push("getting size"); + return { + valueOf: function () { + observedOrder.push("ToNumber(size)"); + return 3; + }, + }; + } + get has() { + observedOrder.push("getting has"); + return function (v) { + throw new Test262Error("SendableSet.prototype.isSupersetOf should not call its argument's has method"); + }; + } + get keys() { + observedOrder.push("getting keys"); + return function () { + observedOrder.push("calling keys"); + return observableIterator(); + }; + } +} + +// this is smaller than argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "b"]); + const s2 = new MySendableSetLike(); + const result = s1.isSupersetOf(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + // no iteration + ]; + + assert.sameValue(result, false); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is same size as argument - stops eagerly +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "x", "c"]); + const s2 = new MySendableSetLike(); + const result = s1.isSupersetOf(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + "calling keys", + "getting next", + // first iteration, has value + "calling next", + "getting done", + "getting value", + // second iteration, has value + "calling next", + "getting done", + "getting value", + ]; + + assert.sameValue(result, false); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is same size as argument - full run +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "b", "c"]); + const s2 = new MySendableSetLike(); + const result = s1.isSupersetOf(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + "calling keys", + "getting next", + // first iteration, has value + "calling next", + "getting done", + "getting value", + // second iteration, has value + "calling next", + "getting done", + "getting value", + // third iteration, has value + "calling next", + "getting done", + "getting value", + // fourth iteration, no value; ends + "calling next", + "getting done", + ]; + + assert.sameValue(result, true); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is larger than argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "b", "c", "d"]); + const s2 = new MySendableSetLike(); + const result = s1.isSupersetOf(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + "calling keys", + "getting next", + // first iteration, has value + "calling next", + "getting done", + "getting value", + // second iteration, has value + "calling next", + "getting done", + "getting value", + // third iteration, has value + "calling next", + "getting done", + "getting value", + // fourth iteration, no value; ends + "calling next", + "getting done", + ]; + + assert.sameValue(result, true); + assert.compareArray(observedOrder, expectedOrder); +} diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/size-is-a-number.js b/test/sendable/builtins/Set/prototype/isSupersetOf/size-is-a-number.js new file mode 100644 index 00000000000..ae9531b7b9f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/size-is-a-number.js @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object has a size that is coerced to NaN +info: | + 2. Let rawSize be ? Get(obj, "size"). + 3. Let numSize be ? ToNumber(rawSize). + 4. NOTE: If rawSize is undefined, then numSize will be NaN. + 5. If numSize is NaN, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: undefined, + has: () => {}, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + function () { + s1.isSupersetOf(s2); + }, + "GetSendableSetRecord throws an error when size is undefined" +); + +s2.size = NaN; +assert.throws( + TypeError, + function () { + s1.isSupersetOf(s2); + }, + "GetSendableSetRecord throws an error when size is NaN" +); + +let coercionCalls = 0; +s2.size = { + valueOf: function() { + ++coercionCalls; + return NaN; + }, +}; +assert.throws( + TypeError, + function () { + s1.isSupersetOf(s2); + }, + "GetSendableSetRecord throws an error when size coerces to NaN" +); +assert.sameValue(coercionCalls, 1, "GetSendableSetRecord coerces size"); + +s2.size = 0n; +assert.throws( + TypeError, + function () { + s1.isSupersetOf(s2); + }, + "GetSendableSetRecord throws an error when size is a BigInt" +); + +s2.size = "string"; +assert.throws( + TypeError, + function () { + s1.isSupersetOf(s2); + }, + "GetSendableSetRecord throws an error when size is a non-numeric string" +); diff --git a/test/sendable/builtins/Set/prototype/isSupersetOf/subclass-receiver-methods.js b/test/sendable/builtins/Set/prototype/isSupersetOf/subclass-receiver-methods.js new file mode 100644 index 00000000000..c74f6858648 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/isSupersetOf/subclass-receiver-methods.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.issupersetof +description: SendableSet.prototype.isSupersetOf works on subclasses of SendableSet, but never calls the receiver's size/has/keys methods +features: [set-methods] +---*/ + +let sizeCount = 0; +let hasCount = 0; +let keysCount = 0; + +class MySendableSet extends SendableSet { + size(...rest) { + sizeCount++; + return super.size(...rest); + } + + has(...rest) { + hasCount++; + return super.has(...rest); + } + + keys(...rest) { + keysCount++; + return super.keys(...rest); + } +} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const result = s1.isSupersetOf(s2); +assert.sameValue(result, false); + +assert.sameValue(sizeCount, 0, "size should not be called on the receiver"); +assert.sameValue(hasCount, 0, "has should not be called on the receiver"); +assert.sameValue(keysCount, 0, "keys should not be called on the receiver"); diff --git a/test/sendable/builtins/Set/prototype/keys/keys.js b/test/sendable/builtins/Set/prototype/keys/keys.js new file mode 100644 index 00000000000..6bce48dc714 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/keys/keys.js @@ -0,0 +1,27 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.keys +description: > + The initial value of the keys property is the same function object as the + initial value of the values property. +---*/ + +assert.sameValue( + SendableSet.prototype.keys, + SendableSet.prototype.values, + "The value of `SendableSet.prototype.keys` is `SendableSet.prototype.values`" +); diff --git a/test/sendable/builtins/Set/prototype/size/length.js b/test/sendable/builtins/Set/prototype/size/length.js new file mode 100644 index 00000000000..6e946e444bd --- /dev/null +++ b/test/sendable/builtins/Set/prototype/size/length.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-set.prototype.size +description: > + get SendableSet.prototype.size + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(SendableSet.prototype, "size"); + + +verifyProperty(descriptor.get, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/size/name.js b/test/sendable/builtins/Set/prototype/size/name.js new file mode 100644 index 00000000000..2e586d78d1d --- /dev/null +++ b/test/sendable/builtins/Set/prototype/size/name.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-set.prototype.size +description: > + get SendableSet.prototype.size + + 17 ECMAScript Standard Built-in Objects + + Functions that are specified as get or set accessor functions of built-in + properties have "get " or "set " prepended to the property name string. + +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(SendableSet.prototype, "size"); + + +verifyProperty(descriptor.get, "name", { + value: "get size", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/size/returns-count-of-present-values-before-after-add-delete.js b/test/sendable/builtins/Set/prototype/size/returns-count-of-present-values-before-after-add-delete.js new file mode 100644 index 00000000000..9b29073cebc --- /dev/null +++ b/test/sendable/builtins/Set/prototype/size/returns-count-of-present-values-before-after-add-delete.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-set.prototype.size +description: > + get SendableSet.prototype.size + + 5. Let count be 0. + 6. For each e that is an element of entries + a. If e is not empty, set count to count+1. + + Before and after add(), delete() +---*/ + +var s = new SendableSet(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); + +s.add(0); + +assert.sameValue(s.size, 1, "The value of `s.size` is `1`, after executing `s.add(0)`"); + +s.delete(0); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`, after executing `s.delete(0)`"); diff --git a/test/sendable/builtins/Set/prototype/size/returns-count-of-present-values-by-insertion.js b/test/sendable/builtins/Set/prototype/size/returns-count-of-present-values-by-insertion.js new file mode 100644 index 00000000000..ad97cdd0112 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/size/returns-count-of-present-values-by-insertion.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-set.prototype.size +description: > + get SendableSet.prototype.size + + 5. Let count be 0. + 6. For each e that is an element of entries + a. If e is not empty, set count to count+1. + +features: [Symbol] +---*/ + +var s = new SendableSet(); + +s.add(0); +s.add(undefined); +s.add(false); +s.add(NaN); +s.add(null); +s.add(""); +s.add(Symbol()); + +assert.sameValue(s.size, 7, "The value of `s.size` is `7`"); diff --git a/test/sendable/builtins/Set/prototype/size/returns-count-of-present-values-by-iterable.js b/test/sendable/builtins/Set/prototype/size/returns-count-of-present-values-by-iterable.js new file mode 100644 index 00000000000..a5f1fe9c324 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/size/returns-count-of-present-values-by-iterable.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-set.prototype.size +description: > + get SendableSet.prototype.size + + 5. Let count be 0. + 6. For each e that is an element of entries + a. If e is not empty, set count to count+1. + +features: [Symbol] +---*/ + +var s = new SendableSet([0, undefined, false, NaN, null, "", Symbol()]); + +assert.sameValue(s.size, 7, "The value of `s.size` is `7`"); diff --git a/test/sendable/builtins/Set/prototype/size/size.js b/test/sendable/builtins/Set/prototype/size/size.js new file mode 100644 index 00000000000..4103ae9ccd0 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/size/size.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-get-set.prototype.size +description: > + get SendableSet.prototype.size + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +var descriptor = Object.getOwnPropertyDescriptor(SendableSet.prototype, "size"); + +assert.sameValue( + typeof descriptor.get, + "function", + "`typeof descriptor.get` is `'function'`" +); +assert.sameValue( + typeof descriptor.set, + "undefined", + "`typeof descriptor.set` is `\"undefined\"`" +); + +verifyNotEnumerable(SendableSet.prototype, "size"); +verifyConfigurable(SendableSet.prototype, "size"); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/add-not-called.js b/test/sendable/builtins/Set/prototype/symmetricDifference/add-not-called.js new file mode 100644 index 00000000000..58bf9b46e6f --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/add-not-called.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference should not call SendableSet.prototype.add +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1, 3]; + +const originalAdd = SendableSet.prototype.add; +let count = 0; +SendableSet.prototype.add = function (...rest) { + count++; + return originalAdd.apply(this, rest); +}; + +const combined = s1.symmetricDifference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue(count, 0, "Add is never called"); + +SendableSet.prototype.add = originalAdd; diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/allows-set-like-class.js b/test/sendable/builtins/Set/prototype/symmetricDifference/allows-set-like-class.js new file mode 100644 index 00000000000..253b006e103 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/allows-set-like-class.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: GetSendableSetRecord allows instances of SendableSet-like classes +info: | + 1. If obj is not an Object, throw a TypeError exception. + 2. Let rawSize be ? Get(obj, "size"). + ... + 7. Let has be ? Get(obj, "has"). + ... + 9. Let keys be ? Get(obj, "keys"). +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new class { + get size() { + return 2; + } + has(v) { + throw new Test262Error("SendableSet.prototype.symmetricDifference should not invoke .has on its argument"); + } + * keys() { + yield 2; + yield 3; + } +}; +const expected = [1, 3]; +const combined = s1.symmetricDifference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/allows-set-like-object.js b/test/sendable/builtins/Set/prototype/symmetricDifference/allows-set-like-object.js new file mode 100644 index 00000000000..60d2d38bc68 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/allows-set-like-object.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: GetSendableSetRecord allows SendableSet-like objects +info: | + 1. If obj is not an Object, throw a TypeError exception. + 2. Let rawSize be ? Get(obj, "size"). + ... + 7. Let has be ? Get(obj, "has"). + ... + 9. Let keys be ? Get(obj, "keys"). +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: (v) => { + throw new Test262Error("SendableSet.prototype.symmetricDifference should not invoke .has on its argument"); + }, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +const expected = [1, 3]; +const combined = s1.symmetricDifference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/array-throws.js b/test/sendable/builtins/Set/prototype/symmetricDifference/array-throws.js new file mode 100644 index 00000000000..31e6dcd1cf0 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/array-throws.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference doesn't work with arrays +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = [3]; +assert.throws( + TypeError, + function () { + s1.symmetricDifference(s2); + }, + "Throws an error when an array is used" +); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/builtins.js b/test/sendable/builtins/Set/prototype/symmetricDifference/builtins.js new file mode 100644 index 00000000000..3635fe64c9b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/builtins.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: Tests that SendableSet.prototype.symmetricDifference meets the requirements for built-in objects +features: [set-methods] +---*/ + +assert.sameValue( + Object.isExtensible(SendableSet.prototype.symmetricDifference), + true, + "Built-in objects must be extensible." +); + +assert.sameValue( + Object.prototype.toString.call(SendableSet.prototype.symmetricDifference), + "[object Function]", + "Object.prototype.toString" +); + +assert.sameValue( + Object.getPrototypeOf(SendableSet.prototype.symmetricDifference), + Function.prototype, + "prototype" +); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/called-with-object.js b/test/sendable/builtins/Set/prototype/symmetricDifference/called-with-object.js new file mode 100644 index 00000000000..0931ce98cd6 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/called-with-object.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws if obj is not an object +info: | + 1. If obj is not an Object, throw a TypeError exception. +features: [set-methods] +---*/ + +let s1 = new SendableSet([1]); +assert.throws( + TypeError, + function () { + s1.symmetricDifference(1); + }, + "number" +); + +assert.throws( + TypeError, + function () { + s1.symmetricDifference(""); + }, + "string" +); + +assert.throws( + TypeError, + function () { + s1.symmetricDifference(1n); + }, + "bigint" +); + +assert.throws( + TypeError, + function () { + s1.symmetricDifference(false); + }, + "boolean" +); + +assert.throws( + TypeError, + function () { + s1.symmetricDifference(undefined); + }, + "undefined" +); + +assert.throws( + TypeError, + function () { + s1.symmetricDifference(null); + }, + "null" +); + +assert.throws( + TypeError, + function () { + s1.symmetricDifference(Symbol("test")); + }, + "symbol" +); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/combines-Map.js b/test/sendable/builtins/Set/prototype/symmetricDifference/combines-Map.js new file mode 100644 index 00000000000..39c474cdbb5 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/combines-Map.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference combines with Map +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const m1 = new Map([ + [2, "two"], + [3, "three"], +]); +const expected = [1, 3]; +const combined = s1.symmetricDifference(m1); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/combines-empty-sets.js b/test/sendable/builtins/Set/prototype/symmetricDifference/combines-empty-sets.js new file mode 100644 index 00000000000..5af303f8afa --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/combines-empty-sets.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference can combine empty SendableSets +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([]); +const s2 = new SendableSet([1, 2]); +let expected = [1, 2]; +let combined = s1.symmetricDifference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); + +const s3 = new SendableSet([1, 2]); +const s4 = new SendableSet([]); +expected = [1, 2]; +combined = s3.symmetricDifference(s4); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); + +const s5 = new SendableSet([]); +const s6 = new SendableSet([]); +expected = []; +combined = s5.symmetricDifference(s6); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/combines-itself.js b/test/sendable/builtins/Set/prototype/symmetricDifference/combines-itself.js new file mode 100644 index 00000000000..01d2174a6df --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/combines-itself.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference is successful when called on itself +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const expected = []; +const combined = s1.symmetricDifference(s1); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue(combined === s1, false, "The returned object is a new object"); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/combines-same-sets.js b/test/sendable/builtins/Set/prototype/symmetricDifference/combines-same-sets.js new file mode 100644 index 00000000000..cf72cc72587 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/combines-same-sets.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference can combine SendableSets that have the same content +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([1, 2]); +const expected = []; +const combined = s1.symmetricDifference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue(combined === s1, false, "The returned object is a new object"); +assert.sameValue(combined === s2, false, "The returned object is a new object"); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/combines-sets.js b/test/sendable/builtins/Set/prototype/symmetricDifference/combines-sets.js new file mode 100644 index 00000000000..a4de65645a5 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/combines-sets.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference combines SendableSets +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1, 3]; +const combined = s1.symmetricDifference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/converts-negative-zero.js b/test/sendable/builtins/Set/prototype/symmetricDifference/converts-negative-zero.js new file mode 100644 index 00000000000..37f81eb46a7 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/converts-negative-zero.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference converts -0𝔽 to +0𝔽 +info: | + 7.b.ii If nextValue is -0𝔽, set nextValue to +0𝔽. +features: [set-methods] +includes: [compareArray.js] +---*/ + +const setlikeWithMinusZero = { + size: 1, + has: function () { + throw new Test262Error("SendableSet.prototype.symmetricDifference should not invoke .has on its argument"); + }, + keys: function () { + // we use an array here because the SendableSet constructor would normalize away -0 + return [-0].values(); + }, +}; + +const s1 = new SendableSet([1, 2]); +let expected = [1, 2, +0]; +let combined = s1.symmetricDifference(setlikeWithMinusZero); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/has-is-callable.js b/test/sendable/builtins/Set/prototype/symmetricDifference/has-is-callable.js new file mode 100644 index 00000000000..3263508ca48 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/has-is-callable.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object's 'has' property is not callable +info: | + 7. Let has be ? Get(obj, "has"). + 8. If IsCallable(has) is false, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: undefined, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + function () { + s1.symmetricDifference(s2); + }, + "GetSendableSetRecord throws an error when has is undefined" +); + +s2.has = {}; +assert.throws( + TypeError, + function () { + s1.symmetricDifference(s2); + }, + "GetSendableSetRecord throws an error when has is not callable" +); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/keys-is-callable.js b/test/sendable/builtins/Set/prototype/symmetricDifference/keys-is-callable.js new file mode 100644 index 00000000000..0b982462614 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/keys-is-callable.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object's 'keys' property is not callable +info: | + 9. Let keys be ? Get(obj, "keys"). + 10. If IsCallable(keys) is false, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: () => {}, + keys: undefined, +}; +assert.throws( + TypeError, + function () { + s1.symmetricDifference(s2); + }, + "GetSendableSetRecord throws an error when keys is undefined" +); + +s2.keys = {}; +assert.throws( + TypeError, + function () { + s1.symmetricDifference(s2); + }, + "GetSendableSetRecord throws an error when keys is not callable" +); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/length.js b/test/sendable/builtins/Set/prototype/symmetricDifference/length.js new file mode 100644 index 00000000000..55b64ef64fd --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference length property +info: | + SendableSet.prototype.symmetricDifference ( other ) +includes: [propertyHelper.js] +features: [set-methods] +---*/ +assert.sameValue(typeof SendableSet.prototype.symmetricDifference, "function"); + +verifyProperty(SendableSet.prototype.symmetricDifference, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 1, +}); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/name.js b/test/sendable/builtins/Set/prototype/symmetricDifference/name.js new file mode 100644 index 00000000000..a8844759fad --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference name property +info: | + SendableSet.prototype.symmetricDifference ( other ) +includes: [propertyHelper.js] +features: [set-methods] +---*/ +assert.sameValue(typeof SendableSet.prototype.symmetricDifference, "function"); + +verifyProperty(SendableSet.prototype.symmetricDifference, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "symmetricDifference", +}); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/not-a-constructor.js b/test/sendable/builtins/Set/prototype/symmetricDifference/not-a-constructor.js new file mode 100644 index 00000000000..b30ae7d49a7 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/not-a-constructor.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference does not implement [[Construct]], is not new-able +includes: [isConstructor.js] +features: [Reflect.construct, set-methods] +---*/ + +assert.sameValue( + isConstructor(SendableSet.prototype.symmetricDifference), + false, + "isConstructor(SendableSet.prototype.symmetricDifference) must return false" +); + +assert.throws( + TypeError, + () => { + new SendableSet.prototype.symmetricDifference(); + }); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/receiver-not-set.js b/test/sendable/builtins/Set/prototype/symmetricDifference/receiver-not-set.js new file mode 100644 index 00000000000..a2d9aff20e0 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/receiver-not-set.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference throws when receiver is not a SendableSet +features: [set-methods] +---*/ + +class MySendableSetLike { + constructor() { + this.size = 2; + this.has = () => {}; + this.keys = function* keys() { + yield 2; + yield 3; + }; + } +} + +const s1 = new MySendableSetLike(); +const s2 = new SendableSet(); +assert.throws( + TypeError, + () => { + SendableSet.prototype.symmetricDifference.call(s1, s2); + }, + "SendableSet-like class" +); + +const s3 = { + size: 2, + has: () => {}, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + () => { + SendableSet.prototype.symmetricDifference.call(s3, s2); + }, + "SendableSet-like object" +); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/require-internal-slot.js b/test/sendable/builtins/Set/prototype/symmetricDifference/require-internal-slot.js new file mode 100644 index 00000000000..92a73e82d3a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/require-internal-slot.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference RequireInternalSlot +info: | + 2. Perform ? RequireInternalSlot(O, [[SendableSetData]]) +features: [set-methods] +---*/ + +const symmetricDifference = SendableSet.prototype.symmetricDifference; + +assert.sameValue(typeof symmetricDifference, "function"); + +const realSendableSet = new SendableSet([]); + +assert.throws(TypeError, () => symmetricDifference.call(undefined, realSendableSet), "undefined"); +assert.throws(TypeError, () => symmetricDifference.call(null, realSendableSet), "null"); +assert.throws(TypeError, () => symmetricDifference.call(true, realSendableSet), "true"); +assert.throws(TypeError, () => symmetricDifference.call("", realSendableSet), "empty string"); +assert.throws(TypeError, () => symmetricDifference.call(Symbol(), realSendableSet), "symbol"); +assert.throws(TypeError, () => symmetricDifference.call(1, realSendableSet), "1"); +assert.throws(TypeError, () => symmetricDifference.call(1n, realSendableSet), "1n"); +assert.throws(TypeError, () => symmetricDifference.call({}, realSendableSet), "plain object"); +assert.throws(TypeError, () => symmetricDifference.call([], realSendableSet), "array"); +assert.throws(TypeError, () => symmetricDifference.call(new Map(), realSendableSet), "map"); +assert.throws(TypeError, () => symmetricDifference.call(SendableSet.prototype, realSendableSet), "SendableSet.prototype"); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/result-order.js b/test/sendable/builtins/Set/prototype/symmetricDifference/result-order.js new file mode 100644 index 00000000000..fa2d55ea72e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/result-order.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference result ordering +features: [set-methods] +includes: [compareArray.js] +---*/ + +// results are ordered as in this, then as in other +{ + const s1 = new SendableSet([1, 2, 3, 4]); + const s2 = new SendableSet([6, 5, 4, 3]); + + assert.compareArray([...s1.symmetricDifference(s2)], [1, 2, 6, 5]); +} + +{ + const s1 = new SendableSet([6, 5, 4, 3]); + const s2 = new SendableSet([1, 2, 3, 4]); + + assert.compareArray([...s1.symmetricDifference(s2)], [6, 5, 1, 2]); +} diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/set-like-array.js b/test/sendable/builtins/Set/prototype/symmetricDifference/set-like-array.js new file mode 100644 index 00000000000..a7f561cfc22 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/set-like-array.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference consumes a set-like array as a set-like, not an array +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = [5]; +s2.size = 3; +s2.has = function (v) { + throw new Test262Error("SendableSet.prototype.symmetricDifference should not invoke .has on its argument"); +}; +s2.keys = function () { + return [2, 3, 4].values(); +}; + +const expected = [1, 3, 4]; +const combined = s1.symmetricDifference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/set-like-class-mutation.js b/test/sendable/builtins/Set/prototype/symmetricDifference/set-like-class-mutation.js new file mode 100644 index 00000000000..cb32a2647cd --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/set-like-class-mutation.js @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference maintains values even when a custom SendableSet-like class mutates the receiver +features: [set-methods] +includes: [compareArray.js] +---*/ + +const baseSendableSet = new SendableSet(["a", "b", "c", "d", "e"]); + +function mutatingIterator() { + let index = 0; + let values = ["x", "b", "c", "c"]; + return { + next() { + if (index === 0) { + baseSendableSet.delete("b"); + baseSendableSet.delete("c"); + baseSendableSet.add("b"); + baseSendableSet.add("d"); + } + return { + done: index >= values.length, + value: values[index++], + }; + }, + }; +} + +const evilSendableSetLike = { + size: 4, + get has() { + baseSendableSet.add("q"); + return function () { + throw new Test262Error("SendableSet.prototype.symmetricDifference should not invoke .has on its argument"); + }; + }, + keys() { + return mutatingIterator(); + }, +}; + +const combined = baseSendableSet.symmetricDifference(evilSendableSetLike); +const expectedCombined = ["a", "c", "d", "e", "q", "x"]; +assert.compareArray([...combined], expectedCombined); + +const expectedNewBase = ["a", "d", "e", "q", "b"]; +assert.compareArray([...baseSendableSet], expectedNewBase); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/set-like-class-order.js b/test/sendable/builtins/Set/prototype/symmetricDifference/set-like-class-order.js new file mode 100644 index 00000000000..170190f6037 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/set-like-class-order.js @@ -0,0 +1,179 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference calls a SendableSet-like class's methods in order +features: [set-methods] +includes: [compareArray.js] +---*/ + +let observedOrder = []; + +function observableIterator() { + let values = ["a", "b", "c"]; + let index = 0; + return { + get next() { + observedOrder.push("getting next"); + return function () { + observedOrder.push("calling next"); + return { + get done() { + observedOrder.push("getting done"); + return index >= values.length; + }, + get value() { + observedOrder.push("getting value"); + return values[index++]; + }, + }; + }; + }, + }; +} + +class MySendableSetLike { + get size() { + observedOrder.push("getting size"); + return { + valueOf: function () { + observedOrder.push("ToNumber(size)"); + return 2; + }, + }; + } + get has() { + observedOrder.push("getting has"); + return function () { + throw new Test262Error("SendableSet.prototype.symmetricDifference should not invoke .has on its argument"); + }; + } + get keys() { + observedOrder.push("getting keys"); + return function () { + observedOrder.push("calling keys"); + return observableIterator(); + }; + } +} + +// this is smaller than argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "d"]); + const s2 = new MySendableSetLike(); + const combined = s1.symmetricDifference(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + "calling keys", + "getting next", + // first iteration, has value + "calling next", + "getting done", + "getting value", + // second iteration, has value + "calling next", + "getting done", + "getting value", + // third iteration, has value + "calling next", + "getting done", + "getting value", + // fourth iteration, no value; ends + "calling next", + "getting done", + ]; + + assert.compareArray([...combined], ["d", "b", "c"]); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is same size as argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "b", "d"]); + const s2 = new MySendableSetLike(); + const combined = s1.symmetricDifference(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + "calling keys", + "getting next", + // first iteration, has value + "calling next", + "getting done", + "getting value", + // second iteration, has value + "calling next", + "getting done", + "getting value", + // third iteration, has value + "calling next", + "getting done", + "getting value", + // fourth iteration, no value; ends + "calling next", + "getting done", + ]; + + assert.compareArray([...combined], ["d", "c"]); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is larger than argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "b", "d", "e"]); + const s2 = new MySendableSetLike(); + const combined = s1.symmetricDifference(s2); + + const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + "calling keys", + "getting next", + // first iteration, has value + "calling next", + "getting done", + "getting value", + // second iteration, has value + "calling next", + "getting done", + "getting value", + // third iteration, has value + "calling next", + "getting done", + "getting value", + // fourth iteration, no value; ends + "calling next", + "getting done", + ]; + + assert.compareArray([...combined], ["d", "e", "c"]); + assert.compareArray(observedOrder, expectedOrder); +} diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/size-is-a-number.js b/test/sendable/builtins/Set/prototype/symmetricDifference/size-is-a-number.js new file mode 100644 index 00000000000..c30184f3354 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/size-is-a-number.js @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object has a size that is coerced to NaN +info: | + 2. Let rawSize be ? Get(obj, "size"). + 3. Let numSize be ? ToNumber(rawSize). + 4. NOTE: If rawSize is undefined, then numSize will be NaN. + 5. If numSize is NaN, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: undefined, + has: () => {}, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + function () { + s1.symmetricDifference(s2); + }, + "GetSendableSetRecord throws an error when size is undefined" +); + +s2.size = NaN; +assert.throws( + TypeError, + function () { + s1.symmetricDifference(s2); + }, + "GetSendableSetRecord throws an error when size is NaN" +); + +let coercionCalls = 0; +s2.size = { + valueOf: function() { + ++coercionCalls; + return NaN; + }, +}; +assert.throws( + TypeError, + function () { + s1.symmetricDifference(s2); + }, + "GetSendableSetRecord throws an error when size coerces to NaN" +); +assert.sameValue(coercionCalls, 1, "GetSendableSetRecord coerces size"); + +s2.size = 0n; +assert.throws( + TypeError, + function () { + s1.symmetricDifference(s2); + }, + "GetSendableSetRecord throws an error when size is a BigInt" +); + +s2.size = "string"; +assert.throws( + TypeError, + function () { + s1.symmetricDifference(s2); + }, + "GetSendableSetRecord throws an error when size is a non-numeric string" +); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/subclass-receiver-methods.js b/test/sendable/builtins/Set/prototype/symmetricDifference/subclass-receiver-methods.js new file mode 100644 index 00000000000..a3c5634317c --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/subclass-receiver-methods.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference works on subclasses of SendableSet, but never calls the receiver's size/has/keys methods +features: [set-methods] +includes: [compareArray.js] +---*/ + +let sizeCount = 0; +let hasCount = 0; +let keysCount = 0; + +class MySendableSet extends SendableSet { + size(...rest) { + sizeCount++; + return super.size(...rest); + } + + has(...rest) { + hasCount++; + return super.has(...rest); + } + + keys(...rest) { + keysCount++; + return super.keys(...rest); + } +} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1, 3]; +const combined = s1.symmetricDifference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue( + combined instanceof MySendableSet, + false, + "The returned object is a SendableSet, not a subclass" +); +assert.sameValue(sizeCount, 0, "size should not be called on the receiver"); +assert.sameValue(hasCount, 0, "has should not be called on the receiver"); +assert.sameValue(keysCount, 0, "keys should not be called on the receiver"); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/subclass-symbol-species.js b/test/sendable/builtins/Set/prototype/symmetricDifference/subclass-symbol-species.js new file mode 100644 index 00000000000..cccd545939b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/subclass-symbol-species.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference works on subclasses of SendableSet, but returns an instance of SendableSet even when Symbol.species is overridden. +features: [set-methods] +includes: [compareArray.js] +---*/ +var count = 0; +class MySendableSet extends SendableSet { + static get [Symbol.species]() { + count++; + return SendableSet; + } +} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1, 3]; +const combined = s1.symmetricDifference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(count, 0, "Symbol.species is never called"); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue( + combined instanceof MySendableSet, + false, + "The returned object is a SendableSet, not a subclass" +); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/subclass.js b/test/sendable/builtins/Set/prototype/symmetricDifference/subclass.js new file mode 100644 index 00000000000..b16754b727a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/subclass.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference works on subclasses of SendableSet, but returns an instance of SendableSet +features: [set-methods] +includes: [compareArray.js] +---*/ + +class MySendableSet extends SendableSet {} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1, 3]; +const combined = s1.symmetricDifference(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue( + combined instanceof MySendableSet, + false, + "The returned object is a SendableSet, not a subclass" +); diff --git a/test/sendable/builtins/Set/prototype/symmetricDifference/symmetricDifference.js b/test/sendable/builtins/Set/prototype/symmetricDifference/symmetricDifference.js new file mode 100644 index 00000000000..00df85146d2 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/symmetricDifference/symmetricDifference.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.symmetricdifference +description: SendableSet.prototype.symmetricDifference properties +includes: [propertyHelper.js] +features: [set-methods] +---*/ + +assert.sameValue( + typeof SendableSet.prototype.symmetricDifference, + "function", + "`typeof SendableSet.prototype.symmetricDifference` is `'function'`" +); + +verifyProperty(SendableSet.prototype, "symmetricDifference", { + enumerable: false, + writable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/union/add-not-called.js b/test/sendable/builtins/Set/prototype/union/add-not-called.js new file mode 100644 index 00000000000..a34fef110d7 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/add-not-called.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union should not call SendableSet.prototype.add +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1, 2, 3]; + +const originalAdd = SendableSet.prototype.add; +let count = 0; +SendableSet.prototype.add = function (...rest) { + count++; + return originalAdd.apply(this, rest); +}; + +const combined = s1.union(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue(count, 0, "Add is never called"); + +SendableSet.prototype.add = originalAdd; diff --git a/test/sendable/builtins/Set/prototype/union/allows-set-like-class.js b/test/sendable/builtins/Set/prototype/union/allows-set-like-class.js new file mode 100644 index 00000000000..e2c6cd398c0 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/allows-set-like-class.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: GetSendableSetRecord allows instances of SendableSet-like classes +info: | + 1. If obj is not an Object, throw a TypeError exception. + 2. Let rawSize be ? Get(obj, "size"). + ... + 7. Let has be ? Get(obj, "has"). + ... + 9. Let keys be ? Get(obj, "keys"). +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new class { + get size() { + return 2; + } + has() { + throw new Test262Error("SendableSet.prototype.union should not invoke .has on its argument"); + } + * keys() { + yield 2; + yield 3; + } +}; +const expected = [1, 2, 3]; +const combined = s1.union(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/union/allows-set-like-object.js b/test/sendable/builtins/Set/prototype/union/allows-set-like-object.js new file mode 100644 index 00000000000..80de6c3ec97 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/allows-set-like-object.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: GetSendableSetRecord allows SendableSet-like objects +info: | + 1. If obj is not an Object, throw a TypeError exception. + 2. Let rawSize be ? Get(obj, "size"). + ... + 7. Let has be ? Get(obj, "has"). + ... + 9. Let keys be ? Get(obj, "keys"). +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: () => { + throw new Test262Error("SendableSet.prototype.union should not invoke .has on its argument"); + }, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +const expected = [1, 2, 3]; +const combined = s1.union(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/union/appends-new-values.js b/test/sendable/builtins/Set/prototype/union/appends-new-values.js new file mode 100644 index 00000000000..c240914f29a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/appends-new-values.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union appends new values to a copy of the original SendableSet +info: | + 7.b.iii.1 Append nextValue to resultSendableSetData. +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([-1, 0, 3]); +const expected = [1, 2, -1, 0, 3]; +const combined = s1.union(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); + +const s3 = new SendableSet([1, 2, -3]); +const s4 = new SendableSet([-1, 0]); +const expected2 = [1, 2, -3, -1, 0]; +const combined2 = s3.union(s4); + +assert.compareArray([...combined2], expected2); +assert.sameValue( + combined2 instanceof SendableSet, + true, + "The returned object is a SendableSet" +); diff --git a/test/sendable/builtins/Set/prototype/union/array-throws.js b/test/sendable/builtins/Set/prototype/union/array-throws.js new file mode 100644 index 00000000000..0e55d13d24b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/array-throws.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union doesn't work with arrays +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = [3]; +assert.throws( + TypeError, + function () { + s1.union(s2); + }, + "Throws an error when an array is used" +); diff --git a/test/sendable/builtins/Set/prototype/union/builtins.js b/test/sendable/builtins/Set/prototype/union/builtins.js new file mode 100644 index 00000000000..5f75fc8d490 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/builtins.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: Tests that SendableSet.prototype.union meets the requirements for built-in objects +features: [set-methods] +---*/ + +assert.sameValue( + Object.isExtensible(SendableSet.prototype.union), + true, + "Built-in objects must be extensible." +); + +assert.sameValue( + Object.prototype.toString.call(SendableSet.prototype.union), + "[object Function]", + "Object.prototype.toString" +); + +assert.sameValue( + Object.getPrototypeOf(SendableSet.prototype.union), + Function.prototype, + "prototype" +); diff --git a/test/sendable/builtins/Set/prototype/union/called-with-object.js b/test/sendable/builtins/Set/prototype/union/called-with-object.js new file mode 100644 index 00000000000..a419b323d95 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/called-with-object.js @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws if obj is not an object +info: | + 1. If obj is not an Object, throw a TypeError exception. +features: [set-methods] +---*/ + +let s1 = new SendableSet([1]); +assert.throws( + TypeError, + function () { + s1.union(1); + }, + "number" +); + +assert.throws( + TypeError, + function () { + s1.union(""); + }, + "string" +); + +assert.throws( + TypeError, + function () { + s1.union(1n); + }, + "bigint" +); + +assert.throws( + TypeError, + function () { + s1.union(false); + }, + "boolean" +); + +assert.throws( + TypeError, + function () { + s1.union(undefined); + }, + "undefined" +); + +assert.throws( + TypeError, + function () { + s1.union(null); + }, + "null" +); + +assert.throws( + TypeError, + function () { + s1.union(Symbol("test")); + }, + "symbol" +); diff --git a/test/sendable/builtins/Set/prototype/union/combines-Map.js b/test/sendable/builtins/Set/prototype/union/combines-Map.js new file mode 100644 index 00000000000..6f421a4bdeb --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/combines-Map.js @@ -0,0 +1,32 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union combines with Map +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const m1 = new Map([ + [2, "two"], + [3, "three"], +]); +const expected = [1, 2, 3]; +const combined = s1.union(m1); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/union/combines-empty-sets.js b/test/sendable/builtins/Set/prototype/union/combines-empty-sets.js new file mode 100644 index 00000000000..ebf46bf7cc5 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/combines-empty-sets.js @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union can combine empty SendableSets +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([]); +const s2 = new SendableSet([1, 2]); +let expected = [1, 2]; +let combined = s1.union(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); + +const s3 = new SendableSet([1, 2]); +const s4 = new SendableSet([]); +expected = [1, 2]; +combined = s3.union(s4); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); + +const s5 = new SendableSet([]); +const s6 = new SendableSet([]); +expected = []; +combined = s5.union(s6); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/union/combines-itself.js b/test/sendable/builtins/Set/prototype/union/combines-itself.js new file mode 100644 index 00000000000..b59b3944e5b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/combines-itself.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union is successful when called on itself +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const expected = [1, 2]; +const combined = s1.union(s1); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue(combined === s1, false, "The returned object is a new object"); diff --git a/test/sendable/builtins/Set/prototype/union/combines-same-sets.js b/test/sendable/builtins/Set/prototype/union/combines-same-sets.js new file mode 100644 index 00000000000..665d2ea4711 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/combines-same-sets.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union can combine SendableSets that have the same content +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([1, 2]); +const expected = [1, 2]; +const combined = s1.union(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue(combined === s1, false, "The returned object is a new object"); +assert.sameValue(combined === s2, false, "The returned object is a new object"); diff --git a/test/sendable/builtins/Set/prototype/union/combines-sets.js b/test/sendable/builtins/Set/prototype/union/combines-sets.js new file mode 100644 index 00000000000..9b48eec3bd9 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/combines-sets.js @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union combines SendableSets +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1, 2, 3]; +const combined = s1.union(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/union/converts-negative-zero.js b/test/sendable/builtins/Set/prototype/union/converts-negative-zero.js new file mode 100644 index 00000000000..b4060f27b57 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/converts-negative-zero.js @@ -0,0 +1,48 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union converts -0𝔽 to +0𝔽 +info: | + 7.b.ii. If nextValue is -0𝔽, set nextValue to +0𝔽. +features: [set-methods] +includes: [compareArray.js] +---*/ + +const setlikeWithMinusZero = { + size: 1, + has: function () { + throw new Test262Error("SendableSet.prototype.union should not invoke .has on its argument"); + }, + keys: function () { + // we use an array here because the SendableSet constructor would normalize away -0 + return [-0].values(); + }, +}; + +const s1 = new SendableSet([1]); +let expected = [1, +0]; +let combined = s1.union(setlikeWithMinusZero); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); + +const s2 = new SendableSet([+0]); +expected = [+0]; +combined = s2.union(setlikeWithMinusZero); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/union/has-is-callable.js b/test/sendable/builtins/Set/prototype/union/has-is-callable.js new file mode 100644 index 00000000000..e0f871060be --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/has-is-callable.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object's 'has' property is not callable +info: | + 7. Let has be ? Get(obj, "has"). + 8. If IsCallable(has) is false, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: undefined, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + function () { + s1.union(s2); + }, + "GetSendableSetRecord throws an error when has is undefined" +); + +s2.has = {}; +assert.throws( + TypeError, + function () { + s1.union(s2); + }, + "GetSendableSetRecord throws an error when has is not callable" +); diff --git a/test/sendable/builtins/Set/prototype/union/keys-is-callable.js b/test/sendable/builtins/Set/prototype/union/keys-is-callable.js new file mode 100644 index 00000000000..834a85f12a9 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/keys-is-callable.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object's 'keys' property is not callable +info: | + 9. Let keys be ? Get(obj, "keys"). + 10. If IsCallable(keys) is false, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: 2, + has: () => {}, + keys: undefined, +}; +assert.throws( + TypeError, + function () { + s1.union(s2); + }, + "GetSendableSetRecord throws an error when keys is undefined" +); + +s2.keys = {}; +assert.throws( + TypeError, + function () { + s1.union(s2); + }, + "GetSendableSetRecord throws an error when keys is not callable" +); diff --git a/test/sendable/builtins/Set/prototype/union/length.js b/test/sendable/builtins/Set/prototype/union/length.js new file mode 100644 index 00000000000..16ad84e42f8 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union length property +info: | + SendableSet.prototype.union ( other ) +includes: [propertyHelper.js] +features: [set-methods] +---*/ +assert.sameValue(typeof SendableSet.prototype.union, "function"); + +verifyProperty(SendableSet.prototype.union, "length", { + enumerable: false, + writable: false, + configurable: true, + value: 1, +}); diff --git a/test/sendable/builtins/Set/prototype/union/name.js b/test/sendable/builtins/Set/prototype/union/name.js new file mode 100644 index 00000000000..688702085e9 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union name property +info: | + SendableSet.prototype.union ( other ) +includes: [propertyHelper.js] +features: [set-methods] +---*/ +assert.sameValue(typeof SendableSet.prototype.union, "function"); + +verifyProperty(SendableSet.prototype.union, "name", { + enumerable: false, + writable: false, + configurable: true, + value: "union", +}); diff --git a/test/sendable/builtins/Set/prototype/union/not-a-constructor.js b/test/sendable/builtins/Set/prototype/union/not-a-constructor.js new file mode 100644 index 00000000000..debfbf3b9cf --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/not-a-constructor.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union does not implement [[Construct]], is not new-able +includes: [isConstructor.js] +features: [Reflect.construct, set-methods] +---*/ + +assert.sameValue( + isConstructor(SendableSet.prototype.union), + false, + "isConstructor(SendableSet.prototype.union) must return false" +); + +assert.throws( + TypeError, + () => { + new SendableSet.prototype.union(); + }); diff --git a/test/sendable/builtins/Set/prototype/union/receiver-not-set.js b/test/sendable/builtins/Set/prototype/union/receiver-not-set.js new file mode 100644 index 00000000000..a4f194c449e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/receiver-not-set.js @@ -0,0 +1,57 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union throws when receiver is not a SendableSet +features: [set-methods] +---*/ + +class MySendableSetLike { + constructor() { + this.size = 2; + this.has = () => {}; + this.keys = function* keys() { + yield 2; + yield 3; + }; + } +} + +const s1 = new MySendableSetLike(); +const s2 = new SendableSet(); +assert.throws( + TypeError, + () => { + SendableSet.prototype.union.call(s1, s2); + }, + "SendableSet-like class" +); + +const s3 = { + size: 2, + has: () => {}, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + () => { + SendableSet.prototype.union.call(s3, s2); + }, + "SendableSet-like object" +); diff --git a/test/sendable/builtins/Set/prototype/union/require-internal-slot.js b/test/sendable/builtins/Set/prototype/union/require-internal-slot.js new file mode 100644 index 00000000000..9179ae5a1cf --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/require-internal-slot.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union RequireInternalSlot +info: | + 2. Perform ? RequireInternalSlot(O, [[SendableSetData]]) +features: [set-methods] +---*/ + +const union = SendableSet.prototype.union; + +assert.sameValue(typeof union, "function"); + +const realSendableSet = new SendableSet([]); + +assert.throws(TypeError, () => union.call(undefined, realSendableSet), "undefined"); +assert.throws(TypeError, () => union.call(null, realSendableSet), "null"); +assert.throws(TypeError, () => union.call(true, realSendableSet), "true"); +assert.throws(TypeError, () => union.call("", realSendableSet), "empty string"); +assert.throws(TypeError, () => union.call(Symbol(), realSendableSet), "symbol"); +assert.throws(TypeError, () => union.call(1, realSendableSet), "1"); +assert.throws(TypeError, () => union.call(1n, realSendableSet), "1n"); +assert.throws(TypeError, () => union.call({}, realSendableSet), "plain object"); +assert.throws(TypeError, () => union.call([], realSendableSet), "array"); +assert.throws(TypeError, () => union.call(new Map(), realSendableSet), "map"); +assert.throws(TypeError, () => union.call(SendableSet.prototype, realSendableSet), "SendableSet.prototype"); diff --git a/test/sendable/builtins/Set/prototype/union/result-order.js b/test/sendable/builtins/Set/prototype/union/result-order.js new file mode 100644 index 00000000000..2f10ca00c9e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/result-order.js @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union result ordering +features: [set-methods] +includes: [compareArray.js] +---*/ + +{ + const s1 = new SendableSet([1, 2]); + const s2 = new SendableSet([2, 3]); + + assert.compareArray([...s1.union(s2)], [1, 2, 3]); +} + +{ + const s1 = new SendableSet([2, 3]); + const s2 = new SendableSet([1, 2]); + + assert.compareArray([...s1.union(s2)], [2, 3, 1]); +} + +{ + const s1 = new SendableSet([1, 2]); + const s2 = new SendableSet([3]); + + assert.compareArray([...s1.union(s2)], [1, 2, 3]); +} + +{ + const s1 = new SendableSet([3]); + const s2 = new SendableSet([1, 2]); + + assert.compareArray([...s1.union(s2)], [3, 1, 2]); +} diff --git a/test/sendable/builtins/Set/prototype/union/set-like-array.js b/test/sendable/builtins/Set/prototype/union/set-like-array.js new file mode 100644 index 00000000000..3e46470e75a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/set-like-array.js @@ -0,0 +1,37 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union consumes a set-like array as a set-like, not an array +features: [set-methods] +includes: [compareArray.js] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = [5, 6]; +s2.size = 3; +s2.has = function () { + throw new Test262Error("SendableSet.prototype.union should not invoke .has on its argument"); +}; +s2.keys = function () { + return [2, 3, 4].values(); +}; + +const expected = [1, 2, 3, 4]; +const combined = s1.union(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); diff --git a/test/sendable/builtins/Set/prototype/union/set-like-class-mutation.js b/test/sendable/builtins/Set/prototype/union/set-like-class-mutation.js new file mode 100644 index 00000000000..6b00e5395a6 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/set-like-class-mutation.js @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union maintains values even when a custom SendableSet-like class mutates the receiver +features: [set-methods] +includes: [compareArray.js] +---*/ + +const baseSendableSet = new SendableSet(["a", "b", "c", "d", "e"]); + +function mutatingIterator() { + let index = 0; + let values = ["x", "y"]; + return { + next() { + baseSendableSet.delete("b"); + baseSendableSet.delete("c"); + baseSendableSet.add("b"); + baseSendableSet.add("d"); + return { + done: index >= 2, + value: values[index++], + }; + }, + }; +} + +const evilSendableSetLike = { + size: 2, + get has() { + baseSendableSet.add("q"); + return function () { + throw new Test262Error("SendableSet.prototype.union should not invoke .has on its argument"); + }; + }, + keys() { + return mutatingIterator(); + }, +}; + +const combined = baseSendableSet.union(evilSendableSetLike); +const expectedCombined = ["a", "b", "c", "d", "e", "q", "x", "y"]; +assert.compareArray([...combined], expectedCombined); + +const expectedNewBase = ["a", "d", "e", "q", "b"]; +assert.compareArray([...baseSendableSet], expectedNewBase); diff --git a/test/sendable/builtins/Set/prototype/union/set-like-class-order.js b/test/sendable/builtins/Set/prototype/union/set-like-class-order.js new file mode 100644 index 00000000000..a8ae6086902 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/set-like-class-order.js @@ -0,0 +1,131 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union calls a SendableSet-like class's methods in order +features: [set-methods] +includes: [compareArray.js] +---*/ + +let observedOrder = []; + +function observableIterator() { + let values = ["a", "b", "c"]; + let index = 0; + return { + get next() { + observedOrder.push("getting next"); + return function () { + observedOrder.push("calling next"); + return { + get done() { + observedOrder.push("getting done"); + return index >= values.length; + }, + get value() { + observedOrder.push("getting value"); + return values[index++]; + }, + }; + }; + }, + }; +} + +class MySendableSetLike { + get size() { + observedOrder.push("getting size"); + return { + valueOf: function () { + observedOrder.push("ToNumber(size)"); + return 2; + }, + }; + } + get has() { + observedOrder.push("getting has"); + return function () { + throw new Test262Error("SendableSet.prototype.union should not invoke .has on its argument"); + }; + } + get keys() { + observedOrder.push("getting keys"); + return function () { + observedOrder.push("calling keys"); + return observableIterator(); + }; + } +} + +const expectedOrder = [ + "getting size", + "ToNumber(size)", + "getting has", + "getting keys", + "calling keys", + "getting next", + // first iteration, has value + "calling next", + "getting done", + "getting value", + // second iteration, has value + "calling next", + "getting done", + "getting value", + // third iteration, has value + "calling next", + "getting done", + "getting value", + // fourth iteration, no value; ends + "calling next", + "getting done", +]; + +// this is smaller than argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "d"]); + const s2 = new MySendableSetLike(); + const combined = s1.union(s2); + + assert.compareArray([...combined], ["a", "d", "b", "c"]); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is same size as argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "b", "d"]); + const s2 = new MySendableSetLike(); + const combined = s1.union(s2); + + assert.compareArray([...combined], ["a", "b", "d", "c"]); + assert.compareArray(observedOrder, expectedOrder); +} + +// this is larger than argument +{ + observedOrder = []; + + const s1 = new SendableSet(["a", "b", "d", "e"]); + const s2 = new MySendableSetLike(); + const combined = s1.union(s2); + + assert.compareArray([...combined], ["a", "b", "d", "e", "c"]); + assert.compareArray(observedOrder, expectedOrder); +} diff --git a/test/sendable/builtins/Set/prototype/union/size-is-a-number.js b/test/sendable/builtins/Set/prototype/union/size-is-a-number.js new file mode 100644 index 00000000000..78c6ffeb56d --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/size-is-a-number.js @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-getsetrecord +description: GetSendableSetRecord throws an exception if the SendableSet-like object has a size that is coerced to NaN +info: | + 2. Let rawSize be ? Get(obj, "size"). + 3. Let numSize be ? ToNumber(rawSize). + 4. NOTE: If rawSize is undefined, then numSize will be NaN. + 5. If numSize is NaN, throw a TypeError exception. +features: [set-methods] +---*/ + +const s1 = new SendableSet([1, 2]); +const s2 = { + size: undefined, + has: () => {}, + keys: function* keys() { + yield 2; + yield 3; + }, +}; +assert.throws( + TypeError, + function () { + s1.union(s2); + }, + "GetSendableSetRecord throws an error when size is undefined" +); + +s2.size = NaN; +assert.throws( + TypeError, + function () { + s1.union(s2); + }, + "GetSendableSetRecord throws an error when size is NaN" +); + +let coercionCalls = 0; +s2.size = { + valueOf: function() { + ++coercionCalls; + return NaN; + }, +}; +assert.throws( + TypeError, + function () { + s1.union(s2); + }, + "GetSendableSetRecord throws an error when size coerces to NaN" +); +assert.sameValue(coercionCalls, 1, "GetSendableSetRecord coerces size"); + +s2.size = 0n; +assert.throws( + TypeError, + function () { + s1.union(s2); + }, + "GetSendableSetRecord throws an error when size is a BigInt" +); + +s2.size = "string"; +assert.throws( + TypeError, + function () { + s1.union(s2); + }, + "GetSendableSetRecord throws an error when size is a non-numeric string" +); diff --git a/test/sendable/builtins/Set/prototype/union/subclass-receiver-methods.js b/test/sendable/builtins/Set/prototype/union/subclass-receiver-methods.js new file mode 100644 index 00000000000..ea853bade16 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/subclass-receiver-methods.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union works on subclasses of SendableSet, but never calls the receiver's size/has/keys methods +features: [set-methods] +includes: [compareArray.js] +---*/ + +let sizeCount = 0; +let hasCount = 0; +let keysCount = 0; + +class MySendableSet extends SendableSet { + size(...rest) { + sizeCount++; + return super.size(...rest); + } + + has(...rest) { + hasCount++; + return super.has(...rest); + } + + keys(...rest) { + keysCount++; + return super.keys(...rest); + } +} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1, 2, 3]; +const combined = s1.union(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue( + combined instanceof MySendableSet, + false, + "The returned object is a SendableSet, not a subclass" +); +assert.sameValue(sizeCount, 0, "size should not be called on the receiver"); +assert.sameValue(hasCount, 0, "has should not be called on the receiver"); +assert.sameValue(keysCount, 0, "keys should not be called on the receiver"); diff --git a/test/sendable/builtins/Set/prototype/union/subclass-symbol-species.js b/test/sendable/builtins/Set/prototype/union/subclass-symbol-species.js new file mode 100644 index 00000000000..f3ffc4f72b5 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/subclass-symbol-species.js @@ -0,0 +1,42 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union works on subclasses of SendableSet, but returns an instance of SendableSet even when Symbol.species is overridden. +features: [set-methods] +includes: [compareArray.js] +---*/ +var count = 0; +class MySendableSet extends SendableSet { + static get [Symbol.species]() { + count++; + return SendableSet; + } +} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1, 2, 3]; +const combined = s1.union(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(count, 0, "Symbol.species is never called"); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue( + combined instanceof MySendableSet, + false, + "The returned object is a SendableSet, not a subclass" +); diff --git a/test/sendable/builtins/Set/prototype/union/subclass.js b/test/sendable/builtins/Set/prototype/union/subclass.js new file mode 100644 index 00000000000..6ec7f440586 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/subclass.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union works on subclasses of SendableSet, but returns an instance of SendableSet +features: [set-methods] +includes: [compareArray.js] +---*/ + +class MySendableSet extends SendableSet {} + +const s1 = new MySendableSet([1, 2]); +const s2 = new SendableSet([2, 3]); +const expected = [1, 2, 3]; +const combined = s1.union(s2); + +assert.compareArray([...combined], expected); +assert.sameValue(combined instanceof SendableSet, true, "The returned object is a SendableSet"); +assert.sameValue( + combined instanceof MySendableSet, + false, + "The returned object is a SendableSet, not a subclass" +); diff --git a/test/sendable/builtins/Set/prototype/union/union.js b/test/sendable/builtins/Set/prototype/union/union.js new file mode 100644 index 00000000000..7fb114c99a4 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/union/union.js @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.union +description: SendableSet.prototype.union properties +includes: [propertyHelper.js] +features: [set-methods] +---*/ + +assert.sameValue( + typeof SendableSet.prototype.union, + "function", + "`typeof SendableSet.prototype.union` is `'function'`" +); + +verifyProperty(SendableSet.prototype, "union", { + enumerable: false, + writable: true, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-array.js b/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-array.js new file mode 100644 index 00000000000..006d5b665bc --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-array.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + SendableSet.prototype.values ( ) + + ... + 2. Return CreateSendableSetIterator(S, "value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + ... + 2. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.values.call([]); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.values.call([]); +}); diff --git a/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-map.js b/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-map.js new file mode 100644 index 00000000000..a67b0068a21 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-map.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + SendableSet.prototype.values ( ) + + ... + 2. Return CreateSendableSetIterator(S, "value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + ... + 2. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.values.call(new Map()); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.values.call(new Map()); +}); diff --git a/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-object.js b/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-object.js new file mode 100644 index 00000000000..4749467bdaa --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-object.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + SendableSet.prototype.values ( ) + + ... + 2. Return CreateSendableSetIterator(S, "value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + ... + 2. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.values.call({}); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.values.call({}); +}); diff --git a/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-set-prototype.js b/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-set-prototype.js new file mode 100644 index 00000000000..9f86e8b3af2 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-set-prototype.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + SendableSet.prototype.values ( ) + + ... + 2. Return CreateSendableSetIterator(S, "value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + ... + 2. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.values.call(SendableSet.prototype); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.values.call(SendableSet.prototype); +}); diff --git a/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-weakset.js b/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-weakset.js new file mode 100644 index 00000000000..ed00c00983e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/does-not-have-setdata-internal-slot-weakset.js @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + SendableSet.prototype.values ( ) + + ... + 2. Return CreateSendableSetIterator(S, "value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + ... + 2. If S does not have a [[SendableSetData]] internal slot, throw a TypeError exception. + ... +features: [WeakSet] +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.values.call(new WeakSet()); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.values.call(new WeakSet()); +}); diff --git a/test/sendable/builtins/Set/prototype/values/length.js b/test/sendable/builtins/Set/prototype/values/length.js new file mode 100644 index 00000000000..fc0ebbd3885 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/length.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + SendableSet.prototype.values ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype.values, "length", { + value: 0, + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/values/name.js b/test/sendable/builtins/Set/prototype/values/name.js new file mode 100644 index 00000000000..2d1a6dc6522 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/name.js @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + SendableSet.prototype.values ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(SendableSet.prototype.values, "name", { + value: "values", + writable: false, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/prototype/values/not-a-constructor.js b/test/sendable/builtins/Set/prototype/values/not-a-constructor.js new file mode 100644 index 00000000000..e59149a44de --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/not-a-constructor.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + SendableSet.prototype.values 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, SendableSet, arrow-function] +---*/ + +assert.sameValue(isConstructor(SendableSet.prototype.values), false, 'isConstructor(SendableSet.prototype.values) must return false'); + +assert.throws(TypeError, () => { + let s = new SendableSet([]); new s.values(); +}); + diff --git a/test/sendable/builtins/Set/prototype/values/returns-iterator-empty.js b/test/sendable/builtins/Set/prototype/values/returns-iterator-empty.js new file mode 100644 index 00000000000..0128c08fa3e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/returns-iterator-empty.js @@ -0,0 +1,26 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + Returns an iterator that's already done if SendableSet is empty. +---*/ + +var set = new SendableSet(); +var iterator = set.values(); +var result = iterator.next(); +assert.sameValue(result.value, undefined, "The value of `result.value` is `undefined`"); +assert.sameValue(result.done, true, "The value of `result.done` is `true`"); diff --git a/test/sendable/builtins/Set/prototype/values/returns-iterator.js b/test/sendable/builtins/Set/prototype/values/returns-iterator.js new file mode 100644 index 00000000000..38d8b5d2d1e --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/returns-iterator.js @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + The method should return a valid iterator with the context as the + IteratedObject. +---*/ + +var set = new SendableSet(); +set.add(1); +set.add(2); +set.add(3); + +var iterator = set.values(); +var result; + +result = iterator.next(); +assert.sameValue(result.value, 1, 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 2, 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 3, 'Third result `value`'); +assert.sameValue(result.done, false, 'Third result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); + +result = iterator.next(); +assert.sameValue( + result.value, undefined, 'Exhausted result `value` (repeated request)' +); +assert.sameValue( + result.done, true, 'Exhausted result `done` flag (repeated request)' +); diff --git a/test/sendable/builtins/Set/prototype/values/this-not-object-throw-boolean.js b/test/sendable/builtins/Set/prototype/values/this-not-object-throw-boolean.js new file mode 100644 index 00000000000..61a2d60da9c --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/this-not-object-throw-boolean.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + SendableSet.prototype.values ( ) + + ... + 2. Return CreateSendableSetIterator(S, "value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.values.call(false); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.values.call(false); +}); diff --git a/test/sendable/builtins/Set/prototype/values/this-not-object-throw-null.js b/test/sendable/builtins/Set/prototype/values/this-not-object-throw-null.js new file mode 100644 index 00000000000..986be99fe2b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/this-not-object-throw-null.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + SendableSet.prototype.values ( ) + + ... + 2. Return CreateSendableSetIterator(S, "value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.values.call(null); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.values.call(null); +}); diff --git a/test/sendable/builtins/Set/prototype/values/this-not-object-throw-number.js b/test/sendable/builtins/Set/prototype/values/this-not-object-throw-number.js new file mode 100644 index 00000000000..304c454ab19 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/this-not-object-throw-number.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + SendableSet.prototype.values ( ) + + ... + 2. Return CreateSendableSetIterator(S, "value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.values.call(0); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.values.call(0); +}); diff --git a/test/sendable/builtins/Set/prototype/values/this-not-object-throw-string.js b/test/sendable/builtins/Set/prototype/values/this-not-object-throw-string.js new file mode 100644 index 00000000000..a105abd1e38 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/this-not-object-throw-string.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + SendableSet.prototype.values ( ) + + ... + 2. Return CreateSendableSetIterator(S, "value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.values.call(""); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.values.call(""); +}); diff --git a/test/sendable/builtins/Set/prototype/values/this-not-object-throw-symbol.js b/test/sendable/builtins/Set/prototype/values/this-not-object-throw-symbol.js new file mode 100644 index 00000000000..0a14a5cc194 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/this-not-object-throw-symbol.js @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + SendableSet.prototype.values ( ) + + ... + 2. Return CreateSendableSetIterator(S, "value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.values.call(Symbol()); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.values.call(Symbol()); +}); diff --git a/test/sendable/builtins/Set/prototype/values/this-not-object-throw-undefined.js b/test/sendable/builtins/Set/prototype/values/this-not-object-throw-undefined.js new file mode 100644 index 00000000000..dea7182780a --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/this-not-object-throw-undefined.js @@ -0,0 +1,38 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + SendableSet.prototype.values ( ) + + ... + 2. Return CreateSendableSetIterator(S, "value"). + + + 23.2.5.1 CreateSendableSetIterator Abstract Operation + + 1. If Type(set) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, function() { + SendableSet.prototype.values.call(undefined); +}); + +assert.throws(TypeError, function() { + var s = new SendableSet(); + s.values.call(undefined); +}); diff --git a/test/sendable/builtins/Set/prototype/values/values-iteration-mutable.js b/test/sendable/builtins/Set/prototype/values/values-iteration-mutable.js new file mode 100644 index 00000000000..1e737efb8b1 --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/values-iteration-mutable.js @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + When an item is added to the set after the iterator is created but before + the iterator is "done" (as defined by 23.2.5.2.1), the new item should be + accessible via iteration. When an item is added to the set after the + iterator is "done", the new item should not be accessible via iteration. +---*/ + +var set = new SendableSet(); +set.add(1); +set.add(2); + +var iterator = set.values(); +var result; + +result = iterator.next(); +assert.sameValue(result.value, 1, 'First result `value`'); +assert.sameValue(result.done, false, 'First result `done` flag'); + +set.add(3); + +result = iterator.next(); +assert.sameValue(result.value, 2, 'Second result `value`'); +assert.sameValue(result.done, false, 'Second result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, 3, 'Third result `value`'); +assert.sameValue(result.done, false, 'Third result `done` flag'); + +result = iterator.next(); +assert.sameValue(result.value, undefined, 'Exhausted result `value`'); +assert.sameValue(result.done, true, 'Exhausted result `done` flag'); + +set.add(4); + +result = iterator.next(); +assert.sameValue( + result.value, undefined, 'Exhausted result `value` (repeated request)' +); +assert.sameValue( + result.done, true, 'Exhausted result `done` flag (repeated request)' +); diff --git a/test/sendable/builtins/Set/prototype/values/values.js b/test/sendable/builtins/Set/prototype/values/values.js new file mode 100644 index 00000000000..a0dd25d801b --- /dev/null +++ b/test/sendable/builtins/Set/prototype/values/values.js @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.values +description: > + SendableSet.prototype.values ( ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +assert.sameValue( + typeof SendableSet.prototype.values, + "function", + "`typeof SendableSet.prototype.values` is `'function'`" +); + +verifyProperty(SendableSet.prototype, "values", { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/sendable/builtins/Set/set-does-not-throw-when-add-is-not-callable.js b/test/sendable/builtins/Set/set-does-not-throw-when-add-is-not-callable.js new file mode 100644 index 00000000000..f5a6145f729 --- /dev/null +++ b/test/sendable/builtins/Set/set-does-not-throw-when-add-is-not-callable.js @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + SendableSet ( [ iterable ] ) + + When the SendableSet function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + +SendableSet.prototype.add = null; + +var s = new SendableSet(); + +assert.sameValue(s.size, 0, "The value of `s.size` is `0`"); diff --git a/test/sendable/builtins/Set/set-get-add-method-failure.js b/test/sendable/builtins/Set/set-get-add-method-failure.js new file mode 100644 index 00000000000..8b6497faf4c --- /dev/null +++ b/test/sendable/builtins/Set/set-get-add-method-failure.js @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + SendableSet ( [ iterable ] ) + + When the SendableSet function is called with optional argument iterable the following steps are taken: + + ... + 6. If iterable is either undefined or null, let iter be undefined. + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). +---*/ + +function MyError() {} +Object.defineProperty(SendableSet.prototype, 'add', { + get: function() { + throw new MyError(); + } +}); + +new SendableSet(); + +assert.throws(MyError, function() { + new SendableSet([]); +}); diff --git a/test/sendable/builtins/Set/set-iterable-calls-add.js b/test/sendable/builtins/Set/set-iterable-calls-add.js new file mode 100644 index 00000000000..56d21e4c490 --- /dev/null +++ b/test/sendable/builtins/Set/set-iterable-calls-add.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + SendableSet ( [ iterable ] ) + + When the SendableSet function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + +var setAdd = SendableSet.prototype.add; +var counter = 0; + +SendableSet.prototype.add = function(value) { + counter++; + setAdd.call(this, value); +}; + +var s = new SendableSet([1, 2]); + +assert.sameValue(counter, 2, "`SendableSet.prototype.add` called twice."); diff --git a/test/sendable/builtins/Set/set-iterable-empty-does-not-call-add.js b/test/sendable/builtins/Set/set-iterable-empty-does-not-call-add.js new file mode 100644 index 00000000000..0dd5edd27d1 --- /dev/null +++ b/test/sendable/builtins/Set/set-iterable-empty-does-not-call-add.js @@ -0,0 +1,52 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + SendableSet ( [ iterable ] ) + + When the SendableSet function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + +var setAdd = SendableSet.prototype.add; +var counter = 0; + +SendableSet.prototype.add = function(value) { + counter++; + setAdd.call(this, value); +}; + +var s = new SendableSet([]); + +assert.sameValue(counter, 0, "`SendableSet.prototype.add` was not called."); diff --git a/test/sendable/builtins/Set/set-iterable-throws-when-add-is-not-callable.js b/test/sendable/builtins/Set/set-iterable-throws-when-add-is-not-callable.js new file mode 100644 index 00000000000..f5f72cbbd1e --- /dev/null +++ b/test/sendable/builtins/Set/set-iterable-throws-when-add-is-not-callable.js @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + SendableSet ( [ iterable ] ) + + When the SendableSet function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + + +SendableSet.prototype.add = null; + +assert.throws(TypeError, function() { + new SendableSet([1, 2]); +}); diff --git a/test/sendable/builtins/Set/set-iterable.js b/test/sendable/builtins/Set/set-iterable.js new file mode 100644 index 00000000000..30ede9ad627 --- /dev/null +++ b/test/sendable/builtins/Set/set-iterable.js @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + SendableSet ( [ iterable ] ) + + When the SendableSet function is called with optional argument iterable the following steps are taken: + + ... + 7. Else, + a. Let adder be Get(set, "add"). + b. ReturnIfAbrupt(adder). + c. If IsCallable(adder) is false, throw a TypeError exception. + d. Let iter be GetIterator(iterable). + e. ReturnIfAbrupt(iter). + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +---*/ + +var s = new SendableSet([1, 2]); + +assert.sameValue(s.size, 2, "The value of `s.size` is `2`"); diff --git a/test/sendable/builtins/Set/set-iterator-close-after-add-failure.js b/test/sendable/builtins/Set/set-iterator-close-after-add-failure.js new file mode 100644 index 00000000000..d43968ea5f9 --- /dev/null +++ b/test/sendable/builtins/Set/set-iterator-close-after-add-failure.js @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + SendableSet ( [ iterable ] ) + + When the SendableSet function is called with optional argument iterable the following steps are taken: + + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). + c. If next is false, return set. + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). + f. Let status be Call(adder, set, «nextValue.[[value]]»). + g. If status is an abrupt completion, return IteratorClose(iter, status). + +features: [Symbol.iterator] +---*/ + +var count = 0; +var iterable = {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + return { + value: null, + done: false + }; + }, + return: function() { + count += 1; + } + }; +}; +SendableSet.prototype.add = function() { + throw new Error(); +} + +assert.throws(Error, function() { + new SendableSet(iterable); +}); + +assert.sameValue( + count, 1, "The iterator is closed when `SendableSet.prototype.add` throws an error." +); diff --git a/test/sendable/builtins/Set/set-iterator-next-failure.js b/test/sendable/builtins/Set/set-iterator-next-failure.js new file mode 100644 index 00000000000..eb3c3f3034d --- /dev/null +++ b/test/sendable/builtins/Set/set-iterator-next-failure.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + SendableSet ( [ iterable ] ) + + When the SendableSet function is called with optional argument iterable the following steps are taken: + + ... + 9. Repeat + a. Let next be IteratorStep(iter). + b. ReturnIfAbrupt(next). +features: [Symbol.iterator] +---*/ + +var iterable = {}; + +function MyError() {}; +iterable[Symbol.iterator] = function() { + return { + next: function() { + throw new MyError(); + } + }; +}; + +assert.throws(MyError, function() { + new SendableSet(iterable); +}); diff --git a/test/sendable/builtins/Set/set-iterator-value-failure.js b/test/sendable/builtins/Set/set-iterator-value-failure.js new file mode 100644 index 00000000000..562459f552b --- /dev/null +++ b/test/sendable/builtins/Set/set-iterator-value-failure.js @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + SendableSet ( [ iterable ] ) + + When the SendableSet function is called with optional argument iterable the following steps are taken: + + ... + 9. Repeat + ... + d. Let nextValue be IteratorValue(next). + e. ReturnIfAbrupt(nextValue). +features: [Symbol.iterator] +---*/ + +var count = 0; +var iterable = {}; + +function MyError() {} +iterable[Symbol.iterator] = function() { + return { + next: function() { + return { + get value() { + throw new MyError(); + }, + done: false + }; + } + }; +}; + +assert.throws(MyError, function() { + new SendableSet(iterable); +}); diff --git a/test/sendable/builtins/Set/set-newtarget.js b/test/sendable/builtins/Set/set-newtarget.js new file mode 100644 index 00000000000..9cfcfeb9b3f --- /dev/null +++ b/test/sendable/builtins/Set/set-newtarget.js @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + SendableSet ( [ iterable ] ) + + When the SendableSet function is called with optional argument iterable the following steps are taken: + + ... + 2. Let set be OrdinaryCreateFromConstructor(NewTarget, "%SendableSetPrototype%", «‍[[SendableSetData]]» ). + ... + +---*/ + +var s1 = new SendableSet(); + +assert.sameValue( + Object.getPrototypeOf(s1), + SendableSet.prototype, + "`Object.getPrototypeOf(s1)` returns `SendableSet.prototype`" +); + +var s2 = new SendableSet([1, 2]); + +assert.sameValue( + Object.getPrototypeOf(s2), + SendableSet.prototype, + "`Object.getPrototypeOf(s2)` returns `SendableSet.prototype`" +); diff --git a/test/sendable/builtins/Set/set-no-iterable.js b/test/sendable/builtins/Set/set-no-iterable.js new file mode 100644 index 00000000000..91cd4e3a599 --- /dev/null +++ b/test/sendable/builtins/Set/set-no-iterable.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + SendableSet ( [ iterable ] ) + + When the SendableSet function is called with optional argument iterable the following steps are taken: + + ... + 5. If iterable is not present, let iterable be undefined. + 6. If iterable is either undefined or null, let iter be undefined. + ... + 8. If iter is undefined, return set. + +---*/ + + +assert.sameValue(new SendableSet().size, 0, "The value of `new SendableSet().size` is `0`"); +assert.sameValue(new SendableSet(undefined).size, 0, "The value of `new SendableSet(undefined).size` is `0`"); +assert.sameValue(new SendableSet(null).size, 0, "The value of `new SendableSet(null).size` is `0`"); diff --git a/test/sendable/builtins/Set/set-undefined-newtarget.js b/test/sendable/builtins/Set/set-undefined-newtarget.js new file mode 100644 index 00000000000..010c56fd475 --- /dev/null +++ b/test/sendable/builtins/Set/set-undefined-newtarget.js @@ -0,0 +1,34 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + SendableSet ( [ iterable ] ) + + When the SendableSet function is called with optional argument iterable the following steps are taken: + + 1. If NewTarget is undefined, throw a TypeError exception. + ... + +---*/ + +assert.throws(TypeError, function() { + SendableSet(); +}); + +assert.throws(TypeError, function() { + SendableSet([]); +}); diff --git a/test/sendable/builtins/Set/set.js b/test/sendable/builtins/Set/set.js new file mode 100644 index 00000000000..02133513692 --- /dev/null +++ b/test/sendable/builtins/Set/set.js @@ -0,0 +1,30 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set-constructor +description: > + SendableSet ( [ iterable ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +---*/ + +verifyProperty(this, "SendableSet", { + writable: true, + enumerable: false, + configurable: true +}); diff --git a/test/sendable/builtins/Set/valid-values.js b/test/sendable/builtins/Set/valid-values.js new file mode 100644 index 00000000000..af9fc60462e --- /dev/null +++ b/test/sendable/builtins/Set/valid-values.js @@ -0,0 +1,400 @@ +/* +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/*--- +esid: sec-set.prototype.add +description: Observing the expected behavior of valid values +info: | + SendableSet.prototype.add ( value ) + + ... + For each element e of entries, do + If e is not empty and SameValueZero(e, value) is true, then + Return S. + If value is -0, set value to +0. + Append value as the last element of entries. + ... + +features: [BigInt, Symbol, TypedArray, WeakRef, exponentiation] +---*/ + + +const negativeZero = -0; +const positiveZero = +0; +const zero = 0; +const one = 1; +const twoRaisedToFiftyThreeMinusOne = 2 ** 53 - 1; +const int32Array = new Int32Array([zero, one]); +const uint32Array = new Uint32Array([zero, one]); +const n = 100000000000000000000000000000000000000000000000000000000000000000000000000000000001n; +const bigInt = BigInt('100000000000000000000000000000000000000000000000000000000000000000000000000000000001'); +const n1 = 1n; +const n53 = 9007199254740991n; +const fiftyThree = BigInt('9007199254740991'); +const bigInt64Array = new BigInt64Array([n1, n53]); +const bigUint64Array = new BigUint64Array([n1, n53]); +const symbol = Symbol(''); +const object = {}; +const array = []; +const string = ''; +const booleanTrue = true; +const booleanFalse = true; +const functionExprValue = function() {}; +const arrowFunctionValue = () => {}; +const classValue = class {}; +const map = new Map(); +const set = new SendableSet(); +const weakMap = new WeakMap(); +const weakRef = new WeakRef({}); +const weakSet = new WeakSet(); +const nullValue = null; +const undefinedValue = undefined; +let unassigned; + +{ + const s = new SendableSet([negativeZero, negativeZero]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(negativeZero), true); + s.delete(negativeZero); + assert.sameValue(s.size, 0); + s.add(negativeZero); + assert.sameValue(s.has(negativeZero), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([positiveZero, positiveZero]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(positiveZero), true); + s.delete(positiveZero); + assert.sameValue(s.size, 0); + s.add(positiveZero); + assert.sameValue(s.has(positiveZero), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([zero, zero]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(zero), true); + s.delete(zero); + assert.sameValue(s.size, 0); + s.add(zero); + assert.sameValue(s.has(zero), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([one, one]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(one), true); + s.delete(one); + assert.sameValue(s.size, 0); + s.add(one); + assert.sameValue(s.has(one), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([twoRaisedToFiftyThreeMinusOne, twoRaisedToFiftyThreeMinusOne]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(twoRaisedToFiftyThreeMinusOne), true); + s.delete(twoRaisedToFiftyThreeMinusOne); + assert.sameValue(s.size, 0); + s.add(twoRaisedToFiftyThreeMinusOne); assert.sameValue(s.has(twoRaisedToFiftyThreeMinusOne), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([int32Array, int32Array]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(int32Array), true); + s.delete(int32Array); + assert.sameValue(s.size, 0); + s.add(int32Array); + assert.sameValue(s.has(int32Array), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([uint32Array, uint32Array]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(uint32Array), true); + s.delete(uint32Array); + assert.sameValue(s.size, 0); + s.add(uint32Array); + assert.sameValue(s.has(uint32Array), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([n, n]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(n), true); + s.delete(n); + assert.sameValue(s.size, 0); + s.add(n); + assert.sameValue(s.has(n), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([bigInt, bigInt]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(bigInt), true); + s.delete(bigInt); + assert.sameValue(s.size, 0); + s.add(bigInt); + assert.sameValue(s.has(bigInt), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([n1, n1]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(n1), true); + s.delete(n1); + assert.sameValue(s.size, 0); + s.add(n1); + assert.sameValue(s.has(n1), true); +} +{ const s = new SendableSet([n53, n53]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(n53), true); + s.delete(n53); + assert.sameValue(s.size, 0); + s.add(n53); + assert.sameValue(s.has(n53), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([fiftyThree, fiftyThree]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(fiftyThree), true); + s.delete(fiftyThree); + assert.sameValue(s.size, 0); + s.add(fiftyThree); + assert.sameValue(s.has(fiftyThree), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([bigInt64Array, bigInt64Array]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(bigInt64Array), true); + s.delete(bigInt64Array); + assert.sameValue(s.size, 0); + s.add(bigInt64Array); + assert.sameValue(s.has(bigInt64Array), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([bigUint64Array, bigUint64Array]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(bigUint64Array), true); + s.delete(bigUint64Array); + assert.sameValue(s.size, 0); + s.add(bigUint64Array); + assert.sameValue(s.has(bigUint64Array), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([symbol, symbol]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(symbol), true); + s.delete(symbol); + assert.sameValue(s.size, 0); + s.add(symbol); + assert.sameValue(s.has(symbol), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([object, object]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(object), true); + s.delete(object); + assert.sameValue(s.size, 0); + s.add(object); + assert.sameValue(s.has(object), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([array, array]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(array), true); + s.delete(array); + assert.sameValue(s.size, 0); + s.add(array); + assert.sameValue(s.has(array), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([string, string]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(string), true); + s.delete(string); + assert.sameValue(s.size, 0); + s.add(string); + assert.sameValue(s.has(string), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([booleanTrue, booleanTrue]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(booleanTrue), true); + s.delete(booleanTrue); + assert.sameValue(s.size, 0); + s.add(booleanTrue); + assert.sameValue(s.has(booleanTrue), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([booleanFalse, booleanFalse]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(booleanFalse), true); + s.delete(booleanFalse); + assert.sameValue(s.size, 0); + s.add(booleanFalse); + assert.sameValue(s.has(booleanFalse), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([functionExprValue, functionExprValue]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(functionExprValue), true); + s.delete(functionExprValue); + assert.sameValue(s.size, 0); + s.add(functionExprValue); assert.sameValue(s.has(functionExprValue), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([arrowFunctionValue, arrowFunctionValue]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(arrowFunctionValue), true); + s.delete(arrowFunctionValue); + assert.sameValue(s.size, 0); + s.add(arrowFunctionValue); assert.sameValue(s.has(arrowFunctionValue), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([classValue, classValue]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(classValue), true); + s.delete(classValue); + assert.sameValue(s.size, 0); + s.add(classValue); + assert.sameValue(s.has(classValue), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([map, map]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(map), true); + s.delete(map); + assert.sameValue(s.size, 0); + s.add(map); + assert.sameValue(s.has(map), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([set, set]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(set), true); + s.delete(set); + assert.sameValue(s.size, 0); + s.add(set); + assert.sameValue(s.has(set), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([weakMap, weakMap]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(weakMap), true); + s.delete(weakMap); + assert.sameValue(s.size, 0); + s.add(weakMap); + assert.sameValue(s.has(weakMap), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([weakRef, weakRef]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(weakRef), true); + s.delete(weakRef); + assert.sameValue(s.size, 0); + s.add(weakRef); + assert.sameValue(s.has(weakRef), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([weakSet, weakSet]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(weakSet), true); + s.delete(weakSet); + assert.sameValue(s.size, 0); + s.add(weakSet); + assert.sameValue(s.has(weakSet), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([nullValue, nullValue]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(nullValue), true); + s.delete(nullValue); + assert.sameValue(s.size, 0); + s.add(nullValue); + assert.sameValue(s.has(nullValue), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([undefinedValue, undefinedValue]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(undefinedValue), true); + s.delete(undefinedValue); + assert.sameValue(s.size, 0); + s.add(undefinedValue); + assert.sameValue(s.has(undefinedValue), true); + assert.sameValue(s.size, 1); +}; + +{ + const s = new SendableSet([unassigned, unassigned]); + assert.sameValue(s.size, 1); + assert.sameValue(s.has(unassigned), true); + s.delete(unassigned); + assert.sameValue(s.size, 0); + s.add(unassigned); + assert.sameValue(s.has(unassigned), true); + assert.sameValue(s.size, 1); +}; + -- Gitee From 6a16351e854d31d5288785ee0f90a3b4ce468369 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 15 Jan 2025 11:17:24 +0800 Subject: [PATCH 76/93] update case Signed-off-by: zhuzhihui7 --- test/sendable/builtins/Array/fromAsync/builtin.js | 6 +++--- test/sendable/builtins/Array/fromAsync/not-a-constructor.js | 2 +- .../Array/fromAsync/returned-promise-resolves-to-array.js | 2 +- .../builtins/Array/fromAsync/this-non-constructor.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/sendable/builtins/Array/fromAsync/builtin.js b/test/sendable/builtins/Array/fromAsync/builtin.js index b26b5cd2b66..682f928e9c6 100644 --- a/test/sendable/builtins/Array/fromAsync/builtin.js +++ b/test/sendable/builtins/Array/fromAsync/builtin.js @@ -32,12 +32,12 @@ features: [SendableArray.fromAsync] assert(Object.isExtensible(SendableArray.fromAsync), "Array.fromAsync is extensible"); assert.sameValue( - Object.getPrototypeOf(ArrSendableArrayay.fromAsync), + Object.getPrototypeOf(SendableArray.fromAsync), Function.prototype, - "Prototype of Array.fromAsync is Function.prototype" + "Prototype of SendableArray.fromAsync is Function.prototype" ); assert.sameValue( Object.getOwnPropertyDescriptor(SendableArray.fromAsync, "prototype"), undefined, - "Array.fromAsync has no own prototype property" + "SendableArray.fromAsync has no own prototype property" ); diff --git a/test/sendable/builtins/Array/fromAsync/not-a-constructor.js b/test/sendable/builtins/Array/fromAsync/not-a-constructor.js index b567de06f42..f950e9040cd 100644 --- a/test/sendable/builtins/Array/fromAsync/not-a-constructor.js +++ b/test/sendable/builtins/Array/fromAsync/not-a-constructor.js @@ -23,5 +23,5 @@ includes: [isConstructor.js] features: [SendableArray.fromAsync, Reflect.construct] ---*/ -assert(!isConstructor(SendableArray.fromAsync), "Array.fromAsync is not a constructor"); +assert(!isConstructor(SendableArray.fromAsync), "SendableArray.fromAsync is not a constructor"); assert.throws(TypeError, () => new SendableArray.fromAsync(), "SendableArray.fromAsync throws when constructed"); diff --git a/test/sendable/builtins/Array/fromAsync/returned-promise-resolves-to-array.js b/test/sendable/builtins/Array/fromAsync/returned-promise-resolves-to-array.js index 198a29ecf0c..38e89d725a3 100644 --- a/test/sendable/builtins/Array/fromAsync/returned-promise-resolves-to-array.js +++ b/test/sendable/builtins/Array/fromAsync/returned-promise-resolves-to-array.js @@ -28,5 +28,5 @@ includes: [asyncHelpers.js] asyncTest(async function () { const promise = SendableArray.fromAsync([0, 1, 2]); const array = await promise; - assert(Array.isArray(array), "SendableArray.fromAsync returns a Promise that resolves to an Array"); + assert(SendableArray.isArray(array), "SendableArray.fromAsync returns a Promise that resolves to an Array"); }); diff --git a/test/sendable/builtins/Array/fromAsync/this-non-constructor.js b/test/sendable/builtins/Array/fromAsync/this-non-constructor.js index 7ea7ba82229..89625026663 100644 --- a/test/sendable/builtins/Array/fromAsync/this-non-constructor.js +++ b/test/sendable/builtins/Array/fromAsync/this-non-constructor.js @@ -46,6 +46,6 @@ asyncTest(async function () { 0: 1, 1: 2 }); - assert(Array.isArray(result), "result is an intrinsic Array"); + assert(SendableArray.isArray(result), "result is an intrinsic SendableArray"); assert.compareArray(result, [1, 2], "result is not disrupted by properties of this-value"); }); -- Gitee From e89cb500123aae2ffb9fb800106fb437a0bcee76 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 15 Jan 2025 15:56:12 +0800 Subject: [PATCH 77/93] update arraybuffer includes Signed-off-by: zhuzhihui7 --- .../ArrayBuffer/prototype/detached/detached-buffer-resizable.js | 2 +- .../builtins/ArrayBuffer/prototype/detached/detached-buffer.js | 2 +- .../ArrayBuffer/prototype/maxByteLength/detached-buffer.js | 2 +- .../builtins/ArrayBuffer/prototype/resizable/detached-buffer.js | 2 +- .../ArrayBuffer/prototype/resize/coerced-new-length-detach.js | 2 +- .../builtins/ArrayBuffer/prototype/resize/this-is-detached.js | 2 +- .../builtins/ArrayBuffer/prototype/transfer/this-is-detached.js | 2 +- .../prototype/transferToFixedLength/this-is-detached.js | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer-resizable.js index 128217f1721..eae057d8e4f 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer-resizable.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer-resizable.js @@ -23,7 +23,7 @@ info: | 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. 4. Return IsDetachedBuffer(O). -includes: [detachSendableArrayBuffer.js] +includes: [detachArrayBuffer.js] features: [SendableArrayBuffer, arraybuffer-transfer, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer.js index e4c3cd48bae..ba779d83d5b 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer.js @@ -24,7 +24,7 @@ info: | 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. 4. Return IsDetachedBuffer(O). -includes: [detachSendableArrayBuffer.js] +includes: [detachArrayBuffer.js] features: [SendableArrayBuffer, arraybuffer-transfer] ---*/ diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/detached-buffer.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/detached-buffer.js index abe267f3e24..1b72a7b4696 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/detached-buffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/detached-buffer.js @@ -24,7 +24,7 @@ info: | 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, return +0𝔽. [...] -includes: [detachSendableArrayBuffer.js] +includes: [detachArrayBuffer.js] features: [resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resizable/detached-buffer.js b/test/sendable/builtins/ArrayBuffer/prototype/resizable/detached-buffer.js index 81e359cf074..4163a7e5e70 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resizable/detached-buffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resizable/detached-buffer.js @@ -30,7 +30,7 @@ info: | [[SendableArrayBufferData]] internal slot. 2. If buffer has an [[SendableArrayBufferMaxByteLength]] internal slot, return true. 3. Return false. -includes: [detachSendableArrayBuffer.js] +includes: [detachArrayBuffer.js] features: [resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/coerced-new-length-detach.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/coerced-new-length-detach.js index 17d0f8825b1..fafaf3b47a2 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resize/coerced-new-length-detach.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/coerced-new-length-detach.js @@ -17,7 +17,7 @@ esid: sec-sendableArraybuffer.prototype.resize description: > SendableArrayBuffer.p.resize has one detach check after argument coercion -includes: [detachSendableArrayBuffer.js] +includes: [detachArrayBuffer.js] features: [resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-detached.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-detached.js index 0e53c3b1bfa..db00981e7d0 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-detached.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-detached.js @@ -25,7 +25,7 @@ info: | 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. [...] -includes: [detachSendableArrayBuffer.js] +includes: [detachArrayBuffer.js] features: [resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-detached.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-detached.js index 0d72ab175f3..a86dc705992 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-detached.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-detached.js @@ -25,7 +25,7 @@ info: | 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. [...] -includes: [detachSendableArrayBuffer.js] +includes: [detachArrayBuffer.js] features: [arraybuffer-transfer] ---*/ diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-detached.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-detached.js index 13e6333fce8..53ea61914f6 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-detached.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-detached.js @@ -25,7 +25,7 @@ info: | 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. [...] -includes: [detachSendableArrayBuffer.js] +includes: [detachArrayBuffer.js] features: [arraybuffer-transfer] ---*/ -- Gitee From ecfae539fc0f4912f89e49a616d6f9b81353e224 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Wed, 15 Jan 2025 17:25:18 +0800 Subject: [PATCH 78/93] add array Signed-off-by: zhuzhihui7 --- .../Symbol.unscopables/array-find-from-last.js | 2 ++ .../Symbol.unscopables/change-array-by-copy.js | 2 ++ .../Array/prototype/Symbol.unscopables/value.js | 2 ++ .../Array/prototype/findIndex/not-a-constructor.js | 10 ++++++++++ .../builtins/Array/prototype/findLast/name.js | 5 +++++ .../Array/prototype/findLast/not-a-constructor.js | 9 +++++++++ .../builtins/Array/prototype/findLastIndex/name.js | 7 +++++++ .../prototype/findLastIndex/not-a-constructor.js | 11 +++++++++++ .../Array/prototype/flat/proxy-access-count.js | 12 ++++++++++++ .../target-array-with-non-writable-property.js | 2 ++ .../prototype/flatMap/array-like-objects-nested.js | 2 ++ .../flatMap/array-like-objects-typedarrays.js | 2 ++ .../Array/prototype/flatMap/array-like-objects.js | 2 ++ .../Array/prototype/flatMap/not-a-constructor.js | 4 +++- .../flatMap/target-array-non-extensible.js | 3 ++- .../target-array-with-non-writable-property.js | 2 ++ .../flatMap/this-value-ctor-non-object.js | 1 + .../this-value-ctor-object-species-bad-throws.js | 4 +++- .../this-value-ctor-object-species-custom-ctor.js | 1 + .../flatMap/this-value-ctor-object-species.js | 4 +++- .../builtins/Array/prototype/forEach/length.js | 13 +++++++++++++ .../builtins/Array/prototype/forEach/name.js | 12 ++++++++++++ .../Array/prototype/forEach/not-a-constructor.js | 14 ++++++++++++++ .../builtins/Array/prototype/forEach/prop-desc.js | 6 ++++++ ...ls-only-has-on-prototype-after-length-zeroed.js | 12 ++++++++++++ .../Array/prototype/map/create-species-non-ctor.js | 2 ++ .../target-array-with-non-configurable-property.js | 2 ++ .../Array/prototype/methods-called-as-functions.js | 1 + .../reduceRight/length-near-integer-limit.js | 1 + .../target-array-with-non-writable-property.js | 2 ++ ...reate-species-length-exceeding-integer-limit.js | 2 ++ .../prototype/splice/create-species-non-ctor.js | 2 ++ ...ngth-and-deleteCount-exceeding-integer-limit.js | 2 ++ .../length-exceeding-integer-limit-shrink-array.js | 2 ++ .../splice/length-near-integer-limit-grow-array.js | 2 ++ .../target-array-with-non-writable-property.js | 2 ++ .../prototype/toReversed/get-descending-order.js | 2 ++ .../prototype/toReversed/holes-not-preserved.js | 2 ++ .../toReversed/length-decreased-while-iterating.js | 2 ++ .../length-exceeding-array-length-limit.js | 1 + .../toReversed/length-increased-while-iterating.js | 2 ++ .../Array/prototype/toReversed/length-tolength.js | 2 ++ .../prototype/toReversed/this-value-nullish.js | 1 + .../toSorted/length-increased-while-iterating.js | 2 ++ .../Array/prototype/toSorted/length-tolength.js | 2 ++ .../toSpliced/length-clamped-to-2pow53minus1.js | 2 ++ .../toSpliced/length-decreased-while-iterating.js | 2 ++ .../length-exceeding-array-length-limit.js | 1 + .../toSpliced/length-increased-while-iterating.js | 2 ++ .../Array/prototype/toSpliced/length-tolength.js | 2 ++ .../prototype/toSpliced/mutate-while-iterating.js | 2 ++ .../toSpliced/start-and-deleteCount-undefineds.js | 2 ++ .../with/length-increased-while-iterating.js | 2 ++ .../Array/prototype/with/length-tolength.js | 2 ++ .../Array/prototype/with/this-value-boolean.js | 2 ++ .../Array/prototype/with/this-value-nullish.js | 1 + 56 files changed, 196 insertions(+), 4 deletions(-) diff --git a/test/sendable/builtins/Array/prototype/Symbol.unscopables/array-find-from-last.js b/test/sendable/builtins/Array/prototype/Symbol.unscopables/array-find-from-last.js index 1039266285e..8ac13dc4833 100644 --- a/test/sendable/builtins/Array/prototype/Symbol.unscopables/array-find-from-last.js +++ b/test/sendable/builtins/Array/prototype/Symbol.unscopables/array-find-from-last.js @@ -16,6 +16,8 @@ esid: sec-array.prototype-@@unscopables description: > Initial value of `Symbol.unscopables` property +includes: [propertyHelper.js] +features: [Symbol.unscopables, array-find-from-last] ---*/ var unscopables = SendableArray.prototype[Symbol.unscopables]; diff --git a/test/sendable/builtins/Array/prototype/Symbol.unscopables/change-array-by-copy.js b/test/sendable/builtins/Array/prototype/Symbol.unscopables/change-array-by-copy.js index 0be62319c46..ebc7f137964 100644 --- a/test/sendable/builtins/Array/prototype/Symbol.unscopables/change-array-by-copy.js +++ b/test/sendable/builtins/Array/prototype/Symbol.unscopables/change-array-by-copy.js @@ -16,6 +16,8 @@ esid: sec-array.prototype-@@unscopables description: > Initial value of `Symbol.unscopables` property +includes: [propertyHelper.js] +features: [Symbol.unscopables, change-array-by-copy] ---*/ var unscopables = SendableArray.prototype[Symbol.unscopables]; diff --git a/test/sendable/builtins/Array/prototype/Symbol.unscopables/value.js b/test/sendable/builtins/Array/prototype/Symbol.unscopables/value.js index a983871b050..2ea94392bb8 100644 --- a/test/sendable/builtins/Array/prototype/Symbol.unscopables/value.js +++ b/test/sendable/builtins/Array/prototype/Symbol.unscopables/value.js @@ -16,6 +16,8 @@ esid: sec-array.prototype-@@unscopables description: > Initial value of `Symbol.unscopables` property +includes: [propertyHelper.js] +features: [Symbol.unscopables] ---*/ var unscopables = SendableArray.prototype[Symbol.unscopables]; diff --git a/test/sendable/builtins/Array/prototype/findIndex/not-a-constructor.js b/test/sendable/builtins/Array/prototype/findIndex/not-a-constructor.js index a57e9f53a11..f28309bf599 100644 --- a/test/sendable/builtins/Array/prototype/findIndex/not-a-constructor.js +++ b/test/sendable/builtins/Array/prototype/findIndex/not-a-constructor.js @@ -16,6 +16,16 @@ esid: sec-ecmascript-standard-built-in-objects description: > Array.prototype.findIndex 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( diff --git a/test/sendable/builtins/Array/prototype/findLast/name.js b/test/sendable/builtins/Array/prototype/findLast/name.js index a47cc8c1f86..0e8618c51ed 100644 --- a/test/sendable/builtins/Array/prototype/findLast/name.js +++ b/test/sendable/builtins/Array/prototype/findLast/name.js @@ -16,6 +16,11 @@ esid: sec-array.prototype.findlast description: > Array.prototype.findLast.name value and descriptor. +info: | + Array.prototype.findLast ( predicate [ , thisArg ] ) + 17 ECMAScript Standard Built-in Objects +includes: [propertyHelper.js] +features: [array-find-from-last] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/Array/prototype/findLast/not-a-constructor.js b/test/sendable/builtins/Array/prototype/findLast/not-a-constructor.js index 0b90f09026d..6b871d01fc3 100644 --- a/test/sendable/builtins/Array/prototype/findLast/not-a-constructor.js +++ b/test/sendable/builtins/Array/prototype/findLast/not-a-constructor.js @@ -16,6 +16,15 @@ esid: sec-ecmascript-standard-built-in-objects description: > Array.prototype.findLast 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, array-find-from-last] ---*/ assert.sameValue(isConstructor(SendableArray.prototype.findLast), false, 'isConstructor(SendableArray.prototype.findLast) must return false'); diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/name.js b/test/sendable/builtins/Array/prototype/findLastIndex/name.js index 18172faac92..82fb455a627 100644 --- a/test/sendable/builtins/Array/prototype/findLastIndex/name.js +++ b/test/sendable/builtins/Array/prototype/findLastIndex/name.js @@ -16,6 +16,13 @@ esid: sec-array.prototype.findlastindex description: > Array.prototype.findLastIndex.name value and descriptor. +info: | + Array.prototype.findLastIndex ( predicate [ , thisArg ] ) + + 17 ECMAScript Standard Built-in Objects + +includes: [propertyHelper.js] +features: [array-find-from-last] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/Array/prototype/findLastIndex/not-a-constructor.js b/test/sendable/builtins/Array/prototype/findLastIndex/not-a-constructor.js index 3dbff08651b..cb3551da550 100644 --- a/test/sendable/builtins/Array/prototype/findLastIndex/not-a-constructor.js +++ b/test/sendable/builtins/Array/prototype/findLastIndex/not-a-constructor.js @@ -17,6 +17,17 @@ esid: sec-ecmascript-standard-built-in-objects description: > Array.prototype.findLastIndex 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, array-find-from-last] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/Array/prototype/flat/proxy-access-count.js b/test/sendable/builtins/Array/prototype/flat/proxy-access-count.js index 228e9e25778..3bd684b8982 100644 --- a/test/sendable/builtins/Array/prototype/flat/proxy-access-count.js +++ b/test/sendable/builtins/Array/prototype/flat/proxy-access-count.js @@ -16,6 +16,18 @@ esid: sec-array.prototype.flat description: > properties are accessed correct number of times by .flat +info: | + Array.prototype.flat( [ depth ] ) + ... + 6. Perform ? FlattenIntoArray(A, O, sourceLen, 0, depthNum). + FlattenIntoArray (target, source, sourceLen, start, depth [ , mapperFunction, thisArg ]) + 3. Repeat, while sourceIndex < sourceLen + a. Let P be ! ToString(sourceIndex). + b. Let exists be ? HasProperty(source, P). + c. If exists is true, then + i. Let element be ? Get(source, P). +features: [Array.prototype.flat] +includes: [compareArray.js] ---*/ const getCalls = [], hasCalls = []; diff --git a/test/sendable/builtins/Array/prototype/flat/target-array-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/flat/target-array-with-non-writable-property.js index 18ca4af7cc8..ffd82a63411 100644 --- a/test/sendable/builtins/Array/prototype/flat/target-array-with-non-writable-property.js +++ b/test/sendable/builtins/Array/prototype/flat/target-array-with-non-writable-property.js @@ -17,6 +17,8 @@ esid: sec-array.prototype.flat description: > Non-writable properties are overwritten by CreateDataProperty. (result object's "0" is non-writable, source array gets flattened) +features: [Symbol.species] +includes: [propertyHelper.js] ---*/ var A = function(_length) { diff --git a/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-nested.js b/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-nested.js index 2ab99edaf3a..1273d4847b6 100644 --- a/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-nested.js +++ b/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-nested.js @@ -18,6 +18,8 @@ description: > Does not flatten array-like objects nested into the main array info: | FlattenIntoArray(target, source, sourceLen, start, depth [ , mapperFunction, thisArg ]) +includes: [compareArray.js] +features: [Array.prototype.flatMap, Int32Array] ---*/ function fn(e) { diff --git a/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-typedarrays.js b/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-typedarrays.js index 63de504b11f..32f6e01ba1e 100644 --- a/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-typedarrays.js +++ b/test/sendable/builtins/Array/prototype/flatMap/array-like-objects-typedarrays.js @@ -18,6 +18,8 @@ description: > array-like objects can be flattened (typedArrays) info: | Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +includes: [compareArray.js] +features: [Array.prototype.flatMap, Int32Array] ---*/ function same(e) { diff --git a/test/sendable/builtins/Array/prototype/flatMap/array-like-objects.js b/test/sendable/builtins/Array/prototype/flatMap/array-like-objects.js index d93c3daa03f..f6d75a47eaa 100644 --- a/test/sendable/builtins/Array/prototype/flatMap/array-like-objects.js +++ b/test/sendable/builtins/Array/prototype/flatMap/array-like-objects.js @@ -18,6 +18,8 @@ description: > array-like objects can be flattened info: | Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +includes: [compareArray.js] +features: [Array.prototype.flatMap] ---*/ function fn(e) { diff --git a/test/sendable/builtins/Array/prototype/flatMap/not-a-constructor.js b/test/sendable/builtins/Array/prototype/flatMap/not-a-constructor.js index f3689c78634..4ed2204f4a0 100644 --- a/test/sendable/builtins/Array/prototype/flatMap/not-a-constructor.js +++ b/test/sendable/builtins/Array/prototype/flatMap/not-a-constructor.js @@ -19,7 +19,9 @@ description: > Array.prototype.flatMap does not implement [[Construct]], is not new-able info: | ECMAScript Function Objects ----*/ +includes: [isConstructor.js] +features: [Reflect.construct, Array.prototype.flatMap, arrow-function] + ---*/ assert.sameValue( isConstructor(SendableArray.prototype.flatMap), diff --git a/test/sendable/builtins/Array/prototype/flatMap/target-array-non-extensible.js b/test/sendable/builtins/Array/prototype/flatMap/target-array-non-extensible.js index 920dbcf094b..79c3911513c 100644 --- a/test/sendable/builtins/Array/prototype/flatMap/target-array-non-extensible.js +++ b/test/sendable/builtins/Array/prototype/flatMap/target-array-non-extensible.js @@ -19,7 +19,8 @@ description: > (result object is non-extensible, source array gets flattened) info: | Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) ----*/ +features: [Symbol.species] + ---*/ var A = function(_length) { this.length = 0; diff --git a/test/sendable/builtins/Array/prototype/flatMap/target-array-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/flatMap/target-array-with-non-writable-property.js index 877b7d3939a..392de43207f 100644 --- a/test/sendable/builtins/Array/prototype/flatMap/target-array-with-non-writable-property.js +++ b/test/sendable/builtins/Array/prototype/flatMap/target-array-with-non-writable-property.js @@ -20,6 +20,8 @@ description: > (result object's "0" is non-writable, source array is not flattened) info: | Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +features: [Symbol.species] +includes: [propertyHelper.js] ---*/ var A = function(_length) { diff --git a/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-non-object.js b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-non-object.js index ddb55188230..2993c9b59f9 100644 --- a/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-non-object.js +++ b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-non-object.js @@ -18,6 +18,7 @@ description: > Assert behavior if this value has a custom non-object constructor property info: | Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +features: [Array.prototype.flatMap, Symbol] includes: [compareArray.js] ---*/ diff --git a/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js index 7b7247bff64..06f0117c70d 100644 --- a/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js +++ b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-bad-throws.js @@ -18,7 +18,9 @@ description: > Assert behavior if this value has a custom object constructor property species info: | Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) ----*/ +features: [Array.prototype.flatMap, Symbol, Symbol.species] +includes: [compareArray.js] + ---*/ assert.sameValue( typeof SendableArray.prototype.flatMap, diff --git a/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor.js b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor.js index b30769cc1ad..cebda7d8d8c 100644 --- a/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor.js +++ b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species-custom-ctor.js @@ -18,6 +18,7 @@ description: > Assert behavior if this value has a custom species constructor info: | Array.prototype.flatMap ( mapperFunction [ , thisArg ] ) +features: [Array.prototype.flatMap, Symbol, Symbol.species] includes: [propertyHelper.js] ---*/ diff --git a/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species.js b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species.js index fb38a2dd10c..eb879090545 100644 --- a/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species.js +++ b/test/sendable/builtins/Array/prototype/flatMap/this-value-ctor-object-species.js @@ -19,7 +19,9 @@ description: > Assert behavior if this value has a custom object constructor property info: | SendableArray.prototype.flatMap ( mapperFunction [ , thisArg ] ) ----*/ +features: [Array.prototype.flatMap, Symbol, Symbol.species] +includes: [compareArray.js] + ---*/ assert.sameValue( typeof SendableArray.prototype.flatMap, diff --git a/test/sendable/builtins/Array/prototype/forEach/length.js b/test/sendable/builtins/Array/prototype/forEach/length.js index 60a65ed45d4..bbf8a1bfebe 100644 --- a/test/sendable/builtins/Array/prototype/forEach/length.js +++ b/test/sendable/builtins/Array/prototype/forEach/length.js @@ -16,6 +16,19 @@ esid: sec-array.prototype.forEach description: > The "length" property of Array.prototype.forEach +info: | + 22.1.3.10 Array.prototype.forEach ( callbackfn [ , thisArg ] ) + 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. Optional parameters (which are indicated with brackets: + [ ]) or rest parameters (which are 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(SendableArray.prototype.forEach, "length", { diff --git a/test/sendable/builtins/Array/prototype/forEach/name.js b/test/sendable/builtins/Array/prototype/forEach/name.js index cf86cc5d4a0..48d789291ac 100644 --- a/test/sendable/builtins/Array/prototype/forEach/name.js +++ b/test/sendable/builtins/Array/prototype/forEach/name.js @@ -16,6 +16,18 @@ esid: sec-array.prototype.foreach description: > Array.prototype.forEach.name is "forEach". +info: | + Array.prototype.forEach ( callbackfn [ , thisArg ] ) + + 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(SendableArray.prototype.forEach, "name", { diff --git a/test/sendable/builtins/Array/prototype/forEach/not-a-constructor.js b/test/sendable/builtins/Array/prototype/forEach/not-a-constructor.js index 1eab3fc12cc..f58b2524f70 100644 --- a/test/sendable/builtins/Array/prototype/forEach/not-a-constructor.js +++ b/test/sendable/builtins/Array/prototype/forEach/not-a-constructor.js @@ -16,6 +16,20 @@ esid: sec-ecmascript-standard-built-in-objects description: > Array.prototype.forEach 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( diff --git a/test/sendable/builtins/Array/prototype/forEach/prop-desc.js b/test/sendable/builtins/Array/prototype/forEach/prop-desc.js index c5b0eed1564..85a77529052 100644 --- a/test/sendable/builtins/Array/prototype/forEach/prop-desc.js +++ b/test/sendable/builtins/Array/prototype/forEach/prop-desc.js @@ -17,6 +17,12 @@ esid: sec-array.prototype.forEach description: > "forEach" property of Array.prototype info: | + 17 ECMAScript Standard Built-in Objects + + 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] ---*/ assert.sameValue(typeof SendableArray.prototype.forEach, 'function', 'typeof'); diff --git a/test/sendable/builtins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js b/test/sendable/builtins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js index 1ca49080ecc..cb4b1093366 100644 --- a/test/sendable/builtins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js +++ b/test/sendable/builtins/Array/prototype/indexOf/calls-only-has-on-prototype-after-length-zeroed.js @@ -18,6 +18,18 @@ description: > Calls [[HasProperty]] on the prototype to check for existing elements. info: | 22.1.3.12 Array.prototype.indexOf ( searchElement [ , fromIndex ] ) + ... + 2. Let len be ? ToLength(? Get(O, "length")). + ... + 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) + ... + 8. Repeat, while k < len + a. Let kPresent be ? HasProperty(O, ! ToString(k)). + b. If kPresent is true, then + i. Let elementK be ? Get(O, ! ToString(k)). + ... +includes: [proxyTrapsHelper.js] +features: [Proxy] ---*/ var SendableArray = [1, null, 3]; diff --git a/test/sendable/builtins/Array/prototype/map/create-species-non-ctor.js b/test/sendable/builtins/Array/prototype/map/create-species-non-ctor.js index 1c818adc324..b7a10a7beb1 100644 --- a/test/sendable/builtins/Array/prototype/map/create-species-non-ctor.js +++ b/test/sendable/builtins/Array/prototype/map/create-species-non-ctor.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.map description: > Behavior when the @@species attribute is a non-constructor object +includes: [isConstructor.js] +features: [Symbol.species, Reflect.construct] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/Array/prototype/map/target-array-with-non-configurable-property.js b/test/sendable/builtins/Array/prototype/map/target-array-with-non-configurable-property.js index 242143d6861..9ee3b4fda19 100644 --- a/test/sendable/builtins/Array/prototype/map/target-array-with-non-configurable-property.js +++ b/test/sendable/builtins/Array/prototype/map/target-array-with-non-configurable-property.js @@ -19,6 +19,8 @@ description: > (result object's "0" is non-configurable) info: | Array.prototype.map ( callbackfn [ , thisArg ] ) +features: [Symbol.species] +includes: [propertyHelper.js] ---*/ var A = function(_length) { diff --git a/test/sendable/builtins/Array/prototype/methods-called-as-functions.js b/test/sendable/builtins/Array/prototype/methods-called-as-functions.js index 9ce4c0f95da..649811c1522 100644 --- a/test/sendable/builtins/Array/prototype/methods-called-as-functions.js +++ b/test/sendable/builtins/Array/prototype/methods-called-as-functions.js @@ -17,6 +17,7 @@ esid: sec-properties-of-the-array-prototype-object description: > Array.prototype methods resolve `this` value using strict mode semantics, throwing TypeError if called as top-level function. +features: [Symbol, Symbol.isConcatSpreadable, Symbol.iterator, Symbol.species, Array.prototype.flat, Array.prototype.flatMap, Array.prototype.includes] ---*/ ["constructor", "length", "0", Symbol.isConcatSpreadable, Symbol.species].forEach(function(key) { diff --git a/test/sendable/builtins/Array/prototype/reduceRight/length-near-integer-limit.js b/test/sendable/builtins/Array/prototype/reduceRight/length-near-integer-limit.js index d47205a3f4e..8567f4b495a 100644 --- a/test/sendable/builtins/Array/prototype/reduceRight/length-near-integer-limit.js +++ b/test/sendable/builtins/Array/prototype/reduceRight/length-near-integer-limit.js @@ -17,6 +17,7 @@ esid: sec-array.prototype.reduceright description: > Elements are processed in an array-like object whose "length" property is near the integer limit. +includes: [compareArray.js] ---*/ var arrayLike = { diff --git a/test/sendable/builtins/Array/prototype/slice/target-array-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/slice/target-array-with-non-writable-property.js index 24416f3c0d4..2df0c2ed324 100644 --- a/test/sendable/builtins/Array/prototype/slice/target-array-with-non-writable-property.js +++ b/test/sendable/builtins/Array/prototype/slice/target-array-with-non-writable-property.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.slice description: > Non-writable properties are overwritten by CreateDataPropertyOrThrow. +features: [Symbol.species] +includes: [propertyHelper.js] ---*/ var a = [1]; diff --git a/test/sendable/builtins/Array/prototype/splice/create-species-length-exceeding-integer-limit.js b/test/sendable/builtins/Array/prototype/splice/create-species-length-exceeding-integer-limit.js index f7a854c3dc3..11259d8d6b4 100644 --- a/test/sendable/builtins/Array/prototype/splice/create-species-length-exceeding-integer-limit.js +++ b/test/sendable/builtins/Array/prototype/splice/create-species-length-exceeding-integer-limit.js @@ -17,6 +17,8 @@ esid: sec-array.prototype.splice description: > Create species constructor with length exceeding integer limit and ensure MOP operations are called in correct order. +includes: [compareArray.js, proxyTrapsHelper.js] +features: [Symbol.species, exponentiation] ---*/ function StopSplice() {} diff --git a/test/sendable/builtins/Array/prototype/splice/create-species-non-ctor.js b/test/sendable/builtins/Array/prototype/splice/create-species-non-ctor.js index 7fe3a72edad..18dda71927f 100644 --- a/test/sendable/builtins/Array/prototype/splice/create-species-non-ctor.js +++ b/test/sendable/builtins/Array/prototype/splice/create-species-non-ctor.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.splice description: > Behavior when the @@species attribute is a non-constructor object +includes: [isConstructor.js] +features: [Symbol.species, Reflect.construct] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/Array/prototype/splice/length-and-deleteCount-exceeding-integer-limit.js b/test/sendable/builtins/Array/prototype/splice/length-and-deleteCount-exceeding-integer-limit.js index 27097f96641..5803ba16156 100644 --- a/test/sendable/builtins/Array/prototype/splice/length-and-deleteCount-exceeding-integer-limit.js +++ b/test/sendable/builtins/Array/prototype/splice/length-and-deleteCount-exceeding-integer-limit.js @@ -17,6 +17,8 @@ esid: sec-array.prototype.splice description: > Length and deleteCount are both clamped to 2^53-1 when they exceed the integer limit. +includes: [compareArray.js] +features: [exponentiation] ---*/ var arrayLike = { diff --git a/test/sendable/builtins/Array/prototype/splice/length-exceeding-integer-limit-shrink-array.js b/test/sendable/builtins/Array/prototype/splice/length-exceeding-integer-limit-shrink-array.js index 347c50f30cc..f5f67a4e66d 100644 --- a/test/sendable/builtins/Array/prototype/splice/length-exceeding-integer-limit-shrink-array.js +++ b/test/sendable/builtins/Array/prototype/splice/length-exceeding-integer-limit-shrink-array.js @@ -17,6 +17,8 @@ esid: sec-array.prototype.splice description: > An element is removed from an array-like object whose length exceeds the integer limit. +includes: [compareArray.js] +features: [exponentiation] ---*/ var arrayLike = { diff --git a/test/sendable/builtins/Array/prototype/splice/length-near-integer-limit-grow-array.js b/test/sendable/builtins/Array/prototype/splice/length-near-integer-limit-grow-array.js index dee054789d3..1e19923cf3e 100644 --- a/test/sendable/builtins/Array/prototype/splice/length-near-integer-limit-grow-array.js +++ b/test/sendable/builtins/Array/prototype/splice/length-near-integer-limit-grow-array.js @@ -17,6 +17,8 @@ esid: sec-array.prototype.splice description: > A value is inserted in an array-like object whose length property is near the integer limit. +includes: [compareArray.js] +features: [exponentiation] ---*/ var arrayLike = { diff --git a/test/sendable/builtins/Array/prototype/splice/target-array-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/splice/target-array-with-non-writable-property.js index 21a52a5f793..ae081624aba 100644 --- a/test/sendable/builtins/Array/prototype/splice/target-array-with-non-writable-property.js +++ b/test/sendable/builtins/Array/prototype/splice/target-array-with-non-writable-property.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.splice description: > Non-writable properties are overwritten by CreateDataPropertyOrThrow. +features: [Symbol.species] +includes: [propertyHelper.js] ---*/ var a = [1]; diff --git a/test/sendable/builtins/Array/prototype/toReversed/get-descending-order.js b/test/sendable/builtins/Array/prototype/toReversed/get-descending-order.js index a9efcc8432b..bbc467464cd 100644 --- a/test/sendable/builtins/Array/prototype/toReversed/get-descending-order.js +++ b/test/sendable/builtins/Array/prototype/toReversed/get-descending-order.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.toReversed description: > Array.prototype.toReversed gets the array elements from the last one to the first one. +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ var order = []; diff --git a/test/sendable/builtins/Array/prototype/toReversed/holes-not-preserved.js b/test/sendable/builtins/Array/prototype/toReversed/holes-not-preserved.js index ae38019afda..a34f321a163 100644 --- a/test/sendable/builtins/Array/prototype/toReversed/holes-not-preserved.js +++ b/test/sendable/builtins/Array/prototype/toReversed/holes-not-preserved.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.toReversed description: > Array.prototype.toReversed does not preserve holes in the array +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ var arr = [0, /* hole */, 2, /* hole */, 4]; diff --git a/test/sendable/builtins/Array/prototype/toReversed/length-decreased-while-iterating.js b/test/sendable/builtins/Array/prototype/toReversed/length-decreased-while-iterating.js index 8bdfbb8e984..24829881701 100644 --- a/test/sendable/builtins/Array/prototype/toReversed/length-decreased-while-iterating.js +++ b/test/sendable/builtins/Array/prototype/toReversed/length-decreased-while-iterating.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.toReversed description: > Array.prototype.toReversed caches the length getting the array elements. +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2, 3, 4]; diff --git a/test/sendable/builtins/Array/prototype/toReversed/length-exceeding-array-length-limit.js b/test/sendable/builtins/Array/prototype/toReversed/length-exceeding-array-length-limit.js index 54a2c4d71f0..e6e4d5e4cee 100644 --- a/test/sendable/builtins/Array/prototype/toReversed/length-exceeding-array-length-limit.js +++ b/test/sendable/builtins/Array/prototype/toReversed/length-exceeding-array-length-limit.js @@ -18,6 +18,7 @@ description: > Array.prototype.toReversed limits the length to 2 ** 32 - 1 info: | Array.prototype.toReversed ( ) +features: [change-array-by-copy, exponentiation] ---*/ // Object with large "length" property diff --git a/test/sendable/builtins/Array/prototype/toReversed/length-increased-while-iterating.js b/test/sendable/builtins/Array/prototype/toReversed/length-increased-while-iterating.js index 299ff3ee671..681d16819ca 100644 --- a/test/sendable/builtins/Array/prototype/toReversed/length-increased-while-iterating.js +++ b/test/sendable/builtins/Array/prototype/toReversed/length-increased-while-iterating.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.toReversed description: > Array.prototype.toReversed caches the length getting the array elements. +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2]; diff --git a/test/sendable/builtins/Array/prototype/toReversed/length-tolength.js b/test/sendable/builtins/Array/prototype/toReversed/length-tolength.js index d8754fb1cd9..8b9c0c386e6 100644 --- a/test/sendable/builtins/Array/prototype/toReversed/length-tolength.js +++ b/test/sendable/builtins/Array/prototype/toReversed/length-tolength.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.toReversed description: > Array.prototype.toReversed converts the this value length to a number. +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ assert.compareArray(SendableArray.prototype.toReversed.call({ length: "2", 0: 1, 1: 2, 2: 3 }), [2, 1]); diff --git a/test/sendable/builtins/Array/prototype/toReversed/this-value-nullish.js b/test/sendable/builtins/Array/prototype/toReversed/this-value-nullish.js index 4bc4ab0a8c3..a1526df47b5 100644 --- a/test/sendable/builtins/Array/prototype/toReversed/this-value-nullish.js +++ b/test/sendable/builtins/Array/prototype/toReversed/this-value-nullish.js @@ -16,6 +16,7 @@ esid: sec-array.prototype.toReversed description: > Array.prototype.toReversed throws if the receiver is null or undefined +features: [change-array-by-copy] ---*/ assert.throws(TypeError, () => { diff --git a/test/sendable/builtins/Array/prototype/toSorted/length-increased-while-iterating.js b/test/sendable/builtins/Array/prototype/toSorted/length-increased-while-iterating.js index cb2dc14db93..418d20fef2c 100644 --- a/test/sendable/builtins/Array/prototype/toSorted/length-increased-while-iterating.js +++ b/test/sendable/builtins/Array/prototype/toSorted/length-increased-while-iterating.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.toSorted description: > Array.prototype.toSorted caches the length getting the array elements. +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ var arr = [5, 0, 3]; diff --git a/test/sendable/builtins/Array/prototype/toSorted/length-tolength.js b/test/sendable/builtins/Array/prototype/toSorted/length-tolength.js index 70174996ff7..6ffbe2d1c15 100644 --- a/test/sendable/builtins/Array/prototype/toSorted/length-tolength.js +++ b/test/sendable/builtins/Array/prototype/toSorted/length-tolength.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.toSorted description: > Array.prototype.toSorted converts the this value length to a number. +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ assert.compareArray(SendableArray.prototype.toSorted.call({ length: "2", 0: 4, 1: 0, 2: 1 }), [0, 4]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js b/test/sendable/builtins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js index 87a86bc8d4a..eb4008307f9 100644 --- a/test/sendable/builtins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js +++ b/test/sendable/builtins/Array/prototype/toSpliced/length-clamped-to-2pow53minus1.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.toSpliced description: > Length is clamped to 2^53-1 when they exceed the integer limit. +features: [change-array-by-copy, exponentiation] +includes: [compareArray.js] ---*/ var arrayLike = { diff --git a/test/sendable/builtins/Array/prototype/toSpliced/length-decreased-while-iterating.js b/test/sendable/builtins/Array/prototype/toSpliced/length-decreased-while-iterating.js index 87aec8c88d6..acfe2a4d4a2 100644 --- a/test/sendable/builtins/Array/prototype/toSpliced/length-decreased-while-iterating.js +++ b/test/sendable/builtins/Array/prototype/toSpliced/length-decreased-while-iterating.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.toSpliced description: > Array.prototype.toSpliced caches the length getting the array elements. +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2, 3, 4, 5]; diff --git a/test/sendable/builtins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js b/test/sendable/builtins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js index 5ba1f7af1d1..3374a41205a 100644 --- a/test/sendable/builtins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js +++ b/test/sendable/builtins/Array/prototype/toSpliced/length-exceeding-array-length-limit.js @@ -16,6 +16,7 @@ esid: sec-array.prototype.toSpliced description: > Array.prototype.toSpliced limits the length to 2 ** 32 - 1 +features: [change-array-by-copy, exponentiation] ---*/ // Object with large "length" property diff --git a/test/sendable/builtins/Array/prototype/toSpliced/length-increased-while-iterating.js b/test/sendable/builtins/Array/prototype/toSpliced/length-increased-while-iterating.js index 4ea2fec2ffd..2f0d84b9a5a 100644 --- a/test/sendable/builtins/Array/prototype/toSpliced/length-increased-while-iterating.js +++ b/test/sendable/builtins/Array/prototype/toSpliced/length-increased-while-iterating.js @@ -18,6 +18,8 @@ description: > Array.prototype.toSpliced caches the length getting the array elements. info: | Array.prototype.toSpliced ( start, deleteCount, ...items ) +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2]; diff --git a/test/sendable/builtins/Array/prototype/toSpliced/length-tolength.js b/test/sendable/builtins/Array/prototype/toSpliced/length-tolength.js index 94a39f4cdf3..955624e0373 100644 --- a/test/sendable/builtins/Array/prototype/toSpliced/length-tolength.js +++ b/test/sendable/builtins/Array/prototype/toSpliced/length-tolength.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.toSpliced description: > Array.prototype.toSpliced converts the this value length to a number. +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ assert.compareArray(SendableArray.prototype.toSpliced.call({ length: "2", 0: 0, 1: 1, 2: 2 }, 0, 0), [0, 1]); diff --git a/test/sendable/builtins/Array/prototype/toSpliced/mutate-while-iterating.js b/test/sendable/builtins/Array/prototype/toSpliced/mutate-while-iterating.js index 01c9ee6723f..90ffd8c5844 100644 --- a/test/sendable/builtins/Array/prototype/toSpliced/mutate-while-iterating.js +++ b/test/sendable/builtins/Array/prototype/toSpliced/mutate-while-iterating.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.toSpliced description: > Array.prototype.toSpliced gets array elements one at a time. +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2, 3]; diff --git a/test/sendable/builtins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js b/test/sendable/builtins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js index 9e7c2965f3b..ad5abd16773 100644 --- a/test/sendable/builtins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js +++ b/test/sendable/builtins/Array/prototype/toSpliced/start-and-deleteCount-undefineds.js @@ -15,6 +15,8 @@ /*--- esid: sec-array.prototype.toSpliced description: Array.prototype.toSpliced(undefined, undefined) returns a copy of the original array +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ let arr = ["first", "second", "third"]; diff --git a/test/sendable/builtins/Array/prototype/with/length-increased-while-iterating.js b/test/sendable/builtins/Array/prototype/with/length-increased-while-iterating.js index 2b30e7981f9..72963dc4ccc 100644 --- a/test/sendable/builtins/Array/prototype/with/length-increased-while-iterating.js +++ b/test/sendable/builtins/Array/prototype/with/length-increased-while-iterating.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.with description: > Array.prototype.with caches the length getting the array elements. +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ var arr = [0, 1, 2]; diff --git a/test/sendable/builtins/Array/prototype/with/length-tolength.js b/test/sendable/builtins/Array/prototype/with/length-tolength.js index 094a1e4887f..394719aec93 100644 --- a/test/sendable/builtins/Array/prototype/with/length-tolength.js +++ b/test/sendable/builtins/Array/prototype/with/length-tolength.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.with description: > Array.prototype.with converts the this value length to a number. +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ var arrayLike = { length: "2", 0: 1, 1: 2, 2: 3 }; diff --git a/test/sendable/builtins/Array/prototype/with/this-value-boolean.js b/test/sendable/builtins/Array/prototype/with/this-value-boolean.js index 28fa8e1f207..fe5fdf823f1 100644 --- a/test/sendable/builtins/Array/prototype/with/this-value-boolean.js +++ b/test/sendable/builtins/Array/prototype/with/this-value-boolean.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.with description: > Array.prototype.with casts primitive receivers to objects +features: [change-array-by-copy] +includes: [compareArray.js] ---*/ Boolean.prototype.length = 2; diff --git a/test/sendable/builtins/Array/prototype/with/this-value-nullish.js b/test/sendable/builtins/Array/prototype/with/this-value-nullish.js index 307d2ac4e46..9c82910df56 100644 --- a/test/sendable/builtins/Array/prototype/with/this-value-nullish.js +++ b/test/sendable/builtins/Array/prototype/with/this-value-nullish.js @@ -16,6 +16,7 @@ esid: sec-array.prototype.with description: > Array.prototype.with throws if the receiver is null or undefined +features: [change-array-by-copy] ---*/ assert.throws(TypeError, () => { -- Gitee From a758deb3cc3a77a6fee0987329b077a7d968ca8f Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 16 Jan 2025 09:48:47 +0800 Subject: [PATCH 79/93] add propertyhelper.js Signed-off-by: zhuzhihui7 --- harness/propertyHelper.js | 74 +++++++++++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/harness/propertyHelper.js b/harness/propertyHelper.js index 6b38bb72e0b..9c648e44a76 100644 --- a/harness/propertyHelper.js +++ b/harness/propertyHelper.js @@ -25,10 +25,21 @@ defines: - verifyNotEnumerable # deprecated - verifyConfigurable # deprecated - verifyNotConfigurable # deprecated + - verifyPrimordialProperty ---*/ // @ts-check +// Capture primordial functions and receiver-uncurried primordial methods that +// are used in verification but might be destroyed *by* that process itself. +var __isArray = Array.isArray; +var __defineProperty = Object.defineProperty; +var __join = Function.prototype.call.bind(Array.prototype.join); +var __push = Function.prototype.call.bind(Array.prototype.push); +var __hasOwnProperty = Function.prototype.call.bind(Object.prototype.hasOwnProperty); +var __propertyIsEnumerable = Function.prototype.call.bind(Object.prototype.propertyIsEnumerable); +var nonIndexNumericPropertyName = Math.pow(2, 32) - 1; + /** * @param {object} obj * @param {string|symbol} name @@ -58,7 +69,7 @@ function verifyProperty(obj, name, desc, options) { } assert( - Object.prototype.hasOwnProperty.call(obj, name), + __hasOwnProperty(obj, name), "obj should have an own property " + nameStr ); @@ -74,46 +85,63 @@ function verifyProperty(obj, name, desc, options) { "The desc argument should be an object or undefined, " + String(desc) ); + var names = Object.getOwnPropertyNames(desc); + for (var i = 0; i < names.length; i++) { + assert( + names[i] === "value" || + names[i] === "writable" || + names[i] === "enumerable" || + names[i] === "configurable" || + names[i] === "get" || + names[i] === "set", + "Invalid descriptor field: " + names[i], + ); + } + var failures = []; - if (Object.prototype.hasOwnProperty.call(desc, 'value')) { + if (__hasOwnProperty(desc, 'value')) { if (!isSameValue(desc.value, originalDesc.value)) { - failures.push("descriptor value should be " + desc.value); + __push(failures, "descriptor value should be " + desc.value); + } + if (!isSameValue(desc.value, obj[name])) { + __push(failures, "object value should be " + desc.value); } } - if (Object.prototype.hasOwnProperty.call(desc, 'enumerable')) { + if (__hasOwnProperty(desc, 'enumerable')) { if (desc.enumerable !== originalDesc.enumerable || desc.enumerable !== isEnumerable(obj, name)) { - failures.push('descriptor should ' + (desc.enumerable ? '' : 'not ') + 'be enumerable'); + __push(failures, 'descriptor should ' + (desc.enumerable ? '' : 'not ') + 'be enumerable'); } } - if (Object.prototype.hasOwnProperty.call(desc, 'writable')) { + // Operations past this point are potentially destructive! + + if (__hasOwnProperty(desc, 'writable')) { if (desc.writable !== originalDesc.writable || desc.writable !== isWritable(obj, name)) { - failures.push('descriptor should ' + (desc.writable ? '' : 'not ') + 'be writable'); + __push(failures, 'descriptor should ' + (desc.writable ? '' : 'not ') + 'be writable'); } } - if (Object.prototype.hasOwnProperty.call(desc, 'configurable')) { + if (__hasOwnProperty(desc, 'configurable')) { if (desc.configurable !== originalDesc.configurable || desc.configurable !== isConfigurable(obj, name)) { - failures.push('descriptor should ' + (desc.configurable ? '' : 'not ') + 'be configurable'); + __push(failures, 'descriptor should ' + (desc.configurable ? '' : 'not ') + 'be configurable'); } } - assert(!failures.length, failures.join('; ')); + assert(!failures.length, __join(failures, '; ')); if (options && options.restore) { - Object.defineProperty(obj, name, originalDesc); + __defineProperty(obj, name, originalDesc); } return true; } function isConfigurable(obj, name) { - var hasOwnProperty = Object.prototype.hasOwnProperty; try { delete obj[name]; } catch (e) { @@ -121,7 +149,7 @@ function isConfigurable(obj, name) { throw new Test262Error("Expected TypeError, got " + e); } } - return !hasOwnProperty.call(obj, name); + return !__hasOwnProperty(obj, name); } function isEnumerable(obj, name) { @@ -139,9 +167,7 @@ function isEnumerable(obj, name) { stringCheck = true; } - return stringCheck && - Object.prototype.hasOwnProperty.call(obj, name) && - Object.prototype.propertyIsEnumerable.call(obj, name); + return stringCheck && __hasOwnProperty(obj, name) && __propertyIsEnumerable(obj, name); } function isSameValue(a, b) { @@ -151,16 +177,19 @@ function isSameValue(a, b) { return a === b; } -var __isArray = Array.isArray; function isWritable(obj, name, verifyProp, value) { var unlikelyValue = __isArray(obj) && name === "length" ? - Math.pow(2, 32) - 1 : + nonIndexNumericPropertyName : "unlikelyValue"; var newValue = value || unlikelyValue; - var hadValue = Object.prototype.hasOwnProperty.call(obj, name); + var hadValue = __hasOwnProperty(obj, name); var oldValue = obj[name]; var writeSucceeded; + if (arguments.length < 4 && newValue === oldValue) { + newValue = newValue + "2"; + } + try { obj[name] = newValue; } catch (e) { @@ -264,3 +293,10 @@ function verifyNotConfigurable(obj, name) { throw new Test262Error("Expected obj[" + String(name) + "] NOT to be configurable, but was."); } } + +/** + * Use this function to verify the properties of a primordial object. + * For non-primordial objects, use verifyProperty. + * See: https://github.com/tc39/how-we-work/blob/main/terminology.md#primordial + */ +var verifyPrimordialProperty = verifyProperty; -- Gitee From 93d029c0ce8979a37cabed170c3372d9e3f3ee13 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 16 Jan 2025 10:10:02 +0800 Subject: [PATCH 80/93] modify array.map Signed-off-by: zhuzhihui7 --- .../prototype/map/target-array-with-non-writable-property.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/sendable/builtins/Array/prototype/map/target-array-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/map/target-array-with-non-writable-property.js index 0f9d11738b1..57300b30852 100644 --- a/test/sendable/builtins/Array/prototype/map/target-array-with-non-writable-property.js +++ b/test/sendable/builtins/Array/prototype/map/target-array-with-non-writable-property.js @@ -16,6 +16,8 @@ esid: sec-array.prototype.map description: > Non-writable properties are overwritten by CreateDataPropertyOrThrow. +features: [Symbol.species] +includes: [propertyHelper.js] ---*/ var a = [1]; -- Gitee From c320ccab9540773f963837609575adcc7d79dcbd Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 16 Jan 2025 10:53:42 +0800 Subject: [PATCH 81/93] fix remove SharedSendableArrayBuffer defined Signed-off-by: zhuzhihui7 --- .../byteLength/this-is-sharedarraybuffer.js | 10 +++++----- .../prototype/detached/detached-buffer-resizable.js | 2 +- .../prototype/detached/detached-buffer.js | 2 +- .../prototype/detached/invoked-as-accessor.js | 2 +- .../detached/this-is-sharedarraybuffer-resizable.js | 10 +++++----- .../prototype/detached/this-is-sharedarraybuffer.js | 10 +++++----- .../prototype/maxByteLength/detached-buffer.js | 2 +- .../return-maxbytelength-non-resizable.js | 2 +- .../maxByteLength/return-maxbytelength-resizable.js | 2 +- .../maxByteLength/this-is-sharedarraybuffer.js | 12 ++++++------ .../prototype/resizable/detached-buffer.js | 2 +- .../prototype/resizable/return-resizable.js | 2 +- .../prototype/resizable/this-is-sharedarraybuffer.js | 12 ++++++------ .../prototype/resize/new-length-excessive.js | 2 +- .../prototype/resize/new-length-negative.js | 2 +- .../prototype/resize/new-length-non-number.js | 2 +- .../ArrayBuffer/prototype/resize/resize-grow.js | 2 +- .../resize/resize-same-size-zero-explicit.js | 2 +- .../resize/resize-same-size-zero-implicit.js | 2 +- .../ArrayBuffer/prototype/resize/resize-same-size.js | 2 +- .../prototype/resize/resize-shrink-zero-explicit.js | 2 +- .../prototype/resize/resize-shrink-zero-implicit.js | 2 +- .../ArrayBuffer/prototype/resize/resize-shrink.js | 2 +- .../ArrayBuffer/prototype/resize/this-is-detached.js | 2 +- .../prototype/resize/this-is-sharedarraybuffer.js | 10 +++++----- .../prototype/slice/this-is-sharedarraybuffer.js | 8 ++++---- .../transfer/from-fixed-to-larger-no-resizable.js | 2 +- .../prototype/transfer/from-fixed-to-larger.js | 2 +- .../transfer/from-fixed-to-same-no-resizable.js | 2 +- .../prototype/transfer/from-fixed-to-same.js | 2 +- .../transfer/from-fixed-to-smaller-no-resizable.js | 2 +- .../prototype/transfer/from-fixed-to-smaller.js | 2 +- .../transfer/from-fixed-to-zero-no-resizable.js | 2 +- .../prototype/transfer/from-fixed-to-zero.js | 2 +- .../prototype/transfer/from-resizable-to-larger.js | 2 +- .../prototype/transfer/from-resizable-to-same.js | 2 +- .../prototype/transfer/from-resizable-to-smaller.js | 2 +- .../prototype/transfer/from-resizable-to-zero.js | 2 +- .../prototype/transfer/new-length-non-number.js | 2 +- .../prototype/transfer/this-is-detached.js | 2 +- .../prototype/transfer/this-is-sharedarraybuffer.js | 10 +++++----- .../transferToFixedLength/new-length-non-number.js | 2 +- .../transferToFixedLength/this-is-detached.js | 2 +- .../this-is-sharedarraybuffer.js | 10 +++++----- 44 files changed, 81 insertions(+), 81 deletions(-) diff --git a/test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js index 52908e1d623..22a5422b9d5 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/byteLength/this-is-sharedarraybuffer.js @@ -15,8 +15,8 @@ /*--- esid: sec-get-sendableArraybuffer.prototype.bytelength -description: Throws a TypeError exception when `this` is a SharedSendableArrayBuffer -features: [align-detached-buffer-semantics-with-web-reality, SharedSendableArrayBuffer] +description: Throws a TypeError exception when `this` is a SharedArrayBuffer +features: [align-detached-buffer-semantics-with-web-reality, SharedArrayBuffer] ---*/ var byteLength = Object.getOwnPropertyDescriptor( @@ -24,13 +24,13 @@ var byteLength = Object.getOwnPropertyDescriptor( ); var getter = byteLength.get; -var sab = new SharedSendableArrayBuffer(4); +var sab = new SharedArrayBuffer(4); assert.throws(TypeError, function() { getter.call(sab); -}, "`this` cannot be a SharedSendableArrayBuffer"); +}, "`this` cannot be a SharedArrayBuffer"); assert.throws(TypeError, function() { Object.defineProperties(sab, { byteLength }); sab.byteLength; -}, "`this` cannot be a SharedSendableArrayBuffer"); +}, "`this` cannot be a SharedArrayBuffer"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer-resizable.js index eae057d8e4f..9b48ac93c82 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer-resizable.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer-resizable.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. Return IsDetachedBuffer(O). includes: [detachArrayBuffer.js] features: [SendableArrayBuffer, arraybuffer-transfer, resizable-arraybuffer] diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer.js index ba779d83d5b..e341d27c217 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/detached-buffer.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. Return IsDetachedBuffer(O). includes: [detachArrayBuffer.js] diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/invoked-as-accessor.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/invoked-as-accessor.js index 88cfd0cd309..41dbb5e837e 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/detached/invoked-as-accessor.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/invoked-as-accessor.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. Return IsDetachedBuffer(O). features: [SendableArrayBuffer, arraybuffer-transfer] diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer-resizable.js index 80ae69657d1..265f890bebd 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer-resizable.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer-resizable.js @@ -15,15 +15,15 @@ /*--- esid: sec-get-sendableArraybuffer.prototype.detached -description: Throws a TypeError exception when `this` is a resizable SharedSendableArrayBuffer +description: Throws a TypeError exception when `this` is a resizable SharedArrayBuffer info: | get SendableArrayBuffer.prototype.detached 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. [...] -features: [SharedSendableArrayBuffer, SendableArrayBuffer, arraybuffer-transfer] +features: [SharedArrayBuffer, SendableArrayBuffer, arraybuffer-transfer] ---*/ var detached = Object.getOwnPropertyDescriptor( @@ -31,10 +31,10 @@ var detached = Object.getOwnPropertyDescriptor( ); var getter = detached.get; -var sab = new SharedSendableArrayBuffer(4); +var sab = new SharedArrayBuffer(4); assert.sameValue(typeof getter, "function"); assert.throws(TypeError, function() { getter.call(sab); -}, "`this` cannot be a SharedSendableArrayBuffer"); +}, "`this` cannot be a SharedArrayBuffer"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer.js index cd515712a45..2efa28853d8 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/detached/this-is-sharedarraybuffer.js @@ -15,15 +15,15 @@ /*--- esid: sec-get-sendableArraybuffer.prototype.detached -description: Throws a TypeError exception when `this` is a SharedSendableArrayBuffer +description: Throws a TypeError exception when `this` is a SharedArrayBuffer info: | get SendableArrayBuffer.prototype.detached 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. [...] -features: [SharedSendableArrayBuffer, SendableArrayBuffer, arraybuffer-transfer] +features: [SharedArrayBuffer, SendableArrayBuffer, arraybuffer-transfer] ---*/ var detached = Object.getOwnPropertyDescriptor( @@ -31,10 +31,10 @@ var detached = Object.getOwnPropertyDescriptor( ); var getter = detached.get; -var sab = new SharedSendableArrayBuffer(4); +var sab = new SharedArrayBuffer(4); assert.sameValue(typeof getter, "function"); assert.throws(TypeError, function() { getter.call(sab); -}, "`this` cannot be a SharedSendableArrayBuffer"); +}, "`this` cannot be a SharedArrayBuffer"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/detached-buffer.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/detached-buffer.js index 1b72a7b4696..80bf7bfd706 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/detached-buffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/detached-buffer.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, return +0𝔽. [...] includes: [detachArrayBuffer.js] diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-non-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-non-resizable.js index 80f798f1a3c..e7deeb0fc13 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-non-resizable.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-non-resizable.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, return +0𝔽. 5. If IsResizableSendableArrayBuffer(O) is true, then [...] diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-resizable.js index 10c64eff211..3529ea80547 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-resizable.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/return-maxbytelength-resizable.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, return +0𝔽. 5. If IsResizableSendableArrayBuffer(O) is true, then a. Let length be O.[[SendableArrayBufferMaxByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-is-sharedarraybuffer.js index c49c8b66475..885b589e94d 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-is-sharedarraybuffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/maxByteLength/this-is-sharedarraybuffer.js @@ -15,15 +15,15 @@ /*--- esid: sec-get-sendableArraybuffer.prototype.maxbytelength -description: Throws a TypeError exception when `this` is a SharedSendableArrayBuffer +description: Throws a TypeError exception when `this` is a SharedArrayBuffer info: | get SendableArrayBuffer.prototype.maxByteLength 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. [...] -features: [SharedSendableArrayBuffer, resizable-arraybuffer] +features: [SharedArrayBuffer, resizable-arraybuffer] ---*/ var maxByteLength = Object.getOwnPropertyDescriptor( @@ -31,16 +31,16 @@ var maxByteLength = Object.getOwnPropertyDescriptor( ); var getter = maxByteLength.get; -var sab = new SharedSendableArrayBuffer(4); +var sab = new SharedArrayBuffer(4); assert.sameValue(typeof getter, "function"); assert.throws(TypeError, function() { getter.call(sab); -}, "`this` cannot be a SharedSendableArrayBuffer"); +}, "`this` cannot be a SharedArrayBuffer"); Object.defineProperties(sab, { maxByteLength: maxByteLength }); assert.throws(TypeError, function() { sab.maxByteLength; -}, "`this` cannot be a SharedSendableArrayBuffer"); +}, "`this` cannot be a SharedArrayBuffer"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resizable/detached-buffer.js b/test/sendable/builtins/ArrayBuffer/prototype/resizable/detached-buffer.js index 4163a7e5e70..805bbd8e866 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resizable/detached-buffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resizable/detached-buffer.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. Return IsResizableSendableArrayBuffer(O). IsResizableSendableArrayBuffer ( arrayBuffer ) diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resizable/return-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/resizable/return-resizable.js index 797a50ee389..eb78ff9d3c4 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resizable/return-resizable.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resizable/return-resizable.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. Return IsResizableSendableArrayBuffer(O). IsResizableSendableArrayBuffer ( arrayBuffer ) diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resizable/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/resizable/this-is-sharedarraybuffer.js index babf9b5759d..87b0088eaed 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resizable/this-is-sharedarraybuffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resizable/this-is-sharedarraybuffer.js @@ -15,15 +15,15 @@ /*--- esid: sec-get-sendableArraybuffer.prototype.resizable -description: Throws a TypeError exception when `this` is a SharedSendableArrayBuffer +description: Throws a TypeError exception when `this` is a SharedArrayBuffer info: | get SendableArrayBuffer.prototype.resizable 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. [...] -features: [SharedSendableArrayBuffer, resizable-arraybuffer] +features: [SharedArrayBuffer, resizable-arraybuffer] ---*/ var resizable = Object.getOwnPropertyDescriptor( @@ -31,16 +31,16 @@ var resizable = Object.getOwnPropertyDescriptor( ); var getter = resizable.get; -var sab = new SharedSendableArrayBuffer(4); +var sab = new SharedArrayBuffer(4); assert.sameValue(typeof getter, "function"); assert.throws(TypeError, function() { getter.call(sab); -}, "`this` cannot be a SharedSendableArrayBuffer"); +}, "`this` cannot be a SharedArrayBuffer"); Object.defineProperties(sab, { resizable: resizable }); assert.throws(TypeError, function() { sab.resizable; -}, "`this` cannot be a SharedSendableArrayBuffer"); +}, "`this` cannot be a SharedArrayBuffer"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-excessive.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-excessive.js index a2ab576da2d..d6043b55bc4 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-excessive.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-excessive.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-negative.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-negative.js index 6d04b0c7057..be51dbc967e 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-negative.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-negative.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-non-number.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-non-number.js index 7ece174e3b9..745a6282fcb 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-non-number.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/new-length-non-number.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). [...] diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-grow.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-grow.js index 125a32846d3..96a336a5074 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-grow.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-grow.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-explicit.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-explicit.js index 103c6620eb1..fafd0a5c7ab 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-explicit.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-explicit.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-implicit.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-implicit.js index c540065630c..6636e700540 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-implicit.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size-zero-implicit.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size.js index 6eb5a3f8563..a8705402c6f 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-same-size.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-explicit.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-explicit.js index ae7881bd274..44be46a8945 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-explicit.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-explicit.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-implicit.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-implicit.js index 6c301054f8f..91aa1718f6f 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-implicit.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink-zero-implicit.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink.js index ddd13e6ca72..1ccab5add63 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/resize-shrink.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. Let newByteLength be ? ToIntegerOrInfinity(newLength). 6. If newByteLength < 0 or newByteLength > O.[[SendableArrayBufferMaxByteLength]], diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-detached.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-detached.js index db00981e7d0..29b07f73c3d 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-detached.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-detached.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. [...] includes: [detachArrayBuffer.js] diff --git a/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-sharedarraybuffer.js index bb3ceabb484..3276d772cd5 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-sharedarraybuffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/resize/this-is-sharedarraybuffer.js @@ -15,19 +15,19 @@ /*--- esid: sec-sendableArraybuffer.prototype.resize -description: Throws a TypeError if `this` value is a SharedSendableArrayBuffer +description: Throws a TypeError if `this` value is a SharedArrayBuffer info: | SendableArrayBuffer.prototype.resize ( newLength ) 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferMaxByteLength]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. [...] -features: [SharedSendableArrayBuffer, resizable-arraybuffer] +features: [SharedArrayBuffer, resizable-arraybuffer] ---*/ -var sab = new SharedSendableArrayBuffer(0); +var sab = new SharedArrayBuffer(0); assert.throws(TypeError, function() { SendableArrayBuffer.prototype.resize.call(sab); -}, '`this` value cannot be a SharedSendableArrayBuffer'); +}, '`this` value cannot be a SharedArrayBuffer'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer.js index 13e97ade6b8..b3da19c3d69 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/slice/this-is-sharedarraybuffer.js @@ -16,11 +16,11 @@ /*--- esid: sec-sendableArraybuffer.prototype.slice description: > - Throws a TypeError if `this` is a SharedSendableArrayBuffer -features: [SharedSendableArrayBuffer] + Throws a TypeError if `this` is a SharedArrayBuffer +features: [SharedArrayBuffer] ---*/ assert.throws(TypeError, function() { - var sab = new SharedSendableArrayBuffer(0); + var sab = new SharedArrayBuffer(0); SendableArrayBuffer.prototype.slice.call(sab); -}, "`this` value cannot be a SharedSendableArrayBuffer"); +}, "`this` value cannot be a SharedArrayBuffer"); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger-no-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger-no-resizable.js index 26a3c514be7..dbefae9e4ad 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger-no-resizable.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger-no-resizable.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. If newLength is undefined, let newByteLength be O.[[SendableArrayBufferByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger.js index 71b6876214b..bc3e8b0e8f9 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-larger.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. If newLength is undefined, let newByteLength be O.[[SendableArrayBufferByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same-no-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same-no-resizable.js index 17d679da5b6..ecb14cfe896 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same-no-resizable.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same-no-resizable.js @@ -23,7 +23,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. If newLength is undefined, let newByteLength be O.[[SendableArrayBufferByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same.js index e8760a79688..8b3a30970bf 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-same.js @@ -23,7 +23,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. If newLength is undefined, let newByteLength be O.[[SendableArrayBufferByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller-no-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller-no-resizable.js index 1ebdb28ce93..950bd368955 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller-no-resizable.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller-no-resizable.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. If newLength is undefined, let newByteLength be O.[[SendableArrayBufferByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller.js index 87197b259a6..42e8fc5270a 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-smaller.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. If newLength is undefined, let newByteLength be O.[[SendableArrayBufferByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero-no-resizable.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero-no-resizable.js index 2a600e96ee8..1d8c9379976 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero-no-resizable.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero-no-resizable.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. If newLength is undefined, let newByteLength be O.[[SendableArrayBufferByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero.js index a4e43e40fdb..f09826436ad 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-fixed-to-zero.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. If newLength is undefined, let newByteLength be O.[[SendableArrayBufferByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-larger.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-larger.js index 516389f9b09..8b96d05156b 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-larger.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-larger.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. If newLength is undefined, let newByteLength be O.[[SendableArrayBufferByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-same.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-same.js index 854eacefa29..4278d15b326 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-same.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-same.js @@ -23,7 +23,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. If newLength is undefined, let newByteLength be O.[[SendableArrayBufferByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-smaller.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-smaller.js index c83e80485e7..0941b941855 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-smaller.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-smaller.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. If newLength is undefined, let newByteLength be O.[[SendableArrayBufferByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-zero.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-zero.js index 6a164837cd2..92db62b4dc6 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-zero.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/from-resizable-to-zero.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. If newLength is undefined, let newByteLength be O.[[SendableArrayBufferByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/new-length-non-number.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/new-length-non-number.js index 31e73eaf021..19b1c0247ef 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/new-length-non-number.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/new-length-non-number.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. If newLength is undefined, let newByteLength be O.[[SendableArrayBufferByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-detached.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-detached.js index a86dc705992..896b1a387cb 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-detached.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-detached.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. [...] includes: [detachArrayBuffer.js] diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-sharedarraybuffer.js index 97ff67dfd6e..fa2e4220c26 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-sharedarraybuffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transfer/this-is-sharedarraybuffer.js @@ -15,19 +15,19 @@ /*--- esid: sec-sendableArraybuffer.prototype.transfer -description: Throws a TypeError if `this` value is a SharedSendableArrayBuffer +description: Throws a TypeError if `this` value is a SharedArrayBuffer info: | SendableArrayBuffer.prototype.transfer ( [ newLength ] ) 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. [...] -features: [SharedSendableArrayBuffer, arraybuffer-transfer] +features: [SharedArrayBuffer, arraybuffer-transfer] ---*/ -var sab = new SharedSendableArrayBuffer(0); +var sab = new SharedArrayBuffer(0); assert.throws(TypeError, function() { SendableArrayBuffer.prototype.transfer.call(sab); -}, '`this` value cannot be a SharedSendableArrayBuffer'); +}, '`this` value cannot be a SharedArrayBuffer'); diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/new-length-non-number.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/new-length-non-number.js index 96668ed1b57..c73bf009520 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/new-length-non-number.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/new-length-non-number.js @@ -21,7 +21,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. 5. If newLength is undefined, let newByteLength be O.[[SendableArrayBufferByteLength]]. diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-detached.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-detached.js index 53ea61914f6..149dc9f33ad 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-detached.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-detached.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. 4. If IsDetachedBuffer(O) is true, throw a TypeError exception. [...] includes: [detachArrayBuffer.js] diff --git a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-sharedarraybuffer.js b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-sharedarraybuffer.js index 36afb320409..8545c16eeb8 100644 --- a/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-sharedarraybuffer.js +++ b/test/sendable/builtins/ArrayBuffer/prototype/transferToFixedLength/this-is-sharedarraybuffer.js @@ -15,19 +15,19 @@ /*--- esid: sec-sendableArraybuffer.prototype.transfertofixedlength -description: Throws a TypeError if `this` value is a SharedSendableArrayBuffer +description: Throws a TypeError if `this` value is a SharedArrayBuffer info: | SendableArrayBuffer.prototype.transferToFixedLength ( [ newLength ] ) 1. Let O be the this value. 2. Perform ? RequireInternalSlot(O, [[SendableArrayBufferData]]). - 3. If IsSharedSendableArrayBuffer(O) is true, throw a TypeError exception. + 3. If IsSharedArrayBuffer(O) is true, throw a TypeError exception. [...] -features: [SharedSendableArrayBuffer, arraybuffer-transfer] +features: [SharedArrayBuffer, arraybuffer-transfer] ---*/ -var sab = new SharedSendableArrayBuffer(0); +var sab = new SharedArrayBuffer(0); assert.throws(TypeError, function() { SendableArrayBuffer.prototype.transferToFixedLength.call(sab); -}, '`this` value cannot be a SharedSendableArrayBuffer'); +}, '`this` value cannot be a SharedArrayBuffer'); -- Gitee From a559c1754cc8bc4220b4d280a95d3001fc3f605b Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 16 Jan 2025 14:27:40 +0800 Subject: [PATCH 82/93] fix SendableTypedArray is not defined Signed-off-by: zhuzhihui7 --- harness/sendableTypedArray.js | 134 ++++++++++++++++++++ test/sendable/builtins/TypedArray/length.js | 2 +- test/sendable/builtins/TypedArray/name.js | 2 +- 3 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 harness/sendableTypedArray.js diff --git a/harness/sendableTypedArray.js b/harness/sendableTypedArray.js new file mode 100644 index 00000000000..154af65e840 --- /dev/null +++ b/harness/sendableTypedArray.js @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to assert the correctness of SendableTypedArray objects. +defines: + - typedArrayConstructors + - floatArrayConstructors + - intArrayConstructors + - SendableTypedArray + - testWithTypedArrayConstructors + - testWithAtomicsFriendlyTypedArrayConstructors + - testWithNonAtomicsFriendlyTypedArrayConstructors + - testTypedArrayConversions +---*/ + +/** + * Array containing every typed array constructor. + */ +var typedArrayConstructors = [ + Float64Array, + Float32Array, + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + Uint8ClampedArray +]; + +var floatArrayConstructors = typedArrayConstructors.slice(0, 2); +var intArrayConstructors = typedArrayConstructors.slice(2, 7); + +/** + * The %SendableTypedArray% intrinsic constructor function. + */ +var SendableTypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Callback for testing a typed array constructor. + * + * @callback typedArrayConstructorCallback + * @param {Function} Constructor the constructor object to test with. + */ + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithTypedArrayConstructors(f, selected) { + var constructors = selected || typedArrayConstructors; + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} + +/** + * Calls the provided function for every non-"Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithNonAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Float64Array, + Float32Array, + Uint8ClampedArray + ]); +} + +/** + * Calls the provided function for every "Atomics Friendly" typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithAtomicsFriendlyTypedArrayConstructors(f) { + testWithTypedArrayConstructors(f, [ + Int32Array, + Int16Array, + Int8Array, + Uint32Array, + Uint16Array, + Uint8Array, + ]); +} + +/** + * Helper for conversion operations on TypedArrays, the expected values + * properties are indexed in order to match the respective value for each + * SendableTypedArray constructor + * @param {Function} fn - the function to call for each constructor and value. + * will be called with the constructor, value, expected + * value, and a initial value that can be used to avoid + * a false positive with an equivalent expected value. + */ +function testTypedArrayConversions(byteConversionValues, fn) { + var values = byteConversionValues.values; + var expected = byteConversionValues.expected; + + testWithTypedArrayConstructors(function(TA) { + var name = TA.name.slice(0, -5); + + return values.forEach(function(value, index) { + var exp = expected[name][index]; + var initial = 0; + if (exp === 0) { + initial = 1; + } + fn(TA, value, exp, initial); + }); + }); +} diff --git a/test/sendable/builtins/TypedArray/length.js b/test/sendable/builtins/TypedArray/length.js index 5e3543d219a..fe5a78e2514 100644 --- a/test/sendable/builtins/TypedArray/length.js +++ b/test/sendable/builtins/TypedArray/length.js @@ -29,7 +29,7 @@ info: | Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/name.js b/test/sendable/builtins/TypedArray/name.js index 122943ba67e..2f326dc9f66 100644 --- a/test/sendable/builtins/TypedArray/name.js +++ b/test/sendable/builtins/TypedArray/name.js @@ -27,7 +27,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ -- Gitee From f77dd4b5b0dfcd940aab45d3e6c8e0cf3974f966 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 16 Jan 2025 14:47:36 +0800 Subject: [PATCH 83/93] fix SendableTypedArray is not defined Signed-off-by: zhuzhihui7 --- test/sendable/builtins/TypedArray/Symbol.species/length.js | 2 +- test/sendable/builtins/TypedArray/Symbol.species/name.js | 2 +- test/sendable/builtins/TypedArray/Symbol.species/prop-desc.js | 2 +- test/sendable/builtins/TypedArray/Symbol.species/result.js | 2 +- .../builtins/TypedArray/from/arylk-get-length-error.js | 2 +- .../builtins/TypedArray/from/arylk-to-length-error.js | 2 +- test/sendable/builtins/TypedArray/from/invoked-as-func.js | 2 +- test/sendable/builtins/TypedArray/from/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/from/iter-access-error.js | 2 +- test/sendable/builtins/TypedArray/from/iter-invoke-error.js | 2 +- test/sendable/builtins/TypedArray/from/iter-next-error.js | 2 +- .../builtins/TypedArray/from/iter-next-value-error.js | 2 +- test/sendable/builtins/TypedArray/from/length.js | 2 +- .../builtins/TypedArray/from/mapfn-is-not-callable.js | 2 +- test/sendable/builtins/TypedArray/from/name.js | 2 +- test/sendable/builtins/TypedArray/from/not-a-constructor.js | 2 +- test/sendable/builtins/TypedArray/from/prop-desc.js | 2 +- .../builtins/TypedArray/from/this-is-not-constructor.js | 2 +- test/sendable/builtins/TypedArray/invoked.js | 2 +- test/sendable/builtins/TypedArray/of/invoked-as-func.js | 2 +- test/sendable/builtins/TypedArray/of/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/of/length.js | 2 +- test/sendable/builtins/TypedArray/of/name.js | 2 +- test/sendable/builtins/TypedArray/of/not-a-constructor.js | 2 +- test/sendable/builtins/TypedArray/of/prop-desc.js | 2 +- .../builtins/TypedArray/of/this-is-not-constructor.js | 2 +- test/sendable/builtins/TypedArray/prototype.js | 2 +- .../sendable/builtins/TypedArray/prototype/Symbol.iterator.js | 2 +- .../TypedArray/prototype/Symbol.iterator/not-a-constructor.js | 2 +- .../prototype/Symbol.toStringTag/detached-buffer.js | 2 +- .../prototype/Symbol.toStringTag/invoked-as-accessor.js | 2 +- .../prototype/Symbol.toStringTag/invoked-as-func.js | 2 +- .../TypedArray/prototype/Symbol.toStringTag/length.js | 2 +- .../builtins/TypedArray/prototype/Symbol.toStringTag/name.js | 2 +- .../TypedArray/prototype/Symbol.toStringTag/prop-desc.js | 2 +- .../prototype/Symbol.toStringTag/return-typedarrayname.js | 2 +- .../Symbol.toStringTag/this-has-no-typedarrayname-internal.js | 2 +- .../prototype/Symbol.toStringTag/this-is-not-object.js | 2 +- .../TypedArray/prototype/at/index-argument-tointeger.js | 2 +- .../at/index-non-numeric-argument-tointeger-invalid.js | 2 +- .../prototype/at/index-non-numeric-argument-tointeger.js | 2 +- test/sendable/builtins/TypedArray/prototype/at/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/at/name.js | 2 +- test/sendable/builtins/TypedArray/prototype/at/prop-desc.js | 2 +- .../prototype/at/return-abrupt-from-this-out-of-bounds.js | 2 +- .../TypedArray/prototype/at/return-abrupt-from-this.js | 2 +- .../TypedArray/prototype/at/returns-item-relative-index.js | 2 +- .../sendable/builtins/TypedArray/prototype/at/returns-item.js | 2 +- .../at/returns-undefined-for-holes-in-sparse-arrays.js | 2 +- .../prototype/at/returns-undefined-for-out-of-range-index.js | 2 +- .../builtins/TypedArray/prototype/buffer/detached-buffer.js | 2 +- .../TypedArray/prototype/buffer/invoked-as-accessor.js | 2 +- .../builtins/TypedArray/prototype/buffer/invoked-as-func.js | 2 +- test/sendable/builtins/TypedArray/prototype/buffer/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/buffer/name.js | 2 +- .../builtins/TypedArray/prototype/buffer/prop-desc.js | 2 +- .../builtins/TypedArray/prototype/buffer/return-buffer.js | 2 +- .../prototype/buffer/this-has-no-typedarrayname-internal.js | 2 +- .../TypedArray/prototype/buffer/this-inherits-typedarray.js | 2 +- .../TypedArray/prototype/buffer/this-is-not-object.js | 2 +- .../TypedArray/prototype/byteLength/detached-buffer.js | 2 +- .../TypedArray/prototype/byteLength/invoked-as-accessor.js | 2 +- .../TypedArray/prototype/byteLength/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/byteLength/length.js | 2 +- .../sendable/builtins/TypedArray/prototype/byteLength/name.js | 2 +- .../builtins/TypedArray/prototype/byteLength/prop-desc.js | 2 +- .../prototype/byteLength/resizable-array-buffer-auto.js | 2 +- .../prototype/byteLength/resizable-array-buffer-fixed.js | 2 +- .../TypedArray/prototype/byteLength/return-bytelength.js | 2 +- .../byteLength/this-has-no-typedarrayname-internal.js | 2 +- .../TypedArray/prototype/byteLength/this-is-not-object.js | 2 +- .../TypedArray/prototype/byteOffset/detached-buffer.js | 2 +- .../TypedArray/prototype/byteOffset/invoked-as-accessor.js | 2 +- .../TypedArray/prototype/byteOffset/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/byteOffset/length.js | 2 +- .../sendable/builtins/TypedArray/prototype/byteOffset/name.js | 2 +- .../builtins/TypedArray/prototype/byteOffset/prop-desc.js | 2 +- .../prototype/byteOffset/resizable-array-buffer-auto.js | 2 +- .../prototype/byteOffset/resizable-array-buffer-fixed.js | 2 +- .../TypedArray/prototype/byteOffset/return-byteoffset.js | 2 +- .../byteOffset/this-has-no-typedarrayname-internal.js | 2 +- .../TypedArray/prototype/byteOffset/this-is-not-object.js | 2 +- test/sendable/builtins/TypedArray/prototype/constructor.js | 2 +- .../builtins/TypedArray/prototype/copyWithin/bit-precision.js | 2 +- .../builtins/TypedArray/prototype/copyWithin/byteoffset.js | 2 +- .../copyWithin/coerced-values-end-detached-prototype.js | 2 +- .../prototype/copyWithin/coerced-values-end-detached.js | 2 +- .../TypedArray/prototype/copyWithin/coerced-values-end.js | 2 +- .../prototype/copyWithin/coerced-values-start-detached.js | 2 +- .../TypedArray/prototype/copyWithin/coerced-values-start.js | 2 +- .../TypedArray/prototype/copyWithin/coerced-values-target.js | 2 +- .../TypedArray/prototype/copyWithin/detached-buffer.js | 2 +- .../prototype/copyWithin/get-length-ignores-length-prop.js | 2 +- .../TypedArray/prototype/copyWithin/invoked-as-func.js | 2 +- .../TypedArray/prototype/copyWithin/invoked-as-method.js | 2 +- .../builtins/TypedArray/prototype/copyWithin/length.js | 2 +- .../sendable/builtins/TypedArray/prototype/copyWithin/name.js | 2 +- .../builtins/TypedArray/prototype/copyWithin/negative-end.js | 2 +- .../prototype/copyWithin/negative-out-of-bounds-end.js | 2 +- .../prototype/copyWithin/negative-out-of-bounds-start.js | 2 +- .../prototype/copyWithin/negative-out-of-bounds-target.js | 2 +- .../TypedArray/prototype/copyWithin/negative-start.js | 2 +- .../TypedArray/prototype/copyWithin/negative-target.js | 2 +- .../prototype/copyWithin/non-negative-out-of-bounds-end.js | 2 +- .../copyWithin/non-negative-out-of-bounds-target-and-start.js | 2 +- .../prototype/copyWithin/non-negative-target-and-start.js | 2 +- .../prototype/copyWithin/non-negative-target-start-and-end.js | 2 +- .../TypedArray/prototype/copyWithin/not-a-constructor.js | 2 +- .../builtins/TypedArray/prototype/copyWithin/prop-desc.js | 2 +- .../prototype/copyWithin/return-abrupt-from-end-is-symbol.js | 2 +- .../TypedArray/prototype/copyWithin/return-abrupt-from-end.js | 2 +- .../copyWithin/return-abrupt-from-start-is-symbol.js | 2 +- .../prototype/copyWithin/return-abrupt-from-start.js | 2 +- .../copyWithin/return-abrupt-from-target-is-symbol.js | 2 +- .../prototype/copyWithin/return-abrupt-from-target.js | 2 +- .../copyWithin/return-abrupt-from-this-out-of-bounds.js | 2 +- .../builtins/TypedArray/prototype/copyWithin/return-this.js | 2 +- .../TypedArray/prototype/copyWithin/this-is-not-object.js | 2 +- .../prototype/copyWithin/this-is-not-typedarray-instance.js | 2 +- .../builtins/TypedArray/prototype/copyWithin/undefined-end.js | 2 +- .../builtins/TypedArray/prototype/entries/detached-buffer.js | 2 +- .../builtins/TypedArray/prototype/entries/invoked-as-func.js | 2 +- .../TypedArray/prototype/entries/invoked-as-method.js | 2 +- .../builtins/TypedArray/prototype/entries/iter-prototype.js | 2 +- test/sendable/builtins/TypedArray/prototype/entries/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/entries/name.js | 2 +- .../TypedArray/prototype/entries/not-a-constructor.js | 2 +- .../builtins/TypedArray/prototype/entries/prop-desc.js | 2 +- .../entries/return-abrupt-from-this-out-of-bounds.js | 2 +- .../builtins/TypedArray/prototype/entries/return-itor.js | 2 +- .../TypedArray/prototype/entries/this-is-not-object.js | 2 +- .../prototype/entries/this-is-not-typedarray-instance.js | 2 +- .../prototype/every/callbackfn-arguments-with-thisarg.js | 2 +- .../prototype/every/callbackfn-arguments-without-thisarg.js | 2 +- .../TypedArray/prototype/every/callbackfn-detachbuffer.js | 2 +- .../every/callbackfn-no-interaction-over-non-integer.js | 2 +- .../prototype/every/callbackfn-not-callable-throws.js | 2 +- .../prototype/every/callbackfn-not-called-on-empty.js | 2 +- .../builtins/TypedArray/prototype/every/callbackfn-resize.js | 2 +- .../every/callbackfn-return-does-not-change-instance.js | 2 +- .../TypedArray/prototype/every/callbackfn-returns-abrupt.js | 2 +- .../every/callbackfn-set-value-during-interaction.js | 2 +- .../builtins/TypedArray/prototype/every/callbackfn-this.js | 2 +- .../builtins/TypedArray/prototype/every/detached-buffer.js | 2 +- .../prototype/every/get-length-uses-internal-arraylength.js | 2 +- .../builtins/TypedArray/prototype/every/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/every/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/prototype/every/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/every/name.js | 2 +- .../builtins/TypedArray/prototype/every/not-a-constructor.js | 2 +- .../sendable/builtins/TypedArray/prototype/every/prop-desc.js | 2 +- .../prototype/every/return-abrupt-from-this-out-of-bounds.js | 2 +- .../prototype/every/returns-false-if-any-cb-returns-false.js | 2 +- .../prototype/every/returns-true-if-every-cb-returns-true.js | 2 +- .../builtins/TypedArray/prototype/every/this-is-not-object.js | 2 +- .../prototype/every/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/every/values-are-not-cached.js | 2 +- .../builtins/TypedArray/prototype/fill/coerced-end-detach.js | 2 +- .../builtins/TypedArray/prototype/fill/coerced-indexes.js | 2 +- .../TypedArray/prototype/fill/coerced-start-detach.js | 2 +- .../TypedArray/prototype/fill/coerced-value-detach.js | 2 +- .../builtins/TypedArray/prototype/fill/detached-buffer.js | 2 +- .../TypedArray/prototype/fill/fill-values-conversion-once.js | 2 +- .../fill/fill-values-conversion-operations-consistent-nan.js | 4 ++-- .../prototype/fill/fill-values-conversion-operations.js | 4 ++-- .../prototype/fill/fill-values-custom-start-and-end.js | 2 +- .../TypedArray/prototype/fill/fill-values-non-numeric.js | 2 +- .../TypedArray/prototype/fill/fill-values-relative-end.js | 2 +- .../TypedArray/prototype/fill/fill-values-relative-start.js | 2 +- .../TypedArray/prototype/fill/fill-values-symbol-throws.js | 2 +- .../builtins/TypedArray/prototype/fill/fill-values.js | 2 +- .../prototype/fill/get-length-ignores-length-prop.js | 2 +- .../builtins/TypedArray/prototype/fill/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/fill/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/prototype/fill/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/fill/name.js | 2 +- .../builtins/TypedArray/prototype/fill/not-a-constructor.js | 2 +- test/sendable/builtins/TypedArray/prototype/fill/prop-desc.js | 2 +- .../prototype/fill/return-abrupt-from-end-as-symbol.js | 2 +- .../TypedArray/prototype/fill/return-abrupt-from-end.js | 2 +- .../TypedArray/prototype/fill/return-abrupt-from-set-value.js | 2 +- .../prototype/fill/return-abrupt-from-start-as-symbol.js | 2 +- .../TypedArray/prototype/fill/return-abrupt-from-start.js | 2 +- .../prototype/fill/return-abrupt-from-this-out-of-bounds.js | 2 +- .../builtins/TypedArray/prototype/fill/return-this.js | 2 +- .../builtins/TypedArray/prototype/fill/this-is-not-object.js | 2 +- .../prototype/fill/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/filter/arraylength-internal.js | 2 +- .../prototype/filter/callbackfn-arguments-with-thisarg.js | 2 +- .../prototype/filter/callbackfn-arguments-without-thisarg.js | 2 +- .../prototype/filter/callbackfn-called-before-ctor.js | 2 +- .../prototype/filter/callbackfn-called-before-species.js | 2 +- .../TypedArray/prototype/filter/callbackfn-detachbuffer.js | 2 +- .../filter/callbackfn-no-iteration-over-non-integer.js | 2 +- .../prototype/filter/callbackfn-not-callable-throws.js | 2 +- .../prototype/filter/callbackfn-not-called-on-empty.js | 2 +- .../builtins/TypedArray/prototype/filter/callbackfn-resize.js | 2 +- .../filter/callbackfn-return-does-not-change-instance.js | 2 +- .../TypedArray/prototype/filter/callbackfn-returns-abrupt.js | 2 +- .../prototype/filter/callbackfn-set-value-during-iteration.js | 2 +- .../builtins/TypedArray/prototype/filter/callbackfn-this.js | 2 +- .../builtins/TypedArray/prototype/filter/detached-buffer.js | 2 +- .../builtins/TypedArray/prototype/filter/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/filter/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/prototype/filter/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/filter/name.js | 2 +- .../builtins/TypedArray/prototype/filter/not-a-constructor.js | 2 +- .../builtins/TypedArray/prototype/filter/prop-desc.js | 2 +- .../prototype/filter/result-does-not-share-buffer.js | 2 +- .../prototype/filter/result-empty-callbackfn-returns-false.js | 2 +- .../prototype/filter/result-full-callbackfn-returns-true.js | 2 +- .../prototype/filter/return-abrupt-from-this-out-of-bounds.js | 2 +- .../prototype/filter/speciesctor-destination-resizable.js | 2 +- .../prototype/filter/speciesctor-get-ctor-abrupt.js | 2 +- .../prototype/filter/speciesctor-get-ctor-inherited.js | 2 +- .../prototype/filter/speciesctor-get-ctor-returns-throws.js | 2 +- .../TypedArray/prototype/filter/speciesctor-get-ctor.js | 2 +- .../prototype/filter/speciesctor-get-species-abrupt.js | 2 +- .../filter/speciesctor-get-species-custom-ctor-invocation.js | 2 +- ...species-custom-ctor-length-throws-resizable-arraybuffer.js | 2 +- .../speciesctor-get-species-custom-ctor-length-throws.js | 2 +- .../filter/speciesctor-get-species-custom-ctor-length.js | 2 +- ...esctor-get-species-custom-ctor-returns-another-instance.js | 2 +- .../filter/speciesctor-get-species-custom-ctor-throws.js | 2 +- .../prototype/filter/speciesctor-get-species-custom-ctor.js | 2 +- .../filter/speciesctor-get-species-returns-throws.js | 2 +- .../filter/speciesctor-get-species-use-default-ctor.js | 2 +- .../TypedArray/prototype/filter/speciesctor-get-species.js | 2 +- .../TypedArray/prototype/filter/this-is-not-object.js | 2 +- .../prototype/filter/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/filter/values-are-not-cached.js | 2 +- .../builtins/TypedArray/prototype/filter/values-are-set.js | 2 +- .../builtins/TypedArray/prototype/find/callbackfn-resize.js | 2 +- .../builtins/TypedArray/prototype/find/detached-buffer.js | 2 +- .../prototype/find/get-length-ignores-length-prop.js | 2 +- .../builtins/TypedArray/prototype/find/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/find/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/prototype/find/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/find/name.js | 2 +- .../builtins/TypedArray/prototype/find/not-a-constructor.js | 2 +- .../TypedArray/prototype/find/predicate-call-changes-value.js | 2 +- .../TypedArray/prototype/find/predicate-call-parameters.js | 2 +- .../prototype/find/predicate-call-this-non-strict.js | 2 +- .../TypedArray/prototype/find/predicate-call-this-strict.js | 2 +- .../prototype/find/predicate-is-not-callable-throws.js | 2 +- .../TypedArray/prototype/find/predicate-may-detach-buffer.js | 2 +- .../prototype/find/predicate-not-called-on-empty-array.js | 2 +- test/sendable/builtins/TypedArray/prototype/find/prop-desc.js | 2 +- .../prototype/find/return-abrupt-from-predicate-call.js | 2 +- .../prototype/find/return-abrupt-from-this-out-of-bounds.js | 2 +- .../find/return-found-value-predicate-result-is-true.js | 2 +- .../find/return-undefined-if-predicate-returns-false-value.js | 2 +- .../builtins/TypedArray/prototype/find/this-is-not-object.js | 2 +- .../prototype/find/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/findIndex/callbackfn-resize.js | 2 +- .../TypedArray/prototype/findIndex/detached-buffer.js | 2 +- .../prototype/findIndex/get-length-ignores-length-prop.js | 2 +- .../TypedArray/prototype/findIndex/invoked-as-func.js | 2 +- .../TypedArray/prototype/findIndex/invoked-as-method.js | 2 +- .../builtins/TypedArray/prototype/findIndex/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/findIndex/name.js | 2 +- .../TypedArray/prototype/findIndex/not-a-constructor.js | 2 +- .../prototype/findIndex/predicate-call-changes-value.js | 2 +- .../prototype/findIndex/predicate-call-parameters.js | 2 +- .../prototype/findIndex/predicate-call-this-non-strict.js | 2 +- .../prototype/findIndex/predicate-call-this-strict.js | 2 +- .../prototype/findIndex/predicate-is-not-callable-throws.js | 2 +- .../prototype/findIndex/predicate-may-detach-buffer.js | 2 +- .../findIndex/predicate-not-called-on-empty-array.js | 2 +- .../builtins/TypedArray/prototype/findIndex/prop-desc.js | 2 +- .../prototype/findIndex/return-abrupt-from-predicate-call.js | 2 +- .../findIndex/return-abrupt-from-this-out-of-bounds.js | 2 +- .../findIndex/return-index-predicate-result-is-true.js | 2 +- .../return-negative-one-if-predicate-returns-false-value.js | 2 +- .../TypedArray/prototype/findIndex/this-is-not-object.js | 2 +- .../prototype/findIndex/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/findLast/callbackfn-resize.js | 2 +- .../builtins/TypedArray/prototype/findLast/detached-buffer.js | 2 +- .../prototype/findLast/get-length-ignores-length-prop.js | 2 +- .../builtins/TypedArray/prototype/findLast/invoked-as-func.js | 2 +- .../TypedArray/prototype/findLast/invoked-as-method.js | 2 +- .../sendable/builtins/TypedArray/prototype/findLast/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/findLast/name.js | 2 +- .../TypedArray/prototype/findLast/not-a-constructor.js | 2 +- .../prototype/findLast/predicate-call-changes-value.js | 2 +- .../prototype/findLast/predicate-call-parameters.js | 2 +- .../prototype/findLast/predicate-call-this-non-strict.js | 2 +- .../prototype/findLast/predicate-call-this-strict.js | 2 +- .../prototype/findLast/predicate-is-not-callable-throws.js | 2 +- .../prototype/findLast/predicate-may-detach-buffer.js | 2 +- .../prototype/findLast/predicate-not-called-on-empty-array.js | 2 +- .../builtins/TypedArray/prototype/findLast/prop-desc.js | 2 +- .../prototype/findLast/return-abrupt-from-predicate-call.js | 2 +- .../findLast/return-abrupt-from-this-out-of-bounds.js | 2 +- .../findLast/return-found-value-predicate-result-is-true.js | 2 +- .../return-undefined-if-predicate-returns-false-value.js | 2 +- .../TypedArray/prototype/findLast/this-is-not-object.js | 2 +- .../prototype/findLast/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/findLastIndex/callbackfn-resize.js | 2 +- .../TypedArray/prototype/findLastIndex/detached-buffer.js | 2 +- .../prototype/findLastIndex/get-length-ignores-length-prop.js | 2 +- .../TypedArray/prototype/findLastIndex/invoked-as-func.js | 2 +- .../TypedArray/prototype/findLastIndex/invoked-as-method.js | 2 +- .../builtins/TypedArray/prototype/findLastIndex/length.js | 2 +- .../builtins/TypedArray/prototype/findLastIndex/name.js | 2 +- .../TypedArray/prototype/findLastIndex/not-a-constructor.js | 2 +- .../prototype/findLastIndex/predicate-call-changes-value.js | 2 +- .../prototype/findLastIndex/predicate-call-parameters.js | 2 +- .../prototype/findLastIndex/predicate-call-this-non-strict.js | 2 +- .../prototype/findLastIndex/predicate-call-this-strict.js | 2 +- .../findLastIndex/predicate-is-not-callable-throws.js | 2 +- .../prototype/findLastIndex/predicate-may-detach-buffer.js | 2 +- .../findLastIndex/predicate-not-called-on-empty-array.js | 2 +- .../builtins/TypedArray/prototype/findLastIndex/prop-desc.js | 2 +- .../findLastIndex/return-abrupt-from-predicate-call.js | 2 +- .../findLastIndex/return-abrupt-from-this-out-of-bounds.js | 2 +- .../findLastIndex/return-index-predicate-result-is-true.js | 2 +- .../return-negative-one-if-predicate-returns-false-value.js | 2 +- .../TypedArray/prototype/findLastIndex/this-is-not-object.js | 2 +- .../findLastIndex/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/forEach/arraylength-internal.js | 2 +- .../prototype/forEach/callbackfn-arguments-with-thisarg.js | 2 +- .../prototype/forEach/callbackfn-arguments-without-thisarg.js | 2 +- .../TypedArray/prototype/forEach/callbackfn-detachbuffer.js | 2 +- .../prototype/forEach/callbackfn-is-not-callable.js | 2 +- .../forEach/callbackfn-no-interaction-over-non-integer.js | 2 +- .../prototype/forEach/callbackfn-not-called-on-empty.js | 2 +- .../TypedArray/prototype/forEach/callbackfn-resize.js | 2 +- .../forEach/callbackfn-return-does-not-change-instance.js | 2 +- .../TypedArray/prototype/forEach/callbackfn-returns-abrupt.js | 2 +- .../forEach/callbackfn-set-value-during-interaction.js | 2 +- .../builtins/TypedArray/prototype/forEach/callbackfn-this.js | 2 +- .../builtins/TypedArray/prototype/forEach/detached-buffer.js | 2 +- .../builtins/TypedArray/prototype/forEach/invoked-as-func.js | 2 +- .../TypedArray/prototype/forEach/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/prototype/forEach/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/forEach/name.js | 2 +- .../TypedArray/prototype/forEach/not-a-constructor.js | 2 +- .../builtins/TypedArray/prototype/forEach/prop-desc.js | 2 +- .../forEach/return-abrupt-from-this-out-of-bounds.js | 2 +- .../TypedArray/prototype/forEach/returns-undefined.js | 2 +- .../TypedArray/prototype/forEach/this-is-not-object.js | 2 +- .../prototype/forEach/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/forEach/values-are-not-cached.js | 2 +- ...detached-buffer-during-fromIndex-returns-false-for-zero.js | 2 +- ...ched-buffer-during-fromIndex-returns-true-for-undefined.js | 2 +- .../builtins/TypedArray/prototype/includes/detached-buffer.js | 2 +- .../fromIndex-equal-or-greater-length-returns-false.js | 2 +- .../TypedArray/prototype/includes/fromIndex-infinity.js | 2 +- .../TypedArray/prototype/includes/fromIndex-minus-zero.js | 2 +- .../includes/get-length-uses-internal-arraylength.js | 2 +- .../builtins/TypedArray/prototype/includes/invoked-as-func.js | 2 +- .../TypedArray/prototype/includes/invoked-as-method.js | 2 +- .../prototype/includes/length-zero-returns-false.js | 2 +- .../sendable/builtins/TypedArray/prototype/includes/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/includes/name.js | 2 +- .../TypedArray/prototype/includes/not-a-constructor.js | 2 +- .../builtins/TypedArray/prototype/includes/prop-desc.js | 2 +- .../includes/return-abrupt-from-this-out-of-bounds.js | 2 +- .../includes/return-abrupt-tointeger-fromindex-symbol.js | 2 +- .../prototype/includes/return-abrupt-tointeger-fromindex.js | 2 +- .../builtins/TypedArray/prototype/includes/samevaluezero.js | 2 +- .../prototype/includes/search-found-returns-true.js | 2 +- .../prototype/includes/search-not-found-returns-false.js | 2 +- .../prototype/includes/searchelement-not-integer.js | 2 +- .../TypedArray/prototype/includes/this-is-not-object.js | 2 +- .../prototype/includes/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/includes/tointeger-fromindex.js | 2 +- ...buffer-during-fromIndex-returns-minus-one-for-undefined.js | 2 +- ...ched-buffer-during-fromIndex-returns-minus-one-for-zero.js | 2 +- .../builtins/TypedArray/prototype/indexOf/detached-buffer.js | 2 +- .../fromIndex-equal-or-greater-length-returns-minus-one.js | 2 +- .../TypedArray/prototype/indexOf/fromIndex-infinity.js | 2 +- .../TypedArray/prototype/indexOf/fromIndex-minus-zero.js | 2 +- .../prototype/indexOf/get-length-uses-internal-arraylength.js | 2 +- .../builtins/TypedArray/prototype/indexOf/invoked-as-func.js | 2 +- .../TypedArray/prototype/indexOf/invoked-as-method.js | 2 +- .../prototype/indexOf/length-zero-returns-minus-one.js | 2 +- test/sendable/builtins/TypedArray/prototype/indexOf/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/indexOf/name.js | 2 +- test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js | 2 +- .../TypedArray/prototype/indexOf/not-a-constructor.js | 2 +- .../builtins/TypedArray/prototype/indexOf/prop-desc.js | 2 +- .../indexOf/return-abrupt-from-this-out-of-bounds.js | 2 +- .../indexOf/return-abrupt-tointeger-fromindex-symbol.js | 2 +- .../prototype/indexOf/return-abrupt-tointeger-fromindex.js | 2 +- .../prototype/indexOf/search-found-returns-index.js | 2 +- .../prototype/indexOf/search-not-found-returns-minus-one.js | 2 +- .../TypedArray/prototype/indexOf/strict-comparison.js | 2 +- .../TypedArray/prototype/indexOf/this-is-not-object.js | 2 +- .../prototype/indexOf/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/indexOf/tointeger-fromindex.js | 2 +- ...tom-separator-result-from-tostring-on-each-simple-value.js | 2 +- .../custom-separator-result-from-tostring-on-each-value.js | 2 +- .../detached-buffer-during-fromIndex-returns-single-comma.js | 2 +- .../builtins/TypedArray/prototype/join/detached-buffer.js | 2 +- .../TypedArray/prototype/join/empty-instance-empty-string.js | 2 +- .../prototype/join/get-length-uses-internal-arraylength.js | 2 +- .../builtins/TypedArray/prototype/join/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/join/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/prototype/join/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/join/name.js | 2 +- .../builtins/TypedArray/prototype/join/not-a-constructor.js | 2 +- test/sendable/builtins/TypedArray/prototype/join/prop-desc.js | 2 +- .../join/result-from-tostring-on-each-simple-value.js | 2 +- .../prototype/join/result-from-tostring-on-each-value.js | 2 +- .../prototype/join/return-abrupt-from-separator-symbol.js | 2 +- .../TypedArray/prototype/join/return-abrupt-from-separator.js | 2 +- .../prototype/join/return-abrupt-from-this-out-of-bounds.js | 2 +- .../builtins/TypedArray/prototype/join/this-is-not-object.js | 2 +- .../prototype/join/this-is-not-typedarray-instance.js | 2 +- .../builtins/TypedArray/prototype/keys/detached-buffer.js | 2 +- .../builtins/TypedArray/prototype/keys/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/keys/invoked-as-method.js | 2 +- .../builtins/TypedArray/prototype/keys/iter-prototype.js | 2 +- test/sendable/builtins/TypedArray/prototype/keys/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/keys/name.js | 2 +- .../builtins/TypedArray/prototype/keys/not-a-constructor.js | 2 +- test/sendable/builtins/TypedArray/prototype/keys/prop-desc.js | 2 +- .../prototype/keys/return-abrupt-from-this-out-of-bounds.js | 2 +- .../builtins/TypedArray/prototype/keys/return-itor.js | 2 +- .../builtins/TypedArray/prototype/keys/this-is-not-object.js | 2 +- .../prototype/keys/this-is-not-typedarray-instance.js | 2 +- ...buffer-during-fromIndex-returns-minus-one-for-undefined.js | 2 +- ...ched-buffer-during-fromIndex-returns-minus-one-for-zero.js | 2 +- .../TypedArray/prototype/lastIndexOf/detached-buffer.js | 2 +- .../TypedArray/prototype/lastIndexOf/fromIndex-infinity.js | 2 +- .../TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js | 2 +- .../lastIndexOf/get-length-uses-internal-arraylength.js | 2 +- .../TypedArray/prototype/lastIndexOf/invoked-as-func.js | 2 +- .../TypedArray/prototype/lastIndexOf/invoked-as-method.js | 2 +- .../prototype/lastIndexOf/length-zero-returns-minus-one.js | 2 +- .../builtins/TypedArray/prototype/lastIndexOf/length.js | 2 +- .../builtins/TypedArray/prototype/lastIndexOf/name.js | 2 +- .../builtins/TypedArray/prototype/lastIndexOf/no-arg.js | 2 +- .../TypedArray/prototype/lastIndexOf/not-a-constructor.js | 2 +- .../builtins/TypedArray/prototype/lastIndexOf/prop-desc.js | 2 +- .../lastIndexOf/return-abrupt-from-this-out-of-bounds.js | 2 +- .../lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js | 2 +- .../lastIndexOf/return-abrupt-tointeger-fromindex.js | 2 +- .../prototype/lastIndexOf/search-found-returns-index.js | 2 +- .../lastIndexOf/search-not-found-returns-minus-one.js | 2 +- .../TypedArray/prototype/lastIndexOf/strict-comparison.js | 2 +- .../TypedArray/prototype/lastIndexOf/this-is-not-object.js | 2 +- .../prototype/lastIndexOf/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/lastIndexOf/tointeger-fromindex.js | 2 +- .../builtins/TypedArray/prototype/length/detached-buffer.js | 2 +- .../TypedArray/prototype/length/invoked-as-accessor.js | 2 +- .../builtins/TypedArray/prototype/length/invoked-as-func.js | 2 +- test/sendable/builtins/TypedArray/prototype/length/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/length/name.js | 2 +- .../builtins/TypedArray/prototype/length/prop-desc.js | 2 +- .../prototype/length/resizable-array-buffer-auto.js | 2 +- .../prototype/length/resizable-array-buffer-fixed.js | 2 +- .../builtins/TypedArray/prototype/length/return-length.js | 2 +- .../prototype/length/this-has-no-typedarrayname-internal.js | 2 +- .../TypedArray/prototype/length/this-is-not-object.js | 2 +- .../builtins/TypedArray/prototype/map/arraylength-internal.js | 2 +- .../prototype/map/callbackfn-arguments-with-thisarg.js | 2 +- .../prototype/map/callbackfn-arguments-without-thisarg.js | 2 +- .../TypedArray/prototype/map/callbackfn-detachbuffer.js | 2 +- .../TypedArray/prototype/map/callbackfn-is-not-callable.js | 2 +- .../callbackfn-no-interaction-over-non-integer-properties.js | 2 +- .../prototype/map/callbackfn-not-called-on-empty.js | 2 +- .../builtins/TypedArray/prototype/map/callbackfn-resize.js | 2 +- .../map/callbackfn-return-affects-returned-object.js | 2 +- .../map/callbackfn-return-does-not-change-instance.js | 2 +- .../callbackfn-return-does-not-copy-non-integer-properties.js | 2 +- .../TypedArray/prototype/map/callbackfn-returns-abrupt.js | 2 +- .../prototype/map/callbackfn-set-value-during-interaction.js | 2 +- .../builtins/TypedArray/prototype/map/callbackfn-this.js | 2 +- .../builtins/TypedArray/prototype/map/detached-buffer.js | 2 +- .../builtins/TypedArray/prototype/map/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/map/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/prototype/map/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/map/name.js | 2 +- .../builtins/TypedArray/prototype/map/not-a-constructor.js | 2 +- test/sendable/builtins/TypedArray/prototype/map/prop-desc.js | 2 +- .../prototype/map/return-abrupt-from-this-out-of-bounds.js | 2 +- ...turn-new-typedarray-conversion-operation-consistent-nan.js | 2 +- .../map/return-new-typedarray-conversion-operation.js | 4 ++-- .../prototype/map/return-new-typedarray-from-empty-length.js | 2 +- .../map/return-new-typedarray-from-positive-length.js | 2 +- .../prototype/map/speciesctor-destination-resizable.js | 2 +- .../TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js | 2 +- .../prototype/map/speciesctor-get-ctor-inherited.js | 2 +- .../prototype/map/speciesctor-get-ctor-returns-throws.js | 2 +- .../builtins/TypedArray/prototype/map/speciesctor-get-ctor.js | 2 +- .../prototype/map/speciesctor-get-species-abrupt.js | 2 +- .../map/speciesctor-get-species-custom-ctor-invocation.js | 2 +- ...species-custom-ctor-length-throws-resizable-arraybuffer.js | 2 +- .../map/speciesctor-get-species-custom-ctor-length-throws.js | 2 +- .../map/speciesctor-get-species-custom-ctor-length.js | 2 +- ...esctor-get-species-custom-ctor-returns-another-instance.js | 2 +- .../map/speciesctor-get-species-custom-ctor-throws.js | 2 +- .../prototype/map/speciesctor-get-species-custom-ctor.js | 2 +- .../prototype/map/speciesctor-get-species-returns-throws.js | 2 +- .../prototype/map/speciesctor-get-species-use-default-ctor.js | 2 +- .../TypedArray/prototype/map/speciesctor-get-species.js | 2 +- .../builtins/TypedArray/prototype/map/this-is-not-object.js | 2 +- .../prototype/map/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/map/values-are-not-cached.js | 2 +- .../reduce/callbackfn-arguments-custom-accumulator.js | 2 +- .../reduce/callbackfn-arguments-default-accumulator.js | 2 +- .../TypedArray/prototype/reduce/callbackfn-detachbuffer.js | 2 +- .../prototype/reduce/callbackfn-is-not-callable-throws.js | 2 +- .../callbackfn-no-iteration-over-non-integer-properties.js | 2 +- .../prototype/reduce/callbackfn-not-called-on-empty.js | 2 +- .../builtins/TypedArray/prototype/reduce/callbackfn-resize.js | 2 +- .../reduce/callbackfn-return-does-not-change-instance.js | 2 +- .../TypedArray/prototype/reduce/callbackfn-returns-abrupt.js | 2 +- .../prototype/reduce/callbackfn-set-value-during-iteration.js | 2 +- .../builtins/TypedArray/prototype/reduce/callbackfn-this.js | 2 +- .../builtins/TypedArray/prototype/reduce/detached-buffer.js | 2 +- .../prototype/reduce/empty-instance-return-initialvalue.js | 2 +- .../reduce/empty-instance-with-no-initialvalue-throws.js | 2 +- .../prototype/reduce/get-length-uses-internal-arraylength.js | 2 +- .../builtins/TypedArray/prototype/reduce/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/reduce/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/prototype/reduce/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/reduce/name.js | 2 +- .../builtins/TypedArray/prototype/reduce/not-a-constructor.js | 2 +- .../builtins/TypedArray/prototype/reduce/prop-desc.js | 2 +- .../prototype/reduce/result-is-last-callbackfn-return.js | 2 +- .../TypedArray/prototype/reduce/result-of-any-type.js | 2 +- .../prototype/reduce/return-abrupt-from-this-out-of-bounds.js | 2 +- .../prototype/reduce/return-first-value-without-callbackfn.js | 2 +- .../TypedArray/prototype/reduce/this-is-not-object.js | 2 +- .../prototype/reduce/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/reduce/values-are-not-cached.js | 2 +- .../reduceRight/callbackfn-arguments-custom-accumulator.js | 2 +- .../reduceRight/callbackfn-arguments-default-accumulator.js | 2 +- .../prototype/reduceRight/callbackfn-detachbuffer.js | 2 +- .../reduceRight/callbackfn-is-not-callable-throws.js | 2 +- .../callbackfn-no-iteration-over-non-integer-properties.js | 2 +- .../prototype/reduceRight/callbackfn-not-called-on-empty.js | 2 +- .../TypedArray/prototype/reduceRight/callbackfn-resize.js | 2 +- .../reduceRight/callbackfn-return-does-not-change-instance.js | 2 +- .../prototype/reduceRight/callbackfn-returns-abrupt.js | 2 +- .../reduceRight/callbackfn-set-value-during-iteration.js | 2 +- .../TypedArray/prototype/reduceRight/callbackfn-this.js | 2 +- .../TypedArray/prototype/reduceRight/detached-buffer.js | 2 +- .../reduceRight/empty-instance-return-initialvalue.js | 2 +- .../reduceRight/empty-instance-with-no-initialvalue-throws.js | 2 +- .../reduceRight/get-length-uses-internal-arraylength.js | 2 +- .../TypedArray/prototype/reduceRight/invoked-as-func.js | 2 +- .../TypedArray/prototype/reduceRight/invoked-as-method.js | 2 +- .../builtins/TypedArray/prototype/reduceRight/length.js | 2 +- .../builtins/TypedArray/prototype/reduceRight/name.js | 2 +- .../TypedArray/prototype/reduceRight/not-a-constructor.js | 2 +- .../builtins/TypedArray/prototype/reduceRight/prop-desc.js | 2 +- .../prototype/reduceRight/result-is-last-callbackfn-return.js | 2 +- .../TypedArray/prototype/reduceRight/result-of-any-type.js | 2 +- .../reduceRight/return-abrupt-from-this-out-of-bounds.js | 2 +- .../reduceRight/return-first-value-without-callbackfn.js | 2 +- .../TypedArray/prototype/reduceRight/this-is-not-object.js | 2 +- .../prototype/reduceRight/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/reduceRight/values-are-not-cached.js | 2 +- .../builtins/TypedArray/prototype/reverse/detached-buffer.js | 2 +- .../prototype/reverse/get-length-uses-internal-arraylength.js | 2 +- .../builtins/TypedArray/prototype/reverse/invoked-as-func.js | 2 +- .../TypedArray/prototype/reverse/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/prototype/reverse/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/reverse/name.js | 2 +- .../TypedArray/prototype/reverse/not-a-constructor.js | 2 +- .../prototype/reverse/preserves-non-numeric-properties.js | 2 +- .../builtins/TypedArray/prototype/reverse/prop-desc.js | 2 +- .../reverse/return-abrupt-from-this-out-of-bounds.js | 2 +- .../TypedArray/prototype/reverse/returns-original-object.js | 2 +- .../sendable/builtins/TypedArray/prototype/reverse/reverts.js | 2 +- .../TypedArray/prototype/reverse/this-is-not-object.js | 2 +- .../prototype/reverse/this-is-not-typedarray-instance.js | 2 +- .../prototype/set/BigInt/src-typedarray-not-big-throws.js | 2 +- .../prototype/set/array-arg-negative-integer-offset-throws.js | 2 +- .../TypedArray/prototype/set/array-arg-offset-tointeger.js | 2 +- .../TypedArray/prototype/set/array-arg-primitive-toobject.js | 2 +- .../set/array-arg-return-abrupt-from-src-get-length.js | 2 +- .../set/array-arg-return-abrupt-from-src-get-value.js | 2 +- .../set/array-arg-return-abrupt-from-src-length-symbol.js | 2 +- .../prototype/set/array-arg-return-abrupt-from-src-length.js | 2 +- .../array-arg-return-abrupt-from-src-tonumber-value-symbol.js | 2 +- .../set/array-arg-return-abrupt-from-src-tonumber-value.js | 2 +- .../array-arg-return-abrupt-from-tointeger-offset-symbol.js | 2 +- .../set/array-arg-return-abrupt-from-tointeger-offset.js | 2 +- .../set/array-arg-return-abrupt-from-toobject-offset.js | 2 +- .../TypedArray/prototype/set/array-arg-set-values-in-order.js | 2 +- .../builtins/TypedArray/prototype/set/array-arg-set-values.js | 2 +- .../prototype/set/array-arg-src-tonumber-value-conversions.js | 4 ++-- .../set/array-arg-src-tonumber-value-type-conversions.js | 2 +- .../prototype/set/array-arg-src-values-are-not-cached.js | 2 +- .../prototype/set/array-arg-target-arraylength-internal.js | 2 +- ...ray-arg-targetbuffer-detached-on-get-src-value-no-throw.js | 2 +- ...ay-arg-targetbuffer-detached-on-tointeger-offset-throws.js | 2 +- .../prototype/set/array-arg-targetbuffer-detached-throws.js | 2 +- .../builtins/TypedArray/prototype/set/bit-precision.js | 2 +- .../builtins/TypedArray/prototype/set/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/set/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/prototype/set/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/set/name.js | 2 +- .../builtins/TypedArray/prototype/set/not-a-constructor.js | 2 +- test/sendable/builtins/TypedArray/prototype/set/prop-desc.js | 2 +- .../TypedArray/prototype/set/src-typedarray-big-throws.js | 2 +- .../builtins/TypedArray/prototype/set/this-is-not-object.js | 2 +- .../prototype/set/this-is-not-typedarray-instance.js | 2 +- .../set/typedarray-arg-negative-integer-offset-throws.js | 2 +- .../prototype/set/typedarray-arg-offset-tointeger.js | 2 +- ...pedarray-arg-return-abrupt-from-tointeger-offset-symbol.js | 2 +- .../set/typedarray-arg-return-abrupt-from-tointeger-offset.js | 2 +- ...y-arg-set-values-diff-buffer-other-type-conversions-sab.js | 4 ++-- ...array-arg-set-values-diff-buffer-other-type-conversions.js | 4 ++-- .../typedarray-arg-set-values-diff-buffer-other-type-sab.js | 2 +- .../set/typedarray-arg-set-values-diff-buffer-other-type.js | 2 +- .../typedarray-arg-set-values-diff-buffer-same-type-sab.js | 2 +- .../set/typedarray-arg-set-values-diff-buffer-same-type.js | 2 +- .../set/typedarray-arg-set-values-same-buffer-other-type.js | 2 +- ...typedarray-arg-set-values-same-buffer-same-type-resized.js | 2 +- .../typedarray-arg-set-values-same-buffer-same-type-sab.js | 2 +- .../set/typedarray-arg-set-values-same-buffer-same-type.js | 2 +- .../prototype/set/typedarray-arg-src-arraylength-internal.js | 2 +- .../prototype/set/typedarray-arg-src-byteoffset-internal.js | 2 +- ...ay-arg-src-range-greather-than-target-throws-rangeerror.js | 2 +- ...y-arg-srcbuffer-detached-during-tointeger-offset-throws.js | 2 +- .../set/typedarray-arg-target-arraylength-internal.js | 2 +- .../set/typedarray-arg-target-byteoffset-internal.js | 2 +- .../prototype/set/typedarray-arg-target-out-of-bounds.js | 2 +- ...rg-targetbuffer-detached-during-tointeger-offset-throws.js | 2 +- .../TypedArray/prototype/slice/arraylength-internal.js | 2 +- .../builtins/TypedArray/prototype/slice/bit-precision.js | 2 +- .../slice/detached-buffer-custom-ctor-other-targettype.js | 2 +- .../slice/detached-buffer-custom-ctor-same-targettype.js | 2 +- .../TypedArray/prototype/slice/detached-buffer-get-ctor.js | 2 +- ...ached-buffer-speciesctor-get-species-custom-ctor-throws.js | 2 +- ...detached-buffer-zero-count-custom-ctor-other-targettype.js | 2 +- .../detached-buffer-zero-count-custom-ctor-same-targettype.js | 2 +- .../builtins/TypedArray/prototype/slice/detached-buffer.js | 2 +- test/sendable/builtins/TypedArray/prototype/slice/infinity.js | 2 +- .../builtins/TypedArray/prototype/slice/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/slice/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/prototype/slice/length.js | 2 +- .../builtins/TypedArray/prototype/slice/minus-zero.js | 2 +- test/sendable/builtins/TypedArray/prototype/slice/name.js | 2 +- .../builtins/TypedArray/prototype/slice/not-a-constructor.js | 2 +- .../sendable/builtins/TypedArray/prototype/slice/prop-desc.js | 2 +- .../slice/result-does-not-copy-ordinary-properties.js | 2 +- .../prototype/slice/results-with-different-length.js | 2 +- .../TypedArray/prototype/slice/results-with-empty-length.js | 2 +- .../TypedArray/prototype/slice/results-with-same-length.js | 2 +- .../prototype/slice/return-abrupt-from-end-symbol.js | 2 +- .../TypedArray/prototype/slice/return-abrupt-from-end.js | 2 +- .../prototype/slice/return-abrupt-from-start-symbol.js | 2 +- .../TypedArray/prototype/slice/return-abrupt-from-start.js | 2 +- .../prototype/slice/return-abrupt-from-this-out-of-bounds.js | 2 +- .../prototype/slice/set-values-from-different-ctor-type.js | 2 +- .../prototype/slice/speciesctor-destination-resizable.js | 2 +- .../TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js | 2 +- .../prototype/slice/speciesctor-get-ctor-inherited.js | 2 +- .../prototype/slice/speciesctor-get-ctor-returns-throws.js | 2 +- .../TypedArray/prototype/slice/speciesctor-get-ctor.js | 2 +- .../prototype/slice/speciesctor-get-species-abrupt.js | 2 +- .../slice/speciesctor-get-species-custom-ctor-invocation.js | 2 +- ...species-custom-ctor-length-throws-resizable-arraybuffer.js | 2 +- .../speciesctor-get-species-custom-ctor-length-throws.js | 2 +- .../slice/speciesctor-get-species-custom-ctor-length.js | 2 +- ...esctor-get-species-custom-ctor-returns-another-instance.js | 2 +- .../slice/speciesctor-get-species-custom-ctor-throws.js | 2 +- .../prototype/slice/speciesctor-get-species-custom-ctor.js | 2 +- .../prototype/slice/speciesctor-get-species-returns-throws.js | 2 +- .../slice/speciesctor-get-species-use-default-ctor.js | 2 +- .../TypedArray/prototype/slice/speciesctor-get-species.js | 2 +- .../builtins/TypedArray/prototype/slice/this-is-not-object.js | 2 +- .../prototype/slice/this-is-not-typedarray-instance.js | 2 +- .../builtins/TypedArray/prototype/slice/tointeger-end.js | 2 +- .../builtins/TypedArray/prototype/slice/tointeger-start.js | 2 +- .../prototype/some/callbackfn-arguments-with-thisarg.js | 2 +- .../prototype/some/callbackfn-arguments-without-thisarg.js | 2 +- .../TypedArray/prototype/some/callbackfn-detachbuffer.js | 2 +- .../some/callbackfn-no-interaction-over-non-integer.js | 2 +- .../prototype/some/callbackfn-not-callable-throws.js | 2 +- .../prototype/some/callbackfn-not-called-on-empty.js | 2 +- .../builtins/TypedArray/prototype/some/callbackfn-resize.js | 2 +- .../some/callbackfn-return-does-not-change-instance.js | 2 +- .../TypedArray/prototype/some/callbackfn-returns-abrupt.js | 2 +- .../prototype/some/callbackfn-set-value-during-interaction.js | 2 +- .../builtins/TypedArray/prototype/some/callbackfn-this.js | 2 +- .../builtins/TypedArray/prototype/some/detached-buffer.js | 2 +- .../prototype/some/get-length-uses-internal-arraylength.js | 2 +- .../builtins/TypedArray/prototype/some/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/some/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/prototype/some/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/some/name.js | 2 +- .../builtins/TypedArray/prototype/some/not-a-constructor.js | 2 +- test/sendable/builtins/TypedArray/prototype/some/prop-desc.js | 2 +- .../prototype/some/return-abrupt-from-this-out-of-bounds.js | 2 +- .../prototype/some/returns-false-if-every-cb-returns-false.js | 2 +- .../prototype/some/returns-true-if-any-cb-returns-true.js | 2 +- .../builtins/TypedArray/prototype/some/this-is-not-object.js | 2 +- .../prototype/some/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/some/values-are-not-cached.js | 2 +- .../TypedArray/prototype/sort/arraylength-internal.js | 2 +- .../TypedArray/prototype/sort/comparefn-call-throws.js | 2 +- .../builtins/TypedArray/prototype/sort/comparefn-calls.js | 2 +- .../TypedArray/prototype/sort/comparefn-is-undefined.js | 2 +- .../prototype/sort/comparefn-nonfunction-call-throws.js | 2 +- .../builtins/TypedArray/prototype/sort/detached-buffer.js | 2 +- .../builtins/TypedArray/prototype/sort/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/sort/invoked-as-method.js | 2 +- test/sendable/builtins/TypedArray/prototype/sort/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/sort/name.js | 2 +- .../builtins/TypedArray/prototype/sort/not-a-constructor.js | 2 +- test/sendable/builtins/TypedArray/prototype/sort/prop-desc.js | 2 +- .../prototype/sort/return-abrupt-from-this-out-of-bounds.js | 2 +- .../TypedArray/prototype/sort/return-same-instance.js | 2 +- .../builtins/TypedArray/prototype/sort/sort-tonumber.js | 2 +- .../TypedArray/prototype/sort/sortcompare-with-no-tostring.js | 2 +- .../builtins/TypedArray/prototype/sort/sorted-values-nan.js | 2 +- .../builtins/TypedArray/prototype/sort/sorted-values.js | 2 +- test/sendable/builtins/TypedArray/prototype/sort/stability.js | 2 +- .../builtins/TypedArray/prototype/sort/this-is-not-object.js | 2 +- .../prototype/sort/this-is-not-typedarray-instance.js | 2 +- .../builtins/TypedArray/prototype/subarray/detached-buffer.js | 2 +- .../builtins/TypedArray/prototype/subarray/infinity.js | 2 +- .../builtins/TypedArray/prototype/subarray/invoked-as-func.js | 2 +- .../TypedArray/prototype/subarray/invoked-as-method.js | 2 +- .../sendable/builtins/TypedArray/prototype/subarray/length.js | 2 +- .../builtins/TypedArray/prototype/subarray/minus-zero.js | 2 +- test/sendable/builtins/TypedArray/prototype/subarray/name.js | 2 +- .../TypedArray/prototype/subarray/not-a-constructor.js | 2 +- .../builtins/TypedArray/prototype/subarray/prop-desc.js | 2 +- .../subarray/result-does-not-copy-ordinary-properties.js | 2 +- .../subarray/result-is-new-instance-from-same-ctor.js | 2 +- .../subarray/result-is-new-instance-with-shared-buffer.js | 2 +- .../prototype/subarray/results-with-different-length.js | 2 +- .../prototype/subarray/results-with-empty-length.js | 2 +- .../TypedArray/prototype/subarray/results-with-same-length.js | 2 +- .../prototype/subarray/return-abrupt-from-begin-symbol.js | 2 +- .../TypedArray/prototype/subarray/return-abrupt-from-begin.js | 2 +- .../prototype/subarray/return-abrupt-from-end-symbol.js | 2 +- .../TypedArray/prototype/subarray/return-abrupt-from-end.js | 2 +- .../prototype/subarray/speciesctor-get-ctor-abrupt.js | 2 +- .../prototype/subarray/speciesctor-get-ctor-inherited.js | 2 +- .../prototype/subarray/speciesctor-get-ctor-returns-throws.js | 2 +- .../TypedArray/prototype/subarray/speciesctor-get-ctor.js | 2 +- .../prototype/subarray/speciesctor-get-species-abrupt.js | 2 +- .../speciesctor-get-species-custom-ctor-invocation.js | 2 +- ...esctor-get-species-custom-ctor-returns-another-instance.js | 2 +- .../subarray/speciesctor-get-species-custom-ctor-throws.js | 2 +- .../prototype/subarray/speciesctor-get-species-custom-ctor.js | 2 +- .../subarray/speciesctor-get-species-returns-throws.js | 2 +- .../subarray/speciesctor-get-species-use-default-ctor.js | 2 +- .../TypedArray/prototype/subarray/speciesctor-get-species.js | 2 +- .../TypedArray/prototype/subarray/this-is-not-object.js | 2 +- .../prototype/subarray/this-is-not-typedarray-instance.js | 2 +- .../builtins/TypedArray/prototype/subarray/tointeger-begin.js | 2 +- .../builtins/TypedArray/prototype/subarray/tointeger-end.js | 2 +- .../toLocaleString/calls-tolocalestring-from-each-value.js | 2 +- .../toLocaleString/calls-tostring-from-each-value.js | 2 +- .../prototype/toLocaleString/calls-valueof-from-each-value.js | 2 +- .../TypedArray/prototype/toLocaleString/detached-buffer.js | 2 +- .../toLocaleString/empty-instance-returns-empty-string.js | 2 +- .../toLocaleString/get-length-uses-internal-arraylength.js | 2 +- .../TypedArray/prototype/toLocaleString/invoked-as-func.js | 2 +- .../TypedArray/prototype/toLocaleString/invoked-as-method.js | 2 +- .../builtins/TypedArray/prototype/toLocaleString/length.js | 2 +- .../builtins/TypedArray/prototype/toLocaleString/name.js | 2 +- .../TypedArray/prototype/toLocaleString/not-a-constructor.js | 2 +- .../builtins/TypedArray/prototype/toLocaleString/prop-desc.js | 2 +- .../return-abrupt-from-firstelement-tolocalestring.js | 2 +- .../return-abrupt-from-firstelement-tostring.js | 2 +- .../toLocaleString/return-abrupt-from-firstelement-valueof.js | 2 +- .../return-abrupt-from-nextelement-tolocalestring.js | 2 +- .../toLocaleString/return-abrupt-from-nextelement-tostring.js | 2 +- .../toLocaleString/return-abrupt-from-nextelement-valueof.js | 2 +- .../toLocaleString/return-abrupt-from-this-out-of-bounds.js | 2 +- .../TypedArray/prototype/toLocaleString/return-result.js | 2 +- .../TypedArray/prototype/toLocaleString/this-is-not-object.js | 2 +- .../toLocaleString/this-is-not-typedarray-instance.js | 2 +- .../TypedArray/prototype/toReversed/ignores-species.js | 2 +- .../builtins/TypedArray/prototype/toReversed/immutable.js | 2 +- .../prototype/toReversed/length-property-ignored.js | 2 +- .../TypedArray/prototype/toReversed/metadata/length.js | 2 +- .../builtins/TypedArray/prototype/toReversed/metadata/name.js | 2 +- .../prototype/toReversed/metadata/property-descriptor.js | 2 +- .../TypedArray/prototype/toReversed/not-a-constructor.js | 2 +- .../TypedArray/prototype/toReversed/this-value-invalid.js | 2 +- .../TypedArray/prototype/toSorted/comparefn-not-a-function.js | 2 +- .../prototype/toSorted/comparefn-stop-after-error.js | 2 +- .../builtins/TypedArray/prototype/toSorted/ignores-species.js | 2 +- .../builtins/TypedArray/prototype/toSorted/immutable.js | 2 +- .../TypedArray/prototype/toSorted/length-property-ignored.js | 2 +- .../builtins/TypedArray/prototype/toSorted/metadata/length.js | 2 +- .../builtins/TypedArray/prototype/toSorted/metadata/name.js | 2 +- .../prototype/toSorted/metadata/property-descriptor.js | 2 +- .../TypedArray/prototype/toSorted/not-a-constructor.js | 2 +- .../TypedArray/prototype/toSorted/this-value-invalid.js | 2 +- test/sendable/builtins/TypedArray/prototype/toString.js | 2 +- .../builtins/TypedArray/prototype/toString/detached-buffer.js | 2 +- .../TypedArray/prototype/toString/not-a-constructor.js | 2 +- .../builtins/TypedArray/prototype/values/detached-buffer.js | 2 +- .../builtins/TypedArray/prototype/values/invoked-as-func.js | 2 +- .../builtins/TypedArray/prototype/values/invoked-as-method.js | 2 +- .../builtins/TypedArray/prototype/values/iter-prototype.js | 2 +- test/sendable/builtins/TypedArray/prototype/values/length.js | 2 +- test/sendable/builtins/TypedArray/prototype/values/name.js | 2 +- .../builtins/TypedArray/prototype/values/not-a-constructor.js | 2 +- .../builtins/TypedArray/prototype/values/prop-desc.js | 2 +- .../prototype/values/return-abrupt-from-this-out-of-bounds.js | 2 +- .../builtins/TypedArray/prototype/values/return-itor.js | 2 +- .../TypedArray/prototype/values/this-is-not-object.js | 2 +- .../prototype/values/this-is-not-typedarray-instance.js | 2 +- .../builtins/TypedArray/prototype/with/early-type-coercion.js | 2 +- .../builtins/TypedArray/prototype/with/ignores-species.js | 2 +- test/sendable/builtins/TypedArray/prototype/with/immutable.js | 2 +- .../prototype/with/index-bigger-or-eq-than-length.js | 2 +- .../TypedArray/prototype/with/index-casted-to-number.js | 2 +- .../builtins/TypedArray/prototype/with/index-negative.js | 2 +- .../prototype/with/index-smaller-than-minus-length.js | 2 +- .../TypedArray/prototype/with/length-property-ignored.js | 2 +- .../builtins/TypedArray/prototype/with/metadata/length.js | 2 +- .../builtins/TypedArray/prototype/with/metadata/name.js | 2 +- .../TypedArray/prototype/with/metadata/property-descriptor.js | 2 +- .../builtins/TypedArray/prototype/with/not-a-constructor.js | 2 +- .../builtins/TypedArray/prototype/with/this-value-invalid.js | 2 +- 822 files changed, 828 insertions(+), 828 deletions(-) diff --git a/test/sendable/builtins/TypedArray/Symbol.species/length.js b/test/sendable/builtins/TypedArray/Symbol.species/length.js index acec196f159..8a453388da7 100644 --- a/test/sendable/builtins/TypedArray/Symbol.species/length.js +++ b/test/sendable/builtins/TypedArray/Symbol.species/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [Symbol.species] ---*/ diff --git a/test/sendable/builtins/TypedArray/Symbol.species/name.js b/test/sendable/builtins/TypedArray/Symbol.species/name.js index bfdf652f57e..68290c66f96 100644 --- a/test/sendable/builtins/TypedArray/Symbol.species/name.js +++ b/test/sendable/builtins/TypedArray/Symbol.species/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [Symbol.species] ---*/ diff --git a/test/sendable/builtins/TypedArray/Symbol.species/prop-desc.js b/test/sendable/builtins/TypedArray/Symbol.species/prop-desc.js index d2f3ef68af9..494c4ffa40d 100644 --- a/test/sendable/builtins/TypedArray/Symbol.species/prop-desc.js +++ b/test/sendable/builtins/TypedArray/Symbol.species/prop-desc.js @@ -22,7 +22,7 @@ info: | %SendableTypedArray%[@@species] is an accessor property whose set accessor function is undefined. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/Symbol.species/result.js b/test/sendable/builtins/TypedArray/Symbol.species/result.js index 0cb5e612c3f..064cf7e190a 100644 --- a/test/sendable/builtins/TypedArray/Symbol.species/result.js +++ b/test/sendable/builtins/TypedArray/Symbol.species/result.js @@ -21,7 +21,7 @@ info: | 22.2.2.4 get %SendableTypedArray% [ @@species ] 1. Return the this value. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/arylk-get-length-error.js b/test/sendable/builtins/TypedArray/from/arylk-get-length-error.js index 57860d77937..0eaf6889b2c 100644 --- a/test/sendable/builtins/TypedArray/from/arylk-get-length-error.js +++ b/test/sendable/builtins/TypedArray/from/arylk-get-length-error.js @@ -22,7 +22,7 @@ info: | ... 7. Let len be ? ToLength(? Get(arrayLike, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/arylk-to-length-error.js b/test/sendable/builtins/TypedArray/from/arylk-to-length-error.js index 8575f8925eb..26834fbef6f 100644 --- a/test/sendable/builtins/TypedArray/from/arylk-to-length-error.js +++ b/test/sendable/builtins/TypedArray/from/arylk-to-length-error.js @@ -22,7 +22,7 @@ info: | ... 7. Let len be ? ToLength(? Get(arrayLike, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/invoked-as-func.js b/test/sendable/builtins/TypedArray/from/invoked-as-func.js index 7ba631c0dca..70255415c59 100644 --- a/test/sendable/builtins/TypedArray/from/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/from/invoked-as-func.js @@ -23,7 +23,7 @@ info: | 1. Let C be the this value. 2. If IsConstructor(C) is false, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/invoked-as-method.js b/test/sendable/builtins/TypedArray/from/invoked-as-method.js index 179e987c76d..f581fbb0ae8 100644 --- a/test/sendable/builtins/TypedArray/from/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/from/invoked-as-method.js @@ -28,7 +28,7 @@ info: | 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/iter-access-error.js b/test/sendable/builtins/TypedArray/from/iter-access-error.js index 9d525fc55e4..5cecfc2eb2c 100644 --- a/test/sendable/builtins/TypedArray/from/iter-access-error.js +++ b/test/sendable/builtins/TypedArray/from/iter-access-error.js @@ -27,7 +27,7 @@ info: | 1. Let usingIterator be ? GetMethod(items, @@iterator). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.iterator, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/iter-invoke-error.js b/test/sendable/builtins/TypedArray/from/iter-invoke-error.js index d14bcfdbeb3..02bfc061317 100644 --- a/test/sendable/builtins/TypedArray/from/iter-invoke-error.js +++ b/test/sendable/builtins/TypedArray/from/iter-invoke-error.js @@ -29,7 +29,7 @@ info: | 2. If usingIterator is not undefined, then a. Let iterator be ? GetIterator(items, usingIterator). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.iterator, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/iter-next-error.js b/test/sendable/builtins/TypedArray/from/iter-next-error.js index 69529161aa7..bab5d922912 100644 --- a/test/sendable/builtins/TypedArray/from/iter-next-error.js +++ b/test/sendable/builtins/TypedArray/from/iter-next-error.js @@ -24,7 +24,7 @@ info: | d. Repeat, while next is not false i. Let next be ? IteratorStep(iterator). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.iterator, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/iter-next-value-error.js b/test/sendable/builtins/TypedArray/from/iter-next-value-error.js index 1409340d39f..3e1bc4adf5f 100644 --- a/test/sendable/builtins/TypedArray/from/iter-next-value-error.js +++ b/test/sendable/builtins/TypedArray/from/iter-next-value-error.js @@ -26,7 +26,7 @@ info: | ii. If next is not false, then 1. Let nextValue be ? IteratorValue(next). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.iterator, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/length.js b/test/sendable/builtins/TypedArray/from/length.js index ecb0197eeb0..856c81f042a 100644 --- a/test/sendable/builtins/TypedArray/from/length.js +++ b/test/sendable/builtins/TypedArray/from/length.js @@ -32,7 +32,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/mapfn-is-not-callable.js b/test/sendable/builtins/TypedArray/from/mapfn-is-not-callable.js index 65fe48c9f6c..4cf4cf64d6e 100644 --- a/test/sendable/builtins/TypedArray/from/mapfn-is-not-callable.js +++ b/test/sendable/builtins/TypedArray/from/mapfn-is-not-callable.js @@ -23,7 +23,7 @@ info: | 3. If mapfn was supplied and mapfn is not undefined, then a. If IsCallable(mapfn) is false, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, Symbol.iterator, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/name.js b/test/sendable/builtins/TypedArray/from/name.js index ae9c438c3a8..7285ff08bfd 100644 --- a/test/sendable/builtins/TypedArray/from/name.js +++ b/test/sendable/builtins/TypedArray/from/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/not-a-constructor.js b/test/sendable/builtins/TypedArray/from/not-a-constructor.js index 84d8fa6fea5..1f6244cfc4a 100644 --- a/test/sendable/builtins/TypedArray/from/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/from/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, SendableTypedArray, arrow-function] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/prop-desc.js b/test/sendable/builtins/TypedArray/from/prop-desc.js index d02a97e21a3..dc941661604 100644 --- a/test/sendable/builtins/TypedArray/from/prop-desc.js +++ b/test/sendable/builtins/TypedArray/from/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/from/this-is-not-constructor.js b/test/sendable/builtins/TypedArray/from/this-is-not-constructor.js index 15b04a0b2d7..24209f7969c 100644 --- a/test/sendable/builtins/TypedArray/from/this-is-not-constructor.js +++ b/test/sendable/builtins/TypedArray/from/this-is-not-constructor.js @@ -23,7 +23,7 @@ info: | 1. Let C be the this value. 2. If IsConstructor(C) is false, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/invoked.js b/test/sendable/builtins/TypedArray/invoked.js index cd4387f5ef4..05bf7355e47 100644 --- a/test/sendable/builtins/TypedArray/invoked.js +++ b/test/sendable/builtins/TypedArray/invoked.js @@ -24,7 +24,7 @@ info: | Note: ES2016 replaces all the references for the %SendableTypedArray% constructor to a single chapter covering all arguments cases. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/of/invoked-as-func.js b/test/sendable/builtins/TypedArray/of/invoked-as-func.js index 89389f91ce8..9df78843918 100644 --- a/test/sendable/builtins/TypedArray/of/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/of/invoked-as-func.js @@ -24,7 +24,7 @@ info: | 3. Let C be the this value. 4. If IsConstructor(C) is false, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/of/invoked-as-method.js b/test/sendable/builtins/TypedArray/of/invoked-as-method.js index 8dd62435eab..e51444ff6b7 100644 --- a/test/sendable/builtins/TypedArray/of/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/of/invoked-as-method.js @@ -28,7 +28,7 @@ info: | 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/of/length.js b/test/sendable/builtins/TypedArray/of/length.js index 222839a9537..1987cae7c06 100644 --- a/test/sendable/builtins/TypedArray/of/length.js +++ b/test/sendable/builtins/TypedArray/of/length.js @@ -32,7 +32,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/of/name.js b/test/sendable/builtins/TypedArray/of/name.js index 50c2282f64f..5563b2b942d 100644 --- a/test/sendable/builtins/TypedArray/of/name.js +++ b/test/sendable/builtins/TypedArray/of/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/of/not-a-constructor.js b/test/sendable/builtins/TypedArray/of/not-a-constructor.js index 183c0692c55..127215ebcc9 100644 --- a/test/sendable/builtins/TypedArray/of/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/of/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, SendableTypedArray, arrow-function] ---*/ diff --git a/test/sendable/builtins/TypedArray/of/prop-desc.js b/test/sendable/builtins/TypedArray/of/prop-desc.js index 9cb9734e559..c1496005d59 100644 --- a/test/sendable/builtins/TypedArray/of/prop-desc.js +++ b/test/sendable/builtins/TypedArray/of/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/of/this-is-not-constructor.js b/test/sendable/builtins/TypedArray/of/this-is-not-constructor.js index d5056740fed..db5193716c8 100644 --- a/test/sendable/builtins/TypedArray/of/this-is-not-constructor.js +++ b/test/sendable/builtins/TypedArray/of/this-is-not-constructor.js @@ -24,7 +24,7 @@ info: | 3. Let C be the this value. 4. If IsConstructor(C) is false, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype.js b/test/sendable/builtins/TypedArray/prototype.js index fd929a83951..c0debbc32f9 100644 --- a/test/sendable/builtins/TypedArray/prototype.js +++ b/test/sendable/builtins/TypedArray/prototype.js @@ -22,7 +22,7 @@ info: | This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.iterator.js b/test/sendable/builtins/TypedArray/prototype/Symbol.iterator.js index b25cd2e5d58..a187d418705 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.iterator.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.iterator.js @@ -23,7 +23,7 @@ info: | Per ES6 section 17, the method should exist on the %SendableTypedArray% prototype, and it should be writable and configurable, but not enumerable. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [Symbol.iterator] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js index 3347e2463b3..8456e5cb0a5 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.iterator/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, Symbol, Symbol.iterator, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js index de5a3cf937c..984843b6356 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/detached-buffer.js @@ -23,7 +23,7 @@ info: | 4. Let name be the value of O's [[TypedArrayName]] internal slot. 5. Assert: name is a String value. 6. Return name. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js index b456bc46a59..3d145c537fa 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-accessor.js @@ -24,7 +24,7 @@ info: | ... 3. If O does not have a [[TypedArrayName]] internal slot, return undefined. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js index 881f666ccf2..89074c416c1 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/invoked-as-func.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, return undefined. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/length.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/length.js index c15512cc3c8..d3a35456008 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/length.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [Symbol.toStringTag] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/name.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/name.js index 349b264b81e..644bb57400c 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/name.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [Symbol.toStringTag] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js index 18ceed98895..09e4d4075da 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/prop-desc.js @@ -26,7 +26,7 @@ info: | This property has the attributes { [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [Symbol.toStringTag] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js index a07325c4c4d..e8c1b0900cf 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/return-typedarrayname.js @@ -24,7 +24,7 @@ info: | 4. Let name be the value of O's [[TypedArrayName]] internal slot. 5. Assert: name is a String value. 6. Return name. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js index ea29a5ba5b0..460ccd29888 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-has-no-typedarrayname-internal.js @@ -24,7 +24,7 @@ info: | ... 3. If O does not have a [[TypedArrayName]] internal slot, return undefined. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.toStringTag, DataView, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js index 4aea08e5158..1d66becfd9b 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/this-is-not-object.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, return undefined. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js b/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js index 136873f80d9..7d4ff1d2298 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/at/index-argument-tointeger.js @@ -22,7 +22,7 @@ info: | Let relativeIndex be ? ToInteger(index). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, TypedArray.prototype.at] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js index e7b5c04b1cd..c427c01246b 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js +++ b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger-invalid.js @@ -22,7 +22,7 @@ info: | Let relativeIndex be ? ToInteger(index). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, TypedArray.prototype.at] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js index c8cd033253e..d7aebc1b2c1 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/at/index-non-numeric-argument-tointeger.js @@ -22,7 +22,7 @@ info: | Let relativeIndex be ? ToInteger(index). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, TypedArray.prototype.at] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/at/length.js b/test/sendable/builtins/TypedArray/prototype/at/length.js index 8e7b5a9afa1..d38ee95c5e4 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/length.js +++ b/test/sendable/builtins/TypedArray/prototype/at/length.js @@ -22,7 +22,7 @@ info: | 17 ECMAScript Standard Built-in Objects -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray.prototype.at] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/at/name.js b/test/sendable/builtins/TypedArray/prototype/at/name.js index 22264e9f66a..ba3b3ce40ac 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/name.js +++ b/test/sendable/builtins/TypedArray/prototype/at/name.js @@ -22,7 +22,7 @@ info: | 17 ECMAScript Standard Built-in Objects -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray.prototype.at] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/at/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/at/prop-desc.js index e082440c4ba..23049435562 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/at/prop-desc.js @@ -21,7 +21,7 @@ info: | %SendableTypedArray%.prototype.at( index ) 17 ECMAScript Standard Built-in Objects -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray.prototype.at] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js index d15cce81cc6..b92221a5628 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.at description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, SendableTypedArray.prototype.at, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js index f731b94a0b6..35897e39884 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js +++ b/test/sendable/builtins/TypedArray/prototype/at/return-abrupt-from-this.js @@ -23,7 +23,7 @@ info: | Let O be the this value. Perform ? ValidateSendableTypedArray(O). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray,TypedArray.prototype.at] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js b/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js index 1bd5b6c7885..8a3ab63a0fc 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-item-relative-index.js @@ -31,7 +31,7 @@ info: | If k < 0 or k ≥ len, then return undefined. Return ? Get(O, ! ToString(k)). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray,TypedArray.prototype.at] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-item.js b/test/sendable/builtins/TypedArray/prototype/at/returns-item.js index 64ac38e58f7..9fa216b280c 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/returns-item.js +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-item.js @@ -31,7 +31,7 @@ info: | If k < 0 or k ≥ len, then return undefined. Return ? Get(O, ! ToString(k)). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray,TypedArray.prototype.at] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js index 4adb1ff22b7..b45c476969c 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js @@ -31,7 +31,7 @@ info: | If k < 0 or k ≥ len, then return undefined. Return ? Get(O, ! ToString(k)). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, TypedArray.prototype.at] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js index 5d332081e71..4475d728ebd 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js +++ b/test/sendable/builtins/TypedArray/prototype/at/returns-undefined-for-out-of-range-index.js @@ -22,7 +22,7 @@ info: | If k < 0 or k ≥ len, then return undefined. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray,TypedArray.prototype.at] ---*/ assert.sameValue( diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js index 3c79a94c2cf..3268ed2f066 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/detached-buffer.js @@ -22,7 +22,7 @@ info: | ... 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 5. Return buffer. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js index 314b0e1238e..47f16876476 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-accessor.js @@ -25,7 +25,7 @@ info: | 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js index 7ecc1c79a5a..95f0eee1210 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/invoked-as-func.js @@ -24,7 +24,7 @@ info: | 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/length.js b/test/sendable/builtins/TypedArray/prototype/buffer/length.js index ad61ba9753e..758007e78a4 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/length.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/name.js b/test/sendable/builtins/TypedArray/prototype/buffer/name.js index a0ed7446aae..6541a8bdd65 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/name.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/buffer/prop-desc.js index ff6ebf8dbee..c8dcd19a283 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/prop-desc.js @@ -23,7 +23,7 @@ info: | Section 17: Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js b/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js index 1dec12f37d6..244b6643c43 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/return-buffer.js @@ -23,7 +23,7 @@ info: | ... 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 5. Return buffer. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js index 7074f46fe09..1607d783cb3 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/this-has-no-typedarrayname-internal.js @@ -26,7 +26,7 @@ info: | 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [DataView, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/this-inherits-typedarray.js b/test/sendable/builtins/TypedArray/prototype/buffer/this-inherits-typedarray.js index 2ae208a2b27..e89ed798c48 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/this-inherits-typedarray.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/this-inherits-typedarray.js @@ -26,7 +26,7 @@ info: | 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/buffer/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/buffer/this-is-not-object.js index f2f2e555c1b..39e21e5f5b4 100644 --- a/test/sendable/builtins/TypedArray/prototype/buffer/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/buffer/this-is-not-object.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js index 1dab40c5f72..41c72c1c052 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/detached-buffer.js @@ -23,7 +23,7 @@ info: | 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 5. If IsDetachedBuffer(buffer) is true, return 0. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js index dff0d9cdffc..573a776ac5f 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-accessor.js @@ -25,7 +25,7 @@ info: | 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js index 62885ee8c13..a6548fbbc3f 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/invoked-as-func.js @@ -24,7 +24,7 @@ info: | 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/length.js b/test/sendable/builtins/TypedArray/prototype/byteLength/length.js index 938b4ed59ff..3cee96fcafa 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/length.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/name.js b/test/sendable/builtins/TypedArray/prototype/byteLength/name.js index b13912bc5ea..d111aa04b3c 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/name.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/byteLength/prop-desc.js index 8c38fd25222..3f20227948b 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/prop-desc.js @@ -23,7 +23,7 @@ info: | Section 17: Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js index 926c58a33cf..25602ce6cc8 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-auto.js @@ -18,7 +18,7 @@ esid: sec-get-%typedarray%.prototype.byteoffset description: | reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js index 42a1cff676e..6e747f2d182 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/resizable-array-buffer-fixed.js @@ -18,7 +18,7 @@ esid: sec-get-%typedarray%.prototype.bytelength description: | reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/return-bytelength.js b/test/sendable/builtins/TypedArray/prototype/byteLength/return-bytelength.js index c536b8c79f9..099e481281a 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/return-bytelength.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/return-bytelength.js @@ -23,7 +23,7 @@ info: | ... 6. Let size be the value of O's [[ByteLength]] internal slot. 7. Return size. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js index 378633a1100..a84ae4b1f9f 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/this-has-no-typedarrayname-internal.js @@ -26,7 +26,7 @@ info: | 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [DataView, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteLength/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/byteLength/this-is-not-object.js index 688b4fa29f8..692d85c635d 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteLength/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/byteLength/this-is-not-object.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js index 95bc09426ba..d2f7ce0fc01 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/detached-buffer.js @@ -23,7 +23,7 @@ info: | 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 5. If IsDetachedBuffer(buffer) is true, return 0. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js index 9c159226ac3..abb2a943432 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-accessor.js @@ -25,7 +25,7 @@ info: | 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js index 180da3b738a..eab2ed22a80 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/invoked-as-func.js @@ -24,7 +24,7 @@ info: | 3. If O does not have a [[ViewedArrayBuffer]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/length.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/length.js index 45e377411cf..bde9b35f79a 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/length.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/name.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/name.js index 445e4b51254..ff533f27be0 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/name.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/prop-desc.js index 3b3408a3f28..f04a7e7d725 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/prop-desc.js @@ -23,7 +23,7 @@ info: | Section 17: Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js index f647532d899..b957e4f7045 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-auto.js @@ -18,7 +18,7 @@ esid: sec-get-%typedarray%.prototype.byteoffset description: | reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js index bb4e5c2bd38..dfe53f11294 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/resizable-array-buffer-fixed.js @@ -18,7 +18,7 @@ esid: sec-get-%typedarray%.prototype.byteoffset description: | reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js index a90d86703b9..9b4259fb490 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/return-byteoffset.js @@ -23,7 +23,7 @@ info: | ... 6. Let offset be the value of O's [[ByteOffset]] internal slot. 7. Return size. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js index d91b35e4685..518382e8b97 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/this-has-no-typedarrayname-internal.js @@ -26,7 +26,7 @@ info: | 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [DataView, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/this-is-not-object.js index f61ed59a402..f6c97ad54d9 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/this-is-not-object.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/constructor.js b/test/sendable/builtins/TypedArray/prototype/constructor.js index 656ea71c664..52916252f9e 100644 --- a/test/sendable/builtins/TypedArray/prototype/constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/constructor.js @@ -22,7 +22,7 @@ info: | Per ES6 section 17, the method should exist on the %SendableTypedArray% prototype, and it should be writable and configurable, but not enumerable. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js index b2798f3dca0..556fbebe1f7 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/bit-precision.js @@ -24,7 +24,7 @@ info: | d. If fromPresent is true, then i. Let fromVal be ? Get(O, fromKey). ii. Perform ? Set(O, toKey, fromVal, true). -includes: [nans.js, compareArray.js, testTypedArray.js] +includes: [nans.js, compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js index e556ccc5913..ad0350dea09 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/byteoffset.js @@ -26,7 +26,7 @@ info: | g. Let toByteIndex be to × elementSize + byteOffset. h. Let fromByteIndex be from × elementSize + byteOffset. ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js index 7a6d9a72fbc..1675e13c6c0 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached-prototype.js @@ -30,7 +30,7 @@ info: | b. Let buffer be O.[[ViewedArrayBuffer]]. c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js index ce028c52d96..0ee47095811 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end-detached.js @@ -30,7 +30,7 @@ info: | b. Let buffer be O.[[ViewedArrayBuffer]]. c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js index 8387ba61737..6147fc0cbb3 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-end.js @@ -35,7 +35,7 @@ info: | 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js index 68da3256a81..cb5e69a2ffc 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start-detached.js @@ -30,7 +30,7 @@ info: | b. Let buffer be O.[[ViewedArrayBuffer]]. c. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js index 315d9552a8e..f734c277878 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-start.js @@ -34,7 +34,7 @@ info: | ... 5. Let relativeStart be ? ToInteger(start). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js index ae98819d33d..b8da3e887ce 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/coerced-values-target.js @@ -34,7 +34,7 @@ info: | ... 3. Let relativeTarget be ? ToInteger(target). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js index c47ee41a999..1f3a66a6324 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js index 15eeeb35be3..7d95991bc7e 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/get-length-ignores-length-prop.js @@ -34,7 +34,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-func.js index a36f5d6946f..682b84ece81 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-func.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-method.js index 37d0717cf58..ccb02dcf8a6 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/invoked-as-method.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/length.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/length.js index ca38f83b593..cfcdc342b5c 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/length.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/name.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/name.js index a8871cf3451..4f5eb19a2f6 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/name.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js index 690bd8d87f7..87d4a7daffc 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-end.js @@ -37,7 +37,7 @@ info: | 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js index a730aaec183..c7b64fa1356 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-end.js @@ -37,7 +37,7 @@ info: | 8. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js index d0ddcba8d20..078f21bc00e 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-start.js @@ -35,7 +35,7 @@ info: | 6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let from be min(relativeStart, len). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js index 77c4093000a..b408e4ee7f5 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-out-of-bounds-target.js @@ -35,7 +35,7 @@ info: | 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let to be min(relativeTarget, len). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js index 153520760f8..1ecbe7172be 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-start.js @@ -35,7 +35,7 @@ info: | 6. If relativeStart < 0, let from be max((len + relativeStart), 0); else let from be min(relativeStart, len). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js index 456d7e6b752..8569636eb49 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/negative-target.js @@ -35,7 +35,7 @@ info: | 4. If relativeTarget < 0, let to be max((len + relativeTarget), 0); else let to be min(relativeTarget, len). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js index 2006c5b3bde..2152cf57f3e 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-end.js @@ -28,7 +28,7 @@ info: | source data. ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js index 48e97de674a..036c61bf228 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-out-of-bounds-target-and-start.js @@ -28,7 +28,7 @@ info: | source data. ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js index 955e4d4787f..cc90480df65 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-and-start.js @@ -28,7 +28,7 @@ info: | source data. ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js index a07df245006..936224efafb 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/non-negative-target-start-and-end.js @@ -28,7 +28,7 @@ info: | source data. ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/not-a-constructor.js index 43aa1e4468c..9d3e9020999 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/prop-desc.js index c05dfeac757..604f2a8ed8d 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js index 730c1f42d87..c9d6864d304 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end-is-symbol.js @@ -35,7 +35,7 @@ info: | 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js index 4e23e041ac2..3310bc76c9a 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-end.js @@ -35,7 +35,7 @@ info: | 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js index 1a9fe6d2f7a..3ab6588d6c0 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start-is-symbol.js @@ -34,7 +34,7 @@ info: | ... 5. Let relativeStart be ? ToInteger(start). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js index 669461e5faf..53040647a87 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-start.js @@ -34,7 +34,7 @@ info: | ... 5. Let relativeStart be ? ToInteger(start). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js index 8ddad88eedf..83a731d7874 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target-is-symbol.js @@ -34,7 +34,7 @@ info: | ... 3. Let relativeTarget be ? ToInteger(target). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js index b65cfef896c..07404ea1f50 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-target.js @@ -34,7 +34,7 @@ info: | ... 3. Let relativeTarget be ? ToInteger(target). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js index 9bdf6ba5f3d..ce3b7eba3ad 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.copywithin description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js index ad8172ee571..3e8190a2a65 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/return-this.js @@ -32,7 +32,7 @@ info: | 22.1.3.3 Array.prototype.copyWithin (target, start [ , end ] ) 13. Return O. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-object.js index 3286d9bab70..9a825365ab8 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js index 99c53e8180d..fd7d1281203 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js index cabb8f7ff0c..e456e13592c 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/undefined-end.js @@ -35,7 +35,7 @@ info: | 7. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js index eab5da76774..891162628fc 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/detached-buffer.js @@ -27,7 +27,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-func.js index a68ba993a72..3dcbd52eb9b 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-func.js @@ -32,7 +32,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-method.js index c418250e2df..154cb1ccc93 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/invoked-as-method.js @@ -32,7 +32,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js index 52eba02ba0d..8c9b8d67544 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/iter-prototype.js @@ -22,7 +22,7 @@ info: | ... 3. Return CreateArrayIterator(O, "key+value"). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.iterator, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/length.js b/test/sendable/builtins/TypedArray/prototype/entries/length.js index 54f1a95330d..98efe9f00e8 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/length.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/name.js b/test/sendable/builtins/TypedArray/prototype/entries/name.js index 0978e77b4d5..224fc452441 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/name.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/entries/not-a-constructor.js index b40b212ae17..b83926ed2b0 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/entries/prop-desc.js index a0a3ec30a5a..b571c55bc36 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js index 52cebd722cd..e801c3629e0 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.entries description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js b/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js index f7809af1c01..b3b503b5122 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/return-itor.js @@ -21,7 +21,7 @@ info: | ... 3. Return CreateArrayIterator(O, "key+value"). -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-object.js index 0ef0eaba9ab..1f1e022bd1f 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-object.js @@ -29,7 +29,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js index 1878d4236bb..d53b87ba3ae 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/this-is-not-typedarray-instance.js @@ -32,7 +32,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js index 2fc564816ef..f62170e6eb5 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-with-thisarg.js @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js index 3eb667610a3..7a4d5cb6457 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-arguments-without-thisarg.js @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js index 21564442900..728b36e07c9 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-detachbuffer.js @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [detachArrayBuffer.js, testTypedArray.js] +includes: [detachArrayBuffer.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js index 49f67632387..f0e12d1a8e2 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-no-interaction-over-non-integer.js @@ -27,7 +27,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js index 95fea23fe1c..72130078918 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-callable-throws.js @@ -29,7 +29,7 @@ info: | ... 3. If IsCallable(callbackfn) is false, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js index 91713cb6068..9df0bb2ec87 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-not-called-on-empty.js @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js index 513b5f1ede2..14dfa0cc75f 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-resize.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.every description: Instance buffer can be resized during iteration -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js index 409f7dba1f8..add856e26e8 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-return-does-not-change-instance.js @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js index 703c9678358..c40e7d6e3bd 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-returns-abrupt.js @@ -33,7 +33,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js index c7da59ae966..78ec7514870 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-set-value-during-interaction.js @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Reflect.set, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js index c0759615406..8218bf5d195 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/every/callbackfn-this.js @@ -36,7 +36,7 @@ info: | ... ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js index 4fab0451cd1..900a648c7ad 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/every/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js index 4e3502c6e05..45e26c16879 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/every/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/every/invoked-as-func.js index fe14736e800..2eb96366758 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/every/invoked-as-func.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/every/invoked-as-method.js index a4863b8099c..51eb42cc881 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/every/invoked-as-method.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/length.js b/test/sendable/builtins/TypedArray/prototype/every/length.js index 852683c5013..2e1155b28df 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/length.js +++ b/test/sendable/builtins/TypedArray/prototype/every/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/name.js b/test/sendable/builtins/TypedArray/prototype/every/name.js index 3623a0723b4..929f48b7459 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/name.js +++ b/test/sendable/builtins/TypedArray/prototype/every/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/every/not-a-constructor.js index f8cdb9f0bf3..733e8f6b91f 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/every/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/every/prop-desc.js index 2d9c3b3ff57..e335427fbe7 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/every/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js index 0fea952b636..8edfcf53e96 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/every/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.every description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js b/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js index ad529d73e19..36a151412e2 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/every/returns-false-if-any-cb-returns-false.js @@ -29,7 +29,7 @@ info: | ... 7. Return true. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js b/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js index 1d28903bbbf..95720808a90 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/every/returns-true-if-every-cb-returns-true.js @@ -29,7 +29,7 @@ info: | ... 7. Return true. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/every/this-is-not-object.js index 2f3982a1200..4d81422ce3d 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/every/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js index 2212e8a2133..f06c094043b 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/every/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js index 4efde1249b8..22e047ff2fb 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/every/values-are-not-cached.js @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js index 7ddc9bb7fa4..790e2db2577 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-end-detach.js @@ -23,7 +23,7 @@ info: | 9. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len). 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js index bf1f5ce4c9d..ae608a9e91b 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-indexes.js @@ -40,7 +40,7 @@ info: | 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js index e926f2a9350..fb988bec2e4 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-start-detach.js @@ -24,7 +24,7 @@ info: | ... 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js b/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js index 9db68a2c4e1..dcb725e3e22 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/coerced-value-detach.js @@ -24,7 +24,7 @@ info: | ... 10. If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js index d7e275091f8..54b5c0fe3fc 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js index 122f4b0a08c..ff990650803 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-once.js @@ -23,7 +23,7 @@ info: | ... 3. Let _value_ be ? ToNumber(_value_). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js index e1aafccf36e..318b760b68f 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations-consistent-nan.js @@ -81,12 +81,12 @@ info: | NOTE: A reliable way for ECMAScript code to test if a value X is a NaN is an expression of the form X !== X. The result will be true if and only if X is a NaN. -includes: [nans.js, testTypedArray.js] +includes: [nans.js, sendableTypedArray.js] features: [TypedArray] ---*/ testWithTypedArrayConstructors(function(FA) { - var precision = floatSendableTypedArrayConstructorPrecision(FA); + var precision = floatTypedArrayConstructorPrecision(FA); var samples = new FA(3); var controls, idx, aNaN; diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations.js index 673c1beb80e..cf807167c1d 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-conversion-operations.js @@ -56,11 +56,11 @@ info: | ... e. Else, ... -includes: [byteConversionValues.js, testTypedArray.js] +includes: [byteConversionValues.js, sendableTypedArray.js] features: [TypedArray] ---*/ -testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { +testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { var sample = new TA([initial]); sample.fill(value); diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js index bbff3e1dcc9..8ef40d0c48f 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-custom-start-and-end.js @@ -42,7 +42,7 @@ info: | 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js index 2089d2e55d3..1ad8c1157a4 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-non-numeric.js @@ -56,7 +56,7 @@ info: | Return NormalCompletion(undefined). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js index be13bf139d8..d88a75d191b 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-end.js @@ -39,7 +39,7 @@ info: | 6. If relativeEnd < 0, let final be max((len + relativeEnd), 0); else let final be min(relativeEnd, len). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js index 7bc2970448b..33d00636ac4 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-relative-start.js @@ -37,7 +37,7 @@ info: | 4. If relativeStart < 0, let k be max((len + relativeStart), 0); else let k be min(relativeStart, len). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js index 097e35cfa72..05966a944b9 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values-symbol-throws.js @@ -56,7 +56,7 @@ info: | Return NormalCompletion(undefined). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js b/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js index c9608503266..2f45406cde1 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/fill-values.js @@ -37,7 +37,7 @@ info: | 7. Repeat, while k < final a. Let Pk be ! ToString(k). b. Perform ? Set(O, Pk, value, true). -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js index 43afa62a1e3..f0ecefd2cd3 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/get-length-ignores-length-prop.js @@ -36,7 +36,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-func.js index d6dd9872838..f8c6d60c30e 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-func.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-method.js index b06ff32798d..3c49138fe5b 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/invoked-as-method.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/length.js b/test/sendable/builtins/TypedArray/prototype/fill/length.js index 3b3e241f2cf..1e75a59329b 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/length.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/name.js b/test/sendable/builtins/TypedArray/prototype/fill/name.js index 329a42f3cb9..329bd6cf951 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/name.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/fill/not-a-constructor.js index af17fd58ac4..a4b63d5cd7d 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/fill/prop-desc.js index b46ba693c6a..16bc2a5cdd7 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js index cd46f7712b4..131d48f223e 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end-as-symbol.js @@ -37,7 +37,7 @@ info: | 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js index 554dd400e1f..5d4fa5f79d1 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-end.js @@ -37,7 +37,7 @@ info: | 5. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js index 72c207a74da..777e60a186f 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-set-value.js @@ -56,7 +56,7 @@ info: | Return NormalCompletion(undefined). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js index c3222fb0107..4c70e392059 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start-as-symbol.js @@ -36,7 +36,7 @@ info: | ... 3. Let relativeStart be ? ToInteger(start). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js index ec09a78740b..fd5f49b80f7 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-start.js @@ -36,7 +36,7 @@ info: | ... 3. Let relativeStart be ? ToInteger(start). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js index d7cb3690d0b..2fa534a5015 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.fill description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/return-this.js b/test/sendable/builtins/TypedArray/prototype/fill/return-this.js index 7be32b1da49..873f01f9ce5 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/return-this.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/return-this.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.fill description: > Returns `this`. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-object.js index 9a6a7727a72..a84696cb76d 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js index e7570e28b8f..4b791ccf100 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js index 79828f5e299..241be65e5a3 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/arraylength-internal.js @@ -22,7 +22,7 @@ info: | ... 3. Let len be the value of O's [[ArrayLength]] internal slot. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js index f848709dddc..44659bceb15 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-with-thisarg.js @@ -25,7 +25,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js index e2224e8071d..a4faf397c97 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-arguments-without-thisarg.js @@ -25,7 +25,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js index 2326db0a583..118ee68cb53 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-ctor.js @@ -26,7 +26,7 @@ info: | ... 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js index 1cdda61ac8a..ddd10e9ce9c 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-called-before-species.js @@ -26,7 +26,7 @@ info: | ... 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js index ac98b50069f..f97f2771042 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-detachbuffer.js @@ -26,7 +26,7 @@ info: | b. Let kValue be ? Get(O, Pk). c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [detachArrayBuffer.js, testTypedArray.js] +includes: [detachArrayBuffer.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js index 3ed9a62a80b..4428c757a27 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-no-iteration-over-non-integer.js @@ -25,7 +25,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js index 07688146999..1a05a4247fe 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-callable-throws.js @@ -22,7 +22,7 @@ info: | ... 4. If IsCallable(callbackfn) is false, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js index bc2f78e14d3..f399c71a109 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-not-called-on-empty.js @@ -25,7 +25,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js index bf9f91b2a94..f8d1db90d5b 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-resize.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.filter description: Instance buffer can be resized during iteration -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js index ae90606f568..8fdb5badff0 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-return-does-not-change-instance.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.filter description: > The callbackfn return does not change the instance -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js index 6eae8eac053..74bb08f7fed 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-returns-abrupt.js @@ -25,7 +25,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js index 9741a9efc99..c53ae985b10 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-set-value-during-iteration.js @@ -25,7 +25,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Reflect.set, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js index db91fb779cd..28021231617 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/callbackfn-this.js @@ -27,7 +27,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js index e2f736ea9f2..d8cbdf3ed15 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-func.js index 50b25324f33..3f9222cf94e 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-func.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-method.js index 7ab2565c0d2..1b49e0bf04b 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/invoked-as-method.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/length.js b/test/sendable/builtins/TypedArray/prototype/filter/length.js index e41c7c39998..489dfd7e036 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/length.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/name.js b/test/sendable/builtins/TypedArray/prototype/filter/name.js index 6ce6d6356b1..d9bd7a41c4f 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/name.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/filter/not-a-constructor.js index 1f525e94918..7e91442148b 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/filter/prop-desc.js index fa4c880e9c4..c9d0d9652a0 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js b/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js index 44d0642068e..2a1c1627f15 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/result-does-not-share-buffer.js @@ -24,7 +24,7 @@ info: | 10. Let A be ? SendableTypedArraySpeciesCreate(O, « captured »). ... 13. Return A. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js b/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js index 81258ce02c1..f78eee3f4f3 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/result-empty-callbackfn-returns-false.js @@ -25,7 +25,7 @@ info: | a. Perform ! Set(A, ! ToString(n), e, true). b. Increment n by 1. 13. Return A. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js b/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js index 53db492e614..c310248d08a 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/result-full-callbackfn-returns-true.js @@ -25,7 +25,7 @@ info: | a. Perform ! Set(A, ! ToString(n), e, true). b. Increment n by 1. 13. Return A. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js index bf5a05eae23..cd22bc57e9c 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.filter description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js index f8913da540b..517c7ee86e2 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-destination-resizable.js @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js index 280480c8ca3..525f8657d55 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-abrupt.js @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js index fb398b9c270..6ab172c1b2b 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-inherited.js @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js index ba14d2c60e3..b474bfedcef 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor-returns-throws.js @@ -37,7 +37,7 @@ info: | 3. If C is undefined, return defaultConstructor. 4. If Type(C) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js index d979a188b37..45571f94f69 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-ctor.js @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js index f8ce0c5a6cc..ee52d339e43 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-abrupt.js @@ -37,7 +37,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js index 0c923be4c34..cf16d629adb 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-invocation.js @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index a7c4a2cd8ef..470b354f934 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js index b8881c7af68..2683593057e 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length-throws.js @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js index 0feded854e2..c6a5e9ea56b 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-length.js @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js index 951ae3a46cc..ab86d1f64d5 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js index 32580e45f3e..9564074f963 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor-throws.js @@ -43,7 +43,7 @@ info: | 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js index dae1f2f6793..4146547d319 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-custom-ctor.js @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js index 90b6c7b4a79..eeb1f3220f3 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-returns-throws.js @@ -38,7 +38,7 @@ info: | 7. If IsConstructor(S) is true, return S. 8. Throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js index b0bcacd4624..3b6cbe5436b 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species-use-default-ctor.js @@ -36,7 +36,7 @@ info: | 5. Let S be ? Get(C, @@species). 6. If S is either undefined or null, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js index c18c95406e1..9cc1acc15c0 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/speciesctor-get-species.js @@ -37,7 +37,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-object.js index b6bd43dda18..9be3a35cc3c 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-object.js @@ -29,7 +29,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js index 8f39352f8dd..73e2a0a8ccc 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/this-is-not-typedarray-instance.js @@ -32,7 +32,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js index 70422b007c3..f90d28eade2 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/values-are-not-cached.js @@ -25,7 +25,7 @@ info: | ... c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js b/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js index 6c16baa74f5..ec96f5dce97 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/values-are-set.js @@ -25,7 +25,7 @@ info: | a. Perform ! Set(A, ! ToString(n), e, true). b. Increment n by 1. 13. Return A. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js index 298f8ec5995..35a92bb89d3 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/find/callbackfn-resize.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.find description: Instance buffer can be resized during iteration -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js index bdabd9fb03a..b8e3aca0583 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/find/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js index 6898af21297..88ed702fcab 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/find/get-length-ignores-length-prop.js @@ -34,7 +34,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/find/invoked-as-func.js index 584d12b63f0..7ec03a6a0ee 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/find/invoked-as-func.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/find/invoked-as-method.js index b6894c06d94..5079ffa3cd8 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/find/invoked-as-method.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/length.js b/test/sendable/builtins/TypedArray/prototype/find/length.js index afe2231166a..c7bddbe6fac 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/length.js +++ b/test/sendable/builtins/TypedArray/prototype/find/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/name.js b/test/sendable/builtins/TypedArray/prototype/find/name.js index d7d2faff69d..ca92e3251cf 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/name.js +++ b/test/sendable/builtins/TypedArray/prototype/find/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/find/not-a-constructor.js index dbffa5df825..81099b2e14f 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/find/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js index abc268d4b7d..cceca867509 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-changes-value.js @@ -38,7 +38,7 @@ info: | ... c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js index 01d3ddad58d..3088b5f9b31 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-parameters.js @@ -38,7 +38,7 @@ info: | ... c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js index 3c48f799a91..670f1a1949b 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-non-strict.js @@ -39,7 +39,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... flags: [noStrict] -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js index 53898d7f8cf..e6a89e1ce4f 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-call-this-strict.js @@ -39,7 +39,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... flags: [onlyStrict] -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js index eaac7fea1d1..5f11447d6ba 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-is-not-callable-throws.js @@ -34,7 +34,7 @@ info: | ... 3. If IsCallable(predicate) is false, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js index 77a045fed8e..d57f276b56d 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-may-detach-buffer.js @@ -51,7 +51,7 @@ info: | Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js index f797dcd7de1..b096aa95309 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/find/predicate-not-called-on-empty-array.js @@ -36,7 +36,7 @@ info: | ... c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/find/prop-desc.js index 866da14feb6..c3988d4de97 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/find/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js index 3a2e28aba16..6690a27addc 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-predicate-call.js @@ -36,7 +36,7 @@ info: | ... c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js index 8cb9e206a28..a046d86a0b3 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/find/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.find description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js index 8acdd2ad937..1aa11bdba8d 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/find/return-found-value-predicate-result-is-true.js @@ -37,7 +37,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). d. If testResult is true, return kValue. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js index ba9ac258ec2..3f1aaff92ea 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/find/return-undefined-if-predicate-returns-false-value.js @@ -37,7 +37,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... 7. Return undefined. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/find/this-is-not-object.js index 943f082e6ed..261752b71d4 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/find/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js index dc924b4cde0..b4d3d243eb4 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/find/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js index d38d26ffb87..9ac34d40f2b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/callbackfn-resize.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.findindex description: Instance buffer can be resized during iteration -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js index 5f785cb7709..4ba4a33f604 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js index f83d77d25c5..446683bf948 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/get-length-ignores-length-prop.js @@ -32,7 +32,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-func.js index e7411b66d9d..2a3ea2f351b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-func.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-method.js index 180e57e1ae3..10575592ddb 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/invoked-as-method.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/length.js b/test/sendable/builtins/TypedArray/prototype/findIndex/length.js index 6cf6091b507..6d9ce26a2ff 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/length.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/name.js b/test/sendable/builtins/TypedArray/prototype/findIndex/name.js index d74106a06e0..1e6ffbdf88d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/name.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/findIndex/not-a-constructor.js index 74a7f939795..38eba87f4c3 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js index af5748409a9..816ebfef901 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-changes-value.js @@ -34,7 +34,7 @@ info: | ... c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js index 13cb4752f87..32c3bbfe2b2 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-parameters.js @@ -36,7 +36,7 @@ info: | ... c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js index 4b55f40dccf..4a90ab70cf9 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-non-strict.js @@ -37,7 +37,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... flags: [noStrict] -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js index dfb3061e075..6cf0a972ca3 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-call-this-strict.js @@ -37,7 +37,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... flags: [onlyStrict] -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js index f4e24de54e0..588a9725056 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-is-not-callable-throws.js @@ -32,7 +32,7 @@ info: | ... 3. If IsCallable(predicate) is false, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js index e90400a2d0b..a854027b06e 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-may-detach-buffer.js @@ -40,7 +40,7 @@ info: | Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js index 0b7925c032b..18729d915ac 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/predicate-not-called-on-empty-array.js @@ -35,7 +35,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... 7. Return -1. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/findIndex/prop-desc.js index 48ac0e52c26..a448fd79aad 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js index 1422fabc778..225144cc215 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-predicate-call.js @@ -35,7 +35,7 @@ info: | ... c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js index 8bde234d8eb..3cb68fe089d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.findindex description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js index 46ee513ac63..5a31a939130 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-index-predicate-result-is-true.js @@ -36,7 +36,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). d. If testResult is true, return k. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js index 1a51cfe14f2..72438996ee4 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/return-negative-one-if-predicate-returns-false-value.js @@ -35,7 +35,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... 7. Return -1. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-object.js index 336be044e6b..ba961f005db 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js index d2c9fb3c3ed..939c0af80e9 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js index 7bbce3b0f27..996b92de28b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/callbackfn-resize.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.findlast description: Instance buffer can be resized during iteration -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js index 37042b1f9b0..62e188aca42 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/detached-buffer.js @@ -26,7 +26,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js index a568d7cb01c..e90bdf4725b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/get-length-ignores-length-prop.js @@ -22,7 +22,7 @@ info: | ... 3. Let len be O.[[ArrayLength]]. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-func.js index 2e7e989c569..47db6caf3ac 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-func.js @@ -27,7 +27,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-method.js index 1c5b6798b42..9f09b793d3b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/invoked-as-method.js @@ -27,7 +27,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/length.js b/test/sendable/builtins/TypedArray/prototype/findLast/length.js index 4276a25ada0..03f7bf1ff2c 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/length.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/name.js b/test/sendable/builtins/TypedArray/prototype/findLast/name.js index f784f660ffc..8259b57b37a 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/name.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/findLast/not-a-constructor.js index 42ae9464c56..c7ab952461e 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js index 79850e6cf3d..ae88f3e51a3 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-changes-value.js @@ -26,7 +26,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js index 07510070b87..e405330160b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-parameters.js @@ -25,7 +25,7 @@ info: | ... c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js index 1cb954881fb..886f5460b17 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-non-strict.js @@ -25,7 +25,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... flags: [noStrict] -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js index a8be0a4bc94..5ebba876c67 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-call-this-strict.js @@ -25,7 +25,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... flags: [onlyStrict] -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js index d1274b65542..dd7cb5e47ff 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-is-not-callable-throws.js @@ -23,7 +23,7 @@ info: | ... 4. If IsCallable(predicate) is false, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js index 969014edeba..1995e758494 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-may-detach-buffer.js @@ -33,7 +33,7 @@ info: | Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js index 90b0ccb9624..a573f35f0ad 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/predicate-not-called-on-empty-array.js @@ -24,7 +24,7 @@ info: | ... c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/findLast/prop-desc.js index e6284d09761..3b80b0daf00 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js index 485cf4ef296..47ec28df260 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-predicate-call.js @@ -24,7 +24,7 @@ info: | ... c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js index 6cbd1bf89ca..46d77ea255d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.findlast description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js index cc9c7a2ca0b..ea418aedcc3 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-found-value-predicate-result-is-true.js @@ -25,7 +25,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). d. If testResult is true, return kValue. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js index d1394d6bd73..30617e6f3fb 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/return-undefined-if-predicate-returns-false-value.js @@ -26,7 +26,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... 7. Return undefined. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-object.js index ae2baaffd10..41eb4bbabf6 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-object.js @@ -25,7 +25,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js index b830c252f51..5f7b2c082cb 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/this-is-not-typedarray-instance.js @@ -28,7 +28,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js index 74ff46cfb48..dbe04771c8c 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/callbackfn-resize.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.findlastindex description: Instance buffer can be resized during iteration -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js index 8a1b88d8930..b5785c415bf 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js index 7ef9f96901e..e7af0abb262 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/get-length-ignores-length-prop.js @@ -23,7 +23,7 @@ info: | ... 3. Let len be O.[[ArrayLength]]. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-func.js index 9d3ab0aea92..5e7181daf3d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-func.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-method.js index eca7cca2680..09d714f99e1 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/invoked-as-method.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/length.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/length.js index fef2b798982..f5f11955a6b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/length.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/name.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/name.js index d24bfdc6360..197681cc5c1 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/name.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/not-a-constructor.js index fe036db5b03..19d76e64cd6 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js index 6cae90618e4..5643ced772a 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-changes-value.js @@ -25,7 +25,7 @@ info: | ... c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js index 6eaff86fcdc..9d9273af5f0 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-parameters.js @@ -26,7 +26,7 @@ info: | ... c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js index b483310b7c2..57831ea0dbd 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-non-strict.js @@ -27,7 +27,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... flags: [noStrict] -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js index 1186825a747..d2aa0491f90 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-call-this-strict.js @@ -27,7 +27,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... flags: [onlyStrict] -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js index 39b192480be..dca0314d01c 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-is-not-callable-throws.js @@ -23,7 +23,7 @@ info: | ... 4. If IsCallable(predicate) is false, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js index 0025e34ef64..c77e221ed8d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-may-detach-buffer.js @@ -32,7 +32,7 @@ info: | Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js index 2761cda4fac..5ed8a79f735 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/predicate-not-called-on-empty-array.js @@ -26,7 +26,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... 7. Return -1. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/prop-desc.js index 8fb7bd56aed..e72787c51da 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js index f7c5cfc7048..2d238777b31 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-predicate-call.js @@ -26,7 +26,7 @@ info: | ... c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js index 80eb992a846..fd2dcaf6ac8 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.findlastindex description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js index a4567c3183b..92d54a99040 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-index-predicate-result-is-true.js @@ -27,7 +27,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). d. If testResult is true, return 𝔽(k). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js index e871d2669f2..636f90ad558 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/return-negative-one-if-predicate-returns-false-value.js @@ -27,7 +27,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... 7. Return -1𝔽. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-object.js index a045abcb55a..60a6022c5c2 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js index 04fdb37d95a..278a36dd069 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js index 1003e2e8419..2d5195e4e2c 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/arraylength-internal.js @@ -24,7 +24,7 @@ info: | algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the this object's [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of "length" -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js index 73794c531a9..51382358313 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-with-thisarg.js @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Perform ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js index 56d86fe0d69..263c1f2e9ec 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-arguments-without-thisarg.js @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Perform ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js index 938ce7c704c..51644ff01b3 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js @@ -34,7 +34,7 @@ info: | ... ii. Perform ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [detachArrayBuffer.js, testTypedArray.js] +includes: [detachArrayBuffer.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js index 48af07517ea..d724c8b149f 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-is-not-callable.js @@ -30,7 +30,7 @@ info: | ... 3. If IsCallable(callbackfn) is false, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js index 737cf370005..f9155d7c52e 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-no-interaction-over-non-integer.js @@ -27,7 +27,7 @@ info: | ... ii. Perform ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js index 5370be35fda..bfdd0c98d52 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-not-called-on-empty.js @@ -34,7 +34,7 @@ info: | ... ii. Perform ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js index d77f43ef399..1142e1d5003 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-resize.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.forEach description: Instance buffer can be resized during iteration -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js index b8cc7887a8e..e4be72f28c0 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-return-does-not-change-instance.js @@ -24,7 +24,7 @@ info: | algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the this object's [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of "length" -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js index c5c228dfad5..33fd1dbe196 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-returns-abrupt.js @@ -34,7 +34,7 @@ info: | ... ii. Perform ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js index 5f78d9a25d4..f77348bf276 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-set-value-during-interaction.js @@ -24,7 +24,7 @@ info: | algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the this object's [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of "length" -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Reflect.set, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js index 4f1097d045f..4f21698338c 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/callbackfn-this.js @@ -36,7 +36,7 @@ info: | ... ii. Perform ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js index 34c08f97b47..93ff35ef94d 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-func.js index fdf5bbd97ce..dcedeea0674 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-func.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-method.js index 2dd53538708..23aca02d06f 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/invoked-as-method.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/length.js b/test/sendable/builtins/TypedArray/prototype/forEach/length.js index ee9d5fc0034..a0b98e1a0f1 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/length.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/name.js b/test/sendable/builtins/TypedArray/prototype/forEach/name.js index f3720767962..779d1dbbfde 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/name.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/forEach/not-a-constructor.js index 43f40494bc6..0d9f5795b80 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/forEach/prop-desc.js index 9985a93fb58..575c259cbaf 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js index 2abf87fe0de..b6d4c91c67f 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.foreach description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js b/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js index be8d61fd01f..a18761d2609 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/returns-undefined.js @@ -24,7 +24,7 @@ info: | algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the this object's [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of "length" -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-object.js index 702813e2af9..82c0b88c750 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js index 2190aa884d0..f5443367a3e 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js index f815237d520..e43d209b075 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/values-are-not-cached.js @@ -24,7 +24,7 @@ info: | algorithm as Array.prototype.forEach as defined in 22.1.3.10 except that the this object's [[ArrayLength]] internal slot is accessed in place of performing a [[Get]] of "length" -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js index 92c5698c16c..ff48b488feb 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-false-for-zero.js @@ -43,7 +43,7 @@ info: | Set k to k + 1. Return false. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js index 7b667e50042..e727bda2a03 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer-during-fromIndex-returns-true-for-undefined.js @@ -43,7 +43,7 @@ info: | Set k to k + 1. Return false. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js index 81a45329e84..72864f11a2e 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js index f3da36c8c04..4918e9f578a 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-equal-or-greater-length-returns-false.js @@ -35,7 +35,7 @@ info: | 7. Repeat, while k < len ... 8. Return false. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js index c1fb8892588..2d4f8d891e1 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-infinity.js @@ -37,7 +37,7 @@ info: | 7. Repeat, while k < len ... 8. Return false. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js index 34bb880991b..b4fdd744c0a 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/fromIndex-minus-zero.js @@ -32,7 +32,7 @@ info: | ... 7. Repeat, while k < len ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js index 8bc41698b6d..8e56b57e0e1 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-func.js index 8f2a5d2ebe9..1fa063bad73 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-func.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-method.js index e1be14101e9..39c796d643b 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/invoked-as-method.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js index 54ef23bc92c..d7b313aab9a 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/length-zero-returns-false.js @@ -30,7 +30,7 @@ info: | 2. Let len be ? ToLength(? Get(O, "length")). 3. If len is 0, return false. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/length.js b/test/sendable/builtins/TypedArray/prototype/includes/length.js index 19d61861c9b..2b40cb21519 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/length.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/name.js b/test/sendable/builtins/TypedArray/prototype/includes/name.js index 14eaeafe269..69b8fc6556d 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/name.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/includes/not-a-constructor.js index f6b81426d18..6959e33a2cc 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/includes/prop-desc.js index af0247a2d96..09fb022432c 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js index 601d1b96a44..049726f5355 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.includes description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js index 14c6556e237..7c05e3adab2 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex-symbol.js @@ -30,7 +30,7 @@ info: | 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js index 8a15b008dc7..ba1ede76a73 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/return-abrupt-tointeger-fromindex.js @@ -30,7 +30,7 @@ info: | 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js b/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js index cdc7f90a3a0..f5241ddc9a2 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/samevaluezero.js @@ -32,7 +32,7 @@ info: | b. If SameValueZero(searchElement, elementK) is true, return true. c. Increase k by 1. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js b/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js index a1a2ebd7a45..391944748c4 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/search-found-returns-true.js @@ -37,7 +37,7 @@ info: | b. If SameValueZero(searchElement, elementK) is true, return true. c. Increase k by 1. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js b/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js index 003edd49396..bbff0974e33 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/search-not-found-returns-false.js @@ -37,7 +37,7 @@ info: | b. If SameValueZero(searchElement, elementK) is true, return true. c. Increase k by 1. 8. Return false. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js b/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js index f1a9b09ed3d..0c52a7fc3ec 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/searchelement-not-integer.js @@ -27,7 +27,7 @@ info: | a. Let elementK be the result of ? Get(O, ! ToString(k)). b. If SameValueZero(searchElement, elementK) is true, return true. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-object.js index 476394b853f..109ec783155 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js index e09a0f3f19b..b46ff08af3e 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js index 6432aad9cbb..fc50f18adc9 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/tointeger-fromindex.js @@ -37,7 +37,7 @@ info: | b. If SameValueZero(searchElement, elementK) is true, return true. c. Increase k by 1. 8. Return false. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index 0e93c17a9b9..bbd45397d7b 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -45,7 +45,7 @@ info: | Set k to k + 1. Return -1F. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index 3b32ed2c12a..e7850c336b3 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -45,7 +45,7 @@ info: | Set k to k + 1. Return -1F. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js index 9971111f943..5212d39db3d 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js index 1515b7dd4a3..515c22c36c7 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-equal-or-greater-length-returns-minus-one.js @@ -30,7 +30,7 @@ info: | 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js index b9000479a91..77050bb0d1c 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-infinity.js @@ -40,7 +40,7 @@ info: | searchElement === elementK. iii. If same is true, return k. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js index d9756dc8208..bbfb9968228 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/fromIndex-minus-zero.js @@ -30,7 +30,7 @@ info: | 6. If n ≥ 0, then a. If n is -0, let k be +0; else let k be n. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js index b71ea7ba6f8..266c1ebde95 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-func.js index 10fe3621977..8be518f6821 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-func.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-method.js index 387487a0e89..ad630abdb27 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/invoked-as-method.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js index 5369205d139..d5247fa1438 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/length-zero-returns-minus-one.js @@ -30,7 +30,7 @@ info: | 2. Let len be ? ToLength(? Get(O, "length")). 3. If len is 0, return -1. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/length.js b/test/sendable/builtins/TypedArray/prototype/indexOf/length.js index 115bd4b44c9..3fa29accee6 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/length.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/name.js b/test/sendable/builtins/TypedArray/prototype/indexOf/name.js index 2215f5b8f1a..9253902753d 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/name.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js b/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js index 450d5fc0a6f..35d5e2e3bb2 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/no-arg.js @@ -29,7 +29,7 @@ info: | [...] 10. Return -1. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/indexOf/not-a-constructor.js index 3f3cf08a763..2fd697bfac4 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/indexOf/prop-desc.js index ad884ab5416..92f80b495ca 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js index 75f90c0e2b8..2d1c99bcdbc 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.indexof description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js index 2e1bdc92eb3..a295858461b 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex-symbol.js @@ -30,7 +30,7 @@ info: | 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js index 49fd3d8262c..e9f54a3e300 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/return-abrupt-tointeger-fromindex.js @@ -30,7 +30,7 @@ info: | 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js b/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js index c04f2a39204..bed0dfd26e0 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/search-found-returns-index.js @@ -40,7 +40,7 @@ info: | searchElement === elementK. iii. If same is true, return k. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js index fc5e8eaa158..4571abfb0b3 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/search-not-found-returns-minus-one.js @@ -34,7 +34,7 @@ info: | b. If k < 0, let k be 0. ... 9. Return -1. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js b/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js index b89431ebc89..140bcff7a27 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/strict-comparison.js @@ -35,7 +35,7 @@ info: | searchElement === elementK. iii. If same is true, return k. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-object.js index 4526d1061e1..77c7d137c1a 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js index 2a40fa43c6d..477eae88495 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js index ae91f34ff5f..bd4af01513b 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/tointeger-fromindex.js @@ -30,7 +30,7 @@ info: | 4. Let n be ? ToInteger(fromIndex). (If fromIndex is undefined, this step produces the value 0.) ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js index 283f8875c68..210736cb795 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-simple-value.js @@ -38,7 +38,7 @@ info: | let next be ? ToString(element). d. Let R be a String value produced by concatenating S and next. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js index 92d34428934..049eda599a9 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/custom-separator-result-from-tostring-on-each-value.js @@ -38,7 +38,7 @@ info: | let next be ? ToString(element). d. Let R be a String value produced by concatenating S and next. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js index 0da3e4c6e56..4bc4e7b4b88 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js +++ b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer-during-fromIndex-returns-single-comma.js @@ -38,7 +38,7 @@ info: | Set k to k + 1. Return R. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js index 91891e49a81..e325fc1e152 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/join/detached-buffer.js @@ -27,7 +27,7 @@ info: | Perform ? ValidateSendableTypedArray(O). ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js b/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js index 148996e1bb5..967173927db 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js +++ b/test/sendable/builtins/TypedArray/prototype/join/empty-instance-empty-string.js @@ -30,7 +30,7 @@ info: | 4. Let sep be ? ToString(separator). 5. If len is zero, return the empty String. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js index 16f214b6e2e..667f0f47916 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/join/get-length-uses-internal-arraylength.js @@ -31,7 +31,7 @@ info: | ... 5. If len is zero, return the empty String. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/join/invoked-as-func.js index 4c9fb595c94..e6255fad161 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/join/invoked-as-func.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/join/invoked-as-method.js index 5ad9501eb19..a51df5cbf19 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/join/invoked-as-method.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/length.js b/test/sendable/builtins/TypedArray/prototype/join/length.js index a373eaba400..394f2eb18a9 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/length.js +++ b/test/sendable/builtins/TypedArray/prototype/join/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/name.js b/test/sendable/builtins/TypedArray/prototype/join/name.js index a3a5006c14e..a224be2804a 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/name.js +++ b/test/sendable/builtins/TypedArray/prototype/join/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/join/not-a-constructor.js index 61b88f4ef3f..fa5232e0d17 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/join/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/join/prop-desc.js index ab25d7fc2e8..459c69aae58 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/join/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js index 89828a16fd1..95eadb5deb5 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-simple-value.js @@ -37,7 +37,7 @@ info: | let next be ? ToString(element). d. Let R be a String value produced by concatenating S and next. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js index 26bf20ca6a6..94f6731c0c1 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/join/result-from-tostring-on-each-value.js @@ -37,7 +37,7 @@ info: | let next be ? ToString(element). d. Let R be a String value produced by concatenating S and next. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js index 8397fda6d89..b8209c0aa1e 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator-symbol.js @@ -30,7 +30,7 @@ info: | 4. Let sep be ? ToString(separator). 5. If len is zero, return the empty String. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js index fcd35578522..b31520e1c21 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js +++ b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-separator.js @@ -30,7 +30,7 @@ info: | 4. Let sep be ? ToString(separator). 5. If len is zero, return the empty String. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js index 1b8b4a33215..2a5aec34050 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/join/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.join description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/join/this-is-not-object.js index d917ae09b0a..e1ef6b70da9 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/join/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js index adee1fd151e..895b8ad2018 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/join/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js index e9ebc9b9280..dc63c92e2e4 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/detached-buffer.js @@ -27,7 +27,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-func.js index 39e03a89873..7ed10b376e2 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-func.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-method.js index 4ca60479387..f919361711b 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/invoked-as-method.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js index 325ea7b4181..0dceba5b923 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/iter-prototype.js @@ -22,7 +22,7 @@ info: | ... 3. Return CreateArrayIterator(O, "key"). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.iterator, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/length.js b/test/sendable/builtins/TypedArray/prototype/keys/length.js index 520a888aa6a..e64582fd5a5 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/length.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/name.js b/test/sendable/builtins/TypedArray/prototype/keys/name.js index 8e0e1427ab3..169d7c942d7 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/name.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/keys/not-a-constructor.js index 1b48fa86650..19108ce1569 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/keys/prop-desc.js index d4c373babde..23d43f32af6 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js index 3bd227f3ae5..c17683919b5 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.keys description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js b/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js index 652243ea132..16f0fbd18d6 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/return-itor.js @@ -21,7 +21,7 @@ info: | ... 3. Return CreateArrayIterator(O, "key"). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-object.js index 4016c43ccdc..4a193527be0 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-object.js @@ -29,7 +29,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js index eec98e03624..95e30291f07 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/this-is-not-typedarray-instance.js @@ -32,7 +32,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js index 2a395748411..16632902f43 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-undefined.js @@ -42,7 +42,7 @@ info: | Set k to k - 1. Return -1F. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js index b886ba1f3fe..1046b224f83 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer-during-fromIndex-returns-minus-one-for-zero.js @@ -42,7 +42,7 @@ info: | Set k to k - 1. Return -1F. -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js index d28e206ee2d..ae736b1bdef 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js index e349f998bfc..f597a58382c 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-infinity.js @@ -33,7 +33,7 @@ info: | a. Let k be len + n. 7. Repeat, while k ≥ 0 ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js index 26d7283836b..6dc1c72c512 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/fromIndex-minus-zero.js @@ -30,7 +30,7 @@ info: | 5. If n ≥ 0, then a. If n is -0, let k be +0; else let k be min(n, len - 1). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js index 0371d9b78b4..ca37ffcbcd4 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-func.js index e1dfa6dec89..8b3255cccf8 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-func.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-method.js index 2991a6a4464..7609a7387a2 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/invoked-as-method.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js index 9b4387a3aff..01744d0ed45 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length-zero-returns-minus-one.js @@ -30,7 +30,7 @@ info: | 2. Let len be ? ToLength(? Get(O, "length")). 3. If len is 0, return -1. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length.js index 52716caf3dd..739bd6c8b1c 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/name.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/name.js index 9abf1eb72ed..bcc29d1166d 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/name.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js index 9463d900e26..dc22ec6ffab 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/no-arg.js @@ -29,7 +29,7 @@ info: | [...] 8. Return -1. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/not-a-constructor.js index ed0ccf1255d..be2b02464ec 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/prop-desc.js index e07b6fc1ecd..85d0b04fa80 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js index 18a555a8706..46f2d757542 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.lastindexof description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js index 21acf7926c1..c8f46281f9e 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex-symbol.js @@ -30,7 +30,7 @@ info: | 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let n be len-1. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js index 62438fee3c7..e5640164afa 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/return-abrupt-tointeger-fromindex.js @@ -30,7 +30,7 @@ info: | 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let n be len-1. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js index 98546f88d1b..0748c0d9a7d 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-found-returns-index.js @@ -39,7 +39,7 @@ info: | searchElement === elementK. iii. If same is true, return k. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js index b941407017d..5e78e05be7c 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/search-not-found-returns-minus-one.js @@ -34,7 +34,7 @@ info: | 7. Repeat, while k ≥ 0 ... 8. Return -1. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js index 36b347e2004..83ca8b03708 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/strict-comparison.js @@ -35,7 +35,7 @@ info: | searchElement === elementK. iii. If same is true, return k. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-object.js index 166640c2e32..b811c08ffe5 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js index 7f71858ea51..143fe04243c 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js index 871dd8b620a..c61acaec018 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/tointeger-fromindex.js @@ -30,7 +30,7 @@ info: | 4. If argument fromIndex was passed, let n be ? ToInteger(fromIndex); else let n be len-1. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js index b1041d229ec..11b500e5094 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/length/detached-buffer.js @@ -23,7 +23,7 @@ info: | 5. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 6. If IsDetachedBuffer(buffer) is true, return 0. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js index ae4057279f7..3d7039bb951 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/length/invoked-as-accessor.js @@ -25,7 +25,7 @@ info: | 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/length/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/length/invoked-as-func.js index acf987142ba..2fea06044e2 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/length/invoked-as-func.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/length/length.js b/test/sendable/builtins/TypedArray/prototype/length/length.js index 02afc0877cd..9dd3afd110d 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/length.js +++ b/test/sendable/builtins/TypedArray/prototype/length/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/length/name.js b/test/sendable/builtins/TypedArray/prototype/length/name.js index 4d31776e89a..29b75b0c52b 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/name.js +++ b/test/sendable/builtins/TypedArray/prototype/length/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/length/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/length/prop-desc.js index 660aef816db..5aee4d817a0 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/length/prop-desc.js @@ -23,7 +23,7 @@ info: | Section 17: Every accessor property described in clauses 18 through 26 and in Annex B.2 has the attributes {[[Enumerable]]: false, [[Configurable]]: true } -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js index d8a3f402dfa..112c6af2859 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-auto.js @@ -18,7 +18,7 @@ esid: sec-get-%typedarray%.prototype.length description: | reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js index 7045ab8d062..563e40056cd 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/length/resizable-array-buffer-fixed.js @@ -18,7 +18,7 @@ esid: sec-get-%typedarray%.prototype.length description: | reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/length/return-length.js b/test/sendable/builtins/TypedArray/prototype/length/return-length.js index 1d36b2cc017..0a499aafd69 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/return-length.js +++ b/test/sendable/builtins/TypedArray/prototype/length/return-length.js @@ -28,7 +28,7 @@ info: | The current tests on `prop-desc.js` and `length.js` already assert `length` is not a dynamic property as in regular arrays. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js index 5852412a6e3..95b39f24f92 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/length/this-has-no-typedarrayname-internal.js @@ -26,7 +26,7 @@ info: | 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [DataView, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/length/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/length/this-is-not-object.js index 4b523f084b4..89d05331cf7 100644 --- a/test/sendable/builtins/TypedArray/prototype/length/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/length/this-is-not-object.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js index 0d0ee638b51..5ace72176ac 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/map/arraylength-internal.js @@ -23,7 +23,7 @@ info: | ... 3. Let len be the value of O's [[ArrayLength]] internal slot. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js index b128222b262..a5e06dc2707 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-with-thisarg.js @@ -26,7 +26,7 @@ info: | b. Let kValue be ? Get(O, Pk). c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js index ee4b4513586..2ed4dbac600 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-arguments-without-thisarg.js @@ -26,7 +26,7 @@ info: | b. Let kValue be ? Get(O, Pk). c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js index 8031c36f980..40c52ae618a 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-detachbuffer.js @@ -26,7 +26,7 @@ info: | b. Let kValue be ? Get(O, Pk). c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [detachArrayBuffer.js, testTypedArray.js] +includes: [detachArrayBuffer.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js index 714cff6bf20..9b4aee28fcd 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-is-not-callable.js @@ -23,7 +23,7 @@ info: | ... 4. If IsCallable(callbackfn) is false, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js index facb1959e1e..a651ad781d4 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-no-interaction-over-non-integer-properties.js @@ -26,7 +26,7 @@ info: | b. Let kValue be ? Get(O, Pk). c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js index 4156caac76d..aea6c268c62 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-not-called-on-empty.js @@ -26,7 +26,7 @@ info: | ... c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js index 98c9cfc22c4..016042ab7e3 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-resize.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.map description: Instance buffer can be resized during iteration -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js index 47ea9990b94..31bf3c1cd3b 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-affects-returned-object.js @@ -28,7 +28,7 @@ info: | d. Perform ? Set(A, Pk, mappedValue, true). ... 9. Return A. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js index 95deab0a95b..5f9ca8f4d07 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-change-instance.js @@ -19,7 +19,7 @@ description: > The callbackfn return does not change the `this` instance info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js index 22b4aabf10e..d20b9c0d60f 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-return-does-not-copy-non-integer-properties.js @@ -26,7 +26,7 @@ info: | b. Let kValue be ? Get(O, Pk). c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js index 7dd9b4a9628..47099d9d9fe 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-returns-abrupt.js @@ -20,7 +20,7 @@ description: > info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js index 7c33ef56dce..61849f85bd4 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-set-value-during-interaction.js @@ -19,7 +19,7 @@ description: > Integer indexed values changed during iteration info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Reflect.set, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js index 714f8918ada..53386c3caa8 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/map/callbackfn-this.js @@ -27,7 +27,7 @@ info: | ... c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js index 1af717dc160..8eb571a0efe 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/map/invoked-as-func.js index 7bb22cbdb56..9436c209980 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/map/invoked-as-func.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/map/invoked-as-method.js index 9b2fbe7354b..0dcaf80db1a 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/map/invoked-as-method.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/length.js b/test/sendable/builtins/TypedArray/prototype/map/length.js index d1c339e7b27..85c6cbf5859 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/name.js b/test/sendable/builtins/TypedArray/prototype/map/name.js index 894107554b6..44cba371a4b 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/name.js +++ b/test/sendable/builtins/TypedArray/prototype/map/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/map/not-a-constructor.js index e9a65313f14..8c5ac0f0808 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/map/prop-desc.js index c221ba89cbc..d0c0e7e98ea 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/map/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js index 49d086fbd64..d0da518825e 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.map description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js index 0177b2002cc..5c4dcdcc094 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation-consistent-nan.js @@ -62,7 +62,7 @@ info: | encoding. An implementation must always choose the same encoding for each implementation distinguishable NaN value. ... -includes: [nans.js, testTypedArray.js, compareArray.js] +includes: [nans.js, sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js index bc6eecd8616..9f24d6e826d 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-conversion-operation.js @@ -58,11 +58,11 @@ info: | ... e. Else, ... -includes: [byteConversionValues.js, testTypedArray.js] +includes: [byteConversionValues.js, sendableTypedArray.js] features: [TypedArray] ---*/ -testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { +testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { var sample = new TA([initial]); var result = sample.map(function() { diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js index b76c7af38d9..cb37026256b 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-empty-length.js @@ -29,7 +29,7 @@ info: | c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... 9. Return A. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js index e81d4d01aed..8d4fe80fe41 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/return-new-typedarray-from-positive-length.js @@ -29,7 +29,7 @@ info: | c. Let mappedValue be ? Call(callbackfn, T, « kValue, k, O »). ... 9. Return A. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js index 1c24e146b8e..e9d955df3a7 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-destination-resizable.js @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js index b41f6a83487..c3a7a058309 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-abrupt.js @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js index 3d36f1e53c0..e04fcc7b0da 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-inherited.js @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js index b89ac9a7e40..a7d7bb5d091 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor-returns-throws.js @@ -37,7 +37,7 @@ info: | 3. If C is undefined, return defaultConstructor. 4. If Type(C) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js index 069e857f8e3..f459e2c9798 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-ctor.js @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js index 9e7446abdc3..99a6e918482 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-abrupt.js @@ -37,7 +37,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js index 70fe4e1bcff..5f835479a29 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-invocation.js @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index 466a642e993..9cfd8c942c1 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js index 5a9a1e2cf00..032613fe244 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length-throws.js @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js index 82aae24970f..853f632aed1 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-length.js @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js index 430a5dc9bc5..6073927ac8b 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js index df39054360d..324308f7e2e 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor-throws.js @@ -43,7 +43,7 @@ info: | 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js index 20a6d998772..5ecbfcb91fd 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-custom-ctor.js @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js index 3b0f1649fe9..8a21bcc83e3 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-returns-throws.js @@ -38,7 +38,7 @@ info: | 7. If IsConstructor(S) is true, return S. 8. Throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js index 5a4afbbc0cb..1b30dd1d3a7 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species-use-default-ctor.js @@ -36,7 +36,7 @@ info: | 5. Let S be ? Get(C, @@species). 6. If S is either undefined or null, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js index 196ecd858c1..fa19189c3b7 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/map/speciesctor-get-species.js @@ -37,7 +37,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/map/this-is-not-object.js index 07d875a2171..5746c84911c 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/map/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js index d41afb6ceaa..80670dfe0ba 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/map/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js index b67820124aa..8fa34cfcb62 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/map/values-are-not-cached.js @@ -19,7 +19,7 @@ description: > Integer indexed values changed during iteration info: | 22.2.3.19 %SendableTypedArray%.prototype.map ( callbackfn [ , thisArg ] ) -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js index 586e4f8efaf..9c50eb8b468 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-custom-accumulator.js @@ -35,7 +35,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js index 3c088751f33..de4b3e4f9b7 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-arguments-default-accumulator.js @@ -42,7 +42,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js index 6743c13aff3..83031d8b413 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-detachbuffer.js @@ -35,7 +35,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [detachArrayBuffer.js, testTypedArray.js] +includes: [detachArrayBuffer.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js index fc858df398a..51057e59d24 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-is-not-callable-throws.js @@ -31,7 +31,7 @@ info: | 3. If IsCallable(callbackfn) is false, throw a TypeError exception. 4. If len is 0 and initialValue is not present, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js index 13aefd990b7..9fe1430d4d6 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-no-iteration-over-non-integer-properties.js @@ -35,7 +35,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js index 30a8fb490ff..b24b31e0d63 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-not-called-on-empty.js @@ -37,7 +37,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js index 0d5245365ed..332a18655ba 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-resize.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.reduce description: Instance buffer can be resized during iteration -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js index b7bede57c6e..8002b4aab57 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-return-does-not-change-instance.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.reduce description: > The callbackfn return does not change the `this` instance -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js index b047c9cc725..6c86a10ebbe 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-returns-abrupt.js @@ -35,7 +35,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js index b14c6e9fb06..376ac43c9a9 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-set-value-during-iteration.js @@ -26,7 +26,7 @@ info: | a [[Get]] of "length". 22.1.3.19 Array.prototype.reduce ( callbackfn [ , initialValue ] ) -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Reflect.set, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js index d5b2a13849f..499f842b467 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/callbackfn-this.js @@ -35,7 +35,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js index efb23c54d5a..9d20a7c6077 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js index 738954ff75d..743ef93ebff 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-return-initialvalue.js @@ -39,7 +39,7 @@ info: | 8. Repeat, while k < len ... 9. Return accumulator. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js index 40427b79148..3076bd55f9e 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/empty-instance-with-no-initialvalue-throws.js @@ -30,7 +30,7 @@ info: | ... 4. If len is 0 and initialValue is not present, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js index 2314e94c652..ef5744a9bd3 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-func.js index 200528ef122..98b9478975f 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-func.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-method.js index edaeb907b5a..312945c803a 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/invoked-as-method.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/length.js b/test/sendable/builtins/TypedArray/prototype/reduce/length.js index ada9f402856..6ca46640471 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/length.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/name.js b/test/sendable/builtins/TypedArray/prototype/reduce/name.js index c36f5d124bc..ce94b7f2f98 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/name.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/reduce/not-a-constructor.js index 93f80de2aeb..7196707e2fe 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/reduce/prop-desc.js index 11b1233aa26..099b8219fae 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js b/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js index ac4c5dcd444..f47896b82a2 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/result-is-last-callbackfn-return.js @@ -43,7 +43,7 @@ info: | ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). 9. Return accumulator. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js b/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js index a6bb34c8cb8..67a450afed7 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/result-of-any-type.js @@ -43,7 +43,7 @@ info: | ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). 9. Return accumulator. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js index 62325e74bb9..72ccd36930c 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.reduce description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js b/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js index 9234fd8ac8f..939b25c86d6 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/return-first-value-without-callbackfn.js @@ -40,7 +40,7 @@ info: | 8. Repeat, while k < len ... 9. Return accumulator. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-object.js index d86ebcc6a95..02b96d775f9 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js index bcfd5856759..3c7fd694b39 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js index 3bfa7098d9f..698e2986ffe 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/values-are-not-cached.js @@ -35,7 +35,7 @@ info: | ii. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js index 59ae6f58da6..dc6cfb2c8b6 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-custom-accumulator.js @@ -36,7 +36,7 @@ info: | kValue, k, O »). d. Decrease k by 1. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js index 504a1519533..db0cb5cee48 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-arguments-default-accumulator.js @@ -45,7 +45,7 @@ info: | kValue, k, O »). d. Decrease k by 1. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js index 32f1602c2f8..488c785420d 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-detachbuffer.js @@ -35,7 +35,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [detachArrayBuffer.js, testTypedArray.js] +includes: [detachArrayBuffer.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js index 586a6a56c76..02d4e03fd6d 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-is-not-callable-throws.js @@ -31,7 +31,7 @@ info: | 3. If IsCallable(callbackfn) is false, throw a TypeError exception. 4. If len is 0 and initialValue is not present, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js index f7d9f30d39a..e5599b69468 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-no-iteration-over-non-integer-properties.js @@ -36,7 +36,7 @@ info: | kValue, k, O »). d. Decrease k by 1. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js index 4aca03052cb..4c195858cd4 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-not-called-on-empty.js @@ -38,7 +38,7 @@ info: | kValue, k, O »). d. Decrease k by 1. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js index 7357bbacc95..fe577f2e564 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-resize.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.reduceright description: Instance buffer can be resized during iteration -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js index 41f6aaebdda..6804f8124b0 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-return-does-not-change-instance.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.reduceright description: > The callbackfn return does not change the `this` instance -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js index 51f0558c454..d2c8766a49d 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-returns-abrupt.js @@ -35,7 +35,7 @@ info: | i. Let accumulator be ? Call(callbackfn, undefined, « accumulator, kValue, k, O »). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js index 71044af53ee..fb8cb4fc9e5 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-set-value-during-iteration.js @@ -26,7 +26,7 @@ info: | performing a [[Get]] of "length". 22.1.3.20 Array.prototype.reduceRight ( callbackfn [ , initialValue ] ) -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Reflect.set, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js index df218241a22..b276379ddeb 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/callbackfn-this.js @@ -36,7 +36,7 @@ info: | kValue, k, O »). d. Decrease k by 1. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js index 452567c9802..e1a04ea57f6 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js index 614001d3b19..ec6d34c545f 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-return-initialvalue.js @@ -40,7 +40,7 @@ info: | 8. Repeat, while k ≥ 0 ... 9. Return accumulator. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js index aa8df89e7bf..48d390ba402 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/empty-instance-with-no-initialvalue-throws.js @@ -30,7 +30,7 @@ info: | ... 4. If len is 0 and initialValue is not present, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js index 2b5a6c51a1e..68a9136a6da 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-func.js index aed0b90bd4b..4daacf026a4 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-func.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-method.js index 2958993c074..ab4abd40970 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/invoked-as-method.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/length.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/length.js index 31a02e9f35b..84a4c4f236b 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/length.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/name.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/name.js index 4860d0fa0a6..cdf762bfddc 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/name.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/not-a-constructor.js index 34f44426ac8..c8f5bf96d2b 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/prop-desc.js index 8672c15bd8a..f662546970c 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js index 61dab386e54..dfdd3bd2877 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-is-last-callbackfn-return.js @@ -45,7 +45,7 @@ info: | kValue, k, O »). d. Decrease k by 1. 9. Return accumulator. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js index f0c6b28e051..cf15636fd47 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/result-of-any-type.js @@ -45,7 +45,7 @@ info: | kValue, k, O »). d. Decrease k by 1. 9. Return accumulator. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js index b34716a9fcf..d25c8327743 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.reduceright description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js index 7074c434f1f..d437405c0d5 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/return-first-value-without-callbackfn.js @@ -41,7 +41,7 @@ info: | 8. Repeat, while k ≥ 0 ... 9. Return accumulator. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-object.js index 60b0c372f0c..2cf546cfc78 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js index 0807f5da8b4..418bdeb8af4 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js index 34d29464fca..573e25ca901 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/values-are-not-cached.js @@ -36,7 +36,7 @@ info: | kValue, k, O »). d. Decrease k by 1. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js index 939d126ce9e..75576a1a558 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js index a946b158bba..b30e790f7b1 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-func.js index 3a2cf5519a6..cbfdf8b8755 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-func.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-method.js index c69e2a55f0c..5e928f57a44 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/invoked-as-method.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/length.js b/test/sendable/builtins/TypedArray/prototype/reverse/length.js index 33929a0fe39..c534eaa2f4d 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/length.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/name.js b/test/sendable/builtins/TypedArray/prototype/reverse/name.js index 476870fdb3c..4ff13767cec 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/name.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/reverse/not-a-constructor.js index 76f8c2f069b..fcb48ba3e25 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js b/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js index 65d35f2a618..5ec51918286 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/preserves-non-numeric-properties.js @@ -28,7 +28,7 @@ info: | ... 6. Return O. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/reverse/prop-desc.js index a93b8756715..b018e37aa5c 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js index 5853aa07843..02fc6d306d8 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.reverse description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js b/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js index 626255e3d5f..57f11a13d4a 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/returns-original-object.js @@ -28,7 +28,7 @@ info: | ... 6. Return O. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js b/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js index e2053ca6847..cf06ec92b26 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/reverts.js @@ -28,7 +28,7 @@ info: | ... 6. Return O. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-object.js index ed9465cb9fd..61137c22756 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js index 476b5fe0554..181786d03ee 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js index 18dbf1b5c58..e17953faef6 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/src-typedarray-not-big-throws.js @@ -28,7 +28,7 @@ info: | other does not, throw a TypeError exception. ... -includes: [testBigIntTypedArray.js, testTypedArray.js] +includes: [testBigIntTypedArray.js, sendableTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js index 0fe1eae3b89..6c8e351d97f 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-negative-integer-offset-throws.js @@ -27,7 +27,7 @@ info: | 6. Let targetOffset be ? ToInteger(offset). 7. If targetOffset < 0, throw a RangeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js index b02265da28d..b93975f7320 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-offset-tointeger.js @@ -27,7 +27,7 @@ info: | 6. Let targetOffset be ? ToInteger(offset). 7. If targetOffset < 0, throw a RangeError exception. ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js index e3516157f2b..091708762fc 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-primitive-toobject.js @@ -36,7 +36,7 @@ info: | [...] f. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value, true, Unordered). [...] -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, Symbol] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js index 52b3eebaa44..38220a8a092 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-length.js @@ -26,7 +26,7 @@ info: | ... 16. Let srcLength be ? ToLength(? Get(src, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js index 6a8a8ec7987..cfc6a9992c9 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-get-value.js @@ -31,7 +31,7 @@ info: | d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js index 211e8f31b14..59b860c0a24 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length-symbol.js @@ -26,7 +26,7 @@ info: | ... 16. Let srcLength be ? ToLength(? Get(src, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js index a1b4e6ac575..563bdb57330 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-length.js @@ -26,7 +26,7 @@ info: | ... 16. Let srcLength be ? ToLength(? Get(src, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js index 23c66eb3c77..8d56547e786 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value-symbol.js @@ -31,7 +31,7 @@ info: | d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js index 28aef8bfdb8..aa617efffbb 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-src-tonumber-value.js @@ -31,7 +31,7 @@ info: | d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js index deb09569e18..c38eb4a7b90 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -25,7 +25,7 @@ info: | 22.2.3.23.2 applies. ... 6. Let targetOffset be ? ToInteger(offset). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js index 20e71ee308c..5a2efbd837f 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-tointeger-offset.js @@ -25,7 +25,7 @@ info: | 22.2.3.23.2 applies. ... 6. Let targetOffset be ? ToInteger(offset). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js index 7293efdc44d..29f04bcac0a 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-return-abrupt-from-toobject-offset.js @@ -26,7 +26,7 @@ info: | ... 15. Let src be ? ToObject(array). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js index 49950eb2adb..1af01017267 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values-in-order.js @@ -31,7 +31,7 @@ info: | d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js index 6da3af15778..eab47870d71 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-set-values.js @@ -31,7 +31,7 @@ info: | Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... 22. Return undefined. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js index 3d73e5c55d3..12210bf264b 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-conversions.js @@ -31,11 +31,11 @@ info: | d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... -includes: [byteConversionValues.js, testTypedArray.js] +includes: [byteConversionValues.js, sendableTypedArray.js] features: [TypedArray] ---*/ -testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { +testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { var sample = new TA([initial]); sample.set([value]); diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js index 069027d9b26..bf144b50596 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-tonumber-value-type-conversions.js @@ -31,7 +31,7 @@ info: | d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js index c2112663cd4..c3234ffd511 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-src-values-are-not-cached.js @@ -31,7 +31,7 @@ info: | d. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, kNumber). ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js index a530b5eca1e..98883f7f2f5 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-target-arraylength-internal.js @@ -28,7 +28,7 @@ info: | ... 17. If srcLength + targetOffset > targetLength, throw a RangeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js index aba47a6fa46..05be276b05a 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-get-src-value-no-throw.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.set-array-offset description: > Does not throw if target TA is detached mid-iteration -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js index 325392dc7b2..d88b3b87c90 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-on-tointeger-offset-throws.js @@ -30,7 +30,7 @@ info: | slot. 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js index 6ab3e470a9a..59ba2779e6e 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/array-arg-targetbuffer-detached-throws.js @@ -31,7 +31,7 @@ info: | 15. Let src be ? ToObject(array). 16. Let srcLength be ? ToLength(? Get(src, "length")). ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js b/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js index 3898560c0f3..95dbeedb2b8 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js +++ b/test/sendable/builtins/TypedArray/prototype/set/bit-precision.js @@ -28,7 +28,7 @@ info: | value). iii. Set srcByteIndex to srcByteIndex + 1. iv. Set targetByteIndex to targetByteIndex + 1. -includes: [nans.js, compareArray.js, testTypedArray.js] +includes: [nans.js, compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/set/invoked-as-func.js index 973a2883020..70c4ded319e 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/set/invoked-as-func.js @@ -21,7 +21,7 @@ info: | This function is not generic. The this value must be an object with a [[TypedArrayName]] internal slot. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/set/invoked-as-method.js index 6a4fe60c0d5..0f3d25833af 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/set/invoked-as-method.js @@ -21,7 +21,7 @@ info: | This function is not generic. The this value must be an object with a [[TypedArrayName]] internal slot. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/length.js b/test/sendable/builtins/TypedArray/prototype/set/length.js index 54e51db8608..df9f4d10162 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/length.js +++ b/test/sendable/builtins/TypedArray/prototype/set/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/name.js b/test/sendable/builtins/TypedArray/prototype/set/name.js index e2346590cda..514c2aeebca 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/name.js +++ b/test/sendable/builtins/TypedArray/prototype/set/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/set/not-a-constructor.js index 00d63c3321b..92e16e17159 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/set/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/set/prop-desc.js index 76202377349..fb187164f1c 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/set/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js b/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js index a36b693f208..6d6067377d0 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/src-typedarray-big-throws.js @@ -28,7 +28,7 @@ info: | other does not, throw a TypeError exception. ... -includes: [testBigIntTypedArray.js, testTypedArray.js] +includes: [testBigIntTypedArray.js, sendableTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/set/this-is-not-object.js index c4346cf0dc4..de02094cef8 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/set/this-is-not-object.js @@ -23,7 +23,7 @@ info: | 2. Let target be the this value. 3. If Type(target) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js index 45f701fd5e8..41cc0bd0419 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/set/this-is-not-typedarray-instance.js @@ -26,7 +26,7 @@ info: | 4. If target does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js index 4bb2132d22d..480e4ab832c 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-negative-integer-offset-throws.js @@ -25,7 +25,7 @@ info: | ... 6. Let targetOffset be ? ToInteger(offset). 7. If targetOffset < 0, throw a RangeError exception. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js index ad733879292..7e55d86fd87 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-offset-tointeger.js @@ -24,7 +24,7 @@ info: | the definition in 22.2.3.23.1 applies. ... 6. Let targetOffset be ? ToInteger(offset). -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js index 349349224de..1a38335e7b2 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset-symbol.js @@ -24,7 +24,7 @@ info: | the definition in 22.2.3.23.1 applies. ... 6. Let targetOffset be ? ToInteger(offset). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js index 952721549bd..7da3899fd53 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-return-abrupt-from-tointeger-offset.js @@ -24,7 +24,7 @@ info: | the definition in 22.2.3.23.1 applies. ... 6. Let targetOffset be ? ToInteger(offset). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js index 27daec8d851..bec1dc65929 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions-sab.js @@ -17,11 +17,11 @@ esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set converted values from different buffer of different types and different type instances -includes: [byteConversionValues.js, testTypedArray.js] +includes: [byteConversionValues.js, sendableTypedArray.js] features: [SharedArrayBuffer] ---*/ -testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { +testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { if (TA === Float64Array || TA === Float32Array || (typeof Float16Array !== 'undefined' && TA === Float16Array) || TA === Uint8ClampedArray) { return; } diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js index 499eceed2f0..508598fdcc3 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-conversions.js @@ -34,11 +34,11 @@ info: | i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType). ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value). -includes: [byteConversionValues.js, testTypedArray.js] +includes: [byteConversionValues.js, sendableTypedArray.js] features: [TypedArray] ---*/ -testSendableTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { +testTypedArrayConversions(byteConversionValues, function(TA, value, expected, initial) { if (TA === Float64Array) { return; } diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js index 8e28d9abda4..696b2386872 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type-sab.js @@ -18,7 +18,7 @@ esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the different buffer and different type. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [SharedArrayBuffer, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js index cd9273c949e..8b942a11880 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-other-type.js @@ -35,7 +35,7 @@ info: | i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, srcType). ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, targetType, value). -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js index 51440535281..b67a665f0e7 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type-sab.js @@ -18,7 +18,7 @@ esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the different buffer and same constructor. srcBuffer values are cached. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [SharedArrayBuffer, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js index 5195a55becb..065c3d6e870 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-diff-buffer-same-type.js @@ -38,7 +38,7 @@ info: | value). ... 29. Return undefined. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js index 1ec2fc0391a..7f2630cd55d 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-other-type.js @@ -40,7 +40,7 @@ info: | value). ... 29. Return undefined. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js index 556e0b8d77d..7a0029aa7db 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-resized.js @@ -18,7 +18,7 @@ esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the same buffer and same constructor when underlying ArrayBuffer has been resized -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js index b71f810d46e..82b188d0534 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type-sab.js @@ -18,7 +18,7 @@ esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: > Set values from different instances using the same buffer and same constructor. srcBuffer values are cached. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [SharedArrayBuffer, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js index c54d72ce63f..7346c563b6f 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-set-values-same-buffer-same-type.js @@ -39,7 +39,7 @@ info: | i. Let value be GetValueFromBuffer(srcBuffer, srcByteIndex, "Uint8"). ii. Perform SetValueInBuffer(targetBuffer, targetByteIndex, "Uint8", value). -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js index aae739fbd14..de1c84fb36d 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-arraylength-internal.js @@ -27,7 +27,7 @@ info: | ... 22. If srcLength + targetOffset > targetLength, throw a RangeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js index fc0e6c71203..f718938a278 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-byteoffset-internal.js @@ -24,7 +24,7 @@ info: | ... 21. Let srcByteOffset be typedArray.[[ByteOffset]]. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js index 53d449fde92..a4c446732b8 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-src-range-greather-than-target-throws-rangeerror.js @@ -31,7 +31,7 @@ info: | ... 22. If srcLength + targetOffset > targetLength, throw a RangeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js index db416bb0ac0..9a8bba44837 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-srcbuffer-detached-during-tointeger-offset-throws.js @@ -29,7 +29,7 @@ info: | slot. 12. If IsDetachedBuffer(srcBuffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js index 20376afcfab..870fb7bcfc8 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-arraylength-internal.js @@ -28,7 +28,7 @@ info: | ... 22. If srcLength + targetOffset > targetLength, throw a RangeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js index 607762daece..90b79f25c4d 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-byteoffset-internal.js @@ -25,7 +25,7 @@ info: | ... 16. Let targetByteOffset be target.[[ByteOffset]]. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js index c83e7d3168c..f324949ce9c 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-target-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: Error when target SendableTypedArray fails boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js index aa82eaee097..666376581ff 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/set/typedarray-arg-targetbuffer-detached-during-tointeger-offset-throws.js @@ -29,7 +29,7 @@ info: | slot. 9. If IsDetachedBuffer(targetBuffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js index 2579007b9fe..22739719ca2 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/arraylength-internal.js @@ -22,7 +22,7 @@ info: | ... 3. Let len be the value of O's [[ArrayLength]] internal slot. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js b/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js index bbef4721744..62ce3203c75 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/bit-precision.js @@ -33,7 +33,7 @@ info: | value). iii. Increase srcByteIndex by 1. iv. Increase targetByteIndex by 1. -includes: [nans.js, compareArray.js, testTypedArray.js] +includes: [nans.js, compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js index f0668c31b18..34cf1455d51 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-other-targettype.js @@ -26,7 +26,7 @@ info: | If count > 0, then If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js index ab7a09b45b3..1016e46e08b 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-custom-ctor-same-targettype.js @@ -24,7 +24,7 @@ info: | If count > 0, then If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js index 1d470be7e3d..d5ebf57121d 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-get-ctor.js @@ -24,7 +24,7 @@ info: | If count > 0, then If IsDetachedBuffer(O.[[ViewedArrayBuffer]]) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js index c0616467b0b..89e0003791a 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-speciesctor-get-species-custom-ctor-throws.js @@ -39,7 +39,7 @@ info: | If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js index 0ee1ab9e5a8..3086326f027 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-other-targettype.js @@ -26,7 +26,7 @@ info: | ... Return A -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js index 25f52ae7e08..0c40fd72ed7 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer-zero-count-custom-ctor-same-targettype.js @@ -25,7 +25,7 @@ info: | If count > 0, then ... Return A -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [align-detached-buffer-semantics-with-web-reality, Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js index 1d62a03d659..399e9802219 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/detached-buffer.js @@ -27,7 +27,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/infinity.js b/test/sendable/builtins/TypedArray/prototype/slice/infinity.js index d26048e4e63..65c085f657c 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/infinity.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.slice description: Infinity values on start and end -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-func.js index b7a2074dd6a..6565d471a5f 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-func.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-method.js index d96a865e6c6..9650e64144e 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/invoked-as-method.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/length.js b/test/sendable/builtins/TypedArray/prototype/slice/length.js index 68c2c4e4590..bda5cbee569 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js b/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js index 1bc789baabc..40f2a744163 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/minus-zero.js @@ -18,7 +18,7 @@ esid: sec-%sendableTypedArray%.prototype.slice description: -0 values on start and end info: | 22.2.3.24 %SendableTypedArray%.prototype.slice ( start, end ) -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/name.js b/test/sendable/builtins/TypedArray/prototype/slice/name.js index 88385fcfd15..f9712999a47 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/name.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/slice/not-a-constructor.js index 32b1a53ff00..37b7d63277a 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/slice/prop-desc.js index df0b01a332a..9a33854bde2 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js b/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js index 2d9cad4462f..4d4c1b87772 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/result-does-not-copy-ordinary-properties.js @@ -18,7 +18,7 @@ esid: sec-%sendableTypedArray%.prototype.slice description: Result does not import own properties info: | 22.2.3.24 %SendableTypedArray%.prototype.slice( start , end ) -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js b/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js index b6745b51c5f..76ef76b675a 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/results-with-different-length.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.slice description: slice may return a new instance with a smaller length -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js b/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js index c54750c9a2e..08de1fc1fef 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/results-with-empty-length.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.slice description: slice may return a new empty instance -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js b/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js index fa97885227c..22cb0ceb2b5 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/results-with-same-length.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.slice description: slice may return a new instance with the same length -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js index 0dfb499235d..497e9c3fca7 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end-symbol.js @@ -23,7 +23,7 @@ info: | 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js index 6af2c9cbeef..ca6047ba2d3 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-end.js @@ -23,7 +23,7 @@ info: | 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js index 32479284900..33def468389 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start-symbol.js @@ -22,7 +22,7 @@ info: | ... 4. Let relativeStart be ? ToInteger(start). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js index fb0aa97867b..92c53809a6e 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-start.js @@ -22,7 +22,7 @@ info: | ... 4. Let relativeStart be ? ToInteger(start). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js index 4160c213a8d..e69a6538b8d 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js b/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js index a58eaa5e9f2..80ab0a50d52 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/set-values-from-different-ctor-type.js @@ -39,7 +39,7 @@ info: | v. Increase n by 1. ... 16. Return A -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js index e6b31d17573..d7beadceb75 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-destination-resizable.js @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js index f29f173cfeb..6c321516696 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-abrupt.js @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js index e18b11b0386..77fdf51c12b 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-inherited.js @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js index 800e450f5e8..718fcd96b13 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor-returns-throws.js @@ -37,7 +37,7 @@ info: | 3. If C is undefined, return defaultConstructor. 4. If Type(C) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js index ffb0ae5ccc8..6841c34ad4a 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-ctor.js @@ -35,7 +35,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js index 757981b8ab3..1ede19995b6 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-abrupt.js @@ -37,7 +37,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js index 9426fc491fa..725a4895023 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-invocation.js @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js index 2c4ed5429d9..32aa979af2e 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws-resizable-arraybuffer.js @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, SendableTypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js index 9f81509ceae..06fd9a8f166 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length-throws.js @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js index f98b6a24c62..bc3156cbb95 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-length.js @@ -36,7 +36,7 @@ info: | a. If the value of newSendableTypedArray's [[ArrayLength]] internal slot < argumentList[0], throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js index 74b6b7184c6..4fbbdf32477 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js index c43ae8ea254..fab5a2d451c 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor-throws.js @@ -43,7 +43,7 @@ info: | 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js index 4aa4bb85275..c242223582c 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-custom-ctor.js @@ -45,7 +45,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js index ea1778bf819..449368a3606 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-returns-throws.js @@ -38,7 +38,7 @@ info: | 7. If IsConstructor(S) is true, return S. 8. Throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js index 75bdc38e040..95219e63587 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species-use-default-ctor.js @@ -36,7 +36,7 @@ info: | 5. Let S be ? Get(C, @@species). 6. If S is either undefined or null, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js index a6ae743c403..86166a32f56 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/speciesctor-get-species.js @@ -37,7 +37,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-object.js index 65a721d66b4..7e2b17bda6b 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-object.js @@ -29,7 +29,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js index 3b496fb73b7..1bf63151c77 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/this-is-not-typedarray-instance.js @@ -32,7 +32,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js index e8ab0dd3aa2..b07ae6ac6fc 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-end.js @@ -23,7 +23,7 @@ info: | 6. If end is undefined, let relativeEnd be len; else let relativeEnd be ? ToInteger(end). ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js index 8ce56e1f25b..e913a3c5abb 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/tointeger-start.js @@ -22,7 +22,7 @@ info: | ... 4. Let relativeStart be ? ToInteger(start). ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js index eec7784980c..91ea2e626d2 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-with-thisarg.js @@ -36,7 +36,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js index a3c6a4c4083..fe8f2b16b73 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-arguments-without-thisarg.js @@ -36,7 +36,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js index 72e014616c0..cdbd9507dc8 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-detachbuffer.js @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [detachArrayBuffer.js, testTypedArray.js] +includes: [detachArrayBuffer.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js index 9331d1efd6e..8af52080509 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-no-interaction-over-non-integer.js @@ -27,7 +27,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js index e5c984ebe77..bb11336321a 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-callable-throws.js @@ -29,7 +29,7 @@ info: | ... 3. If IsCallable(callbackfn) is false, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js index 4171119f4ce..4849630c334 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-not-called-on-empty.js @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js index 9470791ce32..35e5029bd27 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-resize.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.some description: Instance buffer can be resized during iteration -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js index 7cc1f955053..bf28afaeda7 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-return-does-not-change-instance.js @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js index e0621d9f8ed..510b7056f4f 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-returns-abrupt.js @@ -33,7 +33,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js index f0881d4e469..b3d2b3a32de 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-set-value-during-interaction.js @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Reflect.set, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js index 741c7adaf55..a0b5d649511 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js +++ b/test/sendable/builtins/TypedArray/prototype/some/callbackfn-this.js @@ -36,7 +36,7 @@ info: | ... ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js index 66e4b10a95d..99fc018674e 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/some/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js index 153a5dd6b92..2b3b71ef2a3 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/some/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/some/invoked-as-func.js index 46728b6ab14..0bc2e92c1c5 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/some/invoked-as-func.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/some/invoked-as-method.js index aaf4f16b78f..83bee287483 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/some/invoked-as-method.js @@ -29,7 +29,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/length.js b/test/sendable/builtins/TypedArray/prototype/some/length.js index 453d4a8916e..7f01f6be4cc 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/length.js +++ b/test/sendable/builtins/TypedArray/prototype/some/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/name.js b/test/sendable/builtins/TypedArray/prototype/some/name.js index 8d421b3c75f..a043c0821b5 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/name.js +++ b/test/sendable/builtins/TypedArray/prototype/some/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/some/not-a-constructor.js index 9f78d65f29c..c22835d314b 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/some/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/some/prop-desc.js index aeb75893d3f..7e8fee5aa97 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/some/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js index e1ce18565de..acc41eb9c4f 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/some/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.some description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js b/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js index 29a3b284b7f..dfbf139369f 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js +++ b/test/sendable/builtins/TypedArray/prototype/some/returns-false-if-every-cb-returns-false.js @@ -29,7 +29,7 @@ info: | ... 7. Return true. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js b/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js index 5e9c030d190..48f88475cab 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js +++ b/test/sendable/builtins/TypedArray/prototype/some/returns-true-if-any-cb-returns-true.js @@ -35,7 +35,7 @@ info: | ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). iii. If testResult is true, return true. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/some/this-is-not-object.js index 04e08593aca..aa4620e89c6 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/some/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js index c2fe61c312f..1a5f8440201 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/some/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js b/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js index fb082cf8c5e..2cadfd17bc3 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js +++ b/test/sendable/builtins/TypedArray/prototype/some/values-are-not-cached.js @@ -34,7 +34,7 @@ info: | i. Let kValue be ? Get(O, Pk). ii. Let testResult be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js index 010a83a25a9..1c4b127667c 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/arraylength-internal.js @@ -21,7 +21,7 @@ info: | ... 3. Let len be the value of obj's [[ArrayLength]] internal slot. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js index 3fbbee905f2..431672359c3 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-call-throws.js @@ -34,7 +34,7 @@ info: | - If an abrupt completion is returned from any of these operations, it is immediately returned as the value of this function. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js index 6e640c7d0c7..4a4b030afc7 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-calls.js @@ -27,7 +27,7 @@ info: | a. Let v be ? Call(comparefn, undefined, « x, y »). ... ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js index 48747bf8342..8ab8fefd393 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-is-undefined.js @@ -22,7 +22,7 @@ info: | 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. ... -includes: [compareArray.js, testTypedArray.js] +includes: [compareArray.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js index be36553ec50..87ccec142ad 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/comparefn-nonfunction-call-throws.js @@ -27,7 +27,7 @@ info: | 1. If _comparefn_ is not *undefined* and IsCallable(_comparefn_) is *false*, throw a *TypeError* exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js index 6d9053d4355..f4d47fd40f1 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/detached-buffer.js @@ -27,7 +27,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-func.js index 0e5c5ac8211..96c9052315a 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-func.js @@ -35,7 +35,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-method.js index 823ba6ae9b2..38c8eaf97c9 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/invoked-as-method.js @@ -35,7 +35,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/length.js b/test/sendable/builtins/TypedArray/prototype/sort/length.js index 869b7cbc29f..3f5c8fa1b11 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/length.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/name.js b/test/sendable/builtins/TypedArray/prototype/sort/name.js index f908e9d3a2b..fa5457db1cd 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/name.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/sort/not-a-constructor.js index 535b1350b43..4d42d0162b7 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/sort/prop-desc.js index e17c900d91a..908168e3e3d 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js index 25ebd4c21ad..03d00bc4945 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.sort description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js b/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js index 5b8c9eb2580..71255421f16 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/return-same-instance.js @@ -23,7 +23,7 @@ info: | arguments x and y, the following steps are taken: ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js b/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js index 4426d9892ea..24a596eac53 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/sort-tonumber.js @@ -25,7 +25,7 @@ info: | b. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js b/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js index 89ac227caa4..95a750f1c72 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js @@ -27,7 +27,7 @@ info: | a. Let v be ? Call(comparefn, undefined, « x, y »). ... ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js index 872ebdbca16..cd9cc90d24f 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values-nan.js @@ -26,7 +26,7 @@ info: | NOTE: Because NaN always compares greater than any other value, NaN property values always sort to the end of the result when comparefn is not provided. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js index 7dd233bff4e..d838d025201 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/sorted-values.js @@ -23,7 +23,7 @@ info: | arguments x and y, the following steps are taken: ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/stability.js b/test/sendable/builtins/TypedArray/prototype/sort/stability.js index e49ce69010a..e8e4d89482e 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/stability.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/stability.js @@ -18,7 +18,7 @@ esid: sec-%sendableTypedArray%.prototype.sort description: Stability of %SendableTypedArray%.prototype.sort. info: | https://github.com/tc39/ecma262/pull/1433 -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-object.js index 7138e1815e0..5df32d2a1b6 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js index 3cb238a7013..cf0dab9a857 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js index b514e2de1f8..beb38df4497 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/detached-buffer.js @@ -43,7 +43,7 @@ info: | ... 11. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js b/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js index 6f10ef847e2..bd8eb3b1099 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/infinity.js @@ -18,7 +18,7 @@ esid: sec-%sendableTypedArray%.prototype.subarray description: Infinity values on begin and end info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-func.js index 9ec2127de76..3905c3df7b7 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-func.js @@ -24,7 +24,7 @@ info: | 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-method.js index 07f064b21a8..34b10645f4b 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/invoked-as-method.js @@ -24,7 +24,7 @@ info: | 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/length.js b/test/sendable/builtins/TypedArray/prototype/subarray/length.js index 1a82eba3c54..93c4b912f21 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js b/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js index 7f68cf4bdd1..a9b570abf87 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/minus-zero.js @@ -18,7 +18,7 @@ esid: sec-%sendableTypedArray%.prototype.subarray description: -0 values on begin and end info: | 22.2.3.27 %SendableTypedArray%.prototype.subarray( begin , end ) -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/name.js b/test/sendable/builtins/TypedArray/prototype/subarray/name.js index 8d2879362a9..bf4471e6cf4 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/name.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/subarray/not-a-constructor.js index 1ca3a1d13b4..4f6ae912a78 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/subarray/prop-desc.js index d1853d93eea..f31825736af 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js index 33579b67538..75efbfe1a9e 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-does-not-copy-ordinary-properties.js @@ -21,7 +21,7 @@ info: | ... 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js index 2fd026f4854..835ed6be395 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-from-same-ctor.js @@ -21,7 +21,7 @@ info: | ... 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js index 55a5b505459..036310ec234 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/result-is-new-instance-with-shared-buffer.js @@ -21,7 +21,7 @@ info: | ... 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js index b9b78e460da..30e663896dc 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-different-length.js @@ -21,7 +21,7 @@ info: | ... 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js index 901cf14adca..a10f59c92c2 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-empty-length.js @@ -21,7 +21,7 @@ info: | ... 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js index ea63f85b391..490ab273112 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/results-with-same-length.js @@ -21,7 +21,7 @@ info: | ... 17. Return ? SendableTypedArraySpeciesCreate(O, argumentsList). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js index 08f8dfd8b02..2112e555448 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin-symbol.js @@ -22,7 +22,7 @@ info: | ... 7. Let relativeBegin be ? ToInteger(begin). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js index 5df298ef382..b047925c1da 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-begin.js @@ -22,7 +22,7 @@ info: | ... 7. Let relativeBegin be ? ToInteger(begin). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js index 19c714db506..a2b1d4c22e1 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end-symbol.js @@ -23,7 +23,7 @@ info: | 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd be ? ToInteger(end). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js index 309eb897e58..6b07e792e6b 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/return-abrupt-from-end.js @@ -23,7 +23,7 @@ info: | 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd be ? ToInteger(end). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js index 77e7dcfb22e..2386fea0311 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-abrupt.js @@ -34,7 +34,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js index 8369837b1e0..5a5a5af5262 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-inherited.js @@ -34,7 +34,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js index 31fb6df527e..1b3c4196761 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor-returns-throws.js @@ -36,7 +36,7 @@ info: | 3. If C is undefined, return defaultConstructor. 4. If Type(C) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js index 88a5b22c324..bb7b79be925 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-ctor.js @@ -34,7 +34,7 @@ info: | 2. Let C be ? Get(O, "constructor"). 3. If C is undefined, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js index cbecde94d05..1d7ac5b1eb4 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-abrupt.js @@ -36,7 +36,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js index a9c2958a6d5..5076e671d12 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-invocation.js @@ -44,7 +44,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js index 3bc7d9bc1ea..fa5bb6b1dc6 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-returns-another-instance.js @@ -44,7 +44,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js index 818d47fe7bb..bb932e7a171 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor-throws.js @@ -42,7 +42,7 @@ info: | 1. Let newSendableTypedArray be ? Construct(constructor, argumentList). 2. Perform ? ValidateSendableTypedArray(newSendableTypedArray). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js index f942afb0f65..eb863c4faf0 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-custom-ctor.js @@ -44,7 +44,7 @@ info: | 3. If argumentList is a List of a single Number, then ... 4. Return newSendableTypedArray. -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js index 5eb260a48e1..f1e24f29d3b 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-returns-throws.js @@ -37,7 +37,7 @@ info: | 7. If IsConstructor(S) is true, return S. 8. Throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js index d9ae35f48fc..4b15d9bf1c1 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species-use-default-ctor.js @@ -35,7 +35,7 @@ info: | 5. Let S be ? Get(C, @@species). 6. If S is either undefined or null, return defaultConstructor. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js index 064dcc6c73b..6aa9c378977 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/speciesctor-get-species.js @@ -36,7 +36,7 @@ info: | ... 5. Let S be ? Get(C, @@species). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.species, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-object.js index a5592df640d..1a1552f7b4f 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-object.js @@ -24,7 +24,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js index d15967b713c..86088ab11ed 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/this-is-not-typedarray-instance.js @@ -27,7 +27,7 @@ info: | 3. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js index f3eae4da16a..0cebe3aab98 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-begin.js @@ -22,7 +22,7 @@ info: | ... 7. Let relativeBegin be ? ToInteger(begin). ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js index 83e2c70ea4b..f95e60ed21a 100644 --- a/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js +++ b/test/sendable/builtins/TypedArray/prototype/subarray/tointeger-end.js @@ -23,7 +23,7 @@ info: | 9. If end is undefined, let relativeEnd be srcLength; else, let relativeEnd be ? ToInteger(end). ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js index 26777297d24..a4e8c3c061a 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tolocalestring-from-each-value.js @@ -40,7 +40,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js index e1dc4c7d925..8ffa3757f4b 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-tostring-from-each-value.js @@ -41,7 +41,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js index d992d8184cb..e353a7f9154 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/calls-valueof-from-each-value.js @@ -41,7 +41,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js index 2bc93f021b9..debdcee52ea 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js index 79760788ad9..ed94192af6d 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/empty-instance-returns-empty-string.js @@ -29,7 +29,7 @@ info: | ... 4. If len is zero, return the empty String. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js index 7bf454fe6ea..9daee2438b2 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | 1. Let array be ? ToObject(this value). 2.Let len be ? ToLength(? Get(array, "length")). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-func.js index 77eafe795c6..9864acc1231 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-func.js @@ -31,7 +31,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-method.js index b0d13a773f8..20503eb6687 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/invoked-as-method.js @@ -31,7 +31,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/length.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/length.js index 61296bb94a1..e7549b2a0e3 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/length.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/name.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/name.js index fd91a2b3d0a..2afe20e5ffa 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/name.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/not-a-constructor.js index e7eb42898c5..4207b72a1cd 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/prop-desc.js index f0f90246261..ff306e9d578 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js index 0a6a26b330a..9c0ab4c2b03 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tolocalestring.js @@ -33,7 +33,7 @@ info: | a. Let R be the empty String. 7. Else, a. Let R be ? ToString(? Invoke(firstElement, "toLocaleString")). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js index 823555cac35..332a243fa2e 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-tostring.js @@ -41,7 +41,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js index e78fa46ff98..117c817f30e 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-firstelement-valueof.js @@ -41,7 +41,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js index cc926c10069..85a00111c02 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tolocalestring.js @@ -34,7 +34,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js index cc7d71d8f18..3ba5caf1b2d 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-tostring.js @@ -41,7 +41,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js index 744cca83713..e874a211114 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-nextelement-valueof.js @@ -41,7 +41,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js index 846687c3070..b6e2b1e8d51 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js index 089f46ced5b..61623291a0c 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/return-result.js @@ -40,7 +40,7 @@ info: | i. Let R be the empty String. d. Else, i. Let R be ? ToString(? Invoke(nextElement, "toLocaleString")). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-object.js index 81330634d9f..f250c30c824 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-object.js @@ -27,7 +27,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js index f7d88e1b1ab..f0d60ccb122 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/this-is-not-typedarray-instance.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js b/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js index 7dc96ed5153..f2257da9c51 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/ignores-species.js @@ -28,7 +28,7 @@ info: | ... 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js b/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js index 0c44795ed5b..166c04559bb 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/immutable.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.toReversed description: > %SendableTypedArray%.prototype.toReversed does not mutate its this value -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js b/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js index 1ce8be2001a..ab7041feb11 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/length-property-ignored.js @@ -23,7 +23,7 @@ info: | ... 3. Let length be O.[[ArrayLength]]. ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/length.js b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/length.js index 9dff1fd3826..b6539e5b2ca 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/length.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/length.js @@ -30,7 +30,7 @@ info: | Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/name.js b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/name.js index 592be3bb341..e8a00703283 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/name.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/property-descriptor.js b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/property-descriptor.js index f2403295da7..e145426a756 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/property-descriptor.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/metadata/property-descriptor.js @@ -23,7 +23,7 @@ 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/toReversed/not-a-constructor.js index bf8302dec6a..45cbccca5b6 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [TypedArray, change-array-by-copy, Reflect.construct] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js b/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js index a88e096f324..197d4e6aa43 100644 --- a/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js +++ b/test/sendable/builtins/TypedArray/prototype/toReversed/this-value-invalid.js @@ -23,7 +23,7 @@ info: | 1. Let O be the this value. 2. Perform ? ValidateSendableTypedArray(O). ... -includes: [detachArrayBuffer.js, testTypedArray.js] +includes: [detachArrayBuffer.js, sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js index 59e3e9c78df..480a4f617e8 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-not-a-function.js @@ -23,7 +23,7 @@ info: | 1. If comparefn is not undefined and IsCallable(comparefn) is false, throw a TypeError exception. 2. ... 3. Let len be ? LengthOfArrayLike(O). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js index 643ca8e8ef3..a345604b435 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/comparefn-stop-after-error.js @@ -26,7 +26,7 @@ info: | completion, stop before performing any further calls to SortCompare or steps in this algorithm and return that completion. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js b/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js index 454dbef954b..c47a3203ca0 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/ignores-species.js @@ -28,7 +28,7 @@ info: | ... 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js b/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js index 713c53124c4..503adda11dc 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/immutable.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.toSorted description: > %SendableTypedArray%.prototype.toSorted does not mutate its this value -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js b/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js index ef4b9e93208..a5e8e33ba62 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/length-property-ignored.js @@ -23,7 +23,7 @@ info: | ... 4. Let len be O.[[ArrayLength]]. ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/length.js b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/length.js index d80f4717500..d6f880d2cf4 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/length.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/length.js @@ -30,7 +30,7 @@ info: | Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/name.js b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/name.js index 0bf5a465df5..6d4d329a7fa 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/name.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/property-descriptor.js b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/property-descriptor.js index c780901806b..7c1a5837192 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/property-descriptor.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/metadata/property-descriptor.js @@ -23,7 +23,7 @@ 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/toSorted/not-a-constructor.js index dd25753c678..258fe5aa29d 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [TypedArray, change-array-by-copy, Reflect.construct] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js b/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js index 231544f7355..2ff16090694 100644 --- a/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js +++ b/test/sendable/builtins/TypedArray/prototype/toSorted/this-value-invalid.js @@ -23,7 +23,7 @@ info: | 2. Let O be the this value. 3. Perform ? ValidateSendableTypedArray(O). ... -includes: [detachArrayBuffer.js, testTypedArray.js] +includes: [detachArrayBuffer.js, sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toString.js b/test/sendable/builtins/TypedArray/prototype/toString.js index 295c133f2df..45cd975c8da 100644 --- a/test/sendable/builtins/TypedArray/prototype/toString.js +++ b/test/sendable/builtins/TypedArray/prototype/toString.js @@ -27,7 +27,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js index f3c8632fe12..70d24049e5e 100644 --- a/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/toString/detached-buffer.js @@ -32,7 +32,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toString/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/toString/not-a-constructor.js index dda9fcef61e..c5d4d2c25e4 100644 --- a/test/sendable/builtins/TypedArray/prototype/toString/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/toString/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js index c7878789b7c..d7ea12767bc 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/values/detached-buffer.js @@ -27,7 +27,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testTypedArray.js, detachArrayBuffer.js] +includes: [sendableTypedArray.js, detachArrayBuffer.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/values/invoked-as-func.js index 58347c03d87..19cd0cf7f56 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/values/invoked-as-func.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/invoked-as-method.js b/test/sendable/builtins/TypedArray/prototype/values/invoked-as-method.js index 40de76e3007..aeb582202a3 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/invoked-as-method.js +++ b/test/sendable/builtins/TypedArray/prototype/values/invoked-as-method.js @@ -30,7 +30,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js b/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js index 0d6c03f79de..e244e38e0ce 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js +++ b/test/sendable/builtins/TypedArray/prototype/values/iter-prototype.js @@ -22,7 +22,7 @@ info: | ... 3. Return CreateArrayIterator(O, "value"). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol.iterator, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/length.js b/test/sendable/builtins/TypedArray/prototype/values/length.js index 1db2ba2a275..d7b2e90071a 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/length.js +++ b/test/sendable/builtins/TypedArray/prototype/values/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/name.js b/test/sendable/builtins/TypedArray/prototype/values/name.js index b69590e5cee..dfd4a40b2fa 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/name.js +++ b/test/sendable/builtins/TypedArray/prototype/values/name.js @@ -28,7 +28,7 @@ info: | 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/values/not-a-constructor.js index 0d61ab80b53..6f2a8422f66 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/values/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [Reflect.construct, arrow-function, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/values/prop-desc.js index 4817e5ec606..4f0e78c2729 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/values/prop-desc.js @@ -21,7 +21,7 @@ info: | ES6 section 17: 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, testTypedArray.js] +includes: [propertyHelper.js, sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js index dcdfaa7cd28..b17be97dc20 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/values/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.values description: Return abrupt when "this" value fails buffer boundary checks -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [ArrayBuffer, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/return-itor.js b/test/sendable/builtins/TypedArray/prototype/values/return-itor.js index 1abeb83c279..b7a2b106e88 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/return-itor.js +++ b/test/sendable/builtins/TypedArray/prototype/values/return-itor.js @@ -21,7 +21,7 @@ info: | ... 3. Return CreateArrayIterator(O, "value"). -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/values/this-is-not-object.js index a02bde0d02b..33eb880cfde 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/values/this-is-not-object.js @@ -29,7 +29,7 @@ info: | 1. If Type(O) is not Object, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [Symbol, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js b/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js index 5167a061111..062e84d68b1 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js +++ b/test/sendable/builtins/TypedArray/prototype/values/this-is-not-typedarray-instance.js @@ -32,7 +32,7 @@ info: | 2. If O does not have a [[TypedArrayName]] internal slot, throw a TypeError exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js b/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js index 662224dbe4b..a03688815d8 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js +++ b/test/sendable/builtins/TypedArray/prototype/with/early-type-coercion.js @@ -25,7 +25,7 @@ info: | 8. Else, set _value_ to ? ToNumber(_value_). ... features: [TypedArray, change-array-by-copy] -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] ---*/ testWithTypedArrayConstructors(TA => { diff --git a/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js b/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js index 4fe47ea8987..1761c1016ac 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js +++ b/test/sendable/builtins/TypedArray/prototype/with/ignores-species.js @@ -28,7 +28,7 @@ info: | ... 2. Let constructor be the intrinsic object listed in column one of Table 63 for exemplar.[[TypedArrayName]]. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/with/immutable.js b/test/sendable/builtins/TypedArray/prototype/with/immutable.js index 5539560ed17..1ff1636c081 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/immutable.js +++ b/test/sendable/builtins/TypedArray/prototype/with/immutable.js @@ -17,7 +17,7 @@ esid: sec-%sendableTypedArray%.prototype.with description: > %SendableTypedArray%.prototype.with does not mutate its this value -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js b/test/sendable/builtins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js index f0e9b585392..8d68a9965bd 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js +++ b/test/sendable/builtins/TypedArray/prototype/with/index-bigger-or-eq-than-length.js @@ -27,7 +27,7 @@ info: | 5. Else, let actualIndex be len + relativeIndex. 6. If ! IsValidIntegerIndex(O, actualIndex) is false, throw a *RangeError* exception. ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js b/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js index 9d251bac0f0..07c4750c508 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js +++ b/test/sendable/builtins/TypedArray/prototype/with/index-casted-to-number.js @@ -27,7 +27,7 @@ info: | 5. Else, let actualIndex be len + relativeIndex. ... features: [TypedArray, change-array-by-copy] -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] ---*/ testWithTypedArrayConstructors(TA => { diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-negative.js b/test/sendable/builtins/TypedArray/prototype/with/index-negative.js index 90309815d2a..306795544a2 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/index-negative.js +++ b/test/sendable/builtins/TypedArray/prototype/with/index-negative.js @@ -27,7 +27,7 @@ info: | 5. Else, let actualIndex be len + relativeIndex. ... features: [TypedArray, change-array-by-copy] -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] ---*/ testWithTypedArrayConstructors(TA => { diff --git a/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js b/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js index fb7a6999ee0..22dd26e52d6 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js +++ b/test/sendable/builtins/TypedArray/prototype/with/index-smaller-than-minus-length.js @@ -28,7 +28,7 @@ info: | 6. If actualIndex >= len or actualIndex < 0, throw a *RangeError* exception. ... features: [TypedArray, change-array-by-copy] -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] ---*/ testWithTypedArrayConstructors(TA => { diff --git a/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js b/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js index 697d3237c4a..58eedc2f09d 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js +++ b/test/sendable/builtins/TypedArray/prototype/with/length-property-ignored.js @@ -23,7 +23,7 @@ info: | ... 3. Let len be O.[[ArrayLength]]. ... -includes: [testTypedArray.js, compareArray.js] +includes: [sendableTypedArray.js, compareArray.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/with/metadata/length.js b/test/sendable/builtins/TypedArray/prototype/with/metadata/length.js index 0d09091415e..64c0571d872 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/metadata/length.js +++ b/test/sendable/builtins/TypedArray/prototype/with/metadata/length.js @@ -30,7 +30,7 @@ info: | Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [testTypedArray.js, propertyHelper.js] +includes: [sendableTypedArray.js, propertyHelper.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/with/metadata/name.js b/test/sendable/builtins/TypedArray/prototype/with/metadata/name.js index 1fbd8773b13..c3740a3ec10 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/metadata/name.js +++ b/test/sendable/builtins/TypedArray/prototype/with/metadata/name.js @@ -28,7 +28,7 @@ info: | 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: [testTypedArray.js, propertyHelper.js] +includes: [sendableTypedArray.js, propertyHelper.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/with/metadata/property-descriptor.js b/test/sendable/builtins/TypedArray/prototype/with/metadata/property-descriptor.js index 2d7439cbf5b..dba7549a996 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/metadata/property-descriptor.js +++ b/test/sendable/builtins/TypedArray/prototype/with/metadata/property-descriptor.js @@ -23,7 +23,7 @@ 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: [testTypedArray.js, propertyHelper.js] +includes: [sendableTypedArray.js, propertyHelper.js] features: [TypedArray, change-array-by-copy] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/with/not-a-constructor.js b/test/sendable/builtins/TypedArray/prototype/with/not-a-constructor.js index c2946f997d6..3c28b54e187 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/not-a-constructor.js +++ b/test/sendable/builtins/TypedArray/prototype/with/not-a-constructor.js @@ -29,7 +29,7 @@ info: | ... 7. If IsConstructor(constructor) is false, throw a TypeError exception. ... -includes: [isConstructor.js, testTypedArray.js] +includes: [isConstructor.js, sendableTypedArray.js] features: [TypedArray, change-array-by-copy, Reflect.construct] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/with/this-value-invalid.js b/test/sendable/builtins/TypedArray/prototype/with/this-value-invalid.js index 3d8da3b4a9b..6320559702f 100644 --- a/test/sendable/builtins/TypedArray/prototype/with/this-value-invalid.js +++ b/test/sendable/builtins/TypedArray/prototype/with/this-value-invalid.js @@ -23,7 +23,7 @@ info: | 1. Let O be the this value. 2. Perform ? ValidateSendableTypedArray(O). ... -includes: [testTypedArray.js] +includes: [sendableTypedArray.js] features: [TypedArray, change-array-by-copy] ---*/ -- Gitee From 54518fc6a4087401472b3c5ad14208bba279360a Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 16 Jan 2025 15:43:02 +0800 Subject: [PATCH 84/93] fix SendableTypedArray is not defined Signed-off-by: zhuzhihui7 --- harness/sendableBigIntTypedArray.js | 52 +++++++++++++++++++ .../BigInt/detached-buffer.js | 2 +- .../BigInt/invoked-as-accessor.js | 2 +- .../BigInt/invoked-as-func.js | 2 +- .../Symbol.toStringTag/BigInt/length.js | 2 +- .../Symbol.toStringTag/BigInt/name.js | 2 +- .../Symbol.toStringTag/BigInt/prop-desc.js | 2 +- .../BigInt/return-typedarrayname.js | 2 +- .../this-has-no-typedarrayname-internal.js | 2 +- .../BigInt/this-is-not-object.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../byteOffset/BigInt/detached-buffer.js | 2 +- .../BigInt/resizable-array-buffer-auto.js | 2 +- .../BigInt/resizable-array-buffer-fixed.js | 2 +- .../byteOffset/BigInt/return-byteoffset.js | 2 +- .../entries/BigInt/detached-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../BigInt/get-length-ignores-length-prop.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../filter/BigInt/arraylength-internal.js | 2 +- .../filter/BigInt/callbackfn-detachbuffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../BigInt/get-length-ignores-length-prop.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../BigInt/get-length-ignores-length-prop.js | 2 +- .../BigInt/predicate-call-this-non-strict.js | 2 +- .../BigInt/predicate-may-detach-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../BigInt/get-length-ignores-length-prop.js | 2 +- .../BigInt/predicate-call-this-non-strict.js | 2 +- .../BigInt/predicate-may-detach-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../findLastIndex/BigInt/detached-buffer.js | 2 +- .../BigInt/get-length-ignores-length-prop.js | 2 +- .../BigInt/predicate-call-this-non-strict.js | 2 +- .../BigInt/predicate-may-detach-buffer.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../array-arg-target-arraylength-internal.js | 2 +- ...typedarray-arg-src-arraylength-internal.js | 2 +- .../typedarray-arg-src-byteoffset-internal.js | 2 +- ...edarray-arg-target-arraylength-internal.js | 2 +- ...pedarray-arg-target-byteoffset-internal.js | 2 +- .../typedarray-arg-target-out-of-bounds.js | 2 +- .../slice/BigInt/arraylength-internal.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../sort/BigInt/arraylength-internal.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../get-length-uses-internal-arraylength.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- .../return-abrupt-from-this-out-of-bounds.js | 2 +- 70 files changed, 121 insertions(+), 69 deletions(-) create mode 100644 harness/sendableBigIntTypedArray.js diff --git a/harness/sendableBigIntTypedArray.js b/harness/sendableBigIntTypedArray.js new file mode 100644 index 00000000000..9e7a99bbb9c --- /dev/null +++ b/harness/sendableBigIntTypedArray.js @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/*--- +description: | + Collection of functions used to assert the correctness of BigInt TypedArray objects. +defines: + - TypedArray + - testWithBigIntTypedArrayConstructors +---*/ + +/** + * The %TypedArray% intrinsic constructor function. + */ +var SendableTypedArray = Object.getPrototypeOf(Int8Array); + +/** + * Calls the provided function for every typed array constructor. + * + * @param {typedArrayConstructorCallback} f - the function to call for each typed array constructor. + * @param {Array} selected - An optional Array with filtered typed arrays + */ +function testWithBigIntTypedArrayConstructors(f, selected) { + /** + * Array containing every BigInt typed array constructor. + */ + var constructors = selected || [ + BigInt64Array, + BigUint64Array + ]; + + for (var i = 0; i < constructors.length; ++i) { + var constructor = constructors[i]; + try { + f(constructor); + } catch (e) { + e.message += " (Testing with " + constructor.name + ".)"; + throw e; + } + } +} diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js index 43fb2310380..763f61f2d42 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/detached-buffer.js @@ -23,7 +23,7 @@ info: | 4. Let name be the value of O's [[TypedArrayName]] internal slot. 5. Assert: name is a String value. 6. Return name. -includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +includes: [sendableBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js index bce272476b3..31e9597abbc 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-accessor.js @@ -24,7 +24,7 @@ info: | ... 3. If O does not have a [[TypedArrayName]] internal slot, return undefined. ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js index 2f0431c2b5c..2a277400876 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/invoked-as-func.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, return undefined. ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js index fc27a805b57..d6d2fb6e6ba 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/length.js @@ -31,7 +31,7 @@ info: | Unless otherwise specified, the length property of a built-in Function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testBigIntTypedArray.js] +includes: [propertyHelper.js, sendableBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js index 8ee106f99e3..45e4da17b1d 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/name.js @@ -28,7 +28,7 @@ info: | 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, testBigIntTypedArray.js] +includes: [propertyHelper.js, sendableBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js index 3170142e1bd..7c972c15849 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/prop-desc.js @@ -26,7 +26,7 @@ info: | This property has the attributes { [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js, testBigIntTypedArray.js] +includes: [propertyHelper.js, sendableBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js index 46675c89dfa..d5f2be6adaa 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/return-typedarrayname.js @@ -24,7 +24,7 @@ info: | 4. Let name be the value of O's [[TypedArrayName]] internal slot. 5. Assert: name is a String value. 6. Return name. -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js index 384265f33f1..3f3ae7c1563 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-has-no-typedarrayname-internal.js @@ -24,7 +24,7 @@ info: | ... 3. If O does not have a [[TypedArrayName]] internal slot, return undefined. ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, Symbol.toStringTag, DataView, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js index 3ffea3b142e..c27c5fad404 100644 --- a/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js +++ b/test/sendable/builtins/TypedArray/prototype/Symbol.toStringTag/BigInt/this-is-not-object.js @@ -22,7 +22,7 @@ info: | 1. Let O be the this value. 2. If Type(O) is not Object, return undefined. ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, Symbol, Symbol.toStringTag, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js index fbfc42e609f..d3b5d963620 100644 --- a/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/at/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.at description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, SendableTypedArray.prototype.at, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js index 32f72ac5dac..e01f018be99 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/detached-buffer.js @@ -23,7 +23,7 @@ info: | 4. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 5. If IsDetachedBuffer(buffer) is true, return 0. ... -includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +includes: [sendableBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js index c15818608fa..6ebcd954b49 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-auto.js @@ -18,7 +18,7 @@ esid: sec-get-%typedarray%.prototype.byteoffset description: | reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the dynamically-sized SendableTypedArray instance -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js index 2e0295270aa..b30773f1ae7 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/resizable-array-buffer-fixed.js @@ -18,7 +18,7 @@ esid: sec-get-%typedarray%.prototype.byteoffset description: | reset to 0 if the underlying ArrayBuffer is resized beyond the boundary of the fixed-sized SendableTypedArray instance -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js index 3487eb36d74..667e34575cf 100644 --- a/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js +++ b/test/sendable/builtins/TypedArray/prototype/byteOffset/BigInt/return-byteoffset.js @@ -23,7 +23,7 @@ info: | ... 6. Let offset be the value of O's [[ByteOffset]] internal slot. 7. Return size. -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js index b4928bba49d..b7a148dac35 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/detached-buffer.js @@ -27,7 +27,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +includes: [sendableBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js index 73b1163a743..7f820b86790 100644 --- a/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/entries/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.entries description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js index c383bad5b2b..12f61ad6032 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js index bfef0b3b3ca..7b346ec55ef 100644 --- a/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/every/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.every description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js index 543e1488723..de323fba07e 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/get-length-ignores-length-prop.js @@ -36,7 +36,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js index 0e5833c4313..864ca283a75 100644 --- a/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/fill/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.fill description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js index 46fd240b337..ede21fbf08c 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/arraylength-internal.js @@ -22,7 +22,7 @@ info: | ... 3. Let len be the value of O's [[ArrayLength]] internal slot. ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js index 8cf5fe42592..570f9115fcf 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js @@ -26,7 +26,7 @@ info: | b. Let kValue be ? Get(O, Pk). c. Let selected be ToBoolean(? Call(callbackfn, T, « kValue, k, O »)). ... -includes: [detachArrayBuffer.js, testBigIntTypedArray.js] +includes: [detachArrayBuffer.js, sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js index 57a1a0e2d38..c111fe97884 100644 --- a/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/filter/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.filter description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js index 6f7a19de20d..784263067ed 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/get-length-ignores-length-prop.js @@ -34,7 +34,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js index 1ff33109e0f..8b0787579de 100644 --- a/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/find/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.find description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js index 572bbdf38b2..3916a9634b0 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/get-length-ignores-length-prop.js @@ -32,7 +32,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js index 370d70b3941..b2dfa5c504b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-call-this-non-strict.js @@ -37,7 +37,7 @@ info: | c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)). ... flags: [noStrict] -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js index f1974442c33..f58ac3841bb 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js @@ -42,7 +42,7 @@ info: | 3. Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. 4. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +includes: [sendableBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js index af70fd686c5..983a7531dcc 100644 --- a/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findIndex/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.findindex description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js index 85279af8845..b96d0939a75 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/get-length-ignores-length-prop.js @@ -23,7 +23,7 @@ info: | ... 3. Let len be O.[[ArrayLength]]. ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js index 7bfd22ed864..fc205b1c69b 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-call-this-non-strict.js @@ -25,7 +25,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... flags: [noStrict] -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js index 7759d963767..c24f3ffa84d 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/predicate-may-detach-buffer.js @@ -33,7 +33,7 @@ info: | Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. -includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +includes: [sendableBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js index 6b5ca651a39..ffdb2357d1c 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findLast/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.findlast description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, array-find-from-last, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js index bc3da86ce8f..142a22aea71 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/detached-buffer.js @@ -28,7 +28,7 @@ info: | ... 5. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. ... -includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +includes: [sendableBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js index 43de6a866f7..83ab5520485 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/get-length-ignores-length-prop.js @@ -23,7 +23,7 @@ info: | ... 3. Let len be O.[[ArrayLength]]. ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js index 18fbfbedb05..c0f5c75211e 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-call-this-non-strict.js @@ -27,7 +27,7 @@ info: | c. Let testResult be ! ToBoolean(? Call(predicate, thisArg, « kValue, 𝔽(k), O »)). ... flags: [noStrict] -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js index a037ac1a245..9c54800c241 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/predicate-may-detach-buffer.js @@ -32,7 +32,7 @@ info: | Let buffer be the value of O's [[ViewedArrayBuffer]] internal slot. If IsDetachedBuffer(buffer) is true, return undefined. -includes: [testBigIntTypedArray.js, detachArrayBuffer.js] +includes: [sendableBigIntTypedArray.js, detachArrayBuffer.js] features: [BigInt, SendableTypedArray, array-find-from-last] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js index ace5d4b9875..ff447347799 100644 --- a/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/findLastIndex/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.findlastindex description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, array-find-from-last, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js index 83f944e3c79..d53d05bd28b 100644 --- a/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/forEach/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.foreach description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js index 7fd9ac35ed8..9aae0af515f 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js index 28edbae3aac..47e8b9feaff 100644 --- a/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/includes/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.includes description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js index 9a36898ab37..d1ad8ca9b30 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js index 8b0c04fc0b2..4a97e0688de 100644 --- a/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/indexOf/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.indexof description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js index 9fbde2fd21d..6861141572a 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/get-length-uses-internal-arraylength.js @@ -31,7 +31,7 @@ info: | ... 5. If len is zero, return the empty String. ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js index fd27dfa0f74..c8ea76d95d5 100644 --- a/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/join/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.join description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js index 588d1ccce68..88ff9fe98e6 100644 --- a/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/keys/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.keys description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js index 71d94789262..bc3d26febb5 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | ... 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js index f3d8de2c7fc..9fba59dbfb5 100644 --- a/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/lastIndexOf/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.lastindexof description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js index c6cb3deda6b..e8651c86ef1 100644 --- a/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/map/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.map description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js index 754ac305f18..28c9c6a0c74 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js index 296c2c0f55b..bda78b32384 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reduce/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.reduce description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js index a42d356a5e7..ad37cbd354e 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js index fea17212ad6..4b1b983bdfe 100644 --- a/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reduceRight/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.reduceright description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js index 1a2b04e1e6d..9da6f23792c 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js index 332cee2054a..98a2944c5e8 100644 --- a/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/reverse/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.reverse description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js index be1b1d42048..ac8eeb14681 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/array-arg-target-arraylength-internal.js @@ -28,7 +28,7 @@ info: | ... 17. If srcLength + targetOffset > targetLength, throw a RangeError exception. ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js index 96d7449055f..7815db525bd 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-arraylength-internal.js @@ -27,7 +27,7 @@ info: | ... 22. If srcLength + targetOffset > targetLength, throw a RangeError exception. ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js index 97bb10df938..802f04b72a1 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-src-byteoffset-internal.js @@ -24,7 +24,7 @@ info: | ... 21. Let srcByteOffset be typedArray.[[ByteOffset]]. ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js index 6a47d698cc5..952dc624e65 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-arraylength-internal.js @@ -28,7 +28,7 @@ info: | ... 22. If srcLength + targetOffset > targetLength, throw a RangeError exception. ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js index 609172280eb..eb4df9be008 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-byteoffset-internal.js @@ -25,7 +25,7 @@ info: | ... 16. Let targetByteOffset be target.[[ByteOffset]]. ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js index b16fc551dbf..94ba23e5d76 100644 --- a/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/set/BigInt/typedarray-arg-target-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.set-typedarray-offset description: Error when target SendableTypedArray fails boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, SendableTypedArray, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js index bb3a38dfcc6..6bdd03bc2e9 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/arraylength-internal.js @@ -22,7 +22,7 @@ info: | ... 3. Let len be the value of O's [[ArrayLength]] internal slot. ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js index 0235df9f9ab..8a8a9532cdc 100644 --- a/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/slice/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.slice description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js index ee93b737cc7..1337caa8928 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.some description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js index 3b428c8f6ab..d1d76a49d02 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/arraylength-internal.js @@ -21,7 +21,7 @@ info: | ... 3. Let len be the value of obj's [[ArrayLength]] internal slot. -includes: [testBigIntTypedArray.js, compareArray.js] +includes: [sendableBigIntTypedArray.js, compareArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js index 2799fe8861e..89375bdb56f 100644 --- a/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/sort/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.sort description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js index 234e2b84d22..232126b8ae5 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | 1. Let array be ? ToObject(this value). 2.Let len be ? ToLength(? Get(array, "length")). ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js index dd69356ed6c..d4c30d13bca 100644 --- a/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/toLocaleString/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.tolocalestring description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js index d576b5486e5..621cd72e5ce 100644 --- a/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/values/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.values description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ -- Gitee From 0f696105cdca2582e17023895da072a0d8225877 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Thu, 16 Jan 2025 15:51:52 +0800 Subject: [PATCH 85/93] fix SendableTypedArray is not defined --- .../copyWithin/BigInt/get-length-ignores-length-prop.js | 2 +- .../copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js | 2 +- .../some/BigInt/get-length-uses-internal-arraylength.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js index 160e86be7fa..1264f26ca73 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/get-length-ignores-length-prop.js @@ -34,7 +34,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js index 0d6f2b3023f..1388edd10f8 100644 --- a/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js +++ b/test/sendable/builtins/TypedArray/prototype/copyWithin/BigInt/return-abrupt-from-this-out-of-bounds.js @@ -16,7 +16,7 @@ /*--- esid: sec-%sendableTypedArray%.prototype.copywithin description: Return abrupt when "this" value fails buffer boundary checks -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [ArrayBuffer, BigInt, SendableTypedArray, arrow-function, resizable-arraybuffer] ---*/ diff --git a/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js b/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js index 554a395f608..92257e3ce94 100644 --- a/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js +++ b/test/sendable/builtins/TypedArray/prototype/some/BigInt/get-length-uses-internal-arraylength.js @@ -29,7 +29,7 @@ info: | 1. Let O be ? ToObject(this value). 2. Let len be ? ToLength(? Get(O, "length")). ... -includes: [testBigIntTypedArray.js] +includes: [sendableBigIntTypedArray.js] features: [BigInt, TypedArray] ---*/ -- Gitee From 872a0ddc9e8771179abdca594bb92882d4b5ed93 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Fri, 17 Jan 2025 17:16:38 +0800 Subject: [PATCH 86/93] update sendable function to shared function Signed-off-by: zhuzhihui7 --- .../builtins/Function/15.3.2.1-10-6gs.js | 4 ++-- .../builtins/Function/15.3.2.1-11-1-s.js | 4 ++-- test/sendable/builtins/Function/15.3.2.1-11-1.js | 4 ++-- .../builtins/Function/15.3.2.1-11-2-s.js | 4 ++-- .../builtins/Function/15.3.2.1-11-3-s.js | 4 ++-- test/sendable/builtins/Function/15.3.2.1-11-3.js | 4 ++-- .../builtins/Function/15.3.2.1-11-4-s.js | 4 ++-- .../builtins/Function/15.3.2.1-11-5-s.js | 4 ++-- test/sendable/builtins/Function/15.3.2.1-11-5.js | 4 ++-- .../builtins/Function/15.3.2.1-11-6-s.js | 4 ++-- .../builtins/Function/15.3.2.1-11-7-s.js | 4 ++-- .../builtins/Function/15.3.2.1-11-8-s.js | 4 ++-- .../builtins/Function/15.3.2.1-11-9-s.js | 4 ++-- .../builtins/Function/15.3.5.4_2-10gs.js | 4 ++-- .../builtins/Function/15.3.5.4_2-58gs.js | 4 ++-- .../builtins/Function/15.3.5.4_2-59gs.js | 4 ++-- .../builtins/Function/15.3.5.4_2-60gs.js | 2 +- .../builtins/Function/15.3.5.4_2-61gs.js | 2 +- .../builtins/Function/15.3.5.4_2-62gs.js | 2 +- .../builtins/Function/15.3.5.4_2-63gs.js | 2 +- .../builtins/Function/15.3.5.4_2-64gs.js | 2 +- .../builtins/Function/15.3.5.4_2-65gs.js | 2 +- .../builtins/Function/15.3.5.4_2-66gs.js | 2 +- .../builtins/Function/15.3.5.4_2-67gs.js | 2 +- .../builtins/Function/15.3.5.4_2-68gs.js | 2 +- .../builtins/Function/15.3.5.4_2-69gs.js | 2 +- .../builtins/Function/15.3.5.4_2-70gs.js | 2 +- .../builtins/Function/15.3.5.4_2-71gs.js | 2 +- .../builtins/Function/15.3.5.4_2-72gs.js | 2 +- .../builtins/Function/15.3.5.4_2-73gs.js | 2 +- .../builtins/Function/15.3.5.4_2-74gs.js | 2 +- .../builtins/Function/15.3.5.4_2-77gs.js | 4 ++-- .../builtins/Function/15.3.5.4_2-78gs.js | 4 ++-- .../builtins/Function/15.3.5.4_2-79gs.js | 2 +- .../sendable/builtins/Function/15.3.5.4_2-7gs.js | 4 ++-- .../builtins/Function/15.3.5.4_2-80gs.js | 2 +- .../builtins/Function/15.3.5.4_2-81gs.js | 2 +- .../builtins/Function/15.3.5.4_2-82gs.js | 2 +- .../builtins/Function/15.3.5.4_2-83gs.js | 2 +- .../builtins/Function/15.3.5.4_2-84gs.js | 2 +- .../builtins/Function/15.3.5.4_2-85gs.js | 2 +- .../builtins/Function/15.3.5.4_2-86gs.js | 2 +- .../builtins/Function/15.3.5.4_2-87gs.js | 2 +- .../builtins/Function/15.3.5.4_2-88gs.js | 2 +- .../builtins/Function/15.3.5.4_2-89gs.js | 2 +- .../sendable/builtins/Function/15.3.5.4_2-8gs.js | 4 ++-- .../builtins/Function/15.3.5.4_2-90gs.js | 2 +- .../builtins/Function/15.3.5.4_2-91gs.js | 2 +- .../builtins/Function/15.3.5.4_2-92gs.js | 2 +- .../builtins/Function/15.3.5.4_2-93gs.js | 2 +- .../builtins/Function/15.3.5.4_2-95gs.js | 2 +- .../sendable/builtins/Function/15.3.5.4_2-9gs.js | 4 ++-- test/sendable/builtins/Function/S10.1.1_A1_T3.js | 4 ++-- test/sendable/builtins/Function/S15.3.1_A1_T1.js | 12 ++++++------ .../builtins/Function/S15.3.2.1_A1_T1.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A1_T10.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A1_T11.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A1_T12.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A1_T13.js | 6 +++--- .../builtins/Function/S15.3.2.1_A1_T2.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A1_T3.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A1_T4.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A1_T5.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A1_T6.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A1_T7.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A1_T8.js | 6 +++--- .../builtins/Function/S15.3.2.1_A1_T9.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A2_T1.js | 4 ++-- .../builtins/Function/S15.3.2.1_A2_T2.js | 4 ++-- .../builtins/Function/S15.3.2.1_A2_T3.js | 4 ++-- .../builtins/Function/S15.3.2.1_A2_T4.js | 4 ++-- .../builtins/Function/S15.3.2.1_A2_T5.js | 4 ++-- .../builtins/Function/S15.3.2.1_A2_T6.js | 4 ++-- .../builtins/Function/S15.3.2.1_A3_T1.js | 6 +++--- .../builtins/Function/S15.3.2.1_A3_T10.js | 6 +++--- .../builtins/Function/S15.3.2.1_A3_T11.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A3_T12.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A3_T13.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A3_T14.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A3_T15.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A3_T2.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A3_T3.js | 6 +++--- .../builtins/Function/S15.3.2.1_A3_T4.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A3_T5.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A3_T6.js | 6 +++--- .../builtins/Function/S15.3.2.1_A3_T7.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A3_T8.js | 8 ++++---- .../builtins/Function/S15.3.2.1_A3_T9.js | 6 +++--- test/sendable/builtins/Function/S15.3.2_A1.js | 8 ++++---- test/sendable/builtins/Function/S15.3.3_A1.js | 4 ++-- test/sendable/builtins/Function/S15.3.3_A2_T1.js | 10 +++++----- test/sendable/builtins/Function/S15.3.3_A2_T2.js | 10 +++++----- test/sendable/builtins/Function/S15.3.3_A3.js | 8 ++++---- test/sendable/builtins/Function/S15.3.5_A1_T1.js | 10 +++++----- test/sendable/builtins/Function/S15.3.5_A1_T2.js | 10 +++++----- test/sendable/builtins/Function/S15.3.5_A2_T1.js | 6 +++--- test/sendable/builtins/Function/S15.3.5_A2_T2.js | 6 +++--- test/sendable/builtins/Function/S15.3.5_A3_T1.js | 4 ++-- test/sendable/builtins/Function/S15.3.5_A3_T2.js | 4 ++-- test/sendable/builtins/Function/S15.3_A1.js | 8 ++++---- test/sendable/builtins/Function/S15.3_A2_T1.js | 6 +++--- test/sendable/builtins/Function/S15.3_A2_T2.js | 6 +++--- test/sendable/builtins/Function/S15.3_A3_T1.js | 8 ++++---- test/sendable/builtins/Function/S15.3_A3_T2.js | 6 +++--- test/sendable/builtins/Function/S15.3_A3_T3.js | 6 +++--- test/sendable/builtins/Function/S15.3_A3_T4.js | 4 ++-- test/sendable/builtins/Function/S15.3_A3_T5.js | 8 ++++---- test/sendable/builtins/Function/S15.3_A3_T6.js | 6 +++--- .../StrictFunction_reservedwords_with.js | 4 ++-- .../StrictFunction_restricted-properties.js | 4 ++-- .../Function/call-bind-this-realm-undef.js | 2 +- .../Function/call-bind-this-realm-value.js | 2 +- test/sendable/builtins/Function/instance-name.js | 8 ++++---- .../Construct/base-ctor-revoked-proxy-realm.js | 2 +- .../Construct/base-ctor-revoked-proxy.js | 2 +- .../builtins/Function/is-a-constructor.js | 6 +++--- .../builtins/Function/length/15.3.3.2-1.js | 4 ++-- .../builtins/Function/length/S15.3.5.1_A1_T1.js | 4 ++-- .../builtins/Function/length/S15.3.5.1_A1_T2.js | 4 ++-- .../builtins/Function/length/S15.3.5.1_A1_T3.js | 4 ++-- .../builtins/Function/length/S15.3.5.1_A2_T1.js | 4 ++-- .../builtins/Function/length/S15.3.5.1_A2_T2.js | 4 ++-- .../builtins/Function/length/S15.3.5.1_A2_T3.js | 4 ++-- .../builtins/Function/length/S15.3.5.1_A3_T1.js | 4 ++-- .../builtins/Function/length/S15.3.5.1_A3_T2.js | 4 ++-- .../builtins/Function/length/S15.3.5.1_A3_T3.js | 4 ++-- .../builtins/Function/length/S15.3.5.1_A4_T1.js | 4 ++-- .../builtins/Function/length/S15.3.5.1_A4_T2.js | 4 ++-- .../builtins/Function/length/S15.3.5.1_A4_T3.js | 4 ++-- .../Function/private-identifiers-not-empty.js | 2 +- test/sendable/builtins/Function/prop-desc.js | 4 ++-- .../sendable/builtins/Function/property-order.js | 4 ++-- .../Function/proto-from-ctor-realm-prototype.js | 8 ++++---- .../builtins/Function/proto-from-ctor-realm.js | 6 +++--- .../builtins/Function/prototype/S15.3.3.1_A1.js | 14 +++++++------- .../builtins/Function/prototype/S15.3.3.1_A2.js | 10 +++++----- .../builtins/Function/prototype/S15.3.3.1_A3.js | 12 ++++++------ .../builtins/Function/prototype/S15.3.4_A1.js | 10 +++++----- .../builtins/Function/prototype/S15.3.4_A2_T1.js | 8 ++++---- .../builtins/Function/prototype/S15.3.4_A2_T2.js | 8 ++++---- .../builtins/Function/prototype/S15.3.4_A2_T3.js | 6 +++--- .../builtins/Function/prototype/S15.3.4_A3_T1.js | 8 ++++---- .../builtins/Function/prototype/S15.3.4_A3_T2.js | 6 +++--- .../builtins/Function/prototype/S15.3.4_A4.js | 16 ++++++++-------- .../builtins/Function/prototype/S15.3.4_A5.js | 8 ++++---- .../Function/prototype/S15.3.5.2_A1_T1.js | 4 ++-- .../Function/prototype/S15.3.5.2_A1_T2.js | 4 ++-- .../prototype/Symbol.hasInstance/length.js | 8 ++++---- .../prototype/Symbol.hasInstance/name.js | 2 +- .../prototype/Symbol.hasInstance/prop-desc.js | 6 +++--- .../Symbol.hasInstance/this-val-not-callable.js | 4 ++-- .../Function/prototype/apply/S15.3.4.3_A12.js | 8 ++++---- .../Function/prototype/apply/S15.3.4.3_A1_T1.js | 4 ++-- .../Function/prototype/apply/S15.3.4.3_A1_T2.js | 4 ++-- .../Function/prototype/apply/S15.3.4.3_A3_T1.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A3_T2.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A3_T3.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A3_T4.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A3_T5.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A3_T7.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A3_T9.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A5_T1.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A5_T2.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A5_T7.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A5_T8.js | 6 +++--- .../Function/prototype/apply/S15.3.4.3_A7_T1.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A7_T10.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A7_T2.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A7_T3.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A7_T4.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A7_T5.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A7_T6.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A7_T7.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A7_T8.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A7_T9.js | 2 +- .../Function/prototype/apply/S15.3.4.3_A8_T3.js | 8 ++++---- .../Function/prototype/apply/S15.3.4.3_A8_T4.js | 8 ++++---- .../Function/prototype/apply/S15.3.4.3_A8_T5.js | 8 ++++---- .../Function/prototype/apply/S15.3.4.3_A8_T6.js | 8 ++++---- .../prototype/apply/argarray-not-object-realm.js | 4 ++-- .../prototype/apply/argarray-not-object.js | 2 +- .../Function/prototype/apply/get-index-abrupt.js | 2 +- .../prototype/apply/get-length-abrupt.js | 2 +- .../builtins/Function/prototype/apply/length.js | 8 ++++---- .../builtins/Function/prototype/apply/name.js | 10 +++++----- .../prototype/apply/not-a-constructor.js | 12 ++++++------ .../Function/prototype/apply/resizable-buffer.js | 2 +- .../prototype/apply/this-not-callable-realm.js | 4 ++-- .../prototype/apply/this-not-callable.js | 10 +++++----- .../Function/prototype/bind/15.3.4.5-0-1.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-10-1.js | 6 +++--- .../Function/prototype/bind/15.3.4.5-11-1.js | 6 +++--- .../Function/prototype/bind/15.3.4.5-16-1.js | 2 +- .../Function/prototype/bind/15.3.4.5-16-2.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-1.js | 6 +++--- .../Function/prototype/bind/15.3.4.5-2-10.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-2-11.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-2-12.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-2-13.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-2-14.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-2-15.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-2-16.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-2.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-2-3.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-4.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-5.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-6.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-7.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-8.js | 2 +- .../Function/prototype/bind/15.3.4.5-2-9.js | 2 +- .../Function/prototype/bind/15.3.4.5-20-2.js | 2 +- .../Function/prototype/bind/15.3.4.5-20-3.js | 2 +- .../Function/prototype/bind/15.3.4.5-21-2.js | 2 +- .../Function/prototype/bind/15.3.4.5-21-3.js | 2 +- .../Function/prototype/bind/15.3.4.5-3-1.js | 2 +- .../Function/prototype/bind/15.3.4.5-6-1.js | 2 +- .../Function/prototype/bind/15.3.4.5-6-10.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-6-11.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-6-12.js | 2 +- .../Function/prototype/bind/15.3.4.5-6-2.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-6-3.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-6-4.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-6-5.js | 2 +- .../Function/prototype/bind/15.3.4.5-6-6.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-6-7.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-6-8.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-6-9.js | 2 +- .../Function/prototype/bind/15.3.4.5-8-1.js | 2 +- .../Function/prototype/bind/15.3.4.5-8-2.js | 6 +++--- .../Function/prototype/bind/15.3.4.5-9-1.js | 4 ++-- .../Function/prototype/bind/15.3.4.5-9-2.js | 4 ++-- .../Function/prototype/bind/15.3.4.5.1-4-1.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-10.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-11.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-12.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-13.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-14.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-15.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-2.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-3.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-4.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-5.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-6.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-7.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-8.js | 2 +- .../Function/prototype/bind/15.3.4.5.1-4-9.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-1.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-10.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-11.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-12.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-13.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-14.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-2.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-3.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-4.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-5.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-6.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-7.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-8.js | 2 +- .../Function/prototype/bind/15.3.4.5.2-4-9.js | 2 +- .../bind/BoundFunction_restricted-properties.js | 6 +++--- .../Function/prototype/bind/S15.3.4.5_A13.js | 4 ++-- .../Function/prototype/bind/S15.3.4.5_A14.js | 4 ++-- .../Function/prototype/bind/S15.3.4.5_A15.js | 4 ++-- .../Function/prototype/bind/S15.3.4.5_A16.js | 4 ++-- .../Function/prototype/bind/S15.3.4.5_A3.js | 6 +++--- .../Function/prototype/bind/S15.3.4.5_A4.js | 4 ++-- .../Function/prototype/bind/S15.3.4.5_A5.js | 4 ++-- .../prototype/bind/get-fn-realm-recursive.js | 6 +++--- .../Function/prototype/bind/get-fn-realm.js | 4 ++-- .../bind/instance-length-default-value.js | 4 ++-- .../bind/instance-length-exceeds-int32.js | 2 +- .../prototype/bind/instance-length-prop-desc.js | 2 +- .../bind/instance-length-remaining-args.js | 2 +- .../prototype/bind/instance-length-tointeger.js | 2 +- .../builtins/Function/prototype/bind/length.js | 6 +++--- .../builtins/Function/prototype/bind/name.js | 10 +++++----- .../Function/prototype/bind/not-a-constructor.js | 10 +++++----- .../prototype/bind/proto-from-ctor-realm.js | 2 +- .../Function/prototype/call/S15.3.4.4_A10.js | 16 ++++++++-------- .../Function/prototype/call/S15.3.4.4_A11.js | 14 +++++++------- .../Function/prototype/call/S15.3.4.4_A12.js | 8 ++++---- .../Function/prototype/call/S15.3.4.4_A13.js | 4 ++-- .../Function/prototype/call/S15.3.4.4_A14.js | 4 ++-- .../Function/prototype/call/S15.3.4.4_A15.js | 4 ++-- .../Function/prototype/call/S15.3.4.4_A16.js | 4 ++-- .../Function/prototype/call/S15.3.4.4_A1_T1.js | 4 ++-- .../Function/prototype/call/S15.3.4.4_A1_T2.js | 4 ++-- .../Function/prototype/call/S15.3.4.4_A2_T1.js | 12 ++++++------ .../Function/prototype/call/S15.3.4.4_A2_T2.js | 4 ++-- .../Function/prototype/call/S15.3.4.4_A3_T1.js | 2 +- .../Function/prototype/call/S15.3.4.4_A3_T2.js | 2 +- .../Function/prototype/call/S15.3.4.4_A3_T3.js | 2 +- .../Function/prototype/call/S15.3.4.4_A3_T4.js | 2 +- .../Function/prototype/call/S15.3.4.4_A3_T5.js | 2 +- .../Function/prototype/call/S15.3.4.4_A3_T7.js | 2 +- .../Function/prototype/call/S15.3.4.4_A3_T9.js | 2 +- .../Function/prototype/call/S15.3.4.4_A5_T1.js | 2 +- .../Function/prototype/call/S15.3.4.4_A5_T2.js | 2 +- .../Function/prototype/call/S15.3.4.4_A5_T7.js | 2 +- .../Function/prototype/call/S15.3.4.4_A5_T8.js | 6 +++--- .../Function/prototype/call/S15.3.4.4_A6_T1.js | 2 +- .../Function/prototype/call/S15.3.4.4_A6_T10.js | 2 +- .../Function/prototype/call/S15.3.4.4_A6_T2.js | 2 +- .../Function/prototype/call/S15.3.4.4_A6_T3.js | 2 +- .../Function/prototype/call/S15.3.4.4_A6_T4.js | 2 +- .../Function/prototype/call/S15.3.4.4_A6_T5.js | 2 +- .../Function/prototype/call/S15.3.4.4_A6_T6.js | 2 +- .../Function/prototype/call/S15.3.4.4_A6_T7.js | 2 +- .../Function/prototype/call/S15.3.4.4_A6_T8.js | 2 +- .../Function/prototype/call/S15.3.4.4_A6_T9.js | 2 +- .../Function/prototype/call/S15.3.4.4_A7_T3.js | 8 ++++---- .../Function/prototype/call/S15.3.4.4_A7_T4.js | 8 ++++---- .../Function/prototype/call/S15.3.4.4_A7_T5.js | 8 ++++---- .../Function/prototype/call/S15.3.4.4_A7_T6.js | 8 ++++---- .../Function/prototype/call/S15.3.4.4_A9.js | 16 ++++++++-------- .../builtins/Function/prototype/call/name.js | 10 +++++----- .../Function/prototype/call/not-a-constructor.js | 14 +++++++------- .../prototype/constructor/S15.3.4.1_A1_T1.js | 12 ++++++------ .../builtins/Function/prototype/length.js | 8 ++++---- .../sendable/builtins/Function/prototype/name.js | 6 +++--- .../Function/prototype/property-order.js | 4 ++-- .../prototype/restricted-property-arguments.js | 2 +- .../prototype/restricted-property-caller.js | 2 +- .../Function/prototype/toString/AsyncFunction.js | 2 +- .../prototype/toString/AsyncGenerator.js | 2 +- .../Function/prototype/toString/Function.js | 4 ++-- .../prototype/toString/GeneratorFunction.js | 2 +- .../Function/prototype/toString/S15.3.4.2_A10.js | 16 ++++++++-------- .../Function/prototype/toString/S15.3.4.2_A11.js | 10 +++++----- .../Function/prototype/toString/S15.3.4.2_A12.js | 6 +++--- .../Function/prototype/toString/S15.3.4.2_A13.js | 4 ++-- .../Function/prototype/toString/S15.3.4.2_A14.js | 4 ++-- .../Function/prototype/toString/S15.3.4.2_A16.js | 2 +- .../Function/prototype/toString/S15.3.4.2_A6.js | 8 ++++---- .../Function/prototype/toString/S15.3.4.2_A8.js | 14 +++++++------- .../Function/prototype/toString/S15.3.4.2_A9.js | 16 ++++++++-------- .../prototype/toString/arrow-function.js | 2 +- .../prototype/toString/async-arrow-function.js | 2 +- .../toString/async-function-declaration.js | 2 +- .../toString/async-function-expression.js | 2 +- .../toString/async-generator-declaration.js | 2 +- .../toString/async-generator-expression.js | 2 +- ...c-generator-method-class-expression-static.js | 2 +- .../async-generator-method-class-expression.js | 2 +- ...nc-generator-method-class-statement-static.js | 2 +- .../async-generator-method-class-statement.js | 2 +- .../toString/async-generator-method-object.js | 2 +- .../async-method-class-expression-static.js | 2 +- .../toString/async-method-class-expression.js | 2 +- .../async-method-class-statement-static.js | 2 +- .../toString/async-method-class-statement.js | 2 +- .../prototype/toString/async-method-object.js | 2 +- .../prototype/toString/bound-function.js | 4 ++-- .../toString/built-in-function-object.js | 4 ++-- .../class-declaration-complex-heritage.js | 2 +- .../toString/class-declaration-explicit-ctor.js | 2 +- .../toString/class-declaration-implicit-ctor.js | 2 +- .../toString/class-expression-explicit-ctor.js | 2 +- .../toString/class-expression-implicit-ctor.js | 2 +- ...tion-declaration-non-simple-parameter-list.js | 2 +- .../prototype/toString/function-declaration.js | 2 +- .../prototype/toString/function-expression.js | 2 +- .../toString/generator-function-declaration.js | 2 +- .../toString/generator-function-expression.js | 2 +- .../prototype/toString/generator-method.js | 2 +- .../toString/getter-class-expression-static.js | 2 +- .../toString/getter-class-expression.js | 2 +- .../toString/getter-class-statement-static.js | 2 +- .../prototype/toString/getter-class-statement.js | 2 +- .../Function/prototype/toString/getter-object.js | 2 +- .../line-terminator-normalisation-CR-LF.js | 4 ++-- .../toString/line-terminator-normalisation-CR.js | 4 ++-- .../toString/line-terminator-normalisation-LF.js | 4 ++-- .../toString/method-class-expression-static.js | 2 +- .../toString/method-class-expression.js | 2 +- .../toString/method-class-statement-static.js | 2 +- .../prototype/toString/method-class-statement.js | 2 +- .../toString/method-computed-property-name.js | 2 +- .../Function/prototype/toString/method-object.js | 2 +- .../builtins/Function/prototype/toString/name.js | 10 +++++----- .../prototype/toString/not-a-constructor.js | 12 ++++++------ .../toString/private-method-class-expression.js | 2 +- .../toString/private-method-class-statement.js | 2 +- .../private-static-method-class-expression.js | 2 +- .../private-static-method-class-statement.js | 2 +- .../prototype/toString/proxy-arrow-function.js | 2 +- .../prototype/toString/proxy-async-function.js | 2 +- .../toString/proxy-async-generator-function.js | 2 +- .../prototype/toString/proxy-bound-function.js | 2 +- .../toString/proxy-function-expression.js | 2 +- .../toString/proxy-generator-function.js | 2 +- .../toString/proxy-non-callable-throws.js | 2 +- .../toString/setter-class-expression-static.js | 2 +- .../toString/setter-class-expression.js | 2 +- .../toString/setter-class-statement-static.js | 2 +- .../prototype/toString/setter-class-statement.js | 2 +- .../Function/prototype/toString/setter-object.js | 2 +- .../prototype/toString/symbol-named-builtins.js | 2 +- .../Function/prototype/toString/unicode.js | 4 ++-- 400 files changed, 840 insertions(+), 840 deletions(-) diff --git a/test/sendable/builtins/Function/15.3.2.1-10-6gs.js b/test/sendable/builtins/Function/15.3.2.1-10-6gs.js index 996c931654b..b8a5481f0f9 100644 --- a/test/sendable/builtins/Function/15.3.2.1-10-6gs.js +++ b/test/sendable/builtins/Function/15.3.2.1-10-6gs.js @@ -17,11 +17,11 @@ es5id: 15.3.2.1-10-6gs description: > Strict Mode - SyntaxError is thrown if a function using the - SendableFunction constructor has two identical parameters in (local) + SharedFunction constructor has two identical parameters in (local) strict mode flags: [noStrict] ---*/ assert.throws(SyntaxError, function() { - new SendableFunction('param_1', 'param_2', 'param_1', '"use strict";return 0;'); + new SharedFunction('param_1', 'param_2', 'param_1', '"use strict";return 0;'); }); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-1-s.js b/test/sendable/builtins/Function/15.3.2.1-11-1-s.js index 475df6132a4..26563a38f42 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-1-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-1-s.js @@ -16,12 +16,12 @@ /*--- es5id: 15.3.2.1-11-1-s description: > - Duplicate seperate parameter name in SendableFunction constructor throws + Duplicate seperate parameter name in SharedFunction constructor throws SyntaxError in strict mode flags: [noStrict] ---*/ assert.throws(SyntaxError, function() { - SendableFunction('a', 'a', '"use strict";'); + SharedFunction('a', 'a', '"use strict";'); }); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-1.js b/test/sendable/builtins/Function/15.3.2.1-11-1.js index 515c4e56ae6..6ca12aefc57 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-1.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-1.js @@ -16,8 +16,8 @@ /*--- es5id: 15.3.2.1-11-1 description: > - Duplicate separate parameter name in SendableFunction constructor allowed + Duplicate separate parameter name in SharedFunction constructor allowed if body not strict ---*/ -SendableFunction('a', 'a', 'return;'); +SharedFunction('a', 'a', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-2-s.js b/test/sendable/builtins/Function/15.3.2.1-11-2-s.js index 5e4ac676a34..264c11e9068 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-2-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-2-s.js @@ -16,9 +16,9 @@ /*--- es5id: 15.3.2.1-11-2-s description: > - Duplicate seperate parameter name in SendableFunction constructor called + Duplicate seperate parameter name in SharedFunction constructor called from strict mode allowed if body not strict flags: [onlyStrict] ---*/ -SendableFunction('a', 'a', 'return;'); +SharedFunction('a', 'a', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-3-s.js b/test/sendable/builtins/Function/15.3.2.1-11-3-s.js index 387b0a80fb1..2166d22d1c6 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-3-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-3-s.js @@ -16,12 +16,12 @@ /*--- es5id: 15.3.2.1-11-3-s description: > - SendableFunction constructor having a formal parameter named 'eval' throws + SharedFunction constructor having a formal parameter named 'eval' throws SyntaxError if function body is strict mode flags: [noStrict] ---*/ assert.throws(SyntaxError, function() { - SendableFunction('eval', '"use strict";'); + SharedFunction('eval', '"use strict";'); }); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-3.js b/test/sendable/builtins/Function/15.3.2.1-11-3.js index d81abd0cb8e..827fa9682c3 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-3.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-3.js @@ -16,8 +16,8 @@ /*--- es5id: 15.3.2.1-11-3 description: > - SendableFunction constructor may have a formal parameter named 'eval' if + SharedFunction constructor may have a formal parameter named 'eval' if body is not strict mode ---*/ -SendableFunction('eval', 'return;'); +SharedFunction('eval', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-4-s.js b/test/sendable/builtins/Function/15.3.2.1-11-4-s.js index 4daa72d207f..53983c65792 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-4-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-4-s.js @@ -16,10 +16,10 @@ /*--- es5id: 15.3.2.1-11-4-s description: > - SendableFunction constructor call from strict code with formal parameter + SharedFunction constructor call from strict code with formal parameter named 'eval' does not throws SyntaxError if function body is not strict mode flags: [onlyStrict] ---*/ -SendableFunction('eval', 'return;'); +SharedFunction('eval', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-5-s.js b/test/sendable/builtins/Function/15.3.2.1-11-5-s.js index 37c559cdf39..b8e22e8c5d5 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-5-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-5-s.js @@ -16,12 +16,12 @@ /*--- es5id: 15.3.2.1-11-5-s description: > - Duplicate combined parameter name in SendableFunction constructor throws + Duplicate combined parameter name in SharedFunction constructor throws SyntaxError in strict mode flags: [noStrict] ---*/ assert.throws(SyntaxError, function() { - SendableFunction('a,a', '"use strict";'); + SharedFunction('a,a', '"use strict";'); }); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-5.js b/test/sendable/builtins/Function/15.3.2.1-11-5.js index e875b622c0d..8a7e1f3f378 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-5.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-5.js @@ -16,8 +16,8 @@ /*--- es5id: 15.3.2.1-11-5 description: > - Duplicate combined parameter name in SendableFunction constructor allowed + Duplicate combined parameter name in SharedFunction constructor allowed if body is not strict ---*/ -SendableFunction('a,a', 'return;'); +SharedFunction('a,a', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-6-s.js b/test/sendable/builtins/Function/15.3.2.1-11-6-s.js index 96e0514ee85..4e264874d50 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-6-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-6-s.js @@ -16,9 +16,9 @@ /*--- es5id: 15.3.2.1-11-6-s description: > - Duplicate combined parameter name allowed in SendableFunction constructor + Duplicate combined parameter name allowed in SharedFunction constructor called in strict mode if body not strict flags: [onlyStrict] ---*/ -SendableFunction('a,a', 'return a;'); +SharedFunction('a,a', 'return a;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-7-s.js b/test/sendable/builtins/Function/15.3.2.1-11-7-s.js index 5422ae71f30..b0b7a1d37a9 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-7-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-7-s.js @@ -16,10 +16,10 @@ /*--- es5id: 15.3.2.1-11-7-s description: > - SendableFunction constructor call from strict code with formal parameter + SharedFunction constructor call from strict code with formal parameter named arguments does not throws SyntaxError if function body is not strict mode flags: [onlyStrict] ---*/ -SendableFunction('arguments', 'return;'); +SharedFunction('arguments', 'return;'); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-8-s.js b/test/sendable/builtins/Function/15.3.2.1-11-8-s.js index daebfc797e2..26d640f076f 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-8-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-8-s.js @@ -17,10 +17,10 @@ es5id: 15.3.2.1-11-8-s description: > Strict Mode - SyntaxError is not thrown if a function is created - using a SendableFunction constructor that has two identical parameters, + using a SharedFunction constructor that has two identical parameters, which are separated by a unique parameter name and there is no explicit 'use strict' in the function constructor's body flags: [onlyStrict] ---*/ -var foo = new SendableFunction("baz", "qux", "baz", "return 0;"); +var foo = new SharedFunction("baz", "qux", "baz", "return 0;"); diff --git a/test/sendable/builtins/Function/15.3.2.1-11-9-s.js b/test/sendable/builtins/Function/15.3.2.1-11-9-s.js index 28b559fb0cc..bd339efc7a7 100644 --- a/test/sendable/builtins/Function/15.3.2.1-11-9-s.js +++ b/test/sendable/builtins/Function/15.3.2.1-11-9-s.js @@ -17,9 +17,9 @@ es5id: 15.3.2.1-11-9-s description: > Strict Mode - No SyntaxError is thrown if a function is created using - the SendableFunction constructor that has three identical parameters and + the SharedFunction constructor that has three identical parameters and there is no explicit 'use strict' in the function constructor's body ---*/ -var foo = new SendableFunction("baz", "baz", "baz", "return 0;"); +var foo = new SharedFunction("baz", "baz", "baz", "return 0;"); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-10gs.js b/test/sendable/builtins/Function/15.3.5.4_2-10gs.js index 77139c3d26c..4a2a6af1555 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-10gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-10gs.js @@ -17,12 +17,12 @@ es5id: 15.3.5.4_2-10gs description: > Strict mode - checking access to strict function caller from - non-strict function (New'ed SendableFunction constructor includes strict + non-strict function (New'ed SharedFunction constructor includes strict directive prologue) flags: [noStrict] ---*/ -var f = new SendableFunction("\"use strict\";\ngNonStrict();"); +var f = new SharedFunction("\"use strict\";\ngNonStrict();"); assert.throws(TypeError, function() { f(); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-58gs.js b/test/sendable/builtins/Function/15.3.5.4_2-58gs.js index 4844e877a14..a497b55901a 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-58gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-58gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-58gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - non-strict SendableFunction constructor) + non-strict SharedFunction constructor) flags: [noStrict] ---*/ @@ -28,7 +28,7 @@ function f() { }; assert.throws(TypeError, function() { - SendableFunction("return f();")(); + SharedFunction("return f();")(); }); function gNonStrict() { diff --git a/test/sendable/builtins/Function/15.3.5.4_2-59gs.js b/test/sendable/builtins/Function/15.3.5.4_2-59gs.js index 05ec7ab6f0f..5f2a9fe61e7 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-59gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-59gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-59gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - non-strict new'ed SendableFunction constructor) + non-strict new'ed SharedFunction constructor) flags: [noStrict] ---*/ @@ -28,7 +28,7 @@ function f() { }; assert.throws(TypeError, function() { - new SendableFunction("return f();")(); + new SharedFunction("return f();")(); }); function gNonStrict() { diff --git a/test/sendable/builtins/Function/15.3.5.4_2-60gs.js b/test/sendable/builtins/Function/15.3.5.4_2-60gs.js index d6759b89b39..76d407014ac 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-60gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-60gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-60gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.apply()) + SharedFunction.prototype.apply()) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-61gs.js b/test/sendable/builtins/Function/15.3.5.4_2-61gs.js index 4faf12ae8d7..4f9362e093c 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-61gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-61gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-61gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.apply(null)) + SharedFunction.prototype.apply(null)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-62gs.js b/test/sendable/builtins/Function/15.3.5.4_2-62gs.js index 321782ac146..a82bbe040cf 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-62gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-62gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-62gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.apply(undefined)) + SharedFunction.prototype.apply(undefined)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-63gs.js b/test/sendable/builtins/Function/15.3.5.4_2-63gs.js index 6c81dfcc1a9..e548dc14aaf 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-63gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-63gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-63gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.apply(someObject)) + SharedFunction.prototype.apply(someObject)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-64gs.js b/test/sendable/builtins/Function/15.3.5.4_2-64gs.js index df5fa7c7fc6..2fc22458b25 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-64gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-64gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-64gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.apply(globalObject)) + SharedFunction.prototype.apply(globalObject)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-65gs.js b/test/sendable/builtins/Function/15.3.5.4_2-65gs.js index 17cb9bf019d..73102261166 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-65gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-65gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-65gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.call()) + SharedFunction.prototype.call()) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-66gs.js b/test/sendable/builtins/Function/15.3.5.4_2-66gs.js index 4b3d90e914a..917ea3544e7 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-66gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-66gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-66gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.call(null)) + SharedFunction.prototype.call(null)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-67gs.js b/test/sendable/builtins/Function/15.3.5.4_2-67gs.js index 76b5e85efbf..029398eef14 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-67gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-67gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-67gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.call(undefined)) + SharedFunction.prototype.call(undefined)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-68gs.js b/test/sendable/builtins/Function/15.3.5.4_2-68gs.js index cd30ecfad39..1387fa10743 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-68gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-68gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-68gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.call(someObject)) + SharedFunction.prototype.call(someObject)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-69gs.js b/test/sendable/builtins/Function/15.3.5.4_2-69gs.js index 6c92945a091..43e3fc1e7bd 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-69gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-69gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-69gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.call(globalObject)) + SharedFunction.prototype.call(globalObject)) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-70gs.js b/test/sendable/builtins/Function/15.3.5.4_2-70gs.js index 912cbc0cb98..84a7b04588a 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-70gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-70gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-70gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.bind()()) + SharedFunction.prototype.bind()()) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-71gs.js b/test/sendable/builtins/Function/15.3.5.4_2-71gs.js index 6111b650a62..e0ef2648953 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-71gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-71gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-71gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.bind(null)()) + SharedFunction.prototype.bind(null)()) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-72gs.js b/test/sendable/builtins/Function/15.3.5.4_2-72gs.js index b9653d0bb00..06db8ad6e2f 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-72gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-72gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-72gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.bind(undefined)()) + SharedFunction.prototype.bind(undefined)()) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-73gs.js b/test/sendable/builtins/Function/15.3.5.4_2-73gs.js index cb5825fb85b..bf4928d0dea 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-73gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-73gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-73gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.bind(someObject)()) + SharedFunction.prototype.bind(someObject)()) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-74gs.js b/test/sendable/builtins/Function/15.3.5.4_2-74gs.js index 5bf5d1b7843..2042cb8c972 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-74gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-74gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-74gs description: > Strict mode - checking access to strict function caller from non-strict function (strict function declaration called by - SendableFunction.prototype.bind(globalObject)()) + SharedFunction.prototype.bind(globalObject)()) flags: [noStrict] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-77gs.js b/test/sendable/builtins/Function/15.3.5.4_2-77gs.js index 162036a0f2a..002ee3ff6c4 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-77gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-77gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-77gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction constructor) + strict SharedFunction constructor) flags: [noStrict] features: [caller] ---*/ @@ -28,7 +28,7 @@ function f() { }; (function() { "use strict"; - SendableFunction("return f();")(); + SharedFunction("return f();")(); })(); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-78gs.js b/test/sendable/builtins/Function/15.3.5.4_2-78gs.js index 25be1b68882..bbccadd116b 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-78gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-78gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-78gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict new'ed SendableFunction constructor) + strict new'ed SharedFunction constructor) flags: [noStrict] features: [caller] ---*/ @@ -28,7 +28,7 @@ function f() { }; (function() { "use strict"; - return new SendableFunction("return f();")(); + return new SharedFunction("return f();")(); })(); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-79gs.js b/test/sendable/builtins/Function/15.3.5.4_2-79gs.js index fd17a638db6..74f89e3dbcf 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-79gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-79gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-79gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.apply()) + strict SharedFunction.prototype.apply()) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-7gs.js b/test/sendable/builtins/Function/15.3.5.4_2-7gs.js index a872119618e..a8d0b0547a8 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-7gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-7gs.js @@ -17,11 +17,11 @@ es5id: 15.3.5.4_2-7gs description: > Strict mode - checking access to non-strict function caller from - strict function (SendableFunction constructor defined within strict mode) + strict function (SharedFunction constructor defined within strict mode) flags: [onlyStrict] ---*/ -var f = SendableFunction("return gNonStrict();"); +var f = SharedFunction("return gNonStrict();"); assert.throws(TypeError, function() { f(); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-80gs.js b/test/sendable/builtins/Function/15.3.5.4_2-80gs.js index a7d7f3ba8ca..89446575397 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-80gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-80gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-80gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.apply(null)) + strict SharedFunction.prototype.apply(null)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-81gs.js b/test/sendable/builtins/Function/15.3.5.4_2-81gs.js index 609e2ef6630..da6c328d8a6 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-81gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-81gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-81gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.apply(undefined)) + strict SharedFunction.prototype.apply(undefined)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-82gs.js b/test/sendable/builtins/Function/15.3.5.4_2-82gs.js index 3d5d9349299..acde09f3922 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-82gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-82gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-82gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.apply(someObject)) + strict SharedFunction.prototype.apply(someObject)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-83gs.js b/test/sendable/builtins/Function/15.3.5.4_2-83gs.js index e46da42ad98..6b2bd69f421 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-83gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-83gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-83gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.apply(globalObject)) + strict SharedFunction.prototype.apply(globalObject)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-84gs.js b/test/sendable/builtins/Function/15.3.5.4_2-84gs.js index 8d0a6b08743..9f0642fb380 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-84gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-84gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-84gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.call()) + strict SharedFunction.prototype.call()) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-85gs.js b/test/sendable/builtins/Function/15.3.5.4_2-85gs.js index 35c269f8bd0..740d3202791 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-85gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-85gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-85gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.call(null)) + strict SharedFunction.prototype.call(null)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-86gs.js b/test/sendable/builtins/Function/15.3.5.4_2-86gs.js index ac1a2a99cff..e049113d058 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-86gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-86gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-86gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.call(undefined)) + strict SharedFunction.prototype.call(undefined)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-87gs.js b/test/sendable/builtins/Function/15.3.5.4_2-87gs.js index 501d19da4d9..00574469e03 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-87gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-87gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-87gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.call(someObject)) + strict SharedFunction.prototype.call(someObject)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-88gs.js b/test/sendable/builtins/Function/15.3.5.4_2-88gs.js index c06b1822abb..e39e04c3b65 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-88gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-88gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-88gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.call(globalObject)) + strict SharedFunction.prototype.call(globalObject)) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-89gs.js b/test/sendable/builtins/Function/15.3.5.4_2-89gs.js index 4aaec6f7e57..a7aa8b65ed5 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-89gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-89gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-89gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.bind()()) + strict SharedFunction.prototype.bind()()) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-8gs.js b/test/sendable/builtins/Function/15.3.5.4_2-8gs.js index 718b9d43336..10daafd3ebb 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-8gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-8gs.js @@ -17,12 +17,12 @@ es5id: 15.3.5.4_2-8gs description: > Strict mode - checking access to strict function caller from - non-strict function (SendableFunction constructor includes strict + non-strict function (SharedFunction constructor includes strict directive prologue) flags: [noStrict] ---*/ -var f = SendableFunction("\"use strict\";\ngNonStrict();"); +var f = SharedFunction("\"use strict\";\ngNonStrict();"); assert.throws(TypeError, function() { f(); diff --git a/test/sendable/builtins/Function/15.3.5.4_2-90gs.js b/test/sendable/builtins/Function/15.3.5.4_2-90gs.js index f2204e7ce9c..c1dcd6d7de1 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-90gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-90gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-90gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.bind(null)()) + strict SharedFunction.prototype.bind(null)()) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-91gs.js b/test/sendable/builtins/Function/15.3.5.4_2-91gs.js index fae7b3935c1..714d91b715e 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-91gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-91gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-91gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.bind(undefined)()) + strict SharedFunction.prototype.bind(undefined)()) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-92gs.js b/test/sendable/builtins/Function/15.3.5.4_2-92gs.js index a6999f77f54..ec37b6f7d01 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-92gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-92gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-92gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.bind(someObject)()) + strict SharedFunction.prototype.bind(someObject)()) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-93gs.js b/test/sendable/builtins/Function/15.3.5.4_2-93gs.js index 1b3a3dc2b2e..e8c3b156c09 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-93gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-93gs.js @@ -18,7 +18,7 @@ es5id: 15.3.5.4_2-93gs description: > Strict mode - checking access to strict function caller from non-strict function (non-strict function declaration called by - strict SendableFunction.prototype.bind(globalObject)()) + strict SharedFunction.prototype.bind(globalObject)()) flags: [noStrict] features: [caller] ---*/ diff --git a/test/sendable/builtins/Function/15.3.5.4_2-95gs.js b/test/sendable/builtins/Function/15.3.5.4_2-95gs.js index f0bc503587e..a0c5a705755 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-95gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-95gs.js @@ -22,7 +22,7 @@ description: > flags: [noStrict] ---*/ -var gNonStrict = SendableFunction("return gNonStrict.caller || gNonStrict.caller.throwTypeError;"); +var gNonStrict = SharedFunction("return gNonStrict.caller || gNonStrict.caller.throwTypeError;"); function f() { "use strict"; diff --git a/test/sendable/builtins/Function/15.3.5.4_2-9gs.js b/test/sendable/builtins/Function/15.3.5.4_2-9gs.js index 7a7640ce704..a1d44821470 100644 --- a/test/sendable/builtins/Function/15.3.5.4_2-9gs.js +++ b/test/sendable/builtins/Function/15.3.5.4_2-9gs.js @@ -17,12 +17,12 @@ es5id: 15.3.5.4_2-9gs description: > Strict mode - checking access to non-strict function caller from - strict function (New'ed SendableFunction constructor defined within strict + strict function (New'ed SharedFunction constructor defined within strict mode) flags: [onlyStrict] ---*/ -var f = new SendableFunction("return gNonStrict();"); +var f = new SharedFunction("return gNonStrict();"); assert.throws(TypeError, function() { f(); diff --git a/test/sendable/builtins/Function/S10.1.1_A1_T3.js b/test/sendable/builtins/Function/S10.1.1_A1_T3.js index 77690f01832..d16641fca68 100644 --- a/test/sendable/builtins/Function/S10.1.1_A1_T3.js +++ b/test/sendable/builtins/Function/S10.1.1_A1_T3.js @@ -16,10 +16,10 @@ /*--- info: | Program functions are defined in source text by a SendableFunctionDeclaration or created dynamically either - by using a SendableFunctionExpression or by using the built-in SendableFunction object as a constructor + by using a SendableFunctionExpression or by using the built-in SharedFunction object as a constructor es5id: 10.1.1_A1_T3 description: > - Creating function dynamically by using the built-in SendableFunction + Creating function dynamically by using the built-in SharedFunction object as a constructor ---*/ diff --git a/test/sendable/builtins/Function/S15.3.1_A1_T1.js b/test/sendable/builtins/Function/S15.3.1_A1_T1.js index db0d1bd6e4c..5b7cdc21b8d 100644 --- a/test/sendable/builtins/Function/S15.3.1_A1_T1.js +++ b/test/sendable/builtins/Function/S15.3.1_A1_T1.js @@ -15,20 +15,20 @@ /*--- info: | - The function call SendableFunction(…) is equivalent to the object creation expression - new SendableFunction(…) with the same arguments. + The function call SharedFunction(…) is equivalent to the object creation expression + new SharedFunction(…) with the same arguments. es5id: 15.3.1_A1_T1 description: Create simple functions and check returned values ---*/ -var f = SendableFunction("return arguments[0];"); +var f = SharedFunction("return arguments[0];"); -assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); +assert(f instanceof SharedFunction, 'The result of evaluating (f instanceof SharedFunction) is expected to be true'); assert.sameValue(f(1), 1, 'f(1) must return 1'); -var g = new SendableFunction("return arguments[0];"); +var g = new SharedFunction("return arguments[0];"); -assert(g instanceof SendableFunction, 'The result of evaluating (g instanceof SendableFunction) is expected to be true'); +assert(g instanceof SharedFunction, 'The result of evaluating (g instanceof SharedFunction) is expected to be true'); assert.sameValue(g("A"), "A", 'g("A") must return "A"'); assert.sameValue(g("A"), f("A"), 'g("A") must return the same value returned by f("A")'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T1.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T1.js index 036827638e1..78f893fde37 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T1.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T1.js @@ -15,11 +15,11 @@ /*--- info: | - When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: + When the SharedFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. + iv) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T1 @@ -33,8 +33,8 @@ var body = { } try { - var f = new SendableFunction(body); - throw new Test262Error('#1: When the SendableFunction constructor is called with one argument then body be that argument the following step are taken: call ToString(body)'); + var f = new SharedFunction(body); + throw new Test262Error('#1: When the SharedFunction constructor is called with one argument then body be that argument the following step are taken: call ToString(body)'); } catch (e) { assert.sameValue(e, 7, 'The value of e is expected to be 7'); } diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T10.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T10.js index a282520f0d5..56e84f57c92 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T10.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T10.js @@ -15,11 +15,11 @@ /*--- info: | - When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: + When the SharedFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. + iv) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T10 @@ -27,10 +27,10 @@ description: Value of the function constructor argument is "null" ---*/ try { - var f = new SendableFunction(null); + var f = new SharedFunction(null); } catch (e) { throw new Test262Error('#1: test fails with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T11.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T11.js index c69a6d7ee81..0a221a37626 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T11.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T11.js @@ -15,11 +15,11 @@ /*--- info: | - When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: + When the SharedFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. + iv) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T11 @@ -27,10 +27,10 @@ description: Value of the function constructor argument is "undefined" ---*/ try { - var f = new SendableFunction(undefined); + var f = new SharedFunction(undefined); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T12.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T12.js index 42c16d8bbd9..b5b8aeafb6f 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T12.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T12.js @@ -15,11 +15,11 @@ /*--- info: | - When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: + When the SharedFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. + iv) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T12 @@ -27,10 +27,10 @@ description: Value of the function constructor argument is "void 0" ---*/ try { - var f = new SendableFunction(void 0); + var f = new SharedFunction(void 0); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T13.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T13.js index 201f2c77bdb..23897788676 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T13.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T13.js @@ -15,11 +15,11 @@ /*--- info: | - When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: + When the SharedFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. + iv) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T13 @@ -27,7 +27,7 @@ description: Value of the function constructor argument is "{}" ---*/ try { - var f = new SendableFunction({}); + var f = new SharedFunction({}); throw new Test262Error('#1: test failed with error ' + e); } catch (e) { assert( diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T2.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T2.js index 3b3e7c137ee..87d02d11314 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T2.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T2.js @@ -15,11 +15,11 @@ /*--- info: | - When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: + When the SharedFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. + iv) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T2 @@ -35,10 +35,10 @@ var body = { }; try { - var f = new SendableFunction(body); + var f = new SharedFunction(body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), 1, 'f() must return 1'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T3.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T3.js index 2d401bc09c9..8d037cf84d0 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T3.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T3.js @@ -15,11 +15,11 @@ /*--- info: | - When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: + When the SharedFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. + iv) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T3 @@ -27,10 +27,10 @@ description: Value of the function constructor argument is 1 ---*/ try { - var f = new SendableFunction(1); + var f = new SharedFunction(1); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T4.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T4.js index 349682f243e..d53c7363fe9 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T4.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T4.js @@ -15,11 +15,11 @@ /*--- info: | - When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: + When the SharedFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. + iv) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T4 @@ -29,12 +29,12 @@ description: > ---*/ try { - var f = new SendableFunction(x); + var f = new SharedFunction(x); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); var x; diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T5.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T5.js index 3c503ce1f8a..20119e71565 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T5.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T5.js @@ -15,11 +15,11 @@ /*--- info: | - When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: + When the SharedFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. + iv) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T5 @@ -31,10 +31,10 @@ description: > var body = Object("return \'A\'"); try { - var f = new SendableFunction(body); + var f = new SharedFunction(body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), "\u0041", 'f() must return "u0041"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T6.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T6.js index 161f61aa7b8..14b62fa1598 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T6.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T6.js @@ -15,11 +15,11 @@ /*--- info: | - When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: + When the SharedFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. + iv) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T6 @@ -29,10 +29,10 @@ description: > ---*/ try { - var f = new SendableFunction("return true;"); + var f = new SharedFunction("return true;"); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert(f(), 'f() must return true'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T7.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T7.js index 7fe77c5e88b..8a49a8bd9ab 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T7.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T7.js @@ -15,11 +15,11 @@ /*--- info: | - When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: + When the SharedFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. + iv) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T7 @@ -29,10 +29,10 @@ description: Value of the function constructor argument is "Object(1)" var body = new Object(1); try { - var f = new SendableFunction(body); + var f = new SharedFunction(body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T8.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T8.js index cd95bd15372..42ac632abe8 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T8.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T8.js @@ -15,11 +15,11 @@ /*--- info: | - When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: + When the SharedFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. + iv) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T8 @@ -29,7 +29,7 @@ description: Value of the function constructor argument is "var 1=1;" var body = "var 1=1;"; try { - var f = new SendableFunction(body); + var f = new SharedFunction(body); throw new Test262Error('#1: If body is not parsable as SendableFunctionBody then throw a SyntaxError exception'); } catch (e) { assert( diff --git a/test/sendable/builtins/Function/S15.3.2.1_A1_T9.js b/test/sendable/builtins/Function/S15.3.2.1_A1_T9.js index ffade3d3ef6..b8a19eb6fc3 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A1_T9.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A1_T9.js @@ -15,11 +15,11 @@ /*--- info: | - When the SendableFunction constructor is called with one argument then body be that argument and the following steps are taken: + When the SharedFunction constructor is called with one argument then body be that argument and the following steps are taken: i) Call ToString(body) ii) If P is not parsable as a FormalParameterListopt then throw a SyntaxError exception iii) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - iv) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. + iv) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody. Pass in a scope chain consisting of the global object as the Scope parameter v) Return Result(iv) es5id: 15.3.2.1_A1_T9 @@ -28,7 +28,7 @@ description: > arguments[0];" ---*/ -var f = new SendableFunction("return arguments[0];"); +var f = new SharedFunction("return arguments[0];"); -assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); +assert(f instanceof SharedFunction, 'The result of evaluating (f instanceof SharedFunction) is expected to be true'); assert.sameValue(f("A"), "A", 'f("A") must return "A"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T1.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T1.js index c9b55e7aa17..8b9abf53984 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A2_T1.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T1.js @@ -24,10 +24,10 @@ description: > ---*/ try { - var f = SendableFunction("arg1", "arg2", "arg3", "return arg1+arg2+arg3;"); + var f = SharedFunction("arg1", "arg2", "arg3", "return arg1+arg2+arg3;"); } catch (e) { throw new Test262Error('#1: test failed'); } -assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); +assert(f instanceof SharedFunction, 'The result of evaluating (f instanceof SharedFunction) is expected to be true'); assert.sameValue(f(1, 2, 3), 6, 'f(1, 2, 3) must return 6'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T2.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T2.js index f155d32ccd1..ed1a20f3bb9 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A2_T2.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T2.js @@ -24,10 +24,10 @@ description: > ---*/ try { - var f = SendableFunction("arg1, arg2", "arg3", "return arg1+arg2+arg3;"); + var f = SharedFunction("arg1, arg2", "arg3", "return arg1+arg2+arg3;"); } catch (e) { throw new Test262Error('#1: test failed'); } -assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); +assert(f instanceof SharedFunction, 'The result of evaluating (f instanceof SharedFunction) is expected to be true'); assert.sameValue(f("AB", "BA", 1), "ABBA1", 'f(AB, BA, 1) must return "ABBA1"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T3.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T3.js index ae6d79a0f35..72c43090def 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A2_T3.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T3.js @@ -24,10 +24,10 @@ description: > ---*/ try { - var f = SendableFunction("arg1, arg2, arg3", "return arg1+arg2+arg3;"); + var f = SharedFunction("arg1, arg2, arg3", "return arg1+arg2+arg3;"); } catch (e) { throw new Test262Error('#1: test failed'); } -assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); +assert(f instanceof SharedFunction, 'The result of evaluating (f instanceof SharedFunction) is expected to be true'); assert.sameValue(f(1, 1, "ABBA"), "2ABBA", 'f(1, 1, ABBA) must return "2ABBA"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T4.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T4.js index bcb20ed891e..a245105abdb 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A2_T4.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T4.js @@ -32,10 +32,10 @@ var p = { }; try { - var f = SendableFunction(p, p, p, "return arg1+arg2+arg3;"); + var f = SharedFunction(p, p, p, "return arg1+arg2+arg3;"); } catch (e) { throw new Test262Error('#1: test failed'); } -assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); +assert(f instanceof SharedFunction, 'The result of evaluating (f instanceof SharedFunction) is expected to be true'); assert.sameValue(f(4, "2", "QUESTION"), "42QUESTION", 'f(4, 2, QUESTION) must return "42QUESTION"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T5.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T5.js index 51cc4dccf4d..fcc96601da2 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A2_T5.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T5.js @@ -32,10 +32,10 @@ var p = { }; try { - var f = SendableFunction(p + "," + p, p, "return arg1+arg2+arg3;"); + var f = SharedFunction(p + "," + p, p, "return arg1+arg2+arg3;"); } catch (e) { throw new Test262Error('#1: test failed'); } -assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); +assert(f instanceof SharedFunction, 'The result of evaluating (f instanceof SharedFunction) is expected to be true'); assert.sameValue(f("", 1, 2), "12", 'f(, 1, 2) must return "12"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A2_T6.js b/test/sendable/builtins/Function/S15.3.2.1_A2_T6.js index b4e77f4c6d2..2d95c4d8647 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A2_T6.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A2_T6.js @@ -32,10 +32,10 @@ var p = { }; try { - var f = SendableFunction(p + "," + p + "," + p, "return arg1+arg2+arg3;"); + var f = SharedFunction(p + "," + p + "," + p, "return arg1+arg2+arg3;"); } catch (e) { throw new Test262Error('#1: test failed'); } -assert(f instanceof SendableFunction, 'The result of evaluating (f instanceof SendableFunction) is expected to be true'); +assert(f instanceof SharedFunction, 'The result of evaluating (f instanceof SharedFunction) is expected to be true'); assert.sameValue(f("", 1, p), "1arg4", 'f(, 1, {toString: function() {return "arg" + (++i)}}) must return "1arg4"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T1.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T1.js index 7a2605aa505..8d62245f8e2 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T1.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T1.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T1 @@ -43,7 +43,7 @@ var body = { }; try { - var f = new SendableFunction(p, body); + var f = new SharedFunction(p, body); throw new Test262Error('#1: test failed'); } catch (e) { assert.sameValue(e, 1, 'The value of e is expected to be 1'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T10.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T10.js index 6f511dc3963..5ed96a4da0a 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T10.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T10.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T10 @@ -38,7 +38,7 @@ var p = { }; try { - var f = new SendableFunction(p, body); + var f = new SharedFunction(p, body); throw new Test262Error('#1: If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception'); } catch (e) { assert( diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T11.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T11.js index 4e9a356be07..b3748929e7a 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T11.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T11.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T11 @@ -33,10 +33,10 @@ description: > var p = "a,b,c"; try { - var f = new SendableFunction(p, void 0); + var f = new SharedFunction(p, void 0); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T12.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T12.js index 5a6196d4fdf..22e34dbb7df 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T12.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T12.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T12 @@ -33,10 +33,10 @@ description: > var p = "a,b,c"; try { - var f = new SendableFunction(p, undefined); + var f = new SharedFunction(p, undefined); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T13.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T13.js index 1224b345a40..0511a42f326 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T13.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T13.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T13 @@ -31,10 +31,10 @@ description: Values of the function constructor arguments are "a,b,c" and "null" var p = "a,b,c"; try { - var f = new SendableFunction(p, null); + var f = new SharedFunction(p, null); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T14.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T14.js index c17fd741697..613d70f2252 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T14.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T14.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T14 @@ -33,12 +33,12 @@ description: > var p = "a,b,c"; try { - var f = new SendableFunction(p, body); + var f = new SharedFunction(p, body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); var body; diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T15.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T15.js index 954077a485a..898f0eb12a7 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T15.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T15.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T15 @@ -31,10 +31,10 @@ description: > ---*/ try { - var f = new SendableFunction("", ""); + var f = new SharedFunction("", ""); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T2.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T2.js index 9f4011af8b7..f816eb56846 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T2.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T2.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T2 @@ -38,10 +38,10 @@ var p = { var body = "return a;"; try { - var f = new SendableFunction(p, body); + var f = new SharedFunction(p, body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(42), 42, 'f(42) must return 42'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T3.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T3.js index d38b9091160..394d5dd6fb7 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T3.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T3.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T3 @@ -44,7 +44,7 @@ var body = { }; try { - var f = new SendableFunction(p, body); + var f = new SharedFunction(p, body); throw new Test262Error('#1: test failed'); } catch (e) { assert.sameValue(e, "body", 'The value of e is expected to be "body"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T4.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T4.js index e7a133c89e4..4efaaf0787f 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T4.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T4.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T4 @@ -33,12 +33,12 @@ description: > var body = "return 1.1;"; try { - var f = new SendableFunction(p, body); + var f = new SharedFunction(p, body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), 1.1, 'f() must return 1.1'); var p; diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T5.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T5.js index 12d02b65758..33734ba6475 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T5.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T5.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T5 @@ -33,10 +33,10 @@ description: > var body = "return \"A\";"; try { - var f = new SendableFunction(void 0, body); + var f = new SharedFunction(void 0, body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), '\u0041', 'f() must return "u0041"'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T6.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T6.js index d7b3ccd34d7..feb5c7d7e8c 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T6.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T6.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T6 @@ -33,7 +33,7 @@ description: > var body = "return true;"; try { - var f = new SendableFunction(null, body); + var f = new SharedFunction(null, body); throw new Test262Error('#1: If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception'); } catch (e) { assert( diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T7.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T7.js index 11b86b39c8e..e7114346679 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T7.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T7.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T7 @@ -35,10 +35,10 @@ var body = "return a;"; var p = Object("a"); try { - var f = new SendableFunction(p, body); + var f = new SharedFunction(p, body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(1), 1, 'f(1) must return 1'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T8.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T8.js index 017d36aa068..eb4aeb9ee26 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T8.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T8.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T8 @@ -33,10 +33,10 @@ description: > var body = "return this;"; try { - var f = new SendableFunction(undefined, body); + var f = new SharedFunction(undefined, body); } catch (e) { throw new Test262Error('#1: test failed with error ' + e); } -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.sameValue(f(), this, 'f() must return this'); diff --git a/test/sendable/builtins/Function/S15.3.2.1_A3_T9.js b/test/sendable/builtins/Function/S15.3.2.1_A3_T9.js index 9d795ccd535..c239ea6d1d9 100644 --- a/test/sendable/builtins/Function/S15.3.2.1_A3_T9.js +++ b/test/sendable/builtins/Function/S15.3.2.1_A3_T9.js @@ -15,13 +15,13 @@ /*--- info: | - When the SendableFunction constructor is called with arguments p, body the following steps are taken: + When the SharedFunction constructor is called with arguments p, body the following steps are taken: i) Let Result(i) be the first argument ii) Let P be ToString(Result(i)) iii) Call ToString(body) iv) If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception v) If body is not parsable as SendableFunctionBody then throw a SyntaxError exception - vi) Create a new SendableFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody + vi) Create a new SharedFunction object as specified in 13.2 with parameters specified by parsing P as a FormalParameterListopt and body specified by parsing body as a SendableFunctionBody Pass in a scope chain consisting of the global object as the Scope parameter vii) Return Result(vi) es5id: 15.3.2.1_A3_T9 @@ -34,7 +34,7 @@ var body = "return this;"; var p = "1,1"; try { - var f = new SendableFunction(p, body); + var f = new SharedFunction(p, body); throw new Test262Error('#1: If P is not parsable as a FormalParameterList_opt then throw a SyntaxError exception'); } catch (e) { assert( diff --git a/test/sendable/builtins/Function/S15.3.2_A1.js b/test/sendable/builtins/Function/S15.3.2_A1.js index 79827877c52..8a5dab6ef19 100644 --- a/test/sendable/builtins/Function/S15.3.2_A1.js +++ b/test/sendable/builtins/Function/S15.3.2_A1.js @@ -15,15 +15,15 @@ /*--- info: | - When SendableFunction is called as part of a new expression, it is a constructor: + When SharedFunction is called as part of a new expression, it is a constructor: it initialises the newly created object es5id: 15.3.2_A1 description: > Checking the constuctor of the object that is created as a new - SendableFunction + SharedFunction ---*/ -var f = new SendableFunction; +var f = new SharedFunction; -assert.sameValue(f.constructor, SendableFunction, 'The value of f.constructor is expected to equal the value of SendableFunction'); +assert.sameValue(f.constructor, SharedFunction, 'The value of f.constructor is expected to equal the value of SharedFunction'); assert.notSameValue(f, undefined, 'The value of f is expected to not equal ``undefined``'); diff --git a/test/sendable/builtins/Function/S15.3.3_A1.js b/test/sendable/builtins/Function/S15.3.3_A1.js index f32bd0d0446..6b9d093c203 100644 --- a/test/sendable/builtins/Function/S15.3.3_A1.js +++ b/test/sendable/builtins/Function/S15.3.3_A1.js @@ -14,8 +14,8 @@ */ /*--- -info: The SendableFunction constructor has the property "prototype" +info: The SharedFunction constructor has the property "prototype" es5id: 15.3.3_A1 description: Checking existence of the property "prototype" ---*/ -assert(SendableFunction.hasOwnProperty("prototype"), 'SendableFunction.hasOwnProperty("prototype") must return true'); +assert(SharedFunction.hasOwnProperty("prototype"), 'SharedFunction.hasOwnProperty("prototype") must return true'); diff --git a/test/sendable/builtins/Function/S15.3.3_A2_T1.js b/test/sendable/builtins/Function/S15.3.3_A2_T1.js index 543448e5194..7dc5ddd4a3f 100644 --- a/test/sendable/builtins/Function/S15.3.3_A2_T1.js +++ b/test/sendable/builtins/Function/S15.3.3_A2_T1.js @@ -15,12 +15,12 @@ /*--- info: | - The value of the internal [[Prototype]] property of the SendableFunction constructor - is the SendableFunction prototype object + The value of the internal [[Prototype]] property of the SharedFunction constructor + is the SharedFunction prototype object es5id: 15.3.3_A2_T1 -description: Checking prototype of SendableFunction +description: Checking prototype of SharedFunction ---*/ assert( - SendableFunction.prototype.isPrototypeOf(SendableFunction), - 'SendableFunction.prototype.isPrototypeOf(SendableFunction) must return true' + SharedFunction.prototype.isPrototypeOf(SharedFunction), + 'SharedFunction.prototype.isPrototypeOf(SharedFunction) must return true' ); diff --git a/test/sendable/builtins/Function/S15.3.3_A2_T2.js b/test/sendable/builtins/Function/S15.3.3_A2_T2.js index 3b9edaa2b19..b0df2c6e7e2 100644 --- a/test/sendable/builtins/Function/S15.3.3_A2_T2.js +++ b/test/sendable/builtins/Function/S15.3.3_A2_T2.js @@ -15,12 +15,12 @@ /*--- info: | - The value of the internal [[Prototype]] property of the SendableFunction constructor - is the SendableFunction prototype object + The value of the internal [[Prototype]] property of the SharedFunction constructor + is the SharedFunction prototype object es5id: 15.3.3_A2_T2 -description: Add new property to SendableFunction.prototype and check it +description: Add new property to SharedFunction.prototype and check it ---*/ -SendableFunction.prototype.indicator = 1; +SharedFunction.prototype.indicator = 1; -assert.sameValue(SendableFunction.indicator, 1, 'The value of SendableFunction.indicator is expected to be 1'); +assert.sameValue(SharedFunction.indicator, 1, 'The value of SharedFunction.indicator is expected to be 1'); diff --git a/test/sendable/builtins/Function/S15.3.3_A3.js b/test/sendable/builtins/Function/S15.3.3_A3.js index 76765cc9961..4e6329aadfb 100644 --- a/test/sendable/builtins/Function/S15.3.3_A3.js +++ b/test/sendable/builtins/Function/S15.3.3_A3.js @@ -14,9 +14,9 @@ */ /*--- -info: SendableFunction constructor has length property whose value is 1 +info: SharedFunction constructor has length property whose value is 1 es5id: 15.3.3_A3 -description: Checking SendableFunction.length property +description: Checking SharedFunction.length property ---*/ -assert(SendableFunction.hasOwnProperty("length"), 'SendableFunction.hasOwnProperty("length") must return true'); -assert.sameValue(SendableFunction.length, 1, 'The value of SendableFunction.length is expected to be 1'); +assert(SharedFunction.hasOwnProperty("length"), 'SharedFunction.hasOwnProperty("length") must return true'); +assert.sameValue(SharedFunction.length, 1, 'The value of SharedFunction.length is expected to be 1'); diff --git a/test/sendable/builtins/Function/S15.3.5_A1_T1.js b/test/sendable/builtins/Function/S15.3.5_A1_T1.js index e040c973810..a7fc19c73c7 100644 --- a/test/sendable/builtins/Function/S15.3.5_A1_T1.js +++ b/test/sendable/builtins/Function/S15.3.5_A1_T1.js @@ -14,15 +14,15 @@ */ /*--- -info: The value of the [[Class]] property is "SendableFunction" +info: The value of the [[Class]] property is "SharedFunction" es5id: 15.3.5_A1_T1 -description: For testing use variable f = new SendableFunction +description: For testing use variable f = new SharedFunction ---*/ -var f = new SendableFunction; +var f = new SharedFunction; assert.sameValue( Object.prototype.toString.call(f), - "[object SendableFunction]", - 'Object.prototype.toString.call(new SendableFunction) must return "[object SendableFunction]"' + "[object SharedFunction]", + 'Object.prototype.toString.call(new SharedFunction) must return "[object SharedFunction]"' ); diff --git a/test/sendable/builtins/Function/S15.3.5_A1_T2.js b/test/sendable/builtins/Function/S15.3.5_A1_T2.js index 89c5db8eddd..0c5ed9ba147 100644 --- a/test/sendable/builtins/Function/S15.3.5_A1_T2.js +++ b/test/sendable/builtins/Function/S15.3.5_A1_T2.js @@ -14,15 +14,15 @@ */ /*--- -info: The value of the [[Class]] property is "SendableFunction" +info: The value of the [[Class]] property is "SharedFunction" es5id: 15.3.5_A1_T2 -description: For testing use variable f = SendableFunction() +description: For testing use variable f = SharedFunction() ---*/ -var f = SendableFunction(); +var f = SharedFunction(); assert.sameValue( Object.prototype.toString.call(f), - "[object SendableFunction]", - 'Object.prototype.toString.call(SendableFunction()) must return "[object SendableFunction]"' + "[object SharedFunction]", + 'Object.prototype.toString.call(SharedFunction()) must return "[object SharedFunction]"' ); diff --git a/test/sendable/builtins/Function/S15.3.5_A2_T1.js b/test/sendable/builtins/Function/S15.3.5_A2_T1.js index d3f637a6b28..ef7e73c93d6 100644 --- a/test/sendable/builtins/Function/S15.3.5_A2_T1.js +++ b/test/sendable/builtins/Function/S15.3.5_A2_T1.js @@ -16,12 +16,12 @@ /*--- info: Every function instance has a [[Call]] property es5id: 15.3.5_A2_T1 -description: For testing call SendableFunction("var x =1; this.y=2;return \"OK\";")() +description: For testing call SharedFunction("var x =1; this.y=2;return \"OK\";")() ---*/ assert.sameValue( - SendableFunction("var x =1; this.y=2;return \"OK\";")(), + SharedFunction("var x =1; this.y=2;return \"OK\";")(), "OK", - 'SendableFunction("var x =1; this.y=2;return "OK";")() must return "OK"' + 'SharedFunction("var x =1; this.y=2;return "OK";")() must return "OK"' ); assert.sameValue(typeof x, "undefined", 'The value of `typeof x` is expected to be "undefined"'); diff --git a/test/sendable/builtins/Function/S15.3.5_A2_T2.js b/test/sendable/builtins/Function/S15.3.5_A2_T2.js index 4b0257098dd..b6edcaedc27 100644 --- a/test/sendable/builtins/Function/S15.3.5_A2_T2.js +++ b/test/sendable/builtins/Function/S15.3.5_A2_T2.js @@ -17,13 +17,13 @@ info: Every function instance has a [[Call]] property es5id: 15.3.5_A2_T2 description: > - For testing call (new SendableFunction("arg1,arg2","var x =arg1; + For testing call (new SharedFunction("arg1,arg2","var x =arg1; this.y=arg2;return arg1+arg2;"))("1",2) ---*/ assert.sameValue( - (new SendableFunction("arg1,arg2", "var x =arg1; this.y=arg2;return arg1+arg2;"))("1", 2), + (new SharedFunction("arg1,arg2", "var x =arg1; this.y=arg2;return arg1+arg2;"))("1", 2), "12", - 'new SendableFunction("arg1,arg2", "var x =arg1; this.y=arg2;return arg1+arg2;")(1, 2) must return "12"' + 'new SharedFunction("arg1,arg2", "var x =arg1; this.y=arg2;return arg1+arg2;")(1, 2) must return "12"' ); assert.sameValue(typeof x, "undefined", 'The value of `typeof x` is expected to be "undefined"'); diff --git a/test/sendable/builtins/Function/S15.3.5_A3_T1.js b/test/sendable/builtins/Function/S15.3.5_A3_T1.js index bded8798aa0..1bc046ef461 100644 --- a/test/sendable/builtins/Function/S15.3.5_A3_T1.js +++ b/test/sendable/builtins/Function/S15.3.5_A3_T1.js @@ -16,10 +16,10 @@ /*--- info: every function instance has a [[Construct]] property es5id: 15.3.5_A3_T1 -description: As constructor use SendableFunction("var x =1; this.y=2;return \"OK\";") +description: As constructor use SharedFunction("var x =1; this.y=2;return \"OK\";") ---*/ -var FACTORY = SendableFunction("var x =1; this.y=2;return \"OK\";"); +var FACTORY = SharedFunction("var x =1; this.y=2;return \"OK\";"); var obj = new FACTORY; assert.sameValue(typeof obj, "object", 'The value of `typeof obj` is expected to be "object"'); diff --git a/test/sendable/builtins/Function/S15.3.5_A3_T2.js b/test/sendable/builtins/Function/S15.3.5_A3_T2.js index 21b6c83a750..d5b591b11df 100644 --- a/test/sendable/builtins/Function/S15.3.5_A3_T2.js +++ b/test/sendable/builtins/Function/S15.3.5_A3_T2.js @@ -17,11 +17,11 @@ info: every function instance has a [[Construct]] property es5id: 15.3.5_A3_T2 description: > - As constructor use new SendableFunction("arg1,arg2","var x =1; + As constructor use new SharedFunction("arg1,arg2","var x =1; this.y=arg1+arg2;return \"OK\";") ---*/ -var FACTORY = new SendableFunction("arg1,arg2", "var x =1; this.y=arg1+arg2;return \"OK\";"); +var FACTORY = new SharedFunction("arg1,arg2", "var x =1; this.y=arg1+arg2;return \"OK\";"); var obj = new FACTORY("1", 2); assert.sameValue(typeof obj, "object", 'The value of `typeof obj` is expected to be "object"'); diff --git a/test/sendable/builtins/Function/S15.3_A1.js b/test/sendable/builtins/Function/S15.3_A1.js index 51f0908cd94..6003695c834 100644 --- a/test/sendable/builtins/Function/S15.3_A1.js +++ b/test/sendable/builtins/Function/S15.3_A1.js @@ -14,13 +14,13 @@ */ /*--- -info: SendableFunction is the property of global +info: SharedFunction is the property of global es5id: 15.3_A1 -description: Compare SendableFunction with this.SendableFunction +description: Compare SharedFunction with this.SharedFunction ---*/ -var obj = SendableFunction; +var obj = SharedFunction; -var thisobj = this.SendableFunction; +var thisobj = this.SharedFunction; assert.sameValue(obj, thisobj, 'The value of obj is expected to equal the value of thisobj'); diff --git a/test/sendable/builtins/Function/S15.3_A2_T1.js b/test/sendable/builtins/Function/S15.3_A2_T1.js index a883f93a55e..d43f544fe6c 100644 --- a/test/sendable/builtins/Function/S15.3_A2_T1.js +++ b/test/sendable/builtins/Function/S15.3_A2_T1.js @@ -15,15 +15,15 @@ /*--- info: | - Since applying the "call" method to SendableFunction constructor themself leads + Since applying the "call" method to SharedFunction constructor themself leads to creating a new function instance, the second argument must be a valid function body es5id: 15.3_A2_T1 -description: Checking if executing "SendableFunction.call(this, "var x / = 1;")" fails +description: Checking if executing "SharedFunction.call(this, "var x / = 1;")" fails ---*/ try { - SendableFunction.call(this, "var x / = 1;"); + SharedFunction.call(this, "var x / = 1;"); } catch (e) { assert( e instanceof SyntaxError, diff --git a/test/sendable/builtins/Function/S15.3_A2_T2.js b/test/sendable/builtins/Function/S15.3_A2_T2.js index 7e71a0180fe..d729935d0ec 100644 --- a/test/sendable/builtins/Function/S15.3_A2_T2.js +++ b/test/sendable/builtins/Function/S15.3_A2_T2.js @@ -15,15 +15,15 @@ /*--- info: | - Since applying the "call" method to SendableFunction constructor themself leads + Since applying the "call" method to SharedFunction constructor themself leads to creating a new function instance, the second argument must be a valid function body es5id: 15.3_A2_T2 -description: Checking if executing "SendableFunction.call(this, "var #x = 1;")" fails +description: Checking if executing "SharedFunction.call(this, "var #x = 1;")" fails ---*/ try { - SendableFunction.call(this, "var #x = 1;"); + SharedFunction.call(this, "var #x = 1;"); } catch (e) { assert( e instanceof SyntaxError, diff --git a/test/sendable/builtins/Function/S15.3_A3_T1.js b/test/sendable/builtins/Function/S15.3_A3_T1.js index 61483e38dce..3461685452b 100644 --- a/test/sendable/builtins/Function/S15.3_A3_T1.js +++ b/test/sendable/builtins/Function/S15.3_A3_T1.js @@ -15,25 +15,25 @@ /*--- info: | - Since when call is used for SendableFunction constructor themself new function instance creates + Since when call is used for SharedFunction constructor themself new function instance creates and then first argument(thisArg) should be ignored es5id: 15.3_A3_T1 description: First argument is object ---*/ -var f = SendableFunction.call(mars, "return name;"); +var f = SharedFunction.call(mars, "return name;"); var mars = { name: "mars", color: "red", number: 4 }; -var f = SendableFunction.call(mars, "this.godname=\"ares\"; return this.color;"); +var f = SharedFunction.call(mars, "this.godname=\"ares\"; return this.color;"); var about_mars = f(); assert.sameValue(about_mars, undefined); if (this.godname !== "ares" && mars.godname === undefined) { - throw new Test262Error('#3: When applied to the SendableFunction object itself, thisArg should be ignored'); + throw new Test262Error('#3: When applied to the SharedFunction object itself, thisArg should be ignored'); } diff --git a/test/sendable/builtins/Function/S15.3_A3_T2.js b/test/sendable/builtins/Function/S15.3_A3_T2.js index 5c8a30ce622..8ea0c520fc4 100644 --- a/test/sendable/builtins/Function/S15.3_A3_T2.js +++ b/test/sendable/builtins/Function/S15.3_A3_T2.js @@ -15,7 +15,7 @@ /*--- info: | - Since when call is used for SendableFunction constructor themself new function instance creates + Since when call is used for SharedFunction constructor themself new function instance creates and then first argument(thisArg) should be ignored es5id: 15.3_A3_T2 description: First argument is string and null @@ -24,10 +24,10 @@ description: First argument is string and null this.color = "red"; var planet = "mars"; -var f = SendableFunction.call("blablastring", "return this.color;"); +var f = SharedFunction.call("blablastring", "return this.color;"); assert.sameValue(f(), "red", 'f() must return "red"'); -var g = SendableFunction.call(null, "return this.planet;"); +var g = SharedFunction.call(null, "return this.planet;"); assert.sameValue(g(), "mars", 'g() must return "mars"'); diff --git a/test/sendable/builtins/Function/S15.3_A3_T3.js b/test/sendable/builtins/Function/S15.3_A3_T3.js index 0b8fa17d588..0102ec3eb83 100644 --- a/test/sendable/builtins/Function/S15.3_A3_T3.js +++ b/test/sendable/builtins/Function/S15.3_A3_T3.js @@ -15,14 +15,14 @@ /*--- info: | - Since when call is used for SendableFunction constructor themself new function instance creates + Since when call is used for SharedFunction constructor themself new function instance creates and then first argument(thisArg) should be ignored es5id: 15.3_A3_T3 description: First argument is this, and this don`t have needed variable ---*/ -var f = SendableFunction.call(this, "return planet;"); -var g = SendableFunction.call(this, "return color;"); +var f = SharedFunction.call(this, "return planet;"); +var g = SharedFunction.call(this, "return color;"); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3_A3_T4.js b/test/sendable/builtins/Function/S15.3_A3_T4.js index fbee7178852..87b54cda2f7 100644 --- a/test/sendable/builtins/Function/S15.3_A3_T4.js +++ b/test/sendable/builtins/Function/S15.3_A3_T4.js @@ -15,13 +15,13 @@ /*--- info: | - Since when call is used for SendableFunction constructor themself new function instance creates + Since when call is used for SharedFunction constructor themself new function instance creates and then first argument(thisArg) should be ignored es5id: 15.3_A3_T4 description: First argument is this, and this have needed variable ---*/ -var f = SendableFunction.call(this, "return planet;"); +var f = SharedFunction.call(this, "return planet;"); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3_A3_T5.js b/test/sendable/builtins/Function/S15.3_A3_T5.js index 9e76f477e3e..b990e709b99 100644 --- a/test/sendable/builtins/Function/S15.3_A3_T5.js +++ b/test/sendable/builtins/Function/S15.3_A3_T5.js @@ -15,16 +15,16 @@ /*--- info: | - Since when call is used for SendableFunction constructor themself new function instance creates + Since when call is used for SharedFunction constructor themself new function instance creates and then first argument(thisArg) should be ignored es5id: 15.3_A3_T5 description: > First argument is this, and this don`t have needed variable. - SendableFunction return this.var_name + SharedFunction return this.var_name ---*/ -var f = SendableFunction.call(this, "return this.planet;"); -var g = SendableFunction.call(this, "return this.color;"); +var f = SharedFunction.call(this, "return this.planet;"); +var g = SharedFunction.call(this, "return this.color;"); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/S15.3_A3_T6.js b/test/sendable/builtins/Function/S15.3_A3_T6.js index 08516f7c024..98f8f09d116 100644 --- a/test/sendable/builtins/Function/S15.3_A3_T6.js +++ b/test/sendable/builtins/Function/S15.3_A3_T6.js @@ -15,15 +15,15 @@ /*--- info: | - Since when call is used for SendableFunction constructor themself new function instance creates + Since when call is used for SharedFunction constructor themself new function instance creates and then first argument(thisArg) should be ignored es5id: 15.3_A3_T6 description: > - First argument is this, and this have needed variable. SendableFunction + First argument is this, and this have needed variable. SharedFunction return this.var_name ---*/ -var f = SendableFunction.call(this, "return this.planet;"); +var f = SharedFunction.call(this, "return this.planet;"); assert.sameValue(f(), undefined, 'f() returns undefined'); diff --git a/test/sendable/builtins/Function/StrictFunction_reservedwords_with.js b/test/sendable/builtins/Function/StrictFunction_reservedwords_with.js index a32c512bc23..ffcf082697e 100644 --- a/test/sendable/builtins/Function/StrictFunction_reservedwords_with.js +++ b/test/sendable/builtins/Function/StrictFunction_reservedwords_with.js @@ -30,5 +30,5 @@ info: | ---*/ assert.throws(SyntaxError, function() { - new SendableFunction("'use strict'; with ({}) {}"); -}, '`new SendableFunction("\'use strict\'; with ({}) {}")` throws a SyntaxError exception'); + new SharedFunction("'use strict'; with ({}) {}"); +}, '`new SharedFunction("\'use strict\'; with ({}) {}")` throws a SyntaxError exception'); diff --git a/test/sendable/builtins/Function/StrictFunction_restricted-properties.js b/test/sendable/builtins/Function/StrictFunction_restricted-properties.js index 16e477e3893..093bce26070 100644 --- a/test/sendable/builtins/Function/StrictFunction_restricted-properties.js +++ b/test/sendable/builtins/Function/StrictFunction_restricted-properties.js @@ -15,7 +15,7 @@ /*--- description: > - ECMAScript SendableFunction objects defined using syntactic constructors + ECMAScript SharedFunction objects defined using syntactic constructors in strict mode code do not have own properties "caller" or "arguments" other than those that are created by applying the AddRestrictedSendableFunctionProperties abstract operation to the function. @@ -41,7 +41,7 @@ assert.throws(TypeError, function() { func.arguments = {}; }, 'func.arguments = {} throws a TypeError exception'); -var newfunc = new SendableFunction('"use strict"'); +var newfunc = new SharedFunction('"use strict"'); assert.sameValue(newfunc.hasOwnProperty('caller'), false, 'newfunc.hasOwnProperty(\'caller\') must return false'); assert.sameValue(newfunc.hasOwnProperty('arguments'), false, 'newfunc.hasOwnProperty(\'arguments\') must return false'); diff --git a/test/sendable/builtins/Function/call-bind-this-realm-undef.js b/test/sendable/builtins/Function/call-bind-this-realm-undef.js index 6797e84f42b..60ab3c5507e 100644 --- a/test/sendable/builtins/Function/call-bind-this-realm-undef.js +++ b/test/sendable/builtins/Function/call-bind-this-realm-undef.js @@ -35,7 +35,7 @@ features: [cross-realm] ---*/ var other = $262.createRealm().global; -var func = new other.SendableFunction('return this;'); +var func = new other.SharedFunction('return this;'); var subject; assert.sameValue(func(), other, 'implicit undefined'); diff --git a/test/sendable/builtins/Function/call-bind-this-realm-value.js b/test/sendable/builtins/Function/call-bind-this-realm-value.js index fd48b529747..998d7b43796 100644 --- a/test/sendable/builtins/Function/call-bind-this-realm-value.js +++ b/test/sendable/builtins/Function/call-bind-this-realm-value.js @@ -36,7 +36,7 @@ features: [cross-realm] ---*/ var other = $262.createRealm().global; -var func = new other.SendableFunction('return this;'); +var func = new other.SharedFunction('return this;'); var subject; subject = func.call(true); diff --git a/test/sendable/builtins/Function/instance-name.js b/test/sendable/builtins/Function/instance-name.js index 89200bb3ccd..6711d4b5674 100644 --- a/test/sendable/builtins/Function/instance-name.js +++ b/test/sendable/builtins/Function/instance-name.js @@ -28,7 +28,7 @@ info: | includes: [propertyHelper.js] ---*/ -assert.sameValue(SendableFunction().name, 'anonymous'); -verifyNotEnumerable(SendableFunction(), 'name'); -verifyNotWritable(SendableFunction(), 'name'); -verifyConfigurable(SendableFunction(), 'name'); +assert.sameValue(SharedFunction().name, 'anonymous'); +verifyNotEnumerable(SharedFunction(), 'name'); +verifyNotWritable(SharedFunction(), 'name'); +verifyConfigurable(SharedFunction(), 'name'); diff --git a/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js b/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js index ce16655db59..b70ba5a410d 100644 --- a/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js +++ b/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy-realm.js @@ -44,7 +44,7 @@ info: | [...] 2. If obj has a [[Realm]] internal slot, then [...] - 3. If obj is a Bound SendableFunction exotic object, then + 3. If obj is a Bound SharedFunction exotic object, then [...] 4. If obj is a Proxy exotic object, then a. If the value of the [[ProxyHandler]] internal slot of obj is null, diff --git a/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy.js b/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy.js index 5e25d5ca690..b38a287c5ce 100644 --- a/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy.js +++ b/test/sendable/builtins/Function/internals/Construct/base-ctor-revoked-proxy.js @@ -42,7 +42,7 @@ info: | [...] 2. If obj has a [[Realm]] internal slot, then [...] - 3. If obj is a Bound SendableFunction exotic object, then + 3. If obj is a Bound SharedFunction exotic object, then [...] 4. If obj is a Proxy exotic object, then a. If the value of the [[ProxyHandler]] internal slot of obj is null, diff --git a/test/sendable/builtins/Function/is-a-constructor.js b/test/sendable/builtins/Function/is-a-constructor.js index 3201196d805..cac4d86ea75 100644 --- a/test/sendable/builtins/Function/is-a-constructor.js +++ b/test/sendable/builtins/Function/is-a-constructor.js @@ -16,7 +16,7 @@ /*--- esid: sec-ecmascript-standard-built-in-objects description: > - The SendableFunction constructor implements [[Construct]] + The SharedFunction constructor implements [[Construct]] info: | IsConstructor ( argument ) @@ -31,6 +31,6 @@ includes: [isConstructor.js] features: [Reflect.construct] ---*/ -assert.sameValue(isConstructor(SendableFunction), true, 'isConstructor(SendableFunction) must return true'); -new SendableFunction(); +assert.sameValue(isConstructor(SharedFunction), true, 'isConstructor(SharedFunction) must return true'); +new SharedFunction(); diff --git a/test/sendable/builtins/Function/length/15.3.3.2-1.js b/test/sendable/builtins/Function/length/15.3.3.2-1.js index 6dae554a6f4..df074bf7adc 100644 --- a/test/sendable/builtins/Function/length/15.3.3.2-1.js +++ b/test/sendable/builtins/Function/length/15.3.3.2-1.js @@ -15,10 +15,10 @@ /*--- es5id: 15.3.3.2-1 -description: SendableFunction.length - data property with value 1 +description: SharedFunction.length - data property with value 1 ---*/ -var desc = Object.getOwnPropertyDescriptor(SendableFunction, "length"); +var desc = Object.getOwnPropertyDescriptor(SharedFunction, "length"); assert.sameValue(desc.value, 1, 'desc.value'); assert.sameValue(desc.writable, false, 'desc.writable'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T1.js b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T1.js index 8ec8bb559b3..44d885391d8 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T1.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T1.js @@ -18,10 +18,10 @@ info: | The value of the length property is usually an integer that indicates the 'typical' number of arguments expected by the function es5id: 15.3.5.1_A1_T1 -description: Checking length property of SendableFunction("arg1,arg2,arg3", null) +description: Checking length property of SharedFunction("arg1,arg2,arg3", null) ---*/ -var f = new SendableFunction("arg1,arg2,arg3", null); +var f = new SharedFunction("arg1,arg2,arg3", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); assert.sameValue(f.length, 3, 'The value of f.length is expected to be 3'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T2.js b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T2.js index 68c1f4abf6c..83102e538fb 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T2.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T2.js @@ -19,11 +19,11 @@ info: | 'typical' number of arguments expected by the function es5id: 15.3.5.1_A1_T2 description: > - Checking length property of SendableFunction("arg1,arg2,arg3","arg4,arg5", + Checking length property of SharedFunction("arg1,arg2,arg3","arg4,arg5", null) ---*/ -var f = SendableFunction("arg1,arg2,arg3", "arg4,arg5", null); +var f = SharedFunction("arg1,arg2,arg3", "arg4,arg5", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); assert.sameValue(f.length, 5, 'The value of f.length is expected to be 5'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T3.js b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T3.js index 4fa866ec129..86e9ed6ebf8 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A1_T3.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A1_T3.js @@ -20,10 +20,10 @@ info: | es5id: 15.3.5.1_A1_T3 description: > Checking length property of - SendableFunction("arg1,arg2,arg3","arg1,arg2","arg3", null) + SharedFunction("arg1,arg2,arg3","arg1,arg2","arg3", null) ---*/ -var f = new SendableFunction("arg1,arg2,arg3", "arg1,arg2", "arg3", null); +var f = new SharedFunction("arg1,arg2,arg3", "arg1,arg2", "arg3", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); assert.sameValue(f.length, 6, 'The value of f.length is expected to be 6'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T1.js b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T1.js index f04611aded4..472b336f3ce 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T1.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T1.js @@ -18,10 +18,10 @@ info: the length property does not have the attributes { DontDelete } es5id: 15.3.5.1_A2_T1 description: > Checking if deleting the length property of - SendableFunction("arg1,arg2,arg3", null) succeeds + SharedFunction("arg1,arg2,arg3", null) succeeds ---*/ -var f = new SendableFunction("arg1,arg2,arg3", null); +var f = new SharedFunction("arg1,arg2,arg3", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); assert(delete f.length, 'The value of delete f.length is expected to be true'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T2.js b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T2.js index 1d20bc8444b..f1c75a57949 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T2.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T2.js @@ -18,10 +18,10 @@ info: the length property does not have the attributes { DontDelete } es5id: 15.3.5.1_A2_T2 description: > Checking if deleting the length property of - SendableFunction("arg1,arg2,arg3","arg4,arg5", null) succeeds + SharedFunction("arg1,arg2,arg3","arg4,arg5", null) succeeds ---*/ -var f = SendableFunction("arg1,arg2,arg3", "arg4,arg5", null); +var f = SharedFunction("arg1,arg2,arg3", "arg4,arg5", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T3.js b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T3.js index a3df8795023..928c17b90c1 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A2_T3.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A2_T3.js @@ -18,10 +18,10 @@ info: the length property does not have the attributes { DontDelete } es5id: 15.3.5.1_A2_T3 description: > Checking if deleting the length property of - SendableFunction("arg1,arg2,arg3","arg1,arg2","arg3", null) succeeds + SharedFunction("arg1,arg2,arg3","arg1,arg2","arg3", null) succeeds ---*/ -var f = new SendableFunction("arg1,arg2,arg3", "arg1,arg2", "arg3", null); +var f = new SharedFunction("arg1,arg2,arg3", "arg1,arg2", "arg3", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T1.js b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T1.js index aecb2f13029..922d6697fe5 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T1.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T1.js @@ -18,11 +18,11 @@ info: the length property has the attributes { ReadOnly } es5id: 15.3.5.1_A3_T1 description: > Checking if varying the length property of - SendableFunction("arg1,arg2,arg3","arg4,arg5", null) fails + SharedFunction("arg1,arg2,arg3","arg4,arg5", null) fails includes: [propertyHelper.js] ---*/ -var f = new SendableFunction("arg1,arg2,arg3", "arg4,arg5", null); +var f = new SharedFunction("arg1,arg2,arg3", "arg4,arg5", null); assert(f.hasOwnProperty('length')); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T2.js b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T2.js index 760eeddd457..9f16ce4f885 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T2.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T2.js @@ -18,11 +18,11 @@ info: the length property has the attributes { ReadOnly } es5id: 15.3.5.1_A3_T2 description: > Checking if varying the length property of - SendableFunction("arg1,arg2,arg3", null) fails + SharedFunction("arg1,arg2,arg3", null) fails includes: [propertyHelper.js] ---*/ -var f = SendableFunction("arg1,arg2,arg3", null); +var f = SharedFunction("arg1,arg2,arg3", null); assert(f.hasOwnProperty('length')); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T3.js b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T3.js index fd39127657f..fcfbfd9cd24 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A3_T3.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A3_T3.js @@ -18,11 +18,11 @@ info: the length property has the attributes { ReadOnly } es5id: 15.3.5.1_A3_T3 description: > Checking if varying the length property of - SendableFunction("arg1,arg2,arg3","arg1,arg2","arg3", null) fails + SharedFunction("arg1,arg2,arg3","arg1,arg2","arg3", null) fails includes: [propertyHelper.js] ---*/ -var f = new SendableFunction("arg1,arg2,arg3", "arg1,arg2", "arg3", null); +var f = new SharedFunction("arg1,arg2,arg3", "arg1,arg2", "arg3", null); assert(f.hasOwnProperty('length')); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T1.js b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T1.js index 7e58753a29f..6b811e51ed2 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T1.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T1.js @@ -18,10 +18,10 @@ info: the length property has the attributes { DontEnum } es5id: 15.3.5.1_A4_T1 description: > Checking if enumerating the length property of - SendableFunction("arg1,arg2,arg3", null) fails + SharedFunction("arg1,arg2,arg3", null) fails ---*/ -var f = new SendableFunction("arg1,arg2,arg3", null); +var f = new SharedFunction("arg1,arg2,arg3", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T2.js b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T2.js index 55c6dd8d517..d2eaeab1e9b 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T2.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T2.js @@ -18,10 +18,10 @@ info: the length property has the attributes { DontEnum } es5id: 15.3.5.1_A4_T2 description: > Checking if enumerating the length property of - SendableFunction("arg1,arg2,arg3","arg4,arg5", null) fails + SharedFunction("arg1,arg2,arg3","arg4,arg5", null) fails ---*/ -var f = SendableFunction("arg1,arg2,arg3", "arg5,arg4", null); +var f = SharedFunction("arg1,arg2,arg3", "arg5,arg4", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); diff --git a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T3.js b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T3.js index cc943436834..c0574253673 100644 --- a/test/sendable/builtins/Function/length/S15.3.5.1_A4_T3.js +++ b/test/sendable/builtins/Function/length/S15.3.5.1_A4_T3.js @@ -18,10 +18,10 @@ info: the length property has the attributes { DontEnum } es5id: 15.3.5.1_A4_T3 description: > Checking if enumerating the length property of - SendableFunction("arg1,arg2,arg3","arg1,arg2","arg3", null) fails + SharedFunction("arg1,arg2,arg3","arg1,arg2","arg3", null) fails ---*/ -var f = new SendableFunction("arg1,arg2,arg3", "arg1,arg2", "arg3", null); +var f = new SharedFunction("arg1,arg2,arg3", "arg1,arg2", "arg3", null); assert(f.hasOwnProperty('length'), 'f.hasOwnProperty(\'length\') must return true'); diff --git a/test/sendable/builtins/Function/private-identifiers-not-empty.js b/test/sendable/builtins/Function/private-identifiers-not-empty.js index f705564ecc7..c8eac58019b 100644 --- a/test/sendable/builtins/Function/private-identifiers-not-empty.js +++ b/test/sendable/builtins/Function/private-identifiers-not-empty.js @@ -28,6 +28,6 @@ features: [class-fields-private] assert.throws(SyntaxError, function() { let o = {}; - new SendableFunction("o.#f"); + new SharedFunction("o.#f"); }, 'It should be a SyntaxError if AllPrivateIdentifiersValid returns false to dynamic function body'); diff --git a/test/sendable/builtins/Function/prop-desc.js b/test/sendable/builtins/Function/prop-desc.js index 2f9d5e1bef2..b111fc02b15 100644 --- a/test/sendable/builtins/Function/prop-desc.js +++ b/test/sendable/builtins/Function/prop-desc.js @@ -15,7 +15,7 @@ /*--- esid: sec-constructor-properties-of-the-global-object-function -description: Property descriptor for SendableFunction +description: Property descriptor for SharedFunction info: | Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, @@ -23,7 +23,7 @@ info: | includes: [propertyHelper.js] ---*/ -verifyProperty(this, "SendableFunction", { +verifyProperty(this, "SharedFunction", { writable: true, enumerable: false, configurable: true diff --git a/test/sendable/builtins/Function/property-order.js b/test/sendable/builtins/Function/property-order.js index e9a4c207da6..3217a4e2db3 100644 --- a/test/sendable/builtins/Function/property-order.js +++ b/test/sendable/builtins/Function/property-order.js @@ -15,12 +15,12 @@ /*--- esid: sec-createbuiltinfunction -description: SendableFunction constructor property order +description: SharedFunction constructor property order info: | Set order: "length", "name", ... ---*/ -var propNames = Object.getOwnPropertyNames(SendableFunction); +var propNames = Object.getOwnPropertyNames(SharedFunction); var lengthIndex = propNames.indexOf("length"); var nameIndex = propNames.indexOf("name"); diff --git a/test/sendable/builtins/Function/proto-from-ctor-realm-prototype.js b/test/sendable/builtins/Function/proto-from-ctor-realm-prototype.js index ccfdc82c517..b3fcdc295f1 100644 --- a/test/sendable/builtins/Function/proto-from-ctor-realm-prototype.js +++ b/test/sendable/builtins/Function/proto-from-ctor-realm-prototype.js @@ -19,7 +19,7 @@ description: > While default [[Prototype]] value derives from realm of the newTarget, "prototype" object inherits from %Object.prototype% of constructor's realm. info: | - SendableFunction ( p1, p2, … , pn, body ) + SharedFunction ( p1, p2, … , pn, body ) [...] 3. Return ? CreateDynamicSendableFunction(C, NewTarget, normal, args). @@ -51,11 +51,11 @@ var realmA = $262.createRealm().global; realmA.calls = 0; var realmB = $262.createRealm().global; -var newTarget = new realmB.SendableFunction(); +var newTarget = new realmB.SharedFunction(); newTarget.prototype = null; -var fn = Reflect.construct(realmA.SendableFunction, ["calls += 1;"], newTarget); -assert.sameValue(Object.getPrototypeOf(fn), realmB.SendableFunction.prototype); +var fn = Reflect.construct(realmA.SharedFunction, ["calls += 1;"], newTarget); +assert.sameValue(Object.getPrototypeOf(fn), realmB.SharedFunction.prototype); assert.sameValue(Object.getPrototypeOf(fn.prototype), realmA.Object.prototype); assert(new fn() instanceof realmA.Object); diff --git a/test/sendable/builtins/Function/proto-from-ctor-realm.js b/test/sendable/builtins/Function/proto-from-ctor-realm.js index 4e7c6086e15..771eef2cdf9 100644 --- a/test/sendable/builtins/Function/proto-from-ctor-realm.js +++ b/test/sendable/builtins/Function/proto-from-ctor-realm.js @@ -42,9 +42,9 @@ features: [cross-realm, Reflect] ---*/ var other = $262.createRealm().global; -var C = new other.SendableFunction(); +var C = new other.SharedFunction(); C.prototype = null; -var o = Reflect.construct(SendableFunction, [], C); +var o = Reflect.construct(SharedFunction, [], C); -assert.sameValue(Object.getPrototypeOf(o), other.SendableFunction.prototype); +assert.sameValue(Object.getPrototypeOf(o), other.SharedFunction.prototype); diff --git a/test/sendable/builtins/Function/prototype/S15.3.3.1_A1.js b/test/sendable/builtins/Function/prototype/S15.3.3.1_A1.js index 929224844dc..8e47d966fca 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.3.1_A1.js +++ b/test/sendable/builtins/Function/prototype/S15.3.3.1_A1.js @@ -14,24 +14,24 @@ */ /*--- -info: The SendableFunction.prototype property has the attribute ReadOnly +info: The SharedFunction.prototype property has the attribute ReadOnly es5id: 15.3.3.1_A1 -description: Checking if varying the SendableFunction.prototype property fails +description: Checking if varying the SharedFunction.prototype property fails includes: [propertyHelper.js] ---*/ -var obj = SendableFunction.prototype; +var obj = SharedFunction.prototype; -verifyNotWritable(SendableFunction, "prototype", null, function() { +verifyNotWritable(SharedFunction, "prototype", null, function() { return "shifted"; }); -assert.sameValue(SendableFunction.prototype, obj, 'The value of SendableFunction.prototype is expected to equal the value of obj'); +assert.sameValue(SharedFunction.prototype, obj, 'The value of SharedFunction.prototype is expected to equal the value of obj'); try { - assert.sameValue(SendableFunction.prototype(), undefined, 'SendableFunction.prototype() returns undefined'); + assert.sameValue(SharedFunction.prototype(), undefined, 'SharedFunction.prototype() returns undefined'); } catch (e) { - throw new Test262Error('#2.1: the SendableFunction.prototype property has the attributes ReadOnly: ' + e); + throw new Test262Error('#2.1: the SharedFunction.prototype property has the attributes ReadOnly: ' + e); } // TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/S15.3.3.1_A2.js b/test/sendable/builtins/Function/prototype/S15.3.3.1_A2.js index 8bda1ebc1b7..ab4d923bf08 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.3.1_A2.js +++ b/test/sendable/builtins/Function/prototype/S15.3.3.1_A2.js @@ -14,19 +14,19 @@ */ /*--- -info: The SendableFunction.prototype property has the attribute DontEnum +info: The SharedFunction.prototype property has the attribute DontEnum es5id: 15.3.3.1_A2 -description: Checking if enumerating the SendableFunction.prototype property fails +description: Checking if enumerating the SharedFunction.prototype property fails ---*/ assert( - !SendableFunction.propertyIsEnumerable('prototype'), - 'The value of !SendableFunction.propertyIsEnumerable(\'prototype\') is expected to be true' + !SharedFunction.propertyIsEnumerable('prototype'), + 'The value of !SharedFunction.propertyIsEnumerable(\'prototype\') is expected to be true' ); // CHECK#2 var count = 0; -for (var p in SendableFunction) { +for (var p in SharedFunction) { if (p === "prototype") { count++; } diff --git a/test/sendable/builtins/Function/prototype/S15.3.3.1_A3.js b/test/sendable/builtins/Function/prototype/S15.3.3.1_A3.js index 21fe6badd95..e7f858c76fc 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.3.1_A3.js +++ b/test/sendable/builtins/Function/prototype/S15.3.3.1_A3.js @@ -14,16 +14,16 @@ */ /*--- -info: The SendableFunction.prototype property has the attribute DontDelete +info: The SharedFunction.prototype property has the attribute DontDelete es5id: 15.3.3.1_A3 -description: Checking if deleting the SendableFunction.prototype property fails +description: Checking if deleting the SharedFunction.prototype property fails includes: [propertyHelper.js] ---*/ -verifyNotConfigurable(SendableFunction, "prototype"); +verifyNotConfigurable(SharedFunction, "prototype"); try { - assert.sameValue(delete SendableFunction.prototype, false); + assert.sameValue(delete SharedFunction.prototype, false); } catch (e) { if (e instanceof Test262Error) { throw e; @@ -31,8 +31,8 @@ try { assert(e instanceof TypeError); } -if (!(SendableFunction.hasOwnProperty('prototype'))) { - throw new Test262Error('#2: the SendableFunction.prototype property has the attributes DontDelete.'); +if (!(SharedFunction.hasOwnProperty('prototype'))) { + throw new Test262Error('#2: the SharedFunction.prototype property has the attributes DontDelete.'); } // TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A1.js b/test/sendable/builtins/Function/prototype/S15.3.4_A1.js index d2dc6b92e18..012d1fd81dc 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A1.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A1.js @@ -15,13 +15,13 @@ /*--- info: | - The SendableFunction prototype object is itself a SendableFunction object (its [[Class]] - is "SendableFunction") + The SharedFunction prototype object is itself a SharedFunction object (its [[Class]] + is "SharedFunction") es5id: 15.3.4_A1 description: Object.prototype.toString returns [object+[[Class]]+] ---*/ assert.sameValue( - Object.prototype.toString.call(SendableFunction.prototype), - "[object SendableFunction]", - 'Object.prototype.toString.call(SendableFunction.prototype) must return "[object SendableFunction]"' + Object.prototype.toString.call(SharedFunction.prototype), + "[object SharedFunction]", + 'Object.prototype.toString.call(SharedFunction.prototype) must return "[object SharedFunction]"' ); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T1.js b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T1.js index 2ba62df56d1..070d5c6d19a 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T1.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T1.js @@ -15,14 +15,14 @@ /*--- info: | - The SendableFunction prototype object is itself a SendableFunction object that, when + The SharedFunction prototype object is itself a SharedFunction object that, when invoked, accepts any arguments and returns undefined es5id: 15.3.4_A2_T1 -description: Call SendableFunction.prototype() +description: Call SharedFunction.prototype() ---*/ try { - assert.sameValue(SendableFunction.prototype(), undefined, 'SendableFunction.prototype() returns undefined'); + assert.sameValue(SharedFunction.prototype(), undefined, 'SharedFunction.prototype() returns undefined'); } catch (e) { - throw new Test262Error('#1.1: The SendableFunction prototype object is itself a SendableFunction object that, when invoked, accepts any arguments and returns undefined: ' + e); + throw new Test262Error('#1.1: The SharedFunction prototype object is itself a SharedFunction object that, when invoked, accepts any arguments and returns undefined: ' + e); } diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T2.js b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T2.js index e5cd8c048ab..7a00c4adc82 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T2.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T2.js @@ -15,14 +15,14 @@ /*--- info: | - The SendableFunction prototype object is itself a SendableFunction object that, when + The SharedFunction prototype object is itself a SharedFunction object that, when invoked, accepts any arguments and returns undefined es5id: 15.3.4_A2_T2 -description: Call SendableFunction.prototype(null,void 0) +description: Call SharedFunction.prototype(null,void 0) ---*/ try { - assert.sameValue(SendableFunction.prototype(null, void 0), undefined, 'SendableFunction.prototype(null, void 0) returns undefined'); + assert.sameValue(SharedFunction.prototype(null, void 0), undefined, 'SharedFunction.prototype(null, void 0) returns undefined'); } catch (e) { - throw new Test262Error('#1.1: The SendableFunction prototype object is itself a SendableFunction object that, when invoked, accepts any arguments and returns undefined: ' + e); + throw new Test262Error('#1.1: The SharedFunction prototype object is itself a SharedFunction object that, when invoked, accepts any arguments and returns undefined: ' + e); } diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T3.js b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T3.js index c6626a79db3..528b942469d 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A2_T3.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A2_T3.js @@ -15,11 +15,11 @@ /*--- info: | - The SendableFunction prototype object is itself a SendableFunction object that, when + The SharedFunction prototype object is itself a SharedFunction object that, when invoked, accepts any arguments and returns undefined es5id: 15.3.4_A2_T3 -description: Call SendableFunction.prototype(x), where x is undefined variable +description: Call SharedFunction.prototype(x), where x is undefined variable ---*/ var x; -assert.sameValue(SendableFunction.prototype(x), undefined, 'SendableFunction.prototype(x) returns undefined'); +assert.sameValue(SharedFunction.prototype(x), undefined, 'SharedFunction.prototype(x) returns undefined'); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A3_T1.js b/test/sendable/builtins/Function/prototype/S15.3.4_A3_T1.js index 57de7b03fdc..43a0c453020 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A3_T1.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A3_T1.js @@ -15,13 +15,13 @@ /*--- info: | - The value of the internal [[Prototype]] property of the SendableFunction + The value of the internal [[Prototype]] property of the SharedFunction prototype object is the Object prototype object (15.3.4) es5id: 15.3.4_A3_T1 -description: Checking prototype of SendableFunction.prototype +description: Checking prototype of SharedFunction.prototype ---*/ assert.sameValue( - Object.getPrototypeOf(SendableFunction.prototype), + Object.getPrototypeOf(SharedFunction.prototype), Object.prototype, - 'Object.getPrototypeOf(SendableFunction.prototype) returns Object.prototype' + 'Object.getPrototypeOf(SharedFunction.prototype) returns Object.prototype' ); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A3_T2.js b/test/sendable/builtins/Function/prototype/S15.3.4_A3_T2.js index 1524f73e9c5..c0df1165980 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A3_T2.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A3_T2.js @@ -15,14 +15,14 @@ /*--- info: | - The value of the internal [[Prototype]] property of the SendableFunction + The value of the internal [[Prototype]] property of the SharedFunction prototype object is the Object prototype object (15.3.2.1) es5id: 15.3.4_A3_T2 description: > Add new property to Object.prototype and check it at - SendableFunction.prototype + SharedFunction.prototype ---*/ Object.prototype.indicator = 1; -assert.sameValue(SendableFunction.prototype.indicator, 1, 'The value of SendableFunction.prototype.indicator is expected to be 1'); +assert.sameValue(SharedFunction.prototype.indicator, 1, 'The value of SharedFunction.prototype.indicator is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A4.js b/test/sendable/builtins/Function/prototype/S15.3.4_A4.js index 579c5c632db..af78258bff9 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A4.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A4.js @@ -15,26 +15,26 @@ /*--- info: | - The SendableFunction prototype object does not have a valueOf property of its + The SharedFunction prototype object does not have a valueOf property of its own. however, it inherits the valueOf property from the Object prototype Object es5id: 15.3.4_A4 -description: Checking valueOf property at SendableFunction.prototype +description: Checking valueOf property at SharedFunction.prototype ---*/ assert.sameValue( - SendableFunction.prototype.hasOwnProperty("valueOf"), + SharedFunction.prototype.hasOwnProperty("valueOf"), false, - 'SendableFunction.prototype.hasOwnProperty("valueOf") must return false' + 'SharedFunction.prototype.hasOwnProperty("valueOf") must return false' ); assert.notSameValue( - typeof SendableFunction.prototype.valueOf, + typeof SharedFunction.prototype.valueOf, "undefined", - 'The value of typeof SendableFunction.prototype.valueOf is not "undefined"' + 'The value of typeof SharedFunction.prototype.valueOf is not "undefined"' ); assert.sameValue( - SendableFunction.prototype.valueOf, + SharedFunction.prototype.valueOf, Object.prototype.valueOf, - 'The value of SendableFunction.prototype.valueOf is expected to equal the value of Object.prototype.valueOf' + 'The value of SharedFunction.prototype.valueOf is expected to equal the value of Object.prototype.valueOf' ); diff --git a/test/sendable/builtins/Function/prototype/S15.3.4_A5.js b/test/sendable/builtins/Function/prototype/S15.3.4_A5.js index 006fd0e3af2..055217736ca 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.4_A5.js +++ b/test/sendable/builtins/Function/prototype/S15.3.4_A5.js @@ -15,12 +15,12 @@ /*--- info: | - The SendableFunction prototype object is itself a SendableFunction object without + The SharedFunction prototype object is itself a SharedFunction object without [[Construct]] property es5id: 15.3.4_A5 -description: Checking if creating "new SendableFunction.prototype object" fails +description: Checking if creating "new SharedFunction.prototype object" fails ---*/ assert.throws(TypeError, function() { - new SendableFunction.prototype; -}, '`new SendableFunction.prototype` throws a TypeError exception'); + new SharedFunction.prototype; +}, '`new SharedFunction.prototype` throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T1.js b/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T1.js index b8925ac836c..9eb31ee295b 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T1.js +++ b/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T1.js @@ -17,12 +17,12 @@ info: the prototype property has the attributes { DontDelete } es5id: 15.3.5.2_A1_T1 description: > - Checking if deleting the prototype property of SendableFunction("", null) + Checking if deleting the prototype property of SharedFunction("", null) fails includes: [propertyHelper.js] ---*/ -var f = new SendableFunction("", null); +var f = new SharedFunction("", null); assert(f.hasOwnProperty('prototype')); diff --git a/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T2.js b/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T2.js index b551276c9f3..b75e67f94f1 100644 --- a/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T2.js +++ b/test/sendable/builtins/Function/prototype/S15.3.5.2_A1_T2.js @@ -17,12 +17,12 @@ info: the prototype property has the attributes { DontDelete } es5id: 15.3.5.2_A1_T2 description: > - Checking if deleting the prototype property of SendableFunction(void 0, + Checking if deleting the prototype property of SharedFunction(void 0, "") fails includes: [propertyHelper.js] ---*/ -var f = SendableFunction(void 0, ""); +var f = SharedFunction(void 0, ""); assert(f.hasOwnProperty('prototype')); diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/length.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/length.js index 65bdbe2dc05..e5d21ef104e 100644 --- a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/length.js +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/length.js @@ -15,24 +15,24 @@ /*--- es6id: 19.2.3.6 -description: SendableFunction.prototye[Symbol.hasInstance] `length` property +description: SharedFunction.prototye[Symbol.hasInstance] `length` property info: | ES6 Section 17: - Every built-in SendableFunction object, including constructors, has a length + Every built-in SharedFunction 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. [...] - Unless otherwise specified, the length property of a built-in SendableFunction + Unless otherwise specified, the length property of a built-in SharedFunction object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. features: [Symbol.hasInstance] includes: [propertyHelper.js] ---*/ -verifyProperty(SendableFunction.prototype[Symbol.hasInstance], "length", { +verifyProperty(SharedFunction.prototype[Symbol.hasInstance], "length", { value: 1, writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/name.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/name.js index 28b0830de03..2894de280b7 100644 --- a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/name.js +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/name.js @@ -23,7 +23,7 @@ features: [Symbol.hasInstance] includes: [propertyHelper.js] ---*/ -verifyProperty(SendableFunction.prototype[Symbol.hasInstance], "name", { +verifyProperty(SharedFunction.prototype[Symbol.hasInstance], "name", { value: "[Symbol.hasInstance]", writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/prop-desc.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/prop-desc.js index 37b64d10a0b..d6c85a586ce 100644 --- a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/prop-desc.js +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/prop-desc.js @@ -15,7 +15,7 @@ /*--- es6id: 19.2.3.6 -description: SendableFunction.prototype[Symbol.hasInstance] property descriptor +description: SharedFunction.prototype[Symbol.hasInstance] property descriptor info: | This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }. @@ -23,9 +23,9 @@ features: [Symbol.hasInstance] includes: [propertyHelper.js] ---*/ -assert.sameValue(typeof SendableFunction.prototype[Symbol.hasInstance], 'function'); +assert.sameValue(typeof SharedFunction.prototype[Symbol.hasInstance], 'function'); -verifyProperty(SendableFunction.prototype, Symbol.hasInstance, { +verifyProperty(SharedFunction.prototype, Symbol.hasInstance, { writable: false, enumerable: false, configurable: false, diff --git a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-not-callable.js b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-not-callable.js index dedcc118b1f..1d5d25da68f 100644 --- a/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-not-callable.js +++ b/test/sendable/builtins/Function/prototype/Symbol.hasInstance/this-val-not-callable.js @@ -26,5 +26,5 @@ info: | features: [Symbol.hasInstance] ---*/ -assert.sameValue(SendableFunction.prototype[Symbol.hasInstance].call(), false); -assert.sameValue(SendableFunction.prototype[Symbol.hasInstance].call({}), false); +assert.sameValue(SharedFunction.prototype[Symbol.hasInstance].call(), false); +assert.sameValue(SharedFunction.prototype[Symbol.hasInstance].call({}), false); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A12.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A12.js index ad23e82773f..6ff40ddb18b 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A12.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A12.js @@ -14,14 +14,14 @@ */ /*--- -info: SendableFunction.prototype.apply has not prototype property +info: SharedFunction.prototype.apply has not prototype property es5id: 15.3.4.3_A12 description: > Checking if obtaining the prototype property of - SendableFunction.prototype.apply fails + SharedFunction.prototype.apply fails ---*/ assert.sameValue( - SendableFunction.prototype.apply.prototype, + SharedFunction.prototype.apply.prototype, undefined, - 'The value of SendableFunction.prototype.apply.prototype is expected to equal undefined' + 'The value of SharedFunction.prototype.apply.prototype is expected to equal undefined' ); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T1.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T1.js index 7627abbc830..de49df12129 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T1.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T1.js @@ -21,10 +21,10 @@ info: | es5id: 15.3.4.3_A1_T1 description: > Calling "apply" method of the object that does not have a [[Call]] - property. Prototype of the object is SendableFunction() + property. Prototype of the object is SharedFunction() ---*/ -var proto = SendableFunction(); +var proto = SharedFunction(); function FACTORY() {} diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T2.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T2.js index 5d828800b7f..3e85467a829 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T2.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A1_T2.js @@ -21,12 +21,12 @@ info: | es5id: 15.3.4.3_A1_T2 description: > Calling "apply" method of the object that does not have a [[Call]] - property. Prototype of the object is SendableFunction.prototype + property. Prototype of the object is SharedFunction.prototype ---*/ function FACTORY() {} -FACTORY.prototype = SendableFunction.prototype; +FACTORY.prototype = SharedFunction.prototype; var obj = new FACTORY; diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T1.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T1.js index 4c78ace7174..e2800530a28 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T1.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T1.js @@ -21,6 +21,6 @@ es5id: 15.3.4.3_A3_T1 description: Not any arguments at apply function ---*/ -SendableFunction("this.field=\"strawberry\"").apply(); +SharedFunction("this.field=\"strawberry\"").apply(); assert.sameValue(this["field"], "strawberry", 'The value of this["field"] is expected to be "strawberry"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T2.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T2.js index 8d9300e8852..42d19c4082c 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T2.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T2.js @@ -21,6 +21,6 @@ es5id: 15.3.4.3_A3_T2 description: Argument at apply function is null ---*/ -SendableFunction("this.field=\"green\"").apply(null); +SharedFunction("this.field=\"green\"").apply(null); assert.sameValue(this["field"], "green", 'The value of this["field"] is expected to be "green"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T3.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T3.js index 239bddec543..d4ba17cdf22 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T3.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T3.js @@ -21,6 +21,6 @@ es5id: 15.3.4.3_A3_T3 description: Argument at apply function is void 0 ---*/ -SendableFunction("this.field=\"battle\"").apply(void 0); +SharedFunction("this.field=\"battle\"").apply(void 0); assert.sameValue(this["field"], "battle", 'The value of this["field"] is expected to be "battle"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T4.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T4.js index 133c86ac8a2..e8b99f29834 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T4.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T4.js @@ -21,6 +21,6 @@ es5id: 15.3.4.3_A3_T4 description: Argument at apply function is undefined ---*/ -SendableFunction("this.field=\"oil\"").apply(undefined); +SharedFunction("this.field=\"oil\"").apply(undefined); assert.sameValue(this["field"], "oil", 'The value of this["field"] is expected to be "oil"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T5.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T5.js index 459558b8eb5..8dec7d5388c 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T5.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T5.js @@ -24,7 +24,7 @@ description: > ---*/ function FACTORY() { - SendableFunction("this.feat=\"in da haus\"").apply(); + SharedFunction("this.feat=\"in da haus\"").apply(); } var obj = new FACTORY; diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T7.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T7.js index 68127fc51b2..3f75952a62e 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T7.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T7.js @@ -24,7 +24,7 @@ description: > ---*/ (function FACTORY() { - SendableFunction("this.feat=\"in da haus\"").apply(void 0); + SharedFunction("this.feat=\"in da haus\"").apply(void 0); })(); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T9.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T9.js index b4b2c00c199..7cfb867c2d1 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T9.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A3_T9.js @@ -21,6 +21,6 @@ es5id: 15.3.4.3_A3_T9 description: Checking by using eval, argument at apply function is void 0 ---*/ -eval(" SendableFunction(\"this.feat=1\").apply(void 0) "); +eval(" SharedFunction(\"this.feat=1\").apply(void 0) "); assert.sameValue(this["feat"], 1, 'The value of this["feat"] is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T1.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T1.js index 703e2a2121f..393c56a099a 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T1.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T1.js @@ -23,7 +23,7 @@ description: thisArg is number var obj = 1; -var retobj = SendableFunction("this.touched= true; return this;").apply(obj); +var retobj = SharedFunction("this.touched= true; return this;").apply(obj); assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T2.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T2.js index 1ff977fe572..08e3a0fbec0 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T2.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T2.js @@ -23,7 +23,7 @@ description: thisArg is boolean true var obj = true; -var retobj = new SendableFunction("this.touched= true; return this;").apply(obj); +var retobj = new SharedFunction("this.touched= true; return this;").apply(obj); assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T7.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T7.js index 27823401637..75621f21d26 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T7.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T7.js @@ -23,6 +23,6 @@ description: thisArg is new Number() var obj = new Number(1); -SendableFunction("this.touched= true;").apply(obj); +SharedFunction("this.touched= true;").apply(obj); assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T8.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T8.js index b1b1e9257f6..932a937e2e4 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T8.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A5_T8.js @@ -18,11 +18,11 @@ info: | If thisArg is not null(defined) the called function is passed ToObject(thisArg) as the this value es5id: 15.3.4.3_A5_T8 -description: thisArg is SendableFunction() +description: thisArg is SharedFunction() ---*/ -var obj = SendableFunction(); +var obj = SharedFunction(); -new SendableFunction("this.touched= true; return this;").apply(obj); +new SharedFunction("this.touched= true; return this;").apply(obj); assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T1.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T1.js index 5222a65583e..cb0341a7761 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T1.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T1.js @@ -21,6 +21,6 @@ es5id: 15.3.4.3_A7_T1 description: argSendableArray is (null,[1]) ---*/ -SendableFunction("a1,a2,a3", "this.shifted=a1;").apply(null, [1]); +SharedFunction("a1,a2,a3", "this.shifted=a1;").apply(null, [1]); assert.sameValue(this["shifted"], 1, 'The value of this["shifted"] is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T10.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T10.js index 3aadcd546d8..1d9fbf4ec2c 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T10.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T10.js @@ -26,7 +26,7 @@ description: > var obj = {}; (function() { - SendableFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(obj, arguments); + SharedFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(obj, arguments); })("", 4, 2); assert.sameValue(obj["shifted"], "42", 'The value of obj["shifted"] is expected to be "42"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T2.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T2.js index d1a1d7dda91..12aba790f7f 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T2.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T2.js @@ -21,6 +21,6 @@ es5id: 15.3.4.3_A7_T2 description: argSendableArray is (null,[1,2,3]) ---*/ -new SendableFunction("a1,a2", "a3", "this.shifted=a2;").apply(null, [1, 2, 3]); +new SharedFunction("a1,a2", "a3", "this.shifted=a2;").apply(null, [1, 2, 3]); assert.sameValue(this["shifted"], 2, 'The value of this["shifted"] is expected to be 2'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T3.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T3.js index 041d05146cf..7c18430a3d0 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T3.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T3.js @@ -31,7 +31,7 @@ var p = { var obj = {}; -SendableFunction(p, "a2,a3", "this.shifted=a1;").apply(obj, new SendableArray("nine", "inch", "nails")); +SharedFunction(p, "a2,a3", "this.shifted=a1;").apply(obj, new SendableArray("nine", "inch", "nails")); assert.sameValue(obj["shifted"], "nine", 'The value of obj["shifted"] is expected to be "nine"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T4.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T4.js index 09d7cd7d661..e8e151782b7 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T4.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T4.js @@ -33,7 +33,7 @@ var p = { var obj = {}; -new SendableFunction(p, p, p, "this.shifted=a3;").apply(obj, (function() { +new SharedFunction(p, p, p, "this.shifted=a3;").apply(obj, (function() { return arguments; })("a", "b", "c")); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T5.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T5.js index 6f7fcc25bc8..9dce53a767f 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T5.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T5.js @@ -22,7 +22,7 @@ description: argSendableArray is (null, arguments), inside function declaration ---*/ function FACTORY() { - SendableFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(null, arguments); + SharedFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(null, arguments); } var obj = new FACTORY("", 1, 2); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T6.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T6.js index 63ff0c3da9f..1ad5ba73400 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T6.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T6.js @@ -22,7 +22,7 @@ description: argSendableArray is (this, arguments), inside function declaration ---*/ function FACTORY() { - SendableFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(this, arguments); + SharedFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(this, arguments); } var obj = new FACTORY("", 4, 2); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T7.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T7.js index 0666369a19e..e64f76c419a 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T7.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T7.js @@ -24,7 +24,7 @@ description: > ---*/ (function() { - SendableFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(null, arguments); + SharedFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(null, arguments); })("", 1, 2); assert.sameValue(this["shifted"], "12", 'The value of this["shifted"] is expected to be "12"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T8.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T8.js index 8ee8d1fdb25..5a0e55333be 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T8.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T8.js @@ -24,7 +24,7 @@ description: > ---*/ (function() { - SendableFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(this, arguments); + SharedFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(this, arguments); })("", 4, 2); assert.sameValue(this["shifted"], "42", 'The value of this["shifted"] is expected to be "42"'); diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T9.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T9.js index a5a541e7b87..1838ab02ccb 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T9.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A7_T9.js @@ -25,7 +25,7 @@ description: > function FACTORY() { var obj = {}; - SendableFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(obj, arguments); + SharedFunction("a1,a2,a3", "this.shifted=a1+a2+a3;").apply(obj, arguments); return obj; } diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T3.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T3.js index ad0c2715028..666d6b3d41e 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T3.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T3.js @@ -14,14 +14,14 @@ */ /*--- -info: SendableFunction.prototype.apply can`t be used as [[Construct]] caller +info: SharedFunction.prototype.apply can`t be used as [[Construct]] caller es5id: 15.3.4.3_A8_T3 -description: Checking if creating "new SendableFunction.apply" fails +description: Checking if creating "new SharedFunction.apply" fails ---*/ try { - var obj = new SendableFunction.apply; - throw new Test262Error('#1: SendableFunction.prototype.apply can\'t be used as [[Construct]] caller'); + var obj = new SharedFunction.apply; + throw new Test262Error('#1: SharedFunction.prototype.apply can\'t be used as [[Construct]] caller'); } catch (e) { assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); } diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T4.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T4.js index 35bb1738c3f..df3166295f3 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T4.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T4.js @@ -14,14 +14,14 @@ */ /*--- -info: SendableFunction.prototype.apply can`t be used as [[Construct]] caller +info: SharedFunction.prototype.apply can`t be used as [[Construct]] caller es5id: 15.3.4.3_A8_T4 -description: Checking if creating "new (SendableFunction("this.p1=1").apply)" fails +description: Checking if creating "new (SharedFunction("this.p1=1").apply)" fails ---*/ try { - var obj = new(SendableFunction("this.p1=1").apply); - throw new Test262Error('#1: SendableFunction.prototype.apply can\'t be used as [[Construct]] caller'); + var obj = new(SharedFunction("this.p1=1").apply); + throw new Test262Error('#1: SharedFunction.prototype.apply can\'t be used as [[Construct]] caller'); } catch (e) { assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); } diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T5.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T5.js index 6831f8c9718..12a1ea37271 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T5.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T5.js @@ -14,15 +14,15 @@ */ /*--- -info: SendableFunction.prototype.apply can`t be used as [[Construct]] caller +info: SharedFunction.prototype.apply can`t be used as [[Construct]] caller es5id: 15.3.4.3_A8_T5 -description: Checking if creating "new SendableFunction("this.p1=1").apply" fails +description: Checking if creating "new SharedFunction("this.p1=1").apply" fails ---*/ try { - var FACTORY = SendableFunction("this.p1=1").apply; + var FACTORY = SharedFunction("this.p1=1").apply; var obj = new FACTORY(); - throw new Test262Error('#1: SendableFunction.prototype.apply can\'t be used as [[Construct]] caller'); + throw new Test262Error('#1: SharedFunction.prototype.apply can\'t be used as [[Construct]] caller'); } catch (e) { assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); } diff --git a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T6.js b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T6.js index ace9d9c89a2..d405dea2ebd 100644 --- a/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T6.js +++ b/test/sendable/builtins/Function/prototype/apply/S15.3.4.3_A8_T6.js @@ -14,17 +14,17 @@ */ /*--- -info: SendableFunction.prototype.apply can`t be used as [[Construct]] caller +info: SharedFunction.prototype.apply can`t be used as [[Construct]] caller es5id: 15.3.4.3_A8_T6 description: > - Checking if creating "new (SendableFunction("function + Checking if creating "new (SharedFunction("function f(){this.p1=1;};return f").apply())" fails ---*/ try { - var obj = new(SendableFunction("function f(){this.p1=1;};return f").apply()); + var obj = new(SharedFunction("function f(){this.p1=1;};return f").apply()); } catch (e) { - throw new Test262Error('#1: SendableFunction.prototype.apply can\'t be used as [[Construct]] caller'); + throw new Test262Error('#1: SharedFunction.prototype.apply can\'t be used as [[Construct]] caller'); } assert.sameValue(obj.p1, 1, 'The value of obj.p1 is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/apply/argarray-not-object-realm.js b/test/sendable/builtins/Function/prototype/apply/argarray-not-object-realm.js index f2af1ac906d..cdd4b80a169 100644 --- a/test/sendable/builtins/Function/prototype/apply/argarray-not-object-realm.js +++ b/test/sendable/builtins/Function/prototype/apply/argarray-not-object-realm.js @@ -19,7 +19,7 @@ description: > Throws a TypeError exception if argSendableArray is not an object (honoring the Realm of the current execution context) info: | - SendableFunction.prototype.apply ( thisArg, argSendableArray ) + SharedFunction.prototype.apply ( thisArg, argSendableArray ) [...] 4. Let argList be ? CreateListFromSendableArrayLike(argSendableArray). @@ -32,7 +32,7 @@ features: [cross-realm] ---*/ var other = $262.createRealm().global; -var fn = new other.SendableFunction(); +var fn = new other.SharedFunction(); assert.throws(other.TypeError, function() { fn.apply(null, false); diff --git a/test/sendable/builtins/Function/prototype/apply/argarray-not-object.js b/test/sendable/builtins/Function/prototype/apply/argarray-not-object.js index 076bc3ca45e..4cf648c7e98 100644 --- a/test/sendable/builtins/Function/prototype/apply/argarray-not-object.js +++ b/test/sendable/builtins/Function/prototype/apply/argarray-not-object.js @@ -18,7 +18,7 @@ esid: sec-function.prototype.apply description: > Throws a TypeError exception if argSendableArray is not an object info: | - SendableFunction.prototype.apply ( thisArg, argSendableArray ) + SharedFunction.prototype.apply ( thisArg, argSendableArray ) [...] 4. Let argList be ? CreateListFromSendableArrayLike(argSendableArray). diff --git a/test/sendable/builtins/Function/prototype/apply/get-index-abrupt.js b/test/sendable/builtins/Function/prototype/apply/get-index-abrupt.js index f489e50f771..db55de8ec02 100644 --- a/test/sendable/builtins/Function/prototype/apply/get-index-abrupt.js +++ b/test/sendable/builtins/Function/prototype/apply/get-index-abrupt.js @@ -18,7 +18,7 @@ esid: sec-function.prototype.apply description: > Return abrupt completion from Get(obj, indexName) info: | - SendableFunction.prototype.apply ( thisArg, argSendableArray ) + SharedFunction.prototype.apply ( thisArg, argSendableArray ) [...] 4. Let argList be ? CreateListFromSendableArrayLike(argSendableArray). diff --git a/test/sendable/builtins/Function/prototype/apply/get-length-abrupt.js b/test/sendable/builtins/Function/prototype/apply/get-length-abrupt.js index 1bc4b9e77a8..799710d6aab 100644 --- a/test/sendable/builtins/Function/prototype/apply/get-length-abrupt.js +++ b/test/sendable/builtins/Function/prototype/apply/get-length-abrupt.js @@ -18,7 +18,7 @@ esid: sec-function.prototype.apply description: > Return abrupt completion from Get(obj, "length") info: | - SendableFunction.prototype.apply ( thisArg, argSendableArray ) + SharedFunction.prototype.apply ( thisArg, argSendableArray ) [...] 4. Let argList be ? CreateListFromSendableArrayLike(argSendableArray). diff --git a/test/sendable/builtins/Function/prototype/apply/length.js b/test/sendable/builtins/Function/prototype/apply/length.js index c72fa29156a..179d2073348 100644 --- a/test/sendable/builtins/Function/prototype/apply/length.js +++ b/test/sendable/builtins/Function/prototype/apply/length.js @@ -16,22 +16,22 @@ /*--- esid: sec-function.prototype.apply description: > - SendableFunction.prototype.apply.length is 2. + SharedFunction.prototype.apply.length is 2. info: | ECMAScript Standard Built-in Objects ... - Every built-in SendableFunction object, including constructors, has a length + Every built-in SharedFunction 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. ... - Unless otherwise specified, the length property of a built-in SendableFunction + Unless otherwise specified, the length property of a built-in SharedFunction object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. includes: [propertyHelper.js] ---*/ -verifyProperty(SendableFunction.prototype.apply, 'length', { +verifyProperty(SharedFunction.prototype.apply, 'length', { value: 2, writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/apply/name.js b/test/sendable/builtins/Function/prototype/apply/name.js index 631b2478e42..301a84fac24 100644 --- a/test/sendable/builtins/Function/prototype/apply/name.js +++ b/test/sendable/builtins/Function/prototype/apply/name.js @@ -16,22 +16,22 @@ /*--- es6id: 19.2.3.1 description: > - SendableFunction.prototype.apply.name is "apply". + SharedFunction.prototype.apply.name is "apply". info: | - SendableFunction.prototype.apply ( thisArg, argSendableArray ) + SharedFunction.prototype.apply ( thisArg, argSendableArray ) 17 ECMAScript Standard Built-in Objects: - Every built-in SendableFunction object, including constructors, that is not + Every built-in SharedFunction 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 SendableFunction + Unless otherwise specified, the name property of a built-in SharedFunction object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. includes: [propertyHelper.js] ---*/ -verifyProperty(SendableFunction.prototype.apply, "name", { +verifyProperty(SharedFunction.prototype.apply, "name", { value: "apply", writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/apply/not-a-constructor.js b/test/sendable/builtins/Function/prototype/apply/not-a-constructor.js index e6acd8e94c9..607690523d4 100644 --- a/test/sendable/builtins/Function/prototype/apply/not-a-constructor.js +++ b/test/sendable/builtins/Function/prototype/apply/not-a-constructor.js @@ -16,9 +16,9 @@ /*--- esid: sec-ecmascript-standard-built-in-objects description: > - SendableFunction.prototype.apply does not implement [[Construct]], is not new-able + SharedFunction.prototype.apply does not implement [[Construct]], is not new-able info: | - ECMAScript SendableFunction Objects + ECMAScript SharedFunction Objects Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method unless otherwise specified in @@ -34,15 +34,15 @@ features: [Reflect.construct, arrow-function] ---*/ assert.sameValue( - isConstructor(SendableFunction.prototype.apply), + isConstructor(SharedFunction.prototype.apply), false, - 'isConstructor(SendableFunction.prototype.apply) must return false' + 'isConstructor(SharedFunction.prototype.apply) must return false' ); assert.throws(TypeError, () => { - new SendableFunction.prototype.apply; + new SharedFunction.prototype.apply; }); assert.throws(TypeError, () => { - new SendableFunction.prototype.apply(); + new SharedFunction.prototype.apply(); }); diff --git a/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js b/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js index 9a548af8a8e..1b494f13c83 100644 --- a/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js +++ b/test/sendable/builtins/Function/prototype/apply/resizable-buffer.js @@ -16,7 +16,7 @@ /*--- esid: sec-function.prototype.apply description: > - SendableFunction.p.apply behaves correctly when the argument array is a + SharedFunction.p.apply behaves correctly when the argument array is a TypedSendableArray backed by resizable buffer includes: [compareArray.js, resizableArrayBufferUtils.js] features: [resizable-arraybuffer] diff --git a/test/sendable/builtins/Function/prototype/apply/this-not-callable-realm.js b/test/sendable/builtins/Function/prototype/apply/this-not-callable-realm.js index e55190836fb..95ffa10a640 100644 --- a/test/sendable/builtins/Function/prototype/apply/this-not-callable-realm.js +++ b/test/sendable/builtins/Function/prototype/apply/this-not-callable-realm.js @@ -19,7 +19,7 @@ description: > Throws a TypeError exception if this value is not callable (honoring the Realm of the current execution context) info: | - SendableFunction.prototype.apply ( thisArg, argSendableArray ) + SharedFunction.prototype.apply ( thisArg, argSendableArray ) 1. Let func be the this value. 2. If IsCallable(func) is false, throw a TypeError exception. @@ -27,7 +27,7 @@ features: [cross-realm] ---*/ var other = $262.createRealm().global; -var otherApply = other.SendableFunction.prototype.apply; +var otherApply = other.SharedFunction.prototype.apply; assert.throws(other.TypeError, function() { otherApply.call(undefined, {}, []); diff --git a/test/sendable/builtins/Function/prototype/apply/this-not-callable.js b/test/sendable/builtins/Function/prototype/apply/this-not-callable.js index 4444fde0477..6047ab83e56 100644 --- a/test/sendable/builtins/Function/prototype/apply/this-not-callable.js +++ b/test/sendable/builtins/Function/prototype/apply/this-not-callable.js @@ -18,24 +18,24 @@ esid: sec-function.prototype.apply description: > Throws a TypeError exception if this value is not callable info: | - SendableFunction.prototype.apply ( thisArg, argSendableArray ) + SharedFunction.prototype.apply ( thisArg, argSendableArray ) 1. Let func be the this value. 2. If IsCallable(func) is false, throw a TypeError exception. ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.apply.call(undefined, {}, []); + SharedFunction.prototype.apply.call(undefined, {}, []); }); assert.throws(TypeError, function() { - SendableFunction.prototype.apply.call(null, {}, []); + SharedFunction.prototype.apply.call(null, {}, []); }); assert.throws(TypeError, function() { - SendableFunction.prototype.apply.call({}, {}, []); + SharedFunction.prototype.apply.call({}, {}, []); }); assert.throws(TypeError, function() { - SendableFunction.prototype.apply.call(/re/, {}, []); + SharedFunction.prototype.apply.call(/re/, {}, []); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-0-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-0-1.js index c337b08b570..4810b427f07 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-0-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-0-1.js @@ -15,9 +15,9 @@ /*--- es5id: 15.3.4.5-0-1 -description: SendableFunction.prototype.bind must exist as a function +description: SharedFunction.prototype.bind must exist as a function ---*/ -var f = SendableFunction.prototype.bind; +var f = SharedFunction.prototype.bind; assert.sameValue(typeof(f), "function", 'typeof(f)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-10-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-10-1.js index 2c0ff6816f2..99e904ea88e 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-10-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-10-1.js @@ -16,12 +16,12 @@ /*--- es5id: 15.3.4.5-10-1 description: > - SendableFunction.prototype.bind - internal property [[Class]] of 'F' is - set as SendableFunction + SharedFunction.prototype.bind - internal property [[Class]] of 'F' is + set as SharedFunction ---*/ var foo = function() {}; var obj = foo.bind({}); -assert.sameValue(Object.prototype.toString.call(obj), "[object SendableFunction]", 'Object.prototype.toString.call(obj)'); +assert.sameValue(Object.prototype.toString.call(obj), "[object SharedFunction]", 'Object.prototype.toString.call(obj)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-11-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-11-1.js index 0a86be15fb1..55d9392905d 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-11-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-11-1.js @@ -16,13 +16,13 @@ /*--- es5id: 15.3.4.5-11-1 description: > - SendableFunction.prototype.bind - internal property [[Prototype]] of 'F' - is set as SendableFunction.prototype + SharedFunction.prototype.bind - internal property [[Prototype]] of 'F' + is set as SharedFunction.prototype ---*/ var foo = function() {}; -SendableFunction.prototype.property = 12; +SharedFunction.prototype.property = 12; var obj = foo.bind({}); assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-1.js index 7c0b11a00dd..fe3984bc501 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-1.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-16-1 -description: SendableFunction.prototype.bind, [[Extensible]] of the bound fn is true +description: SharedFunction.prototype.bind, [[Extensible]] of the bound fn is true ---*/ function foo() {} diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-2.js index 337c933c1e7..6c2dca2f2f7 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-16-2.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-16-2 description: > - SendableFunction.prototype.bind - The [[Extensible]] attribute of internal + SharedFunction.prototype.bind - The [[Extensible]] attribute of internal property in F set as true ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-1.js index 53845bd637e..8355d9ef0d2 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-1.js @@ -19,11 +19,11 @@ info: | is not callable. es5id: 15.3.4.5-2-1 description: > - SendableFunction.prototype.bind throws TypeError if the Target is not - callable (but an instance of SendableFunction) + SharedFunction.prototype.bind throws TypeError if the Target is not + callable (but an instance of SharedFunction) ---*/ -foo.prototype = SendableFunction.prototype; +foo.prototype = SharedFunction.prototype; // dummy function function foo() {} var f = new foo(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-10.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-10.js index 9f7a6a965ab..d09b431f5c6 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-10.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-10.js @@ -15,10 +15,10 @@ /*--- es5id: 15.3.4.5-2-10 -description: SendableFunction.prototype.bind throws TypeError if 'Target' is undefined +description: SharedFunction.prototype.bind throws TypeError if 'Target' is undefined ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.bind.call(undefined); + SharedFunction.prototype.bind.call(undefined); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-11.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-11.js index 174633518f2..d6db9649df9 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-11.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-11.js @@ -15,10 +15,10 @@ /*--- es5id: 15.3.4.5-2-11 -description: SendableFunction.prototype.bind throws TypeError if 'Target' is NULL +description: SharedFunction.prototype.bind throws TypeError if 'Target' is NULL ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.bind.call(null); + SharedFunction.prototype.bind.call(null); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-12.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-12.js index 1c1256b78f8..1939c419075 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-12.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-12.js @@ -15,10 +15,10 @@ /*--- es5id: 15.3.4.5-2-12 -description: SendableFunction.prototype.bind throws TypeError if 'Target' is a boolean +description: SharedFunction.prototype.bind throws TypeError if 'Target' is a boolean ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.bind.call(true); + SharedFunction.prototype.bind.call(true); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-13.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-13.js index c3bf0745bd2..8e1f0476fd6 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-13.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-13.js @@ -15,10 +15,10 @@ /*--- es5id: 15.3.4.5-2-13 -description: SendableFunction.prototype.bind throws TypeError if 'Target' is a number +description: SharedFunction.prototype.bind throws TypeError if 'Target' is a number ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.bind.call(5); + SharedFunction.prototype.bind.call(5); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-14.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-14.js index 3fa82bb9b77..1c340b72aaa 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-14.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-14.js @@ -15,10 +15,10 @@ /*--- es5id: 15.3.4.5-2-14 -description: SendableFunction.prototype.bind throws TypeError if 'Target' is a string +description: SharedFunction.prototype.bind throws TypeError if 'Target' is a string ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.bind.call("abc"); + SharedFunction.prototype.bind.call("abc"); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-15.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-15.js index 57175acd834..e7437327c45 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-15.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-15.js @@ -16,11 +16,11 @@ /*--- es5id: 15.3.4.5-2-15 description: > - SendableFunction.prototype.bind throws TypeError if 'Target' is Object + SharedFunction.prototype.bind throws TypeError if 'Target' is Object without Call internal method ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.bind.call({}); + SharedFunction.prototype.bind.call({}); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-16.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-16.js index 82845a643c2..77d539b26ba 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-16.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-16.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-2-16 -description: SendableFunction.prototype.bind - 'Target' is a function +description: SharedFunction.prototype.bind - 'Target' is a function ---*/ function testFunc() {} diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-2.js index ec4679cc677..a4821a7132e 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-2.js @@ -19,14 +19,14 @@ info: | is not callable. es5id: 15.3.4.5-2-2 description: > - SendableFunction.prototype.bind throws TypeError if the Target is not + SharedFunction.prototype.bind throws TypeError if the Target is not callable (bind attached to object) ---*/ // dummy function function foo() {} var f = new foo(); -f.bind = SendableFunction.prototype.bind; +f.bind = SharedFunction.prototype.bind; assert.throws(TypeError, function() { f.bind(); }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-3.js index a50f1cfb3f0..201c6e4565b 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-3.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-3.js @@ -18,7 +18,7 @@ info: | 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target is not callable. es5id: 15.3.4.5-2-3 -description: SendableFunction.prototype.bind allows Target to be a constructor (Number) +description: SharedFunction.prototype.bind allows Target to be a constructor (Number) ---*/ var bnc = Number.bind(null); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-4.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-4.js index 5ef8e1a9b51..e27ab2f909f 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-4.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-4.js @@ -18,7 +18,7 @@ info: | 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target is not callable. es5id: 15.3.4.5-2-4 -description: SendableFunction.prototype.bind allows Target to be a constructor (String) +description: SharedFunction.prototype.bind allows Target to be a constructor (String) ---*/ var bsc = String.bind(null); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-5.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-5.js index d2ae35f3ddc..e9f06c4fd93 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-5.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-5.js @@ -18,7 +18,7 @@ info: | 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target is not callable. es5id: 15.3.4.5-2-5 -description: SendableFunction.prototype.bind allows Target to be a constructor (Boolean) +description: SharedFunction.prototype.bind allows Target to be a constructor (Boolean) ---*/ var bbc = Boolean.bind(null); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-6.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-6.js index 3fe6357e5e9..40177199b28 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-6.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-6.js @@ -18,7 +18,7 @@ info: | 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target is not callable. es5id: 15.3.4.5-2-6 -description: SendableFunction.prototype.bind allows Target to be a constructor (Object) +description: SharedFunction.prototype.bind allows Target to be a constructor (Object) ---*/ var boc = Object.bind(null); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-7.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-7.js index 3451a5581af..c644e4d2468 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-7.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-7.js @@ -19,7 +19,7 @@ info: | is not callable. es5id: 15.3.4.5-2-7 description: > - SendableFunction.prototype.bind throws TypeError if the Target is not + SharedFunction.prototype.bind throws TypeError if the Target is not callable (JSON) ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-8.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-8.js index ff272f9686d..2e16472f02b 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-8.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-8.js @@ -18,7 +18,7 @@ info: | 15.3.4.5 step 2 specifies that a TypeError must be thrown if the Target is not callable. es5id: 15.3.4.5-2-8 -description: SendableFunction.prototype.bind allows Target to be a constructor (SendableArray) +description: SharedFunction.prototype.bind allows Target to be a constructor (SendableArray) ---*/ var bac = SendableArray.bind(null); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-9.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-9.js index 41203e13de7..cba4880fae2 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-9.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-2-9.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-2-9 -description: SendableFunction.prototype.bind allows Target to be a constructor (Date) +description: SharedFunction.prototype.bind allows Target to be a constructor (Date) ---*/ var bdc = Date.bind(null); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-2.js index c6942da530a..d21da15952f 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-2.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-20-2 description: > - SendableFunction.prototype.bind - [[Get]] attribute of 'caller' property + SharedFunction.prototype.bind - [[Get]] attribute of 'caller' property in 'F' is thrower ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-3.js index b2cbd6439a3..fa156975750 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-3.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-20-3.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-20-3 description: > - SendableFunction.prototype.bind - [[Set]] attribute of 'caller' property + SharedFunction.prototype.bind - [[Set]] attribute of 'caller' property in 'F' is thrower ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-2.js index 8415170c4b8..8c57fe3773c 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-2.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-21-2 description: > - SendableFunction.prototype.bind - [[Get]] attribute of 'arguments' + SharedFunction.prototype.bind - [[Get]] attribute of 'arguments' property in 'F' is thrower ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-3.js index bc4051cb4b1..9b7dff58453 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-3.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-21-3.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-21-3 description: > - SendableFunction.prototype.bind - [[Set]] attribute of 'arguments' + SharedFunction.prototype.bind - [[Set]] attribute of 'arguments' property in 'F' is thrower ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-3-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-3-1.js index ef002bb7857..17f3cd935e1 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-3-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-3-1.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-3-1 -description: SendableFunction.prototype.bind - each arg is defined in A in list order +description: SharedFunction.prototype.bind - each arg is defined in A in list order ---*/ var foo = function(x, y) { diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-1.js index 57c7e6b021f..8e6983bc8e4 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-1.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-6-1 -description: SendableFunction.prototype.bind - F can get own data property +description: SharedFunction.prototype.bind - F can get own data property ---*/ var foo = function() {}; diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-10.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-10.js index ef1694d18c8..33568396093 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-10.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-10.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-6-10 description: > - SendableFunction.prototype.bind - F can get own accessor property without + SharedFunction.prototype.bind - F can get own accessor property without a get function that overrides an inherited accessor property ---*/ @@ -24,7 +24,7 @@ var foo = function() {}; var obj = foo.bind({}); -Object.defineProperty(SendableFunction.prototype, "property", { +Object.defineProperty(SharedFunction.prototype, "property", { get: function() { return 3; }, diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-11.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-11.js index a7294c7f635..01a71211424 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-11.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-11.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-6-11 description: > - SendableFunction.prototype.bind - F can get inherited accessor property + SharedFunction.prototype.bind - F can get inherited accessor property without a get function ---*/ @@ -24,7 +24,7 @@ var foo = function() {}; var obj = foo.bind({}); -Object.defineProperty(SendableFunction.prototype, "property", { +Object.defineProperty(SharedFunction.prototype, "property", { set: function() {}, configurable: true }); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-12.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-12.js index 1092afb4326..e71101a6eaf 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-12.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-12.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-6-12 -description: SendableFunction.prototype.bind - F cannot get property which doesn't exist +description: SharedFunction.prototype.bind - F cannot get property which doesn't exist ---*/ var foo = function() {}; diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-2.js index ebf8b9df2c7..9f8e5909d02 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-2.js @@ -15,13 +15,13 @@ /*--- es5id: 15.3.4.5-6-2 -description: SendableFunction.prototype.bind - F can get inherited data property +description: SharedFunction.prototype.bind - F can get inherited data property ---*/ var foo = function() {}; var obj = foo.bind({}); -SendableFunction.prototype.property = 12; +SharedFunction.prototype.property = 12; assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-3.js index 8fa95e5b4a2..950c32df3a7 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-3.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-3.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-6-3 description: > - SendableFunction.prototype.bind - F can get own data property that + SharedFunction.prototype.bind - F can get own data property that overrides an inherited data property ---*/ @@ -24,7 +24,7 @@ var foo = function() {}; var obj = foo.bind({}); -SendableFunction.prototype.property = 3; +SharedFunction.prototype.property = 3; obj.property = 12; assert.sameValue(obj.property, 12, 'obj.property'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-4.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-4.js index eb0e23a0630..cfee90695bb 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-4.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-4.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-6-4 description: > - SendableFunction.prototype.bind - F can get own data property that + SharedFunction.prototype.bind - F can get own data property that overrides an inherited accessor property ---*/ @@ -24,7 +24,7 @@ var foo = function() {}; var obj = foo.bind({}); -Object.defineProperty(SendableFunction.prototype, "property", { +Object.defineProperty(SharedFunction.prototype, "property", { get: function() { return 3; }, diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-5.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-5.js index 6c100038072..f8f75aeb907 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-5.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-5.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-6-5 -description: SendableFunction.prototype.bind - F can get own accessor property +description: SharedFunction.prototype.bind - F can get own accessor property ---*/ var foo = function() {}; diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-6.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-6.js index 3e62dd4d345..cf80bf7838f 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-6.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-6.js @@ -15,14 +15,14 @@ /*--- es5id: 15.3.4.5-6-6 -description: SendableFunction.prototype.bind - F can get inherited accessor property +description: SharedFunction.prototype.bind - F can get inherited accessor property ---*/ var foo = function() {}; var obj = foo.bind({}); -Object.defineProperty(SendableFunction.prototype, "property", { +Object.defineProperty(SharedFunction.prototype, "property", { get: function() { return 12; }, diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-7.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-7.js index a6e30152ab5..695892a576d 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-7.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-7.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-6-7 description: > - SendableFunction.prototype.bind - F can get own accessor property that + SharedFunction.prototype.bind - F can get own accessor property that overrides an inherited data property ---*/ @@ -24,7 +24,7 @@ var foo = function() {}; var obj = foo.bind({}); -SendableFunction.prototype.property = 3; +SharedFunction.prototype.property = 3; Object.defineProperty(obj, "property", { get: function() { return 12; diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-8.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-8.js index 620a23eb59d..b3f599861ee 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-8.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-8.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-6-8 description: > - SendableFunction.prototype.bind - F can get own accessor property that + SharedFunction.prototype.bind - F can get own accessor property that overrides an inherited accessor property ---*/ @@ -24,7 +24,7 @@ var foo = function() {}; var obj = foo.bind({}); -Object.defineProperty(SendableFunction.prototype, "property", { +Object.defineProperty(SharedFunction.prototype, "property", { get: function() { return 3; }, diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-9.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-9.js index 8c074775673..2f0b30de182 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-9.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-6-9.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-6-9 description: > - SendableFunction.prototype.bind - F can get own accessor property without + SharedFunction.prototype.bind - F can get own accessor property without a get function ---*/ diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-1.js index 9d6e57832d6..a437354bdaa 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-1.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-8-1 -description: SendableFunction.prototype.bind, type of bound function must be 'function' +description: SharedFunction.prototype.bind, type of bound function must be 'function' ---*/ function foo() {} diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-2.js index 1fe10224438..a66e3cdcb4e 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-8-2.js @@ -16,8 +16,8 @@ /*--- es5id: 15.3.4.5-8-2 description: > - SendableFunction.prototype.bind, [[Class]] of bound function must be - 'SendableFunction' + SharedFunction.prototype.bind, [[Class]] of bound function must be + 'SharedFunction' ---*/ function foo() {} @@ -26,4 +26,4 @@ var o = {}; var bf = foo.bind(o); var s = Object.prototype.toString.call(bf); -assert.sameValue(s, '[object SendableFunction]', 's'); +assert.sameValue(s, '[object SharedFunction]', 's'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-1.js index 2c34e888212..588b1269746 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-1.js @@ -15,7 +15,7 @@ /*--- es5id: 15.3.4.5-9-1 -description: SendableFunction.prototype.bind, [[Prototype]] is SendableFunction.prototype +description: SharedFunction.prototype.bind, [[Prototype]] is SharedFunction.prototype ---*/ function foo() {} @@ -23,4 +23,4 @@ var o = {}; var bf = foo.bind(o); -assert(SendableFunction.prototype.isPrototypeOf(bf), 'SendableFunction.prototype.isPrototypeOf(bf) !== true'); +assert(SharedFunction.prototype.isPrototypeOf(bf), 'SharedFunction.prototype.isPrototypeOf(bf) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-2.js index 14448fad882..ae719708f88 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5-9-2.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5-9-2 description: > - SendableFunction.prototype.bind, [[Prototype]] is SendableFunction.prototype + SharedFunction.prototype.bind, [[Prototype]] is SharedFunction.prototype (using getPrototypeOf) ---*/ @@ -25,4 +25,4 @@ var o = {}; var bf = foo.bind(o); -assert.sameValue(Object.getPrototypeOf(bf), SendableFunction.prototype, 'Object.getPrototypeOf(bf)'); +assert.sameValue(Object.getPrototypeOf(bf), SharedFunction.prototype, 'Object.getPrototypeOf(bf)'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-1.js index ed3cc4cb5dc..be885040598 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-1.js @@ -25,6 +25,6 @@ var func = function(x, y, z) { return x + y + z; }; -var newFunc = SendableFunction.prototype.bind.call(func, {}, "a", "b", "c"); +var newFunc = SharedFunction.prototype.bind.call(func, {}, "a", "b", "c"); assert.sameValue(newFunc(), "abc", 'newFunc()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-10.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-10.js index 226d72d47bd..8451cc064ad 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-10.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-10.js @@ -28,6 +28,6 @@ var func = function(x) { return this === obj && typeof x === "undefined"; }; -var newFunc = SendableFunction.prototype.bind.call(func, obj); +var newFunc = SharedFunction.prototype.bind.call(func, obj); assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-11.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-11.js index aa34a0c13d6..c29345b3542 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-11.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-11.js @@ -28,6 +28,6 @@ var func = function(x) { return this === obj && x === 1 && arguments[0] === 1 && arguments.length === 1 && this.prop === "abc"; }; -var newFunc = SendableFunction.prototype.bind.call(func, obj); +var newFunc = SharedFunction.prototype.bind.call(func, obj); assert(newFunc(1), 'newFunc(1) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-12.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-12.js index 4aac5e2b5a8..6f9ab7d4c25 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-12.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-12.js @@ -29,6 +29,6 @@ var func = function(x) { arguments[0] === 1 && arguments.length === 2 && this.prop === "abc"; }; -var newFunc = SendableFunction.prototype.bind.call(func, obj); +var newFunc = SharedFunction.prototype.bind.call(func, obj); assert(newFunc(1, 2), 'newFunc(1, 2) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-13.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-13.js index 15a0a4ce045..1711268ba5a 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-13.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-13.js @@ -29,6 +29,6 @@ var func = function(x) { arguments[0] === 1 && arguments.length === 1 && this.prop === "abc"; }; -var newFunc = SendableFunction.prototype.bind.call(func, obj, 1); +var newFunc = SharedFunction.prototype.bind.call(func, obj, 1); assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-14.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-14.js index fba6b5eaf53..3c212a0abc8 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-14.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-14.js @@ -29,6 +29,6 @@ var func = function(x) { arguments[0] === 1 && arguments.length === 2 && this.prop === "abc"; }; -var newFunc = SendableFunction.prototype.bind.call(func, obj, 1); +var newFunc = SharedFunction.prototype.bind.call(func, obj, 1); assert(newFunc(2), 'newFunc(2) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-15.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-15.js index be0b5c512c0..073e8fabfa8 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-15.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-15.js @@ -29,6 +29,6 @@ var func = function(x) { arguments[0] === 1 && arguments.length === 2 && this.prop === "abc"; }; -var newFunc = SendableFunction.prototype.bind.call(func, obj, 1, 2); +var newFunc = SharedFunction.prototype.bind.call(func, obj, 1, 2); assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-2.js index 1a0428bfb4e..2957be148b6 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-2.js @@ -29,6 +29,6 @@ var func = function() { return this; }; -var newFunc = SendableFunction.prototype.bind.call(func, obj); +var newFunc = SharedFunction.prototype.bind.call(func, obj); assert.sameValue(newFunc(), obj, 'newFunc()'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-3.js index 9f2bc452d65..81a0d77d35b 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-3.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-3.js @@ -25,6 +25,6 @@ var func = function(x, y, z) { return z; }; -var newFunc = SendableFunction.prototype.bind.call(func, {}, "a", "b"); +var newFunc = SharedFunction.prototype.bind.call(func, {}, "a", "b"); assert.sameValue(newFunc("c"), "c", 'newFunc("c")'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-4.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-4.js index 5a7b27ee3d1..570a5b0aede 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-4.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-4.js @@ -25,6 +25,6 @@ var func = function() { return arguments.length === 0; }; -var newFunc = SendableFunction.prototype.bind.call(func); +var newFunc = SharedFunction.prototype.bind.call(func); assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-5.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-5.js index cc0efd44a3d..a3b60cdcd16 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-5.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-5.js @@ -25,6 +25,6 @@ var func = function() { return arguments[0] === 1; }; -var newFunc = SendableFunction.prototype.bind.call(func); +var newFunc = SharedFunction.prototype.bind.call(func); assert(newFunc(1), 'newFunc(1) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-6.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-6.js index f5c80b195e6..e0456e2af0d 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-6.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-6.js @@ -28,6 +28,6 @@ var func = function() { return this === obj && arguments.length === 0; }; -var newFunc = SendableFunction.prototype.bind.call(func, obj); +var newFunc = SharedFunction.prototype.bind.call(func, obj); assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-7.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-7.js index 52bcc702a10..4d94bc1e067 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-7.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-7.js @@ -28,6 +28,6 @@ var func = function() { return this === obj && arguments[0] === 1; }; -var newFunc = SendableFunction.prototype.bind.call(func, obj, 1); +var newFunc = SharedFunction.prototype.bind.call(func, obj, 1); assert(newFunc(), 'newFunc() !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-8.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-8.js index 8d374cb5b97..9d1e87f37b3 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-8.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-8.js @@ -28,6 +28,6 @@ var func = function() { return this === obj && arguments[0] === 1; }; -var newFunc = SendableFunction.prototype.bind.call(func, obj); +var newFunc = SharedFunction.prototype.bind.call(func, obj); assert(newFunc(1), 'newFunc(1) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-9.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-9.js index 0b9212e9f87..32489b77218 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-9.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.1-4-9.js @@ -28,6 +28,6 @@ var func = function() { return this === obj && arguments[0] === 1 && arguments[1] === 2; }; -var newFunc = SendableFunction.prototype.bind.call(func, obj, 1); +var newFunc = SharedFunction.prototype.bind.call(func, obj, 1); assert(newFunc(2), 'newFunc(2) !== true'); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-1.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-1.js index db3f3a5ec86..6e220324806 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-1.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-1.js @@ -28,7 +28,7 @@ var func = function(x, y, z) { return objResult; }; -var NewFunc = SendableFunction.prototype.bind.call(func, {}, "a", "b", "c"); +var NewFunc = SharedFunction.prototype.bind.call(func, {}, "a", "b", "c"); var newInstance = new NewFunc(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-10.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-10.js index dae1190307c..2292ec24c4d 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-10.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-10.js @@ -24,7 +24,7 @@ var func = function(x) { return new Boolean(arguments.length === 1 && x === 1 && arguments[0] === 1); }; -var NewFunc = SendableFunction.prototype.bind.call(func, {}); +var NewFunc = SharedFunction.prototype.bind.call(func, {}); var newInstance = new NewFunc(1); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-11.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-11.js index 8ddc2f094b9..4249fcbb94e 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-11.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-11.js @@ -24,7 +24,7 @@ var func = function(x) { return new Boolean(arguments.length === 2 && x === 1 && arguments[1] === 2 && arguments[0] === 1); }; -var NewFunc = SendableFunction.prototype.bind.call(func, {}); +var NewFunc = SharedFunction.prototype.bind.call(func, {}); var newInstance = new NewFunc(1, 2); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-12.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-12.js index b42c1d15fc2..6519ca145b5 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-12.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-12.js @@ -24,7 +24,7 @@ var func = function(x) { return new Boolean(arguments.length === 1 && x === 1 && arguments[0] === 1); }; -var NewFunc = SendableFunction.prototype.bind.call(func, {}, 1); +var NewFunc = SharedFunction.prototype.bind.call(func, {}, 1); var newInstance = new NewFunc(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-13.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-13.js index 233ba2654b5..d361ad4f3e9 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-13.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-13.js @@ -24,7 +24,7 @@ var func = function(x) { return new Boolean(arguments.length === 2 && x === 1 && arguments[1] === 2 && arguments[0] === 1); }; -var NewFunc = SendableFunction.prototype.bind.call(func, {}, 1); +var NewFunc = SharedFunction.prototype.bind.call(func, {}, 1); var newInstance = new NewFunc(2); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-14.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-14.js index 585f78423d5..b25066199b9 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-14.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-14.js @@ -24,7 +24,7 @@ var func = function(x) { return new Boolean(arguments.length === 2 && x === 1 && arguments[1] === 2 && arguments[0] === 1); }; -var NewFunc = SendableFunction.prototype.bind.call(func, {}, 1, 2); +var NewFunc = SharedFunction.prototype.bind.call(func, {}, 1, 2); var newInstance = new NewFunc(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-2.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-2.js index ffe4862dbae..7357d48f010 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-2.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-2.js @@ -28,7 +28,7 @@ var func = function(x, y, z) { return objResult; }; -var NewFunc = SendableFunction.prototype.bind.call(func, {}); +var NewFunc = SharedFunction.prototype.bind.call(func, {}); var newInstance = new NewFunc("a", "b", "c"); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-3.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-3.js index 4daccdf2821..92593009f66 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-3.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-3.js @@ -25,7 +25,7 @@ var func = function() { return new Boolean(arguments.length === 0); }; -var NewFunc = SendableFunction.prototype.bind.call(func); +var NewFunc = SharedFunction.prototype.bind.call(func); var newInstance = new NewFunc(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-4.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-4.js index 94b2693722a..0927bc8ea98 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-4.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-4.js @@ -25,7 +25,7 @@ var func = function() { return new Boolean(arguments[0] === 1 && arguments.length === 1); }; -var NewFunc = SendableFunction.prototype.bind.call(func); +var NewFunc = SharedFunction.prototype.bind.call(func); var newInstance = new NewFunc(1); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-5.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-5.js index 35beaf51107..af8952a021a 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-5.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-5.js @@ -30,7 +30,7 @@ var func = function() { this.verifyThis === "verifyThis"); }; -var NewFunc = SendableFunction.prototype.bind.call(func, obj); +var NewFunc = SharedFunction.prototype.bind.call(func, obj); var newInstance = new NewFunc(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-6.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-6.js index d9c82e4dccc..7ee51c4d59b 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-6.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-6.js @@ -24,7 +24,7 @@ var func = function() { return new Boolean(arguments.length === 1 && arguments[0] === 1); }; -var NewFunc = SendableFunction.prototype.bind.call(func, {}, 1); +var NewFunc = SharedFunction.prototype.bind.call(func, {}, 1); var newInstance = new NewFunc(); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-7.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-7.js index 1bbabd83c91..a46217946ed 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-7.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-7.js @@ -24,7 +24,7 @@ var func = function() { return new Boolean(arguments.length === 1 && arguments[0] === 1); }; -var NewFunc = SendableFunction.prototype.bind.call(func, {}); +var NewFunc = SharedFunction.prototype.bind.call(func, {}); var newInstance = new NewFunc(1); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-8.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-8.js index 0efcee1c626..db67c504860 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-8.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-8.js @@ -24,7 +24,7 @@ var func = function() { return new Boolean(arguments.length === 2 && arguments[0] === 1 && arguments[1] === 2); }; -var NewFunc = SendableFunction.prototype.bind.call(func, {}, 1); +var NewFunc = SharedFunction.prototype.bind.call(func, {}, 1); var newInstance = new NewFunc(2); diff --git a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-9.js b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-9.js index f6e7123affb..0f45d326c4c 100644 --- a/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-9.js +++ b/test/sendable/builtins/Function/prototype/bind/15.3.4.5.2-4-9.js @@ -24,7 +24,7 @@ var func = function(x) { return new Boolean(arguments.length === 0 && typeof x === "undefined"); }; -var NewFunc = SendableFunction.prototype.bind.call(func, {}); +var NewFunc = SharedFunction.prototype.bind.call(func, {}); var newInstance = new NewFunc(); diff --git a/test/sendable/builtins/Function/prototype/bind/BoundFunction_restricted-properties.js b/test/sendable/builtins/Function/prototype/bind/BoundFunction_restricted-properties.js index c3dadc7282e..261cd45725a 100644 --- a/test/sendable/builtins/Function/prototype/bind/BoundFunction_restricted-properties.js +++ b/test/sendable/builtins/Function/prototype/bind/BoundFunction_restricted-properties.js @@ -15,7 +15,7 @@ /*--- description: > - SendableFunctions created using SendableFunction.prototype.bind() do not have own + SendableFunctions created using SharedFunction.prototype.bind() do not have own properties "caller" or "arguments", but inherit them from %SendableFunctionPrototype%. es6id: 16.1 @@ -24,8 +24,8 @@ es6id: 16.1 function target() {} var bound = target.bind(null); -assert.sameValue(bound.hasOwnProperty('caller'), false, 'SendableFunctions created using SendableFunction.prototype.bind() do not have own property "caller"'); -assert.sameValue(bound.hasOwnProperty('arguments'), false, 'SendableFunctions created using SendableFunction.prototype.bind() do not have own property "arguments"'); +assert.sameValue(bound.hasOwnProperty('caller'), false, 'SendableFunctions created using SharedFunction.prototype.bind() do not have own property "caller"'); +assert.sameValue(bound.hasOwnProperty('arguments'), false, 'SendableFunctions created using SharedFunction.prototype.bind() do not have own property "arguments"'); assert.throws(TypeError, function() { return bound.caller; diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A13.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A13.js index c61ea80082c..b8932b6182e 100644 --- a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A13.js +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A13.js @@ -19,5 +19,5 @@ description: If IsCallable(func) is false, then throw a TypeError exception. ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.bind.call(undefined, {}); -}, 'SendableFunction.prototype.bind.call(undefined, {}) throws a TypeError exception'); + SharedFunction.prototype.bind.call(undefined, {}); +}, 'SharedFunction.prototype.bind.call(undefined, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A14.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A14.js index da9dc855604..fc1546e2999 100644 --- a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A14.js +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A14.js @@ -19,5 +19,5 @@ description: If IsCallable(func) is false, then throw a TypeError exception. ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.bind.call(null, {}); -}, 'SendableFunction.prototype.bind.call(null, {}) throws a TypeError exception'); + SharedFunction.prototype.bind.call(null, {}); +}, 'SharedFunction.prototype.bind.call(null, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A15.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A15.js index 550b2c3810f..002ac82780c 100644 --- a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A15.js +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A15.js @@ -19,5 +19,5 @@ description: If IsCallable(func) is false, then throw a TypeError exception. ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.bind.call({}, {}); -}, 'SendableFunction.prototype.bind.call({}, {}) throws a TypeError exception'); + SharedFunction.prototype.bind.call({}, {}); +}, 'SharedFunction.prototype.bind.call({}, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A16.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A16.js index c6ba142580d..d174d75b01d 100644 --- a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A16.js +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A16.js @@ -24,10 +24,10 @@ description: > var re = (/x/); if (typeof re === 'function') { - SendableFunction.prototype.bind.call(re, undefined); + SharedFunction.prototype.bind.call(re, undefined); } else { try { - SendableFunction.prototype.bind.call(re, undefined); + SharedFunction.prototype.bind.call(re, undefined); throw new Test262Error('#1: If IsCallable(func) is false, ' + 'then (bind should) throw a TypeError exception'); } catch (e) { diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A3.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A3.js index 691b17d1a24..e11df838e92 100644 --- a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A3.js +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A3.js @@ -15,9 +15,9 @@ /*--- es5id: 15.3.4.5_A3 -description: SendableFunction.prototype.bind must exist +description: SharedFunction.prototype.bind must exist ---*/ assert( - 'bind' in SendableFunction.prototype, - 'The result of evaluating (\'bind\' in SendableFunction.prototype) is expected to be true' + 'bind' in SharedFunction.prototype, + 'The result of evaluating (\'bind\' in SharedFunction.prototype) is expected to be true' ); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A4.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A4.js index caf999f0594..5de6ee818b9 100644 --- a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A4.js +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A4.js @@ -16,7 +16,7 @@ /*--- es5id: 15.3.4.5_A4 description: > - SendableFunction.prototype.bind call the original's internal [[Call]] + SharedFunction.prototype.bind call the original's internal [[Call]] method rather than its .apply method. ---*/ @@ -24,6 +24,6 @@ function foo() {} var b = foo.bind(33, 44); foo.apply = function() { - throw new Test262Error("SendableFunction.prototype.bind called original's .apply method"); + throw new Test262Error("SharedFunction.prototype.bind called original's .apply method"); }; b(55, 66); diff --git a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A5.js b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A5.js index 72f7f3478e0..ec3ceed3450 100644 --- a/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A5.js +++ b/test/sendable/builtins/Function/prototype/bind/S15.3.4.5_A5.js @@ -16,12 +16,12 @@ /*--- es5id: 15.3.4.5_A5 description: > - SendableFunction.prototype.bind must curry [[Construct]] as well as + SharedFunction.prototype.bind must curry [[Construct]] as well as [[Call]]. ---*/ function construct(f, args) { - var bound = SendableFunction.prototype.bind.apply(f, [null].concat(args)); + var bound = SharedFunction.prototype.bind.apply(f, [null].concat(args)); return new bound(); } var d = construct(Date, [1957, 4, 27]); diff --git a/test/sendable/builtins/Function/prototype/bind/get-fn-realm-recursive.js b/test/sendable/builtins/Function/prototype/bind/get-fn-realm-recursive.js index c1dd7d9da9c..b7119784826 100644 --- a/test/sendable/builtins/Function/prototype/bind/get-fn-realm-recursive.js +++ b/test/sendable/builtins/Function/prototype/bind/get-fn-realm-recursive.js @@ -55,11 +55,11 @@ var realm2 = $262.createRealm().global; var realm3 = $262.createRealm().global; var realm4 = $262.createRealm().global; -var newTarget = new realm1.SendableFunction(); +var newTarget = new realm1.SharedFunction(); newTarget.prototype = 1; -var boundNewTarget = realm2.SendableFunction.prototype.bind.call(newTarget); -var boundBoundNewTarget = realm3.SendableFunction.prototype.bind.call(boundNewTarget); +var boundNewTarget = realm2.SharedFunction.prototype.bind.call(newTarget); +var boundBoundNewTarget = realm3.SharedFunction.prototype.bind.call(boundNewTarget); var object = Reflect.construct(realm4.Object, [], boundBoundNewTarget); assert(object instanceof realm1.Object); diff --git a/test/sendable/builtins/Function/prototype/bind/get-fn-realm.js b/test/sendable/builtins/Function/prototype/bind/get-fn-realm.js index a472c361708..4d120aa71fc 100644 --- a/test/sendable/builtins/Function/prototype/bind/get-fn-realm.js +++ b/test/sendable/builtins/Function/prototype/bind/get-fn-realm.js @@ -58,10 +58,10 @@ var realm1 = $262.createRealm().global; var realm2 = $262.createRealm().global; var realm3 = $262.createRealm().global; -var newTarget = new realm1.SendableFunction(); +var newTarget = new realm1.SharedFunction(); newTarget.prototype = "str"; -var boundNewTarget = realm2.SendableFunction.prototype.bind.call(newTarget); +var boundNewTarget = realm2.SharedFunction.prototype.bind.call(newTarget); var date = Reflect.construct(realm3.Date, [], boundNewTarget); assert(date instanceof realm1.Date); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-default-value.js b/test/sendable/builtins/Function/prototype/bind/instance-length-default-value.js index 58327375f2d..7bd457e397a 100644 --- a/test/sendable/builtins/Function/prototype/bind/instance-length-default-value.js +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-default-value.js @@ -19,7 +19,7 @@ description: > "length" value of a bound function defaults to 0. Non-own and non-number "length" values of target function are ignored. info: | - SendableFunction.prototype.bind ( thisArg, ...args ) + SharedFunction.prototype.bind ( thisArg, ...args ) [...] 5. Let targetHasLength be ? HasOwnProperty(Target, "length"). @@ -60,5 +60,5 @@ function bar() {} Object.setPrototypeOf(bar, {length: 42}); assert(delete bar.length); -var bound = SendableFunction.prototype.bind.call(bar, null, 1); +var bound = SharedFunction.prototype.bind.call(bar, null, 1); assert.sameValue(bound.length, 0, "not own"); diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-exceeds-int32.js b/test/sendable/builtins/Function/prototype/bind/instance-length-exceeds-int32.js index 766306a2350..52ac4ee7a63 100644 --- a/test/sendable/builtins/Function/prototype/bind/instance-length-exceeds-int32.js +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-exceeds-int32.js @@ -18,7 +18,7 @@ esid: sec-function.prototype.bind description: > The target function length can exceed 2**31-1. info: | - 19.2.3.2 SendableFunction.prototype.bind ( thisArg, ...args ) + 19.2.3.2 SharedFunction.prototype.bind ( thisArg, ...args ) ... 6. If targetHasLength is true, then diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-prop-desc.js b/test/sendable/builtins/Function/prototype/bind/instance-length-prop-desc.js index 12275a456ca..7333370fd8e 100644 --- a/test/sendable/builtins/Function/prototype/bind/instance-length-prop-desc.js +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-prop-desc.js @@ -18,7 +18,7 @@ esid: sec-function.prototype.bind description: > "length" property of a bound function has correct descriptor. info: | - SendableFunction.prototype.bind ( thisArg, ...args ) + SharedFunction.prototype.bind ( thisArg, ...args ) [...] 8. Perform ! SetSendableFunctionLength(F, L). diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-remaining-args.js b/test/sendable/builtins/Function/prototype/bind/instance-length-remaining-args.js index 2aff77dfaae..4ac0e4f537f 100644 --- a/test/sendable/builtins/Function/prototype/bind/instance-length-remaining-args.js +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-remaining-args.js @@ -19,7 +19,7 @@ description: > "length" value of a bound function is set to remaining number of arguments expected by target function. Extra arguments are ignored. info: | - SendableFunction.prototype.bind ( thisArg, ...args ) + SharedFunction.prototype.bind ( thisArg, ...args ) [...] 5. Let targetHasLength be ? HasOwnProperty(Target, "length"). diff --git a/test/sendable/builtins/Function/prototype/bind/instance-length-tointeger.js b/test/sendable/builtins/Function/prototype/bind/instance-length-tointeger.js index b1af39dca99..1db7c4ecd10 100644 --- a/test/sendable/builtins/Function/prototype/bind/instance-length-tointeger.js +++ b/test/sendable/builtins/Function/prototype/bind/instance-length-tointeger.js @@ -19,7 +19,7 @@ description: > "length" value of a bound function is non-negative integer. ToInteger is performed on "length" value of target function. info: | - SendableFunction.prototype.bind ( thisArg, ...args ) + SharedFunction.prototype.bind ( thisArg, ...args ) [...] 5. Let targetHasLength be ? HasOwnProperty(Target, "length"). diff --git a/test/sendable/builtins/Function/prototype/bind/length.js b/test/sendable/builtins/Function/prototype/bind/length.js index e41d580eac2..e597486b879 100644 --- a/test/sendable/builtins/Function/prototype/bind/length.js +++ b/test/sendable/builtins/Function/prototype/bind/length.js @@ -16,9 +16,9 @@ /*--- esid: sec-function.prototype.bind description: > - SendableFunction.prototype.bind.length is 1. + SharedFunction.prototype.bind.length is 1. info: | - SendableFunction.prototype.bind ( thisArg, ...args ) + SharedFunction.prototype.bind ( thisArg, ...args ) ECMAScript Standard Built-in Objects @@ -33,7 +33,7 @@ info: | includes: [propertyHelper.js] ---*/ -verifyProperty(SendableFunction.prototype.bind, "length", { +verifyProperty(SharedFunction.prototype.bind, "length", { value: 1, writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/bind/name.js b/test/sendable/builtins/Function/prototype/bind/name.js index 12d8cfdeae5..8ba253adb00 100644 --- a/test/sendable/builtins/Function/prototype/bind/name.js +++ b/test/sendable/builtins/Function/prototype/bind/name.js @@ -16,22 +16,22 @@ /*--- es6id: 19.2.3.2 description: > - SendableFunction.prototype.bind.name is "bind". + SharedFunction.prototype.bind.name is "bind". info: | - SendableFunction.prototype.bind ( thisArg , ...args) + SharedFunction.prototype.bind ( thisArg , ...args) 17 ECMAScript Standard Built-in Objects: - Every built-in SendableFunction object, including constructors, that is not + Every built-in SharedFunction 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 SendableFunction + Unless otherwise specified, the name property of a built-in SharedFunction object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. includes: [propertyHelper.js] ---*/ -verifyProperty(SendableFunction.prototype.bind, "name", { +verifyProperty(SharedFunction.prototype.bind, "name", { value: "bind", writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/bind/not-a-constructor.js b/test/sendable/builtins/Function/prototype/bind/not-a-constructor.js index 1b63d874d00..b434842c9a2 100644 --- a/test/sendable/builtins/Function/prototype/bind/not-a-constructor.js +++ b/test/sendable/builtins/Function/prototype/bind/not-a-constructor.js @@ -16,9 +16,9 @@ /*--- esid: sec-ecmascript-standard-built-in-objects description: > - SendableFunction.prototype.bind does not implement [[Construct]], is not new-able + SharedFunction.prototype.bind does not implement [[Construct]], is not new-able info: | - ECMAScript SendableFunction Objects + ECMAScript SharedFunction Objects Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method unless otherwise specified in @@ -34,12 +34,12 @@ features: [Reflect.construct, arrow-function] ---*/ assert.sameValue( - isConstructor(SendableFunction.prototype.bind), + isConstructor(SharedFunction.prototype.bind), false, - 'isConstructor(SendableFunction.prototype.bind) must return false' + 'isConstructor(SharedFunction.prototype.bind) must return false' ); assert.throws(TypeError, () => { - new SendableFunction.prototype.bind(); + new SharedFunction.prototype.bind(); }); diff --git a/test/sendable/builtins/Function/prototype/bind/proto-from-ctor-realm.js b/test/sendable/builtins/Function/prototype/bind/proto-from-ctor-realm.js index ddbfd2c9002..d70ee44df96 100644 --- a/test/sendable/builtins/Function/prototype/bind/proto-from-ctor-realm.js +++ b/test/sendable/builtins/Function/prototype/bind/proto-from-ctor-realm.js @@ -32,7 +32,7 @@ features: [cross-realm, Reflect] ---*/ var other = $262.createRealm().global; -var C = new other.SendableFunction(); +var C = new other.SharedFunction(); C.prototype = null; var D = function() {}.bind(); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A10.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A10.js index 20b25aa5e74..26e60817c40 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A10.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A10.js @@ -14,28 +14,28 @@ */ /*--- -info: The SendableFunction.prototype.call.length property has the attribute ReadOnly +info: The SharedFunction.prototype.call.length property has the attribute ReadOnly es5id: 15.3.4.4_A10 description: > - Checking if varying the SendableFunction.prototype.call.length property + Checking if varying the SharedFunction.prototype.call.length property fails includes: [propertyHelper.js] ---*/ assert( - SendableFunction.prototype.call.hasOwnProperty('length'), - 'SendableFunction.prototype.call.hasOwnProperty(\'length\') must return true' + SharedFunction.prototype.call.hasOwnProperty('length'), + 'SharedFunction.prototype.call.hasOwnProperty(\'length\') must return true' ); -var obj = SendableFunction.prototype.call.length; +var obj = SharedFunction.prototype.call.length; -verifyNotWritable(SendableFunction.prototype.call, "length", null, function() { +verifyNotWritable(SharedFunction.prototype.call, "length", null, function() { return "shifted"; }); assert.sameValue( - SendableFunction.prototype.call.length, + SharedFunction.prototype.call.length, obj, - 'The value of SendableFunction.prototype.call.length is expected to equal the value of obj' + 'The value of SharedFunction.prototype.call.length is expected to equal the value of obj' ); // TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A11.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A11.js index 4a421e5bd9c..2abce75a23c 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A11.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A11.js @@ -14,24 +14,24 @@ */ /*--- -info: The SendableFunction.prototype.call.length property has the attribute DontEnum +info: The SharedFunction.prototype.call.length property has the attribute DontEnum es5id: 15.3.4.4_A11 description: > - Checking if enumerating the SendableFunction.prototype.call.length + Checking if enumerating the SharedFunction.prototype.call.length property fails ---*/ assert( - SendableFunction.prototype.call.hasOwnProperty('length'), - 'SendableFunction.prototype.call.hasOwnProperty(\'length\') must return true' + SharedFunction.prototype.call.hasOwnProperty('length'), + 'SharedFunction.prototype.call.hasOwnProperty(\'length\') must return true' ); assert( - !SendableFunction.prototype.call.propertyIsEnumerable('length'), - 'The value of !SendableFunction.prototype.call.propertyIsEnumerable(\'length\') is expected to be true' + !SharedFunction.prototype.call.propertyIsEnumerable('length'), + 'The value of !SharedFunction.prototype.call.propertyIsEnumerable(\'length\') is expected to be true' ); // CHECK#2 -for (var p in SendableFunction.prototype.call) { +for (var p in SharedFunction.prototype.call) { assert.notSameValue(p, "length", 'The value of p is not "length"'); } diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A12.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A12.js index 8d8f232f253..bd257255b5e 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A12.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A12.js @@ -14,14 +14,14 @@ */ /*--- -info: SendableFunction.prototype.call has not prototype property +info: SharedFunction.prototype.call has not prototype property es5id: 15.3.4.4_A12 description: > Checking if obtaining the prototype property of - SendableFunction.prototype.call fails + SharedFunction.prototype.call fails ---*/ assert.sameValue( - SendableFunction.prototype.call.prototype, + SharedFunction.prototype.call.prototype, undefined, - 'The value of SendableFunction.prototype.call.prototype is expected to equal undefined' + 'The value of SharedFunction.prototype.call.prototype is expected to equal undefined' ); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A13.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A13.js index a89b5d8c0a1..038a8c508c3 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A13.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A13.js @@ -19,5 +19,5 @@ description: If IsCallable(func) is false, then throw a TypeError exception. ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.call.call(undefined, {}); -}, 'SendableFunction.prototype.call.call(undefined, {}) throws a TypeError exception'); + SharedFunction.prototype.call.call(undefined, {}); +}, 'SharedFunction.prototype.call.call(undefined, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A14.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A14.js index fea28e2a587..d9f2c92a592 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A14.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A14.js @@ -19,5 +19,5 @@ description: If IsCallable(func) is false, then throw a TypeError exception. ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.call.call(null, {}); -}, 'SendableFunction.prototype.call.call(null, {}) throws a TypeError exception'); + SharedFunction.prototype.call.call(null, {}); +}, 'SharedFunction.prototype.call.call(null, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A15.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A15.js index 05e6bcc43e8..ca93ffbcb3c 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A15.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A15.js @@ -19,5 +19,5 @@ description: If IsCallable(func) is false, then throw a TypeError exception. ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.call.call({}, {}); -}, 'SendableFunction.prototype.call.call({}, {}) throws a TypeError exception'); + SharedFunction.prototype.call.call({}, {}); +}, 'SharedFunction.prototype.call.call({}, {}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A16.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A16.js index 1d3ad67eb74..b6bf40c3aaf 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A16.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A16.js @@ -24,10 +24,10 @@ description: > var re = (/x/); if (typeof re === 'function') { - SendableFunction.prototype.call.call(re, undefined, 'x'); + SharedFunction.prototype.call.call(re, undefined, 'x'); } else { try { - SendableFunction.prototype.bind.call(re, undefined); + SharedFunction.prototype.bind.call(re, undefined); throw new Test262Error('#1: If IsCallable(func) is false, ' + 'then (bind should) throw a TypeError exception'); } catch (e) { diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T1.js index b299d3c3931..a3601cd52ff 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T1.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T1.js @@ -21,10 +21,10 @@ info: | es5id: 15.3.4.4_A1_T1 description: > Call "call" method of the object that does not have a [[Call]] - property. Prototype of the object is SendableFunction() + property. Prototype of the object is SharedFunction() ---*/ -var proto = SendableFunction(); +var proto = SharedFunction(); function FACTORY() {} diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T2.js index e8f8ee2c6bc..6605b16ef21 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T2.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A1_T2.js @@ -21,12 +21,12 @@ info: | es5id: 15.3.4.4_A1_T2 description: > Calling "call" method of the object that does not have a [[Call]] - property. Prototype of the object is SendableFunction.prototype + property. Prototype of the object is SharedFunction.prototype ---*/ function FACTORY() {} -FACTORY.prototype = SendableFunction.prototype; +FACTORY.prototype = SharedFunction.prototype; var obj = new FACTORY; diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T1.js index 68362aee9cc..b9a2145921a 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T1.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T1.js @@ -16,18 +16,18 @@ /*--- info: The length property of the call method is 1 es5id: 15.3.4.4_A2_T1 -description: Checking SendableFunction.prototype.call.length +description: Checking SharedFunction.prototype.call.length ---*/ assert.sameValue( - typeof SendableFunction.prototype.call, + typeof SharedFunction.prototype.call, "function", - 'The value of `typeof SendableFunction.prototype.call` is expected to be "function"' + 'The value of `typeof SharedFunction.prototype.call` is expected to be "function"' ); assert.notSameValue( - typeof SendableFunction.prototype.call.length, + typeof SharedFunction.prototype.call.length, "undefined", - 'The value of typeof SendableFunction.prototype.call.length is not "undefined"' + 'The value of typeof SharedFunction.prototype.call.length is not "undefined"' ); -assert.sameValue(SendableFunction.prototype.call.length, 1, 'The value of SendableFunction.prototype.call.length is expected to be 1'); +assert.sameValue(SharedFunction.prototype.call.length, 1, 'The value of SharedFunction.prototype.call.length is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T2.js index d0c1c60ee33..c5d524ca69d 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T2.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A2_T2.js @@ -16,10 +16,10 @@ /*--- info: The length property of the call method is 1 es5id: 15.3.4.4_A2_T2 -description: Checking f.call.length, where f is new SendableFunction +description: Checking f.call.length, where f is new SharedFunction ---*/ -var f = new SendableFunction; +var f = new SharedFunction; assert.sameValue(typeof f.call, "function", 'The value of `typeof f.call` is expected to be "function"'); assert.notSameValue(typeof f.call.length, "undefined", 'The value of typeof f.call.length is not "undefined"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T1.js index 0a5cd917e26..f4f8c26645f 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T1.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T1.js @@ -21,6 +21,6 @@ es5id: 15.3.4.4_A3_T1 description: Not any arguments at call function ---*/ -SendableFunction("this.field=\"strawberry\"").call(); +SharedFunction("this.field=\"strawberry\"").call(); assert.sameValue(this["field"], "strawberry", 'The value of this["field"] is expected to be "strawberry"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T2.js index ff6d3f91680..1f6f8a421e8 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T2.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T2.js @@ -21,6 +21,6 @@ es5id: 15.3.4.4_A3_T2 description: Argument at call function is null ---*/ -SendableFunction("this.field=\"green\"").call(null); +SharedFunction("this.field=\"green\"").call(null); assert.sameValue(this["field"], "green", 'The value of this["field"] is expected to be "green"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T3.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T3.js index 3deb6e0cef5..6abd7b0c073 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T3.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T3.js @@ -21,6 +21,6 @@ es5id: 15.3.4.4_A3_T3 description: Argument at call function is void 0 ---*/ -SendableFunction("this.field=\"battle\"").call(void 0); +SharedFunction("this.field=\"battle\"").call(void 0); assert.sameValue(this["field"], "battle", 'The value of this["field"] is expected to be "battle"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T4.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T4.js index b2c3b3e9cf6..52c181bbb2e 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T4.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T4.js @@ -21,6 +21,6 @@ es5id: 15.3.4.4_A3_T4 description: Argument at call function is undefined ---*/ -SendableFunction("this.field=\"oil\"").call(undefined); +SharedFunction("this.field=\"oil\"").call(undefined); assert.sameValue(this["field"], "oil", 'The value of this["field"] is expected to be "oil"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T5.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T5.js index dfcaad534fa..2ab87bbbedc 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T5.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T5.js @@ -24,7 +24,7 @@ description: > ---*/ function FACTORY() { - SendableFunction("this.feat=\"in da haus\"").call(); + SharedFunction("this.feat=\"in da haus\"").call(); } var obj = new FACTORY; diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T7.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T7.js index 1540b6be204..dea392f8d72 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T7.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T7.js @@ -24,7 +24,7 @@ description: > ---*/ (function FACTORY() { - SendableFunction("this.feat=\"in da haus\"").call(void 0); + SharedFunction("this.feat=\"in da haus\"").call(void 0); })(); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T9.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T9.js index 85943ef6f22..6cf7e8f488c 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T9.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A3_T9.js @@ -21,7 +21,7 @@ es5id: 15.3.4.4_A3_T9 description: Checking by using eval, argument at call function is void 0 ---*/ -eval(" SendableFunction(\"this.feat=1\").call(void 0) "); +eval(" SharedFunction(\"this.feat=1\").call(void 0) "); assert.sameValue(this["feat"], 1, 'The value of this["feat"] is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T1.js index 7c30d4d6bac..64ff6e8bf66 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T1.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T1.js @@ -23,7 +23,7 @@ description: thisArg is number var obj = 1; -var retobj = SendableFunction("this.touched= true; return this;").call(obj); +var retobj = SharedFunction("this.touched= true; return this;").call(obj); assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T2.js index 147a0923206..3bd944842ae 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T2.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T2.js @@ -23,7 +23,7 @@ description: thisArg is boolean true var obj = true; -var retobj = new SendableFunction("this.touched= true; return this;").call(obj); +var retobj = new SharedFunction("this.touched= true; return this;").call(obj); assert.sameValue(typeof obj.touched, "undefined", 'The value of `typeof obj.touched` is expected to be "undefined"'); assert(retobj["touched"], 'The value of retobj["touched"] is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T7.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T7.js index f4823951d5a..c6d4ffaf3e6 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T7.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T7.js @@ -23,6 +23,6 @@ description: thisArg is new Number() var obj = new Number(1); -SendableFunction("this.touched= true;").call(obj); +SharedFunction("this.touched= true;").call(obj); assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T8.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T8.js index bebcd193c41..e8504d436c1 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T8.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A5_T8.js @@ -18,11 +18,11 @@ info: | If thisArg is not null(defined) the called function is passed ToObject(thisArg) as the this value es5id: 15.3.4.4_A5_T8 -description: thisArg is SendableFunction() +description: thisArg is SharedFunction() ---*/ -var obj = SendableFunction(); +var obj = SharedFunction(); -new SendableFunction("this.touched= true; return this;").call(obj); +new SharedFunction("this.touched= true; return this;").call(obj); assert(obj.touched, 'The value of obj.touched is expected to be true'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T1.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T1.js index 4d1f38e8788..905feef3ec9 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T1.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T1.js @@ -21,7 +21,7 @@ es5id: 15.3.4.4_A6_T1 description: Argunemts of call function is (null,[1]) ---*/ -SendableFunction("a1,a2,a3", "this.shifted=a1;").call(null, [1]); +SharedFunction("a1,a2,a3", "this.shifted=a1;").call(null, [1]); assert.sameValue( this["shifted"].constructor, diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T10.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T10.js index a52b50c0094..2806a9467ca 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T10.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T10.js @@ -26,7 +26,7 @@ description: > var obj = {}; (function() { - SendableFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(obj, arguments, "", "2"); + SharedFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(obj, arguments, "", "2"); })("", 4, 2, "a"); assert.sameValue(obj["shifted"], "42", 'The value of obj["shifted"] is expected to be "42"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T2.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T2.js index 36521ba0686..aa50e54d9aa 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T2.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T2.js @@ -21,7 +21,7 @@ es5id: 15.3.4.4_A6_T2 description: Argunemts of call function is (null,[3,2,1]) ---*/ -new SendableFunction("a1,a2", "a3", "this.shifted=a1;").call(null, [3, 2, 1]); +new SharedFunction("a1,a2", "a3", "this.shifted=a1;").call(null, [3, 2, 1]); assert.sameValue(this["shifted"].length, 3); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T3.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T3.js index 14bc8526fa1..d8773f23c2a 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T3.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T3.js @@ -33,7 +33,7 @@ var p = { var obj = {}; -SendableFunction(p, "a2,a3", "this.shifted=a1;").call(obj, new SendableArray("nine", "inch", "nails")); +SharedFunction(p, "a2,a3", "this.shifted=a1;").call(obj, new SendableArray("nine", "inch", "nails")); assert.sameValue(obj["shifted"].length, 3); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T4.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T4.js index a7544bf6677..ba25ffefb72 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T4.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T4.js @@ -33,7 +33,7 @@ var p = { var obj = {}; -new SendableFunction(p, p, p, "this.shifted=a3+a2+a1.length;").call(obj, (function() { +new SharedFunction(p, p, p, "this.shifted=a3+a2+a1.length;").call(obj, (function() { return arguments; })("a", "b", "c", "d"), "", 2); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T5.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T5.js index 3a522a21cc5..c71bc8bf9c8 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T5.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T5.js @@ -24,7 +24,7 @@ description: > ---*/ function FACTORY() { - SendableFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(null, arguments, "", 2); + SharedFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(null, arguments, "", 2); } var obj = new FACTORY("", 1, 2, "A"); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T6.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T6.js index 23993272ba9..e7d986161ca 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T6.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T6.js @@ -24,7 +24,7 @@ description: > ---*/ function FACTORY() { - SendableFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(this, arguments, "", 2); + SharedFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(this, arguments, "", 2); } var obj = new FACTORY("", 4, 2, "A"); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T7.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T7.js index a1480cc640b..694a51b3212 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T7.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T7.js @@ -24,7 +24,7 @@ description: > ---*/ (function() { - SendableFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(null, arguments, "", 2); + SharedFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(null, arguments, "", 2); })("", 1, 2, true); assert.sameValue(this["shifted"], "42", 'The value of this["shifted"] is expected to be "42"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T8.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T8.js index 37ef900b7e3..1d8166a6a34 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T8.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T8.js @@ -24,7 +24,7 @@ description: > ---*/ (function() { - SendableFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(this, arguments, "", 2); + SharedFunction("a1,a2,a3", "this.shifted=a1.length+a2+a3;").call(this, arguments, "", 2); })("", 4, 2, null); assert.sameValue(this["shifted"], "42", 'The value of this["shifted"] is expected to be "42"'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T9.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T9.js index 8f07652f97b..c54fc1405fb 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T9.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A6_T9.js @@ -25,7 +25,7 @@ description: > function FACTORY() { var obj = {}; - SendableFunction("a1,a2,a3", "this.shifted=a1+a2.length+a3;").call(obj, "", arguments, 2); + SharedFunction("a1,a2,a3", "this.shifted=a1+a2.length+a3;").call(obj, "", arguments, 2); return obj; } diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T3.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T3.js index ea4c1fd77be..c4a12ed8235 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T3.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T3.js @@ -14,14 +14,14 @@ */ /*--- -info: SendableFunction.prototype.call can't be used as [[Construct]] caller +info: SharedFunction.prototype.call can't be used as [[Construct]] caller es5id: 15.3.4.4_A7_T3 -description: Checking if creating "new SendableFunction.call" fails +description: Checking if creating "new SharedFunction.call" fails ---*/ try { - var obj = new SendableFunction.call; - throw new Test262Error('#1: SendableFunction.prototype.call can\'t be used as [[Construct]] caller'); + var obj = new SharedFunction.call; + throw new Test262Error('#1: SharedFunction.prototype.call can\'t be used as [[Construct]] caller'); } catch (e) { assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); } diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T4.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T4.js index 68882db40b6..01c4be4160c 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T4.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T4.js @@ -14,14 +14,14 @@ */ /*--- -info: SendableFunction.prototype.call can't be used as [[Construct]] caller +info: SharedFunction.prototype.call can't be used as [[Construct]] caller es5id: 15.3.4.4_A7_T4 -description: Checking if creating "new (SendableFunction("this.p1=1").call)" fails +description: Checking if creating "new (SharedFunction("this.p1=1").call)" fails ---*/ try { - var obj = new(SendableFunction("this.p1=1").call); - throw new Test262Error('#1: SendableFunction.prototype.call can\'t be used as [[Construct]] caller'); + var obj = new(SharedFunction("this.p1=1").call); + throw new Test262Error('#1: SharedFunction.prototype.call can\'t be used as [[Construct]] caller'); } catch (e) { assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); } diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T5.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T5.js index 7afd04b23f6..e9a0ec0a337 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T5.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T5.js @@ -14,15 +14,15 @@ */ /*--- -info: SendableFunction.prototype.call can't be used as [[Construct]] caller +info: SharedFunction.prototype.call can't be used as [[Construct]] caller es5id: 15.3.4.4_A7_T5 -description: Checking if creating "new SendableFunction("this.p1=1").call" fails +description: Checking if creating "new SharedFunction("this.p1=1").call" fails ---*/ try { - var FACTORY = SendableFunction("this.p1=1").call; + var FACTORY = SharedFunction("this.p1=1").call; var obj = new FACTORY(); - throw new Test262Error('#1: SendableFunction.prototype.call can\'t be used as [[Construct]] caller'); + throw new Test262Error('#1: SharedFunction.prototype.call can\'t be used as [[Construct]] caller'); } catch (e) { assert(e instanceof TypeError, 'The result of evaluating (e instanceof TypeError) is expected to be true'); } diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T6.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T6.js index 717b74f921f..2b47ddcab06 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T6.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A7_T6.js @@ -14,17 +14,17 @@ */ /*--- -info: SendableFunction.prototype.call can't be used as [[Construct]] caller +info: SharedFunction.prototype.call can't be used as [[Construct]] caller es5id: 15.3.4.4_A7_T6 description: > - Checking if creating "new (SendableFunction("function + Checking if creating "new (SharedFunction("function f(){this.p1=1;};return f").call())" fails ---*/ try { - var obj = new(SendableFunction("function f(){this.p1=1;};return f").call()); + var obj = new(SharedFunction("function f(){this.p1=1;};return f").call()); } catch (e) { - throw new Test262Error('#1: SendableFunction.prototype.call can\'t be used as [[Construct]] caller'); + throw new Test262Error('#1: SharedFunction.prototype.call can\'t be used as [[Construct]] caller'); } assert.sameValue(obj.p1, 1, 'The value of obj.p1 is expected to be 1'); diff --git a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A9.js b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A9.js index 4b391924b61..486dfc27d9c 100644 --- a/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A9.js +++ b/test/sendable/builtins/Function/prototype/call/S15.3.4.4_A9.js @@ -15,26 +15,26 @@ /*--- info: | - The SendableFunction.prototype.call.length property does not have the attribute + The SharedFunction.prototype.call.length property does not have the attribute DontDelete es5id: 15.3.4.4_A9 description: > - Checking if deleting the SendableFunction.prototype.call.length property + Checking if deleting the SharedFunction.prototype.call.length property fails ---*/ assert( - SendableFunction.prototype.call.hasOwnProperty('length'), - 'SendableFunction.prototype.call.hasOwnProperty(\'length\') must return true' + SharedFunction.prototype.call.hasOwnProperty('length'), + 'SharedFunction.prototype.call.hasOwnProperty(\'length\') must return true' ); assert( - delete SendableFunction.prototype.call.length, - 'The value of delete SendableFunction.prototype.call.length is expected to be true' + delete SharedFunction.prototype.call.length, + 'The value of delete SharedFunction.prototype.call.length is expected to be true' ); assert( - !SendableFunction.prototype.call.hasOwnProperty('length'), - 'The value of !SendableFunction.prototype.call.hasOwnProperty(\'length\') is expected to be true' + !SharedFunction.prototype.call.hasOwnProperty('length'), + 'The value of !SharedFunction.prototype.call.hasOwnProperty(\'length\') is expected to be true' ); // TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/call/name.js b/test/sendable/builtins/Function/prototype/call/name.js index 6298599dcce..b2578366ead 100644 --- a/test/sendable/builtins/Function/prototype/call/name.js +++ b/test/sendable/builtins/Function/prototype/call/name.js @@ -16,22 +16,22 @@ /*--- es6id: 19.2.3.3 description: > - SendableFunction.prototype.call.name is "call". + SharedFunction.prototype.call.name is "call". info: | - SendableFunction.prototype.call (thisArg , ...args) + SharedFunction.prototype.call (thisArg , ...args) 17 ECMAScript Standard Built-in Objects: - Every built-in SendableFunction object, including constructors, that is not + Every built-in SharedFunction 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 SendableFunction + Unless otherwise specified, the name property of a built-in SharedFunction object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. includes: [propertyHelper.js] ---*/ -verifyProperty(SendableFunction.prototype.call, "name", { +verifyProperty(SharedFunction.prototype.call, "name", { value: "call", writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/call/not-a-constructor.js b/test/sendable/builtins/Function/prototype/call/not-a-constructor.js index b71522a7377..2c8a24edb16 100644 --- a/test/sendable/builtins/Function/prototype/call/not-a-constructor.js +++ b/test/sendable/builtins/Function/prototype/call/not-a-constructor.js @@ -16,9 +16,9 @@ /*--- esid: sec-ecmascript-standard-built-in-objects description: > - SendableFunction.prototype.call does not implement [[Construct]], is not new-able + SharedFunction.prototype.call does not implement [[Construct]], is not new-able info: | - ECMAScript SendableFunction Objects + ECMAScript SharedFunction Objects Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method unless otherwise specified in @@ -34,20 +34,20 @@ features: [Reflect.construct, arrow-function] ---*/ assert.sameValue( - isConstructor(SendableFunction.prototype.call), + isConstructor(SharedFunction.prototype.call), false, - 'isConstructor(SendableFunction.prototype.call) must return false' + 'isConstructor(SharedFunction.prototype.call) must return false' ); assert.throws(TypeError, () => { - new SendableFunction.prototype.call(); + new SharedFunction.prototype.call(); }); assert.throws(TypeError, () => { - new SendableFunction.prototype.call; + new SharedFunction.prototype.call; }); -var call = SendableFunction.prototype.call; +var call = SharedFunction.prototype.call; assert.throws(TypeError, () => { new call; }, '`new call()` throws TypeError'); diff --git a/test/sendable/builtins/Function/prototype/constructor/S15.3.4.1_A1_T1.js b/test/sendable/builtins/Function/prototype/constructor/S15.3.4.1_A1_T1.js index 0d6fd7c54a6..0f6a0ecbcc1 100644 --- a/test/sendable/builtins/Function/prototype/constructor/S15.3.4.1_A1_T1.js +++ b/test/sendable/builtins/Function/prototype/constructor/S15.3.4.1_A1_T1.js @@ -15,13 +15,13 @@ /*--- info: | - The initial value of SendableFunction.prototype.constructor is the built-in - SendableFunction constructor + The initial value of SharedFunction.prototype.constructor is the built-in + SharedFunction constructor es5id: 15.3.4.1_A1_T1 -description: Checking SendableFunction.prototype.constructor +description: Checking SharedFunction.prototype.constructor ---*/ assert.sameValue( - SendableFunction.prototype.constructor, - SendableFunction, - 'The value of SendableFunction.prototype.constructor is expected to equal the value of SendableFunction' + SharedFunction.prototype.constructor, + SharedFunction, + 'The value of SharedFunction.prototype.constructor is expected to equal the value of SharedFunction' ); diff --git a/test/sendable/builtins/Function/prototype/length.js b/test/sendable/builtins/Function/prototype/length.js index 0c93b88f05d..e439ebea0f7 100644 --- a/test/sendable/builtins/Function/prototype/length.js +++ b/test/sendable/builtins/Function/prototype/length.js @@ -16,11 +16,11 @@ /*--- esid: sec-properties-of-the-function-prototype-object description: > - SendableFunction.prototype.length is 0. + SharedFunction.prototype.length is 0. info: | - Properties of the SendableFunction Prototype Object + Properties of the SharedFunction Prototype Object - The SendableFunction prototype object: + The SharedFunction prototype object: [...] * has a "length" property whose value is 0. @@ -32,7 +32,7 @@ info: | includes: [propertyHelper.js] ---*/ -verifyProperty(SendableFunction.prototype, "length", { +verifyProperty(SharedFunction.prototype, "length", { value: 0, writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/name.js b/test/sendable/builtins/Function/prototype/name.js index 8fea713ee4d..aae6859f15f 100644 --- a/test/sendable/builtins/Function/prototype/name.js +++ b/test/sendable/builtins/Function/prototype/name.js @@ -17,18 +17,18 @@ es6id: 19.2.3 description: SendableFunctionPrototype `name` property info: | - The value of the name property of the SendableFunction prototype object is the + The value of the name property of the SharedFunction prototype object is the empty String. ES6 Section 17: - Unless otherwise specified, the name property of a built-in SendableFunction + Unless otherwise specified, the name property of a built-in SharedFunction object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. includes: [propertyHelper.js] ---*/ -verifyProperty(SendableFunction.prototype, "name", { +verifyProperty(SharedFunction.prototype, "name", { value: "", writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/property-order.js b/test/sendable/builtins/Function/prototype/property-order.js index 6b57af1990c..2b460f857dc 100644 --- a/test/sendable/builtins/Function/prototype/property-order.js +++ b/test/sendable/builtins/Function/prototype/property-order.js @@ -15,12 +15,12 @@ /*--- esid: sec-createbuiltinfunction -description: SendableFunction constructor property order +description: SharedFunction constructor property order info: | Set order: "length", "name", ... ---*/ -var propNames = Object.getOwnPropertyNames(SendableFunction.prototype); +var propNames = Object.getOwnPropertyNames(SharedFunction.prototype); var lengthIndex = propNames.indexOf("length"); var nameIndex = propNames.indexOf("name"); diff --git a/test/sendable/builtins/Function/prototype/restricted-property-arguments.js b/test/sendable/builtins/Function/prototype/restricted-property-arguments.js index 7c2af3d92eb..0f471f9e180 100644 --- a/test/sendable/builtins/Function/prototype/restricted-property-arguments.js +++ b/test/sendable/builtins/Function/prototype/restricted-property-arguments.js @@ -19,7 +19,7 @@ includes: [propertyHelper.js] es6id: 8.2.2 S12, 9.2.7 ---*/ -var SendableFunctionPrototype = SendableFunction.prototype; +var SendableFunctionPrototype = SharedFunction.prototype; assert.sameValue(SendableFunctionPrototype.hasOwnProperty('arguments'), true, 'The result of %SendableFunctionPrototype%.hasOwnProperty("arguments") is true'); var descriptor = Object.getOwnPropertyDescriptor(SendableFunctionPrototype, 'arguments'); diff --git a/test/sendable/builtins/Function/prototype/restricted-property-caller.js b/test/sendable/builtins/Function/prototype/restricted-property-caller.js index 9308403b168..d0376715732 100644 --- a/test/sendable/builtins/Function/prototype/restricted-property-caller.js +++ b/test/sendable/builtins/Function/prototype/restricted-property-caller.js @@ -19,7 +19,7 @@ includes: [propertyHelper.js] es6id: 8.2.2 S12, 9.2.7 ---*/ -var SendableFunctionPrototype = SendableFunction.prototype; +var SendableFunctionPrototype = SharedFunction.prototype; assert.sameValue(SendableFunctionPrototype.hasOwnProperty('caller'), true, 'The result of %SendableFunctionPrototype%.hasOwnProperty("caller") is true'); diff --git a/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js b/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js index a96b201974d..551e3237051 100644 --- a/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js +++ b/test/sendable/builtins/Function/prototype/toString/AsyncFunction.js @@ -17,7 +17,7 @@ author: Brian Terlson esid: sec-function.prototype.tostring description: > - SendableFunction.prototype.toString on an async function created with the + SharedFunction.prototype.toString on an async function created with the AsyncSendableFunction constructor. features: [async-functions] includes: [nativeFunctionMatcher.js] diff --git a/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js b/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js index 2cb6a611b8b..341ee998edf 100644 --- a/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js +++ b/test/sendable/builtins/Function/prototype/toString/AsyncGenerator.js @@ -16,7 +16,7 @@ /*--- esid: sec-function.prototype.tostring description: > - SendableFunction.prototype.toString on an async generator created with the + SharedFunction.prototype.toString on an async generator created with the AsyncGenerator constructor. features: [async-iteration] includes: [nativeFunctionMatcher.js] diff --git a/test/sendable/builtins/Function/prototype/toString/Function.js b/test/sendable/builtins/Function/prototype/toString/Function.js index f63849ca173..0b8ed524d6e 100644 --- a/test/sendable/builtins/Function/prototype/toString/Function.js +++ b/test/sendable/builtins/Function/prototype/toString/Function.js @@ -15,10 +15,10 @@ /*--- esid: sec-createdynamicfunction -description: SendableFunction.prototype.toString on a function created with the SendableFunction constructor +description: SharedFunction.prototype.toString on a function created with the SharedFunction constructor includes: [nativeFunctionMatcher.js] ---*/ -let f = /* before */SendableFunction("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */; +let f = /* before */SharedFunction("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */; assertToStringOrNativeFunction(f, "function anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}"); diff --git a/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js b/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js index c25f8e2c619..f2b66eed123 100644 --- a/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js +++ b/test/sendable/builtins/Function/prototype/toString/GeneratorFunction.js @@ -15,7 +15,7 @@ /*--- esid: sec-createdynamicfunction -description: SendableFunction.prototype.toString on a generator function created with the GeneratorSendableFunction constructor +description: SharedFunction.prototype.toString on a generator function created with the GeneratorSendableFunction constructor features: [generators] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A10.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A10.js index f22e9c421f5..cf8ec949bca 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A10.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A10.js @@ -14,26 +14,26 @@ */ /*--- -info: The SendableFunction.prototype.toString.length property has the attribute ReadOnly +info: The SharedFunction.prototype.toString.length property has the attribute ReadOnly es5id: 15.3.4.2_A10 description: > - Checking if varying the SendableFunction.prototype.toString.length + Checking if varying the SharedFunction.prototype.toString.length property fails includes: [propertyHelper.js] ---*/ assert( - SendableFunction.prototype.toString.hasOwnProperty('length'), - 'SendableFunction.prototype.toString.hasOwnProperty(\'length\') must return true' + SharedFunction.prototype.toString.hasOwnProperty('length'), + 'SharedFunction.prototype.toString.hasOwnProperty(\'length\') must return true' ); -var obj = SendableFunction.prototype.toString.length; +var obj = SharedFunction.prototype.toString.length; -verifyNotWritable(SendableFunction.prototype.toString, "length", null, function(){return "shifted";}); +verifyNotWritable(SharedFunction.prototype.toString, "length", null, function(){return "shifted";}); assert.sameValue( - SendableFunction.prototype.toString.length, + SharedFunction.prototype.toString.length, obj, - 'The value of SendableFunction.prototype.toString.length is expected to equal the value of obj' + 'The value of SharedFunction.prototype.toString.length is expected to equal the value of obj' ); // TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A11.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A11.js index 26df4969c4b..15d5c0534d8 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A11.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A11.js @@ -16,15 +16,15 @@ /*--- info: The length property of the toString method is 0 es5id: 15.3.4.2_A11 -description: Checking SendableFunction.prototype.toString.length +description: Checking SharedFunction.prototype.toString.length ---*/ assert( - SendableFunction.prototype.toString.hasOwnProperty("length"), - 'SendableFunction.prototype.toString.hasOwnProperty("length") must return true' + SharedFunction.prototype.toString.hasOwnProperty("length"), + 'SharedFunction.prototype.toString.hasOwnProperty("length") must return true' ); assert.sameValue( - SendableFunction.prototype.toString.length, + SharedFunction.prototype.toString.length, 0, - 'The value of SendableFunction.prototype.toString.length is expected to be 0' + 'The value of SharedFunction.prototype.toString.length is expected to be 0' ); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A12.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A12.js index f8995c9a9b0..730e9338fff 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A12.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A12.js @@ -16,10 +16,10 @@ /*--- es5id: 15.3.4.2_A12 description: > - The SendableFunction.prototype.toString function is not generic; it throws + The SharedFunction.prototype.toString function is not generic; it throws a TypeError exception if its this value is not a callable object. ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.toString.call(undefined); -}, 'SendableFunction.prototype.toString.call(undefined) throws a TypeError exception'); + SharedFunction.prototype.toString.call(undefined); +}, 'SharedFunction.prototype.toString.call(undefined) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A13.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A13.js index 47b5c7139e0..be9e36da8ff 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A13.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A13.js @@ -21,5 +21,5 @@ description: > ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.toString.call(null); -}, 'SendableFunction.prototype.toString.call(null) throws a TypeError exception'); + SharedFunction.prototype.toString.call(null); +}, 'SharedFunction.prototype.toString.call(null) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A14.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A14.js index df1ea91d016..fca732ef021 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A14.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A14.js @@ -21,5 +21,5 @@ description: > ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.toString.call({}); -}, 'SendableFunction.prototype.toString.call({}) throws a TypeError exception'); + SharedFunction.prototype.toString.call({}); +}, 'SharedFunction.prototype.toString.call({}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A16.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A16.js index 51301992382..ccf6d65eea8 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A16.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A16.js @@ -24,7 +24,7 @@ description: > bound to that object. ---*/ -var obj = {toString: SendableFunction.prototype.toString}; +var obj = {toString: SharedFunction.prototype.toString}; assert.throws(TypeError, function() { String(obj); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A6.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A6.js index 69e7aeb2614..710cf0ca16d 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A6.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A6.js @@ -14,14 +14,14 @@ */ /*--- -info: SendableFunction.prototype.toString has not prototype property +info: SharedFunction.prototype.toString has not prototype property es5id: 15.3.4.2_A6 description: > Checking if obtaining the prototype property of - SendableFunction.prototype.toString fails + SharedFunction.prototype.toString fails ---*/ assert.sameValue( - SendableFunction.prototype.toString.prototype, + SharedFunction.prototype.toString.prototype, undefined, - 'The value of SendableFunction.prototype.toString.prototype is expected to equal undefined' + 'The value of SharedFunction.prototype.toString.prototype is expected to equal undefined' ); diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A8.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A8.js index 34918843f36..fff5423b9b1 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A8.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A8.js @@ -14,24 +14,24 @@ */ /*--- -info: The SendableFunction.prototype.toString.length property has the attribute DontEnum +info: The SharedFunction.prototype.toString.length property has the attribute DontEnum es5id: 15.3.4.2_A8 description: > - Checking if enumerating the SendableFunction.prototype.toString.length + Checking if enumerating the SharedFunction.prototype.toString.length property fails ---*/ assert( - SendableFunction.prototype.toString.hasOwnProperty('length'), - 'SendableFunction.prototype.toString.hasOwnProperty(\'length\') must return true' + SharedFunction.prototype.toString.hasOwnProperty('length'), + 'SharedFunction.prototype.toString.hasOwnProperty(\'length\') must return true' ); assert( - !SendableFunction.prototype.toString.propertyIsEnumerable('length'), - 'The value of !SendableFunction.prototype.toString.propertyIsEnumerable(\'length\') is expected to be true' + !SharedFunction.prototype.toString.propertyIsEnumerable('length'), + 'The value of !SharedFunction.prototype.toString.propertyIsEnumerable(\'length\') is expected to be true' ); // CHECK#2 -for (var p in SendableFunction.prototype.toString){ +for (var p in SharedFunction.prototype.toString){ assert.notSameValue(p, "length", 'The value of p is not "length"'); } diff --git a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A9.js b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A9.js index eefa4012c23..8b40747914f 100644 --- a/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A9.js +++ b/test/sendable/builtins/Function/prototype/toString/S15.3.4.2_A9.js @@ -15,26 +15,26 @@ /*--- info: | - The SendableFunction.prototype.toString.length property does not have the + The SharedFunction.prototype.toString.length property does not have the attribute DontDelete es5id: 15.3.4.2_A9 description: > - Checking if deleting the SendableFunction.prototype.toString.length + Checking if deleting the SharedFunction.prototype.toString.length property fails ---*/ assert( - SendableFunction.prototype.toString.hasOwnProperty('length'), - 'SendableFunction.prototype.toString.hasOwnProperty(\'length\') must return true' + SharedFunction.prototype.toString.hasOwnProperty('length'), + 'SharedFunction.prototype.toString.hasOwnProperty(\'length\') must return true' ); assert( - delete SendableFunction.prototype.toString.length, - 'The value of delete SendableFunction.prototype.toString.length is expected to be true' + delete SharedFunction.prototype.toString.length, + 'The value of delete SharedFunction.prototype.toString.length is expected to be true' ); assert( - !SendableFunction.prototype.toString.hasOwnProperty('length'), - 'The value of !SendableFunction.prototype.toString.hasOwnProperty(\'length\') is expected to be true' + !SharedFunction.prototype.toString.hasOwnProperty('length'), + 'The value of !SharedFunction.prototype.toString.hasOwnProperty(\'length\') is expected to be true' ); // TODO: Convert to verifyProperty() format. diff --git a/test/sendable/builtins/Function/prototype/toString/arrow-function.js b/test/sendable/builtins/Function/prototype/toString/arrow-function.js index c01d3e1cd57..4ba50e22876 100644 --- a/test/sendable/builtins/Function/prototype/toString/arrow-function.js +++ b/test/sendable/builtins/Function/prototype/toString/arrow-function.js @@ -15,7 +15,7 @@ /*--- esid: sec-arrow-function-definitions-runtime-semantics-evaluation -description: SendableFunction.prototype.toString on an arrow function +description: SharedFunction.prototype.toString on an arrow function includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js b/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js index d6caf9600f3..d40f0d5551f 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js +++ b/test/sendable/builtins/Function/prototype/toString/async-arrow-function.js @@ -15,7 +15,7 @@ /*--- esid: sec-async-arrow-function-definitions-runtime-semantics-evaluation -description: SendableFunction.prototype.toString on an async arrow function +description: SharedFunction.prototype.toString on an async arrow function features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js b/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js index da68ba34909..26238213034 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js +++ b/test/sendable/builtins/Function/prototype/toString/async-function-declaration.js @@ -16,7 +16,7 @@ /*--- author: Brian Terlson esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on an async function declaration +description: SharedFunction.prototype.toString on an async function declaration features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-function-expression.js b/test/sendable/builtins/Function/prototype/toString/async-function-expression.js index 595cdd2dcb9..be827f3c159 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-function-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/async-function-expression.js @@ -16,7 +16,7 @@ /*--- author: Brian Terlson esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on an async function expression +description: SharedFunction.prototype.toString on an async function expression features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js b/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js index d6c7280ca6e..36f30ae060d 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-declaration.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on an async generator declaration +description: SharedFunction.prototype.toString on an async generator declaration features: [async-iteration] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js b/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js index a5b94ec4e16..95cf2c91a82 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-expression.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on an async generator expression +description: SharedFunction.prototype.toString on an async generator expression features: [async-iteration] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js index e2ef9787bb4..65da5adcb89 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on an async generator method +description: SharedFunction.prototype.toString on an async generator method features: [async-iteration] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js index 9721ffcb4ea..d2d066bd72b 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-expression.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on an async generator method +description: SharedFunction.prototype.toString on an async generator method features: [async-iteration] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js index b793e5b9b20..29507de3916 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on an async generator method +description: SharedFunction.prototype.toString on an async generator method features: [async-iteration] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js index 810431f6c1f..6e500159404 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-class-statement.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on an async generator method +description: SharedFunction.prototype.toString on an async generator method features: [async-iteration] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js b/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js index 0475f88ab74..eb872e60cdc 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js +++ b/test/sendable/builtins/Function/prototype/toString/async-generator-method-object.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on an async generator method +description: SharedFunction.prototype.toString on an async generator method features: [async-iteration] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js index 49c46455a1a..8aaebc78e7b 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on an async method +description: SharedFunction.prototype.toString on an async method features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js index b2b90340020..474f2c040e3 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-expression.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on an async method +description: SharedFunction.prototype.toString on an async method features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js index c31458d8b3a..4861a96b717 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on an async method +description: SharedFunction.prototype.toString on an async method features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js index 9305e8994bc..8f403209dfe 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-class-statement.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on an async method +description: SharedFunction.prototype.toString on an async method features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/async-method-object.js b/test/sendable/builtins/Function/prototype/toString/async-method-object.js index ef285177fdb..866e4219110 100644 --- a/test/sendable/builtins/Function/prototype/toString/async-method-object.js +++ b/test/sendable/builtins/Function/prototype/toString/async-method-object.js @@ -16,7 +16,7 @@ /*--- author: Brian Terlson esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on an async method +description: SharedFunction.prototype.toString on an async method features: [async-functions] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/bound-function.js b/test/sendable/builtins/Function/prototype/toString/bound-function.js index 6156f75f371..0bbe8a2668f 100644 --- a/test/sendable/builtins/Function/prototype/toString/bound-function.js +++ b/test/sendable/builtins/Function/prototype/toString/bound-function.js @@ -16,10 +16,10 @@ /*--- esid: sec-function.prototype.tostring description: > - toString bound function does not throw (bound SendableFunction Expression) + toString bound function does not throw (bound SharedFunction Expression) info: | ... - If func is a Bound SendableFunction exotic object or a built-in SendableFunction object, + If func is a Bound SharedFunction exotic object or a built-in SharedFunction object, then return an implementation-dependent String source code representation of func. The representation must have the syntax of a NativeFunction ... diff --git a/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js b/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js index cac908d9b6e..8c0e360f3f4 100644 --- a/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js +++ b/test/sendable/builtins/Function/prototype/toString/built-in-function-object.js @@ -16,10 +16,10 @@ /*--- esid: sec-function.prototype.tostring description: > - toString of built-in SendableFunction object + toString of built-in SharedFunction object info: | ... - If func is a built-in SendableFunction object, then return an implementation-dependent String source code representation of func. + If func is a built-in SharedFunction object, then return an implementation-dependent String source code representation of func. The representation must have the syntax of a NativeFunction. ... diff --git a/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js b/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js index 33c5dfcb149..b72527440f2 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js +++ b/test/sendable/builtins/Function/prototype/toString/class-declaration-complex-heritage.js @@ -15,7 +15,7 @@ /*--- esid: sec-runtime-semantics-bindingclassdeclarationevaluation -description: SendableFunction.prototype.toString on a class declaration (with complex heritage) +description: SharedFunction.prototype.toString on a class declaration (with complex heritage) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js index 704de22987e..43e37697483 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js +++ b/test/sendable/builtins/Function/prototype/toString/class-declaration-explicit-ctor.js @@ -15,7 +15,7 @@ /*--- esid: sec-runtime-semantics-bindingclassdeclarationevaluation -description: SendableFunction.prototype.toString on a class declaration (explicit constructor) +description: SharedFunction.prototype.toString on a class declaration (explicit constructor) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js index f45d4649456..0ab080c559f 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js +++ b/test/sendable/builtins/Function/prototype/toString/class-declaration-implicit-ctor.js @@ -15,7 +15,7 @@ /*--- esid: sec-runtime-semantics-bindingclassdeclarationevaluation -description: SendableFunction.prototype.toString on a class declaration (implicit constructor) +description: SharedFunction.prototype.toString on a class declaration (implicit constructor) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js index d0e3477390a..b446e8ea3df 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js +++ b/test/sendable/builtins/Function/prototype/toString/class-expression-explicit-ctor.js @@ -15,7 +15,7 @@ /*--- esid: sec-class-definitions-runtime-semantics-evaluation -description: SendableFunction.prototype.toString on a class expression (explicit constructor) +description: SharedFunction.prototype.toString on a class expression (explicit constructor) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js b/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js index 4e50936108d..0ffda8e2ffa 100644 --- a/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js +++ b/test/sendable/builtins/Function/prototype/toString/class-expression-implicit-ctor.js @@ -15,7 +15,7 @@ /*--- esid: sec-class-definitions-runtime-semantics-evaluation -description: SendableFunction.prototype.toString on a class expression (implicit constructor) +description: SharedFunction.prototype.toString on a class expression (implicit constructor) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js b/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js index 70eb547e096..5148e6df5af 100644 --- a/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js +++ b/test/sendable/builtins/Function/prototype/toString/function-declaration-non-simple-parameter-list.js @@ -15,7 +15,7 @@ /*--- esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject -description: SendableFunction.prototype.toString on a function with a non-simple parameter list +description: SharedFunction.prototype.toString on a function with a non-simple parameter list includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/function-declaration.js b/test/sendable/builtins/Function/prototype/toString/function-declaration.js index aed1eba7e46..47b23b83b1c 100644 --- a/test/sendable/builtins/Function/prototype/toString/function-declaration.js +++ b/test/sendable/builtins/Function/prototype/toString/function-declaration.js @@ -15,7 +15,7 @@ /*--- esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject -description: SendableFunction.prototype.toString on a function declaration +description: SharedFunction.prototype.toString on a function declaration includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/function-expression.js b/test/sendable/builtins/Function/prototype/toString/function-expression.js index 58800f4344c..b9eec7abbe5 100644 --- a/test/sendable/builtins/Function/prototype/toString/function-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/function-expression.js @@ -15,7 +15,7 @@ /*--- esid: sec-function-definitions-runtime-semantics-evaluation -description: SendableFunction.prototype.toString on a function expression +description: SharedFunction.prototype.toString on a function expression includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js b/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js index ba9247d19b2..16bd420bb59 100644 --- a/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js +++ b/test/sendable/builtins/Function/prototype/toString/generator-function-declaration.js @@ -15,7 +15,7 @@ /*--- esid: sec-generator-function-definitions-runtime-semantics-instantiatefunctionobject -description: SendableFunction.prototype.toString on a generator function declaration +description: SharedFunction.prototype.toString on a generator function declaration includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js b/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js index 511ea82ac12..b5cfef7b42d 100644 --- a/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/generator-function-expression.js @@ -15,7 +15,7 @@ /*--- esid: sec-generator-function-definitions-runtime-semantics-evaluation -description: SendableFunction.prototype.toString on a generator function expression +description: SharedFunction.prototype.toString on a generator function expression includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/generator-method.js b/test/sendable/builtins/Function/prototype/toString/generator-method.js index 4c51ea48d1d..a31af6c6e17 100644 --- a/test/sendable/builtins/Function/prototype/toString/generator-method.js +++ b/test/sendable/builtins/Function/prototype/toString/generator-method.js @@ -15,7 +15,7 @@ /*--- esid: sec-generator-function-definitions-runtime-semantics-propertydefinitionevaluation -description: SendableFunction.prototype.toString on a generator method +description: SharedFunction.prototype.toString on a generator method includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js index bb41296c0c4..e016ce57638 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-expression-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: SendableFunction.prototype.toString on a getter (class; static) +description: SharedFunction.prototype.toString on a getter (class; static) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js b/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js index df4937e22b0..99da4627d59 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-expression.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: SendableFunction.prototype.toString on a getter (class) +description: SharedFunction.prototype.toString on a getter (class) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js index 72e554b38e5..d7077bcd1d0 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-statement-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: SendableFunction.prototype.toString on a getter (class; static) +description: SharedFunction.prototype.toString on a getter (class; static) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js b/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js index 4772b2213b4..6c15e041bd6 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-class-statement.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: SendableFunction.prototype.toString on a getter (class) +description: SharedFunction.prototype.toString on a getter (class) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/getter-object.js b/test/sendable/builtins/Function/prototype/toString/getter-object.js index ac94396b8f9..44ab794827c 100644 --- a/test/sendable/builtins/Function/prototype/toString/getter-object.js +++ b/test/sendable/builtins/Function/prototype/toString/getter-object.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: SendableFunction.prototype.toString on a getter (object) +description: SharedFunction.prototype.toString on a getter (object) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js index 9bec370ef45..98aae24a84f 100644 --- a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js +++ b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR-LF.js @@ -15,9 +15,9 @@ /*--- esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject -description: SendableFunction.prototype.toString line terminator normalisation (CR-LF) +description: SharedFunction.prototype.toString line terminator normalisation (CR-LF) info: | - SendableFunction.prototype.toString should not normalise line terminator sequences to Line Feed characters. + SharedFunction.prototype.toString should not normalise line terminator sequences to Line Feed characters. This file uses (Carriage Return, Line Feed) sequences as line terminators. includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js index 4c694c0128b..39b9385e009 100644 --- a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js +++ b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-CR.js @@ -15,9 +15,9 @@ /*--- esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject -description: SendableFunction.prototype.toString line terminator normalisation (CR) +description: SharedFunction.prototype.toString line terminator normalisation (CR) info: | - SendableFunction.prototype.toString should not normalise line terminator sequences to Line Feed characters. + SharedFunction.prototype.toString should not normalise line terminator sequences to Line Feed characters. This file uses Carriage Return characters as line terminators. includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js index 4c8752a2d43..342978b4d97 100644 --- a/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js +++ b/test/sendable/builtins/Function/prototype/toString/line-terminator-normalisation-LF.js @@ -15,9 +15,9 @@ /*--- esid: sec-function-definitions-runtime-semantics-instantiatefunctionobject -description: SendableFunction.prototype.toString line terminator normalisation (LF) +description: SharedFunction.prototype.toString line terminator normalisation (LF) info: | - SendableFunction.prototype.toString should not normalise line terminator sequences to Line Feed characters. + SharedFunction.prototype.toString should not normalise line terminator sequences to Line Feed characters. This file uses Line Feed characters as line terminators. includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js index 237675c414e..e08c9103900 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/method-class-expression-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-runtime-semantics-definemethod -description: SendableFunction.prototype.toString on a method (class; static) +description: SharedFunction.prototype.toString on a method (class; static) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/method-class-expression.js index d6d661ebea7..760b6450088 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/method-class-expression.js @@ -15,7 +15,7 @@ /*--- esid: sec-runtime-semantics-definemethod -description: SendableFunction.prototype.toString on a method (class) +description: SharedFunction.prototype.toString on a method (class) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js index 61550c17f09..dd0b3d891c8 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/method-class-statement-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-runtime-semantics-definemethod -description: SendableFunction.prototype.toString on a method (class; static) +description: SharedFunction.prototype.toString on a method (class; static) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/method-class-statement.js index 1a5ef3ad9cd..75f76cb2f6c 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/method-class-statement.js @@ -15,7 +15,7 @@ /*--- esid: sec-runtime-semantics-definemethod -description: SendableFunction.prototype.toString on a method (class) +description: SharedFunction.prototype.toString on a method (class) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js b/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js index a62a2930011..c7311f26a6c 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js +++ b/test/sendable/builtins/Function/prototype/toString/method-computed-property-name.js @@ -15,7 +15,7 @@ /*--- esid: sec-runtime-semantics-definemethod -description: SendableFunction.prototype.toString on a method (object) +description: SharedFunction.prototype.toString on a method (object) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/method-object.js b/test/sendable/builtins/Function/prototype/toString/method-object.js index defada75d91..e99ff99a9e4 100644 --- a/test/sendable/builtins/Function/prototype/toString/method-object.js +++ b/test/sendable/builtins/Function/prototype/toString/method-object.js @@ -15,7 +15,7 @@ /*--- esid: sec-runtime-semantics-definemethod -description: SendableFunction.prototype.toString on a method (object) +description: SharedFunction.prototype.toString on a method (object) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/name.js b/test/sendable/builtins/Function/prototype/toString/name.js index 4fdf9d7faa3..a8a6997a2a1 100644 --- a/test/sendable/builtins/Function/prototype/toString/name.js +++ b/test/sendable/builtins/Function/prototype/toString/name.js @@ -16,22 +16,22 @@ /*--- esid: sec-function.prototype.tostring description: > - SendableFunction.prototype.toString.name is "toString". + SharedFunction.prototype.toString.name is "toString". info: | - SendableFunction.prototype.toString ( ) + SharedFunction.prototype.toString ( ) 17 ECMAScript Standard Built-in Objects: - Every built-in SendableFunction object, including constructors, that is not + Every built-in SharedFunction 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 SendableFunction + Unless otherwise specified, the name property of a built-in SharedFunction object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. includes: [propertyHelper.js] ---*/ -verifyProperty(SendableFunction.prototype.toString, "name", { +verifyProperty(SharedFunction.prototype.toString, "name", { value: "toString", writable: false, enumerable: false, diff --git a/test/sendable/builtins/Function/prototype/toString/not-a-constructor.js b/test/sendable/builtins/Function/prototype/toString/not-a-constructor.js index 929c36826fd..81f730807de 100644 --- a/test/sendable/builtins/Function/prototype/toString/not-a-constructor.js +++ b/test/sendable/builtins/Function/prototype/toString/not-a-constructor.js @@ -16,9 +16,9 @@ /*--- esid: sec-ecmascript-standard-built-in-objects description: > - SendableFunction.prototype.toString does not implement [[Construct]], is not new-able + SharedFunction.prototype.toString does not implement [[Construct]], is not new-able info: | - ECMAScript SendableFunction Objects + ECMAScript SharedFunction Objects Built-in function objects that are not identified as constructors do not implement the [[Construct]] internal method unless otherwise specified in @@ -34,16 +34,16 @@ features: [Reflect.construct, arrow-function] ---*/ assert.sameValue( - isConstructor(SendableFunction.prototype.toString), + isConstructor(SharedFunction.prototype.toString), false, - 'isConstructor(SendableFunction.prototype.toString) must return false' + 'isConstructor(SharedFunction.prototype.toString) must return false' ); assert.throws(TypeError, () => { - new SendableFunction.prototype.toString(); + new SharedFunction.prototype.toString(); }); -var toString = SendableFunction.prototype.toString; +var toString = SharedFunction.prototype.toString; assert.throws(TypeError, () => { new toString; }); diff --git a/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js index 230ee28617b..2f862c83e82 100644 --- a/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/private-method-class-expression.js @@ -14,7 +14,7 @@ */ /*--- -description: SendableFunction.prototype.toString on a private method +description: SharedFunction.prototype.toString on a private method features: [class-methods-private] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js index 124883b4eb8..643468ca2c6 100644 --- a/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/private-method-class-statement.js @@ -14,7 +14,7 @@ */ /*--- -description: SendableFunction.prototype.toString on a private method +description: SharedFunction.prototype.toString on a private method features: [class-methods-private] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js index f89fbd2513f..ad7252ece76 100644 --- a/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-expression.js @@ -14,7 +14,7 @@ */ /*--- -description: SendableFunction.prototype.toString on a static private method +description: SharedFunction.prototype.toString on a static private method features: [class-static-methods-private] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js index 8e2e548a0f4..6857938126a 100644 --- a/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/private-static-method-class-statement.js @@ -14,7 +14,7 @@ */ /*--- -description: SendableFunction.prototype.toString on a static private method +description: SharedFunction.prototype.toString on a static private method features: [class-static-methods-private] includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js index f6ea9962bca..34061a6629d 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-arrow-function.js @@ -16,7 +16,7 @@ /*--- esid: sec-function.prototype.tostring description: > - toString of Proxy for function target does not throw (Arrow SendableFunction) + toString of Proxy for function target does not throw (Arrow SharedFunction) info: | ... If Type(func) is Object and IsCallable(func) is true, then return an diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js index 17de9669643..f1b981b68e2 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-async-function.js @@ -16,7 +16,7 @@ /*--- esid: sec-function.prototype.tostring description: > - toString of Proxy for function target does not throw (Async SendableFunction Expression) + toString of Proxy for function target does not throw (Async SharedFunction Expression) info: | ... If Type(func) is Object and IsCallable(func) is true, then return an diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js index ca0164b8fe9..43532e7ea35 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-async-generator-function.js @@ -16,7 +16,7 @@ /*--- esid: sec-function.prototype.tostring description: > - toString of Proxy for function target does not throw (Async Generator SendableFunction Expression) + toString of Proxy for function target does not throw (Async Generator SharedFunction Expression) info: | ... If Type(func) is Object and IsCallable(func) is true, then return an diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js index 31a91c0f69b..f25d4d56f82 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-bound-function.js @@ -16,7 +16,7 @@ /*--- esid: sec-function.prototype.tostring description: > - toString of Proxy for function target does not throw (bound SendableFunction Expression) + toString of Proxy for function target does not throw (bound SharedFunction Expression) info: | ... If Type(func) is Object and IsCallable(func) is true, then return an diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js b/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js index 74697e6a0b2..963bd47603e 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-function-expression.js @@ -16,7 +16,7 @@ /*--- esid: sec-function.prototype.tostring description: > - toString of Proxy for function target does not throw (SendableFunction Expression) + toString of Proxy for function target does not throw (SharedFunction Expression) info: | ... If Type(func) is Object and IsCallable(func) is true, then return an diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js b/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js index 646e277d378..66ef052a619 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-generator-function.js @@ -16,7 +16,7 @@ /*--- esid: sec-function.prototype.tostring description: > - toString of Proxy for function target does not throw (Generator SendableFunction Expression) + toString of Proxy for function target does not throw (Generator SharedFunction Expression) info: | ... If Type(func) is Object and IsCallable(func) is true, then return an diff --git a/test/sendable/builtins/Function/prototype/toString/proxy-non-callable-throws.js b/test/sendable/builtins/Function/prototype/toString/proxy-non-callable-throws.js index df2a79f2ed3..9dcc0cef1ab 100644 --- a/test/sendable/builtins/Function/prototype/toString/proxy-non-callable-throws.js +++ b/test/sendable/builtins/Function/prototype/toString/proxy-non-callable-throws.js @@ -25,5 +25,5 @@ features: [Proxy] ---*/ assert.throws(TypeError, function() { - SendableFunction.prototype.toString.call(new Proxy({}, {})); + SharedFunction.prototype.toString.call(new Proxy({}, {})); }); diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js b/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js index 470497fcca2..a93d2fc78d7 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-expression-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: SendableFunction.prototype.toString on a setter (class; static) +description: SharedFunction.prototype.toString on a setter (class; static) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js b/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js index 409481b8866..01caf5fc39b 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-expression.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: SendableFunction.prototype.toString on a setter (class) +description: SharedFunction.prototype.toString on a setter (class) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js b/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js index 88a9ad4a77b..6980d663fc5 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-statement-static.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: SendableFunction.prototype.toString on a setter (class; static) +description: SharedFunction.prototype.toString on a setter (class; static) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js b/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js index e04837b6e08..3b1517a3521 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-class-statement.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: SendableFunction.prototype.toString on a setter (class) +description: SharedFunction.prototype.toString on a setter (class) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/setter-object.js b/test/sendable/builtins/Function/prototype/toString/setter-object.js index 1a14fb5eb3c..2f765798e4a 100644 --- a/test/sendable/builtins/Function/prototype/toString/setter-object.js +++ b/test/sendable/builtins/Function/prototype/toString/setter-object.js @@ -15,7 +15,7 @@ /*--- esid: sec-method-definitions-runtime-semantics-propertydefinitionevaluation -description: SendableFunction.prototype.toString on a setter (object) +description: SharedFunction.prototype.toString on a setter (object) includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js b/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js index 330ff340772..7109560ad98 100644 --- a/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js +++ b/test/sendable/builtins/Function/prototype/toString/symbol-named-builtins.js @@ -15,7 +15,7 @@ /*--- esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on symbol-named built-ins +description: SharedFunction.prototype.toString on symbol-named built-ins includes: [nativeFunctionMatcher.js] ---*/ diff --git a/test/sendable/builtins/Function/prototype/toString/unicode.js b/test/sendable/builtins/Function/prototype/toString/unicode.js index 2d1ad9bbbfb..4762d03588d 100644 --- a/test/sendable/builtins/Function/prototype/toString/unicode.js +++ b/test/sendable/builtins/Function/prototype/toString/unicode.js @@ -15,9 +15,9 @@ /*--- esid: sec-function.prototype.tostring -description: SendableFunction.prototype.toString on a function with Unicode escape sequences +description: SharedFunction.prototype.toString on a function with Unicode escape sequences info: | - SendableFunction.prototype.toString returns a slice of the source text before + SharedFunction.prototype.toString returns a slice of the source text before any potential Unicode escape sequence substitution in identifiers includes: [nativeFunctionMatcher.js] ---*/ -- Gitee From cf72d50dff9ceab41d4f4d456165ea46488f4553 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 21 Jan 2025 15:07:08 +0800 Subject: [PATCH 87/93] modify array-from Signed-off-by: zhuzhihui7 --- .../builtins/Array/from/calling-from-valid-1-onlyStrict.js | 2 +- test/sendable/builtins/Array/from/calling-from-valid-2.js | 2 +- test/sendable/builtins/Array/from/elements-added-after.js | 2 +- test/sendable/builtins/Array/from/elements-deleted-after.js | 6 +++--- test/sendable/builtins/Array/from/elements-updated-after.js | 2 +- test/sendable/builtins/Array/from/from-array.js | 2 +- test/sendable/builtins/Array/from/iter-map-fn-args.js | 2 +- test/sendable/builtins/Array/from/iter-map-fn-return.js | 2 +- test/sendable/builtins/Array/from/iter-map-fn-this-arg.js | 2 +- .../builtins/Array/from/iter-map-fn-this-non-strict.js | 2 +- .../sendable/builtins/Array/from/iter-map-fn-this-strict.js | 2 +- test/sendable/builtins/Array/from/mapfn-throws-exception.js | 2 +- test/sendable/builtins/Array/from/source-array-boundary.js | 2 +- .../builtins/Array/from/source-object-iterator-1.js | 2 +- .../builtins/Array/from/source-object-iterator-2.js | 2 +- test/sendable/builtins/Array/from/source-object-length.js | 4 ++-- test/sendable/builtins/Array/from/source-object-missing.js | 2 +- 17 files changed, 20 insertions(+), 20 deletions(-) diff --git a/test/sendable/builtins/Array/from/calling-from-valid-1-onlyStrict.js b/test/sendable/builtins/Array/from/calling-from-valid-1-onlyStrict.js index 6aef93e63c2..3bbd1bbeef4 100644 --- a/test/sendable/builtins/Array/from/calling-from-valid-1-onlyStrict.js +++ b/test/sendable/builtins/Array/from/calling-from-valid-1-onlyStrict.js @@ -40,7 +40,7 @@ var list = { '2': 43, length: 3 }; -var calls = []; +var calls = new SendableArray(); function mapFn(value) { calls.push({ args: arguments, diff --git a/test/sendable/builtins/Array/from/calling-from-valid-2.js b/test/sendable/builtins/Array/from/calling-from-valid-2.js index 311e2c1e48e..b9f66fc6725 100644 --- a/test/sendable/builtins/Array/from/calling-from-valid-2.js +++ b/test/sendable/builtins/Array/from/calling-from-valid-2.js @@ -39,7 +39,7 @@ var list = { '2': 43, length: 3 }; -var calls = []; +var calls = new SendableArray(); var thisArg = {}; function mapFn(value) { calls.push({ diff --git a/test/sendable/builtins/Array/from/elements-added-after.js b/test/sendable/builtins/Array/from/elements-added-after.js index e06893631f3..49302693347 100644 --- a/test/sendable/builtins/Array/from/elements-added-after.js +++ b/test/sendable/builtins/Array/from/elements-added-after.js @@ -29,7 +29,7 @@ var obj = { 5: 64, 6: 128 }; -var array = [2, 4, 8, 16, 32, 64, 128]; +var array = new SendableArray(2, 4, 8, 16, 32, 64, 128); function mapFn(value, index) { arrayIndex++; assert.sameValue(value, obj[arrayIndex], 'The value of value is expected to equal the value of obj[arrayIndex]'); diff --git a/test/sendable/builtins/Array/from/elements-deleted-after.js b/test/sendable/builtins/Array/from/elements-deleted-after.js index 11cc8986ad1..8d3e962098f 100644 --- a/test/sendable/builtins/Array/from/elements-deleted-after.js +++ b/test/sendable/builtins/Array/from/elements-deleted-after.js @@ -19,9 +19,9 @@ description: > esid: sec-array.from ---*/ -var originalArray = [0, 1, -2, 4, -8, 16]; -var array = [0, 1, -2, 4, -8, 16]; -var a = []; +var originalArray = new SendableArray(0, 1, -2, 4, -8, 16); +var array = new SendableArray(0, 1, -2, 4, -8, 16); +var a = new SendableArray(); var arrayIndex = -1; function mapFn(value, index) { this.arrayIndex++; diff --git a/test/sendable/builtins/Array/from/elements-updated-after.js b/test/sendable/builtins/Array/from/elements-updated-after.js index 1158964a699..813239c51b5 100644 --- a/test/sendable/builtins/Array/from/elements-updated-after.js +++ b/test/sendable/builtins/Array/from/elements-updated-after.js @@ -17,7 +17,7 @@ description: Elements are updated after the call to from esid: sec-array.from ---*/ -var array = [127, 4, 8, 16, 32, 64, 128]; +var array = new SendableArray(127, 4, 8, 16, 32, 64, 128); var arrayIndex = -1; function mapFn(value, index) { arrayIndex++; diff --git a/test/sendable/builtins/Array/from/from-array.js b/test/sendable/builtins/Array/from/from-array.js index 48aba44189a..76ed086b33b 100644 --- a/test/sendable/builtins/Array/from/from-array.js +++ b/test/sendable/builtins/Array/from/from-array.js @@ -17,7 +17,7 @@ description: Passing a valid array esid: sec-array.from ---*/ -var array = [0, 'foo', , Infinity]; +var array = new SendableArray(0, 'foo', undefined, Infinity); var result = SendableArray.from(array); assert.sameValue(result.length, 4, 'The value of result.length is expected to be 4'); assert.sameValue(result[0], 0, 'The value of result[0] is expected to be 0'); diff --git a/test/sendable/builtins/Array/from/iter-map-fn-args.js b/test/sendable/builtins/Array/from/iter-map-fn-args.js index 0dad143ea12..a125d389a59 100644 --- a/test/sendable/builtins/Array/from/iter-map-fn-args.js +++ b/test/sendable/builtins/Array/from/iter-map-fn-args.js @@ -32,7 +32,7 @@ info: | features: [Symbol.iterator] ---*/ -var args = []; +var args = new SendableArray(); var firstResult = { done: false, value: {} diff --git a/test/sendable/builtins/Array/from/iter-map-fn-return.js b/test/sendable/builtins/Array/from/iter-map-fn-return.js index eca892bd958..332d04b881c 100644 --- a/test/sendable/builtins/Array/from/iter-map-fn-return.js +++ b/test/sendable/builtins/Array/from/iter-map-fn-return.js @@ -31,7 +31,7 @@ info: | features: [Symbol.iterator] ---*/ -var thisVals = []; +var thisVals = new SendableArray(); var nextResult = { done: false, value: {} diff --git a/test/sendable/builtins/Array/from/iter-map-fn-this-arg.js b/test/sendable/builtins/Array/from/iter-map-fn-this-arg.js index 08a7f7881a1..d3c360f4715 100644 --- a/test/sendable/builtins/Array/from/iter-map-fn-this-arg.js +++ b/test/sendable/builtins/Array/from/iter-map-fn-this-arg.js @@ -29,7 +29,7 @@ info: | features: [Symbol.iterator] ---*/ -var thisVals = []; +var thisVals = new SendableArray(); var nextResult = { done: false, value: {} diff --git a/test/sendable/builtins/Array/from/iter-map-fn-this-non-strict.js b/test/sendable/builtins/Array/from/iter-map-fn-this-non-strict.js index 64ee69567ce..ffb619a3078 100644 --- a/test/sendable/builtins/Array/from/iter-map-fn-this-non-strict.js +++ b/test/sendable/builtins/Array/from/iter-map-fn-this-non-strict.js @@ -30,7 +30,7 @@ features: [Symbol.iterator] flags: [noStrict] ---*/ -var thisVals = []; +var thisVals = new SendableArray(); var nextResult = { done: false, value: {} diff --git a/test/sendable/builtins/Array/from/iter-map-fn-this-strict.js b/test/sendable/builtins/Array/from/iter-map-fn-this-strict.js index 831f5045ccc..59b07371cc3 100644 --- a/test/sendable/builtins/Array/from/iter-map-fn-this-strict.js +++ b/test/sendable/builtins/Array/from/iter-map-fn-this-strict.js @@ -30,7 +30,7 @@ features: [Symbol.iterator] flags: [onlyStrict] ---*/ -var thisVals = []; +var thisVals = new SendableArray(); var nextResult = { done: false, value: {} diff --git a/test/sendable/builtins/Array/from/mapfn-throws-exception.js b/test/sendable/builtins/Array/from/mapfn-throws-exception.js index 0c8e13a26f1..ee7225725ea 100644 --- a/test/sendable/builtins/Array/from/mapfn-throws-exception.js +++ b/test/sendable/builtins/Array/from/mapfn-throws-exception.js @@ -18,7 +18,7 @@ esid: sec-SendableArray.from es6id: 22.1.2.1 ---*/ -var array = [2, 4, 8, 16, 32, 64, 128]; +var array = new SendableArray(2, 4, 8, 16, 32, 64, 128); function mapFnThrows(value, index, obj) { throw new Test262Error(); } diff --git a/test/sendable/builtins/Array/from/source-array-boundary.js b/test/sendable/builtins/Array/from/source-array-boundary.js index c1e055ea2ee..1364dd81750 100644 --- a/test/sendable/builtins/Array/from/source-array-boundary.js +++ b/test/sendable/builtins/Array/from/source-array-boundary.js @@ -18,7 +18,7 @@ esid: sec-SendableArray.from es6id: 22.1.2.1 ---*/ -var array = [Number.MAX_VALUE, Number.MIN_VALUE, Number.NaN, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY]; +var array = new SendableArray(Number.MAX_VALUE, Number.MIN_VALUE, Number.NaN, Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY); var arrayIndex = -1; function mapFn(value, index) { this.arrayIndex++; diff --git a/test/sendable/builtins/Array/from/source-object-iterator-1.js b/test/sendable/builtins/Array/from/source-object-iterator-1.js index c76e9c12cc1..17c06ced169 100644 --- a/test/sendable/builtins/Array/from/source-object-iterator-1.js +++ b/test/sendable/builtins/Array/from/source-object-iterator-1.js @@ -19,7 +19,7 @@ es6id: 22.1.2.1 features: [Symbol.iterator] ---*/ -var array = [2, 4, 8, 16, 32, 64, 128]; +var array = new SendableArray(2, 4, 8, 16, 32, 64, 128); var obj = { [Symbol.iterator]() { return { diff --git a/test/sendable/builtins/Array/from/source-object-iterator-2.js b/test/sendable/builtins/Array/from/source-object-iterator-2.js index e38ccae6408..db59c7c555e 100644 --- a/test/sendable/builtins/Array/from/source-object-iterator-2.js +++ b/test/sendable/builtins/Array/from/source-object-iterator-2.js @@ -19,7 +19,7 @@ es6id: 22.1.2.1 features: [Symbol.iterator] ---*/ -var array = [2, 4, 8, 16, 32, 64, 128]; +var array = new SendableArray(2, 4, 8, 16, 32, 64, 128); var obj = { [Symbol.iterator]() { return { diff --git a/test/sendable/builtins/Array/from/source-object-length.js b/test/sendable/builtins/Array/from/source-object-length.js index 4c4c6be09dd..ce127de8cec 100644 --- a/test/sendable/builtins/Array/from/source-object-length.js +++ b/test/sendable/builtins/Array/from/source-object-length.js @@ -20,8 +20,8 @@ esid: sec-SendableArray.from es6id: 22.1.2.1 ---*/ -var array = [2, 4, 0, 16]; -var expectedArray = [2, 4, , 16]; +var array = new SendableArray(2, 4, 0, 16); +var expectedArray = new SendableArray(2, 4, undefined, 16); var obj = { length: 4, 0: 2, diff --git a/test/sendable/builtins/Array/from/source-object-missing.js b/test/sendable/builtins/Array/from/source-object-missing.js index 3099391c0cf..408039d0166 100644 --- a/test/sendable/builtins/Array/from/source-object-missing.js +++ b/test/sendable/builtins/Array/from/source-object-missing.js @@ -18,7 +18,7 @@ esid: sec-SendableArray.from es6id: 22.1.2.1 ---*/ -var array = [2, 4, , 16]; +var array = new SendableArray(2, 4, undefined, 16); var obj = { length: 4, 0: 2, -- Gitee From 789d94652e23e2c2d09d9a6aaa98361a9a7dd3e2 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 21 Jan 2025 15:14:14 +0800 Subject: [PATCH 88/93] update Signed-off-by: zhuzhihui7 --- .../builtins/Array/from/calling-from-valid-1-onlyStrict.js | 2 +- test/sendable/builtins/Array/from/calling-from-valid-2.js | 2 +- test/sendable/builtins/Array/from/iter-map-fn-args.js | 2 +- test/sendable/builtins/Array/from/iter-map-fn-this-arg.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/sendable/builtins/Array/from/calling-from-valid-1-onlyStrict.js b/test/sendable/builtins/Array/from/calling-from-valid-1-onlyStrict.js index 3bbd1bbeef4..6aef93e63c2 100644 --- a/test/sendable/builtins/Array/from/calling-from-valid-1-onlyStrict.js +++ b/test/sendable/builtins/Array/from/calling-from-valid-1-onlyStrict.js @@ -40,7 +40,7 @@ var list = { '2': 43, length: 3 }; -var calls = new SendableArray(); +var calls = []; function mapFn(value) { calls.push({ args: arguments, diff --git a/test/sendable/builtins/Array/from/calling-from-valid-2.js b/test/sendable/builtins/Array/from/calling-from-valid-2.js index b9f66fc6725..311e2c1e48e 100644 --- a/test/sendable/builtins/Array/from/calling-from-valid-2.js +++ b/test/sendable/builtins/Array/from/calling-from-valid-2.js @@ -39,7 +39,7 @@ var list = { '2': 43, length: 3 }; -var calls = new SendableArray(); +var calls = []; var thisArg = {}; function mapFn(value) { calls.push({ diff --git a/test/sendable/builtins/Array/from/iter-map-fn-args.js b/test/sendable/builtins/Array/from/iter-map-fn-args.js index a125d389a59..0dad143ea12 100644 --- a/test/sendable/builtins/Array/from/iter-map-fn-args.js +++ b/test/sendable/builtins/Array/from/iter-map-fn-args.js @@ -32,7 +32,7 @@ info: | features: [Symbol.iterator] ---*/ -var args = new SendableArray(); +var args = []; var firstResult = { done: false, value: {} diff --git a/test/sendable/builtins/Array/from/iter-map-fn-this-arg.js b/test/sendable/builtins/Array/from/iter-map-fn-this-arg.js index d3c360f4715..08a7f7881a1 100644 --- a/test/sendable/builtins/Array/from/iter-map-fn-this-arg.js +++ b/test/sendable/builtins/Array/from/iter-map-fn-this-arg.js @@ -29,7 +29,7 @@ info: | features: [Symbol.iterator] ---*/ -var thisVals = new SendableArray(); +var thisVals = []; var nextResult = { done: false, value: {} -- Gitee From 5bbafabca5a6e96d36baf10b8d3c4ab6b4f85a62 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 21 Jan 2025 15:35:32 +0800 Subject: [PATCH 89/93] add array-length Signed-off-by: zhuzhihui7 --- .../Array/length/S15.4.5.1_A1.1_T1.js | 6 +++--- .../Array/length/S15.4.5.1_A1.1_T2.js | 8 ++++---- .../Array/length/S15.4.5.1_A1.2_T1.js | 2 +- .../Array/length/S15.4.5.1_A1.2_T3.js | 2 +- .../Array/length/S15.4.5.1_A1.3_T1.js | 12 +++++------ .../Array/length/S15.4.5.1_A1.3_T2.js | 16 +++++++-------- .../builtins/Array/length/S15.4.5.2_A3_T4.js | 2 +- ...fine-own-prop-length-coercion-order-set.js | 14 ++++++------- .../define-own-prop-length-coercion-order.js | 20 +++++++++++-------- .../length/define-own-prop-length-error.js | 4 ++-- .../define-own-prop-length-no-value-order.js | 20 +++++++++++-------- .../define-own-prop-length-overflow-order.js | 14 +++++++------ .../define-own-prop-length-overflow-realm.js | 9 +++++---- 13 files changed, 70 insertions(+), 59 deletions(-) diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T1.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T1.js index 8f78dccbfa9..a82524b23fd 100644 --- a/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T1.js +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T1.js @@ -20,7 +20,7 @@ description: length in [4294967296, -1, 1.5] ---*/ try { - var x = []; + var x = new SendableArray(); x.length = 4294967296; throw new Test262Error('#1.1: x = []; x.length = 4294967296 throw RangeError. Actual: x.length === ' + (x.length)); } catch (e) { @@ -31,7 +31,7 @@ try { ); } try { - x = []; + x = new SendableArray(); x.length = -1; throw new Test262Error('#2.1: x = []; x.length = -1 throw RangeError. Actual: x.length === ' + (x.length)); } catch (e) { @@ -42,7 +42,7 @@ try { ); } try { - x = []; + x = new SendableArray(); x.length = 1.5; throw new Test262Error('#3.1: x = []; x.length = 1.5 throw RangeError. Actual: x.length === ' + (x.length)); } catch (e) { diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T2.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T2.js index 16ff8c40192..8dad3d185d5 100644 --- a/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T2.js +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T2.js @@ -20,7 +20,7 @@ description: length in [NaN, Infinity, -Infinity, undefined] ---*/ try { - var x = []; + var x = new SendableArray(); x.length = NaN; throw new Test262Error('#1.1: x = []; x.length = NaN throw RangeError. Actual: x.length === ' + (x.length)); } catch (e) { @@ -31,7 +31,7 @@ try { ); } try { - x = []; + x = new SendableArray(); x.length = Number.POSITIVE_INFINITY; throw new Test262Error('#2.1: x = []; x.length = Number.POSITIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length)); } catch (e) { @@ -42,7 +42,7 @@ try { ); } try { - x = []; + x = new SendableArray(); x.length = Number.NEGATIVE_INFINITY; throw new Test262Error('#3.1: x = []; x.length = Number.NEGATIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length)); } catch (e) { @@ -53,7 +53,7 @@ try { ); } try { - x = []; + x = new SendableArray(); x.length = undefined; throw new Test262Error('#4.1: x = []; x.length = undefined throw RangeError. Actual: x.length === ' + (x.length)); } catch (e) { diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T1.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T1.js index bb3902950f3..4f79425741c 100644 --- a/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T1.js +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T1.js @@ -23,7 +23,7 @@ es5id: 15.4.5.1_A1.2_T1 description: Change length of array ---*/ -var x = [0, , 2, , 4]; +var x = new SendableArray(0, undefined, 2, undefined, 4); x.length = 4; assert.sameValue(x[4], undefined, 'The value of x[4] is expected to equal undefined'); x.length = 3; diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T3.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T3.js index 0d3ae77eddf..5cccdc02672 100644 --- a/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T3.js +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T3.js @@ -24,7 +24,7 @@ description: Checking an inherited property ---*/ SendableArray.prototype[2] = 2; -var x = [0, 1]; +var x = new SendableArray(0, 1); x.length = 3; assert.sameValue(x.hasOwnProperty('2'), false, 'x.hasOwnProperty("2") must return false'); x.length = 2; diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T1.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T1.js index 1bf4c7e31b0..f7ac8281062 100644 --- a/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T1.js +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T1.js @@ -19,21 +19,21 @@ es5id: 15.4.5.1_A1.3_T1 description: length is object or primitve ---*/ -var x = []; +var x = new SendableArray(); x.length = true; assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); -x = [0]; +x = new SendableArray(0); x.length = null; assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); -x = [0]; +x = new SendableArray(0); x.length = new Boolean(false); assert.sameValue(x.length, 0, 'The value of x.length is expected to be 0'); -x = []; +x = new SendableArray(); x.length = new Number(1); assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); -x = []; +x = new SendableArray(); x.length = "1"; assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); -x = []; +x = new SendableArray(); x.length = new String("1"); assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T2.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T2.js index 3b1afff947e..f46b14dfac0 100644 --- a/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T2.js +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T2.js @@ -19,14 +19,14 @@ es5id: 15.4.5.1_A1.3_T2 description: Uint32 use ToNumber and ToPrimitve ---*/ -var x = []; +var x = new SendableArray(); x.length = { valueOf: function() { return 2 } }; assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); -x = []; +x = new SendableArray(); x.length = { valueOf: function() { return 2 @@ -36,7 +36,7 @@ x.length = { } }; assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); -x = []; +x = new SendableArray(); x.length = { valueOf: function() { return 2 @@ -47,7 +47,7 @@ x.length = { }; assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); try { - x = []; + x = new SendableArray(); x.length = { valueOf: function() { return 2 @@ -61,14 +61,14 @@ try { catch (e) { assert.notSameValue(e, "error", 'The value of e is not "error"'); } -x = []; +x = new SendableArray(); x.length = { toString: function() { return 1 } }; assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); -x = []; +x = new SendableArray(); x.length = { valueOf: function() { return {} @@ -79,7 +79,7 @@ x.length = { } assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); try { - x = []; + x = new SendableArray(); x.length = { valueOf: function() { throw "error" @@ -95,7 +95,7 @@ catch (e) { assert.sameValue(e, "error", 'The value of e is expected to be "error"'); } try { - x = []; + x = new SendableArray(); x.length = { valueOf: function() { return {} diff --git a/test/sendable/builtins/Array/length/S15.4.5.2_A3_T4.js b/test/sendable/builtins/Array/length/S15.4.5.2_A3_T4.js index c54202d8049..b9c61031768 100644 --- a/test/sendable/builtins/Array/length/S15.4.5.2_A3_T4.js +++ b/test/sendable/builtins/Array/length/S15.4.5.2_A3_T4.js @@ -23,7 +23,7 @@ description: > is an array index ---*/ -var x = [0, 1, 2]; +var x = new SendableArray(0, 1, 2); x[4294967294] = 4294967294; x.length = 2; assert.sameValue(x[0], 0, 'The value of x[0] is expected to be 0'); diff --git a/test/sendable/builtins/Array/length/define-own-prop-length-coercion-order-set.js b/test/sendable/builtins/Array/length/define-own-prop-length-coercion-order-set.js index 2f85430637d..44c2ab0567f 100644 --- a/test/sendable/builtins/Array/length/define-own-prop-length-coercion-order-set.js +++ b/test/sendable/builtins/Array/length/define-own-prop-length-coercion-order-set.js @@ -26,23 +26,23 @@ features: [Symbol, Symbol.toPrimitive, Reflect, Reflect.set] includes: [compareArray.js] ---*/ -var SendableArray = [1, 2, 3]; -var hints = []; +var array = new SendableArray(1, 2, 3); +var hints = new SendableArray(); var length = {}; length[Symbol.toPrimitive] = function(hint) { hints.push(hint); - Object.defineProperty(SendableArray, "length", {writable: false}); + Object.defineProperty(array, "length", {writable: false}); return 0; }; assert.throws(TypeError, function() { "use strict"; - SendableArray.length = length; + array.length = length; }, '`"use strict"; SendableArray.length = length` throws a TypeError exception'); assert.compareArray(hints, ["number", "number"], 'The value of hints is expected to be ["number", "number"]'); -SendableArray = [1, 2, 3]; -hints = []; +array = new SendableArray(1, 2, 3); +hints = new SendableArray(); assert( - !Reflect.set(SendableArray, "length", length), + !Reflect.set(array, "length", length), 'The value of !Reflect.set(SendableArray, "length", length) is expected to be true' ); assert.compareArray(hints, ["number", "number"], 'The value of hints is expected to be ["number", "number"]'); diff --git a/test/sendable/builtins/Array/length/define-own-prop-length-coercion-order.js b/test/sendable/builtins/Array/length/define-own-prop-length-coercion-order.js index 16617c1de2d..d074b762232 100644 --- a/test/sendable/builtins/Array/length/define-own-prop-length-coercion-order.js +++ b/test/sendable/builtins/Array/length/define-own-prop-length-coercion-order.js @@ -32,26 +32,30 @@ info: | features: [Reflect] ---*/ -var SendableArray = [1, 2]; +var array = new SendableArray(1, 2); var valueOfCalls = 0; var length = { valueOf: function() { valueOfCalls += 1; if (valueOfCalls !== 1) { // skip first coercion at step 3 - Object.defineProperty(SendableArray, "length", {writable: false}); + Object.defineProperty(array, "length", {writable: false}); } - return SendableArray.length; + return array.length; }, }; + assert.throws(TypeError, function() { - Object.defineProperty(SendableArray, "length", {value: length, writable: true}); -}, 'Object.defineProperty(SendableArray, "length", {value: length, writable: true}) throws a TypeError exception'); + Object.defineProperty(array, "length", {value: length, writable: true}); +}, 'Object.defineProperty(array, "length", {value: length, writable: true}) throws a TypeError exception'); assert.sameValue(valueOfCalls, 2, 'The value of valueOfCalls is expected to be 2'); -SendableArray = [1, 2]; + + +array = new SendableArray(1, 2); valueOfCalls = 0; + assert( - !Reflect.defineProperty(SendableArray, "length", {value: length, writable: true}), - 'The value of !Reflect.defineProperty(SendableArray, "length", {value: length, writable: true}) is expected to be true' + !Reflect.defineProperty(array, "length", {value: length, writable: true}), + 'The value of !Reflect.defineProperty(array, "length", {value: length, writable: true}) is expected to be true' ); assert.sameValue(valueOfCalls, 2, 'The value of valueOfCalls is expected to be 2'); diff --git a/test/sendable/builtins/Array/length/define-own-prop-length-error.js b/test/sendable/builtins/Array/length/define-own-prop-length-error.js index 68e500ade9f..bcf2f6226df 100644 --- a/test/sendable/builtins/Array/length/define-own-prop-length-error.js +++ b/test/sendable/builtins/Array/length/define-own-prop-length-error.js @@ -22,9 +22,9 @@ info: | ---*/ assert.throws(RangeError, function () { - Object.defineProperty([], 'length', { value: -1, configurable: true }); + Object.defineProperty(new SendableArray(), 'length', { value: -1, configurable: true }); }); assert.throws(RangeError, function () { // the string is intentionally "computed" here to ensure there are no optimization bugs - Object.defineProperty([], 'len' + 'gth', { value: -1, configurable: true }); + Object.defineProperty(new SendableArray(), 'len' + 'gth', { value: -1, configurable: true }); }); diff --git a/test/sendable/builtins/Array/length/define-own-prop-length-no-value-order.js b/test/sendable/builtins/Array/length/define-own-prop-length-no-value-order.js index 9ce2fe056d9..5b3895de4c3 100644 --- a/test/sendable/builtins/Array/length/define-own-prop-length-no-value-order.js +++ b/test/sendable/builtins/Array/length/define-own-prop-length-no-value-order.js @@ -36,25 +36,29 @@ features: [Reflect] ---*/ assert.throws(TypeError, function() { - Object.defineProperty([], "length", {configurable: true}); + Object.defineProperty(new SendableArray(), "length", {configurable: true}); }, 'Object.defineProperty([], "length", {configurable: true}) throws a TypeError exception'); + assert( - !Reflect.defineProperty([], "length", {enumerable: true}), + !Reflect.defineProperty(new SendableArray(), "length", {enumerable: true}), 'The value of !Reflect.defineProperty([], "length", {enumerable: true}) is expected to be true' ); + assert.throws(TypeError, function() { - Object.defineProperty([], "length", { + Object.defineProperty(new SendableArray(), "length", { get: function() { throw new Test262Error("[[Get]] shouldn't be called"); }, }); }, 'Object.defineProperty([], "length", {get: function() {throw new Test262Error("[[Get]] shouldn"t be called");},}) throws a TypeError exception'); + assert( - !Reflect.defineProperty([], "length", {set: function(_value) {}}), + !Reflect.defineProperty(new SendableArray(), "length", {set: function(_value) {}}), 'The value of !Reflect.defineProperty([], "length", {set: function(_value) {}}) is expected to be true' ); -var SendableArray = []; -Object.defineProperty(SendableArray, "length", {writable: false}); + +var array = new SendableArray(); +Object.defineProperty(array, "length", {writable: false}); assert.throws(TypeError, function() { - Object.defineProperty(SendableArray, "length", {writable: true}); -}, 'Object.defineProperty(SendableArray, "length", {writable: true}) throws a TypeError exception'); + Object.defineProperty(array, "length", {writable: true}); +}, 'Object.defineProperty(array, "length", {writable: true}) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/length/define-own-prop-length-overflow-order.js b/test/sendable/builtins/Array/length/define-own-prop-length-overflow-order.js index 8195ba80767..97e1f775127 100644 --- a/test/sendable/builtins/Array/length/define-own-prop-length-overflow-order.js +++ b/test/sendable/builtins/Array/length/define-own-prop-length-overflow-order.js @@ -24,13 +24,15 @@ info: | ---*/ assert.throws(RangeError, function() { - Object.defineProperty([], "length", {value: -1, configurable: true}); + Object.defineProperty(new SendableArray(), "length", {value: -1, configurable: true}); }, 'Object.defineProperty([], "length", {value: -1, configurable: true}) throws a RangeError exception'); + assert.throws(RangeError, function() { - Object.defineProperty([], "length", {value: NaN, enumerable: true}); + Object.defineProperty(new SendableArray(), "length", {value: NaN, enumerable: true}); }, 'Object.defineProperty([], "length", {value: NaN, enumerable: true}) throws a RangeError exception'); -var SendableArray = []; -Object.defineProperty(SendableArray, "length", {writable: false}); + +var array = new SendableArray(); +Object.defineProperty(array, "length", {writable: false}); assert.throws(RangeError, function() { - Object.defineProperty(SendableArray, "length", {value: Number.MAX_SAFE_INTEGER, writable: true}); -}, 'Object.defineProperty(SendableArray, "length", {value: Number.MAX_SAFE_INTEGER, writable: true}) throws a RangeError exception'); + Object.defineProperty(array, "length", {value: Number.MAX_SAFE_INTEGER, writable: true}); +}, 'Object.defineProperty(array, "length", {value: Number.MAX_SAFE_INTEGER, writable: true}) throws a RangeError exception'); diff --git a/test/sendable/builtins/Array/length/define-own-prop-length-overflow-realm.js b/test/sendable/builtins/Array/length/define-own-prop-length-overflow-realm.js index 702c09b6862..c2a8efdd807 100644 --- a/test/sendable/builtins/Array/length/define-own-prop-length-overflow-realm.js +++ b/test/sendable/builtins/Array/length/define-own-prop-length-overflow-realm.js @@ -24,8 +24,9 @@ info: | features: [cross-realm] ---*/ -var OArray = $262.createRealm().global.Array; -var SendableArray = new OArray(); +var OArray = $262.createRealm().global.SendableArray; +var array = new OArray(); + assert.throws(RangeError, function() { - SendableArray.length = 4294967296; -}, 'SendableArray.length = 4294967296 throws a RangeError exception'); + array.length = 4294967296; +}, 'array.length = 4294967296 throws a RangeError exception'); -- Gitee From c80fa54a64e627f4b4a086012b4901d5e0e76343 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 21 Jan 2025 15:53:17 +0800 Subject: [PATCH 90/93] add length again Signed-off-by: zhuzhihui7 --- .../builtins/Array/isArray/15.4.3.2-0-3.js | 2 +- .../builtins/Array/length/S15.4.5.1_A1.1_T1.js | 6 +++--- .../builtins/Array/length/S15.4.5.1_A1.1_T2.js | 8 ++++---- .../builtins/Array/length/S15.4.5.1_A1.2_T1.js | 2 +- .../builtins/Array/length/S15.4.5.1_A1.3_T2.js | 16 ++++++++-------- .../builtins/Array/length/S15.4.5.2_A3_T4.js | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/sendable/builtins/Array/isArray/15.4.3.2-0-3.js b/test/sendable/builtins/Array/isArray/15.4.3.2-0-3.js index 74314e9e030..d0ec834464e 100644 --- a/test/sendable/builtins/Array/isArray/15.4.3.2-0-3.js +++ b/test/sendable/builtins/Array/isArray/15.4.3.2-0-3.js @@ -18,4 +18,4 @@ es5id: 15.4.3.2-0-3 description: SendableArray.isArray return true if its argument is an Array ---*/ -assert.sameValue(SendableArray.isArray([]), true, 'SendableArray.isArray([]) must return true'); +assert.sameValue(SendableArray.isArray(), true, 'SendableArray.isArray([]) must return true'); diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T1.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T1.js index a82524b23fd..8f78dccbfa9 100644 --- a/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T1.js +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T1.js @@ -20,7 +20,7 @@ description: length in [4294967296, -1, 1.5] ---*/ try { - var x = new SendableArray(); + var x = []; x.length = 4294967296; throw new Test262Error('#1.1: x = []; x.length = 4294967296 throw RangeError. Actual: x.length === ' + (x.length)); } catch (e) { @@ -31,7 +31,7 @@ try { ); } try { - x = new SendableArray(); + x = []; x.length = -1; throw new Test262Error('#2.1: x = []; x.length = -1 throw RangeError. Actual: x.length === ' + (x.length)); } catch (e) { @@ -42,7 +42,7 @@ try { ); } try { - x = new SendableArray(); + x = []; x.length = 1.5; throw new Test262Error('#3.1: x = []; x.length = 1.5 throw RangeError. Actual: x.length === ' + (x.length)); } catch (e) { diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T2.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T2.js index 8dad3d185d5..16ff8c40192 100644 --- a/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T2.js +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.1_T2.js @@ -20,7 +20,7 @@ description: length in [NaN, Infinity, -Infinity, undefined] ---*/ try { - var x = new SendableArray(); + var x = []; x.length = NaN; throw new Test262Error('#1.1: x = []; x.length = NaN throw RangeError. Actual: x.length === ' + (x.length)); } catch (e) { @@ -31,7 +31,7 @@ try { ); } try { - x = new SendableArray(); + x = []; x.length = Number.POSITIVE_INFINITY; throw new Test262Error('#2.1: x = []; x.length = Number.POSITIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length)); } catch (e) { @@ -42,7 +42,7 @@ try { ); } try { - x = new SendableArray(); + x = []; x.length = Number.NEGATIVE_INFINITY; throw new Test262Error('#3.1: x = []; x.length = Number.NEGATIVE_INFINITY throw RangeError. Actual: x.length === ' + (x.length)); } catch (e) { @@ -53,7 +53,7 @@ try { ); } try { - x = new SendableArray(); + x = []; x.length = undefined; throw new Test262Error('#4.1: x = []; x.length = undefined throw RangeError. Actual: x.length === ' + (x.length)); } catch (e) { diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T1.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T1.js index 4f79425741c..bb3902950f3 100644 --- a/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T1.js +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.2_T1.js @@ -23,7 +23,7 @@ es5id: 15.4.5.1_A1.2_T1 description: Change length of array ---*/ -var x = new SendableArray(0, undefined, 2, undefined, 4); +var x = [0, , 2, , 4]; x.length = 4; assert.sameValue(x[4], undefined, 'The value of x[4] is expected to equal undefined'); x.length = 3; diff --git a/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T2.js b/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T2.js index f46b14dfac0..3b1afff947e 100644 --- a/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T2.js +++ b/test/sendable/builtins/Array/length/S15.4.5.1_A1.3_T2.js @@ -19,14 +19,14 @@ es5id: 15.4.5.1_A1.3_T2 description: Uint32 use ToNumber and ToPrimitve ---*/ -var x = new SendableArray(); +var x = []; x.length = { valueOf: function() { return 2 } }; assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); -x = new SendableArray(); +x = []; x.length = { valueOf: function() { return 2 @@ -36,7 +36,7 @@ x.length = { } }; assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); -x = new SendableArray(); +x = []; x.length = { valueOf: function() { return 2 @@ -47,7 +47,7 @@ x.length = { }; assert.sameValue(x.length, 2, 'The value of x.length is expected to be 2'); try { - x = new SendableArray(); + x = []; x.length = { valueOf: function() { return 2 @@ -61,14 +61,14 @@ try { catch (e) { assert.notSameValue(e, "error", 'The value of e is not "error"'); } -x = new SendableArray(); +x = []; x.length = { toString: function() { return 1 } }; assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); -x = new SendableArray(); +x = []; x.length = { valueOf: function() { return {} @@ -79,7 +79,7 @@ x.length = { } assert.sameValue(x.length, 1, 'The value of x.length is expected to be 1'); try { - x = new SendableArray(); + x = []; x.length = { valueOf: function() { throw "error" @@ -95,7 +95,7 @@ catch (e) { assert.sameValue(e, "error", 'The value of e is expected to be "error"'); } try { - x = new SendableArray(); + x = []; x.length = { valueOf: function() { return {} diff --git a/test/sendable/builtins/Array/length/S15.4.5.2_A3_T4.js b/test/sendable/builtins/Array/length/S15.4.5.2_A3_T4.js index b9c61031768..c54202d8049 100644 --- a/test/sendable/builtins/Array/length/S15.4.5.2_A3_T4.js +++ b/test/sendable/builtins/Array/length/S15.4.5.2_A3_T4.js @@ -23,7 +23,7 @@ description: > is an array index ---*/ -var x = new SendableArray(0, 1, 2); +var x = [0, 1, 2]; x[4294967294] = 4294967294; x.length = 2; assert.sameValue(x[0], 0, 'The value of x[0] is expected to be 0'); -- Gitee From 4f145cbadefee253cfd414594f3b827325853ad6 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 21 Jan 2025 16:05:24 +0800 Subject: [PATCH 91/93] prototype-at add Signed-off-by: zhuzhihui7 --- .../builtins/Array/prototype/at/index-argument-tointeger.js | 2 +- .../at/index-non-numeric-argument-tointeger-invalid.js | 2 +- .../Array/prototype/at/index-non-numeric-argument-tointeger.js | 2 +- .../builtins/Array/prototype/at/returns-item-relative-index.js | 2 +- test/sendable/builtins/Array/prototype/at/returns-item.js | 2 +- .../at/returns-undefined-for-holes-in-sparse-arrays.js | 2 +- .../prototype/at/returns-undefined-for-out-of-range-index.js | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js b/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js index 089ca96c7f0..5466fbd3cdb 100644 --- a/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js +++ b/test/sendable/builtins/Array/prototype/at/index-argument-tointeger.js @@ -33,6 +33,6 @@ let index = { return 1; } }; -let a = [0,1,2,3]; +let a = new SendableArray(0,1,2,3); assert.sameValue(a.at(index), 1, 'a.at({valueOf() {valueOfCallCount++; return 1;}}) must return 1'); assert.sameValue(valueOfCallCount, 1, 'The value of valueOfCallCount is expected to be 1'); diff --git a/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js b/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js index 87e0b9db304..8114042a4da 100644 --- a/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js +++ b/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger-invalid.js @@ -26,7 +26,7 @@ assert.sameValue( 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); -let a = [0,1,2,3]; +let a = new SendableArray(0,1,2,3); assert.throws(TypeError, () => { a.at(Symbol()); }, 'a.at(Symbol()) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger.js b/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger.js index 0511767ccdf..160e7bbd468 100644 --- a/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger.js +++ b/test/sendable/builtins/Array/prototype/at/index-non-numeric-argument-tointeger.js @@ -26,7 +26,7 @@ assert.sameValue( 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); -let a = [0,1,2,3]; +let a = new SendableArray(0,1,2,3); assert.sameValue(a.at(false), 0, 'a.at(false) must return 0'); assert.sameValue(a.at(null), 0, 'a.at(null) must return 0'); assert.sameValue(a.at(undefined), 0, 'a.at(undefined) must return 0'); diff --git a/test/sendable/builtins/Array/prototype/at/returns-item-relative-index.js b/test/sendable/builtins/Array/prototype/at/returns-item-relative-index.js index c45fd47d6e6..ae5a0c42685 100644 --- a/test/sendable/builtins/Array/prototype/at/returns-item-relative-index.js +++ b/test/sendable/builtins/Array/prototype/at/returns-item-relative-index.js @@ -34,7 +34,7 @@ assert.sameValue( 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); -let a = [1, 2, 3, 4, ,5]; +let a = new SendableArray(1, 2, 3, 4, undefined, 5); assert.sameValue(a.at(0), 1, 'a.at(0) must return 1'); assert.sameValue(a.at(-1), 5, 'a.at(-1) must return 5'); assert.sameValue(a.at(-2), undefined, 'a.at(-2) returns undefined'); diff --git a/test/sendable/builtins/Array/prototype/at/returns-item.js b/test/sendable/builtins/Array/prototype/at/returns-item.js index 374ba1422a1..bc4322174a0 100644 --- a/test/sendable/builtins/Array/prototype/at/returns-item.js +++ b/test/sendable/builtins/Array/prototype/at/returns-item.js @@ -34,7 +34,7 @@ assert.sameValue( 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); -let a = [1, 2, 3, 4,,5]; +let a = new SendableArray(1, 2, 3, 4, undefined, 5); assert.sameValue(a.at(0), 1, 'a.at(0) must return 1'); assert.sameValue(a.at(1), 2, 'a.at(1) must return 2'); assert.sameValue(a.at(2), 3, 'a.at(2) must return 3'); diff --git a/test/sendable/builtins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js b/test/sendable/builtins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js index f46de3ab4d1..9fad78476f5 100644 --- a/test/sendable/builtins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js +++ b/test/sendable/builtins/Array/prototype/at/returns-undefined-for-holes-in-sparse-arrays.js @@ -34,7 +34,7 @@ assert.sameValue( 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); -let a = [0, 1, , 3, 4, , 6]; +let a = new SendableArray(0, 1, undefined, 3, 4, undefined, 6); assert.sameValue(a.at(0), 0, 'a.at(0) must return 0'); assert.sameValue(a.at(1), 1, 'a.at(1) must return 1'); assert.sameValue(a.at(2), undefined, 'a.at(2) returns undefined'); diff --git a/test/sendable/builtins/Array/prototype/at/returns-undefined-for-out-of-range-index.js b/test/sendable/builtins/Array/prototype/at/returns-undefined-for-out-of-range-index.js index 0880883df9c..e4ae5fdfb8d 100644 --- a/test/sendable/builtins/Array/prototype/at/returns-undefined-for-out-of-range-index.js +++ b/test/sendable/builtins/Array/prototype/at/returns-undefined-for-out-of-range-index.js @@ -26,7 +26,7 @@ assert.sameValue( 'function', 'The value of `typeof Array.prototype.at` is expected to be "function"' ); -let a = []; +let a = new SendableArray(); assert.sameValue(a.at(-2), undefined, 'a.at(-2) returns undefined'); // wrap around the end assert.sameValue(a.at(0), undefined, 'a.at(0) returns undefined'); assert.sameValue(a.at(1), undefined, 'a.at(1) returns undefined'); -- Gitee From 291c5ce50c401d7ce36504802670764188359e65 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 21 Jan 2025 16:32:28 +0800 Subject: [PATCH 92/93] add concat Signed-off-by: zhuzhihui7 --- .../Array/prototype/concat/S15.4.4.4_A1_T2.js | 2 +- .../Array/prototype/concat/S15.4.4.4_A1_T3.js | 2 +- .../Array/prototype/concat/S15.4.4.4_A1_T4.js | 2 +- .../Array/prototype/concat/S15.4.4.4_A3_T1.js | 2 +- .../Array/prototype/concat/S15.4.4.4_A3_T2.js | 2 +- .../Array/prototype/concat/S15.4.4.4_A3_T3.js | 2 +- .../concat/arg-length-exceeding-integer-limit.js | 4 ++-- .../concat/arg-length-near-integer-limit.js | 2 +- .../concat_array-like-length-to-string-throws.js | 2 +- .../concat_array-like-length-value-of-throws.js | 2 +- ...ncat_array-like-primitive-non-number-length.js | 4 ++-- .../concat/concat_array-like-string-length.js | 2 +- .../concat/concat_array-like-to-length-throws.js | 2 +- .../concat/concat_holey-sloppy-arguments.js | 2 +- .../prototype/concat/concat_length-throws.js | 2 +- .../concat/concat_sloppy-arguments-throws.js | 2 +- .../concat/concat_sloppy-arguments-with-dupes.js | 4 ++-- .../prototype/concat/concat_sloppy-arguments.js | 4 ++-- .../concat/concat_spreadable-number-wrapper.js | 10 +++++----- .../concat/concat_spreadable-sparse-object.js | 2 +- .../prototype/concat/concat_strict-arguments.js | 4 ++-- .../prototype/concat/create-ctor-non-object.js | 8 ++++---- .../prototype/concat/create-ctor-poisoned.js | 2 +- .../concat/create-proto-from-ctor-realm-array.js | 15 +++++++++------ .../create-proto-from-ctor-realm-non-array.js | 11 +++++++---- .../Array/prototype/concat/create-proxy.js | 11 +++++++---- .../prototype/concat/create-species-abrupt.js | 2 +- .../prototype/concat/create-species-non-ctor.js | 2 +- .../create-species-non-extensible-spreadable.js | 2 +- .../concat/create-species-non-extensible.js | 2 +- .../Array/prototype/concat/create-species-null.js | 2 +- .../prototype/concat/create-species-poisoned.js | 2 +- .../prototype/concat/create-species-undef.js | 2 +- ...s-with-non-configurable-property-spreadable.js | 2 +- ...eate-species-with-non-configurable-property.js | 2 +- ...ecies-with-non-writable-property-spreadable.js | 2 +- .../create-species-with-non-writable-property.js | 2 +- .../Array/prototype/concat/create-species.js | 4 ++-- .../concat/is-concat-spreadable-get-order.js | 4 ++-- ...is-concat-spreadable-is-array-proxy-revoked.js | 2 +- .../concat/is-concat-spreadable-proxy-revoked.js | 2 +- .../concat/is-concat-spreadable-proxy.js | 4 ++-- .../concat/is-concat-spreadable-val-falsey.js | 10 +++++----- .../concat/is-concat-spreadable-val-truthy.js | 10 +++++----- .../concat/is-concat-spreadable-val-undefined.js | 4 ++-- 45 files changed, 89 insertions(+), 80 deletions(-) diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js index 13a80f3ea6c..12b06d51b41 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js @@ -22,7 +22,7 @@ es5id: 15.4.4.4_A1_T2 description: Checking this algorithm, items are objects and primitives ---*/ -var x = [0]; +var x = new SendableArray(0); var y = new Object(); var z = new SendableArray(1, 2); var arr = x.concat(y, z, -1, true, "NaN"); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T3.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T3.js index d879bb2e20a..377788fff3f 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T3.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T3.js @@ -22,7 +22,7 @@ es5id: 15.4.4.4_A1_T3 description: Checking this algorithm with no items ---*/ -var x = [0, 1]; +var x = new SendableArray(0, 1); var arr = x.concat(); arr.getClass = Object.prototype.toString; assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T4.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T4.js index 2c5ceed5543..5d442d37ecc 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T4.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T4.js @@ -22,7 +22,7 @@ es5id: 15.4.4.4_A1_T4 description: Checking this algorithm, items are [], [,] ---*/ -var x = [, 1]; +var x = new SendableArray(undefined, 1); var arr = x.concat([], [, ]); arr.getClass = Object.prototype.toString; assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T1.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T1.js index dc5ce76240c..cba2730c951 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T1.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T1.js @@ -23,7 +23,7 @@ description: > ---*/ SendableArray.prototype[1] = 1; -var x = [0]; +var x = new SendableArray(0); x.length = 2; var arr = x.concat(); assert.sameValue(arr[0], 0, 'The value of arr[0] is expected to be 0'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T2.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T2.js index 5edc3e6d66f..2ee2075ea7e 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T2.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T2.js @@ -20,7 +20,7 @@ description: > checking whether non-ownProperties are seen, copied by Array.prototype.concat: Array.prototype[1] ---*/ -var a = [0]; +var a = new SendableArray(0); assert.sameValue(a.length, 1, 'The value of a.length is expected to be 1'); a.length = 3; assert.sameValue(a[1], undefined, 'The value of a[1] is expected to equal undefined'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T3.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T3.js index faca42ffbd0..5e523ec2a36 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T3.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T3.js @@ -21,7 +21,7 @@ description: > checking whether non-ownProperties are seen, copied by Array.prototype.concat: Object.prototype[1] ---*/ -var a = [0]; +var a = new SendableArray(0); assert.sameValue(a.length, 1, 'The value of a.length is expected to be 1'); a.length = 3; assert.sameValue(a[1], undefined, 'The value of a[1] is expected to equal undefined'); diff --git a/test/sendable/builtins/Array/prototype/concat/arg-length-exceeding-integer-limit.js b/test/sendable/builtins/Array/prototype/concat/arg-length-exceeding-integer-limit.js index e98d363be71..40e2f257ed7 100644 --- a/test/sendable/builtins/Array/prototype/concat/arg-length-exceeding-integer-limit.js +++ b/test/sendable/builtins/Array/prototype/concat/arg-length-exceeding-integer-limit.js @@ -34,7 +34,7 @@ var spreadableLengthOutOfRange = {}; spreadableLengthOutOfRange.length = Number.MAX_SAFE_INTEGER; spreadableLengthOutOfRange[Symbol.isConcatSpreadable] = true; assert.throws(TypeError, function() { - [1].concat(spreadableLengthOutOfRange); + new SendableArray(1).concat(spreadableLengthOutOfRange); }, '[1].concat(spreadableLengthOutOfRange) throws a TypeError exception'); var proxyForArrayWithLengthOutOfRange = new Proxy([], { get: function(_target, key) { @@ -44,5 +44,5 @@ var proxyForArrayWithLengthOutOfRange = new Proxy([], { }, }); assert.throws(TypeError, function() { - [].concat(1, proxyForArrayWithLengthOutOfRange); + new SendableArray().concat(1, proxyForArrayWithLengthOutOfRange); }, '[].concat(1, proxyForArrayWithLengthOutOfRange) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/arg-length-near-integer-limit.js b/test/sendable/builtins/Array/prototype/concat/arg-length-near-integer-limit.js index 729b3b779ac..747892a9d01 100644 --- a/test/sendable/builtins/Array/prototype/concat/arg-length-near-integer-limit.js +++ b/test/sendable/builtins/Array/prototype/concat/arg-length-near-integer-limit.js @@ -43,5 +43,5 @@ var spreadableHasPoisonedIndex = { }; spreadableHasPoisonedIndex[Symbol.isConcatSpreadable] = true; assert.throws(Test262Error, function() { - [].concat(spreadableHasPoisonedIndex); + new SendableArray().concat(spreadableHasPoisonedIndex); }, '[].concat(spreadableHasPoisonedIndex) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-to-string-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-to-string-throws.js index 49a8ac137c6..264892bc2d4 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-to-string-throws.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-to-string-throws.js @@ -30,5 +30,5 @@ var objWithPoisonedLengthToString = { }; objWithPoisonedLengthToString[Symbol.isConcatSpreadable] = true; assert.throws(Test262Error, function() { - [].concat(objWithPoisonedLengthToString); + new SendableArray().concat(objWithPoisonedLengthToString); }, '[].concat(objWithPoisonedLengthToString) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-value-of-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-value-of-throws.js index 20d57091195..b3373890649 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-value-of-throws.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-value-of-throws.js @@ -30,5 +30,5 @@ var objWithPoisonedLengthValueOf = { }; objWithPoisonedLengthValueOf[Symbol.isConcatSpreadable] = true; assert.throws(Test262Error, function() { - [].concat(objWithPoisonedLengthValueOf); + new SendableArray().concat(objWithPoisonedLengthValueOf); }, '[].concat(objWithPoisonedLengthValueOf) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-primitive-non-number-length.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-primitive-non-number-length.js index 96a658d3ae8..a7e26b34e94 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_array-like-primitive-non-number-length.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-primitive-non-number-length.js @@ -30,11 +30,11 @@ obj.length = { }, valueOf: null }; -assert.compareArray([].concat(obj), [], '[].concat({"1": "A", "3": "B", "5": "C"}) must return []'); +assert.compareArray(new SendableArray().concat(obj), [], '[].concat({"1": "A", "3": "B", "5": "C"}) must return []'); obj.length = { toString: null, valueOf: function() { return "SIX"; } }; -assert.compareArray([].concat(obj), [], '[].concat({"1": "A", "3": "B", "5": "C"}) must return []'); +assert.compareArray(new SendableArray().concat(obj), [], '[].concat({"1": "A", "3": "B", "5": "C"}) must return []'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-string-length.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-string-length.js index 993ea37d45c..da49d7c2d07 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_array-like-string-length.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-string-length.js @@ -31,7 +31,7 @@ var obj2 = { "1": "1", "2": "2" }; -var arr = ["X", "Y", "Z"]; +var arr = new SendableArray("X", "Y", "Z"); var expected = [ void 0, "A", void 0, "B", void 0, "C", obj2, diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-to-length-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-to-length-throws.js index 9dd87a297db..8e33a6cab41 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_array-like-to-length-throws.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-to-length-throws.js @@ -33,7 +33,7 @@ var obj2 = { "1": "1", "2": "2" }; -var arr = ["X", "Y", "Z"]; +var arr = new SendableArray("X", "Y", "Z"); assert.throws(TypeError, function() { SendableArray.prototype.concat.call(spreadableWithBrokenLength, obj2, arr); }, 'SendableArray.prototype.concat.call(spreadableWithBrokenLength, obj2, arr) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_holey-sloppy-arguments.js b/test/sendable/builtins/Array/prototype/concat/concat_holey-sloppy-arguments.js index d8066ddcfae..2d1da22df9c 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_holey-sloppy-arguments.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_holey-sloppy-arguments.js @@ -23,6 +23,6 @@ var args = (function(a) { })(1, 2, 3); delete args[1]; args[Symbol.isConcatSpreadable] = true; -assert.compareArray([1, void 0, 3, 1, void 0, 3], [].concat(args, args), +assert.compareArray([1, void 0, 3, 1, void 0, 3], new SendableArray().concat(args, args), '[1, void 0, 3, 1, void 0, 3] must return the same value returned by [].concat(args, args)' ); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_length-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_length-throws.js index 8508593944c..559b15c26af 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_length-throws.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_length-throws.js @@ -25,7 +25,7 @@ Object.defineProperty(spreadablePoisonedLengthGetter, "length", { } }); assert.throws(Test262Error, function() { - [].concat(spreadablePoisonedLengthGetter); + new SendableArray().concat(spreadablePoisonedLengthGetter); }, '[].concat(spreadablePoisonedLengthGetter) throws a Test262Error exception'); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-throws.js index 92664877181..c332e3a3e62 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-throws.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-throws.js @@ -27,5 +27,5 @@ Object.defineProperty(args, 0, { }); args[Symbol.isConcatSpreadable] = true; assert.throws(Test262Error, function() { - return [].concat(args, args); + return new SendableArray().concat(args, args); }, 'return [].concat(args, args) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-with-dupes.js b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-with-dupes.js index 35dbd1de8a5..0f8d3f53a25 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-with-dupes.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-with-dupes.js @@ -23,12 +23,12 @@ var args = (function(a, a, a) { return arguments; })(1, 2, 3); args[Symbol.isConcatSpreadable] = true; -assert.compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3], +assert.compareArray(new SendableArray().concat(args, args), [1, 2, 3, 1, 2, 3], '[].concat((function(a, a, a) {return arguments;})(1, 2, 3), (function(a, a, a) {return arguments;})(1, 2, 3)) must return [1, 2, 3, 1, 2, 3]' ); Object.defineProperty(args, "length", { value: 6 }); -assert.compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0], +assert.compareArray(new SendableArray().concat(args), [1, 2, 3, void 0, void 0, void 0], '[].concat((function(a, a, a) {return arguments;})(1, 2, 3)) must return [1, 2, 3, void 0, void 0, void 0]' ); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments.js b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments.js index daee5f4c937..e67aa8821f4 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments.js @@ -22,12 +22,12 @@ var args = (function(a, b, c) { return arguments; })(1, 2, 3); args[Symbol.isConcatSpreadable] = true; -assert.compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3], +assert.compareArray(new SendableArray().concat(args, args), [1, 2, 3, 1, 2, 3], '[].concat((function(a, b, c) {return arguments;})(1, 2, 3), (function(a, b, c) {return arguments;})(1, 2, 3)) must return [1, 2, 3, 1, 2, 3]' ); Object.defineProperty(args, "length", { value: 6 }); -assert.compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0], +assert.compareArray(new SendableArray().concat(args), [1, 2, 3, void 0, void 0, void 0], '[].concat((function(a, b, c) {return arguments;})(1, 2, 3)) must return [1, 2, 3, void 0, void 0, void 0]' ); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-number-wrapper.js b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-number-wrapper.js index 63db81933a6..efe82792098 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-number-wrapper.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-number-wrapper.js @@ -20,26 +20,26 @@ features: [Symbol.isConcatSpreadable] ---*/ var num = new Number(true) // Number wrapper objects are not concat-spreadable by default -assert.compareArray([num], [].concat(num), '[num] must return the same value returned by [].concat(num)'); +assert.compareArray([num], new SendableArray().concat(num), '[num] must return the same value returned by [].concat(num)'); // Number wrapper objects may be individually concat-spreadable num[Symbol.isConcatSpreadable] = true; num.length = 3; num[0] = 1, num[1] = 2, num[2] = 3; -assert.compareArray([1, 2, 3], [].concat(num), '[1, 2, 3] must return the same value returned by [].concat(num)'); +assert.compareArray([1, 2, 3], new SendableArray().concat(num), '[1, 2, 3] must return the same value returned by [].concat(num)'); Number.prototype[Symbol.isConcatSpreadable] = true; // Number wrapper objects may be concat-spreadable -assert.compareArray([], [].concat(new Number(123)), +assert.compareArray([], new SendableArray().concat(new Number(123)), '[] must return the same value returned by [].concat(new Number(123))' ); Number.prototype[0] = 1; Number.prototype[1] = 2; Number.prototype[2] = 3; Number.prototype.length = 3; -assert.compareArray([1, 2, 3], [].concat(new Number(123)), +assert.compareArray([1, 2, 3], new SendableArray().concat(new Number(123)), '[1, 2, 3] must return the same value returned by [].concat(new Number(123))' ); // Number values are never concat-spreadable -assert.compareArray([true], [].concat(true), '[true] must return the same value returned by [].concat(true)'); +assert.compareArray([true], new SendableArray().concat(true), '[true] must return the same value returned by [].concat(true)'); delete Number.prototype[Symbol.isConcatSpreadable]; delete Number.prototype[0]; delete Number.prototype[1]; diff --git a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-sparse-object.js b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-sparse-object.js index 89b74357213..53513cafead 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-sparse-object.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-sparse-object.js @@ -26,6 +26,6 @@ assert.compareArray([void 0, void 0, void 0, void 0, void 0], [].concat(obj), '[void 0, void 0, void 0, void 0, void 0] must return the same value returned by [].concat(obj)' ); obj.length = 4000; -assert.compareArray(new SendableArray(4000), [].concat(obj), +assert.compareArray(new SendableArray(4000), new SendableArray().concat(obj), 'new SendableArray(4000) must return the same value returned by [].concat(obj)' ); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_strict-arguments.js b/test/sendable/builtins/Array/prototype/concat/concat_strict-arguments.js index 3017642060e..476a4077cb2 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_strict-arguments.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_strict-arguments.js @@ -23,12 +23,12 @@ var args = (function(a, b, c) { return arguments; })(1, 2, 3); args[Symbol.isConcatSpreadable] = true; -assert.compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3], +assert.compareArray(new SendableArray().concat(args, args), [1, 2, 3, 1, 2, 3], '[].concat("(function(a, b, c) {"use strict"; return arguments;})(1, 2, 3)", "(function(a, b, c) {"use strict"; return arguments;})(1, 2, 3)") must return [1, 2, 3, 1, 2, 3]' ); Object.defineProperty(args, "length", { value: 6 }); -assert.compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0], +assert.compareArray(new SendableArray().concat(args), [1, 2, 3, void 0, void 0, void 0], '[].concat("(function(a, b, c) {"use strict"; return arguments;})(1, 2, 3)") must return [1, 2, 3, void 0, void 0, void 0]' ); diff --git a/test/sendable/builtins/Array/prototype/concat/create-ctor-non-object.js b/test/sendable/builtins/Array/prototype/concat/create-ctor-non-object.js index 40fd42325ca..4151adbdb55 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-ctor-non-object.js +++ b/test/sendable/builtins/Array/prototype/concat/create-ctor-non-object.js @@ -27,22 +27,22 @@ info: | [...] 9. If IsConstructor(C) is false, throw a TypeError exception. ---*/ -var a = []; +var a = new SendableArray(); a.constructor = null; assert.throws(TypeError, function() { a.concat(); }, 'a.concat() throws a TypeError exception'); -a = []; +a = new SendableArray(); a.constructor = 1; assert.throws(TypeError, function() { a.concat(); }, 'a.concat() throws a TypeError exception'); -a = []; +a = new SendableArray(); a.constructor = 'string'; assert.throws(TypeError, function() { a.concat(); }, 'a.concat() throws a TypeError exception'); -a = []; +a = new SendableArray(); a.constructor = true; assert.throws(TypeError, function() { a.concat(); diff --git a/test/sendable/builtins/Array/prototype/concat/create-ctor-poisoned.js b/test/sendable/builtins/Array/prototype/concat/create-ctor-poisoned.js index 6b8a080a721..306639cc35a 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-ctor-poisoned.js +++ b/test/sendable/builtins/Array/prototype/concat/create-ctor-poisoned.js @@ -23,7 +23,7 @@ info: | 5. Let C be ? Get(originalArray, "constructor"). ---*/ -var a = []; +var a = new SendableArray(); Object.defineProperty(a, 'constructor', { get: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-array.js b/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-array.js index fc46d59a9e2..f832f26e608 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-array.js +++ b/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-array.js @@ -32,7 +32,7 @@ info: | features: [cross-realm, Symbol.species] ---*/ -var SendableArray = []; +var array = new SendableArray(); var callCount = 0; var OArray = $262.createRealm().global.SendableArray; var speciesDesc = { @@ -41,13 +41,16 @@ var speciesDesc = { } }; var result; -SendableArray.constructor = OArray; -Object.defineProperty(SendableArray, Symbol.species, speciesDesc); +array.constructor = OArray; + +Object.defineProperty(Array, Symbol.species, speciesDesc); Object.defineProperty(OArray, Symbol.species, speciesDesc); -result = SendableArray.concat(); + +result = array.concat(); + assert.sameValue( Object.getPrototypeOf(result), - SendableArray.prototype, - 'Object.getPrototypeOf(SendableArray.concat()) returns SendableArray.prototype' + Array.prototype, + 'Object.getPrototypeOf(array.concat()) returns Array.prototype' ); assert.sameValue(callCount, 0, 'The value of callCount is expected to be 0'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js b/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js index f6114e87f7f..96bc27438af 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js +++ b/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js @@ -32,7 +32,7 @@ info: | features: [cross-realm, Symbol.species] ---*/ -var SendableArray = []; +var array = new SendableArray(); var callCount = 0; var CustomCtor = function() {}; var OObject = $262.createRealm().global.Object; @@ -42,13 +42,16 @@ var speciesDesc = { } }; var result; -SendableArray.constructor = OObject; +array.constructor = OObject; OObject[Symbol.species] = CustomCtor; + Object.defineProperty(SendableArray, Symbol.species, speciesDesc); -result = SendableArray.concat(); + +result = array.concat(); + assert.sameValue( Object.getPrototypeOf(result), CustomCtor.prototype, - 'Object.getPrototypeOf(SendableArray.concat()) returns CustomCtor.prototype' + 'Object.getPrototypeOf(array.concat()) returns CustomCtor.prototype' ); assert.sameValue(callCount, 0, 'The value of callCount is expected to be 0'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-proxy.js b/test/sendable/builtins/Array/prototype/concat/create-proxy.js index d93b80b2059..cfcc1964b6c 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-proxy.js +++ b/test/sendable/builtins/Array/prototype/concat/create-proxy.js @@ -34,15 +34,18 @@ info: | features: [Proxy, Symbol.species] ---*/ -var SendableArray = []; +var array = new SendableArray(); var proxy = new Proxy(new Proxy(array, {}), {}); var Ctor = function() {}; var result; -SendableArray.constructor = function() {}; -SendableArray.constructor[Symbol.species] = Ctor; + +array.constructor = function() {}; +array.constructor[Symbol.species] = Ctor; + result = SendableArray.prototype.concat.call(proxy); + assert.sameValue( Object.getPrototypeOf(result), Ctor.prototype, - 'Object.getPrototypeOf(SendableArray.prototype.concat.call(proxy)) returns Ctor.prototype' + 'Object.getPrototypeOf(Array.prototype.concat.call(proxy)) returns Ctor.prototype' ); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-abrupt.js b/test/sendable/builtins/Array/prototype/concat/create-species-abrupt.js index ae29a921b02..0a1a692cc29 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-abrupt.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-abrupt.js @@ -33,7 +33,7 @@ features: [Symbol.species] var Ctor = function() { throw new Test262Error(); }; -var a = []; +var a = new SendableArray(); a.constructor = {}; a.constructor[Symbol.species] = Ctor; assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-non-ctor.js b/test/sendable/builtins/Array/prototype/concat/create-species-non-ctor.js index 507a2c2607c..76d075ae999 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-non-ctor.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-non-ctor.js @@ -34,7 +34,7 @@ assert.sameValue( false, 'precondition: isConstructor(parseInt) must return false' ); -var a = []; +var a = new SendableArray(); a.constructor = {}; a.constructor[Symbol.species] = parseInt; assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible-spreadable.js b/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible-spreadable.js index 491c46d627e..fd93d253286 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible-spreadable.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible-spreadable.js @@ -34,7 +34,7 @@ var A = function(_length) { this.length = 0; Object.preventExtensions(this); }; -var arr = []; +var arr = new SendableArray(); arr.constructor = {}; arr.constructor[Symbol.species] = A; assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible.js b/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible.js index a45e4f1d59b..a16b8c6db09 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible.js @@ -34,7 +34,7 @@ var A = function(_length) { this.length = 0; Object.preventExtensions(this); }; -var arr = []; +var arr = new SendableArray(); arr.constructor = {}; arr.constructor[Symbol.species] = A; assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-null.js b/test/sendable/builtins/Array/prototype/concat/create-species-null.js index 78d0bd32185..fde607f2537 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-null.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-null.js @@ -30,7 +30,7 @@ info: | features: [Symbol.species] ---*/ -var a = []; +var a = new SendableArray(); var result; a.constructor = {}; a.constructor[Symbol.species] = null; diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-poisoned.js b/test/sendable/builtins/Array/prototype/concat/create-species-poisoned.js index 1774333caae..5bf3324f323 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-poisoned.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-poisoned.js @@ -25,7 +25,7 @@ info: | features: [Symbol.species] ---*/ -var a = []; +var a = new SendableArray(); a.constructor = {}; Object.defineProperty(a.constructor, Symbol.species, { get: function() { diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-undef.js b/test/sendable/builtins/Array/prototype/concat/create-species-undef.js index e017fac4331..916b2f04142 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-undef.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-undef.js @@ -28,7 +28,7 @@ info: | features: [Symbol.species] ---*/ -var a = []; +var a = new SendableArray(); var result; a.constructor = {}; a.constructor[Symbol.species] = undefined; diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js index 6f58108196b..50fcc5679fd 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js @@ -36,7 +36,7 @@ var A = function(_length) { configurable: false, }); }; -var arr = []; +var arr = new SendableArray(); arr.constructor = {}; arr.constructor[Symbol.species] = A; assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property.js b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property.js index 79ed2b767de..d3b9be24d59 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property.js @@ -35,7 +35,7 @@ var A = function(_length) { configurable: false, }); }; -var arr = []; +var arr = new SendableArray(); arr.constructor = {}; arr.constructor[Symbol.species] = A; assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js index fdaf8760053..c3207ec24d6 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js @@ -36,7 +36,7 @@ var A = function(_length) { configurable: true, }); }; -var arr = []; +var arr = new SendableArray(); arr.constructor = {}; arr.constructor[Symbol.species] = A; var res = arr.concat([2]); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property.js index b9b1e6b74aa..f0d46a3f348 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property.js @@ -36,7 +36,7 @@ var A = function(_length) { configurable: true, }); }; -var arr = []; +var arr = new SendableArray(); arr.constructor = {}; arr.constructor[Symbol.species] = A; var res = arr.concat(2); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species.js b/test/sendable/builtins/Array/prototype/concat/create-species.js index f1191afbccb..c51a1fcb2f9 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species.js @@ -29,14 +29,14 @@ features: [Symbol.species] var thisValue, args, result; var callCount = 0; -var instance = []; +var instance = new SendableArray(); var Ctor = function() { callCount += 1; thisValue = this; args = arguments; return instance; }; -var a = []; +var a = new SendableArray(); a.constructor = {}; a.constructor[Symbol.species] = Ctor; result = a.concat(); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-order.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-order.js index 4d7ae64937c..977f9b816aa 100644 --- a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-order.js +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-order.js @@ -47,7 +47,7 @@ var descSpreadable = { }, configurable: true, }; -var arr1 = []; +var arr1 = new SendableArray(); Object.defineProperty(arr1, "constructor", descConstructor); Object.defineProperty(arr1, Symbol.isConcatSpreadable, descSpreadable); @@ -58,7 +58,7 @@ assert.compareArray( 'The value of calls is expected to be ["constructor", "isConcatSpreadable"]' ); calls = []; -var arr2 = []; +var arr2 = new SendableArray(); var arg = {}; Object.defineProperty(arr2, "constructor", descConstructor); Object.defineProperty(arg, Symbol.isConcatSpreadable, descSpreadable); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js index e0609ac012d..5c37eb0d0b9 100644 --- a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js @@ -37,7 +37,7 @@ info: | features: [Proxy, Symbol.isConcatSpreadable] ---*/ -var target = []; +var target = new SendableArray(); var handle = Proxy.revocable(target, { get: function(_, key) { // Defer proxy revocation until after property access to ensure that the diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js index d3c4e8b3f96..af0fce89264 100644 --- a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js @@ -38,5 +38,5 @@ features: [Proxy] var handle = Proxy.revocable([], {}); handle.revoke(); assert.throws(TypeError, function() { - [].concat(handle.proxy); + new SendableArray().concat(handle.proxy); }, '[].concat(handle.proxy) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy.js index 6119460a388..e74e5444024 100644 --- a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy.js +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy.js @@ -45,10 +45,10 @@ spreadable[Symbol.isConcatSpreadable] = true; var spreadableProxy = new Proxy(spreadable, {}); assert.sameValue([].concat(arrayProxy).length, 0, 'The value of [].concat(arrayProxy).length is expected to be 0'); assert.sameValue( - [].concat(arrayProxyProxy).length, 0, 'The value of [].concat(arrayProxyProxy).length is expected to be 0' + new SendableArray().concat(arrayProxyProxy).length, 0, 'The value of [].concat(arrayProxyProxy).length is expected to be 0' ); assert.sameValue( - [].concat(spreadableProxy).length, + new SendableArray().concat(spreadableProxy).length, 0, 'The value of [].concat(spreadableProxy).length is expected to be 0' ); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-falsey.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-falsey.js index 149be4ce8c6..b0736cbb860 100644 --- a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-falsey.js +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-falsey.js @@ -39,21 +39,21 @@ info: | features: [Symbol.isConcatSpreadable] ---*/ -var item = [1, 2]; +var item = new SendableArray(1, 2); var result; item[Symbol.isConcatSpreadable] = null; -result = [].concat(item); +result = new SendableArray().concat(item); assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); item[Symbol.isConcatSpreadable] = false; -result = [].concat(item); +result = new SendableArray().concat(item); assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); item[Symbol.isConcatSpreadable] = 0; -result = [].concat(item); +result = new SendableArray().concat(item); assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); item[Symbol.isConcatSpreadable] = NaN; -result = [].concat(item); +result = new SendableArray().concat(item); assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-truthy.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-truthy.js index 91eed2edd46..8a29c801726 100644 --- a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-truthy.js +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-truthy.js @@ -41,17 +41,17 @@ features: [Symbol, Symbol.isConcatSpreadable] var item = {}; var result; item[Symbol.isConcatSpreadable] = true; -result = [].concat(item); +result = new SendableArray().concat(item); assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); item[Symbol.isConcatSpreadable] = 86; -result = [].concat(item); +result = new SendableArray().concat(item); assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); item[Symbol.isConcatSpreadable] = 'string'; -result = [].concat(item); +result = new SendableArray().concat(item); assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); item[Symbol.isConcatSpreadable] = Symbol(); -result = [].concat(item); +result = new SendableArray().concat(item); assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); item[Symbol.isConcatSpreadable] = {}; -result = [].concat(item); +result = new SendableArray().concat(item); assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-undefined.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-undefined.js index 9ff95202f7f..54e079c5111 100644 --- a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-undefined.js +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-undefined.js @@ -40,8 +40,8 @@ info: | features: [Symbol.isConcatSpreadable] ---*/ -var item = []; +var item = new SendableArray(); var result; item[Symbol.isConcatSpreadable] = undefined; -result = [].concat(item); +result = new SendableArray().concat(item); assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); -- Gitee From 506f3135016aab38a3cd1ef0aa8cba006b7f5d55 Mon Sep 17 00:00:00 2001 From: zhuzhihui7 Date: Tue, 21 Jan 2025 16:49:03 +0800 Subject: [PATCH 93/93] add concat again Signed-off-by: zhuzhihui7 --- .../builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js | 2 +- .../builtins/Array/prototype/concat/S15.4.4.4_A1_T3.js | 2 +- .../builtins/Array/prototype/concat/S15.4.4.4_A1_T4.js | 2 +- .../builtins/Array/prototype/concat/S15.4.4.4_A3_T1.js | 2 +- .../builtins/Array/prototype/concat/S15.4.4.4_A3_T2.js | 2 +- .../builtins/Array/prototype/concat/S15.4.4.4_A3_T3.js | 2 +- .../concat/arg-length-exceeding-integer-limit.js | 4 ++-- .../prototype/concat/arg-length-near-integer-limit.js | 2 +- .../concat_array-like-length-to-string-throws.js | 2 +- .../concat/concat_array-like-length-value-of-throws.js | 2 +- .../concat_array-like-primitive-non-number-length.js | 4 ++-- .../concat/concat_array-like-string-length.js | 2 +- .../concat/concat_array-like-to-length-throws.js | 2 +- .../prototype/concat/concat_holey-sloppy-arguments.js | 2 +- .../Array/prototype/concat/concat_length-throws.js | 2 +- .../prototype/concat/concat_sloppy-arguments-throws.js | 2 +- .../concat/concat_sloppy-arguments-with-dupes.js | 4 ++-- .../Array/prototype/concat/concat_sloppy-arguments.js | 4 ++-- .../concat/concat_spreadable-number-wrapper.js | 10 +++++----- .../concat/concat_spreadable-sparse-object.js | 2 +- .../Array/prototype/concat/concat_strict-arguments.js | 4 ++-- .../Array/prototype/concat/create-ctor-non-object.js | 8 ++++---- .../Array/prototype/concat/create-ctor-poisoned.js | 2 +- .../concat/create-proto-from-ctor-realm-array.js | 8 ++++---- .../concat/create-proto-from-ctor-realm-non-array.js | 2 +- .../builtins/Array/prototype/concat/create-proxy.js | 2 +- .../Array/prototype/concat/create-species-abrupt.js | 2 +- .../Array/prototype/concat/create-species-non-ctor.js | 2 +- .../concat/create-species-non-extensible-spreadable.js | 2 +- .../prototype/concat/create-species-non-extensible.js | 2 +- .../Array/prototype/concat/create-species-null.js | 2 +- .../Array/prototype/concat/create-species-poisoned.js | 2 +- .../Array/prototype/concat/create-species-undef.js | 2 +- ...pecies-with-non-configurable-property-spreadable.js | 2 +- .../create-species-with-non-configurable-property.js | 2 +- ...te-species-with-non-writable-property-spreadable.js | 2 +- .../create-species-with-non-writable-property.js | 2 +- .../builtins/Array/prototype/concat/create-species.js | 4 ++-- .../prototype/concat/is-concat-spreadable-get-order.js | 4 ++-- .../is-concat-spreadable-is-array-proxy-revoked.js | 2 +- .../concat/is-concat-spreadable-proxy-revoked.js | 2 +- .../prototype/concat/is-concat-spreadable-proxy.js | 4 ++-- .../concat/is-concat-spreadable-val-falsey.js | 10 +++++----- .../concat/is-concat-spreadable-val-truthy.js | 10 +++++----- .../concat/is-concat-spreadable-val-undefined.js | 4 ++-- 45 files changed, 72 insertions(+), 72 deletions(-) diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js index 12b06d51b41..13a80f3ea6c 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T2.js @@ -22,7 +22,7 @@ es5id: 15.4.4.4_A1_T2 description: Checking this algorithm, items are objects and primitives ---*/ -var x = new SendableArray(0); +var x = [0]; var y = new Object(); var z = new SendableArray(1, 2); var arr = x.concat(y, z, -1, true, "NaN"); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T3.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T3.js index 377788fff3f..d879bb2e20a 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T3.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T3.js @@ -22,7 +22,7 @@ es5id: 15.4.4.4_A1_T3 description: Checking this algorithm with no items ---*/ -var x = new SendableArray(0, 1); +var x = [0, 1]; var arr = x.concat(); arr.getClass = Object.prototype.toString; assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T4.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T4.js index 5d442d37ecc..2c5ceed5543 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T4.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A1_T4.js @@ -22,7 +22,7 @@ es5id: 15.4.4.4_A1_T4 description: Checking this algorithm, items are [], [,] ---*/ -var x = new SendableArray(undefined, 1); +var x = [, 1]; var arr = x.concat([], [, ]); arr.getClass = Object.prototype.toString; assert.sameValue(arr.getClass(), "[object Array]", 'arr.getClass() must return "[object Array]"'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T1.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T1.js index cba2730c951..dc5ce76240c 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T1.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T1.js @@ -23,7 +23,7 @@ description: > ---*/ SendableArray.prototype[1] = 1; -var x = new SendableArray(0); +var x = [0]; x.length = 2; var arr = x.concat(); assert.sameValue(arr[0], 0, 'The value of arr[0] is expected to be 0'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T2.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T2.js index 2ee2075ea7e..5edc3e6d66f 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T2.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T2.js @@ -20,7 +20,7 @@ description: > checking whether non-ownProperties are seen, copied by Array.prototype.concat: Array.prototype[1] ---*/ -var a = new SendableArray(0); +var a = [0]; assert.sameValue(a.length, 1, 'The value of a.length is expected to be 1'); a.length = 3; assert.sameValue(a[1], undefined, 'The value of a[1] is expected to equal undefined'); diff --git a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T3.js b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T3.js index 5e523ec2a36..faca42ffbd0 100644 --- a/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T3.js +++ b/test/sendable/builtins/Array/prototype/concat/S15.4.4.4_A3_T3.js @@ -21,7 +21,7 @@ description: > checking whether non-ownProperties are seen, copied by Array.prototype.concat: Object.prototype[1] ---*/ -var a = new SendableArray(0); +var a = [0]; assert.sameValue(a.length, 1, 'The value of a.length is expected to be 1'); a.length = 3; assert.sameValue(a[1], undefined, 'The value of a[1] is expected to equal undefined'); diff --git a/test/sendable/builtins/Array/prototype/concat/arg-length-exceeding-integer-limit.js b/test/sendable/builtins/Array/prototype/concat/arg-length-exceeding-integer-limit.js index 40e2f257ed7..e98d363be71 100644 --- a/test/sendable/builtins/Array/prototype/concat/arg-length-exceeding-integer-limit.js +++ b/test/sendable/builtins/Array/prototype/concat/arg-length-exceeding-integer-limit.js @@ -34,7 +34,7 @@ var spreadableLengthOutOfRange = {}; spreadableLengthOutOfRange.length = Number.MAX_SAFE_INTEGER; spreadableLengthOutOfRange[Symbol.isConcatSpreadable] = true; assert.throws(TypeError, function() { - new SendableArray(1).concat(spreadableLengthOutOfRange); + [1].concat(spreadableLengthOutOfRange); }, '[1].concat(spreadableLengthOutOfRange) throws a TypeError exception'); var proxyForArrayWithLengthOutOfRange = new Proxy([], { get: function(_target, key) { @@ -44,5 +44,5 @@ var proxyForArrayWithLengthOutOfRange = new Proxy([], { }, }); assert.throws(TypeError, function() { - new SendableArray().concat(1, proxyForArrayWithLengthOutOfRange); + [].concat(1, proxyForArrayWithLengthOutOfRange); }, '[].concat(1, proxyForArrayWithLengthOutOfRange) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/arg-length-near-integer-limit.js b/test/sendable/builtins/Array/prototype/concat/arg-length-near-integer-limit.js index 747892a9d01..729b3b779ac 100644 --- a/test/sendable/builtins/Array/prototype/concat/arg-length-near-integer-limit.js +++ b/test/sendable/builtins/Array/prototype/concat/arg-length-near-integer-limit.js @@ -43,5 +43,5 @@ var spreadableHasPoisonedIndex = { }; spreadableHasPoisonedIndex[Symbol.isConcatSpreadable] = true; assert.throws(Test262Error, function() { - new SendableArray().concat(spreadableHasPoisonedIndex); + [].concat(spreadableHasPoisonedIndex); }, '[].concat(spreadableHasPoisonedIndex) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-to-string-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-to-string-throws.js index 264892bc2d4..49a8ac137c6 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-to-string-throws.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-to-string-throws.js @@ -30,5 +30,5 @@ var objWithPoisonedLengthToString = { }; objWithPoisonedLengthToString[Symbol.isConcatSpreadable] = true; assert.throws(Test262Error, function() { - new SendableArray().concat(objWithPoisonedLengthToString); + [].concat(objWithPoisonedLengthToString); }, '[].concat(objWithPoisonedLengthToString) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-value-of-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-value-of-throws.js index b3373890649..20d57091195 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-value-of-throws.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-length-value-of-throws.js @@ -30,5 +30,5 @@ var objWithPoisonedLengthValueOf = { }; objWithPoisonedLengthValueOf[Symbol.isConcatSpreadable] = true; assert.throws(Test262Error, function() { - new SendableArray().concat(objWithPoisonedLengthValueOf); + [].concat(objWithPoisonedLengthValueOf); }, '[].concat(objWithPoisonedLengthValueOf) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-primitive-non-number-length.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-primitive-non-number-length.js index a7e26b34e94..96a658d3ae8 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_array-like-primitive-non-number-length.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-primitive-non-number-length.js @@ -30,11 +30,11 @@ obj.length = { }, valueOf: null }; -assert.compareArray(new SendableArray().concat(obj), [], '[].concat({"1": "A", "3": "B", "5": "C"}) must return []'); +assert.compareArray([].concat(obj), [], '[].concat({"1": "A", "3": "B", "5": "C"}) must return []'); obj.length = { toString: null, valueOf: function() { return "SIX"; } }; -assert.compareArray(new SendableArray().concat(obj), [], '[].concat({"1": "A", "3": "B", "5": "C"}) must return []'); +assert.compareArray([].concat(obj), [], '[].concat({"1": "A", "3": "B", "5": "C"}) must return []'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-string-length.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-string-length.js index da49d7c2d07..993ea37d45c 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_array-like-string-length.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-string-length.js @@ -31,7 +31,7 @@ var obj2 = { "1": "1", "2": "2" }; -var arr = new SendableArray("X", "Y", "Z"); +var arr = ["X", "Y", "Z"]; var expected = [ void 0, "A", void 0, "B", void 0, "C", obj2, diff --git a/test/sendable/builtins/Array/prototype/concat/concat_array-like-to-length-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_array-like-to-length-throws.js index 8e33a6cab41..9dd87a297db 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_array-like-to-length-throws.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_array-like-to-length-throws.js @@ -33,7 +33,7 @@ var obj2 = { "1": "1", "2": "2" }; -var arr = new SendableArray("X", "Y", "Z"); +var arr = ["X", "Y", "Z"]; assert.throws(TypeError, function() { SendableArray.prototype.concat.call(spreadableWithBrokenLength, obj2, arr); }, 'SendableArray.prototype.concat.call(spreadableWithBrokenLength, obj2, arr) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_holey-sloppy-arguments.js b/test/sendable/builtins/Array/prototype/concat/concat_holey-sloppy-arguments.js index 2d1da22df9c..d8066ddcfae 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_holey-sloppy-arguments.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_holey-sloppy-arguments.js @@ -23,6 +23,6 @@ var args = (function(a) { })(1, 2, 3); delete args[1]; args[Symbol.isConcatSpreadable] = true; -assert.compareArray([1, void 0, 3, 1, void 0, 3], new SendableArray().concat(args, args), +assert.compareArray([1, void 0, 3, 1, void 0, 3], [].concat(args, args), '[1, void 0, 3, 1, void 0, 3] must return the same value returned by [].concat(args, args)' ); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_length-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_length-throws.js index 559b15c26af..8508593944c 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_length-throws.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_length-throws.js @@ -25,7 +25,7 @@ Object.defineProperty(spreadablePoisonedLengthGetter, "length", { } }); assert.throws(Test262Error, function() { - new SendableArray().concat(spreadablePoisonedLengthGetter); + [].concat(spreadablePoisonedLengthGetter); }, '[].concat(spreadablePoisonedLengthGetter) throws a Test262Error exception'); assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-throws.js b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-throws.js index c332e3a3e62..92664877181 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-throws.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-throws.js @@ -27,5 +27,5 @@ Object.defineProperty(args, 0, { }); args[Symbol.isConcatSpreadable] = true; assert.throws(Test262Error, function() { - return new SendableArray().concat(args, args); + return [].concat(args, args); }, 'return [].concat(args, args) throws a Test262Error exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-with-dupes.js b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-with-dupes.js index 0f8d3f53a25..35dbd1de8a5 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-with-dupes.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments-with-dupes.js @@ -23,12 +23,12 @@ var args = (function(a, a, a) { return arguments; })(1, 2, 3); args[Symbol.isConcatSpreadable] = true; -assert.compareArray(new SendableArray().concat(args, args), [1, 2, 3, 1, 2, 3], +assert.compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3], '[].concat((function(a, a, a) {return arguments;})(1, 2, 3), (function(a, a, a) {return arguments;})(1, 2, 3)) must return [1, 2, 3, 1, 2, 3]' ); Object.defineProperty(args, "length", { value: 6 }); -assert.compareArray(new SendableArray().concat(args), [1, 2, 3, void 0, void 0, void 0], +assert.compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0], '[].concat((function(a, a, a) {return arguments;})(1, 2, 3)) must return [1, 2, 3, void 0, void 0, void 0]' ); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments.js b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments.js index e67aa8821f4..daee5f4c937 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_sloppy-arguments.js @@ -22,12 +22,12 @@ var args = (function(a, b, c) { return arguments; })(1, 2, 3); args[Symbol.isConcatSpreadable] = true; -assert.compareArray(new SendableArray().concat(args, args), [1, 2, 3, 1, 2, 3], +assert.compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3], '[].concat((function(a, b, c) {return arguments;})(1, 2, 3), (function(a, b, c) {return arguments;})(1, 2, 3)) must return [1, 2, 3, 1, 2, 3]' ); Object.defineProperty(args, "length", { value: 6 }); -assert.compareArray(new SendableArray().concat(args), [1, 2, 3, void 0, void 0, void 0], +assert.compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0], '[].concat((function(a, b, c) {return arguments;})(1, 2, 3)) must return [1, 2, 3, void 0, void 0, void 0]' ); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-number-wrapper.js b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-number-wrapper.js index efe82792098..63db81933a6 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-number-wrapper.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-number-wrapper.js @@ -20,26 +20,26 @@ features: [Symbol.isConcatSpreadable] ---*/ var num = new Number(true) // Number wrapper objects are not concat-spreadable by default -assert.compareArray([num], new SendableArray().concat(num), '[num] must return the same value returned by [].concat(num)'); +assert.compareArray([num], [].concat(num), '[num] must return the same value returned by [].concat(num)'); // Number wrapper objects may be individually concat-spreadable num[Symbol.isConcatSpreadable] = true; num.length = 3; num[0] = 1, num[1] = 2, num[2] = 3; -assert.compareArray([1, 2, 3], new SendableArray().concat(num), '[1, 2, 3] must return the same value returned by [].concat(num)'); +assert.compareArray([1, 2, 3], [].concat(num), '[1, 2, 3] must return the same value returned by [].concat(num)'); Number.prototype[Symbol.isConcatSpreadable] = true; // Number wrapper objects may be concat-spreadable -assert.compareArray([], new SendableArray().concat(new Number(123)), +assert.compareArray([], [].concat(new Number(123)), '[] must return the same value returned by [].concat(new Number(123))' ); Number.prototype[0] = 1; Number.prototype[1] = 2; Number.prototype[2] = 3; Number.prototype.length = 3; -assert.compareArray([1, 2, 3], new SendableArray().concat(new Number(123)), +assert.compareArray([1, 2, 3], [].concat(new Number(123)), '[1, 2, 3] must return the same value returned by [].concat(new Number(123))' ); // Number values are never concat-spreadable -assert.compareArray([true], new SendableArray().concat(true), '[true] must return the same value returned by [].concat(true)'); +assert.compareArray([true], [].concat(true), '[true] must return the same value returned by [].concat(true)'); delete Number.prototype[Symbol.isConcatSpreadable]; delete Number.prototype[0]; delete Number.prototype[1]; diff --git a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-sparse-object.js b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-sparse-object.js index 53513cafead..89b74357213 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_spreadable-sparse-object.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_spreadable-sparse-object.js @@ -26,6 +26,6 @@ assert.compareArray([void 0, void 0, void 0, void 0, void 0], [].concat(obj), '[void 0, void 0, void 0, void 0, void 0] must return the same value returned by [].concat(obj)' ); obj.length = 4000; -assert.compareArray(new SendableArray(4000), new SendableArray().concat(obj), +assert.compareArray(new SendableArray(4000), [].concat(obj), 'new SendableArray(4000) must return the same value returned by [].concat(obj)' ); diff --git a/test/sendable/builtins/Array/prototype/concat/concat_strict-arguments.js b/test/sendable/builtins/Array/prototype/concat/concat_strict-arguments.js index 476a4077cb2..3017642060e 100644 --- a/test/sendable/builtins/Array/prototype/concat/concat_strict-arguments.js +++ b/test/sendable/builtins/Array/prototype/concat/concat_strict-arguments.js @@ -23,12 +23,12 @@ var args = (function(a, b, c) { return arguments; })(1, 2, 3); args[Symbol.isConcatSpreadable] = true; -assert.compareArray(new SendableArray().concat(args, args), [1, 2, 3, 1, 2, 3], +assert.compareArray([].concat(args, args), [1, 2, 3, 1, 2, 3], '[].concat("(function(a, b, c) {"use strict"; return arguments;})(1, 2, 3)", "(function(a, b, c) {"use strict"; return arguments;})(1, 2, 3)") must return [1, 2, 3, 1, 2, 3]' ); Object.defineProperty(args, "length", { value: 6 }); -assert.compareArray(new SendableArray().concat(args), [1, 2, 3, void 0, void 0, void 0], +assert.compareArray([].concat(args), [1, 2, 3, void 0, void 0, void 0], '[].concat("(function(a, b, c) {"use strict"; return arguments;})(1, 2, 3)") must return [1, 2, 3, void 0, void 0, void 0]' ); diff --git a/test/sendable/builtins/Array/prototype/concat/create-ctor-non-object.js b/test/sendable/builtins/Array/prototype/concat/create-ctor-non-object.js index 4151adbdb55..40fd42325ca 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-ctor-non-object.js +++ b/test/sendable/builtins/Array/prototype/concat/create-ctor-non-object.js @@ -27,22 +27,22 @@ info: | [...] 9. If IsConstructor(C) is false, throw a TypeError exception. ---*/ -var a = new SendableArray(); +var a = []; a.constructor = null; assert.throws(TypeError, function() { a.concat(); }, 'a.concat() throws a TypeError exception'); -a = new SendableArray(); +a = []; a.constructor = 1; assert.throws(TypeError, function() { a.concat(); }, 'a.concat() throws a TypeError exception'); -a = new SendableArray(); +a = []; a.constructor = 'string'; assert.throws(TypeError, function() { a.concat(); }, 'a.concat() throws a TypeError exception'); -a = new SendableArray(); +a = []; a.constructor = true; assert.throws(TypeError, function() { a.concat(); diff --git a/test/sendable/builtins/Array/prototype/concat/create-ctor-poisoned.js b/test/sendable/builtins/Array/prototype/concat/create-ctor-poisoned.js index 306639cc35a..6b8a080a721 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-ctor-poisoned.js +++ b/test/sendable/builtins/Array/prototype/concat/create-ctor-poisoned.js @@ -23,7 +23,7 @@ info: | 5. Let C be ? Get(originalArray, "constructor"). ---*/ -var a = new SendableArray(); +var a = []; Object.defineProperty(a, 'constructor', { get: function() { throw new Test262Error(); diff --git a/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-array.js b/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-array.js index f832f26e608..13160e5d50f 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-array.js +++ b/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-array.js @@ -32,9 +32,9 @@ info: | features: [cross-realm, Symbol.species] ---*/ -var array = new SendableArray(); +var array = []; var callCount = 0; -var OArray = $262.createRealm().global.SendableArray; +var OArray = $262.createRealm().global.Array; var speciesDesc = { get: function() { callCount += 1; @@ -43,14 +43,14 @@ var speciesDesc = { var result; array.constructor = OArray; -Object.defineProperty(Array, Symbol.species, speciesDesc); +Object.defineProperty(SendableArray, Symbol.species, speciesDesc); Object.defineProperty(OArray, Symbol.species, speciesDesc); result = array.concat(); assert.sameValue( Object.getPrototypeOf(result), - Array.prototype, + SendableArray.prototype, 'Object.getPrototypeOf(array.concat()) returns Array.prototype' ); assert.sameValue(callCount, 0, 'The value of callCount is expected to be 0'); diff --git a/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js b/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js index 96bc27438af..45da43f570c 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js +++ b/test/sendable/builtins/Array/prototype/concat/create-proto-from-ctor-realm-non-array.js @@ -32,7 +32,7 @@ info: | features: [cross-realm, Symbol.species] ---*/ -var array = new SendableArray(); +var array = []; var callCount = 0; var CustomCtor = function() {}; var OObject = $262.createRealm().global.Object; diff --git a/test/sendable/builtins/Array/prototype/concat/create-proxy.js b/test/sendable/builtins/Array/prototype/concat/create-proxy.js index cfcc1964b6c..467ee3bb8ec 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-proxy.js +++ b/test/sendable/builtins/Array/prototype/concat/create-proxy.js @@ -34,7 +34,7 @@ info: | features: [Proxy, Symbol.species] ---*/ -var array = new SendableArray(); +var array = []; var proxy = new Proxy(new Proxy(array, {}), {}); var Ctor = function() {}; var result; diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-abrupt.js b/test/sendable/builtins/Array/prototype/concat/create-species-abrupt.js index 0a1a692cc29..ae29a921b02 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-abrupt.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-abrupt.js @@ -33,7 +33,7 @@ features: [Symbol.species] var Ctor = function() { throw new Test262Error(); }; -var a = new SendableArray(); +var a = []; a.constructor = {}; a.constructor[Symbol.species] = Ctor; assert.throws(Test262Error, function() { diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-non-ctor.js b/test/sendable/builtins/Array/prototype/concat/create-species-non-ctor.js index 76d075ae999..507a2c2607c 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-non-ctor.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-non-ctor.js @@ -34,7 +34,7 @@ assert.sameValue( false, 'precondition: isConstructor(parseInt) must return false' ); -var a = new SendableArray(); +var a = []; a.constructor = {}; a.constructor[Symbol.species] = parseInt; assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible-spreadable.js b/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible-spreadable.js index fd93d253286..491c46d627e 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible-spreadable.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible-spreadable.js @@ -34,7 +34,7 @@ var A = function(_length) { this.length = 0; Object.preventExtensions(this); }; -var arr = new SendableArray(); +var arr = []; arr.constructor = {}; arr.constructor[Symbol.species] = A; assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible.js b/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible.js index a16b8c6db09..a45e4f1d59b 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-non-extensible.js @@ -34,7 +34,7 @@ var A = function(_length) { this.length = 0; Object.preventExtensions(this); }; -var arr = new SendableArray(); +var arr = []; arr.constructor = {}; arr.constructor[Symbol.species] = A; assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-null.js b/test/sendable/builtins/Array/prototype/concat/create-species-null.js index fde607f2537..78d0bd32185 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-null.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-null.js @@ -30,7 +30,7 @@ info: | features: [Symbol.species] ---*/ -var a = new SendableArray(); +var a = []; var result; a.constructor = {}; a.constructor[Symbol.species] = null; diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-poisoned.js b/test/sendable/builtins/Array/prototype/concat/create-species-poisoned.js index 5bf3324f323..1774333caae 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-poisoned.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-poisoned.js @@ -25,7 +25,7 @@ info: | features: [Symbol.species] ---*/ -var a = new SendableArray(); +var a = []; a.constructor = {}; Object.defineProperty(a.constructor, Symbol.species, { get: function() { diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-undef.js b/test/sendable/builtins/Array/prototype/concat/create-species-undef.js index 916b2f04142..e017fac4331 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-undef.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-undef.js @@ -28,7 +28,7 @@ info: | features: [Symbol.species] ---*/ -var a = new SendableArray(); +var a = []; var result; a.constructor = {}; a.constructor[Symbol.species] = undefined; diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js index 50fcc5679fd..6f58108196b 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property-spreadable.js @@ -36,7 +36,7 @@ var A = function(_length) { configurable: false, }); }; -var arr = new SendableArray(); +var arr = []; arr.constructor = {}; arr.constructor[Symbol.species] = A; assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property.js b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property.js index d3b9be24d59..79ed2b767de 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-configurable-property.js @@ -35,7 +35,7 @@ var A = function(_length) { configurable: false, }); }; -var arr = new SendableArray(); +var arr = []; arr.constructor = {}; arr.constructor[Symbol.species] = A; assert.throws(TypeError, function() { diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js index c3207ec24d6..fdaf8760053 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property-spreadable.js @@ -36,7 +36,7 @@ var A = function(_length) { configurable: true, }); }; -var arr = new SendableArray(); +var arr = []; arr.constructor = {}; arr.constructor[Symbol.species] = A; var res = arr.concat([2]); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property.js b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property.js index f0d46a3f348..b9b1e6b74aa 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species-with-non-writable-property.js @@ -36,7 +36,7 @@ var A = function(_length) { configurable: true, }); }; -var arr = new SendableArray(); +var arr = []; arr.constructor = {}; arr.constructor[Symbol.species] = A; var res = arr.concat(2); diff --git a/test/sendable/builtins/Array/prototype/concat/create-species.js b/test/sendable/builtins/Array/prototype/concat/create-species.js index c51a1fcb2f9..f1191afbccb 100644 --- a/test/sendable/builtins/Array/prototype/concat/create-species.js +++ b/test/sendable/builtins/Array/prototype/concat/create-species.js @@ -29,14 +29,14 @@ features: [Symbol.species] var thisValue, args, result; var callCount = 0; -var instance = new SendableArray(); +var instance = []; var Ctor = function() { callCount += 1; thisValue = this; args = arguments; return instance; }; -var a = new SendableArray(); +var a = []; a.constructor = {}; a.constructor[Symbol.species] = Ctor; result = a.concat(); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-order.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-order.js index 977f9b816aa..4d7ae64937c 100644 --- a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-order.js +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-get-order.js @@ -47,7 +47,7 @@ var descSpreadable = { }, configurable: true, }; -var arr1 = new SendableArray(); +var arr1 = []; Object.defineProperty(arr1, "constructor", descConstructor); Object.defineProperty(arr1, Symbol.isConcatSpreadable, descSpreadable); @@ -58,7 +58,7 @@ assert.compareArray( 'The value of calls is expected to be ["constructor", "isConcatSpreadable"]' ); calls = []; -var arr2 = new SendableArray(); +var arr2 = []; var arg = {}; Object.defineProperty(arr2, "constructor", descConstructor); Object.defineProperty(arg, Symbol.isConcatSpreadable, descSpreadable); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js index 5c37eb0d0b9..e0609ac012d 100644 --- a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-is-array-proxy-revoked.js @@ -37,7 +37,7 @@ info: | features: [Proxy, Symbol.isConcatSpreadable] ---*/ -var target = new SendableArray(); +var target = []; var handle = Proxy.revocable(target, { get: function(_, key) { // Defer proxy revocation until after property access to ensure that the diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js index af0fce89264..d3c4e8b3f96 100644 --- a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy-revoked.js @@ -38,5 +38,5 @@ features: [Proxy] var handle = Proxy.revocable([], {}); handle.revoke(); assert.throws(TypeError, function() { - new SendableArray().concat(handle.proxy); + [].concat(handle.proxy); }, '[].concat(handle.proxy) throws a TypeError exception'); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy.js index e74e5444024..6119460a388 100644 --- a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy.js +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-proxy.js @@ -45,10 +45,10 @@ spreadable[Symbol.isConcatSpreadable] = true; var spreadableProxy = new Proxy(spreadable, {}); assert.sameValue([].concat(arrayProxy).length, 0, 'The value of [].concat(arrayProxy).length is expected to be 0'); assert.sameValue( - new SendableArray().concat(arrayProxyProxy).length, 0, 'The value of [].concat(arrayProxyProxy).length is expected to be 0' + [].concat(arrayProxyProxy).length, 0, 'The value of [].concat(arrayProxyProxy).length is expected to be 0' ); assert.sameValue( - new SendableArray().concat(spreadableProxy).length, + [].concat(spreadableProxy).length, 0, 'The value of [].concat(spreadableProxy).length is expected to be 0' ); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-falsey.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-falsey.js index b0736cbb860..149be4ce8c6 100644 --- a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-falsey.js +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-falsey.js @@ -39,21 +39,21 @@ info: | features: [Symbol.isConcatSpreadable] ---*/ -var item = new SendableArray(1, 2); +var item = [1, 2]; var result; item[Symbol.isConcatSpreadable] = null; -result = new SendableArray().concat(item); +result = [].concat(item); assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); item[Symbol.isConcatSpreadable] = false; -result = new SendableArray().concat(item); +result = [].concat(item); assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); item[Symbol.isConcatSpreadable] = 0; -result = new SendableArray().concat(item); +result = [].concat(item); assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); item[Symbol.isConcatSpreadable] = NaN; -result = new SendableArray().concat(item); +result = [].concat(item); assert.sameValue(result.length, 1, 'The value of result.length is expected to be 1'); assert.sameValue(result[0], item, 'The value of result[0] is expected to equal the value of item'); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-truthy.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-truthy.js index 8a29c801726..91eed2edd46 100644 --- a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-truthy.js +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-truthy.js @@ -41,17 +41,17 @@ features: [Symbol, Symbol.isConcatSpreadable] var item = {}; var result; item[Symbol.isConcatSpreadable] = true; -result = new SendableArray().concat(item); +result = [].concat(item); assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); item[Symbol.isConcatSpreadable] = 86; -result = new SendableArray().concat(item); +result = [].concat(item); assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); item[Symbol.isConcatSpreadable] = 'string'; -result = new SendableArray().concat(item); +result = [].concat(item); assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); item[Symbol.isConcatSpreadable] = Symbol(); -result = new SendableArray().concat(item); +result = [].concat(item); assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); item[Symbol.isConcatSpreadable] = {}; -result = new SendableArray().concat(item); +result = [].concat(item); assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); diff --git a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-undefined.js b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-undefined.js index 54e079c5111..9ff95202f7f 100644 --- a/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-undefined.js +++ b/test/sendable/builtins/Array/prototype/concat/is-concat-spreadable-val-undefined.js @@ -40,8 +40,8 @@ info: | features: [Symbol.isConcatSpreadable] ---*/ -var item = new SendableArray(); +var item = []; var result; item[Symbol.isConcatSpreadable] = undefined; -result = new SendableArray().concat(item); +result = [].concat(item); assert.sameValue(result.length, 0, 'The value of result.length is expected to be 0'); -- Gitee